[Piglit] [PATCH 2/4] framework/core.py: Add pre_run and post_run hooks to TestProfile

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 4 15:39:37 PDT 2014


These hooks no-op in the default TestProfile class, however they are
intended to give versatility and power to external test suites, which
may have specific environment requirements, setup requirements, or
teardown requirements, by allowing them to subclass TestProfile and set
these methods.
---
 framework/core.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/framework/core.py b/framework/core.py
index 5238f60..48dd9b0 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -474,14 +474,34 @@ class TestProfile(object):
         self.test_list = dict(item for item in self.test_list.iteritems()
                               if check_all(item))
 
+    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 dfault 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 dfault it will no-op
+
+        """
+        pass
+
     def run(self, env, json_writer):
         '''
         Schedule all tests in profile for execution.
 
         See ``Test.schedule`` and ``Test.run``.
         '''
-
         self.prepare_test_list(env)
+
+        self.pre_run_hook()
+
         log = Log(len(self.test_list), env.verbose)
 
         def test(pair):
@@ -523,6 +543,8 @@ class TestProfile(object):
 
         log.summary()
 
+        self.post_run_hook()
+
     def filter_tests(self, function):
         """Filter out tests that return false from the supplied function
 
-- 
1.9.1



More information about the Piglit mailing list