Skip to content
Snippets Groups Projects
Commit 8c3103d8 authored by Joerg Stelzer's avatar Joerg Stelzer Committed by Brian Petersen
Browse files

Remove regtest.pl and regtest.py from TrigValTools

Remove regtest.pl and regtest.py from TrigValTools
parent d9cfc522
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,6 @@ atlas_add_dictionary( TrigValToolsDict
# Install files from the package:
atlas_install_python_modules( python/*.py python/TrigValSteering bin/chainDump.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
atlas_install_scripts( bin/*.py test/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
atlas_install_scripts( bin/*.pl )
atlas_install_data( share/*.json share/*.conf )
# Unit tests:
......
#!/usr/bin/perl -w
use Getopt::Long;
use File::Basename;
use File::Spec;
use File::Copy;
use File::Path;
use constant TRUE => 1;
use constant FALSE => 0;
use constant UNDEFINED => "undefined";
$prog = basename $0;
sub main();
main();
exit -10;
sub main(){
command_line();
$status = regtest();
exit($status);
}
sub prog_error_exit($$){
$failkey = 'FAILURE' if (!defined($failkey));
my ($message,$exitcode) = @_ or die;
print "$prog: $failkey $message\n";
exit($exitcode);
}
sub command_line(){
# parse command arguments and check usage
$debug = FALSE;
$inputfile = '';
$reffile = '';
$failkey = 'FAILURE';
$linematch = 'REGTEST';
my $result = GetOptions ('help' => \$help,
'debug!' => \$debug,
'failkey=s' => \$failkey,
'inputfile=s' => \$inputfile,
'reffile=s' => \$reffile,
'linematch=s' => \$linematch);
if ($help || !$result) {
usage();
prog_error_exit("usage",-1);
}
}
# usage message
sub usage(){
print "
Usage: $prog [options]
Testing tool for comparing marked lines in a log file against a reference
Options:
--help show this information
--debug print debug information, for the script maintainer
--failkey <string> keyword to be printed to indicate to the test
framework that a test has failed, default $failkey
--inputfile <string> specify (athena) log file to take as input
--reffile <string> specifiy reference file, with absolute or reletive path
--linematch <string> only compare lines which match this string
default: REGTEST
Note: this is a perl regexp. See man perlre.
Example to match a particular algorithm:
'TrigJetRec_Cone.+REGTEST'
Return codes: 0 = success, non-zero = failure of some sort.
Technical info:
Lines which match the regular expression
";
}
sub regtest(){
my $newfile = basename($reffile) . ".new";
# extract regression test lines from log file
open NEW, ">$newfile"
or die "$prog: error: failed opening $newfile to write: $!\n";
if (! open LOG, "<$inputfile"){
print "$prog: error: failed opening $inputfile to read: $!\n";
print "-> $failkey Aborting this test\n";
return 2; # go on to next test
}
my $lines=0;
my $result;
while (<LOG>){
if (/$linematch/){
print NEW;
$lines++;
}
}
print "$prog debug: regtest $lines lines matched $linematch in LOG\n" if ($debug);
close LOG;
close NEW;
# check whether any lines matched - if zero it's an error straight away
# and no point in doing the diff
if ($lines == 0){
# print failure keyword here to flag it as an error
print "=== Alert! $failkey no lines matching $linematch were found in log file\n";
$result = 1;
}
# diff the output and the reference
# even if verify is off
print "$prog: debug: diff -U 2 -b $reffile $newfile\n" if ($debug);
my $rc = system("diff -U 2 -b $reffile $newfile ");
if ($rc == 0){
print "=== Output is the same as reference\n";
$result = 0;
} else {
# print failure keyword here to flag it as an error
print "=== Alert! $failkey input file (+) differs from reference (-) \n";
print " If this change is understood, to update the reference file please type:\n";
print " cp ",File::Spec->rel2abs($newfile)," ",File::Spec->rel2abs($reffile),"\n";
$result = 1;
}
print "$prog debug: returning result $result\n" if ($debug);
return $result;
}
#!/usr/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from __future__ import print_function
import re
import argparse
import sys
import os
def main():
commandLine()
global status
status = regtest()
sys.exit(status)
def progErrorExit(message, exitcode):
try:
failkey
except NameError:
failkey = 'FAILURE'
print('regtest.py: %s %s' % (failkey, message))
sys.exit(exitcode)
def commandLine():
global debug
global inputfile
global failkey
global linematch
global reffile
debug = False
inputfile = ''
reffile = ''
failkey = 'FAILURE'
linematch = 'REGTEST'
parser = argparse.ArgumentParser(description = 'usage')
parser.add_argument('--debug',
action = 'store_true',
default = False,
help = 'print debug information, for the script maintainer'
)
parser.add_argument('--failkey',
type = str,
default = 'FAILURE',
help =''' keyword to be printed to indicate to the test framework that a
test has failed, default FAILURE'''
)
parser.add_argument('--linematch',
default = "REGTEST",
type = str,
help = ' only compare lines which match this string default: REGTEST'
)
parser.add_argument('--inputfile',
metavar = '<file>',
type = str,
help = 'specify (athena) log file to take as input'
)
parser.add_argument('--reffile',
metavar = '<file>',
type = str,
help = 'specifiy reference file, with absolute or reletive path'
)
global args
args = parser.parse_args()
if help is True:
usage()
progErrorExit('usage', -1)
def usage():
print('''
Usage: regtest.py [options]
Testing tool for comparing marked lines in a log file against a reference
Options:
--help show this information
--debug print debug information, for the script maintainer
--failkey <string> keyword to be printed to indicate to the test
framework that a test has failed, default ''', failkey,'''
--inputfile <string> specify (athena) log file to take as input
--reffile <string> specifiy reference file, with absolute or reletive path
--linematch <string> only compare lines which match this string
default: REGTEST
Example to match a particular algorithm:
'TrigJetRec_Cone.+REGTEST'
Return codes: False = success, True = failure of some sort.
Technical info:
Lines which match the regular expression
''')
def regtest():
with open(args.inputfile,'r') as inpfile:
matchline = 0
for line in inpfile:
if re.search('REGTEST',line):
matchline += 1
if matchline == 0:
print('=== Alert!', failkey, 'no lines matching', linematch, 'in LOG')
result = True
exit()
if debug is True:
print('regtest.py,: debug: diff -b', args.inputfile, args.reffile)
command = 'diff -b ' + args.inputfile + ' ' + args.reffile
rc = os.system(command)
if rc is False:
print('=== Output is the same as reference.')
# result = False
result = 0
else:
print('''=== Alert!''', failkey, '''input file (<) differs from reference (>)
If this change is understood, to update the reference file please type:
cp ''', args.inputfile, args.reffile)
# result = True
result = 1
if debug is True:
print('regtest.py debug: returning result', result)
return result
if __name__ == '__main__':
main()
......@@ -296,16 +296,15 @@ class RegTestStep(RefComparisonStep):
def __init__(self, name='RegTest'):
super(RegTestStep, self).__init__(name)
self.regex = 'REGTEST'
self.executable = 'regtest.pl'
self.executable = 'diff'
self.input_base_name = 'athena'
self.args += ' --linematch ".*"'
self.auto_report_result = True
self.output_stream = Step.OutputStream.FILE_AND_STDOUT
def configure(self, test):
self.input_file = self.input_base_name+'.regtest'
RefComparisonStep.configure(self, test)
self.args += ' --inputfile {} --reffile {}'.format(self.input_file, self.reference)
self.args += ' -U 2 -b {} {}'.format(self.input_file, self.reference)
Step.configure(self, test)
def prepare_inputs(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment