GaudiTest.GaudiExeTest Class Reference
Inheritance diagram for GaudiTest.GaudiExeTest:
Collaboration diagram for GaudiTest.GaudiExeTest:

Public Member Functions

def PlatformIsNotSupported (self, context, result)
 
def GetPlatform (self)
 
def isWinPlatform (self)
 
def CheckTTreesSummaries
 
def CheckHistosSummaries
 
def ValidateWithReference
 
def ValidateOutput (self, stdout, stderr, result)
 
def DumpEnvironment (self, result)
 
def Run (self, context, result)
 
def RunProgram (self, program, arguments, context, result)
 
def PlatformIsNotSupported (self, context, result)
 
def GetPlatform (self)
 
def isWinPlatform (self)
 
def CheckTTreesSummaries
 
def CheckHistosSummaries
 
def ValidateWithReference
 
def ValidateOutput (self, stdout, stderr, result)
 
def DumpEnvironment (self, result)
 
def Run (self, context, result)
 
def RunProgram (self, program, arguments, context, result)
 

Public Attributes

 callable
 
 extra_args
 
 args_order
 
 program
 
 reference
 
 error_reference
 
 use_temp_dir
 
 timeout
 
 signal
 

Static Public Attributes

list arguments
 

Private Member Functions

def _expandReferenceFileName (self, reffile)
 
def _CreateEclipseLaunch
 
def _expandReferenceFileName (self, reffile)
 
def _CreateEclipseLaunch
 

Detailed Description

Standard Gaudi test.

Definition at line 1066 of file GaudiTest.py.

Member Function Documentation

def GaudiTest.GaudiExeTest._CreateEclipseLaunch (   self,
  prog,
  args,
  destdir = None 
)
private

Definition at line 1671 of file GaudiTest.py.

