The Gaudi Framework  master (594c33fa)
GaudiTesting.QMTTest.QMTTest Class Reference
Inheritance diagram for GaudiTesting.QMTTest.QMTTest:
Collaboration diagram for GaudiTesting.QMTTest.QMTTest:

Public Member Functions

def __init__ (self, path=None)
 
def XMLParser (self, path)
 
def ValidateOutput (self, stdout, stderr, result)
 
- Public Member Functions inherited from GaudiTesting.BaseTest.BaseTest
def __init__ (self)
 
def run (self)
 
def findReferenceBlock (self, reference=None, stdout=None, result=None, causes=None, signature_offset=0, signature=None, id=None)
 
def countErrorLines (self, expected={"ERROR":0, "FATAL":0}, stdout=None, result=None, causes=None)
 
def CheckTTreesSummaries (self, stdout=None, result=None, causes=None, trees_dict=None, ignore=r"Basket|.*size|Compression")
 
def CheckHistosSummaries (self, stdout=None, result=None, causes=None, dict=None, ignore=None)
 
def validateWithReference (self, stdout=None, stderr=None, result=None, causes=None, preproc=None)
 
def validateJSONWithReference (self, output_file, reference_file, result=None, causes=None, detailed=True)
 

Public Attributes

 validator
 
 name
 
 callable
 
 extra_args
 
 args_order
 
- Public Attributes inherited from GaudiTesting.BaseTest.BaseTest
 program
 
 args
 
 reference
 
 error_reference
 
 options
 
 stderr
 
 timeout
 
 exit_code
 
 environment
 
 unsupported_platforms
 
 signal
 
 workdir
 
 use_temp_dir
 
 status
 
 name
 
 causes
 
 result
 
 returnedCode
 
 out
 
 err
 
 proc
 
 stack_trace
 
 basedir
 
 validate_time
 

Detailed Description

Definition at line 18 of file QMTTest.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiTesting.QMTTest.QMTTest.__init__ (   self,
  path = None 
)

Definition at line 19 of file QMTTest.py.

19  def __init__(self, path=None):
20  BaseTest.__init__(self)
21  self.validator = ""
22  if path:
23  self.XMLParser(path)
24 

Member Function Documentation

◆ ValidateOutput()

def GaudiTesting.QMTTest.QMTTest.ValidateOutput (   self,
  stdout,
  stderr,
  result 
)

Reimplemented from GaudiTesting.BaseTest.BaseTest.

Definition at line 65 of file QMTTest.py.

65  def ValidateOutput(self, stdout, stderr, result):
66  if self.validator:
67 
68  class CallWrapper(object):
69  """
70  Small wrapper class to dynamically bind some default arguments
71  to a callable.
72  """
73 
74  def __init__(self, callable, extra_args={}):
75  self.callable = callable
76  self.extra_args = extra_args
77  # get the list of names of positional arguments
78  try:
79  # Removed in Python 3.11
80  from inspect import getargspec
81 
82  self.args_order = getargspec(callable)[0]
83  except ImportError:
84  import inspect
85 
86  self.args_order = [
87  param.name
88  for param in inspect.signature(callable).parameters.values()
89  if param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD
90  ]
91  # Remove "self" from the list of positional arguments
92  # since it is added automatically
93  if self.args_order[0] == "self":
94  del self.args_order[0]
95 
96  def __call__(self, *args, **kwargs):
97  # Check which positional arguments are used
98  positional = self.args_order[: len(args)]
99 
100  kwargs = dict(kwargs) # copy the arguments dictionary
101  for a in self.extra_args:
102  # use "extra_args" for the arguments not specified as
103  # positional or keyword
104  if a not in positional and a not in kwargs:
105  kwargs[a] = self.extra_args[a]
106  return self.callable(*args, **kwargs)
107 
108  # local names to be exposed in the script
109  stdout_ref = self._expandReferenceFileName(self.reference)
110  stderr_ref = self._expandReferenceFileName(self.error_reference)
111  exported_symbols = {
112  "self": self,
113  "stdout": stdout,
114  "stderr": stderr,
115  "result": result,
116  "causes": self.causes,
117  "reference": stdout_ref,
118  "error_reference": stderr_ref,
119  "findReferenceBlock": CallWrapper(
120  self.findReferenceBlock,
121  {"stdout": stdout, "result": result, "causes": self.causes},
122  ),
123  "validateWithReference": CallWrapper(
124  self.validateWithReference,
125  {
126  "stdout": stdout,
127  "stderr": stderr,
128  "result": result,
129  "causes": self.causes,
130  },
131  ),
132  "validateJSONWithReference": CallWrapper(
133  self.validateJSONWithReference,
134  {
135  "result": result,
136  "causes": self.causes,
137  },
138  ),
139  "countErrorLines": CallWrapper(
140  self.countErrorLines,
141  {"stdout": stdout, "result": result, "causes": self.causes},
142  ),
143  "checkTTreesSummaries": CallWrapper(
144  self.CheckTTreesSummaries,
145  {"stdout": stdout, "result": result, "causes": self.causes},
146  ),
147  "checkHistosSummaries": CallWrapper(
148  self.CheckHistosSummaries,
149  {"stdout": stdout, "result": result, "causes": self.causes},
150  ),
151  }
152  # print self.validator
153  exec(self.validator, globals(), exported_symbols)
154  return result, self.causes
155  else:
156  return super(QMTTest, self).ValidateOutput(stdout, stderr, result)

◆ XMLParser()

def GaudiTesting.QMTTest.QMTTest.XMLParser (   self,
  path 
)
Parse a QMTest XML test description (.qmt file) to initialize the test
instance.

Definition at line 25 of file QMTTest.py.

25  def XMLParser(self, path):
26  """
27  Parse a QMTest XML test description (.qmt file) to initialize the test
28  instance.
29  """
30  from string import Template
31 
32  log = logging.getLogger("QMTest.XMLParser")
33  import xml.etree.ElementTree as ET
34 
35  log.debug("parsing %s", path)
36 
37  self.name = ".".join(
38  os.path.relpath(path, self.basedir)
39  .replace(".qmt", "")
40  .replace(".qms", "")
41  .split(os.sep)
42  )
43 
44  tree = ET.parse(path)
45  for child in tree.getroot():
46  name = child.attrib["name"]
47  if hasattr(self, name):
48  log.debug("setting %s", name)
49  value = child[0]
50  if name in ("args", "unsupported_platforms"):
51  setattr(self, name, [el.text for el in value.findall("text")])
52  elif name == "environment":
53  for el in value.findall("text"):
54  key, value = el.text.split("=", 1)
55  self.environment[key] = Template(value).safe_substitute(
56  self.environment
57  )
58  else:
59  data = value.text
60  if data is not None:
61  if value.tag == "integer":
62  data = int(data)
63  setattr(self, name, data)
64 

Member Data Documentation

◆ args_order

GaudiTesting.QMTTest.QMTTest.args_order

Definition at line 82 of file QMTTest.py.

◆ callable

GaudiTesting.QMTTest.QMTTest.callable

Definition at line 75 of file QMTTest.py.

◆ extra_args

GaudiTesting.QMTTest.QMTTest.extra_args

Definition at line 76 of file QMTTest.py.

◆ name

GaudiTesting.QMTTest.QMTTest.name

Definition at line 37 of file QMTTest.py.

◆ validator

GaudiTesting.QMTTest.QMTTest.validator

Definition at line 21 of file QMTTest.py.


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