| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
GaudiTesting.BaseTest.BaseTest Class Reference
Inheritance diagram for GaudiTesting.BaseTest.BaseTest:
[legend]
Collaboration diagram for GaudiTesting.BaseTest.BaseTest:
[legend]

## Public Member Functions
def | __init__ (self)
def | run (self)
def | ValidateOutput (self, stdout, stderr, result)
def | findReferenceBlock (self, reference=None, stdout=None, result=None, causes=None, signature_offset=0, signature=None, id=None)
def | countErrorLines
def | CheckTTreesSummaries (self, stdout=None, result=None, causes=None, trees_dict=None, ignore=r"Basket|.*size|Compression")
def | CheckHistosSummaries (self, stdout=None, result=None, causes=None, dict=None, ignore=None)
def | validateWithReference (self, stdout=None, stderr=None, result=None, causes=None, preproc=None)

## Public Attributes
| program
| args
| reference
| error_reference
| options
| stderr
| timeout
| exit_code
| environment
| unsupported_platforms
| signal
| workdir
| use_temp_dir
| status
| name
| causes
| result
| returnedCode
| out
| err
| proc
| stack_trace
| basedir

## Private Member Functions
def | _expandReferenceFileName (self, reffile)

## Static Private Attributes
| _common_tmpdir = None

## Detailed Description

Definition at line 58 of file BaseTest.py.

## Constructor & Destructor Documentation

def GaudiTesting.BaseTest.BaseTest.__init__ | ( |  | self | ) |

Definition at line 62 of file BaseTest.py.

62 def __init__(self):
63 self.program = ''
64 self.args = []
65 self.reference = ''
66 self.error_reference = ''
67 self.options = ''
68 self.stderr = ''
69 self.timeout = 600
70 self.exit_code = None
71 self.environment = None
72 self.unsupported_platforms = []
73 self.signal = None
74 self.workdir = os.curdir
75 self.use_temp_dir = False
76 #Variables not for users
77 self.status = None
78 self.name = ''
79 self.causes = []
80 self.result = Result(self)
81 self.returnedCode = 0
82 self.out = ''
83 self.err = ''
84 self.proc = None
85 self.stack_trace = None
86 self.basedir = os.getcwd()
87
GaudiTesting.BaseTest.BaseTest.err
err
Definition: BaseTest.py:83
GaudiTesting.BaseTest.BaseTest.basedir
basedir
Definition: BaseTest.py:86
GaudiTesting.BaseTest.BaseTest.options
options
Definition: BaseTest.py:67
GaudiTesting.BaseTest.BaseTest.use_temp_dir
use_temp_dir
Definition: BaseTest.py:75
GaudiTesting.BaseTest.Result
Definition: BaseTest.py:565
GaudiTesting.BaseTest.BaseTest.args
args
Definition: BaseTest.py:64
GaudiTesting.BaseTest.BaseTest.stack_trace
stack_trace
Definition: BaseTest.py:85
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:65
GaudiTesting.BaseTest.BaseTest.program
program
Definition: BaseTest.py:63
GaudiTesting.BaseTest.BaseTest.unsupported_platforms
unsupported_platforms
Definition: BaseTest.py:72
GaudiTesting.BaseTest.BaseTest.__init__
def __init__(self)
Definition: BaseTest.py:62
GaudiTesting.BaseTest.BaseTest.error_reference
error_reference
Definition: BaseTest.py:66
GaudiTesting.BaseTest.BaseTest.stderr
stderr
Definition: BaseTest.py:68
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.BaseTest.proc
proc
Definition: BaseTest.py:84
GaudiTesting.BaseTest.BaseTest.environment
environment
Definition: BaseTest.py:71
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.BaseTest.exit_code
exit_code
Definition: BaseTest.py:70
GaudiTesting.BaseTest.BaseTest.timeout
timeout
Definition: BaseTest.py:69
GaudiTesting.BaseTest.BaseTest.status
status
Definition: BaseTest.py:77
GaudiTesting.BaseTest.BaseTest.workdir
workdir
Definition: BaseTest.py:74
GaudiTesting.BaseTest.BaseTest.returnedCode
returnedCode
Definition: BaseTest.py:81
GaudiTesting.BaseTest.BaseTest.name
name
Definition: BaseTest.py:78
GaudiTesting.BaseTest.BaseTest.signal
signal
Definition: BaseTest.py:73

