[Piglit] [PATCH 3/5] framework/test: allow tests to set per instance timeouts from initializer
Dylan Baker
baker.dylan.c at gmail.com
Thu Jul 9 14:25:43 PDT 2015
This allows tests to set a per instance timeout in the class
initializer, which means it can be done in all.py from the adder
function by specifying a timeout value. If the timeout value is not set
then it falls back to the class value, which is either None (from the
base Test class) or a value set in one of Test's Children.
This fixes fp-indirections and max-varyings on my haswell (which take
longer than the 30 seconds provided by PiglitGLTest)
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/test/base.py | 7 ++++++-
framework/tests/base_tests.py | 17 +++++++++++++++++
tests/all.py | 4 ++--
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/framework/test/base.py b/framework/test/base.py
index e85f5f1..52cfb50 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -95,7 +95,7 @@ class Test(object, metaclass=abc.ABCMeta):
'_test_hook_execute_run']
timeout = None
- def __init__(self, command, run_concurrent=False):
+ def __init__(self, command, run_concurrent=False, timeout=None):
assert isinstance(command, list), command
self.run_concurrent = run_concurrent
@@ -103,6 +103,11 @@ class Test(object, metaclass=abc.ABCMeta):
self.env = {}
self.result = TestResult({'result': 'fail'})
self.cwd = None
+ if timeout is not None:
+ # If no timeout is specified this will fallback to the class value
+ # XXX: can this actually be a float?
+ assert isinstance(timeout, (int, float))
+ self.timeout = timeout # pylint: disable=assigning-non-slot
# This is a hook for doing some testing on execute right before
# self.run is called.
diff --git a/framework/tests/base_tests.py b/framework/tests/base_tests.py
index 41916a8..c68251f 100644
--- a/framework/tests/base_tests.py
+++ b/framework/tests/base_tests.py
@@ -36,6 +36,7 @@ class TestTest(Test):
self.test_interpret_result name
"""
+ timeout = 120
test_interpret_result = lambda: None
def interpret_result(self):
@@ -160,3 +161,19 @@ def test_mutation():
_Test(args)
nt.assert_list_equal(args, ['a', 'b'])
+
+
+ at nt.timed(3)
+def test_override_timeout():
+ """test.base.Test: overriding timeout on a per instance basis works
+
+ Since TestTest has a timeout of 120 seconds, and the test defined here
+ should run 60 seconds, and we set a timeout of 1 second we expect this test
+ to take less than 3 seconds (to give some setup flexability) if it goes
+ over that it is a failure.
+
+ """
+ utils.binary_check('sleep')
+
+ test = TestTest(['sleep', '60'], timeout=1)
+ test.run()
diff --git a/tests/all.py b/tests/all.py
index 27933be..96c16f3 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1897,7 +1897,7 @@ with profile.group_manager(
g(['fp-formats'], run_concurrent=False)
g(['fp-fragment-position'], run_concurrent=False)
g(['fp-incomplete-tex'], run_concurrent=False)
- g(['fp-indirections'], run_concurrent=False)
+ g(['fp-indirections'], run_concurrent=False, timeout=60)
g(['fp-indirections2'], run_concurrent=False)
g(['fp-kil'], run_concurrent=False)
g(['fp-lit-mask'], run_concurrent=False)
@@ -3272,7 +3272,7 @@ with profile.group_manager(
'immediate-reuse-index-buffer')
g(['ext_transform_feedback-immediate-reuse-uniform-buffer'],
'immediate-reuse-uniform-buffer')
- g(['ext_transform_feedback-max-varyings'], 'max-varyings')
+ g(['ext_transform_feedback-max-varyings'], 'max-varyings', timeout=60)
g(['ext_transform_feedback-nonflat-integral'], 'nonflat-integral')
g(['ext_transform_feedback-overflow-edge-cases'], 'overflow-edge-cases')
g(['ext_transform_feedback-overflow-edge-cases', 'use_gs'],
--
2.4.5
More information about the Piglit
mailing list