| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

QMTTest.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 from BaseTest import *
3 import logging
4 import os
5 import sys
6
7 class QMTTest(BaseTest):
8
9 def __init__(self, path=None):
10 BaseTest.__init__(self)
11 self.validator = ''
12 if path:
13 self.XMLParser(path)
14
15 def XMLParser(self, path) :
16 '''
17 Parse a QMTest XML test description (.qmt file) to initialize the test
18 instance.
19 '''
20 log = logging.getLogger('QMTest.XMLParser')
21 import xml.etree.ElementTree as ET
22 log.debug('parsing %s', path)
23
24 self.name = path
25
26 tree = ET.parse(path)
27 for child in tree.getroot():
28 name = child.attrib['name']
29 if hasattr(self, name):
30 log.debug('setting %s', name)
31 value = child[0]
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')))
38 else:
39 data = value.text
40 if data is not None:
41 if value.tag == 'integer':
42 data = int(data)
43 setattr(self, name, data)
44
45
46 def ValidateOutput(self, stdout, stderr, result):
47 if self.validator:
48 class CallWrapper(object):
49 """
50 Small wrapper class to dynamically bind some default arguments
51 to a callable.
52 """
53 def __init__(self, callable, extra_args = {}):
54 self.callable = callable
55 self.extra_args = extra_args
56 # get the list of names of positional arguments
57 from inspect import getargspec
58 self.args_order = getargspec(callable)[0]
59 # Remove "self" from the list of positional arguments
60 # since it is added automatically
61 if self.args_order[0] == "self":
62 del self.args_order[0]
63 def __call__(self, *args, **kwargs):
64 # Check which positional arguments are used
65 positional = self.args_order[:len(args)]
66
67 kwargs = dict(kwargs) # copy the arguments dictionary
68 for a in self.extra_args:
69 # use "extra_args" for the arguments not specified as
70 # positional or keyword
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)
74
75 # local names to be exposed in the script
76 stdout_ref = self._expandReferenceFileName(self.reference)
77 stderr_ref = self._expandReferenceFileName(self.error_reference)
78 exported_symbols = {"self": self,
79 "stdout": stdout,
80 "stderr": stderr,
81 "result": result,
82 "causes": self.causes,
83 "reference": stdout_ref,
84 "error_reference": stderr_ref,
85 "findReferenceBlock":
86 CallWrapper(self.findReferenceBlock,
87 {"stdout": stdout,
88 "result": result,
89 "causes": self.causes}),
90 "validateWithReference":
91 CallWrapper(self.validateWithReference,
92 {"stdout": stdout,
93 "stderr": stderr,
94 "result": result,
95 "causes": self.causes}),
96 "countErrorLines":
97 CallWrapper(self.countErrorLines,
98 {"stdout": stdout,
99 "result": result,
100 "causes": self.causes}),
101 "checkTTreesSummaries":
102 CallWrapper(self.CheckTTreesSummaries,
103 {"stdout": stdout,
104 "result": result,
105 "causes": self.causes}),
106 "checkHistosSummaries":
107 CallWrapper(self.CheckHistosSummaries,
108 {"stdout": stdout,
109 "result": result,
110 "causes": self.causes})
111 }
112 #print self.validator
113 exec self.validator in globals(), exported_symbols
114 return result, self.causes
115 else:
116 return super(QMTTest, self).ValidateOutput(stdout, stderr, result)
GaudiTesting.QMTTest.QMTTest.args_order
args_order
Definition: QMTTest.py:58
GaudiTesting.QMTTest.QMTTest.XMLParser
def XMLParser(self, path)
Definition: QMTTest.py:15
GaudiTesting.BaseTest.BaseTest.validateWithReference
def validateWithReference(self, stdout=None, stderr=None, result=None, causes=None, preproc=None)
Definition: BaseTest.py:412
GaudiTesting.QMTTest.QMTTest.ValidateOutput
def ValidateOutput(self, stdout, stderr, result)
Definition: QMTTest.py:46
GaudiTesting.BaseTest.BaseTest
Definition: BaseTest.py:58
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:65
GaudiTesting.QMTTest.QMTTest.validator
validator
Definition: QMTTest.py:11
GaudiTesting.QMTTest.QMTTest
Definition: QMTTest.py:7
GaudiTesting.BaseTest.BaseTest.error_reference
error_reference
Definition: BaseTest.py:66
GaudiTesting.QMTTest.QMTTest.extra_args
extra_args
Definition: QMTTest.py:55
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:79
GaudiTesting.QMTTest.QMTTest.__init__
def __init__(self, path=None)
Definition: QMTTest.py:9
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:468
GaudiTesting.QMTTest.QMTTest.callable
callable
Definition: QMTTest.py:54
GaudiTesting.BaseTest.BaseTest.findReferenceBlock
def findReferenceBlock(self, reference=None, stdout=None, result=None, causes=None, signature_offset=0, signature=None, id=None)
Definition: BaseTest.py:259
GaudiTesting.BaseTest.BaseTest.CheckHistosSummaries
def CheckHistosSummaries(self, stdout=None, result=None, causes=None, dict=None, ignore=None)
Definition: BaseTest.py:375
Gaudi::Functional::details::apply
constexpr void apply(const Fun &, Container &, Args...)
Definition: FunctionalDetails.h:444
GaudiTesting.BaseTest.BaseTest.countErrorLines
def countErrorLines
Definition: BaseTest.py:300
GaudiTesting.BaseTest.BaseTest.CheckTTreesSummaries
def CheckTTreesSummaries(self, stdout=None, result=None, causes=None, trees_dict=None, ignore=r"Basket|.*size|Compression")
Definition: BaseTest.py:338
GaudiTesting.BaseTest.BaseTest.name
name
Definition: BaseTest.py:78