## Member Function Documentation

def GaudiTesting.BaseTest.BaseTest._expandReferenceFileName | ( |  | self,
|  |  | reffile
| ) |  |
| private

Definition at line 468 of file BaseTest.py.

468 def _expandReferenceFileName(self, reffile):
469 # if no file is passed, do nothing
470 if not reffile:
471 return ""
472
473 # function to split an extension in constituents parts
474 platformSplit = lambda p: set(p.split('-' in p and '-' or '_'))
475
476 reference = os.path.normpath(os.path.join(self.basedir,
477 os.path.expandvars(reffile)))
478
479 # old-style platform-specific reference name
480 spec_ref = reference[:-3] + GetPlatform(self)[0:3] + reference[-3:]
481 if os.path.isfile(spec_ref):
482 reference = spec_ref
483 else: # look for new-style platform specific reference files:
484 # get all the files whose name start with the reference filename
485 dirname, basename = os.path.split(reference)
486 if not dirname: dirname = '.'
487 head = basename + "."
488 head_len = len(head)
489 platform = platformSplit(GetPlatform(self))
490 if 'do0' in platform:
491 platform.add('dbg')
492 candidates = []
493 for f in os.listdir(dirname):
494 if f.startswith(head):
495 req_plat = platformSplit(f[head_len:])
496 if platform.issuperset(req_plat):
497 candidates.append( (len(req_plat), f) )
498 if candidates: # take the one with highest matching
499 # FIXME: it is not possible to say if x86_64-slc5-gcc43-dbg
500 # has to use ref.x86_64-gcc43 or ref.slc5-dbg
501 candidates.sort()
502 reference = os.path.join(dirname, candidates[-1][1])
503 return reference
504
505 #---------------------------------------------------------------------------------------------------#
506 #---------------------------------------------------------------------------------------------------#
507 #-----------------------------------------GAUDI TOOLS-----------------------------------------------------#
508 #---------------------------------------------------------------------------------------------------#
509 #---------------------------------------------------------------------------------------------------#
510
GaudiTesting.BaseTest.BaseTest.basedir
basedir
Definition: BaseTest.py:86
GaudiTesting.BaseTest.GetPlatform
def GetPlatform(self)
Definition: BaseTest.py:1114
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:468

def GaudiTesting.BaseTest.BaseTest.CheckHistosSummaries | ( |  | self,
|  |  | stdout = `None`,
|  |  | result = `None`,
|  |  | causes = `None`,
|  |  | dict = `None`,
|  |  | ignore = `None`
| ) |  |

        Compare the TTree summaries in stdout with the ones in trees_dict or in
        the reference file. By default ignore the size, compression and basket
        fields.
        The presence of TTree summaries when none is expected is not a failure.

Definition at line 375 of file BaseTest.py.

375 ignore = None):
376 """
377 Compare the TTree summaries in stdout with the ones in trees_dict or in
378 the reference file. By default ignore the size, compression and basket
379 fields.
380 The presence of TTree summaries when none is expected is not a failure.
381 """
382 if stdout is None : stdout=self.out
383 if result is None : result=self.result
384 if causes is None : causes=self.causes
385
386 if dict is None:
387 lreference = self._expandReferenceFileName(self.reference)
388 # call the validator if the file exists
389 if lreference and os.path.isfile(lreference):
390 dict = findHistosSummaries(open(lreference).read())
391 else:
392 dict = {}
393
394 from pprint import PrettyPrinter
395 pp = PrettyPrinter()
396 if dict:
397 result["GaudiTest.Histos.expected"] = result.Quote(pp.pformat(dict))
398 if ignore:
399 result["GaudiTest.Histos.ignore"] = result.Quote(ignore)
400
401 histos = findHistosSummaries(stdout)
402 failed = cmpTreesDicts(dict, histos, ignore)
403 if failed:
404 causes.append("histos summaries")
405 msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed)
406 result["GaudiTest.Histos.failure_on"] = result.Quote(msg)
407 result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos))
408
409 return causes
410
GaudiTesting.BaseTest.cmpTreesDicts
def cmpTreesDicts(reference, to_check, ignore=None)
Definition: BaseTest.py:923
hivetimeline.read
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:19
GaudiTesting.BaseTest.findHistosSummaries
def findHistosSummaries(stdout)
Definition: BaseTest.py:1082
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:65
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.getCmpFailingValues
def getCmpFailingValues(reference, to_check, fail_path)
Definition: BaseTest.py:954
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:468

