From 56db16e43bbbd002eca2e908c9a8a7acf2dc43f3 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 28 Jun 2018 13:40:42 -0700 Subject: framework: add a --timeout parameter This allows an timeout (in integers) to be set for each test. If the tests run over this alotted time they'll be killed and the status will be set to timeout. This only work on Unix-like machines running with python 3.x or with 2.7 and subprocess32 installed. It can be made to work for windows, either by bumping the python version or by writing some windows specific code for killing processes. v2: - Add the word "Default" to help message. Reviewed-by: Jordan Justen --- framework/programs/run.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'framework') diff --git a/framework/programs/run.py b/framework/programs/run.py index afb7eb78d..151762fc5 100644 --- a/framework/programs/run.py +++ b/framework/programs/run.py @@ -39,6 +39,7 @@ from framework import exceptions from framework import monitoring from framework import profile from framework.results import TimeAttribute +from framework.test import base from . import parsers __all__ = ['run', @@ -220,6 +221,13 @@ def _run_parser(input_): dest="ignore_missing", action="store_true", help="missing tests are considered as 'notrun'") + parser.add_argument('--timeout', + dest='timeout', + action='store', + type=int, + default=None, + metavar='', + help='Set a default timeout threshold for tests to run in.') parser.add_argument("test_profile", metavar="", nargs='+', @@ -247,6 +255,7 @@ def _create_metadata(args, name, forced_test_list): opts['platform'] = args.platform opts['forced_test_list'] = forced_test_list opts['ignore_missing'] = args.ignore_missing + opts['timeout'] = args.timeout metadata = {'options': opts} metadata['name'] = name @@ -291,6 +300,7 @@ def run(input_): """ args = _run_parser(input_) + base.Test.timeout = args.timeout _disable_windows_exception_messages() # If dmesg is requested we must have serial run, this is because dmesg @@ -423,6 +433,7 @@ def resume(input_): core.get_config(args.config_file) options.OPTIONS.env['PIGLIT_PLATFORM'] = results.options['platform'] + base.Test.timeout = results.options['timeout'] results.options['env'] = core.collect_system_info() results.options['name'] = results.name -- cgit v1.2.3