[Piglit] [PATCH 2/2] framework: Report the command string instead of traceback on OSError.
Eric Anholt
eric at anholt.net
Fri Sep 28 11:44:18 PDT 2012
Getting:
<type 'exceptions.OSError'>[Errno 2] No such file or directory
in the results is way less useful than getting:
Errors: No such file or directory
command: ./bin/glx-oml-sync-control-return -auto -fbo
---
framework/exectest.py | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/framework/exectest.py b/framework/exectest.py
index d2173d4..ea972eb 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -56,14 +56,21 @@ class ExecTest(Test):
i = 0
while True:
- proc = subprocess.Popen(
- command,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- env=fullenv,
- universal_newlines=True
- )
- out, err = proc.communicate()
+ returncode = -1
+ try:
+ proc = subprocess.Popen(
+ command,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ env=fullenv,
+ universal_newlines=True
+ )
+ out, err = proc.communicate()
+ returncode = proc.returncode
+ except OSError, e:
+ out = ''
+ err = e.strerror
+ returncode = e.errno
# https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
# affecting many developers. If we catch it
@@ -111,17 +118,17 @@ class ExecTest(Test):
-1073741676
]
- if proc.returncode in crash_codes:
+ if returncode in crash_codes:
results['result'] = 'crash'
- elif proc.returncode != 0:
- results['note'] = 'Returncode was %d' % (proc.returncode)
+ elif returncode != 0:
+ results['note'] = 'Returncode was %d' % (returncode)
if valgrind:
# If the underlying test failed, simply report
# 'skip' for this valgrind test.
if results['result'] != 'pass':
results['result'] = 'skip'
- elif proc.returncode == 0:
+ elif returncode == 0:
# Test passes and is valgrind clean.
results['result'] = 'pass'
else:
@@ -133,8 +140,8 @@ class ExecTest(Test):
env = env + key + '="' + self.env[key] + '" '
if env:
results['environment'] = env
- results['info'] = "Returncode: %d\n\nErrors:\n%s\n\nOutput:\n%s" % (proc.returncode, err, out)
- results['returncode'] = proc.returncode
+ results['info'] = "Returncode: %d\n\nErrors:\n%s\n\nOutput:\n%s" % (returncode, err, out)
+ results['returncode'] = returncode
results['command'] = ' '.join(self.command)
self.handleErr(results, err)
--
1.7.10.4
More information about the Piglit
mailing list