[Piglit] [PATCH] framework: add a timeout command line parameter
Thomas Wood
thomas.wood at intel.com
Mon Jul 13 06:09:26 PDT 2015
On 10 July 2015 at 19:24, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> Hi Thomas,
>
> I meant to get back to you earlier on this, but I forgot yesterday when
> I got bogged down in Jenkins madness.
>
> Anyway, if you have a look at the (I think) 2nd patch in my python3
> series, you'll notice that I had the idea that we could set timeouts in
> classes on a per class basis. This presents a problem for using a
> universal test time overwrite, especially when you consider that we also
> may need per-test overwrites (some of the piglit tests are really long,
> some of them are really short).
>
> Do you want to have an igt only override, or should we try to figure out
> how to make something that will work universally?
>
The idea was to allow the user to temporarily change the timeout that
applied to all tests. It could include a parameter to ensure that timeout
durations are only ever reduced or increased.
> Dylan
>
> On Thu, Jul 09, 2015 at 06:05:56PM +0100, Thomas Wood wrote:
> > 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
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150713/03e7af91/attachment-0001.html>
More information about the Piglit
mailing list