<div dir="ltr">This submit was authored by Chaoren Lin, BTW.<div><br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 4:23 PM, Vince Harron <span dir="ltr"><<a href="mailto:vharron@google.com" target="_blank">vharron@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vharron<br>
Date: Thu Dec  4 18:23:03 2014<br>
New Revision: 223423<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223423&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223423&view=rev</a><br>
Log:<br>
Kill any python test script that takes more than 5 minutes<br>
<br>
There is at least one test that hangs on the Linux debian buildbot.<br>
<br>
When that test hangs, the buildbot kills dosep which loses all test<br>
results.  This change kills just the hung test and should let us see<br>
which test is hanging.  This is useful for that test and any others<br>
in the future which start hanging.<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=223423&r1=223422&r2=223423&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=223423&r1=223422&r2=223423&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/test/dosep.py (original)<br>
+++ lldb/trunk/test/dosep.py Thu Dec  4 18:23:03 2014<br>
@@ -7,15 +7,29 @@ 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 try_timeout(command):<br>
+    if not sys.platform.startswith("win32"):<br>
+        try:<br>
+            return {0: "passed", 124: "timed out"}.get(<br>
+                subprocess.call(["timeout", "5m"] + command), "failed")<br>
+        except OSError:<br>
+            pass<br>
+        try:<br>
+            return {0: "passed", 124: "timed out"}.get(<br>
+                subprocess.call(["gtimeout", "5m"] + command), "failed")<br>
+        except OSError:<br>
+            pass<br>
+    return "passed" if subprocess.call(command) == 0 else "failed"<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 +43,17 @@ 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>
+        command = ([sys.executable, "%s/dotest.py" % test_root] +<br>
+                   (shlex.split(dotest_options) if dotest_options else []) +<br>
+                   ["-p", name, root])<br>
+        exit_status = try_timeout(command)<br>
+        if "passed" != exit_status:<br>
+            if "timed out" == exit_status:<br>
+                timed_out.append(name)<br>
             failed.append(name)<br>
         else:<br>
             passed.append(name)<br>
-    return (failed, passed)<br>
+    return (timed_out, failed, passed)<br>
<br>
 in_q = None<br>
 out_q = None<br>
@@ -66,15 +85,17 @@ def walk_and_invoke(test_root, dotest_op<br>
         for work_item in test_work_items:<br>
             test_results.append(process_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 +128,8 @@ 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>
     num_tests = len(failed) + len(passed)<br>
<br>
     print "Ran %d tests." % num_tests<br>
@@ -115,7 +137,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>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">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/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><br><table cellspacing="0" cellpadding="0" style="font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Vince Harron |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Technical Lead Manager |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:vharron@google.com" target="_blank">vharron@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 858-442-0868</td></tr></tbody></table><br></div></div>
</div>