<div dir="ltr">Looks ok, did you get a chance to run on Windows to verify that it still works?<br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, May 31, 2015 at 9:30 PM Chaoren Lin <<a href="mailto:chaorenl@google.com">chaorenl@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">- Accidentally printed stdout again instead of stderr.<br>
- Passing lock and counter by argument to work on Windows.<br>
<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10143&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=9GSZML-c2ZQwYe9xEzMIJAlNbfXbrwAg0JYCdF1MOz4&s=5Yfcc51tuhhHMWJv23PQPHHdW8glQMd-nj_zE5jU19s&e=" target="_blank">http://reviews.llvm.org/D10143</a><br>
<br>
Files:<br>
test/dosep.py<br>
<br>
Index: test/dosep.py<br>
===================================================================<br>
--- test/dosep.py<br>
+++ test/dosep.py<br>
@@ -66,6 +66,28 @@<br>
# Status codes for running command with timeout.<br>
eTimedOut, ePassed, eFailed = 124, 0, 1<br>
<br>
+output_lock = None<br>
+test_counter = None<br>
+total_tests = None<br>
+<br>
+def setup_lock_and_counter(lock, counter, total):<br>
+ global output_lock, test_counter, total_tests<br>
+ output_lock = lock<br>
+ test_counter = counter<br>
+ total_tests = total<br>
+<br>
+def update_status(name = None, output = None):<br>
+ global output_lock, test_counter, total_tests<br>
+ with output_lock:<br>
+ if output is not None:<br>
+ print >> sys.stderr<br>
+ print >> sys.stderr, 'Test suite %s failed' % name<br>
+ print >> sys.stderr, 'stdout:\n' + output[0]<br>
+ print >> sys.stderr, 'stderr:\n' + output[1]<br>
+ sys.stderr.write("\r%*d out of %d test suites processed" %<br>
+ (len(str(total_tests)), test_counter.value, total_tests))<br>
+ test_counter.value += 1<br>
+<br>
def parse_test_results(output):<br>
passes = 0<br>
failures = 0<br>
@@ -84,7 +106,7 @@<br>
pass<br>
return passes, failures<br>
<br>
-def call_with_timeout(command, timeout):<br>
+def call_with_timeout(command, timeout, name):<br>
"""Run command with a timeout if possible."""<br>
"""-s QUIT will create a coredump if they are enabled on your system"""<br>
process = None<br>
@@ -103,6 +125,7 @@<br>
output = process.communicate()<br>
exit_status = process.returncode<br>
passes, failures = parse_test_results(output)<br>
+ update_status(name, output if failures > 0 else None)<br>
return exit_status, passes, failures<br>
<br>
def process_dir(root, files, test_root, dotest_argv):<br>
@@ -132,7 +155,7 @@<br>
<br>
timeout = os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or default_timeout<br>
<br>
- exit_status, pass_count, fail_count = call_with_timeout(command, timeout)<br>
+ exit_status, pass_count, fail_count = call_with_timeout(command, timeout, name)<br>
<br>
pass_sub_count = pass_sub_count + pass_count<br>
fail_sub_count = fail_sub_count + fail_count<br>
@@ -169,10 +192,19 @@<br>
for root, dirs, files in os.walk(test_subdir, topdown=False):<br>
test_work_items.append((root, files, test_directory, dotest_argv))<br>
<br>
+ global output_lock, test_counter, total_tests<br>
+ output_lock = multiprocessing.Lock()<br>
+ total_tests = len(test_work_items)<br>
+ test_counter = multiprocessing.Value('i', 0)<br>
+ print >> sys.stderr, "Testing: %d tests, %d threads" % (total_tests, num_threads)<br>
+ update_status()<br>
+<br>
# Run the items, either in a pool (for multicore speedup) or<br>
# calling each individually.<br>
if num_threads > 1:<br>
- pool = multiprocessing.Pool(num_threads)<br>
+ pool = multiprocessing.Pool(num_threads,<br>
+ initializer = setup_lock_and_counter,<br>
+ initargs = (output_lock, test_counter, total_tests))<br>
test_results = pool.map(process_dir_worker, test_work_items)<br>
else:<br>
test_results = []<br>
@@ -355,6 +387,7 @@<br>
test_name = os.path.splitext(xtime)[0]<br>
touch(os.path.join(session_dir, "{}-{}".format(result, test_name)))<br>
<br>
+ print<br>
print "Ran %d test suites (%d failed) (%f%%)" % (num_test_files, len(failed), 100.0*len(failed)/num_test_files)<br>
print "Ran %d test cases (%d failed) (%f%%)" % (num_tests, all_fails, 100.0*all_fails/num_tests)<br>
if len(failed) > 0:<br>
<br>
EMAIL PREFERENCES<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_settings_panel_emailpreferences_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MEqT8U_n7oNfuDW5NRbY3ZV384ZquXIYFPWmprwUdKM&m=9GSZML-c2ZQwYe9xEzMIJAlNbfXbrwAg0JYCdF1MOz4&s=PAeIaXkKCy_ucBGIoNg5sdkwZEbs24L2qe3CjJZNEW8&e=" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</blockquote></div>