1671  def _CreateEclipseLaunch(self, prog, args, destdir = None):
1672  if 'NO_ECLIPSE_LAUNCHERS' in os.environ:
1673  # do not generate eclipse launchers if the user asks so
1674  return
1675  # Find the project name used in ecplise.
1676  # The name is in a file called ".project" in one of the parent directories
1677  projbasedir = os.path.normpath(destdir)
1678  while not os.path.exists(os.path.join(projbasedir, ".project")):
1679  oldprojdir = projbasedir
1680  projbasedir = os.path.normpath(os.path.join(projbasedir, os.pardir))
1681  # FIXME: the root level is invariant when trying to go up one level,
1682  # but it must be cheched on windows
1683  if oldprojdir == projbasedir:
1684  # If we cannot find a .project, so no point in creating a .launch file
1685  return
1686  # Ensure that we have a place where to write.
1687  if not os.path.exists(destdir):
1688  os.makedirs(destdir)
1689  # Use ElementTree to parse the XML file
1690  from xml.etree import ElementTree as ET
1691  t = ET.parse(os.path.join(projbasedir, ".project"))
1692  projectName = t.find("name").text
1693 
1694  # prepare the name/path of the generated file
1695  destfile = "%s.launch" % self._Runnable__id
1696  if destdir:
1697  destfile = os.path.join(destdir, destfile)
1698 
1699  if self.options.strip():
1700  # this means we have some custom options in the qmt file, so we have
1701  # to copy them from the temporary file at the end of the arguments
1702  # in another file
1703  tempfile = args.pop()
1704  optsfile = destfile + os.path.splitext(tempfile)[1]
1705  shutil.copyfile(tempfile, optsfile)
1706  args.append(optsfile)
1707 
1708  # prepare the data to insert in the XML file
1709  from xml.sax.saxutils import quoteattr # useful to quote XML special chars
1710  data = {}
1711  # Note: the "quoteattr(k)" is not needed because special chars cannot be part of a variable name,
1712  # but it doesn't harm.
1713  data["environment"] = "\n".join(['<mapEntry key=%s value=%s/>' % (quoteattr(k), quoteattr(v))
1714  for k, v in os.environ.iteritems()
1715  if k not in ('MAKEOVERRIDES', 'MAKEFLAGS', 'MAKELEVEL')])
1716 
1717  data["exec"] = which(prog) or prog
1718  if os.path.basename(data["exec"]).lower().startswith("python"):
1719  data["stopAtMain"] = "false" # do not stop at main when debugging Python scripts
1720  else:
1721  data["stopAtMain"] = "true"
1722 
1723  data["args"] = "&#10;".join(map(rationalizepath, args))
1724  if self.isWinPlatform():
1725  data["args"] = "&#10;".join(["/debugexe"] + map(rationalizepath, [data["exec"]] + args))
1726  data["exec"] = which("vcexpress.exe")
1727 
1728  if not self.use_temp_dir:
1729  data["workdir"] = os.getcwd()
1730  else:
1731  # If the test is using a tmporary directory, it is better to run it
1732  # in the same directory as the .launch file when debugged in eclipse
1733  data["workdir"] = destdir
1734 
1735  data["project"] = projectName.strip()
1736 
1737  # Template for the XML file, based on eclipse 3.4
1738  xml_template = u"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1739 <launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
1740 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB" value="true"/>
1741 <listAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB_LIST"/>
1742 <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="gdb"/>
1743 <stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=".gdbinit"/>
1744 <listAttribute key="org.eclipse.cdt.debug.mi.core.SOLIB_PATH"/>
1745 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.STOP_ON_SOLIB_EVENTS" value="false"/>
1746 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.breakpointsFullPath" value="false"/>
1747 <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="org.eclipse.cdt.debug.mi.core.standardCommandFactory"/>
1748 <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
1749 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
1750 <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
1751 <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
1752 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebuggerNew"/>
1753 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
1754 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
1755 <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="%(stopAtMain)s"/>
1756 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
1757 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
1758 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
1759 <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;"/>
1760 <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;"/>
1761 <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;"/>
1762 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="%(args)s"/>
1763 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="%(exec)s"/>
1764 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="%(project)s"/>
1765 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
1766 <stringAttribute key="org.eclipse.cdt.launch.WORKING_DIRECTORY" value="%(workdir)s"/>
1767 <booleanAttribute key="org.eclipse.cdt.launch.ui.ApplicationCDebuggerTab.DEFAULTS_SET" value="true"/>
1768 <booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
1769 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
1770 <listEntry value="/%(project)s"/>
1771 </listAttribute>
1772 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
1773 <listEntry value="4"/>
1774 </listAttribute>
1775 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="false"/>
1776 <mapAttribute key="org.eclipse.debug.core.environmentVariables">
1777 %(environment)s
1778 </mapAttribute>
1779 <mapAttribute key="org.eclipse.debug.core.preferred_launchers">
1780 <mapEntry key="[debug]" value="org.eclipse.cdt.cdi.launch.localCLaunch"/>
1781 </mapAttribute>
1782 <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
1783 <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
1784 </listAttribute>
1785 </launchConfiguration>
1786 """
1787  try:
1788  # ensure the correct encoding of data values
1789  for k in data:
1790  data[k] = codecs.decode(data[k], 'utf-8')
1791  xml = xml_template % data
1792 
1793  # Write the output file
1794  codecs.open(destfile, "w", encoding='utf-8').write(xml)
1795  except:
1796  print 'WARNING: problem generating Eclipse launcher'
1797 
1798 
1799 try:
struct GAUDI_API map
Parametrisation class for map-like implementation.
def which(executable)
Locates an executable in the executables path ($PATH) and returns the full path to it...
Definition: GaudiTest.py:289
def GaudiTest.GaudiExeTest._CreateEclipseLaunch (   self,
  prog,
  args,
  destdir = None 
)
private

Definition at line 1671 of file GaudiTest.py.

1671  def _CreateEclipseLaunch(self, prog, args, destdir = None):
1672  if 'NO_ECLIPSE_LAUNCHERS' in os.environ:
1673  # do not generate eclipse launchers if the user asks so
1674  return
1675  # Find the project name used in ecplise.
1676  # The name is in a file called ".project" in one of the parent directories
1677  projbasedir = os.path.normpath(destdir)
1678  while not os.path.exists(os.path.join(projbasedir, ".project")):
1679  oldprojdir = projbasedir
1680  projbasedir = os.path.normpath(os.path.join(projbasedir, os.pardir))
1681  # FIXME: the root level is invariant when trying to go up one level,
1682  # but it must be cheched on windows
1683  if oldprojdir == projbasedir:
1684  # If we cannot find a .project, so no point in creating a .launch file
1685  return
1686  # Ensure that we have a place where to write.
1687  if not os.path.exists(destdir):
1688  os.makedirs(destdir)
1689  # Use ElementTree to parse the XML file
1690  from xml.etree import ElementTree as ET
1691  t = ET.parse(os.path.join(projbasedir, ".project"))
1692  projectName = t.find("name").text
1693 
1694  # prepare the name/path of the generated file
1695  destfile = "%s.launch" % self._Runnable__id
1696  if destdir:
1697  destfile = os.path.join(destdir, destfile)
1698 
1699  if self.options.strip():
1700  # this means we have some custom options in the qmt file, so we have
1701  # to copy them from the temporary file at the end of the arguments
1702  # in another file
1703  tempfile = args.pop()
1704  optsfile = destfile + os.path.splitext(tempfile)[1]
1705  shutil.copyfile(tempfile, optsfile)
1706  args.append(optsfile)
1707 
1708  # prepare the data to insert in the XML file
1709  from xml.sax.saxutils import quoteattr # useful to quote XML special chars
1710  data = {}
1711  # Note: the "quoteattr(k)" is not needed because special chars cannot be part of a variable name,
1712  # but it doesn't harm.
1713  data["environment"] = "\n".join(['<mapEntry key=%s value=%s/>' % (quoteattr(k), quoteattr(v))
1714  for k, v in os.environ.iteritems()
1715  if k not in ('MAKEOVERRIDES', 'MAKEFLAGS', 'MAKELEVEL')])
1716 
1717  data["exec"] = which(prog) or prog
1718  if os.path.basename(data["exec"]).lower().startswith("python"):
1719  data["stopAtMain"] = "false" # do not stop at main when debugging Python scripts
1720  else:
1721  data["stopAtMain"] = "true"
1722 
1723  data["args"] = "&#10;".join(map(rationalizepath, args))
1724  if self.isWinPlatform():
1725  data["args"] = "&#10;".join(["/debugexe"] + map(rationalizepath, [data["exec"]] + args))
1726  data["exec"] = which("vcexpress.exe")
1727 
1728  if not self.use_temp_dir:
1729  data["workdir"] = os.getcwd()
1730  else:
1731  # If the test is using a tmporary directory, it is better to run it
1732  # in the same directory as the .launch file when debugged in eclipse
1733  data["workdir"] = destdir
1734 
1735  data["project"] = projectName.strip()
1736 
1737  # Template for the XML file, based on eclipse 3.4
1738  xml_template = u"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1739 <launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
1740 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB" value="true"/>
1741 <listAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB_LIST"/>
1742 <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="gdb"/>
1743 <stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=".gdbinit"/>
1744 <listAttribute key="org.eclipse.cdt.debug.mi.core.SOLIB_PATH"/>
1745 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.STOP_ON_SOLIB_EVENTS" value="false"/>
1746 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.breakpointsFullPath" value="false"/>
1747 <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="org.eclipse.cdt.debug.mi.core.standardCommandFactory"/>
1748 <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
1749 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
1750 <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
1751 <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
1752 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebuggerNew"/>
1753 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
1754 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
1755 <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="%(stopAtMain)s"/>
1756 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
1757 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
1758 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
1759 <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;"/>
1760 <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;"/>
1761 <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;"/>
1762 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="%(args)s"/>
1763 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="%(exec)s"/>
1764 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="%(project)s"/>
1765 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
1766 <stringAttribute key="org.eclipse.cdt.launch.WORKING_DIRECTORY" value="%(workdir)s"/>
1767 <booleanAttribute key="org.eclipse.cdt.launch.ui.ApplicationCDebuggerTab.DEFAULTS_SET" value="true"/>
1768 <booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
1769 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
1770 <listEntry value="/%(project)s"/>
1771 </listAttribute>
1772 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
1773 <listEntry value="4"/>
1774 </listAttribute>
1775 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="false"/>
1776 <mapAttribute key="org.eclipse.debug.core.environmentVariables">
1777 %(environment)s
1778 </mapAttribute>
1779 <mapAttribute key="org.eclipse.debug.core.preferred_launchers">
1780 <mapEntry key="[debug]" value="org.eclipse.cdt.cdi.launch.localCLaunch"/>
1781 </mapAttribute>
1782 <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
1783 <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
1784 </listAttribute>
1785 </launchConfiguration>
1786 """
1787  try:
1788  # ensure the correct encoding of data values
1789  for k in data:
1790  data[k] = codecs.decode(data[k], 'utf-8')
1791  xml = xml_template % data
1792 
1793  # Write the output file
1794  codecs.open(destfile, "w", encoding='utf-8').write(xml)
1795  except:
1796  print 'WARNING: problem generating Eclipse launcher'
1797 
1798 
1799 try:
struct GAUDI_API map
Parametrisation class for map-like implementation.
def which(executable)
Locates an executable in the executables path ($PATH) and returns the full path to it...
Definition: GaudiTest.py:289
def GaudiTest.GaudiExeTest._expandReferenceFileName (   self,
  reffile 
)
private

Definition at line 1226 of file GaudiTest.py.

1226  def _expandReferenceFileName(self, reffile):
1227  # if no file is passed, do nothing
1228  if not reffile:
1229  return ""
1230 
1231  # function to split an extension in constituents parts
1232  platformSplit = lambda p: set(p.split('-' in p and '-' or '_'))
1233 
1234  reference = os.path.normpath(os.path.expandvars(reffile))
1235  # old-style platform-specific reference name
1236  spec_ref = reference[:-3] + self.GetPlatform()[0:3] + reference[-3:]
1237  if os.path.isfile(spec_ref):
1238  reference = spec_ref
1239  else: # look for new-style platform specific reference files:
1240  # get all the files whose name start with the reference filename
1241  dirname, basename = os.path.split(reference)
1242  if not dirname: dirname = '.'
1243  head = basename + "."
1244  head_len = len(head)
1245  platform = platformSplit(self.GetPlatform())
1246  if 'do0' in platform:
1247  platform.add('dbg')
1248  candidates = []
1249  for f in os.listdir(dirname):
1250  if f.startswith(head):
1251  req_plat = platformSplit(f[head_len:])
1252  if platform.issuperset(req_plat):
1253  candidates.append( (len(req_plat), f) )
1254  if candidates: # take the one with highest matching
1255  # FIXME: it is not possible to say if x86_64-slc5-gcc43-dbg
1256  # has to use ref.x86_64-gcc43 or ref.slc5-dbg
1257  candidates.sort()
1258  reference = os.path.join(dirname, candidates[-1][1])
1259  return reference
1260 
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
def GaudiTest.GaudiExeTest._expandReferenceFileName (   self,
  reffile 
)
private

