Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2011 the V8 project authors. All rights reserved. | |
| 2 # Redistribution and use in source and binary forms, with or without | |
| 3 # modification, are permitted provided that the following conditions are | |
| 4 # met: | |
| 5 # | |
| 6 # * Redistributions of source code must retain the above copyright | |
| 7 # notice, this list of conditions and the following disclaimer. | |
| 8 # * Redistributions in binary form must reproduce the above | |
| 9 # copyright notice, this list of conditions and the following | |
| 10 # disclaimer in the documentation and/or other materials provided | |
| 11 # with the distribution. | |
| 12 # * Neither the name of Google Inc. nor the names of its | |
| 13 # contributors may be used to endorse or promote products derived | |
| 14 # from this software without specific prior written permission. | |
| 15 # | |
| 16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 27 | |
| 28 | |
| 29 import test | |
| 30 import os | |
| 31 from os.path import join, split | |
| 32 | |
| 33 def IsNumber(string): | |
| 34 try: | |
| 35 float(string) | |
| 36 return True | |
| 37 except ValueError: | |
| 38 return False | |
| 39 | |
| 40 | |
| 41 class BenchmarkTestCase(test.TestCase): | |
| 42 | |
| 43 def __init__(self, path, context, mode): | |
| 44 super(BenchmarkTestCase, self).__init__(context, path, mode) | |
| 45 self.root = '/'.join(self.path) | |
| 46 | |
| 47 def GetLabel(self): | |
| 48 return '%s benchmark %s' % (self.mode, self.GetName()) | |
| 49 | |
| 50 def IsFailureOutput(self, output): | |
| 51 if output.exit_code != 0: | |
| 52 return True | |
| 53 lines = output.stdout.splitlines() | |
| 54 for line in lines: | |
| 55 colon_index = line.find(':') | |
| 56 if colon_index >= 0: | |
| 57 if not IsNumber(line[colon_index+1:].strip()): | |
|
Rico
2011/03/16 08:51:57
line[colon_index+1:].strip().isdigit() ?
Mads Ager (chromium)
2011/03/16 09:44:33
I did that initially. The issue is that when runni
| |
| 58 return True | |
| 59 return False | |
| 60 | |
| 61 def GetCommand(self): | |
| 62 result = self.context.GetVmCommand(self, self.mode) | |
| 63 result.append(join(self.root, 'run.js')) | |
| 64 return result | |
| 65 | |
| 66 def GetName(self): | |
| 67 return 'V8' | |
| 68 | |
| 69 def BeforeRun(self): | |
| 70 self.dir_before = os.getcwd() | |
| 71 os.chdir(self.root) | |
| 72 | |
| 73 def AfterRun(self, result): | |
| 74 os.chdir(self.dir_before) | |
| 75 | |
| 76 def GetSource(self): | |
| 77 return open(join(self.root, 'run.js')).read() | |
| 78 | |
| 79 def GetCustomFlags(self, mode): | |
| 80 return [] | |
| 81 | |
| 82 | |
| 83 class BenchmarkTestConfiguration(test.TestConfiguration): | |
| 84 | |
| 85 def __init__(self, context, root): | |
| 86 super(BenchmarkTestConfiguration, self).__init__(context, root) | |
| 87 | |
| 88 def ListTests(self, current_path, path, mode): | |
| 89 path = self.root.split(os.path.sep)[:-2] | |
| 90 path.append('benchmarks') | |
| 91 test = BenchmarkTestCase(path, self.context, mode) | |
| 92 return [test] | |
| 93 | |
| 94 def GetBuildRequirements(self): | |
| 95 return ['sample', 'sample=shell'] | |
| 96 | |
| 97 def GetTestStatus(self, sections, defs): | |
| 98 pass | |
| 99 | |
| 100 def GetConfiguration(context, root): | |
| 101 return BenchmarkTestConfiguration(context, root) | |
| OLD | NEW |