OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 # Extra debuging information when files are claimed missing. | 137 # Extra debuging information when files are claimed missing. |
138 f = match.group(1) | 138 f = match.group(1) |
139 stderr += ">>> File %s exists? -> %s\n" % (f, os.path.exists(f)) | 139 stderr += ">>> File %s exists? -> %s\n" % (f, os.path.exists(f)) |
140 return test.id, output.Output(1, False, "", stderr), 0 | 140 return test.id, output.Output(1, False, "", stderr), 0 |
141 | 141 |
142 | 142 |
143 class TestJob(Job): | 143 class TestJob(Job): |
144 def __init__(self, test): | 144 def __init__(self, test): |
145 self.test = test | 145 self.test = test |
146 | 146 |
| 147 def _rename_coverage_data(self, output, context): |
| 148 """Rename coverage data. |
| 149 |
| 150 Rename files with PIDs to files with unique test IDs, because the number |
| 151 of tests might be higher than pid_max. E.g.: |
| 152 d8.1234.sancov -> d8.test.1.sancov, where 1234 was the process' PID |
| 153 and 1 is the test ID. |
| 154 """ |
| 155 if context.sancov_dir: |
| 156 sancov_file = os.path.join( |
| 157 context.sancov_dir, "%s.%d.sancov" % (self.test.shell(), output.pid)) |
| 158 |
| 159 # Some tests are expected to fail and don't produce coverage data. |
| 160 if os.path.exists(sancov_file): |
| 161 parts = sancov_file.split(".") |
| 162 new_sancov_file = ".".join( |
| 163 parts[:-2] + ["test", str(self.test.id)] + parts[-1:]) |
| 164 assert not os.path.exists(new_sancov_file) |
| 165 os.rename(sancov_file, new_sancov_file) |
| 166 |
147 def Run(self, process_context): | 167 def Run(self, process_context): |
148 try: | 168 try: |
149 # Retrieve a new suite object on the worker-process side. The original | 169 # Retrieve a new suite object on the worker-process side. The original |
150 # suite object isn't pickled. | 170 # suite object isn't pickled. |
151 self.test.SetSuiteObject(process_context.suites) | 171 self.test.SetSuiteObject(process_context.suites) |
152 instr = _GetInstructions(self.test, process_context.context) | 172 instr = _GetInstructions(self.test, process_context.context) |
153 except Exception, e: | 173 except Exception, e: |
154 return SetupProblem(e, self.test) | 174 return SetupProblem(e, self.test) |
155 | 175 |
156 start_time = time.time() | 176 start_time = time.time() |
157 output = commands.Execute(instr.command, instr.verbose, instr.timeout) | 177 output = commands.Execute(instr.command, instr.verbose, instr.timeout) |
| 178 self._rename_coverage_data(output, process_context.context) |
158 return (instr.id, output, time.time() - start_time) | 179 return (instr.id, output, time.time() - start_time) |
159 | 180 |
160 | 181 |
161 def RunTest(job, process_context): | 182 def RunTest(job, process_context): |
162 return job.Run(process_context) | 183 return job.Run(process_context) |
163 | 184 |
164 | 185 |
165 class Runner(object): | 186 class Runner(object): |
166 | 187 |
167 def __init__(self, suites, progress_indicator, context): | 188 def __init__(self, suites, progress_indicator, context): |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if self.context.verbose: | 385 if self.context.verbose: |
365 print text | 386 print text |
366 sys.stdout.flush() | 387 sys.stdout.flush() |
367 | 388 |
368 | 389 |
369 class BreakNowException(Exception): | 390 class BreakNowException(Exception): |
370 def __init__(self, value): | 391 def __init__(self, value): |
371 self.value = value | 392 self.value = value |
372 def __str__(self): | 393 def __str__(self): |
373 return repr(self.value) | 394 return repr(self.value) |
OLD | NEW |