summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2013-01-11 14:52:27 -0800
committerKenneth Graunke <kenneth@whitecape.org>2013-01-11 15:05:27 -0800
commit6e3b1330a975ae46d3e180ed4c444075371b9fa8 (patch)
tree16e2e160239199c05f025523adcfa67fe42ba6dd
parent8e65e2c49c2f5a40b2fb99efaabb6ab853b14e3d (diff)
Make Piglit run in the proper directoryHEADmaster
-rw-r--r--framework/process.py4
-rw-r--r--framework/test.py5
-rw-r--r--suites/piglit.py8
3 files changed, 9 insertions, 8 deletions
diff --git a/framework/process.py b/framework/process.py
index efe2b26..7423769 100644
--- a/framework/process.py
+++ b/framework/process.py
@@ -28,7 +28,7 @@ from threading import Thread
__all__ = ['runProgram']
-def runProgram(cmd, timeout, env = None):
+def runProgram(cmd, timeout, workingDir = None, env = None):
'''Run a program with a timeout in case it never terminates.
cmd -- List of command and arguments. See subprocess.Popen.
@@ -47,7 +47,7 @@ def runProgram(cmd, timeout, env = None):
out = ''
err = ''
try:
- proc = Popen(cmd, stdout=PIPE, stderr=PIPE, env=fullEnv,
+ proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=workingDir, env=fullEnv,
start_new_session=True, universal_newlines=True)
out, err = proc.communicate(timeout=timeout)
return (out, err, proc.returncode, True)
diff --git a/framework/test.py b/framework/test.py
index 2f90c81..fa51172 100644
--- a/framework/test.py
+++ b/framework/test.py
@@ -31,11 +31,12 @@ __all__ = ['runProgram']
class Test:
- def __init__(self, command):
+ def __init__(self, command, working_directory = None):
self.command = command
+ self.working_directory = working_directory
def run(self, timeout):
- out, err, exitcode, finished = runProgram(self.command, timeout)
+ out, err, exitcode, finished = runProgram(self.command, timeout, self.working_directory)
return {'out': out, 'err': err, 'exitcode': exitcode,
'status': self.resultStatus(out, err, exitcode, finished)}
diff --git a/suites/piglit.py b/suites/piglit.py
index 2add243..5de9634 100644
--- a/suites/piglit.py
+++ b/suites/piglit.py
@@ -47,8 +47,8 @@ skip_re = re.compile(r"^PIGLIT: *{ *'result': *'skip' *}")
pass_re = re.compile(r"^PIGLIT: *{ *'result': *'pass' *}")
class PiglitTest(Test):
- def __init__(self, test, cmd):
- Test.__init__(self, shlex.split(cmd))
+ def __init__(self, cmd):
+ Test.__init__(self, shlex.split(cmd), piglit_path)
def interpretResult(self, out, err, exitcode):
if skip_re.search(out) is not None:
@@ -60,11 +60,11 @@ class PiglitTest(Test):
def makeTestList():
# XXX: can't handle glean yet.
- (out, _, _, _) = runProgram([path.join(piglit_path, 'piglit-print-commands.py'), '-x', 'glean', 'tests/quick.tests'], None)
+ (out, _, _, _) = runProgram(['python2', 'piglit-print-commands.py', '-x', 'glean', 'tests/quick.tests'], None, piglit_path)
d = {}
for l in out.splitlines():
test, cmd = l.split(' ::: ')
- d['piglit/' + test] = PiglitTest(test, cmd)
+ d['piglit/' + test] = PiglitTest(cmd)
return d