ATLAS Offline Software
Loading...
Searching...
No Matches
python.TrigP1TestSteps.TrigBSDumpGrepStep Class Reference
Inheritance diagram for python.TrigP1TestSteps.TrigBSDumpGrepStep:
Collaboration diagram for python.TrigP1TestSteps.TrigBSDumpGrepStep:

Public Member Functions

 __init__ (self, name='TrigBSDumpGrep')
 run (self, dry_run=False)

Public Attributes

str executable = 'trigbs_dumpHLTContentInBS_run3.py'
str file_name_base = 'output'
bool auto_report_result = True
bool required = True
str regex = ''
int comparator = lambda n: n > 0
 name
int result = 0

Detailed Description

Extra step based on grepping trigbs_dumpHLTContentInBS.py output
and comparing the line count to expected value

Definition at line 17 of file TrigP1TestSteps.py.

Constructor & Destructor Documentation

◆ __init__()

python.TrigP1TestSteps.TrigBSDumpGrepStep.__init__ ( self,
name = 'TrigBSDumpGrep' )

Definition at line 23 of file TrigP1TestSteps.py.

23 def __init__(self, name='TrigBSDumpGrep'):
24 super(TrigBSDumpGrepStep, self).__init__(name)
25 self.executable = 'trigbs_dumpHLTContentInBS_run3.py'
26 self.file_name_base = 'output'
27 self.auto_report_result = True
28 self.required = True
29 self.regex = ''
30 self.comparator = lambda n: n > 0
31

Member Function Documentation

◆ run()

python.TrigP1TestSteps.TrigBSDumpGrepStep.run ( self,
dry_run = False )

Definition at line 32 of file TrigP1TestSteps.py.

32 def run(self, dry_run=False):
33 if dry_run:
34 self.log.info('Skipping %s in dry run', self.name)
35 self.result = 0
36 return self.result, '# (internal) {} -> skipped'.format(self.name)
37 file_name = None
38 for ls_file in os.listdir('.'):
39 if self.file_name_base in ls_file:
40 file_name = ls_file
41 if file_name is None:
42 self.log.error('%s cannot find the BS output file', self.name)
43 self.result = 1
44 if self.auto_report_result:
45 self.report_result()
46 return self.result, '# (internal) {} -> failed'.format(self.name)
47 self.log.debug('%s found BS file %s', self.name, file_name)
48 self.args += ' ' + file_name
49 self.args += ' | grep "{}" | wc -l'.format(self.regex)
50
51 old_auto_report = self.auto_report_result
52 self.auto_report_result = False
53 ret, cmd = super(TrigBSDumpGrepStep, self).run(dry_run)
54 self.auto_report_result = old_auto_report
55
56 if ret != 0:
57 self.log.error('%s failed', self.name)
58 if self.auto_report_result:
59 self.report_result()
60 return self.result, cmd
61
62 if not os.path.isfile(self.get_log_file_name()):
63 self.log.error('%s failed, the file %s is missing',
64 self.name, self.get_log_file_name())
65 self.result = 1
66 if self.auto_report_result:
67 self.report_result()
68 return self.result, cmd
69
70 num = None
71 with open(self.get_log_file_name()) as log_file:
72 num = eval(log_file.read())
73 if not self.comparator(num) or num is None:
74 self.log.error('%s failed the comparison', self.name)
75 self.result = 1
76 if self.auto_report_result:
77 self.report_result()
78 return self.result, cmd
79
80 compare_str_list = inspect.getsource(self.comparator).split(':')
81 compare_str = ''.join(compare_str_list[1:])
82 compare_str = compare_str.strip()
83 self.log.info('Comparison %s for num=%s gives True', compare_str, num)
84 self.result = 0
85 if self.auto_report_result:
86 self.report_result()
87 return self.result, cmd
88
89
const bool debug
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
Definition run.py:1

Member Data Documentation

◆ auto_report_result

bool python.TrigP1TestSteps.TrigBSDumpGrepStep.auto_report_result = True

Definition at line 27 of file TrigP1TestSteps.py.

◆ comparator

int python.TrigP1TestSteps.TrigBSDumpGrepStep.comparator = lambda n: n > 0

Definition at line 30 of file TrigP1TestSteps.py.

◆ executable

str python.TrigP1TestSteps.TrigBSDumpGrepStep.executable = 'trigbs_dumpHLTContentInBS_run3.py'

Definition at line 25 of file TrigP1TestSteps.py.

◆ file_name_base

str python.TrigP1TestSteps.TrigBSDumpGrepStep.file_name_base = 'output'

Definition at line 26 of file TrigP1TestSteps.py.

◆ name

python.TrigP1TestSteps.TrigBSDumpGrepStep.name

Definition at line 34 of file TrigP1TestSteps.py.

◆ regex

str python.TrigP1TestSteps.TrigBSDumpGrepStep.regex = ''

Definition at line 29 of file TrigP1TestSteps.py.

◆ required

bool python.TrigP1TestSteps.TrigBSDumpGrepStep.required = True

Definition at line 28 of file TrigP1TestSteps.py.

◆ result

python.TrigP1TestSteps.TrigBSDumpGrepStep.result = 0

Definition at line 35 of file TrigP1TestSteps.py.


The documentation for this class was generated from the following file: