Add more structure constructor tests.
[piglit/hramrach.git] / framework / gleantest.py
blob4cabe4f9aa4d3d53af9d98c275109012b22a561d
1 #!/usr/bin/env python
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation
5 # files (the "Software"), to deal in the Software without
6 # restriction, including without limitation the rights to use,
7 # copy, modify, merge, publish, distribute, sublicense, and/or
8 # sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following
10 # conditions:
12 # This permission notice shall be included in all copies or
13 # substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR(S) BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
21 # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
24 import os
25 import subprocess
27 from core import checkDir, testBinDir, Test, TestResult
29 #############################################################################
30 ##### GleanTest: Execute a sub-test of Glean
31 #############################################################################
32 def gleanExecutable():
33 return testBinDir + 'glean'
35 def gleanResultDir():
36 return os.path.join('.', 'results', 'glean')
38 class GleanTest(Test):
39 globalParams = []
41 def __init__(self, name):
42 Test.__init__(self)
43 self.name = name
44 self.env = {}
46 def run(self):
47 results = TestResult()
49 fullenv = os.environ.copy()
50 for e in self.env:
51 fullenv[e] = str(self.env[e])
53 checkDir(os.path.join(gleanResultDir(), self.name), False)
55 glean = subprocess.Popen(
56 [gleanExecutable(), "-r", os.path.join(gleanResultDir(), self.name),
57 "-o",
58 "-v", "-v", "-v",
59 "-t", "+"+self.name] + GleanTest.globalParams,
60 stdout=subprocess.PIPE,
61 stderr=subprocess.PIPE,
62 env=fullenv,
63 universal_newlines=True
66 out, err = glean.communicate()
68 results['result'] = 'pass'
69 if glean.returncode != 0 or out.find('FAIL') >= 0:
70 results['result'] = 'fail'
72 results['returncode'] = glean.returncode
74 self.handleErr(results, err)
76 results['info'] = "@@@Returncode: %d\n\nErrors:\n%s\n\nOutput:\n%s" % (glean.returncode, err, out)
78 return results