| The Gaudi Framework v27r1

- 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 exported_symbols = {"self":self,
77 "stdout":stdout,
78 "stderr":stderr,
79 "result":result,
80 "causes":self.causes,
81 "findReferenceBlock":
82 CallWrapper(self.findReferenceBlock, {"stdout":stdout,
83 "result":result,
84 "causes":self.causes}),
85 "validateWithReference":
86 CallWrapper(self.validateWithReference, {"stdout":stdout,
87 "stderr":stderr,
88 "result":result,
89 "causes":self.causes}),
90 "countErrorLines":
91 CallWrapper(self.countErrorLines, {"stdout":stdout,
92 "result":result,
93 "causes":self.causes}),
94 "checkTTreesSummaries":
95 CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout,
96 "result":result,
97 "causes":self.causes}),
98 "checkHistosSummaries":
99 CallWrapper(self.CheckHistosSummaries, {"stdout":stdout,
100 "result":result,
101 "causes":self.causes})
102 }
103 #print self.validator
104 exec self.validator in globals(), exported_symbols
105 else:
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')
110
111 return result, self.causes
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.CheckHistosSummaries
def CheckHistosSummaries
Definition: BaseTest.py:387
GaudiTesting.BaseTest.BaseTest.validateWithReference
def validateWithReference
Definition: BaseTest.py:424
GaudiTesting.BaseTest.BaseTest.CheckTTreesSummaries
def CheckTTreesSummaries
Definition: BaseTest.py:350
GaudiTesting.QMTTest.QMTTest.ValidateOutput
def ValidateOutput(self, stdout, stderr, result)
Definition: QMTTest.py:46
GaudiTesting.BaseTest.BaseTest
Definition: BaseTest.py:58
GaudiTesting.QMTTest.QMTTest.validator
validator
Definition: QMTTest.py:11
GaudiTesting.QMTTest.QMTTest
Definition: QMTTest.py:7
GaudiTesting.BaseTest.BaseTest.stderr
stderr
Definition: BaseTest.py:68
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__
Definition: QMTTest.py:9
GaudiTesting.QMTTest.QMTTest.callable
callable
Definition: QMTTest.py:54
GaudiTesting.BaseTest.BaseTest.findReferenceBlock
def findReferenceBlock
Definition: BaseTest.py:271
GaudiTesting.BaseTest.BaseTest.countErrorLines
def countErrorLines
Definition: BaseTest.py:312
GaudiTesting.BaseTest.BaseTest.name
name
Definition: BaseTest.py:78