Add a 10 minute timeout to individual tests.

On the bots, we have a timeout without output of 60 minutes for the entire test.
This should ensure that we are able to kill mis-behaving tests and give a good
error instead of just getting a jenkins timeout error.

For those confused, this is for the guard malloc/leaks test.

rdar://36874229
This commit is contained in:
Michael Gottesman
2018-01-26 13:19:31 -08:00
parent 02fcdf150d
commit 70251a3ff8
2 changed files with 39 additions and 15 deletions

View File

@@ -57,6 +57,24 @@ class Result(object):
print(fmt.format(self.get_name(), self.get_result()))
def run_with_timeout(func, args):
# We timeout after 10 minutes.
timeout_seconds = 10 * 60
# We just use this to create a timeout since we use an older python. Once
# we update to use python >= 3.3, use the timeout API on communicate
# instead.
import multiprocessing.dummy
fakeThreadPool = multiprocessing.dummy.Pool(1)
try:
result = fakeThreadPool.apply_async(func, args=args)
return result.get(timeout_seconds)
except multiprocessing.TimeoutError:
fakeThreadPool.terminate()
raise RuntimeError("Child process aborted due to timeout. "
"Timeout: %s seconds" % timeout_seconds)
def _unwrap_self(args):
return type(args[0]).process_input(*args)