I didn't notice this while it was up for review, but a command line option to dotest might be better than an environment variable, since it will be documented when you run dotest.py --help<br><div class="gmail_quote">On Fri, Dec 12, 2014 at 4:09 PM Vince Harron <<a href="mailto:vharron@google.com">vharron@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vharron<br>
Date: Fri Dec 12 18:08:19 2014<br>
New Revision: 224171<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224171&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=224171&view=rev</a><br>
Log:<br>
Tests will timeout if they exceed time limit.<br>
<br>
Default time limit is 5 minutes.<br>
<br>
Override the default timeout of 5 minutes with LLDB_TEST_TIMEOUT.<br>
LLDB_TEST_TIMEOUT=10m<br>
<br>
Override the timeout for individual tests with LLDB_[TESTNAME]_TIMEOUT.<br>
E.g., LLDB_TESTCONCURRENTEVENTS_<u></u>TIMEOUT=2m<br>
<br>
Set to "0" to run without timeout.<br>
<br>
Submitted for Chaoren Lin<br>
<br>
<br>
Modified:<br>
lldb/trunk/test/dosep.py<br>
<br>
Modified: lldb/trunk/test/dosep.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=224171&r1=224170&r2=224171&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/lldb/trunk/test/dosep.<u></u>py?rev=224171&r1=224170&r2=<u></u>224171&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- lldb/trunk/test/dosep.py (original)<br>
+++ lldb/trunk/test/dosep.py Fri Dec 12 18:08:19 2014<br>
@@ -7,15 +7,50 @@ Run the test suite using a separate proc<br>
import multiprocessing<br>
import os<br>
import platform<br>
+import shlex<br>
+import subprocess<br>
import sys<br>
<br>
from optparse import OptionParser<br>
<br>
-# Command template of the invocation of the test driver.<br>
-template = '%s %s/dotest.py %s -p %s %s'<br>
+def get_timeout_command():<br>
+ if sys.platform.startswith("<u></u>win32"):<br>
+ return None<br>
+ try:<br>
+ subprocess.call("timeout")<br>
+ return "timeout"<br>
+ except OSError:<br>
+ pass<br>
+ try:<br>
+ subprocess.call("gtimeout")<br>
+ return "gtimeout"<br>
+ except OSError:<br>
+ pass<br>
+ return None<br>
+<br>
+timeout_command = get_timeout_command()<br>
+<br>
+default_timeout = os.getenv("LLDB_TEST_TIMEOUT") or "5m"<br>
+<br>
+# Status codes for running command with timeout.<br>
+eTimedOut, ePassed, eFailed = 124, 0, 1<br>
+<br>
+def call_with_timeout(command, timeout):<br>
+ """Each test will timeout after 5 minutes by default.<br>
+ Override the default timeout of 5 minutes with LLDB_TEST_TIMEOUT.<br>
+ E.g., LLDB_TEST_TIMEOUT=10m<br>
+ Override the timeout for individual tests with LLDB_[TEST NAME]_TIMEOUT.<br>
+ E.g., LLDB_TESTCONCURRENTEVENTS_<u></u>TIMEOUT=2m<br>
+ Set to "0" to run without timeout."""<br>
+ if timeout_command:<br>
+ return subprocess.call([timeout_<u></u>command, timeout] + command,<br>
+ stdin=subprocess.PIPE)<br>
+ return (ePassed if subprocess.call(command, stdin=subprocess.PIPE) == 0<br>
+ else eFailed)<br>
<br>
def process_dir(root, files, test_root, dotest_options):<br>
"""Examine a directory for tests, and invoke any found within it."""<br>
+ timed_out = []<br>
failed = []<br>
passed = []<br>
for name in files:<br>
@@ -29,12 +64,23 @@ def process_dir(root, files, test_root,<br>
if os.path.islink(path):<br>
continue<br>
<br>
- command = template % (sys.executable, test_root, dotest_options if dotest_options else "", name, root)<br>
- if 0 != os.system(command):<br>
- failed.append(name)<br>
- else:<br>
+ command = ([sys.executable, "%s/dotest.py" % test_root] +<br>
+ (shlex.split(dotest_options) if dotest_options else []) +<br>
+ ["-p", name, root])<br>
+<br>
+ timeout_name = os.path.basename(os.path.<u></u>splitext(name)[0]).upper()<br>
+<br>
+ timeout = os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or default_timeout<br>
+<br>
+ exit_status = call_with_timeout(command, timeout)<br>
+<br>
+ if ePassed == exit_status:<br>
passed.append(name)<br>
- return (failed, passed)<br>
+ else:<br>
+ if eTimedOut == exit_status:<br>
+ timed_out.append(name)<br>
+ failed.append(name)<br>
+ return (timed_out, failed, passed)<br>
<br>
in_q = None<br>
out_q = None<br>
@@ -66,15 +112,17 @@ def walk_and_invoke(test_root, dotest_op<br>
for work_item in test_work_items:<br>
test_results.append(process_<u></u>dir_worker(work_item))<br>
<br>
+ timed_out = []<br>
failed = []<br>
passed = []<br>
<br>
for test_result in test_results:<br>
- (dir_failed, dir_passed) = test_result<br>
+ (dir_timed_out, dir_failed, dir_passed) = test_result<br>
+ timed_out += dir_timed_out<br>
failed += dir_failed<br>
passed += dir_passed<br>
<br>
- return (failed, passed)<br>
+ return (timed_out, failed, passed)<br>
<br>
def main():<br>
test_root = sys.path[0]<br>
@@ -107,7 +155,9 @@ Run lldb test suite using a separate pro<br>
num_threads = 1<br>
<br>
system_info = " ".join(platform.uname())<br>
- (failed, passed) = walk_and_invoke(test_root, dotest_options, num_threads)<br>
+ (timed_out, failed, passed) = walk_and_invoke(test_root, dotest_options,<br>
+ num_threads)<br>
+ timed_out = set(timed_out)<br>
num_tests = len(failed) + len(passed)<br>
<br>
print "Ran %d tests." % num_tests<br>
@@ -115,7 +165,9 @@ Run lldb test suite using a separate pro<br>
failed.sort()<br>
print "Failing Tests (%d)" % len(failed)<br>
for f in failed:<br>
- print "FAIL: LLDB (suite) :: %s (%s)" % (f, system_info)<br>
+ print "%s: LLDB (suite) :: %s (%s)" % (<br>
+ "TIMEOUT" if f in timed_out else "FAIL", f, system_info<br>
+ )<br>
sys.exit(1)<br>
sys.exit(0)<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/lldb-commits</a><br>
</blockquote></div>