def GaudiTesting.BaseTest.BaseTest.CheckTTreesSummaries | ( |  | self,
|  |  | stdout = `None`,
|  |  | result = `None`,
|  |  | causes = `None`,
|  |  | trees_dict = `None`,
|  |  | ignore = `r"Basket|.*size|Compression"`
| ) |  |

        Compare the TTree summaries in stdout with the ones in trees_dict or in
        the reference file. By default ignore the size, compression and basket
        fields.
        The presence of TTree summaries when none is expected is not a failure.

Definition at line 338 of file BaseTest.py.

338 ignore = r"Basket|.*size|Compression"):
339 """
340 Compare the TTree summaries in stdout with the ones in trees_dict or in
341 the reference file. By default ignore the size, compression and basket
342 fields.
343 The presence of TTree summaries when none is expected is not a failure.
344 """
345 if stdout is None : stdout=self.out
346 if result is None : result=self.result
347 if causes is None : causes=self.causes
348 if trees_dict is None:
349 lreference = self._expandReferenceFileName(self.reference)
350 # call the validator if the file exists
351 if lreference and os.path.isfile(lreference):
352 trees_dict = findTTreeSummaries(open(lreference).read())
353 else:
354 trees_dict = {}
355
356 from pprint import PrettyPrinter
357 pp = PrettyPrinter()
358 if trees_dict:
359 result["GaudiTest.TTrees.expected"] = result.Quote(pp.pformat(trees_dict))
360 if ignore:
361 result["GaudiTest.TTrees.ignore"] = result.Quote(ignore)
362
363 trees = findTTreeSummaries(stdout)
364 failed = cmpTreesDicts(trees_dict, trees, ignore)
365 if failed:
366 causes.append("trees summaries")
367 msg = "%s: %s != %s" % getCmpFailingValues(trees_dict, trees, failed)
368 result["GaudiTest.TTrees.failure_on"] = result.Quote(msg)
369 result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees))
370
371 return causes
372
GaudiTesting.BaseTest.cmpTreesDicts
def cmpTreesDicts(reference, to_check, ignore=None)
Definition: BaseTest.py:923
hivetimeline.read
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:19
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:65
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.getCmpFailingValues
def getCmpFailingValues(reference, to_check, fail_path)
Definition: BaseTest.py:954
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:468
GaudiTesting.BaseTest.findTTreeSummaries
def findTTreeSummaries(stdout)
Definition: BaseTest.py:902

def GaudiTesting.BaseTest.BaseTest.countErrorLines | ( |  | self,
|  |  | expected = `{'ERROR':0`,
|  |  | FATAL
| ) |  |

Definition at line 300 of file BaseTest.py.

300 def countErrorLines(self, expected = {'ERROR':0, 'FATAL':0}, stdout=None, result=None,causes=None):
301 """
302 Count the number of messages with required severity (by default ERROR and FATAL)
303 and check if their numbers match the expected ones (0 by default).
304 The dictionary "expected" can be used to tune the number of errors and fatals
305 allowed, or to limit the number of expected warnings etc.
306 """
307
308 if stdout is None : stdout=self.out
309 if result is None : result=self.result
310 if causes is None : causes=self.causes
311
312 # prepare the dictionary to record the extracted lines
313 errors = {}
314 for sev in expected:
315 errors[sev] = []
316
317 outlines = stdout.splitlines()
318 from math import log10
319 fmt = "%%%dd - %%s" % (int(log10(len(outlines)+1)))
320
321 linecount = 0
322 for l in outlines:
323 linecount += 1
324 words = l.split()
325 if len(words) >= 2 and words[1] in errors:
326 errors[words[1]].append(fmt%(linecount,l.rstrip()))
327
328 for e in errors:
329 if len(errors[e]) != expected[e]:
330 causes.append('%s(%d)'%(e,len(errors[e])))
331 result["GaudiTest.lines.%s"%e] = result.Quote('\n'.join(errors[e]))
332 result["GaudiTest.lines.%s.expected#"%e] = result.Quote(str(expected[e]))
333
334 return causes
335
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.BaseTest.countErrorLines
def countErrorLines
Definition: BaseTest.py:300