Definition at line 1226 of file GaudiTest.py.

1226  def _expandReferenceFileName(self, reffile):
1227  # if no file is passed, do nothing
1228  if not reffile:
1229  return ""
1230 
1231  # function to split an extension in constituents parts
1232  platformSplit = lambda p: set(p.split('-' in p and '-' or '_'))
1233 
1234  reference = os.path.normpath(os.path.expandvars(reffile))
1235  # old-style platform-specific reference name
1236  spec_ref = reference[:-3] + self.GetPlatform()[0:3] + reference[-3:]
1237  if os.path.isfile(spec_ref):
1238  reference = spec_ref
1239  else: # look for new-style platform specific reference files:
1240  # get all the files whose name start with the reference filename
1241  dirname, basename = os.path.split(reference)
1242  if not dirname: dirname = '.'
1243  head = basename + "."
1244  head_len = len(head)
1245  platform = platformSplit(self.GetPlatform())
1246  if 'do0' in platform:
1247  platform.add('dbg')
1248  candidates = []
1249  for f in os.listdir(dirname):
1250  if f.startswith(head):
1251  req_plat = platformSplit(f[head_len:])
1252  if platform.issuperset(req_plat):
1253  candidates.append( (len(req_plat), f) )
1254  if candidates: # take the one with highest matching
1255  # FIXME: it is not possible to say if x86_64-slc5-gcc43-dbg
1256  # has to use ref.x86_64-gcc43 or ref.slc5-dbg
1257  candidates.sort()
1258  reference = os.path.join(dirname, candidates[-1][1])
1259  return reference
1260 
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
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 1297 of file GaudiTest.py.

1297  ignore = None):
1298  """
1299  Compare the TTree summaries in stdout with the ones in trees_dict or in
1300  the reference file. By default ignore the size, compression and basket
1301  fields.
1302  The presence of TTree summaries when none is expected is not a failure.
1303  """
1304  if dict is None:
1305  reference = self._expandReferenceFileName(self.reference)
1306  # call the validator if the file exists
1307  if reference and os.path.isfile(reference):
1308  dict = findHistosSummaries(open(reference).read())
1309  else:
1310  dict = {}
1311 
1312  from pprint import PrettyPrinter
1313  pp = PrettyPrinter()
1314  if dict:
1315  result["GaudiTest.Histos.expected"] = result.Quote(pp.pformat(dict))
1316  if ignore:
1317  result["GaudiTest.Histos.ignore"] = result.Quote(ignore)
1318 
1319  histos = findHistosSummaries(stdout)
1320  failed = cmpTreesDicts(dict, histos, ignore)
1321  if failed:
1322  causes.append("histos summaries")
1323  msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed)
1324  result["GaudiTest.Histos.failure_on"] = result.Quote(msg)
1325  result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos))
1326 
1327  return causes
1328 
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
def cmpTreesDicts
Definition: GaudiTest.py:777
def getCmpFailingValues(reference, to_check, fail_path)
Definition: GaudiTest.py:808
def findHistosSummaries(stdout)
Definition: GaudiTest.py:884
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 1297 of file GaudiTest.py.

1297  ignore = None):
1298  """
1299  Compare the TTree summaries in stdout with the ones in trees_dict or in
1300  the reference file. By default ignore the size, compression and basket
1301  fields.
1302  The presence of TTree summaries when none is expected is not a failure.
1303  """
1304  if dict is None:
1305  reference = self._expandReferenceFileName(self.reference)
1306  # call the validator if the file exists
1307  if reference and os.path.isfile(reference):
1308  dict = findHistosSummaries(open(reference).read())
1309  else:
1310  dict = {}
1311 
1312  from pprint import PrettyPrinter
1313  pp = PrettyPrinter()
1314  if dict:
1315  result["GaudiTest.Histos.expected"] = result.Quote(pp.pformat(dict))
1316  if ignore:
1317  result["GaudiTest.Histos.ignore"] = result.Quote(ignore)
1318 
1319  histos = findHistosSummaries(stdout)
1320  failed = cmpTreesDicts(dict, histos, ignore)
1321  if failed:
1322  causes.append("histos summaries")
1323  msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed)
1324  result["GaudiTest.Histos.failure_on"] = result.Quote(msg)
1325  result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos))
1326 
1327  return causes
1328 
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
def cmpTreesDicts
Definition: GaudiTest.py:777
def getCmpFailingValues(reference, to_check, fail_path)
Definition: GaudiTest.py:808
def findHistosSummaries(stdout)
Definition: GaudiTest.py:884
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 1263 of file GaudiTest.py.

1263  ignore = r"Basket|.*size|Compression"):
1264  """
1265  Compare the TTree summaries in stdout with the ones in trees_dict or in
1266  the reference file. By default ignore the size, compression and basket
1267  fields.
1268  The presence of TTree summaries when none is expected is not a failure.
1269  """
1270  if trees_dict is None:
1271  reference = self._expandReferenceFileName(self.reference)
1272  # call the validator if the file exists
1273  if reference and os.path.isfile(reference):
1274  trees_dict = findTTreeSummaries(open(reference).read())
1275  else:
1276  trees_dict = {}
1277 
1278  from pprint import PrettyPrinter
1279  pp = PrettyPrinter()
1280  if trees_dict:
1281  result["GaudiTest.TTrees.expected"] = result.Quote(pp.pformat(trees_dict))
1282  if ignore:
1283  result["GaudiTest.TTrees.ignore"] = result.Quote(ignore)
1284 
1285  trees = findTTreeSummaries(stdout)
1286  failed = cmpTreesDicts(trees_dict, trees, ignore)
1287  if failed:
1288  causes.append("trees summaries")
1289  msg = "%s: %s != %s" % getCmpFailingValues(trees_dict, trees, failed)
1290  result["GaudiTest.TTrees.failure_on"] = result.Quote(msg)
1291  result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees))
1292 
1293  return causes
1294 
def findTTreeSummaries(stdout)
Definition: GaudiTest.py:756
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
def cmpTreesDicts
Definition: GaudiTest.py:777
def getCmpFailingValues(reference, to_check, fail_path)
Definition: GaudiTest.py:808
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 1263 of file GaudiTest.py.

1263  ignore = r"Basket|.*size|Compression"):
1264  """
1265  Compare the TTree summaries in stdout with the ones in trees_dict or in
1266  the reference file. By default ignore the size, compression and basket
1267  fields.
1268  The presence of TTree summaries when none is expected is not a failure.
1269  """
1270  if trees_dict is None:
1271  reference = self._expandReferenceFileName(self.reference)
1272  # call the validator if the file exists
1273  if reference and os.path.isfile(reference):
1274  trees_dict = findTTreeSummaries(open(reference).read())
1275  else:
1276  trees_dict = {}
1277 
1278  from pprint import PrettyPrinter
1279  pp = PrettyPrinter()
1280  if trees_dict:
1281  result["GaudiTest.TTrees.expected"] = result.Quote(pp.pformat(trees_dict))
1282  if ignore:
1283  result["GaudiTest.TTrees.ignore"] = result.Quote(ignore)
1284 
1285  trees = findTTreeSummaries(stdout)
1286  failed = cmpTreesDicts(trees_dict, trees, ignore)
1287  if failed:
1288  causes.append("trees summaries")
1289  msg = "%s: %s != %s" % getCmpFailingValues(trees_dict, trees, failed)
1290  result["GaudiTest.TTrees.failure_on"] = result.Quote(msg)
1291  result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees))
1292 
1293  return causes
1294 
def findTTreeSummaries(stdout)
Definition: GaudiTest.py:756
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
def cmpTreesDicts
Definition: GaudiTest.py:777
def getCmpFailingValues(reference, to_check, fail_path)
Definition: GaudiTest.py:808
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 1451 of file GaudiTest.py.

1451  def DumpEnvironment(self, result):
1452  """
1453  Add the content of the environment to the result object.
1454 
1455  Copied from the QMTest class of COOL.
1456  """
1457  vars = os.environ.keys()
1458  vars.sort()
1459  result['GaudiTest.environment'] = \
1460  result.Quote('\n'.join(["%s=%s"%(v,os.environ[v]) for v in vars]))
1461 
def DumpEnvironment(self, result)
Definition: GaudiTest.py:1451
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 1451 of file GaudiTest.py.

1451  def DumpEnvironment(self, result):
1452  """
1453  Add the content of the environment to the result object.
1454 
1455  Copied from the QMTest class of COOL.
1456  """
1457  vars = os.environ.keys()
1458  vars.sort()
1459  result['GaudiTest.environment'] = \
1460  result.Quote('\n'.join(["%s=%s"%(v,os.environ[v]) for v in vars]))
1461 
def DumpEnvironment(self, result)
Definition: GaudiTest.py:1451
def GaudiTest.GaudiExeTest.GetPlatform (   self)
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.

Definition at line 1204 of file GaudiTest.py.

1204  def GetPlatform(self):
1205  """
1206  Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
1207  """
1208  arch = "None"
1209  # check architecture name
1210  if "CMTCONFIG" in os.environ:
1211  arch = os.environ["CMTCONFIG"]
1212  elif "SCRAM_ARCH" in os.environ:
1213  arch = os.environ["SCRAM_ARCH"]
1214  return arch
1215 
def GaudiTest.GaudiExeTest.GetPlatform (   self)
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.

Definition at line 1204 of file GaudiTest.py.

1204  def GetPlatform(self):
1205  """
1206  Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
1207  """
1208  arch = "None"
1209  # check architecture name
1210  if "CMTCONFIG" in os.environ:
1211  arch = os.environ["CMTCONFIG"]
1212  elif "SCRAM_ARCH" in os.environ:
1213  arch = os.environ["SCRAM_ARCH"]
1214  return arch
1215 
def GaudiTest.GaudiExeTest.isWinPlatform (   self)
Return True if the current platform is Windows.

This function was needed because of the change in the CMTCONFIG format,
from win32_vc71_dbg to i686-winxp-vc9-dbg.

Definition at line 1216 of file GaudiTest.py.

1216  def isWinPlatform(self):
1217  """
1218  Return True if the current platform is Windows.
1219 
1220  This function was needed because of the change in the CMTCONFIG format,
1221  from win32_vc71_dbg to i686-winxp-vc9-dbg.
1222  """
1223  platform = self.GetPlatform()
1224  return "winxp" in platform or platform.startswith("win")
1225 
def GaudiTest.GaudiExeTest.isWinPlatform (   self)
Return True if the current platform is Windows.

This function was needed because of the change in the CMTCONFIG format,
from win32_vc71_dbg to i686-winxp-vc9-dbg.

Definition at line 1216 of file GaudiTest.py.

1216  def isWinPlatform(self):
1217  """
1218  Return True if the current platform is Windows.
1219 
1220  This function was needed because of the change in the CMTCONFIG format,
1221  from win32_vc71_dbg to i686-winxp-vc9-dbg.
1222  """
1223  platform = self.GetPlatform()
1224  return "winxp" in platform or platform.startswith("win")
1225 
def GaudiTest.GaudiExeTest.PlatformIsNotSupported (   self,
  context,
  result 
)

Definition at line 1190 of file GaudiTest.py.

1190  def PlatformIsNotSupported(self, context, result):
1191  platform = self.GetPlatform()
1192  unsupported = [ re.compile(x)
1193  for x in [ str(y).strip()
1194  for y in self.unsupported_platforms ]
1195  if x
1196  ]
1197  for p_re in unsupported:
1198  if p_re.search(platform):
1199  result.SetOutcome(result.UNTESTED)
1200  result[result.CAUSE] = 'Platform not supported.'
1201  return True
1202  return False
1203 
def PlatformIsNotSupported(self, context, result)
Definition: GaudiTest.py:1190
def GaudiTest.GaudiExeTest.PlatformIsNotSupported (   self,
  context,
  result 
)

Definition at line 1190 of file GaudiTest.py.

1190  def PlatformIsNotSupported(self, context, result):
1191  platform = self.GetPlatform()
1192  unsupported = [ re.compile(x)
1193  for x in [ str(y).strip()
1194  for y in self.unsupported_platforms ]
1195  if x
1196  ]
1197  for p_re in unsupported:
1198  if p_re.search(platform):
1199  result.SetOutcome(result.UNTESTED)
1200  result[result.CAUSE] = 'Platform not supported.'
1201  return True
1202  return False
1203 
def PlatformIsNotSupported(self, context, result)
Definition: GaudiTest.py:1190
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 1462 of file GaudiTest.py.

1462  def Run(self, context, result):
1463  """Run the test.
1464 
1465  'context' -- A 'Context' giving run-time parameters to the
1466  test.
1467 
1468  'result' -- A 'Result' object. The outcome will be
1469  'Result.PASS' when this method is called. The 'result' may be
1470  modified by this method to indicate outcomes other than
1471  'Result.PASS' or to add annotations."""
1472 
1473  # Check if the platform is supported
1474  if self.PlatformIsNotSupported(context, result):
1475  return
1476 
1477  # Prepare program name and arguments (expanding variables, and converting to absolute)
1478  if self.program:
1479  prog = rationalizepath(self.program)
1480  elif "GAUDIEXE" in os.environ:
1481  prog = os.environ["GAUDIEXE"]
1482  else:
1483  prog = "Gaudi.exe"
1484  self.program = prog
1485 
1486  dummy, prog_ext = os.path.splitext(prog)
1487  if prog_ext not in [ ".exe", ".py", ".bat" ] and self.isWinPlatform():
1488  prog += ".exe"
1489  prog_ext = ".exe"
1490 
1491  prog = which(prog) or prog
1492 
1493  # Convert paths to absolute paths in arguments and reference files
1494  args = map(rationalizepath, self.args)
1497 
1498 
1499  # check if the user provided inline options
1500  tmpfile = None
1501  if self.options.strip():
1502  ext = ".opts"
1503  if re.search(r"from\s+Gaudi.Configuration\s+import\s+\*|from\s+Configurables\s+import", self.options):
1504  ext = ".py"
1505  tmpfile = TempFile(ext)
1506  tmpfile.writelines("\n".join(self.options.splitlines()))
1507  tmpfile.flush()
1508  args.append(tmpfile.name)
1509  result["GaudiTest.options"] = result.Quote(self.options)
1510 
1511  # if the program is a python file, execute it through python
1512  if prog_ext == ".py":
1513  args.insert(0,prog)
1514  if self.isWinPlatform():
1515  prog = which("python.exe") or "python.exe"
1516  else:
1517  prog = which("python") or "python"
1518 
1519  # Change to the working directory if specified or to the default temporary
1520  origdir = os.getcwd()
1521  if self.workdir:
1522  os.chdir(str(os.path.normpath(os.path.expandvars(self.workdir))))
1523  elif self.use_temp_dir == "true":
1524  if "QMTEST_TMPDIR" in os.environ:
1525  qmtest_tmpdir = os.environ["QMTEST_TMPDIR"]
1526  if not os.path.exists(qmtest_tmpdir):
1527  os.makedirs(qmtest_tmpdir)
1528  os.chdir(qmtest_tmpdir)
1529  elif "qmtest.tmpdir" in context:
1530  os.chdir(context["qmtest.tmpdir"])
1531 
1532  if "QMTEST_IGNORE_TIMEOUT" not in os.environ:
1533  self.timeout = max(self.timeout,600)
1534  else:
1535  self.timeout = -1
1536 
1537  try:
1538  # Generate eclipse.org debug launcher for the test
1539  self._CreateEclipseLaunch(prog, args, destdir = os.path.join(origdir, '.eclipse'))
1540  # Run the test
1541  self.RunProgram(prog,
1542  [ prog ] + args,
1543  context, result)
1544  # Record the content of the enfironment for failing tests
1545  if result.GetOutcome() not in [ result.PASS ]:
1546  self.DumpEnvironment(result)
1547  finally:
1548  # revert to the original directory
1549  os.chdir(origdir)
1550 
def PlatformIsNotSupported(self, context, result)
Definition: GaudiTest.py:1190
def DumpEnvironment(self, result)
Definition: GaudiTest.py:1451
def RunProgram(self, program, arguments, context, result)
Definition: GaudiTest.py:1551
struct GAUDI_API map
Parametrisation class for map-like implementation.
def rationalizepath(p)
Definition: GaudiTest.py:309
def Run(self, context, result)
Definition: GaudiTest.py:1462
def which(executable)
Locates an executable in the executables path ($PATH) and returns the full path to it...
Definition: GaudiTest.py:289
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 1462 of file GaudiTest.py.

1462  def Run(self, context, result):
1463  """Run the test.
1464 
1465  'context' -- A 'Context' giving run-time parameters to the
1466  test.
1467 
1468  'result' -- A 'Result' object. The outcome will be
1469  'Result.PASS' when this method is called. The 'result' may be
1470  modified by this method to indicate outcomes other than
1471  'Result.PASS' or to add annotations."""
1472 
1473  # Check if the platform is supported
1474  if self.PlatformIsNotSupported(context, result):
1475  return
1476 
1477  # Prepare program name and arguments (expanding variables, and converting to absolute)
1478  if self.program:
1479  prog = rationalizepath(self.program)
1480  elif "GAUDIEXE" in os.environ:
1481  prog = os.environ["GAUDIEXE"]
1482  else:
1483  prog = "Gaudi.exe"
1484  self.program = prog
1485 
1486  dummy, prog_ext = os.path.splitext(prog)
1487  if prog_ext not in [ ".exe", ".py", ".bat" ] and self.isWinPlatform():
1488  prog += ".exe"
1489  prog_ext = ".exe"
1490 
1491  prog = which(prog) or prog
1492 
1493  # Convert paths to absolute paths in arguments and reference files
1494  args = map(rationalizepath, self.args)
1497 
1498 
1499  # check if the user provided inline options
1500  tmpfile = None
1501  if self.options.strip():
1502  ext = ".opts"
1503  if re.search(r"from\s+Gaudi.Configuration\s+import\s+\*|from\s+Configurables\s+import", self.options):
1504  ext = ".py"
1505  tmpfile = TempFile(ext)
1506  tmpfile.writelines("\n".join(self.options.splitlines()))
1507  tmpfile.flush()
1508  args.append(tmpfile.name)
1509  result["GaudiTest.options"] = result.Quote(self.options)
1510 
1511  # if the program is a python file, execute it through python
1512  if prog_ext == ".py":
1513  args.insert(0,prog)
1514  if self.isWinPlatform():
1515  prog = which("python.exe") or "python.exe"
1516  else:
1517  prog = which("python") or "python"
1518 
1519  # Change to the working directory if specified or to the default temporary
1520  origdir = os.getcwd()
1521  if self.workdir:
1522  os.chdir(str(os.path.normpath(os.path.expandvars(self.workdir))))
1523  elif self.use_temp_dir == "true":
1524  if "QMTEST_TMPDIR" in os.environ:
1525  qmtest_tmpdir = os.environ["QMTEST_TMPDIR"]
1526  if not os.path.exists(qmtest_tmpdir):
1527  os.makedirs(qmtest_tmpdir)
1528  os.chdir(qmtest_tmpdir)
1529  elif "qmtest.tmpdir" in context:
1530  os.chdir(context["qmtest.tmpdir"])
1531 
1532  if "QMTEST_IGNORE_TIMEOUT" not in os.environ:
1533  self.timeout = max(self.timeout,600)
1534  else:
1535  self.timeout = -1
1536 
1537  try:
1538  # Generate eclipse.org debug launcher for the test
1539  self._CreateEclipseLaunch(prog, args, destdir = os.path.join(origdir, '.eclipse'))
1540  # Run the test
1541  self.RunProgram(prog,
1542  [ prog ] + args,
1543  context, result)
1544  # Record the content of the enfironment for failing tests
1545  if result.GetOutcome() not in [ result.PASS ]:
1546  self.DumpEnvironment(result)
1547  finally:
1548  # revert to the original directory
1549  os.chdir(origdir)
1550 
def PlatformIsNotSupported(self, context, result)
Definition: GaudiTest.py:1190
def DumpEnvironment(self, result)
Definition: GaudiTest.py:1451
def RunProgram(self, program, arguments, context, result)
Definition: GaudiTest.py:1551
struct GAUDI_API map
Parametrisation class for map-like implementation.
def rationalizepath(p)
Definition: GaudiTest.py:309
def Run(self, context, result)
Definition: GaudiTest.py:1462
def which(executable)
Locates an executable in the executables path ($PATH) and returns the full path to it...
Definition: GaudiTest.py:289
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 1551 of file GaudiTest.py.

