[Piglit] [PATCH 11/12] exectest.py: Merge Test and ExecTest into a single class

Dylan Baker baker.dylan.c at gmail.com
Tue Feb 11 18:11:16 PST 2014


Rather than have 2 base classes, let's just have one.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/exectest.py  | 26 +++++++++-----------------
 framework/gleantest.py | 12 ++++++------
 framework/gtest.py     |  4 ++--
 tests/es3conform.py    |  8 +++++---
 tests/igt.py           |  7 ++++---
 tests/oglconform.py    |  7 ++++---
 6 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/framework/exectest.py b/framework/exectest.py
index 30241de..eae9662 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -31,7 +31,6 @@ import sys
 from .core import TestResult
 
 __all__ = ['Test',
-           'ExecTest',
            'PlainExecTest',
            'PIGLIT_PLATFORM',
            'testBinDir']
@@ -54,7 +53,7 @@ if 'PIGLIT_SOURCE_DIR' not in os.environ:
 
 
 class Test(object):
-    def __init__(self, runConcurrent=False):
+    def __init__(self, command, runConcurrent=False):
         '''
                 'runConcurrent' controls whether this test will
                 execute it's work (i.e. __doRunWork) on the calling thread
@@ -62,6 +61,10 @@ class Test(object):
         '''
         self.runConcurrent = runConcurrent
         self.skip_test = False
+        self.command = command
+        self.split_command = os.path.split(self._command[0])[1]
+        self.env = {}
+        self.skip_test = self.check_for_skip_scenario(command)
 
         # This is a hook for doing some testing on execute right before
         # self.run is called.
@@ -117,18 +120,6 @@ class Test(object):
             log.log()
         log.mark_complete(log_current)
 
-
-# ExecTest: A shared base class for tests that simply runs an executable.
-class ExecTest(Test):
-    def __init__(self, command):
-        Test.__init__(self)
-        self.command = command
-        self.split_command = os.path.split(self._command[0])[1]
-        self.env = {}
-
-
-        self.skip_test = self.check_for_skip_scenario(command)
-
     @property
     def command(self):
         return self._command
@@ -294,15 +285,16 @@ class ExecTest(Test):
         return out, err, returncode
 
 
-class PlainExecTest(ExecTest):
+class PlainExecTest(Test):
     """
     PlainExecTest: Run a "native" piglit test executable
 
     Expect one line prefixed PIGLIT: in the output, which contains a result
     dictionary. The plain output is appended to this dictionary
     """
-    def __init__(self, command):
-        ExecTest.__init__(self, command)
+    def __init__(self, *args, **kwargs):
+        super(PlainExecTest, self).__init__(*args, **kwargs)
+
         # Prepend testBinDir to the path.
         self._command[0] = os.path.join(testBinDir, self._command[0])
 
diff --git a/framework/gleantest.py b/framework/gleantest.py
index aad73fd..4032bf5 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -23,20 +23,20 @@
 
 import os
 
-from .exectest import ExecTest, testBinDir
+from .exectest import Test, testBinDir
 
 glean_executable = os.path.join(testBinDir, "glean")
 
 # GleanTest: Execute a sub-test of Glean
-class GleanTest(ExecTest):
+class GleanTest(Test):
     globalParams = []
 
-    def __init__(self, name):
-        ExecTest.__init__(self, [glean_executable,
-                                 "-o", "-v", "-v", "-v", "-t", "+" + name])
+    def __init__(self, name, **kwargs):
+        super(GleanTest, self).__init__([glean_executable, "-o", "-v", "-v",
+                                       "-v", "-t", "+" + name])
         self.name = name
 
-    @ExecTest.command.getter
+    @Test.command.getter
     def command(self):
         return self._command + self.globalParams
 
diff --git a/framework/gtest.py b/framework/gtest.py
index 7b474f3..9e953eb 100644
--- a/framework/gtest.py
+++ b/framework/gtest.py
@@ -26,9 +26,9 @@
 
 import re
 
-from framework.exectest import ExecTest
+from framework.exectest import Test
 
-class GTest(ExecTest):
+class GTest(Test):
     def interpretResult(self, out, returncode, results, dmesg):
         # Since gtests can have several subtets, if any of the subtests fail
         # then we need to report fail.
diff --git a/tests/es3conform.py b/tests/es3conform.py
index d5d6a12..8302a44 100644
--- a/tests/es3conform.py
+++ b/tests/es3conform.py
@@ -27,7 +27,7 @@ import sys
 from os import path
 from glob import glob
 from framework.core import TestProfile
-from framework.exectest import ExecTest, testBinDir
+from framework.exectest import Test, testBinDir
 
 __all__ = ['profile']
 
@@ -47,11 +47,13 @@ profile = TestProfile()
 # Chase the piglit/bin/GTF symlink to find where the tests really live.
 gtfroot = path.dirname(path.realpath(path.join(testBinDir, 'GTF3')))
 
-class GTFTest(ExecTest):
+class GTFTest(Test):
     pass_re = re.compile(r'(Conformance|Regression) PASSED all (?P<passed>\d+) tests')
 
     def __init__(self, testpath):
-        ExecTest.__init__(self, [path.join(testBinDir, 'GTF3'), '-minfmt', '-width=113', '-height=47', '-run=' + testpath])
+        super(GTFTest, self).__init__([path.join(testBinDir, 'GTF3'),
+                                       '-minfmt', '-width=113', '-height=47',
+                                       '-run=' + testpath])
 
     def interpretResult(self, out, returncode, results):
         mo = self.pass_re.search(out)
diff --git a/tests/igt.py b/tests/igt.py
index 7416b4e..0179ebd 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -29,7 +29,7 @@ import subprocess
 
 from os import path
 from framework.core import TestProfile, TestResult
-from framework.exectest import ExecTest, testBinDir
+from framework.exectest import Test, testBinDir
 
 __all__ = ['profile']
 
@@ -70,9 +70,10 @@ igtEnvironmentOk = checkEnvironment()
 
 profile = TestProfile()
 
-class IGTTest(ExecTest):
+class IGTTest(Test):
     def __init__(self, binary, arguments=[]):
-        ExecTest.__init__(self, [path.join(igtTestRoot, binary)] + arguments)
+        super(IGTTest, self).__init__(
+            [path.join(igtTestRoot, binary)] + arguments)
 
     def interpretResult(self, out, returncode, results):
         if not igtEnvironmentOk:
diff --git a/tests/oglconform.py b/tests/oglconform.py
index c2273dc..ce3bac6 100644
--- a/tests/oglconform.py
+++ b/tests/oglconform.py
@@ -27,7 +27,7 @@ import sys
 import subprocess
 
 from framework.core import TestProfile
-from framework.exectest import ExecTest, testBinDir
+from framework.exectest import Test, testBinDir
 from os import path
 
 __all__ = ['profile']
@@ -45,11 +45,12 @@ profile = TestProfile()
 ##### To use this, create an 'oglconform' symlink in piglit/bin.  Piglit
 ##### will obtain a list of tests from oglconform and add them all.
 #############################################################################
-class OGLCTest(ExecTest):
+class OGLCTest(Test):
     skip_re = re.compile(r'Total Not run: 1|no test in schedule is compat|GLSL [13].[345]0 is not supported|wont be scheduled due to lack of compatible fbconfig')
 
     def __init__(self, category, subtest):
-        ExecTest.__init__(self, [bin_oglconform, '-minFmt', '-v', '4', '-test', category, subtest])
+        super(OGLCTest, self).__init__([bin_oglconform, '-minFmt', '-v', '4',
+                                        '-test', category, subtest])
 
     def interpretResult(self, out, returncode, results):
         if self.skip_re.search(out) is not None:
-- 
1.8.5.4



More information about the Piglit mailing list