7 class QMTTest(BaseTest):
9 def __init__(self, path=None):
10 BaseTest.__init__(self)
15 def XMLParser(self, path) :
17 Parse a QMTest XML test description (.qmt file) to initialize the test
20 log = logging.getLogger(
'QMTest.XMLParser')
21 import xml.etree.ElementTree
as ET
22 log.debug(
'parsing %s', path)
27 for child
in tree.getroot():
28 name = child.attrib[
'name']
29 if hasattr(self, name):
30 log.debug(
'setting %s', name)
32 if name
in (
'args',
'unsupported_platforms'):
33 setattr(self, name, [el.text
34 for el
in value.findall(
'text')])
35 elif name ==
'environment':
36 setattr(self, name, dict(el.text.split(
'=', 1)
37 for el
in value.findall(
'text')))
41 if value.tag ==
'integer':
43 setattr(self, name, data)
46 def ValidateOutput(self, stdout, stderr, result):
48 class CallWrapper(object):
50 Small wrapper class to dynamically bind some default arguments
53 def __init__(self, callable, extra_args = {}):
54 self.callable = callable
55 self.extra_args = extra_args
57 from inspect
import getargspec
58 self.args_order = getargspec(callable)[0]
61 if self.args_order[0] ==
"self":
62 del self.args_order[0]
63 def __call__(self, *args, **kwargs):
65 positional = self.args_order[:len(args)]
68 for a
in self.extra_args:
71 if a
not in positional
and a
not in kwargs:
72 kwargs[a] = self.extra_args[a]
73 return apply(self.callable, args, kwargs)
76 exported_symbols = {
"self":self,
82 CallWrapper(self.findReferenceBlock, {
"stdout":stdout,
84 "causes":self.causes}),
85 "validateWithReference":
86 CallWrapper(self.validateWithReference, {
"stdout":stdout,
89 "causes":self.causes}),
91 CallWrapper(self.countErrorLines, {
"stdout":stdout,
93 "causes":self.causes}),
94 "checkTTreesSummaries":
95 CallWrapper(self.CheckTTreesSummaries, {
"stdout":stdout,
97 "causes":self.causes}),
98 "checkHistosSummaries":
99 CallWrapper(self.CheckHistosSummaries, {
"stdout":stdout,
101 "causes":self.causes})
104 exec self.validator
in globals(), exported_symbols
106 if self.stderr ==
'':
107 self.validateWithReference(stdout, stderr, result, self.causes)
108 elif stderr.strip() != self.stderr.strip():
109 self.causes.append(
'standard error')
111 return result, self.causes