Index: tools/purge_flakies.py |
diff --git a/tools/purge_flakies.py b/tools/purge_flakies.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..a24eea0871916ee7518cb27906c69e6c48cfa3be |
--- /dev/null |
+++ b/tools/purge_flakies.py |
@@ -0,0 +1,84 @@ |
+#!/usr/bin/env python |
+ |
+ |
M-A Ruel
2011/08/19 15:07:01
Just add the copyright header there
clee
2011/08/19 16:53:57
Done.
|
+"""Usage: python %prog testname [infile] [num_tests] |
+""" |
+ |
+ |
+import os |
+import re |
+import subprocess |
+import sys |
+import time |
+ |
+ |
+def main(): |
+ test = sys.argv[1] |
+ path = "/usr/local/google/home/charleslee/chromium/src/out/Debug/" + test |
+ test_name_regex = r"(?P<testname>(\w+/)?\w+\.\w+(/\d+)?)" |
+ test_start = re.compile("\[\s+RUN\s+\] " + test_name_regex) |
+ test_list = [] |
+ if len(sys.argv) > 2: |
+ infile = sys.argv[2] |
+ data_list = open(infile, "r") |
+ for line in data_list: |
+ test_list.append(line.rstrip()) |
+ data_list.close() |
+ else: |
+ proc = subprocess.Popen([path], stdout=subprocess.PIPE) |
+ while True: |
+ line = proc.stdout.readline() |
+ if not line: |
+ if proc.poll() is not None: |
+ break |
+ continue |
+ sys.stdout.write(line) |
+ results = test_start.search(line) |
+ if results: |
+ test_list.append(results.group("testname")) |
+ failures = [] |
+ index = 0 |
+ total = len(test_list) |
+ print total |
+ if len(sys.argv) > 3: |
+ num_tests = int(sys.argv[3]) |
+ test_list = test_list[:num_tests] |
+ for test_name in test_list: |
+ num_fails = 0 |
+ num_terminated = 0 |
+ procs = [] |
+ args = [path, "--gtest_filter=" + test_name, "--gtest_repeat=10"] |
+ while len(procs) < 18: |
+ procs.append(subprocess.Popen(args)) |
+ seconds = 0 |
+ while procs: |
+ for proc in procs: |
+ if proc.poll() is not None: |
+ if proc.returncode != 0: |
+ ++num_fails |
+ procs.remove(proc) |
+ if seconds > 1000: |
+ num_fails += len(procs) |
+ num_terminated = len(procs) |
+ while procs: |
+ procs.pop().terminate() |
+ time.sleep(1) |
+ seconds += 1 |
+ if num_fails: |
+ line = "%s: %i" % (test_name, num_fails) |
+ if num_terminated: |
+ line += ", %i terminated" % num_terminated |
+ failures.append(line) |
+ print "%s (%i / %i): %i" % (test_name, index, total, num_fails) |
+ index += 1 |
+ time.sleep(1) |
+ print failures |
+ data_file = open(test + "_purges", "w") |
+ for line in failures: |
+ data_file.write(line + "\n") |
+ data_file.close() |
+ |
+ |
+if __name__ == "__main__": |
+ main() |
+ |
M-A Ruel
2011/08/19 15:07:01
remove the extra line there
clee
2011/08/19 16:53:57
Done.
|