| The Gaudi Framework v29r0 (ff2e7097)

- 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 65 of file BaseTest.py.

## Constructor & Destructor Documentation

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

Definition at line 69 of file BaseTest.py.

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

## Member Function Documentation

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

Definition at line 504 of file BaseTest.py.

504 def _expandReferenceFileName(self, reffile):
505 # if no file is passed, do nothing
506 if not reffile:
507 return ""
508
509 # function to split an extension in constituents parts
510 def platformSplit(p): return set(p.split('-' in p and '-' or '_'))
511
512 reference = os.path.normpath(os.path.join(self.basedir,
513 os.path.expandvars(reffile)))
514
515 # old-style platform-specific reference name
516 spec_ref = reference[:-3] + GetPlatform(self)[0:3] + reference[-3:]
517 if os.path.isfile(spec_ref):
518 reference = spec_ref
519 else: # look for new-style platform specific reference files:
520 # get all the files whose name start with the reference filename
521 dirname, basename = os.path.split(reference)
522 if not dirname:
523 dirname = '.'
524 head = basename + "."
525 head_len = len(head)
526 platform = platformSplit(GetPlatform(self))
527 if 'do0' in platform:
528 platform.add('dbg')
529 candidates = []
530 for f in os.listdir(dirname):
531 if f.startswith(head):
532 req_plat = platformSplit(f[head_len:])
533 if platform.issuperset(req_plat):
534 candidates.append((len(req_plat), f))
535 if candidates: # take the one with highest matching
536 # FIXME: it is not possible to say if x86_64-slc5-gcc43-dbg
537 # has to use ref.x86_64-gcc43 or ref.slc5-dbg
538 candidates.sort()
539 reference = os.path.join(dirname, candidates[-1][1])
540 return reference
541
542 # ======= GAUDI TOOLS =======
543
544
GaudiTesting.BaseTest.BaseTest.basedir
basedir
Definition: BaseTest.py:93
GaudiTesting.BaseTest.GetPlatform
def GetPlatform(self)
Definition: BaseTest.py:1201
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:504

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 402 of file BaseTest.py.

402 ignore=None):
403 """
404 Compare the TTree summaries in stdout with the ones in trees_dict or in
405 the reference file. By default ignore the size, compression and basket
406 fields.
407 The presence of TTree summaries when none is expected is not a failure.
408 """
409 if stdout is None:
410 stdout = self.out
411 if result is None:
412 result = self.result
413 if causes is None:
414 causes = self.causes
415
416 if dict is None:
417 lreference = self._expandReferenceFileName(self.reference)
418 # call the validator if the file exists
419 if lreference and os.path.isfile(lreference):
420 dict = findHistosSummaries(open(lreference).read())
421 else:
422 dict = {}
423
424 from pprint import PrettyPrinter
425 pp = PrettyPrinter()
426 if dict:
427 result["GaudiTest.Histos.expected"] = result.Quote(
428 pp.pformat(dict))
429 if ignore:
430 result["GaudiTest.Histos.ignore"] = result.Quote(ignore)
431
432 histos = findHistosSummaries(stdout)
433 failed = cmpTreesDicts(dict, histos, ignore)
434 if failed:
435 causes.append("histos summaries")
436 msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed)
437 result["GaudiTest.Histos.failure_on"] = result.Quote(msg)
438 result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos))
439
440 return causes
441
GaudiTesting.BaseTest.cmpTreesDicts
def cmpTreesDicts(reference, to_check, ignore=None)
Definition: BaseTest.py:999
hivetimeline.read
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:22
GaudiTesting.BaseTest.findHistosSummaries
def findHistosSummaries(stdout)
Definition: BaseTest.py:1166
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:72
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86
GaudiTesting.BaseTest.getCmpFailingValues
def getCmpFailingValues(reference, to_check, fail_path)
Definition: BaseTest.py:1032
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:87
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:89
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:504

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 360 of file BaseTest.py.

