Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 | |
|
M-A Ruel
2011/08/19 15:07:01
Just add the copyright header there
clee
2011/08/19 16:53:57
Done.
| |
| 4 """Usage: python %prog testname [infile] [num_tests] | |
| 5 """ | |
| 6 | |
| 7 | |
| 8 import os | |
| 9 import re | |
| 10 import subprocess | |
| 11 import sys | |
| 12 import time | |
| 13 | |
| 14 | |
| 15 def main(): | |
| 16 test = sys.argv[1] | |
| 17 path = "/usr/local/google/home/charleslee/chromium/src/out/Debug/" + test | |
| 18 test_name_regex = r"(?P<testname>(\w+/)?\w+\.\w+(/\d+)?)" | |
| 19 test_start = re.compile("\[\s+RUN\s+\] " + test_name_regex) | |
| 20 test_list = [] | |
| 21 if len(sys.argv) > 2: | |
| 22 infile = sys.argv[2] | |
| 23 data_list = open(infile, "r") | |
| 24 for line in data_list: | |
| 25 test_list.append(line.rstrip()) | |
| 26 data_list.close() | |
| 27 else: | |
| 28 proc = subprocess.Popen([path], stdout=subprocess.PIPE) | |
| 29 while True: | |
| 30 line = proc.stdout.readline() | |
| 31 if not line: | |
| 32 if proc.poll() is not None: | |
| 33 break | |
| 34 continue | |
| 35 sys.stdout.write(line) | |
| 36 results = test_start.search(line) | |
| 37 if results: | |
| 38 test_list.append(results.group("testname")) | |
| 39 failures = [] | |
| 40 index = 0 | |
| 41 total = len(test_list) | |
| 42 print total | |
| 43 if len(sys.argv) > 3: | |
| 44 num_tests = int(sys.argv[3]) | |
| 45 test_list = test_list[:num_tests] | |
| 46 for test_name in test_list: | |
| 47 num_fails = 0 | |
| 48 num_terminated = 0 | |
| 49 procs = [] | |
| 50 args = [path, "--gtest_filter=" + test_name, "--gtest_repeat=10"] | |
| 51 while len(procs) < 18: | |
| 52 procs.append(subprocess.Popen(args)) | |
| 53 seconds = 0 | |
| 54 while procs: | |
| 55 for proc in procs: | |
| 56 if proc.poll() is not None: | |
| 57 if proc.returncode != 0: | |
| 58 ++num_fails | |
| 59 procs.remove(proc) | |
| 60 if seconds > 1000: | |
| 61 num_fails += len(procs) | |
| 62 num_terminated = len(procs) | |
| 63 while procs: | |
| 64 procs.pop().terminate() | |
| 65 time.sleep(1) | |
| 66 seconds += 1 | |
| 67 if num_fails: | |
| 68 line = "%s: %i" % (test_name, num_fails) | |
| 69 if num_terminated: | |
| 70 line += ", %i terminated" % num_terminated | |
| 71 failures.append(line) | |
| 72 print "%s (%i / %i): %i" % (test_name, index, total, num_fails) | |
| 73 index += 1 | |
| 74 time.sleep(1) | |
| 75 print failures | |
| 76 data_file = open(test + "_purges", "w") | |
| 77 for line in failures: | |
| 78 data_file.write(line + "\n") | |
| 79 data_file.close() | |
| 80 | |
| 81 | |
| 82 if __name__ == "__main__": | |
| 83 main() | |
| 84 | |
|
M-A Ruel
2011/08/19 15:07:01
remove the extra line there
clee
2011/08/19 16:53:57
Done.
| |
| OLD | NEW |