[v4,3/27] framework/profile: make run hooks public

Submitted by Dylan Baker on Nov. 9, 2016, 8:53 p.m.

Details

Message ID 818859aa3d9dd5ef268695157b9aa68510f5c071.1478724535.git-series.dylan@pnwbakers.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Dylan Baker Nov. 9, 2016, 8:53 p.m.
These are used in a couple of places, and since they're meant to be
changed by subclasses they need to be public.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
---
 framework/profile.py | 28 ++++++++--------------------
 tests/igt.py         |  3 ++-
 tests/xts.py         |  8 ++++----
 3 files changed, 14 insertions(+), 25 deletions(-)

Patch hide | download patch | download mbox

diff --git a/framework/profile.py b/framework/profile.py
index 7b0cb07..0d2e1cf 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -287,22 +287,6 @@  class TestProfile(object):
             raise exceptions.PiglitFatalError(
                 'There are no tests scheduled to run. Aborting run.')
 
-    def _pre_run_hook(self):
-        """ Hook executed at the start of TestProfile.run
-
-        To make use of this hook one will need to subclass TestProfile, and
-        set this to do something, as be default it will no-op
-        """
-        pass
-
-    def _post_run_hook(self):
-        """ Hook executed at the end of TestProfile.run
-
-        To make use of this hook one will need to subclass TestProfile, and
-        set this to do something, as be default it will no-op
-        """
-        pass
-
     def run(self, logger, backend):
         """ Runs all tests using Thread pool
 
@@ -321,8 +305,6 @@  class TestProfile(object):
 
         """
 
-        self._pre_run_hook()
-
         chunksize = 1
 
         self._prepare_test_list()
@@ -350,6 +332,7 @@  class TestProfile(object):
         single = multiprocessing.dummy.Pool(1)
         multi = multiprocessing.dummy.Pool()
 
+        self.setup()
         try:
             if options.OPTIONS.concurrent == "all":
                 run_threads(multi, six.iteritems(self.test_list))
@@ -371,8 +354,7 @@  class TestProfile(object):
             # then die. Pressing C-c again will kill immediately.
             log.get().summary()
             raise
-
-        self._post_run_hook()
+        self.teardown()
 
         if self._monitoring.abort_needed:
             raise exceptions.PiglitAbort(self._monitoring.error_message)
@@ -482,6 +464,12 @@  class TestProfile(object):
         with self.test_list.allow_reassignment:
             yield
 
+    def setup(self):
+        """Method to do pre-run setup."""
+
+    def teardown(self):
+        """Method to od post-run teardown."""
+
 
 def load_test_profile(filename):
     """Load a python module and return it's profile attribute.
diff --git a/tests/igt.py b/tests/igt.py
index 7ebb036..69c91d1 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -91,7 +91,8 @@  else:
 
 class IGTTestProfile(TestProfile):
     """Test profile for intel-gpu-tools tests."""
-    def _pre_run_hook(self):
+
+    def setup(self):
         if options.OPTIONS.execute:
             try:
                 check_environment()
diff --git a/tests/xts.py b/tests/xts.py
index f3cbbe8..715ecfa 100644
--- a/tests/xts.py
+++ b/tests/xts.py
@@ -41,12 +41,12 @@  X_TEST_SUITE = core.PIGLIT_CONFIG.required_get('xts', 'path')
 
 class XTSProfile(TestProfile):  # pylint: disable=too-few-public-methods
     """ A subclass of TestProfile that provides a setup hook for XTS """
-    def _pre_run_hook(self):
-        """ This hook sets the XTSTest.results_path variable
 
-        Setting this variable allows images created by XTS to moved into the
-        results directory
+    def setup(self):
+        """This hook sets the XTSTest.results_path variable.
 
+        Setting this variable allows images created by XTS to moved into the
+        results directory.
         """
         XTSTest.RESULTS_PATH = self.results_dir