360 ignore=r"Basket|.*size|Compression"):
361 """
362 Compare the TTree summaries in stdout with the ones in trees_dict or in
363 the reference file. By default ignore the size, compression and basket
364 fields.
365 The presence of TTree summaries when none is expected is not a failure.
366 """
367 if stdout is None:
368 stdout = self.out
369 if result is None:
370 result = self.result
371 if causes is None:
372 causes = self.causes
373 if trees_dict is None:
374 lreference = self._expandReferenceFileName(self.reference)
375 # call the validator if the file exists
376 if lreference and os.path.isfile(lreference):
377 trees_dict = findTTreeSummaries(open(lreference).read())
378 else:
379 trees_dict = {}
380
381 from pprint import PrettyPrinter
382 pp = PrettyPrinter()
383 if trees_dict:
384 result["GaudiTest.TTrees.expected"] = result.Quote(
385 pp.pformat(trees_dict))
386 if ignore:
387 result["GaudiTest.TTrees.ignore"] = result.Quote(ignore)
388
389 trees = findTTreeSummaries(stdout)
390 failed = cmpTreesDicts(trees_dict, trees, ignore)
391 if failed:
392 causes.append("trees summaries")
393 msg = "%s: %s != %s" % getCmpFailingValues(
394 trees_dict, trees, failed)
395 result["GaudiTest.TTrees.failure_on"] = result.Quote(msg)
396 result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees))
397
398 return causes
399
GaudiTesting.BaseTest.cmpTreesDicts
def cmpTreesDicts(reference, to_check, ignore=None)
Definition: BaseTest.py:999
hivetimeline.read
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:22
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:72
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86
GaudiTesting.BaseTest.getCmpFailingValues
def getCmpFailingValues(reference, to_check, fail_path)
Definition: BaseTest.py:1032
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:87
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:89
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:504
GaudiTesting.BaseTest.findTTreeSummaries
def findTTreeSummaries(stdout)
Definition: BaseTest.py:977

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

Definition at line 317 of file BaseTest.py.

317 def countErrorLines(self, expected={'ERROR': 0, 'FATAL': 0}, stdout=None, result=None, causes=None):
318 """
319 Count the number of messages with required severity (by default ERROR and FATAL)
320 and check if their numbers match the expected ones (0 by default).
321 The dictionary "expected" can be used to tune the number of errors and fatals
322 allowed, or to limit the number of expected warnings etc.
323 """
324
325 if stdout is None:
326 stdout = self.out
327 if result is None:
328 result = self.result
329 if causes is None:
330 causes = self.causes
331
332 # prepare the dictionary to record the extracted lines
333 errors = {}
334 for sev in expected:
335 errors[sev] = []
336
337 outlines = stdout.splitlines()
338 from math import log10
339 fmt = "%%%dd - %%s" % (int(log10(len(outlines) + 1)))
340
341 linecount = 0
342 for l in outlines:
343 linecount += 1
344 words = l.split()
345 if len(words) >= 2 and words[1] in errors:
346 errors[words[1]].append(fmt % (linecount, l.rstrip()))
347
348 for e in errors:
349 if len(errors[e]) != expected[e]:
350 causes.append('%s(%d)' % (e, len(errors[e])))
351 result["GaudiTest.lines.%s" %
352 e] = result.Quote('\n'.join(errors[e]))
353 result["GaudiTest.lines.%s.expected#" %
354 e] = result.Quote(str(expected[e]))
355
356 return causes
357
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:87
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:89
GaudiTesting.BaseTest.BaseTest.countErrorLines
def countErrorLines
Definition: BaseTest.py:317

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 269 of file BaseTest.py.

269 def findReferenceBlock(self, reference=None, stdout=None, result=None, causes=None, signature_offset=0, signature=None, id=None):
270 """
271 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.
272 """
273
274 if reference is None:
275 reference = self.reference
276 if stdout is None:
277 stdout = self.out
278 if result is None:
279 result = self.result
280 if causes is None:
281 causes = self.causes
282
283 reflines = filter(
284 None, map(lambda s: s.rstrip(), reference.splitlines()))
285 if not reflines:
286 raise RuntimeError("Empty (or null) reference")
287 # the same on standard output
288 outlines = filter(None, map(lambda s: s.rstrip(), stdout.splitlines()))
289
290 res_field = "GaudiTest.RefBlock"
291 if id:
292 res_field += "_%s" % id
293
294 if signature is None:
295 if signature_offset < 0:
296 signature_offset = len(reference) + signature_offset
297 signature = reflines[signature_offset]
298 # find the reference block in the output file
299 try:
300 pos = outlines.index(signature)
301 outlines = outlines[pos - signature_offset:pos +
302 len(reflines) - signature_offset]
303 if reflines != outlines:
304 msg = "standard output"
305 # I do not want 2 messages in causes if teh function is called twice
306 if not msg in causes:
307 causes.append(msg)
308 result[res_field +
309 ".observed"] = result.Quote("\n".join(outlines))
310 except ValueError:
311 causes.append("missing signature")
312 result[res_field + ".signature"] = result.Quote(signature)
313 if len(reflines) > 1 or signature != reflines[0]:
314 result[res_field + ".expected"] = result.Quote("\n".join(reflines))
315 return causes
316
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:72
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:26
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:87
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:89
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:269

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

Definition at line 95 of file BaseTest.py.

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

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

Definition at line 262 of file BaseTest.py.

