Hi Jose,
On Friday, August 02, 2013 05:57:42 Jose Fonseca wrote:
> > I found one occurance of os.execv in framework/shader_test.py and three of
> > Popen in framework/{glsl_parser_test.py,exectest.py,core.py}.
> > Do you know which ones of these are actually used for the tests in
> > question? Any hint which one to change?
>
> No, I don't. My guess would be either exectest.py or core.py
Cought.
Attached is a change that implements a fixed 30 minute timeout for a single
test.
The change was initially a port of your code snipped. The difference in the
implementation arises from signal.signal not willing to execute in a non main
thread.
I expect that in the long term one needs a per test configurable timeout. Also
probably a time factor that is put on that numbers for the valgrind runs.
Greetings
Mathias
>From 5023a4830dbcadf010d572a3c6e446a2ad120e7f Mon Sep 17 00:00:00 2001
From: Mathias Froehlich <[email protected]>
Date: Wed, 7 Aug 2013 07:40:15 +0200
Subject: [PATCH] Implement a timeout for the test runs.
Some tests, especially those testing for race conditions,
might deadlock. Not to hang the test runs indefinitely, there is
now a 30 minute timeout.
---
framework/core.py | 2 ++
framework/exectest.py | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/framework/core.py b/framework/core.py
index 108b517..7c48984 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -417,6 +417,8 @@ class Test:
'''
self.runConcurrent = runConcurrent
self.skip_test = False
+ # timeout in seconds
+ self.timeout = 30*60
def run(self):
raise NotImplementedError
diff --git a/framework/exectest.py b/framework/exectest.py
index 6ee550c..1d0947b 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -24,6 +24,7 @@ import errno
import os
import subprocess
import shlex
+import threading
import types
from core import Test, testBinDir, TestResult
@@ -48,6 +49,11 @@ class ExecTest(Test):
self.command = shlex.split(str(self.command))
self.skip_test = self.check_for_skip_scenario(command)
+ # timeout in seconds
+ # This is in effect set in the Test class.
+ # The reason is that some of the classes deriving from ExecTest only
+ # call Test.__init__ instead of ExecTest.__init__
+ # self.timeout = 30*60
def interpretResult(self, out, returncode, results):
raise NotImplementedError
@@ -181,12 +187,22 @@ class ExecTest(Test):
return False
def get_command_result(self, command, fullenv):
+ timer = None
+ timedout = False
try:
proc = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=fullenv,
universal_newlines=True)
+
+ def _kill_process():
+ timedout = True
+ proc.kill()
+
+ timer = threading.Timer(self.timeout, _kill_process)
+ timer.start()
+
out, err = proc.communicate()
returncode = proc.returncode
except OSError as e:
@@ -202,6 +218,16 @@ class ExecTest(Test):
returncode = None
else:
raise e
+ finally:
+ if not timer is None:
+ timer.cancel()
+
+ if timedout:
+ out = ""
+ err = "PIGLIT: {'result': 'fail'}\n" \
+ + "Test timed out.\n"
+ returncode = None
+
return out, err, returncode
--
1.7.1
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit