[Piglit] [Patch v2 10/11] exectest.py: Merge Test and ExecTest into a single class

Dylan Baker baker.dylan.c at gmail.com
Thu Mar 27 15:34:03 PDT 2014


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

v2: - remove test that no longer is valid

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

diff --git a/framework/exectest.py b/framework/exectest.py
index 3028722..b5c62d2 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -32,7 +32,6 @@ from .core import TestResult
 
 
 __all__ = ['Test',
-           'ExecTest',
            'PlainExecTest',
            'testBinDir']
 
@@ -50,7 +49,7 @@ else:
 
 
 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
@@ -58,6 +57,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.
@@ -115,18 +118,6 @@ class Test(object):
             log.log(path, 'dry-run')
             log.post_log(log_current, 'dry-run')
 
-
-# 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
@@ -292,15 +283,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 637d3db..3047e93 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 00ed6db..03be7be 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):
         # Since gtests can have several subtets, if any of the subtests fail
         # then we need to report fail.
diff --git a/framework/tests/exectest_test.py b/framework/tests/exectest_test.py
index 064edcf..0362e0d 100644
--- a/framework/tests/exectest_test.py
+++ b/framework/tests/exectest_test.py
@@ -20,7 +20,7 @@
 
 """ Tests for the exectest module """
 
-from framework.exectest import PlainExecTest, ExecTest, Test
+from framework.exectest import PlainExecTest, Test
 
 
 def test_initialize_test():
@@ -28,11 +28,6 @@ def test_initialize_test():
     Test('/bin/true')
 
 
-def test_initialize_exectest():
-    """ ExecTest initializes """
-    ExecTest('/bin/true')
-
-
 def test_initialize_plainexectest():
     """ Test that PlainExecTest initializes correctly """
     PlainExecTest('/bin/true')
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.9.1



More information about the Piglit mailing list