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 GetSuite(name, root): | |
34 # Not implemented. | |
35 return None | |
36 | |
37 | |
38 def IsNumber(string): | |
39 try: | |
40 float(string) | |
41 return True | |
42 except ValueError: | |
43 return False | |
44 | |
45 | |
46 class BenchmarkTestCase(test.TestCase): | |
47 | |
48 def __init__(self, path, context, mode): | |
49 super(BenchmarkTestCase, self).__init__(context, split(path), mode) | |
50 self.root = path | |
51 | |
52 def GetLabel(self): | |
53 return '%s benchmark %s' % (self.mode, self.GetName()) | |
54 | |
55 def IsFailureOutput(self, output): | |
56 if output.exit_code != 0: | |
57 return True | |
58 lines = output.stdout.splitlines() | |
59 for line in lines: | |
60 colon_index = line.find(':') | |
61 if colon_index >= 0: | |
62 if not IsNumber(line[colon_index+1:].strip()): | |
63 return True | |
64 return False | |
65 | |
66 def GetCommand(self): | |
67 result = self.context.GetVmCommand(self, self.mode) | |
68 result.append(join(self.root, 'run.js')) | |
69 return result | |
70 | |
71 def GetName(self): | |
72 return 'V8' | |
73 | |
74 def BeforeRun(self): | |
75 os.chdir(self.root) | |
76 | |
77 def AfterRun(self, result): | |
78 os.chdir(self.context.buildspace) | |
79 | |
80 def GetSource(self): | |
81 return open(join(self.root, 'run.js')).read() | |
82 | |
83 def GetCustomFlags(self, mode): | |
84 return [] | |
85 | |
86 | |
87 class BenchmarkTestConfiguration(test.TestConfiguration): | |
88 | |
89 def __init__(self, context, root): | |
90 super(BenchmarkTestConfiguration, self).__init__(context, root) | |
91 | |
92 def ListTests(self, current_path, path, mode, variant_flags): | |
93 path = self.context.workspace | |
94 path = join(path, 'benchmarks') | |
95 test = BenchmarkTestCase(path, self.context, mode) | |
96 return [test] | |
97 | |
98 def GetBuildRequirements(self): | |
99 return ['d8'] | |
100 | |
101 def GetTestStatus(self, sections, defs): | |
102 pass | |
103 | |
104 def GetConfiguration(context, root): | |
105 return BenchmarkTestConfiguration(context, root) | |
OLD | NEW |