1551  def RunProgram(self, program, arguments, context, result):
1552  """Run the 'program'.
1553 
1554  'program' -- The path to the program to run.
1555 
1556  'arguments' -- A list of the arguments to the program. This
1557  list must contain a first argument corresponding to 'argv[0]'.
1558 
1559  'context' -- A 'Context' giving run-time parameters to the
1560  test.
1561 
1562  'result' -- A 'Result' object. The outcome will be
1563  'Result.PASS' when this method is called. The 'result' may be
1564  modified by this method to indicate outcomes other than
1565  'Result.PASS' or to add annotations.
1566 
1567  @attention: This method has been copied from command.ExecTestBase
1568  (QMTest 2.3.0) and modified to keep stdout and stderr
1569  for tests that have been terminated by a signal.
1570  (Fundamental for debugging in the Application Area)
1571  """
1572 
1573  # Construct the environment.
1574  environment = self.MakeEnvironment(context)
1575  # FIXME: whithout this, we get some spurious '\x1b[?1034' in the std out on SLC6
1576  if "slc6" in environment.get('CMTCONFIG', ''):
1577  environment['TERM'] = 'dumb'
1578  # Create the executable.
1579  if self.timeout >= 0:
1580  timeout = self.timeout
1581  else:
1582  # If no timeout was specified, we sill run this process in a
1583  # separate process group and kill the entire process group
1584  # when the child is done executing. That means that
1585  # orphaned child processes created by the test will be
1586  # cleaned up.
1587  timeout = -2
1588  e = GaudiFilterExecutable(self.stdin, timeout)
1589  # Run it.
1590  exit_status = e.Run(arguments, environment, path = program)
1591  # Get the stack trace from the temporary file (if present)
1592  if e.stack_trace_file and os.path.exists(e.stack_trace_file):
1593  stack_trace = open(e.stack_trace_file).read()
1594  os.remove(e.stack_trace_file)
1595  else:
1596  stack_trace = None
1597  if stack_trace:
1598  result["ExecTest.stack_trace"] = result.Quote(stack_trace)
1599 
1600  # If the process terminated normally, check the outputs.
1601  if (sys.platform == "win32" or os.WIFEXITED(exit_status)
1602  or self.signal == os.WTERMSIG(exit_status)):
1603  # There are no causes of failure yet.
1604  causes = []
1605  # The target program terminated normally. Extract the
1606  # exit code, if this test checks it.
1607  if self.exit_code is None:
1608  exit_code = None
1609  elif sys.platform == "win32":
1610  exit_code = exit_status
1611  else:
1612  exit_code = os.WEXITSTATUS(exit_status)
1613  # Get the output generated by the program.
1614  stdout = e.stdout
1615  stderr = e.stderr
1616  # Record the results.
1617  result["ExecTest.exit_code"] = str(exit_code)
1618  result["ExecTest.stdout"] = result.Quote(stdout)
1619  result["ExecTest.stderr"] = result.Quote(stderr)
1620  # Check to see if the exit code matches.
1621  if exit_code != self.exit_code:
1622  causes.append("exit_code")
1623  result["ExecTest.expected_exit_code"] \
1624  = str(self.exit_code)
1625  # Validate the output.
1626  causes += self.ValidateOutput(stdout, stderr, result)
1627  # If anything went wrong, the test failed.
1628  if causes:
1629  result.Fail("Unexpected %s." % string.join(causes, ", "))
1630  elif os.WIFSIGNALED(exit_status):
1631  # The target program terminated with a signal. Construe
1632  # that as a test failure.
1633  signal_number = str(os.WTERMSIG(exit_status))
1634  if not stack_trace:
1635  result.Fail("Program terminated by signal.")
1636  else:
1637  # The presence of stack_trace means tha we stopped the job because
1638  # of a time-out
1639  result.Fail("Exceeded time limit (%ds), terminated." % timeout)
1640  result["ExecTest.signal_number"] = signal_number
1641  result["ExecTest.stdout"] = result.Quote(e.stdout)
1642  result["ExecTest.stderr"] = result.Quote(e.stderr)
1643  if self.signal:
1644  result["ExecTest.expected_signal_number"] = str(self.signal)
1645  elif os.WIFSTOPPED(exit_status):
1646  # The target program was stopped. Construe that as a
1647  # test failure.
1648  signal_number = str(os.WSTOPSIG(exit_status))
1649  if not stack_trace:
1650  result.Fail("Program stopped by signal.")
1651  else:
1652  # The presence of stack_trace means tha we stopped the job because
1653  # of a time-out
1654  result.Fail("Exceeded time limit (%ds), stopped." % timeout)
1655  result["ExecTest.signal_number"] = signal_number
1656  result["ExecTest.stdout"] = result.Quote(e.stdout)
1657  result["ExecTest.stderr"] = result.Quote(e.stderr)
1658  else:
1659  # The target program terminated abnormally in some other
1660  # manner. (This shouldn't normally happen...)
1661  result.Fail("Program did not terminate normally.")
1662 
1663  # Marco Cl.: This is a special trick to fix a "problem" with the output
1664  # of gaudi jobs when they use colors
1665  esc = '\x1b'
1666  repr_esc = '\\x1b'
1667  result["ExecTest.stdout"] = result["ExecTest.stdout"].replace(esc,repr_esc)
1668  # TODO: (MCl) improve the hack for colors in standard output
1669  # may be converting them to HTML tags
1670 
def RunProgram(self, program, arguments, context, result)
Definition: GaudiTest.py:1551
def ValidateOutput(self, stdout, stderr, result)
Definition: GaudiTest.py:1386
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 1551 of file GaudiTest.py.

