| 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 |
| 11 # with the distribution. | 11 # with the distribution. |
| 12 # * Neither the name of Google Inc. nor the names of its | 12 # * Neither the name of Google Inc. nor the names of its |
| 13 # contributors may be used to endorse or promote products derived | 13 # contributors may be used to endorse or promote products derived |
| 14 # from this software without specific prior written permission. | 14 # from this software without specific prior written permission. |
| 15 # | 15 # |
| 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 |
| 29 import os | 29 import os |
| 30 import shutil |
| 30 import time | 31 import time |
| 31 | 32 |
| 32 from pool import Pool | 33 from pool import Pool |
| 33 from . import commands | 34 from . import commands |
| 34 from . import perfdata | 35 from . import perfdata |
| 35 from . import utils | 36 from . import utils |
| 36 | 37 |
| 37 | 38 |
| 38 class Job(object): | 39 class Job(object): |
| 39 def __init__(self, command, dep_command, test_id, timeout, verbose): | 40 def __init__(self, command, dep_command, test_id, timeout, verbose): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 53 # only cctests define dependencies, for which this simplification is | 54 # only cctests define dependencies, for which this simplification is |
| 54 # correct. | 55 # correct. |
| 55 if dep_output.exit_code != 0: | 56 if dep_output.exit_code != 0: |
| 56 return (job.id, dep_output, time.time() - start_time) | 57 return (job.id, dep_output, time.time() - start_time) |
| 57 output = commands.Execute(job.command, job.verbose, job.timeout) | 58 output = commands.Execute(job.command, job.verbose, job.timeout) |
| 58 return (job.id, output, time.time() - start_time) | 59 return (job.id, output, time.time() - start_time) |
| 59 | 60 |
| 60 class Runner(object): | 61 class Runner(object): |
| 61 | 62 |
| 62 def __init__(self, suites, progress_indicator, context): | 63 def __init__(self, suites, progress_indicator, context): |
| 63 datapath = os.path.join("out", "testrunner_data") | 64 self.datapath = os.path.join("out", "testrunner_data") |
| 64 self.perf_data_manager = perfdata.PerfDataManager(datapath) | 65 self.perf_data_manager = perfdata.PerfDataManager(self.datapath) |
| 65 self.perfdata = self.perf_data_manager.GetStore(context.arch, context.mode) | 66 self.perfdata = self.perf_data_manager.GetStore(context.arch, context.mode) |
| 67 self.perf_failures = False |
| 66 self.tests = [ t for s in suites for t in s.tests ] | 68 self.tests = [ t for s in suites for t in s.tests ] |
| 67 if not context.no_sorting: | 69 if not context.no_sorting: |
| 68 for t in self.tests: | 70 for t in self.tests: |
| 69 t.duration = self.perfdata.FetchPerfData(t) or 1.0 | 71 t.duration = self.perfdata.FetchPerfData(t) or 1.0 |
| 70 self.tests.sort(key=lambda t: t.duration, reverse=True) | 72 self.tests.sort(key=lambda t: t.duration, reverse=True) |
| 71 self._CommonInit(len(self.tests), progress_indicator, context) | 73 self._CommonInit(len(self.tests), progress_indicator, context) |
| 72 | 74 |
| 73 def _CommonInit(self, num_tests, progress_indicator, context): | 75 def _CommonInit(self, num_tests, progress_indicator, context): |
| 74 self.indicator = progress_indicator | 76 self.indicator = progress_indicator |
| 75 progress_indicator.runner = self | 77 progress_indicator.runner = self |
| 76 self.context = context | 78 self.context = context |
| 77 self.succeeded = 0 | 79 self.succeeded = 0 |
| 78 self.total = num_tests | 80 self.total = num_tests |
| 79 self.remaining = num_tests | 81 self.remaining = num_tests |
| 80 self.failed = [] | 82 self.failed = [] |
| 81 self.crashed = 0 | 83 self.crashed = 0 |
| 82 | 84 |
| 85 def _RunPerfSafe(self, fun): |
| 86 try: |
| 87 fun() |
| 88 except Exception, e: |
| 89 print("PerfData exception: %s" % e) |
| 90 self.perf_failures = True |
| 91 |
| 83 def Run(self, jobs): | 92 def Run(self, jobs): |
| 84 self.indicator.Starting() | 93 self.indicator.Starting() |
| 85 self._RunInternal(jobs) | 94 self._RunInternal(jobs) |
| 86 self.indicator.Done() | 95 self.indicator.Done() |
| 87 if self.failed or self.remaining: | 96 if self.failed or self.remaining: |
| 88 return 1 | 97 return 1 |
| 89 return 0 | 98 return 0 |
| 90 | 99 |
| 91 def _RunInternal(self, jobs): | 100 def _RunInternal(self, jobs): |
| 92 pool = Pool(jobs) | 101 pool = Pool(jobs) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 123 test = test_map[result[0]] | 132 test = test_map[result[0]] |
| 124 self.indicator.AboutToRun(test) | 133 self.indicator.AboutToRun(test) |
| 125 test.output = result[1] | 134 test.output = result[1] |
| 126 test.duration = result[2] | 135 test.duration = result[2] |
| 127 has_unexpected_output = test.suite.HasUnexpectedOutput(test) | 136 has_unexpected_output = test.suite.HasUnexpectedOutput(test) |
| 128 if has_unexpected_output: | 137 if has_unexpected_output: |
| 129 self.failed.append(test) | 138 self.failed.append(test) |
| 130 if test.output.HasCrashed(): | 139 if test.output.HasCrashed(): |
| 131 self.crashed += 1 | 140 self.crashed += 1 |
| 132 else: | 141 else: |
| 142 self._RunPerfSafe(lambda: self.perfdata.UpdatePerfData(test)) |
| 133 self.succeeded += 1 | 143 self.succeeded += 1 |
| 134 self.remaining -= 1 | 144 self.remaining -= 1 |
| 135 try: | |
| 136 self.perfdata.UpdatePerfData(test) | |
| 137 except Exception, e: | |
| 138 print("UpdatePerfData exception: %s" % e) | |
| 139 pass # Just keep working. | |
| 140 self.indicator.HasRun(test, has_unexpected_output) | 145 self.indicator.HasRun(test, has_unexpected_output) |
| 141 finally: | 146 finally: |
| 142 pool.terminate() | 147 pool.terminate() |
| 143 self.perf_data_manager.close() | 148 self._RunPerfSafe(lambda: self.perf_data_manager.close()) |
| 149 if self.perf_failures: |
| 150 # Nuke perf data in case of failures. This might not work on windows as |
| 151 # some files might still be open. |
| 152 print "Deleting perf test data due to db corruption." |
| 153 shutil.rmtree(self.datapath) |
| 144 if queued_exception: | 154 if queued_exception: |
| 145 raise queued_exception | 155 raise queued_exception |
| 146 | 156 |
| 147 | 157 |
| 148 def GetCommand(self, test): | 158 def GetCommand(self, test): |
| 149 d8testflag = [] | 159 d8testflag = [] |
| 150 shell = test.suite.shell() | 160 shell = test.suite.shell() |
| 151 if shell == "d8": | 161 if shell == "d8": |
| 152 d8testflag = ["--test"] | 162 d8testflag = ["--test"] |
| 153 if utils.IsWindows(): | 163 if utils.IsWindows(): |
| 154 shell += ".exe" | 164 shell += ".exe" |
| 155 cmd = (self.context.command_prefix + | 165 cmd = (self.context.command_prefix + |
| 156 [os.path.abspath(os.path.join(self.context.shell_dir, shell))] + | 166 [os.path.abspath(os.path.join(self.context.shell_dir, shell))] + |
| 157 d8testflag + | 167 d8testflag + |
| 158 ["--random-seed=%s" % self.context.random_seed] + | 168 ["--random-seed=%s" % self.context.random_seed] + |
| 159 test.suite.GetFlagsForTestCase(test, self.context) + | 169 test.suite.GetFlagsForTestCase(test, self.context) + |
| 160 self.context.extra_flags) | 170 self.context.extra_flags) |
| 161 return cmd | 171 return cmd |
| 162 | 172 |
| 163 | 173 |
| 164 class BreakNowException(Exception): | 174 class BreakNowException(Exception): |
| 165 def __init__(self, value): | 175 def __init__(self, value): |
| 166 self.value = value | 176 self.value = value |
| 167 def __str__(self): | 177 def __str__(self): |
| 168 return repr(self.value) | 178 return repr(self.value) |
| OLD | NEW |