OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Traces each test cases of a google-test executable individually. | 6 """Traces each test cases of a google-test executable individually. |
7 | 7 |
8 Gives detailed information about each test case. The logs can be read afterward | 8 Gives detailed information about each test case. The logs can be read afterward |
9 with ./trace_inputs.py read -l /path/to/executable.logs | 9 with ./trace_inputs.py read -l /path/to/executable.logs |
10 """ | 10 """ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 'tracename': tracename, | 60 'tracename': tracename, |
61 'returncode': returncode, | 61 'returncode': returncode, |
62 'duration': duration, | 62 'duration': duration, |
63 'valid': valid, | 63 'valid': valid, |
64 'output': output, | 64 'output': output, |
65 }) | 65 }) |
66 logging.debug( | 66 logging.debug( |
67 'Tracing %s done: %d, %.1fs' % (test_case, returncode, duration)) | 67 'Tracing %s done: %d, %.1fs' % (test_case, returncode, duration)) |
68 if retry: | 68 if retry: |
69 self.progress.update_item( | 69 self.progress.update_item( |
70 '%s - %d' % (test_case, retry), index=1, size=int(not valid)) | 70 '%s - %d' % (test_case, retry), col0=1, col1=int(not valid)) |
71 else: | 71 else: |
72 self.progress.update_item(test_case, index=1, size=int(not valid)) | 72 self.progress.update_item(test_case, col0=1, col1=int(not valid)) |
73 if valid: | 73 if valid: |
74 break | 74 break |
75 return out | 75 return out |
76 | 76 |
77 | 77 |
78 def trace_test_cases(cmd, cwd_dir, test_cases, jobs, logname): | 78 def trace_test_cases(cmd, cwd_dir, test_cases, jobs, logname): |
79 """Traces each test cases individually but all in parallel.""" | 79 """Traces each test cases individually but all in parallel.""" |
80 assert os.path.isabs(cwd_dir) and os.path.isdir(cwd_dir), cwd_dir | 80 assert os.path.isabs(cwd_dir) and os.path.isdir(cwd_dir), cwd_dir |
81 | 81 |
82 if not test_cases: | 82 if not test_cases: |
(...skipping 10 matching lines...) Expand all Loading... |
93 # Try to do black magic here by guessing a few of the run_test_cases.py | 93 # Try to do black magic here by guessing a few of the run_test_cases.py |
94 # flags. It's cheezy but it works. | 94 # flags. It's cheezy but it works. |
95 for i, v in enumerate(cmd): | 95 for i, v in enumerate(cmd): |
96 if v.endswith('run_test_cases.py'): | 96 if v.endswith('run_test_cases.py'): |
97 # Found it. Process the arguments here. | 97 # Found it. Process the arguments here. |
98 _, options, _ = run_test_cases.process_args(cmd[i:]) | 98 _, options, _ = run_test_cases.process_args(cmd[i:]) |
99 # Always override with the lowest value. | 99 # Always override with the lowest value. |
100 jobs = min(options.jobs, jobs) | 100 jobs = min(options.jobs, jobs) |
101 break | 101 break |
102 | 102 |
103 progress = threading_utils.Progress(len(test_cases)) | 103 progress = threading_utils.Progress([0, len(test_cases)]) |
104 with threading_utils.ThreadPoolWithProgress( | 104 with threading_utils.ThreadPoolWithProgress( |
105 progress, jobs, jobs, len(test_cases)) as pool: | 105 progress, jobs, jobs, len(test_cases)) as pool: |
106 with api.get_tracer(logname) as tracer: | 106 with api.get_tracer(logname) as tracer: |
107 function = Tracer(tracer, cmd, cwd_dir, progress).map | 107 function = Tracer(tracer, cmd, cwd_dir, progress).map |
108 for test_case in test_cases: | 108 for test_case in test_cases: |
109 pool.add_task(0, function, test_case) | 109 pool.add_task(0, function, test_case) |
110 | 110 |
111 results = pool.join() | 111 results = pool.join() |
112 print('') | 112 print('') |
113 return results | 113 return results |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 options.jobs, | 197 options.jobs, |
198 logname) | 198 logname) |
199 print('Reading trace logs...') | 199 print('Reading trace logs...') |
200 blacklist = trace_inputs.gen_blacklist(options.trace_blacklist) | 200 blacklist = trace_inputs.gen_blacklist(options.trace_blacklist) |
201 write_details(logname, options.out, options.root_dir, blacklist, results) | 201 write_details(logname, options.out, options.root_dir, blacklist, results) |
202 return 0 | 202 return 0 |
203 | 203 |
204 | 204 |
205 if __name__ == '__main__': | 205 if __name__ == '__main__': |
206 sys.exit(main()) | 206 sys.exit(main()) |
OLD | NEW |