[Piglit] [PATCH] framework: add a timeout command line parameter
Thomas Wood
thomas.wood at intel.com
Thu Jul 9 10:05:56 PDT 2015
Signed-off-by: Thomas Wood <thomas.wood at intel.com>
---
framework/core.py | 6 +++++-
framework/programs/run.py | 8 ++++++--
framework/test/base.py | 7 +++----
framework/tests/base_tests.py | 2 +-
tests/igt.py | 3 ++-
5 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/framework/core.py b/framework/core.py
index f9cdbfe..45d2552 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -146,10 +146,13 @@ class Options(object):
valgrind -- True if valgrind is to be used
dmesg -- True if dmesg checking is desired. This forces concurrency off
env -- environment variables set for each test before run
+ sync -- Sync results to disk after every test
+ timeout -- Number of seconds before a test is assumed to have failed
"""
def __init__(self, concurrent=True, execute=True, include_filter=None,
- exclude_filter=None, valgrind=False, dmesg=False, sync=False):
+ exclude_filter=None, valgrind=False, dmesg=False, sync=False,
+ timeout=None):
self.concurrent = concurrent
self.execute = execute
self.filter = \
@@ -160,6 +163,7 @@ class Options(object):
self.valgrind = valgrind
self.dmesg = dmesg
self.sync = sync
+ self.timeout = int(timeout) if timeout else None
# env is used to set some base environment variables that are not going
# to change across runs, without sending them to os.environ which is
diff --git a/framework/programs/run.py b/framework/programs/run.py
index 2981ffa..f852ba4 100644
--- a/framework/programs/run.py
+++ b/framework/programs/run.py
@@ -179,6 +179,8 @@ def _run_parser(input_):
help="Set the logger verbosity level")
parser.add_argument("--test-list",
help="A file containing a list of tests to run")
+ parser.add_argument("--timeout",
+ help="Number of seconds before a test is assumed to have failed")
parser.add_argument("test_profile",
metavar="<Profile path(s)>",
nargs='+',
@@ -257,7 +259,8 @@ def run(input_):
execute=args.execute,
valgrind=args.valgrind,
dmesg=args.dmesg,
- sync=args.sync)
+ sync=args.sync,
+ timeout=args.timeout)
# Set the platform to pass to waffle
opts.env['PIGLIT_PLATFORM'] = args.platform
@@ -325,7 +328,8 @@ def resume(input_):
execute=results.options['execute'],
valgrind=results.options['valgrind'],
dmesg=results.options['dmesg'],
- sync=results.options['sync'])
+ sync=results.options['sync'],
+ timeout=results.options['timeout'])
core.get_config(args.config_file)
diff --git a/framework/test/base.py b/framework/test/base.py
index b4ee4ad..9f43673 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -146,7 +146,6 @@ class Test(object):
__metaclass__ = abc.ABCMeta
__slots__ = ['run_concurrent', 'env', 'result', 'cwd', '_command',
'_test_hook_execute_run', '__proc_timeout']
- timeout = 0
def __init__(self, command, run_concurrent=False):
assert isinstance(command, list), command
@@ -244,7 +243,7 @@ class Test(object):
if _is_crash_returncode(self.result['returncode']):
# check if the process was terminated by the timeout
- if self.timeout > 0 and self.__proc_timeout.join() > 0:
+ if self.OPTS.timeout > 0 and self.__proc_timeout.join() > 0:
self.result['result'] = 'timeout'
else:
self.result['result'] = 'crash'
@@ -320,8 +319,8 @@ class Test(object):
# process is still going after the timeout, then it will be killed
# forcing the communicate function (which is a blocking call) to
# return
- if self.timeout > 0:
- self.__proc_timeout = ProcessTimeout(self.timeout, proc)
+ if self.OPTS.timeout:
+ self.__proc_timeout = ProcessTimeout(self.OPTS.timeout, proc)
self.__proc_timeout.start()
out, err = proc.communicate()
diff --git a/framework/tests/base_tests.py b/framework/tests/base_tests.py
index a9e0e88..5d73a9f 100644
--- a/framework/tests/base_tests.py
+++ b/framework/tests/base_tests.py
@@ -65,7 +65,7 @@ def test_timeout():
test = TestTest(['sleep', '60'])
test.test_interpret_result = helper
- test.timeout = 1
+ test.OPTS.timeout = 1
test.run()
assert test.result['result'] == 'timeout'
diff --git a/tests/igt.py b/tests/igt.py
index 01531d2..f4db0d9 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -106,7 +106,8 @@ class IGTTest(Test):
arguments = []
super(IGTTest, self).__init__(
[os.path.join(IGT_TEST_ROOT, binary)] + arguments)
- self.timeout = 600
+ if not self.OPTS.timeout:
+ self.OPTS.timeout = 600
def interpret_result(self):
if self.result['returncode'] == 0:
--
2.4.3
More information about the Piglit
mailing list