[Piglit] [PATCH] framework: remove _test_run_hook from Test

Dylan Baker baker.dylan.c at gmail.com
Mon Aug 3 14:30:53 PDT 2015


This was a design mistake from the start, subclassing the Test class and
overriding the run() method achieves the same result, without the need
for this hook

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---

This hook was only used in unit tests, so the only affect should be to
make running piglit use a little less memory and run a little faster.

 framework/test/base.py         |  7 +------
 framework/tests/dmesg_tests.py | 12 ++++++++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/framework/test/base.py b/framework/test/base.py
index b4ee4ad..276ef1c 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -145,7 +145,7 @@ class Test(object):
     OPTS = Options()
     __metaclass__ = abc.ABCMeta
     __slots__ = ['run_concurrent', 'env', 'result', 'cwd', '_command',
-                 '_test_hook_execute_run', '__proc_timeout']
+                 '__proc_timeout']
     timeout = 0
 
     def __init__(self, command, run_concurrent=False):
@@ -158,10 +158,6 @@ class Test(object):
         self.cwd = None
         self.__proc_timeout = None
 
-        # This is a hook for doing some testing on execute right before
-        # self.run is called.
-        self._test_hook_execute_run = lambda: None
-
     def execute(self, path, log, dmesg):
         """ Run a test
 
@@ -180,7 +176,6 @@ class Test(object):
             try:
                 time_start = time.time()
                 dmesg.update_dmesg()
-                self._test_hook_execute_run()
                 self.run()
                 self.result['time'] = time.time() - time_start
                 self.result = dmesg.update_result(self.result)
diff --git a/framework/tests/dmesg_tests.py b/framework/tests/dmesg_tests.py
index c264acb..55b0b2a 100644
--- a/framework/tests/dmesg_tests.py
+++ b/framework/tests/dmesg_tests.py
@@ -402,6 +402,10 @@ def test_testclasses_dmesg():
 
 def check_classes_dmesg(test_class, test_args):
     """ Do the actual check on the provided test class for dmesg """
+    # There is so much magic in this test that pylint freaks out needlessly,
+    # please ignore all of those errors
+    # pylint: disable=no-init,too-few-public-methods,super-on-old-class
+    # pylint: disable=no-member
     if not os.path.exists('bin'):
         raise SkipTest("This tests requires a working, built version of "
                        "piglit")
@@ -409,8 +413,12 @@ def check_classes_dmesg(test_class, test_args):
     test = _get_dmesg()
 
     # Create the test and then write to dmesg to ensure that it actually works
-    test = test_class(test_args)
-    test._test_hook_execute_run = _write_dev_kmesg
+    class _localclass(test_class):
+        def run(self):
+            _write_dev_kmesg()
+            super(_localclass, self).run()
+
+    test = _localclass(test_args)
 
     json = DummyJsonWriter()
 
-- 
2.5.0



More information about the Piglit mailing list