[Piglit] [Patch v2 16/18] framework: refactor valgrind handling to make glean cleaner

Dylan Baker baker.dylan.c at gmail.com
Mon Jul 28 15:35:25 PDT 2014


This allows more state in glean to be shared rather than storing the
same list in memory once for each glean test.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/exectest.py  |  8 +++++---
 framework/gleantest.py | 12 +++++++-----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/framework/exectest.py b/framework/exectest.py
index d1441c9..0787442 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -69,10 +69,13 @@ class Test(object):
     run_concurrent -- If True the test is thread safe. Default: False
 
     """
-    OPTS = Options()
     __slots__ = ['run_concurrent', 'env', 'result', 'cwd', '_command',
                  '_test_hook_execute_run']
 
+    OPTS = Options()
+    _VALGRIND_CMD = ['valgrind', '--quiet', '--error-exitcode=1',
+                     '--tool=memcheck']
+
     def __init__(self, command, run_concurrent=False):
         self._command = None
         self.run_concurrent = run_concurrent
@@ -130,8 +133,7 @@ class Test(object):
     def command(self):
         assert self._command
         if self.OPTS.valgrind:
-            return ['valgrind', '--quiet', '--error-exitcode=1',
-                    '--tool=memcheck'] + self._command
+            return self._VALGRIND_CMD + self._command
         return self._command
 
     @command.setter
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 1af1897..015a145 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -36,16 +36,18 @@ class GleanTest(Test):
 
     """
     GLOBAL_PARAMS = []
-    _EXECUTABLE = os.path.join(TEST_BIN_DIR, "glean")
+    _EXECUTABLE = [os.path.join(TEST_BIN_DIR, "glean"),
+                   "-o", "-v", "-v", "-v", "-t"]
 
     def __init__(self, name, **kwargs):
-        super(GleanTest, self).__init__(
-            [self._EXECUTABLE, "-o", "-v", "-v", "-v", "-t", "+" + name],
-            **kwargs)
+        super(GleanTest, self).__init__(['+' + name], **kwargs)
 
     @Test.command.getter
     def command(self):
-        return super(GleanTest, self).command + self.GLOBAL_PARAMS
+        if self.OPTS.valgrind:
+            return self._VALGRIND_CMD + self._EXECUTABLE + \
+                self._command + self.GLOBAL_PARAMS
+        return self._EXECUTABLE + self._command + self.GLOBAL_PARAMS
 
     def interpret_result(self):
         if self.result['returncode'] != 0 or 'FAIL' in self.result['out']:
-- 
2.0.2



More information about the Piglit mailing list