def GaudiTesting.BaseTest.BaseTest.findReferenceBlock | ( |  | self,
|  |  | reference = `None`,
|  |  | stdout = `None`,
|  |  | result = `None`,
|  |  | causes = `None`,
|  |  | signature_offset = `0`,
|  |  | signature = `None`,
|  |  | id = `None`
| ) |  |

        Given a block of text, tries to find it in the output. The block had to be identified by a signature line. By default, the first line is used as signature, or the line pointed to by signature_offset. If signature_offset points outside the block, a signature line can be passed as signature argument. Note: if 'signature' is None (the default), a negative signature_offset is interpreted as index in a list (e.g. -1 means the last line), otherwise the it is interpreted as the number of lines before the first one of the block the signature must appear. The parameter 'id' allow to distinguish between different calls to this function in the same validation code.

Definition at line 259 of file BaseTest.py.

259 def findReferenceBlock(self,reference=None, stdout=None, result=None, causes=None, signature_offset=0, signature=None, id = None):
260 """
261 Given a block of text, tries to find it in the output. The block had to be identified by a signature line. By default, the first line is used as signature, or the line pointed to by signature_offset. If signature_offset points outside the block, a signature line can be passed as signature argument. Note: if 'signature' is None (the default), a negative signature_offset is interpreted as index in a list (e.g. -1 means the last line), otherwise the it is interpreted as the number of lines before the first one of the block the signature must appear. The parameter 'id' allow to distinguish between different calls to this function in the same validation code.
262 """
263
264 if reference is None : reference=self.reference
265 if stdout is None : stdout=self.out
266 if result is None : result=self.result
267 if causes is None : causes=self.causes
268
269 reflines = filter(None,map(lambda s: s.rstrip(), reference.splitlines()))
270 if not reflines:
271 raise RuntimeError("Empty (or null) reference")
272 # the same on standard output
273 outlines = filter(None,map(lambda s: s.rstrip(), stdout.splitlines()))
274
275 res_field = "GaudiTest.RefBlock"
276 if id:
277 res_field += "_%s" % id
278
279 if signature is None:
280 if signature_offset < 0:
281 signature_offset = len(reference)+signature_offset
282 signature = reflines[signature_offset]
283 # find the reference block in the output file
284 try:
285 pos = outlines.index(signature)
286 outlines = outlines[pos-signature_offset:pos+len(reflines)-signature_offset]
287 if reflines != outlines:
288 msg = "standard output"
289 # I do not want 2 messages in causes if teh function is called twice
290 if not msg in causes:
291 causes.append(msg)
292 result[res_field + ".observed"] = result.Quote("\n".join(outlines))
293 except ValueError:
294 causes.append("missing signature")
295 result[res_field + ".signature"] = result.Quote(signature)
296 if len(reflines) > 1 or signature != reflines[0]:
297 result[res_field + ".expected"] = result.Quote("\n".join(reflines))
298 return causes
299
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:65
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:25
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.BaseTest.findReferenceBlock
def findReferenceBlock(self, reference=None, stdout=None, result=None, causes=None, signature_offset=0, signature=None, id=None)
Definition: BaseTest.py:259

def GaudiTesting.BaseTest.BaseTest.run | ( |  | self | ) |

Definition at line 88 of file BaseTest.py.

