Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions

GaudiTest::GaudiExeTest Class Reference

Inheritance diagram for GaudiTest::GaudiExeTest:
Inheritance graph
[legend]
Collaboration diagram for GaudiTest::GaudiExeTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def PlatformIsNotSupported
def GetPlatform
def CheckTTreesSummaries
def CheckHistosSummaries
def ValidateWithReference
def ValidateOutput
def DumpEnvironment
def Run
def RunProgram

Public Attributes

 callable
 extra_args
 args_order
 program
 reference
 error_reference
 use_temp_dir
 timeout

Static Public Attributes

list arguments

Private Member Functions

def _expandReferenceFileName
def _CreateEclipseLaunch

Detailed Description

Standard Gaudi test.

Definition at line 971 of file GaudiTest.py.


Member Function Documentation

def GaudiTest::GaudiExeTest::_CreateEclipseLaunch (   self,
  prog,
  args,
  destdir = None 
) [private]

Definition at line 1548 of file GaudiTest.py.

01549                                                               :
01550         # Find the project name used in ecplise.
01551         # The name is in a file called ".project" in one of the parent directories
01552         projbasedir = os.path.normpath(destdir)
01553         while not os.path.exists(os.path.join(projbasedir, ".project")):
01554             oldprojdir = projbasedir
01555             projbasedir = os.path.normpath(os.path.join(projbasedir, os.pardir))
01556             # FIXME: the root level is invariant when trying to go up one level,
01557             #        but it must be cheched on windows
01558             if oldprojdir == projbasedir:
01559                 # If we cannot find a .project, so no point in creating a .launch file
01560                 return
01561         # Use ElementTree to parse the XML file
01562         from xml.etree import ElementTree as ET
01563         t = ET.parse(os.path.join(projbasedir, ".project"))
01564         projectName = t.find("name").text
01565 
01566         # prepare the name/path of the generated file
01567         destfile = "%s.launch" % self._Runnable__id
01568         if destdir:
01569             destfile = os.path.join(destdir, destfile)
01570 
01571         if self.options.strip():
01572             # this means we have some custom options in the qmt file, so we have
01573             # to copy them from the temporary file at the end of the arguments
01574             # in another file
01575             tempfile = args.pop()
01576             optsfile = destfile + os.path.splitext(tempfile)[1]
01577             shutil.copyfile(tempfile, optsfile)
01578             args.append(optsfile)
01579 
01580         # prepare the data to insert in the XML file
01581         from xml.sax.saxutils import quoteattr # useful to quote XML special chars
01582         data = {}
01583         # Note: the "quoteattr(k)" is not needed because special chars cannot be part of a variable name,
01584         # but it doesn't harm.
01585         data["environment"] = "\n".join(['<mapEntry key=%s value=%s/>' % (quoteattr(k), quoteattr(v))
01586                                          for k, v in os.environ.iteritems()])
01587 
01588         data["exec"] = which(prog) or prog
01589         if os.path.basename(data["exec"]).lower().startswith("python"):
01590             data["stopAtMain"] = "false" # do not stop at main when debugging Python scripts
01591         else:
01592             data["stopAtMain"] = "true"
01593 
01594         data["args"] = "&#10;".join(map(rationalizepath, args))
01595 
01596         if not self.use_temp_dir:
01597             data["workdir"] = os.getcwd()
01598         else:
01599             # If the test is using a tmporary directory, it is better to run it
01600             # in the same directory as the .launch file when debugged in eclipse
01601             data["workdir"] = destdir
01602 
01603         data["project"] = projectName.strip()
01604 
01605         # Template for the XML file, based on eclipse 3.4
01606         xml = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
01607 <launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
01608 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB" value="true"/>
01609 <listAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB_LIST"/>
01610 <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="gdb"/>
01611 <stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=".gdbinit"/>
01612 <listAttribute key="org.eclipse.cdt.debug.mi.core.SOLIB_PATH"/>
01613 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.STOP_ON_SOLIB_EVENTS" value="false"/>
01614 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.breakpointsFullPath" value="false"/>
01615 <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="org.eclipse.cdt.debug.mi.core.standardCommandFactory"/>
01616 <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
01617 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
01618 <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
01619 <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
01620 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebuggerNew"/>
01621 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
01622 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
01623 <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="%(stopAtMain)s"/>
01624 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
01625 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
01626 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
01627 <stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/>
01628 <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
01629 <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList/&gt;&#10;"/>
01630 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="%(args)s"/>
01631 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="%(exec)s"/>
01632 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="%(project)s"/>
01633 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
01634 <stringAttribute key="org.eclipse.cdt.launch.WORKING_DIRECTORY" value="%(workdir)s"/>
01635 <booleanAttribute key="org.eclipse.cdt.launch.ui.ApplicationCDebuggerTab.DEFAULTS_SET" value="true"/>
01636 <booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
01637 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
01638 <listEntry value="/%(project)s"/>
01639 </listAttribute>
01640 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
01641 <listEntry value="4"/>
01642 </listAttribute>
01643 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="false"/>
01644 <mapAttribute key="org.eclipse.debug.core.environmentVariables">
01645 %(environment)s
01646 </mapAttribute>
01647 <mapAttribute key="org.eclipse.debug.core.preferred_launchers">
01648 <mapEntry key="[debug]" value="org.eclipse.cdt.cdi.launch.localCLaunch"/>
01649 </mapAttribute>
01650 <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
01651 <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
01652 </listAttribute>
01653 </launchConfiguration>
01654 """ % data
01655 
01656         # Write the output file
01657         open(destfile, "w").write(xml)
01658         #open(destfile + "_copy.xml", "w").write(xml)
01659 
01660 
try:
def GaudiTest::GaudiExeTest::_expandReferenceFileName (   self,
  reffile 
) [private]

Definition at line 1114 of file GaudiTest.py.

01115                                                :
01116         # if no file is passed, do nothing
01117         if not reffile:
01118             return ""
01119 
01120         # function to split an extension in constituents parts
01121         platformSplit = lambda p: set(p.split('-' in p and '-' or '_'))
01122 
01123         reference = os.path.normpath(os.path.expandvars(reffile))
01124         # old-style platform-specific reference name
01125         spec_ref = reference[:-3] + self.GetPlatform()[0:3] + reference[-3:]
01126         if os.path.isfile(spec_ref):
01127             reference = spec_ref
01128         else: # look for new-style platform specific reference files:
01129             # get all the files whose name start with the reference filename
01130             dirname, basename = os.path.split(reference)
01131             if not dirname: dirname = '.'
01132             head = basename + "."
01133             head_len = len(head)
01134             platform = platformSplit(self.GetPlatform())
01135             candidates = []
01136             for f in os.listdir(dirname):
01137                 if f.startswith(head):
01138                     req_plat = platformSplit(f[head_len:])
01139                     if platform.issuperset(req_plat):
01140                         candidates.append( (len(req_plat), f) )
01141             if candidates: # take the one with highest matching
01142                 # FIXME: it is not possible to say if x86_64-slc5-gcc43-dbg
01143                 #        has to use ref.x86_64-gcc43 or ref.slc5-dbg
01144                 candidates.sort()
01145                 reference = os.path.join(dirname, candidates[-1][1])
01146         return reference

def GaudiTest::GaudiExeTest::CheckHistosSummaries (   self,
  stdout,
  result,
  causes,
  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 1181 of file GaudiTest.py.

01184                                            :
01185         """
01186         Compare the TTree summaries in stdout with the ones in trees_dict or in
01187         the reference file. By default ignore the size, compression and basket
01188         fields.
01189         The presence of TTree summaries when none is expected is not a failure.
01190         """
01191         if dict is None:
01192             reference = self._expandReferenceFileName(self.reference)
01193             # call the validator if the file exists
01194             if reference and os.path.isfile(reference):
01195                 dict = findHistosSummaries(open(reference).read())
01196             else:
01197                 dict = {}
01198 
01199         from pprint import PrettyPrinter
01200         pp = PrettyPrinter()
01201         if dict:
01202             result["GaudiTest.Histos.expected"] = result.Quote(pp.pformat(dict))
01203             if ignore:
01204                 result["GaudiTest.Histos.ignore"] = result.Quote(ignore)
01205 
01206         histos = findHistosSummaries(stdout)
01207         failed = cmpTreesDicts(dict, histos, ignore)
01208         if failed:
01209             causes.append("histos summaries")
01210             msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed)
01211             result["GaudiTest.Histos.failure_on"] = result.Quote(msg)
01212             result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos))
01213 
01214         return causes

def GaudiTest::GaudiExeTest::CheckTTreesSummaries (   self,
  stdout,
  result,
  causes,
  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 1147 of file GaudiTest.py.

01150                                                                    :
01151         """
01152         Compare the TTree summaries in stdout with the ones in trees_dict or in
01153         the reference file. By default ignore the size, compression and basket
01154         fields.
01155         The presence of TTree summaries when none is expected is not a failure.
01156         """
01157         if trees_dict is None:
01158             reference = self._expandReferenceFileName(self.reference)
01159             # call the validator if the file exists
01160             if reference and os.path.isfile(reference):
01161                 trees_dict = findTTreeSummaries(open(reference).read())
01162             else:
01163                 trees_dict = {}
01164 
01165         from pprint import PrettyPrinter
01166         pp = PrettyPrinter()
01167         if trees_dict:
01168             result["GaudiTest.TTrees.expected"] = result.Quote(pp.pformat(trees_dict))
01169             if ignore:
01170                 result["GaudiTest.TTrees.ignore"] = result.Quote(ignore)
01171 
01172         trees = findTTreeSummaries(stdout)
01173         failed = cmpTreesDicts(trees_dict, trees, ignore)
01174         if failed:
01175             causes.append("trees summaries")
01176             msg = "%s: %s != %s" % getCmpFailingValues(trees_dict, trees, failed)
01177             result["GaudiTest.TTrees.failure_on"] = result.Quote(msg)
01178             result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees))
01179 
01180         return causes

def GaudiTest::GaudiExeTest::DumpEnvironment (   self,
  result 
)
Add the content of the environment to the result object.

Copied from the QMTest class of COOL.

Definition at line 1337 of file GaudiTest.py.

01338                                      :
01339         """
01340         Add the content of the environment to the result object.
01341 
01342         Copied from the QMTest class of COOL.
01343         """
01344         vars = os.environ.keys()
01345         vars.sort()
01346         result['GaudiTest.environment'] = \
01347             result.Quote('\n'.join(["%s=%s"%(v,os.environ[v]) for v in vars]))

def GaudiTest::GaudiExeTest::GetPlatform (   self )
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.

Definition at line 1102 of file GaudiTest.py.

01103                          :
01104         """
01105         Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
01106         """
01107         arch = "None"
01108         # check architecture name
01109         if "CMTCONFIG" in os.environ:
01110             arch = os.environ["CMTCONFIG"]
01111         elif "SCRAM_ARCH" in os.environ:
01112             arch = os.environ["SCRAM_ARCH"]
01113         return arch

def GaudiTest::GaudiExeTest::PlatformIsNotSupported (   self,
  context,
  result 
)

Definition at line 1088 of file GaudiTest.py.

01089                                                      :
01090         platform = self.GetPlatform()
01091         unsupported = [ re.compile(x)
01092                         for x in [ str(y).strip()
01093                                    for y in self.unsupported_platforms ]
01094                         if x
01095                        ]
01096         for p_re in unsupported:
01097             if p_re.search(platform):
01098                 result.SetOutcome(result.UNTESTED)
01099                 result[result.CAUSE] = 'Platform not supported.'
01100                 return True
01101         return False

def GaudiTest::GaudiExeTest::Run (   self,
  context,
  result 
)
Run the test.

'context' -- A 'Context' giving run-time parameters to the
test.

'result' -- A 'Result' object.  The outcome will be
'Result.PASS' when this method is called.  The 'result' may be
modified by this method to indicate outcomes other than
'Result.PASS' or to add annotations.

Definition at line 1348 of file GaudiTest.py.

01349                                   :
01350         """Run the test.
01351 
01352         'context' -- A 'Context' giving run-time parameters to the
01353         test.
01354 
01355         'result' -- A 'Result' object.  The outcome will be
01356         'Result.PASS' when this method is called.  The 'result' may be
01357         modified by this method to indicate outcomes other than
01358         'Result.PASS' or to add annotations."""
01359 
01360         # Check if the platform is supported
01361         if self.PlatformIsNotSupported(context, result):
01362             return
01363 
01364         # Prepare program name and arguments (expanding variables, and converting to absolute)
01365         if self.program:
01366             prog = rationalizepath(self.program)
01367         elif "GAUDIEXE" in os.environ:
01368             prog = os.environ["GAUDIEXE"]
01369         else:
01370             prog = "Gaudi.exe"
01371         self.program = prog
01372 
01373         dummy, prog_ext = os.path.splitext(prog)
01374         if prog_ext not in [ ".exe", ".py", ".bat" ] and self.GetPlatform()[0:3] == "win":
01375             prog += ".exe"
01376             prog_ext = ".exe"
01377 
01378         prog = which(prog) or prog
01379 
01380         # Convert paths to absolute paths in arguments and reference files
01381         args = map(rationalizepath, self.args)
01382         self.reference = rationalizepath(self.reference)
01383         self.error_reference = rationalizepath(self.error_reference)
01384 
01385 
01386         # check if the user provided inline options
01387         tmpfile = None
01388         if self.options.strip():
01389             ext = ".opts"
01390             if re.search(r"from\s*Gaudi.Configuration\s*import\s*\*", self.options):
01391                 ext = ".py"
01392             tmpfile = TempFile(ext)
01393             tmpfile.writelines("\n".join(self.options.splitlines()))
01394             tmpfile.flush()
01395             args.append(tmpfile.name)
01396             result["GaudiTest.options"] = result.Quote(self.options)
01397 
01398         # if the program is a python file, execute it through python
01399         if prog_ext == ".py":
01400             args.insert(0,prog)
01401             if self.GetPlatform()[0:3] == "win":
01402                 prog = which("python.exe") or "python.exe"
01403             else:
01404                 prog = which("python") or "python"
01405 
01406         # Change to the working directory if specified or to the default temporary
01407         origdir = os.getcwd()
01408         if self.workdir:
01409             os.chdir(str(os.path.normpath(os.path.expandvars(self.workdir))))
01410         elif self.use_temp_dir == "true":
01411             if "QMTEST_TMPDIR" in os.environ:
01412                 os.chdir(os.environ["QMTEST_TMPDIR"])
01413             elif "qmtest.tmpdir" in context:
01414                 os.chdir(context["qmtest.tmpdir"])
01415 
01416         if "QMTEST_IGNORE_TIMEOUT" not in os.environ:
01417             self.timeout = max(self.timeout,600)
01418         else:
01419             self.timeout = -1
01420 
01421         try:
01422             # Generate eclipse.org debug launcher for the test
01423             self._CreateEclipseLaunch(prog, args, destdir = origdir)
01424             # Run the test
01425             self.RunProgram(prog,
01426                             [ prog ] + args,
01427                             context, result)
01428             # Record the content of the enfironment for failing tests
01429             if result.GetOutcome() not in [ result.PASS ]:
01430                 self.DumpEnvironment(result)
01431         finally:
01432             # revert to the original directory
01433             os.chdir(origdir)

def GaudiTest::GaudiExeTest::RunProgram (   self,
  program,
  arguments,
  context,
  result 
)
Run the 'program'.

'program' -- The path to the program to run.

'arguments' -- A list of the arguments to the program.  This
list must contain a first argument corresponding to 'argv[0]'.

'context' -- A 'Context' giving run-time parameters to the
test.

'result' -- A 'Result' object.  The outcome will be
'Result.PASS' when this method is called.  The 'result' may be
modified by this method to indicate outcomes other than
'Result.PASS' or to add annotations.

@attention: This method has been copied from command.ExecTestBase
    (QMTest 2.3.0) and modified to keep stdout and stderr
    for tests that have been terminated by a signal.
    (Fundamental for debugging in the Application Area)

Definition at line 1434 of file GaudiTest.py.

01435                                                              :
01436         """Run the 'program'.
01437 
01438         'program' -- The path to the program to run.
01439 
01440         'arguments' -- A list of the arguments to the program.  This
01441         list must contain a first argument corresponding to 'argv[0]'.
01442 
01443         'context' -- A 'Context' giving run-time parameters to the
01444         test.
01445 
01446         'result' -- A 'Result' object.  The outcome will be
01447         'Result.PASS' when this method is called.  The 'result' may be
01448         modified by this method to indicate outcomes other than
01449         'Result.PASS' or to add annotations.
01450 
01451         @attention: This method has been copied from command.ExecTestBase
01452                     (QMTest 2.3.0) and modified to keep stdout and stderr
01453                     for tests that have been terminated by a signal.
01454                     (Fundamental for debugging in the Application Area)
01455         """
01456 
01457         # Construct the environment.
01458         environment = self.MakeEnvironment(context)
01459         # Create the executable.
01460         if self.timeout >= 0:
01461             timeout = self.timeout
01462         else:
01463             # If no timeout was specified, we sill run this process in a
01464             # separate process group and kill the entire process group
01465             # when the child is done executing.  That means that
01466             # orphaned child processes created by the test will be
01467             # cleaned up.
01468             timeout = -2
01469         e = GaudiFilterExecutable(self.stdin, timeout)
01470         # Run it.
01471         exit_status = e.Run(arguments, environment, path = program)
01472         # Get the stack trace from the temporary file (if present)
01473         if e.stack_trace_file and os.path.exists(e.stack_trace_file):
01474             stack_trace = open(e.stack_trace_file).read()
01475             os.remove(e.stack_trace_file)
01476         else:
01477             stack_trace = None
01478         if stack_trace:
01479             result["ExecTest.stack_trace"] = result.Quote(stack_trace)
01480 
01481         # If the process terminated normally, check the outputs.
01482         if sys.platform == "win32" or os.WIFEXITED(exit_status):
01483             # There are no causes of failure yet.
01484             causes = []
01485             # The target program terminated normally.  Extract the
01486             # exit code, if this test checks it.
01487             if self.exit_code is None:
01488                 exit_code = None
01489             elif sys.platform == "win32":
01490                 exit_code = exit_status
01491             else:
01492                 exit_code = os.WEXITSTATUS(exit_status)
01493             # Get the output generated by the program.
01494             stdout = e.stdout
01495             stderr = e.stderr
01496             # Record the results.
01497             result["ExecTest.exit_code"] = str(exit_code)
01498             result["ExecTest.stdout"] = result.Quote(stdout)
01499             result["ExecTest.stderr"] = result.Quote(stderr)
01500             # Check to see if the exit code matches.
01501             if exit_code != self.exit_code:
01502                 causes.append("exit_code")
01503                 result["ExecTest.expected_exit_code"] \
01504                     = str(self.exit_code)
01505             # Validate the output.
01506             causes += self.ValidateOutput(stdout, stderr, result)
01507             # If anything went wrong, the test failed.
01508             if causes:
01509                 result.Fail("Unexpected %s." % string.join(causes, ", "))
01510         elif os.WIFSIGNALED(exit_status):
01511             # The target program terminated with a signal.  Construe
01512             # that as a test failure.
01513             signal_number = str(os.WTERMSIG(exit_status))
01514             if not stack_trace:
01515                 result.Fail("Program terminated by signal.")
01516             else:
01517                 # The presence of stack_trace means tha we stopped the job because
01518                 # of a time-out
01519                 result.Fail("Exceeded time limit (%ds), terminated." % timeout)
01520             result["ExecTest.signal_number"] = signal_number
01521             result["ExecTest.stdout"] = result.Quote(e.stdout)
01522             result["ExecTest.stderr"] = result.Quote(e.stderr)
01523         elif os.WIFSTOPPED(exit_status):
01524             # The target program was stopped.  Construe that as a
01525             # test failure.
01526             signal_number = str(os.WSTOPSIG(exit_status))
01527             if not stack_trace:
01528                 result.Fail("Program stopped by signal.")
01529             else:
01530                 # The presence of stack_trace means tha we stopped the job because
01531                 # of a time-out
01532                 result.Fail("Exceeded time limit (%ds), stopped." % timeout)
01533             result["ExecTest.signal_number"] = signal_number
01534             result["ExecTest.stdout"] = result.Quote(e.stdout)
01535             result["ExecTest.stderr"] = result.Quote(e.stderr)
01536         else:
01537             # The target program terminated abnormally in some other
01538             # manner.  (This shouldn't normally happen...)
01539             result.Fail("Program did not terminate normally.")
01540 
01541         # Marco Cl.: This is a special trick to fix a "problem" with the output
01542         # of gaudi jobs when they use colors
01543         esc = '\x1b'
01544         repr_esc = '\\x1b'
01545         result["ExecTest.stdout"] = result["ExecTest.stdout"].replace(esc,repr_esc)
01546         # TODO: (MCl) improve the hack for colors in standard output
01547         #             may be converting them to HTML tags

def GaudiTest::GaudiExeTest::ValidateOutput (   self,
  stdout,
  stderr,
  result 
)

Definition at line 1272 of file GaudiTest.py.

01273                                                     :
01274         causes = []
01275         # if the test definition contains a custom validator, use it
01276         if self.validator.strip() != "":
01277             class CallWrapper(object):
01278                 """
01279                 Small wrapper class to dynamically bind some default arguments
01280                 to a callable.
01281                 """
01282                 def __init__(self, callable, extra_args = {}):
01283                     self.callable = callable
01284                     self.extra_args = extra_args
01285                     # get the list of names of positional arguments
01286                     from inspect import getargspec
01287                     self.args_order = getargspec(callable)[0]
01288                     # Remove "self" from the list of positional arguments
01289                     # since it is added automatically
01290                     if self.args_order[0] == "self":
01291                         del self.args_order[0]
01292                 def __call__(self, *args, **kwargs):
01293                     # Check which positional arguments are used
01294                     positional = self.args_order[:len(args)]
01295 
01296                     kwargs = dict(kwargs) # copy the arguments dictionary
01297                     for a in self.extra_args:
01298                         # use "extra_args" for the arguments not specified as
01299                         # positional or keyword
01300                         if a not in positional and a not in kwargs:
01301                             kwargs[a] = self.extra_args[a]
01302                     return apply(self.callable, args, kwargs)
01303             # local names to be exposed in the script
01304             exported_symbols = {"self":self,
01305                                 "stdout":stdout,
01306                                 "stderr":stderr,
01307                                 "result":result,
01308                                 "causes":causes,
01309                                 "findReferenceBlock":
01310                                     CallWrapper(findReferenceBlock, {"stdout":stdout,
01311                                                                      "result":result,
01312                                                                      "causes":causes}),
01313                                 "validateWithReference":
01314                                     CallWrapper(self.ValidateWithReference, {"stdout":stdout,
01315                                                                              "stderr":stderr,
01316                                                                              "result":result,
01317                                                                              "causes":causes}),
01318                                 "countErrorLines":
01319                                     CallWrapper(countErrorLines, {"stdout":stdout,
01320                                                                   "result":result,
01321                                                                   "causes":causes}),
01322                                 "checkTTreesSummaries":
01323                                     CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout,
01324                                                                             "result":result,
01325                                                                             "causes":causes}),
01326                                 "checkHistosSummaries":
01327                                     CallWrapper(self.CheckHistosSummaries, {"stdout":stdout,
01328                                                                             "result":result,
01329                                                                             "causes":causes}),
01330 
01331                                 }
01332             exec self.validator in globals(), exported_symbols
01333         else:
01334             self.ValidateWithReference(stdout, stderr, result, causes)
01335 
01336         return causes

def GaudiTest::GaudiExeTest::ValidateWithReference (   self,
  stdout,
  stderr,
  result,
  causes,
  preproc = None 
)
Default validation action: compare standard output and error to the
reference files.

Definition at line 1215 of file GaudiTest.py.

01216                                                                                    :
01217         """
01218         Default validation action: compare standard output and error to the
01219         reference files.
01220         """
01221         # set the default output preprocessor
01222         if preproc is None:
01223             preproc = normalizeExamples
01224         # check standard output
01225         reference = self._expandReferenceFileName(self.reference)
01226         # call the validator if the file exists
01227         if reference and os.path.isfile(reference):
01228             result["GaudiTest.output_reference"] = reference
01229             causes += ReferenceFileValidator(reference,
01230                                              "standard output",
01231                                              "GaudiTest.output_diff",
01232                                              preproc = preproc)(stdout, result)
01233 
01234         # Compare TTree summaries
01235         causes = self.CheckTTreesSummaries(stdout, result, causes)
01236         causes = self.CheckHistosSummaries(stdout, result, causes)
01237 
01238         if causes: # Write a new reference file for stdout
01239             try:
01240                 newref = open(reference + ".new","w")
01241                 # sanitize newlines
01242                 for l in stdout.splitlines():
01243                     newref.write(l.rstrip() + '\n')
01244                 del newref # flush and close
01245             except IOError:
01246                 # Ignore IO errors when trying to update reference files
01247                 # because we may be in a read-only filesystem
01248                 pass
01249 
01250         # check standard error
01251         reference = self._expandReferenceFileName(self.error_reference)
01252         # call the validator if we have a file to use
01253         if reference and os.path.isfile(reference):
01254             result["GaudiTest.error_reference"] = reference
01255             newcauses = ReferenceFileValidator(reference,
01256                                                "standard error",
01257                                                "GaudiTest.error_diff",
01258                                                preproc = preproc)(stderr, result)
01259             causes += newcauses
01260             if newcauses: # Write a new reference file for stdedd
01261                 newref = open(reference + ".new","w")
01262                 # sanitize newlines
01263                 for l in stderr.splitlines():
01264                     newref.write(l.rstrip() + '\n')
01265                 del newref # flush and close
01266         else:
01267             causes += BasicOutputValidator(self.stderr,
01268                                            "standard error",
01269                                            "ExecTest.expected_stderr")(stderr, result)
01270 
01271         return causes


Member Data Documentation

Definition at line 1275 of file GaudiTest.py.

Definition at line 974 of file GaudiTest.py.

Definition at line 1275 of file GaudiTest.py.

Definition at line 1356 of file GaudiTest.py.

Definition at line 1275 of file GaudiTest.py.

Definition at line 1356 of file GaudiTest.py.

Definition at line 1356 of file GaudiTest.py.

Definition at line 1356 of file GaudiTest.py.

Definition at line 1356 of file GaudiTest.py.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Tue May 10 2011 18:55:38 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004