1551  def RunProgram(self, program, arguments, context, result):
1552  """Run the 'program'.
1553 
1554  'program' -- The path to the program to run.
1555 
1556  'arguments' -- A list of the arguments to the program. This
1557  list must contain a first argument corresponding to 'argv[0]'.
1558 
1559  'context' -- A 'Context' giving run-time parameters to the
1560  test.
1561 
1562  'result' -- A 'Result' object. The outcome will be
1563  'Result.PASS' when this method is called. The 'result' may be
1564  modified by this method to indicate outcomes other than
1565  'Result.PASS' or to add annotations.
1566 
1567  @attention: This method has been copied from command.ExecTestBase
1568  (QMTest 2.3.0) and modified to keep stdout and stderr
1569  for tests that have been terminated by a signal.
1570  (Fundamental for debugging in the Application Area)
1571  """
1572 
1573  # Construct the environment.
1574  environment = self.MakeEnvironment(context)
1575  # FIXME: whithout this, we get some spurious '\x1b[?1034' in the std out on SLC6
1576  if "slc6" in environment.get('CMTCONFIG', ''):
1577  environment['TERM'] = 'dumb'
1578  # Create the executable.
1579  if self.timeout >= 0:
1580  timeout = self.timeout
1581  else:
1582  # If no timeout was specified, we sill run this process in a
1583  # separate process group and kill the entire process group
1584  # when the child is done executing. That means that
1585  # orphaned child processes created by the test will be
1586  # cleaned up.
1587  timeout = -2
1588  e = GaudiFilterExecutable(self.stdin, timeout)
1589  # Run it.
1590  exit_status = e.Run(arguments, environment, path = program)
1591  # Get the stack trace from the temporary file (if present)
1592  if e.stack_trace_file and os.path.exists(e.stack_trace_file):
1593  stack_trace = open(e.stack_trace_file).read()
1594  os.remove(e.stack_trace_file)
1595  else:
1596  stack_trace = None
1597  if stack_trace:
1598  result["ExecTest.stack_trace"] = result.Quote(stack_trace)
1599 
1600  # If the process terminated normally, check the outputs.
1601  if (sys.platform == "win32" or os.WIFEXITED(exit_status)
1602  or self.signal == os.WTERMSIG(exit_status)):
1603  # There are no causes of failure yet.
1604  causes = []
1605  # The target program terminated normally. Extract the
1606  # exit code, if this test checks it.
1607  if self.exit_code is None:
1608  exit_code = None
1609  elif sys.platform == "win32":
1610  exit_code = exit_status
1611  else:
1612  exit_code = os.WEXITSTATUS(exit_status)
1613  # Get the output generated by the program.
1614  stdout = e.stdout
1615  stderr = e.stderr
1616  # Record the results.
1617  result["ExecTest.exit_code"] = str(exit_code)
1618  result["ExecTest.stdout"] = result.Quote(stdout)
1619  result["ExecTest.stderr"] = result.Quote(stderr)
1620  # Check to see if the exit code matches.
1621  if exit_code != self.exit_code:
1622  causes.append("exit_code")
1623  result["ExecTest.expected_exit_code"] \
1624  = str(self.exit_code)
1625  # Validate the output.
1626  causes += self.ValidateOutput(stdout, stderr, result)
1627  # If anything went wrong, the test failed.
1628  if causes:
1629  result.Fail("Unexpected %s." % string.join(causes, ", "))
1630  elif os.WIFSIGNALED(exit_status):
1631  # The target program terminated with a signal. Construe
1632  # that as a test failure.
1633  signal_number = str(os.WTERMSIG(exit_status))
1634  if not stack_trace:
1635  result.Fail("Program terminated by signal.")
1636  else:
1637  # The presence of stack_trace means tha we stopped the job because
1638  # of a time-out
1639  result.Fail("Exceeded time limit (%ds), terminated." % timeout)
1640  result["ExecTest.signal_number"] = signal_number
1641  result["ExecTest.stdout"] = result.Quote(e.stdout)
1642  result["ExecTest.stderr"] = result.Quote(e.stderr)
1643  if self.signal:
1644  result["ExecTest.expected_signal_number"] = str(self.signal)
1645  elif os.WIFSTOPPED(exit_status):
1646  # The target program was stopped. Construe that as a
1647  # test failure.
1648  signal_number = str(os.WSTOPSIG(exit_status))
1649  if not stack_trace:
1650  result.Fail("Program stopped by signal.")
1651  else:
1652  # The presence of stack_trace means tha we stopped the job because
1653  # of a time-out
1654  result.Fail("Exceeded time limit (%ds), stopped." % timeout)
1655  result["ExecTest.signal_number"] = signal_number
1656  result["ExecTest.stdout"] = result.Quote(e.stdout)
1657  result["ExecTest.stderr"] = result.Quote(e.stderr)
1658  else:
1659  # The target program terminated abnormally in some other
1660  # manner. (This shouldn't normally happen...)
1661  result.Fail("Program did not terminate normally.")
1662 
1663  # Marco Cl.: This is a special trick to fix a "problem" with the output
1664  # of gaudi jobs when they use colors
1665  esc = '\x1b'
1666  repr_esc = '\\x1b'
1667  result["ExecTest.stdout"] = result["ExecTest.stdout"].replace(esc,repr_esc)
1668  # TODO: (MCl) improve the hack for colors in standard output
1669  # may be converting them to HTML tags
1670 
def RunProgram(self, program, arguments, context, result)
Definition: GaudiTest.py:1551
def ValidateOutput(self, stdout, stderr, result)
Definition: GaudiTest.py:1386
def GaudiTest.GaudiExeTest.ValidateOutput (   self,
  stdout,
  stderr,
  result 
)

Definition at line 1386 of file GaudiTest.py.

1386  def ValidateOutput(self, stdout, stderr, result):
1387  causes = []
1388  # if the test definition contains a custom validator, use it
1389  if self.validator.strip() != "":
1390  class CallWrapper(object):
1391  """
1392  Small wrapper class to dynamically bind some default arguments
1393  to a callable.
1394  """
1395  def __init__(self, callable, extra_args = {}):
1396  self.callable = callable
1397  self.extra_args = extra_args
1398  # get the list of names of positional arguments
1399  from inspect import getargspec
1400  self.args_order = getargspec(callable)[0]
1401  # Remove "self" from the list of positional arguments
1402  # since it is added automatically
1403  if self.args_order[0] == "self":
1404  del self.args_order[0]
1405  def __call__(self, *args, **kwargs):
1406  # Check which positional arguments are used
1407  positional = self.args_order[:len(args)]
1408 
1409  kwargs = dict(kwargs) # copy the arguments dictionary
1410  for a in self.extra_args:
1411  # use "extra_args" for the arguments not specified as
1412  # positional or keyword
1413  if a not in positional and a not in kwargs:
1414  kwargs[a] = self.extra_args[a]
1415  return apply(self.callable, args, kwargs)
1416  # local names to be exposed in the script
1417  exported_symbols = {"self":self,
1418  "stdout":stdout,
1419  "stderr":stderr,
1420  "result":result,
1421  "causes":causes,
1422  "findReferenceBlock":
1423  CallWrapper(findReferenceBlock, {"stdout":stdout,
1424  "result":result,
1425  "causes":causes}),
1426  "validateWithReference":
1427  CallWrapper(self.ValidateWithReference, {"stdout":stdout,
1428  "stderr":stderr,
1429  "result":result,
1430  "causes":causes}),
1431  "countErrorLines":
1432  CallWrapper(countErrorLines, {"stdout":stdout,
1433  "result":result,
1434  "causes":causes}),
1435  "checkTTreesSummaries":
1436  CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout,
1437  "result":result,
1438  "causes":causes}),
1439  "checkHistosSummaries":
1440  CallWrapper(self.CheckHistosSummaries, {"stdout":stdout,
1441  "result":result,
1442  "causes":causes}),
1443 
1444  }
1445  exec self.validator in globals(), exported_symbols
1446  else:
1447  self.ValidateWithReference(stdout, stderr, result, causes)
1448 
1449  return causes
1450 
def ValidateOutput(self, stdout, stderr, result)
Definition: GaudiTest.py:1386
def GaudiTest.GaudiExeTest.ValidateOutput (   self,
  stdout,
  stderr,
  result 
)

Definition at line 1386 of file GaudiTest.py.