88 def run(self):
89 logging.debug('running test %s', self.name)
90
91 if self.options:
92 if re.search(r'from\s+Gaudi.Configuration\s+import\s+\*|'
93 'from\s+Configurables\s+import', self.options):
94 optionFile = tempfile.NamedTemporaryFile(suffix='.py')
95 else:
96 optionFile = tempfile.NamedTemporaryFile(suffix='.opts')
97 optionFile.file.write(self.options)
98 optionFile.seek(0)
99 self.args.append(RationalizePath(optionFile.name))
100
101 #If not specified, setting the environment
102 if self.environment is None : self.environment = os.environ
103 else : self.environment=dict(self.environment.items()+os.environ.items())
104
105 platform_id = (os.environ.get('BINARY_TAG') or
106 os.environ.get('CMTCONFIG') or
107 platform.platform())
108 # If at least one regex matches we skip the test.
109 skip_test = bool([None
110 for prex in self.unsupported_platforms
111 if re.search(prex, platform_id)])
112
113 if not skip_test:
114 # handle working/temporary directory options
115 workdir = self.workdir
116 if self.use_temp_dir:
117 if self._common_tmpdir:
118 workdir = self._common_tmpdir
119 else:
120 workdir = tempfile.mkdtemp()
121
122 # prepare the command to execute
123 prog=''
124 if self.program != '':
125 prog = self.program
126 elif "GAUDIEXE" in os.environ :
127 prog = os.environ["GAUDIEXE"]
128 else :
129 prog = "Gaudi.exe"
130
131 dummy, prog_ext = os.path.splitext(prog)
132 if prog_ext not in [ ".exe", ".py", ".bat" ]:
133 prog += ".exe"
134 prog_ext = ".exe"
135
136 prog = which(prog) or prog
137
138 args = map(RationalizePath, self.args)
139
140 if prog_ext == ".py" :
141 params = ['python', RationalizePath(prog)] + args
142 else :
143 params = [RationalizePath(prog)] + args
144
145 validatorRes = Result({'CAUSE': None, 'EXCEPTION': None,
146 'RESOURCE': None, 'TARGET': None,
147 'TRACEBACK': None, 'START_TIME': None,
148 'END_TIME': None, 'TIMEOUT_DETAIL': None})
149 self.result = validatorRes
150
151 # we need to switch directory because the validator expects to run
152 # in the same dir as the program
153 os.chdir(workdir)
154
155 #launching test in a different thread to handle timeout exception
156 def target() :
157 logging.debug('executing %r in %s',
158 params, workdir)
159 self.proc = Popen(params, stdout=PIPE, stderr=PIPE,
160 env=self.environment)
161 logging.debug('(pid: %d)', self.proc.pid)
162 self.out, self.err = self.proc.communicate()
163
164 thread = threading.Thread(target=target)
165 thread.start()
166 # catching timeout
167 thread.join(self.timeout)
168
169 if thread.is_alive():
170 logging.debug('time out in test %s (pid %d)', self.name, self.proc.pid)
171 # get the stack trace of the stuck process
172 cmd = ['gdb', '--pid', str(self.proc.pid), '--batch',
173 '--eval-command=thread apply all backtrace']
174 gdb = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
175 self.stack_trace = gdb.communicate()[0]
176
177 kill_tree(self.proc.pid, signal.SIGTERM)
178 thread.join(60)
179 if thread.is_alive():
180 kill_tree(self.proc.pid, signal.SIGKILL)
181 self.causes.append('timeout')
182 else:
183 logging.debug('completed test %s', self.name)
184
185 #Getting the error code
186 logging.debug('returnedCode = %s', self.proc.returncode)
187 self.returnedCode = self.proc.returncode
188
189 logging.debug('validating test...')
190 self.result, self.causes = self.ValidateOutput(stdout=self.out,
191 stderr=self.err,
192 result=validatorRes)
193
194 # remove the temporary directory if we created it
195 if self.use_temp_dir and not self._common_tmpdir:
196 shutil.rmtree(workdir, True)
197
198 os.chdir(self.basedir)
199
200 # handle application exit code
201 if self.signal is not None:
202 if int(self.returnedCode) != -int(self.signal):
203 self.causes.append('exit code')
204
205 elif self.exit_code is not None:
206 if int(self.returnedCode) != int(self.exit_code):
207 self.causes.append('exit code')
208
209 elif self.returnedCode != 0:
210 self.causes.append("exit code")
211
212 if self.causes:
213 self.status = "failed"
214 else:
215 self.status = "passed"
216
217 else:
218 self.status = "skipped"
219
220 logging.debug('%s: %s', self.name, self.status)
221 field_mapping = {'Exit Code': 'returnedCode',
222 'stderr': 'err',
223 'Arguments': 'args',
224 'Environment': 'environment',
225 'Status': 'status',
226 'stdout': 'out',
227 'Program Name': 'program',
228 'Name': 'name',
229 'Validator': 'validator',
230 'Output Reference File': 'reference',
231 'Error Reference File': 'error_reference',
232 'Causes': 'causes',
233 #'Validator Result': 'result.annotations',
234 'Unsupported Platforms': 'unsupported_platforms',
235 'Stack Trace': 'stack_trace'}
236 resultDict = [(key, getattr(self, attr))
237 for key, attr in field_mapping.iteritems()
238 if getattr(self, attr)]
239 resultDict.append(('Working Directory',
240 RationalizePath(os.path.join(os.getcwd(),
241 self.workdir))))
242 #print dict(resultDict).keys()
243 resultDict.extend(self.result.annotations.iteritems())
244 #print self.result.annotations.keys()
245 return dict(resultDict)
246
247
GaudiTesting.BaseTest.BaseTest.err
err
Definition: BaseTest.py:83
GaudiTesting.BaseTest.BaseTest.basedir
basedir
Definition: BaseTest.py:86
GaudiTesting.BaseTest.BaseTest.options
options
Definition: BaseTest.py:67
GaudiTesting.BaseTest.BaseTest.use_temp_dir
use_temp_dir
Definition: BaseTest.py:75
GaudiTesting.BaseTest.Result
Definition: BaseTest.py:565
GaudiTesting.BaseTest.BaseTest.ValidateOutput
def ValidateOutput(self, stdout, stderr, result)
Definition: BaseTest.py:252
GaudiTesting.BaseTest.RationalizePath
def RationalizePath(p)
Definition: BaseTest.py:525
GaudiTesting.BaseTest.BaseTest.args
args
Definition: BaseTest.py:64
GaudiTesting.BaseTest.BaseTest.stack_trace
stack_trace
Definition: BaseTest.py:85
GaudiTesting.BaseTest.BaseTest.run
def run(self)
Definition: BaseTest.py:88
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:25
GaudiTesting.BaseTest.BaseTest.program
program
Definition: BaseTest.py:63
GaudiTesting.BaseTest.BaseTest.unsupported_platforms
unsupported_platforms
Definition: BaseTest.py:72
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.BaseTest.proc
proc
Definition: BaseTest.py:84
GaudiTesting.BaseTest.BaseTest.environment
environment
Definition: BaseTest.py:71
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.which
def which(executable)
Definition: BaseTest.py:535
GaudiTesting.BaseTest.BaseTest.exit_code
exit_code
Definition: BaseTest.py:70
GaudiTesting.BaseTest.BaseTest.timeout
timeout
Definition: BaseTest.py:69
GaudiTesting.BaseTest.BaseTest.status
status
Definition: BaseTest.py:77
GaudiTesting.BaseTest.kill_tree
def kill_tree(ppid, sig)
Definition: BaseTest.py:38
GaudiTesting.BaseTest.BaseTest.workdir
workdir
Definition: BaseTest.py:74
GaudiTesting.BaseTest.BaseTest.returnedCode
returnedCode
Definition: BaseTest.py:81
GaudiTesting.BaseTest.BaseTest.name
name
Definition: BaseTest.py:78
GaudiTesting.BaseTest.BaseTest.signal
signal
Definition: BaseTest.py:73
GaudiTesting.BaseTest.BaseTest._common_tmpdir
_common_tmpdir
Definition: BaseTest.py:60