262 def ValidateOutput(self, stdout, stderr, result):
263 if not self.stderr:
264 self.validateWithReference(stdout, stderr, result, self.causes)
265 elif stderr.strip() != self.stderr.strip():
266 self.causes.append('standard error')
267 return result, self.causes
268
GaudiTesting.BaseTest.BaseTest.validateWithReference
def validateWithReference(self, stdout=None, stderr=None, result=None, causes=None, preproc=None)
Definition: BaseTest.py:443
GaudiTesting.BaseTest.BaseTest.ValidateOutput
def ValidateOutput(self, stdout, stderr, result)
Definition: BaseTest.py:262
GaudiTesting.BaseTest.BaseTest.stderr
stderr
Definition: BaseTest.py:75
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86

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 443 of file BaseTest.py.

443 causes=None, preproc=None):
444 '''
445 Default validation acti*on: compare standard output and error to the
446 reference files.
447 '''
448
449 if stdout is None:
450 stdout = self.out
451 if stderr is None:
452 stderr = self.err
453 if result is None:
454 result = self.result
455 if causes is None:
456 causes = self.causes
457
458 # set the default output preprocessor
459 if preproc is None:
460 preproc = normalizeExamples
461 # check standard output
462 lreference = self._expandReferenceFileName(self.reference)
463 # call the validator if the file exists
464 if lreference and os.path.isfile(lreference):
465 causes += ReferenceFileValidator(lreference,
466 "standard output",
467 "Output Diff",
468 preproc=preproc)(stdout, result)
469 # Compare TTree summaries
470 causes = self.CheckTTreesSummaries(stdout, result, causes)
471 causes = self.CheckHistosSummaries(stdout, result, causes)
472 if causes: # Write a new reference file for stdout
473 try:
474 newref = open(lreference + ".new", "w")
475 # sanitize newlines
476 for l in stdout.splitlines():
477 newref.write(l.rstrip() + '\n')
478 del newref # flush and close
479 except IOError:
480 # Ignore IO errors when trying to update reference files
481 # because we may be in a read-only filesystem
482 pass
483
484 # check standard error
485 lreference = self._expandReferenceFileName(self.error_reference)
486 # call the validator if we have a file to use
487 if lreference and os.path.isfile(lreference):
488 newcauses = ReferenceFileValidator(lreference,
489 "standard error",
490 "Error Diff",
491 preproc=preproc)(stderr, result)
492 causes += newcauses
493 if newcauses: # Write a new reference file for stdedd
494 newref = open(lreference + ".new", "w")
495 # sanitize newlines
496 for l in stderr.splitlines():
497 newref.write(l.rstrip() + '\n')
498 del newref # flush and close
499 else:
500 causes += BasicOutputValidator(lreference, "standard error",
501 "ExecTest.expected_stderr")(stderr, result)
502 return causes
503
GaudiTesting.BaseTest.BaseTest.err
err
Definition: BaseTest.py:90
GaudiTesting.BaseTest.ReferenceFileValidator
Definition: BaseTest.py:941
GaudiTesting.BaseTest.BasicOutputValidator
Definition: BaseTest.py:639
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:72
GaudiTesting.BaseTest.BaseTest.error_reference
error_reference
Definition: BaseTest.py:73
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86
GaudiTesting.BaseTest.BaseTest.result
result
Definition: BaseTest.py:87
GaudiTesting.BaseTest.BaseTest.out
out
Definition: BaseTest.py:89
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:504
GaudiTesting.BaseTest.BaseTest.CheckHistosSummaries
def CheckHistosSummaries(self, stdout=None, result=None, causes=None, dict=None, ignore=None)
Definition: BaseTest.py:402
GaudiTesting.BaseTest.BaseTest.CheckTTreesSummaries
def CheckTTreesSummaries(self, stdout=None, result=None, causes=None, trees_dict=None, ignore=r"Basket|.*size|Compression")
Definition: BaseTest.py:360

## Member Data Documentation

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

Definition at line 67 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.args

Definition at line 71 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.basedir

Definition at line 93 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.causes

Definition at line 86 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.environment

Definition at line 78 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.err

Definition at line 90 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.error_reference

Definition at line 73 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.exit_code

Definition at line 77 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.name

Definition at line 85 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.options

Definition at line 74 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.out

Definition at line 89 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.proc

Definition at line 91 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.program

Definition at line 70 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.reference

Definition at line 72 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.result

Definition at line 87 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.returnedCode

Definition at line 88 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.signal

Definition at line 80 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.stack_trace

Definition at line 92 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.status

Definition at line 84 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.stderr

Definition at line 75 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.timeout

Definition at line 76 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.unsupported_platforms

Definition at line 79 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.use_temp_dir

Definition at line 82 of file BaseTest.py.

GaudiTesting.BaseTest.BaseTest.workdir

Definition at line 81 of file BaseTest.py.

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

- GaudiPolicy/python/GaudiTesting/BaseTest.py