summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVince Harron <vharron@google.com>2014-12-13 00:08:19 +0000
committerVince Harron <vharron@google.com>2014-12-13 00:08:19 +0000
commit17f429f46255230b5b54f4ed947cc88c9f424a62 (patch)
treed7ce49235544fc12275cf2aeaee4be775d3cbe45
parentf4b170d0daf68b38fa951cb12d0b6e1395bc6ec7 (diff)
downloadbcm5719-llvm-17f429f46255230b5b54f4ed947cc88c9f424a62.tar.gz
bcm5719-llvm-17f429f46255230b5b54f4ed947cc88c9f424a62.zip
Tests will timeout if they exceed time limit.
Default time limit is 5 minutes. Override the default timeout of 5 minutes with LLDB_TEST_TIMEOUT. LLDB_TEST_TIMEOUT=10m Override the timeout for individual tests with LLDB_[TESTNAME]_TIMEOUT. E.g., LLDB_TESTCONCURRENTEVENTS_TIMEOUT=2m Set to "0" to run without timeout. Submitted for Chaoren Lin llvm-svn: 224171
-rwxr-xr-xlldb/test/dosep.py74
1 files changed, 63 insertions, 11 deletions
diff --git a/lldb/test/dosep.py b/lldb/test/dosep.py
index 153b8fc9bfd..4571320d59f 100755
--- a/lldb/test/dosep.py
+++ b/lldb/test/dosep.py
@@ -7,15 +7,50 @@ Run the test suite using a separate process for each test file.
import multiprocessing
import os
import platform
+import shlex
+import subprocess
import sys
from optparse import OptionParser
-# Command template of the invocation of the test driver.
-template = '%s %s/dotest.py %s -p %s %s'
+def get_timeout_command():
+ if sys.platform.startswith("win32"):
+ return None
+ try:
+ subprocess.call("timeout")
+ return "timeout"
+ except OSError:
+ pass
+ try:
+ subprocess.call("gtimeout")
+ return "gtimeout"
+ except OSError:
+ pass
+ return None
+
+timeout_command = get_timeout_command()
+
+default_timeout = os.getenv("LLDB_TEST_TIMEOUT") or "5m"
+
+# Status codes for running command with timeout.
+eTimedOut, ePassed, eFailed = 124, 0, 1
+
+def call_with_timeout(command, timeout):
+ """Each test will timeout after 5 minutes by default.
+ Override the default timeout of 5 minutes with LLDB_TEST_TIMEOUT.
+ E.g., LLDB_TEST_TIMEOUT=10m
+ Override the timeout for individual tests with LLDB_[TEST NAME]_TIMEOUT.
+ E.g., LLDB_TESTCONCURRENTEVENTS_TIMEOUT=2m
+ Set to "0" to run without timeout."""
+ if timeout_command:
+ return subprocess.call([timeout_command, timeout] + command,
+ stdin=subprocess.PIPE)
+ return (ePassed if subprocess.call(command, stdin=subprocess.PIPE) == 0
+ else eFailed)
def process_dir(root, files, test_root, dotest_options):
"""Examine a directory for tests, and invoke any found within it."""
+ timed_out = []
failed = []
passed = []
for name in files:
@@ -29,12 +64,23 @@ def process_dir(root, files, test_root, dotest_options):
if os.path.islink(path):
continue
- command = template % (sys.executable, test_root, dotest_options if dotest_options else "", name, root)
- if 0 != os.system(command):
- failed.append(name)
- else:
+ command = ([sys.executable, "%s/dotest.py" % test_root] +
+ (shlex.split(dotest_options) if dotest_options else []) +
+ ["-p", name, root])
+
+ timeout_name = os.path.basename(os.path.splitext(name)[0]).upper()
+
+ timeout = os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or default_timeout
+
+ exit_status = call_with_timeout(command, timeout)
+
+ if ePassed == exit_status:
passed.append(name)
- return (failed, passed)
+ else:
+ if eTimedOut == exit_status:
+ timed_out.append(name)
+ failed.append(name)
+ return (timed_out, failed, passed)
in_q = None
out_q = None
@@ -66,15 +112,17 @@ def walk_and_invoke(test_root, dotest_options, num_threads):
for work_item in test_work_items:
test_results.append(process_dir_worker(work_item))
+ timed_out = []
failed = []
passed = []
for test_result in test_results:
- (dir_failed, dir_passed) = test_result
+ (dir_timed_out, dir_failed, dir_passed) = test_result
+ timed_out += dir_timed_out
failed += dir_failed
passed += dir_passed
- return (failed, passed)
+ return (timed_out, failed, passed)
def main():
test_root = sys.path[0]
@@ -107,7 +155,9 @@ Run lldb test suite using a separate process for each test file.
num_threads = 1
system_info = " ".join(platform.uname())
- (failed, passed) = walk_and_invoke(test_root, dotest_options, num_threads)
+ (timed_out, failed, passed) = walk_and_invoke(test_root, dotest_options,
+ num_threads)
+ timed_out = set(timed_out)
num_tests = len(failed) + len(passed)
print "Ran %d tests." % num_tests
@@ -115,7 +165,9 @@ Run lldb test suite using a separate process for each test file.
failed.sort()
print "Failing Tests (%d)" % len(failed)
for f in failed:
- print "FAIL: LLDB (suite) :: %s (%s)" % (f, system_info)
+ print "%s: LLDB (suite) :: %s (%s)" % (
+ "TIMEOUT" if f in timed_out else "FAIL", f, system_info
+ )
sys.exit(1)
sys.exit(0)
OpenPOWER on IntegriCloud