def GaudiTesting.BaseTest.BaseTest.ValidateOutput | ( |  | self,
|  |  | stdout,
|  |  | stderr,
|  |  | result
| ) |  |

Definition at line 252 of file BaseTest.py.

252 def ValidateOutput(self, stdout, stderr, result):
253 if not self.stderr:
254 self.validateWithReference(stdout, stderr, result, self.causes)
255 elif stderr.strip() != self.stderr.strip():
256 self.causes.append('standard error')
257 return result, self.causes
258
GaudiTesting.BaseTest.BaseTest.validateWithReference
def validateWithReference(self, stdout=None, stderr=None, result=None, causes=None, preproc=None)
Definition: BaseTest.py:412
GaudiTesting.BaseTest.BaseTest.ValidateOutput
def ValidateOutput(self, stdout, stderr, result)
Definition: BaseTest.py:252
GaudiTesting.BaseTest.BaseTest.stderr
stderr
Definition: BaseTest.py:68
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79

def GaudiTesting.BaseTest.BaseTest.validateWithReference | ( |  | self,
|  |  | stdout = `None`,
|  |  | stderr = `None`,
|  |  | result = `None`,
|  |  | causes = `None`,
|  |  | preproc = `None`
| ) |  |

    Default validation acti*on: compare standard output and error to the
    reference files.

Definition at line 412 of file BaseTest.py.

412 causes=None, preproc=None):
413 '''
414 Default validation acti*on: compare standard output and error to the
415 reference files.
416 '''
417
418 if stdout is None : stdout = self.out
419 if stderr is None : stderr = self.err
420 if result is None : result = self.result
421 if causes is None : causes = self.causes
422
423 # set the default output preprocessor
424 if preproc is None:
425 preproc = normalizeExamples
426 # check standard output
427 lreference = self._expandReferenceFileName(self.reference)
428 # call the validator if the file exists
429 if lreference and os.path.isfile(lreference):
430 causes += ReferenceFileValidator(lreference,
431 "standard output",
432 "Output Diff",
433 preproc=preproc)(stdout, result)
434 # Compare TTree summaries
435 causes = self.CheckTTreesSummaries(stdout, result, causes)
436 causes = self.CheckHistosSummaries(stdout, result, causes)
437 if causes: # Write a new reference file for stdout
438 try:
439 newref = open(lreference + ".new","w")
440 # sanitize newlines
441 for l in stdout.splitlines():
442 newref.write(l.rstrip() + '\n')
443 del newref # flush and close
444 except IOError:
445 # Ignore IO errors when trying to update reference files
446 # because we may be in a read-only filesystem
447 pass
448
449 # check standard error
450 lreference = self._expandReferenceFileName(self.error_reference)
451 # call the validator if we have a file to use
452 if lreference and os.path.isfile(lreference):
453 newcauses = ReferenceFileValidator(lreference,
454 "standard error",
455 "Error Diff",
456 preproc=preproc)(stderr, result)
457 causes += newcauses
458 if newcauses: # Write a new reference file for stdedd
459 newref = open(lreference + ".new","w")
460 # sanitize newlines
461 for l in stderr.splitlines():
462 newref.write(l.rstrip() + '\n')
463 del newref # flush and close
464 else:
465 causes += BasicOutputValidator(lreference, "standard error", "ExecTest.expected_stderr")(stderr, result)
466 return causes
467
GaudiTesting.BaseTest.BaseTest.err
err
Definition: BaseTest.py:83
GaudiTesting.BaseTest.ReferenceFileValidator
Definition: BaseTest.py:868
GaudiTesting.BaseTest.BasicOutputValidator
Definition: BaseTest.py:603
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:65
GaudiTesting.BaseTest.BaseTest.error_reference
error_reference
Definition: BaseTest.py:66
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:80
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:82
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:468
GaudiTesting.BaseTest.BaseTest.CheckHistosSummaries
def CheckHistosSummaries(self, stdout=None, result=None, causes=None, dict=None, ignore=None)
Definition: BaseTest.py:375
GaudiTesting.BaseTest.BaseTest.CheckTTreesSummaries
def CheckTTreesSummaries(self, stdout=None, result=None, causes=None, trees_dict=None, ignore=r"Basket|.*size|Compression")
Definition: BaseTest.py:338

## Member Data Documentation

GaudiTesting.BaseTest.BaseTest._common_tmpdir = None
| static private

Definition at line 60 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.args

Definition at line 64 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.basedir

Definition at line 86 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.causes

Definition at line 79 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.environment

Definition at line 71 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.err

Definition at line 83 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.error_reference

Definition at line 66 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.exit_code

Definition at line 70 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.name

Definition at line 78 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.options

Definition at line 67 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.out

Definition at line 82 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.proc

Definition at line 84 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.program

Definition at line 63 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.reference

Definition at line 65 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.result

Definition at line 80 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.returnedCode

Definition at line 81 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.signal

Definition at line 73 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.stack_trace

Definition at line 85 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.status

Definition at line 77 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.stderr

Definition at line 68 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.timeout

Definition at line 69 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.unsupported_platforms

Definition at line 72 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.use_temp_dir

Definition at line 75 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.workdir

Definition at line 74 of file BaseTest.py.

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

- GaudiPolicy/python/GaudiTesting/BaseTest.py