[Piglit] [PATCH 06/13] framework/exectest.py: Optimize skips in Test.run()
Dylan Baker
baker.dylan.c at gmail.com
Tue Apr 15 16:12:39 PDT 2014
This optimizes the Test.check_for_skip_scenario() path. With this change
there is a single if branch for skip, and a single alternate path for
non-skip. Skip returns early, bypassing a bunch of processing overhead
that is unnecessary.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/exectest.py | 39 ++++++++++++++++-----------------------
1 file changed, 16 insertions(+), 23 deletions(-)
diff --git a/framework/exectest.py b/framework/exectest.py
index 3bbaf1f..37d352b 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -142,15 +142,21 @@ class Test(object):
* For 'command', the value will be command line program and arguments.
"""
if self.command is not None:
+ results = TestResult()
+ results['command'] = ' '.join(self.command)
+ results['environment'] = " ".join(
+ '{0}="{1}"'.format(k, v) for k, v in self.env.iteritems())
+
+ if self.check_for_skip_scenario():
+ results['result'] = 'skip'
+ results['out'] = "PIGLIT: {'result': 'skip'}\n"
+ results['err'] = ""
+ results['returncode'] = None
+ return results
+
i = 0
- skip = self.check_for_skip_scenario()
while True:
- if skip:
- out = "PIGLIT: {'result': 'skip'}\n"
- err = ""
- returncode = None
- else:
- out, err, returncode = self.get_command_result()
+ out, err, returncode = self.get_command_result()
# https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
# affecting many developers. If we catch it
@@ -162,13 +168,8 @@ class Test(object):
else:
break
- results = TestResult()
-
- if skip:
- results['result'] = 'skip'
- else:
- results['result'] = 'fail'
- out = self.interpret_result(out, returncode, results)
+ results['result'] = 'fail'
+ out = self.interpret_result(out, returncode, results)
crash_codes = [
# Unix: terminated by a signal
@@ -201,18 +202,10 @@ class Test(object):
# Test passed but has valgrind errors.
results['result'] = 'fail'
- env = ''
- for key in self.env:
- env = env + key + '="' + self.env[key] + '" '
- if env:
- results['environment'] = env
-
+ results['returncode'] = returncode
results['info'] = unicode("Returncode: {0}\n\nErrors:\n{1}\n\n"
"Output:\n{2}").format(returncode,
err, out)
- results['returncode'] = returncode
- results['command'] = ' '.join(self.command)
-
else:
results = TestResult()
if 'result' not in results:
--
1.9.2
More information about the Piglit
mailing list