| The Gaudi Framework v30r0 (c919700c)

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

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

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

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

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

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

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

Definition at line 318 of file BaseTest.py.

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

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 the function is called
306 # twice
307 if not msg in causes:
308 causes.append(msg)
309 result[res_field +
310 ".observed"] = result.Quote("\n".join(outlines))
311 except ValueError:
312 causes.append("missing signature")
313 result[res_field + ".signature"] = result.Quote(signature)
314 if len(reflines) > 1 or signature != reflines[0]:
315 result[res_field + ".expected"] = result.Quote("\n".join(reflines))
316 return causes
317
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:561
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:571
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:444
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 444 of file BaseTest.py.

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

## 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