| The Gaudi Framework v29r1 (5cd95fa2)

- 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
8 class QMTTest(BaseTest):
9
10 def __init__(self, path=None):
11 BaseTest.__init__(self)
12 self.validator = ''
13 if path:
14 self.XMLParser(path)
15
16 def XMLParser(self, path):
17 '''
18 Parse a QMTest XML test description (.qmt file) to initialize the test
19 instance.
20 '''
21 log = logging.getLogger('QMTest.XMLParser')
22 import xml.etree.ElementTree as ET
23 log.debug('parsing %s', path)
24
25 self.name = path
26
27 tree = ET.parse(path)
28 for child in tree.getroot():
29 name = child.attrib['name']
30 if hasattr(self, name):
31 log.debug('setting %s', name)
32 value = child[0]
33 if name in ('args', 'unsupported_platforms'):
34 setattr(self, name, [el.text
35 for el in value.findall('text')])
36 elif name == 'environment':
37 setattr(self, name, dict(el.text.split('=', 1)
38 for el in value.findall('text')))
39 else:
40 data = value.text
41 if data is not None:
42 if value.tag == 'integer':
43 data = int(data)
44 setattr(self, name, data)
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
54 def __init__(self, callable, extra_args={}):
55 self.callable = callable
56 self.extra_args = extra_args
57 # get the list of names of positional arguments
58 from inspect import getargspec
59 self.args_order = getargspec(callable)[0]
60 # Remove "self" from the list of positional arguments
61 # since it is added automatically
62 if self.args_order[0] == "self":
63 del self.args_order[0]
64
65 def __call__(self, *args, **kwargs):
66 # Check which positional arguments are used
67 positional = self.args_order[:len(args)]
68
69 kwargs = dict(kwargs) # copy the arguments dictionary
70 for a in self.extra_args:
71 # use "extra_args" for the arguments not specified as
72 # positional or keyword
73 if a not in positional and a not in kwargs:
74 kwargs[a] = self.extra_args[a]
75 return apply(self.callable, args, kwargs)
76
77 # local names to be exposed in the script
78 stdout_ref = self._expandReferenceFileName(self.reference)
79 stderr_ref = self._expandReferenceFileName(self.error_reference)
80 exported_symbols = {"self": self,
81 "stdout": stdout,
82 "stderr": stderr,
83 "result": result,
84 "causes": self.causes,
85 "reference": stdout_ref,
86 "error_reference": stderr_ref,
87 "findReferenceBlock":
88 CallWrapper(self.findReferenceBlock,
89 {"stdout": stdout,
90 "result": result,
91 "causes": self.causes}),
92 "validateWithReference":
93 CallWrapper(self.validateWithReference,
94 {"stdout": stdout,
95 "stderr": stderr,
96 "result": result,
97 "causes": self.causes}),
98 "countErrorLines":
99 CallWrapper(self.countErrorLines,
100 {"stdout": stdout,
101 "result": result,
102 "causes": self.causes}),
103 "checkTTreesSummaries":
104 CallWrapper(self.CheckTTreesSummaries,
105 {"stdout": stdout,
106 "result": result,
107 "causes": self.causes}),
108 "checkHistosSummaries":
109 CallWrapper(self.CheckHistosSummaries,
110 {"stdout": stdout,
111 "result": result,
112 "causes": self.causes})
113 }
114 # print self.validator
115 exec self.validator in globals(), exported_symbols
116 return result, self.causes
117 else:
118 return super(QMTTest, self).ValidateOutput(stdout, stderr, result)
GaudiTesting.QMTTest.QMTTest.args_order
args_order
Definition: QMTTest.py:59
GaudiTesting.QMTTest.QMTTest.XMLParser
def XMLParser(self, path)
Definition: QMTTest.py:16
GaudiTesting.BaseTest.BaseTest.validateWithReference
def validateWithReference(self, stdout=None, stderr=None, result=None, causes=None, preproc=None)
Definition: BaseTest.py:443
GaudiTesting.QMTTest.QMTTest.ValidateOutput
def ValidateOutput(self, stdout, stderr, result)
Definition: QMTTest.py:46
GaudiTesting.BaseTest.BaseTest
Definition: BaseTest.py:65
GaudiTesting.BaseTest.BaseTest.reference
reference
Definition: BaseTest.py:72
GaudiTesting.QMTTest.QMTTest.validator
validator
Definition: QMTTest.py:12
GaudiTesting.QMTTest.QMTTest
Definition: QMTTest.py:8
GaudiTesting.BaseTest.BaseTest.error_reference
error_reference
Definition: BaseTest.py:73
GaudiTesting.QMTTest.QMTTest.extra_args
extra_args
Definition: QMTTest.py:56
GaudiTesting.BaseTest.BaseTest.causes
causes
Definition: BaseTest.py:86
GaudiTesting.QMTTest.QMTTest.__init__
def __init__(self, path=None)
Definition: QMTTest.py:10
GaudiTesting.BaseTest.BaseTest._expandReferenceFileName
def _expandReferenceFileName(self, reffile)
Definition: BaseTest.py:504
GaudiTesting.QMTTest.QMTTest.callable
callable
Definition: QMTTest.py:55
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:269
GaudiTesting.BaseTest.BaseTest.CheckHistosSummaries
def CheckHistosSummaries(self, stdout=None, result=None, causes=None, dict=None, ignore=None)
Definition: BaseTest.py:402
GaudiTesting.BaseTest.BaseTest.countErrorLines
def countErrorLines
Definition: BaseTest.py:317
GaudiTesting.BaseTest.BaseTest.CheckTTreesSummaries
def CheckTTreesSummaries(self, stdout=None, result=None, causes=None, trees_dict=None, ignore=r"Basket|.*size|Compression")
Definition: BaseTest.py:360
GaudiTesting.BaseTest.BaseTest.name
name
Definition: BaseTest.py:85