1386  def ValidateOutput(self, stdout, stderr, result):
1387  causes = []
1388  # if the test definition contains a custom validator, use it
1389  if self.validator.strip() != "":
1390  class CallWrapper(object):
1391  """
1392  Small wrapper class to dynamically bind some default arguments
1393  to a callable.
1394  """
1395  def __init__(self, callable, extra_args = {}):
1396  self.callable = callable
1397  self.extra_args = extra_args
1398  # get the list of names of positional arguments
1399  from inspect import getargspec
1400  self.args_order = getargspec(callable)[0]
1401  # Remove "self" from the list of positional arguments
1402  # since it is added automatically
1403  if self.args_order[0] == "self":
1404  del self.args_order[0]
1405  def __call__(self, *args, **kwargs):
1406  # Check which positional arguments are used
1407  positional = self.args_order[:len(args)]
1408 
1409  kwargs = dict(kwargs) # copy the arguments dictionary
1410  for a in self.extra_args:
1411  # use "extra_args" for the arguments not specified as
1412  # positional or keyword
1413  if a not in positional and a not in kwargs:
1414  kwargs[a] = self.extra_args[a]
1415  return apply(self.callable, args, kwargs)
1416  # local names to be exposed in the script
1417  exported_symbols = {"self":self,
1418  "stdout":stdout,
1419  "stderr":stderr,
1420  "result":result,
1421  "causes":causes,
1422  "findReferenceBlock":
1423  CallWrapper(findReferenceBlock, {"stdout":stdout,
1424  "result":result,
1425  "causes":causes}),
1426  "validateWithReference":
1427  CallWrapper(self.ValidateWithReference, {"stdout":stdout,
1428  "stderr":stderr,
1429  "result":result,
1430  "causes":causes}),
1431  "countErrorLines":
1432  CallWrapper(countErrorLines, {"stdout":stdout,
1433  "result":result,
1434  "causes":causes}),
1435  "checkTTreesSummaries":
1436  CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout,
1437  "result":result,
1438  "causes":causes}),
1439  "checkHistosSummaries":
1440  CallWrapper(self.CheckHistosSummaries, {"stdout":stdout,
1441  "result":result,
1442  "causes":causes}),
1443 
1444  }
1445  exec self.validator in globals(), exported_symbols
1446  else:
1447  self.ValidateWithReference(stdout, stderr, result, causes)
1448 
1449  return causes
1450 
def ValidateOutput(self, stdout, stderr, result)
Definition: GaudiTest.py:1386
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 1329 of file GaudiTest.py.

1329  def ValidateWithReference(self, stdout, stderr, result, causes, preproc = None):
1330  """
1331  Default validation action: compare standard output and error to the
1332  reference files.
1333  """
1334  # set the default output preprocessor
1335  if preproc is None:
1336  preproc = normalizeExamples
1337  # check standard output
1338  reference = self._expandReferenceFileName(self.reference)
1339  # call the validator if the file exists
1340  if reference and os.path.isfile(reference):
1341  result["GaudiTest.output_reference"] = reference
1342  causes += ReferenceFileValidator(reference,
1343  "standard output",
1344  "GaudiTest.output_diff",
1345  preproc = preproc)(stdout, result)
1346 
1347  # Compare TTree summaries
1348  causes = self.CheckTTreesSummaries(stdout, result, causes)
1349  causes = self.CheckHistosSummaries(stdout, result, causes)
1350 
1351  if causes: # Write a new reference file for stdout
1352  try:
1353  newref = open(reference + ".new","w")
1354  # sanitize newlines
1355  for l in stdout.splitlines():
1356  newref.write(l.rstrip() + '\n')
1357  del newref # flush and close
1358  except IOError:
1359  # Ignore IO errors when trying to update reference files
1360  # because we may be in a read-only filesystem
1361  pass
1362 
1363  # check standard error
1364  reference = self._expandReferenceFileName(self.error_reference)
1365  # call the validator if we have a file to use
1366  if reference and os.path.isfile(reference):
1367  result["GaudiTest.error_reference"] = reference
1368  newcauses = ReferenceFileValidator(reference,
1369  "standard error",
1370  "GaudiTest.error_diff",
1371  preproc = preproc)(stderr, result)
1372  causes += newcauses
1373  if newcauses: # Write a new reference file for stdedd
1374  newref = open(reference + ".new","w")
1375  # sanitize newlines
1376  for l in stderr.splitlines():
1377  newref.write(l.rstrip() + '\n')
1378  del newref # flush and close
1379  else:
1380  causes += BasicOutputValidator(self.stderr,
1381  "standard error",
1382  "ExecTest.expected_stderr")(stderr, result)
1383 
1384  return causes
1385 
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
Output Validation Classes.
Definition: GaudiTest.py:351
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 1329 of file GaudiTest.py.

1329  def ValidateWithReference(self, stdout, stderr, result, causes, preproc = None):
1330  """
1331  Default validation action: compare standard output and error to the
1332  reference files.
1333  """
1334  # set the default output preprocessor
1335  if preproc is None:
1336  preproc = normalizeExamples
1337  # check standard output
1338  reference = self._expandReferenceFileName(self.reference)
1339  # call the validator if the file exists
1340  if reference and os.path.isfile(reference):
1341  result["GaudiTest.output_reference"] = reference
1342  causes += ReferenceFileValidator(reference,
1343  "standard output",
1344  "GaudiTest.output_diff",
1345  preproc = preproc)(stdout, result)
1346 
1347  # Compare TTree summaries
1348  causes = self.CheckTTreesSummaries(stdout, result, causes)
1349  causes = self.CheckHistosSummaries(stdout, result, causes)
1350 
1351  if causes: # Write a new reference file for stdout
1352  try:
1353  newref = open(reference + ".new","w")
1354  # sanitize newlines
1355  for l in stdout.splitlines():
1356  newref.write(l.rstrip() + '\n')
1357  del newref # flush and close
1358  except IOError:
1359  # Ignore IO errors when trying to update reference files
1360  # because we may be in a read-only filesystem
1361  pass
1362 
1363  # check standard error
1364  reference = self._expandReferenceFileName(self.error_reference)
1365  # call the validator if we have a file to use
1366  if reference and os.path.isfile(reference):
1367  result["GaudiTest.error_reference"] = reference
1368  newcauses = ReferenceFileValidator(reference,
1369  "standard error",
1370  "GaudiTest.error_diff",
1371  preproc = preproc)(stderr, result)
1372  causes += newcauses
1373  if newcauses: # Write a new reference file for stdedd
1374  newref = open(reference + ".new","w")
1375  # sanitize newlines
1376  for l in stderr.splitlines():
1377  newref.write(l.rstrip() + '\n')
1378  del newref # flush and close
1379  else:
1380  causes += BasicOutputValidator(self.stderr,
1381  "standard error",
1382  "ExecTest.expected_stderr")(stderr, result)
1383 
1384  return causes
1385 
def _expandReferenceFileName(self, reffile)
Definition: GaudiTest.py:1226
Output Validation Classes.
Definition: GaudiTest.py:351

Member Data Documentation

GaudiTest.GaudiExeTest.args_order

Definition at line 1400 of file GaudiTest.py.

list GaudiTest.GaudiExeTest.arguments
static

Definition at line 1069 of file GaudiTest.py.

GaudiTest.GaudiExeTest.callable

Definition at line 1396 of file GaudiTest.py.

GaudiTest.GaudiExeTest.error_reference

Definition at line 1496 of file GaudiTest.py.

GaudiTest.GaudiExeTest.extra_args

Definition at line 1397 of file GaudiTest.py.

GaudiTest.GaudiExeTest.program

Definition at line 1484 of file GaudiTest.py.

GaudiTest.GaudiExeTest.reference

Definition at line 1495 of file GaudiTest.py.

GaudiTest.GaudiExeTest.signal

Definition at line 1602 of file GaudiTest.py.

GaudiTest.GaudiExeTest.timeout

Definition at line 1533 of file GaudiTest.py.

GaudiTest.GaudiExeTest.use_temp_dir

Definition at line 1523 of file GaudiTest.py.


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