Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: tools/testrunner/local/testsuite.py

Issue 2203013002: [test] Enable test status filtering by variant (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Clean up Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
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 imp 29 import imp
30 import os 30 import os
31 31
32 from . import commands 32 from . import commands
33 from . import statusfile 33 from . import statusfile
34 from . import utils 34 from . import utils
35 from ..objects import testcase 35 from ..objects import testcase
36 from variants import ALL_VARIANTS, ALL_VARIANT_FLAGS, FAST_VARIANT_FLAGS
36 37
37 # Use this to run several variants of the tests.
38 ALL_VARIANT_FLAGS = {
39 "default": [[]],
40 "stress": [["--stress-opt", "--always-opt"]],
41 "turbofan": [["--turbo"]],
42 "turbofan_opt": [["--turbo", "--always-opt"]],
43 "nocrankshaft": [["--nocrankshaft"]],
44 "ignition": [["--ignition"]],
45 "ignition_turbofan": [["--ignition-staging", "--turbo"]],
46 "preparser": [["--min-preparse-length=0"]],
47 }
48 38
49 # FAST_VARIANTS implies no --always-opt.
50 FAST_VARIANT_FLAGS = {
51 "default": [[]],
52 "stress": [["--stress-opt"]],
53 "turbofan": [["--turbo"]],
54 "nocrankshaft": [["--nocrankshaft"]],
55 "ignition": [["--ignition"]],
56 "ignition_turbofan": [["--ignition-staging", "--turbo"]],
57 "preparser": [["--min-preparse-length=0"]],
58 }
59
60 ALL_VARIANTS = set(["default", "stress", "turbofan", "turbofan_opt",
61 "nocrankshaft", "ignition", "ignition_turbofan",
62 "preparser"])
63 FAST_VARIANTS = set(["default", "turbofan"]) 39 FAST_VARIANTS = set(["default", "turbofan"])
64 STANDARD_VARIANT = set(["default"]) 40 STANDARD_VARIANT = set(["default"])
65 IGNITION_VARIANT = set(["ignition"]) 41 IGNITION_VARIANT = set(["ignition"])
66 42
67 43
68 class VariantGenerator(object): 44 class VariantGenerator(object):
69 def __init__(self, suite, variants): 45 def __init__(self, suite, variants):
70 self.suite = suite 46 self.suite = suite
71 self.all_variants = ALL_VARIANTS & variants 47 self.all_variants = ALL_VARIANTS & variants
72 self.fast_variants = FAST_VARIANTS & variants 48 self.fast_variants = FAST_VARIANTS & variants
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 variants: List of variant names to be run as specified by the test 122 variants: List of variant names to be run as specified by the test
147 runner. 123 runner.
148 Returns: An object of type VariantGenerator. 124 Returns: An object of type VariantGenerator.
149 """ 125 """
150 return self._VariantGeneratorFactory()(self, set(variants)) 126 return self._VariantGeneratorFactory()(self, set(variants))
151 127
152 def DownloadData(self): 128 def DownloadData(self):
153 pass 129 pass
154 130
155 def ReadStatusFile(self, variables): 131 def ReadStatusFile(self, variables):
156 (self.rules, self.wildcards) = \ 132 self.rules, self.wildcards = \
157 statusfile.ReadStatusFile(self.status_file(), variables) 133 statusfile.ReadStatusFile(self.status_file(), variables)
158 134
159 def ReadTestCases(self, context): 135 def ReadTestCases(self, context):
160 self.tests = self.ListTests(context) 136 self.tests = self.ListTests(context)
161 137
162 @staticmethod 138 @staticmethod
163 def _FilterSlow(slow, mode): 139 def _FilterSlow(slow, mode):
164 return (mode == "run" and not slow) or (mode == "skip" and slow) 140 return (mode == "run" and not slow) or (mode == "skip" and slow)
165 141
166 @staticmethod 142 @staticmethod
167 def _FilterPassFail(pass_fail, mode): 143 def _FilterPassFail(pass_fail, mode):
168 return (mode == "run" and not pass_fail) or (mode == "skip" and pass_fail) 144 return (mode == "run" and not pass_fail) or (mode == "skip" and pass_fail)
169 145
170 def FilterTestCasesByStatus(self, warn_unused_rules, 146 def FilterTestCasesByStatus(self, warn_unused_rules,
171 slow_tests="dontcare", 147 slow_tests="dontcare",
172 pass_fail_tests="dontcare"): 148 pass_fail_tests="dontcare",
149 variants=False):
150
151 # Use only variants-dependent rules and wildcards when filtering
152 # respective test cases and generic rules when filtering generic test
153 # cases.
154 if not variants:
155 rules = self.rules[""]
156 wildcards = self.wildcards[""]
157 else:
158 # We set rules and wildcards to a variant-specific version for each test
159 # below.
160 rules = {}
161 wildcards = {}
162
173 filtered = [] 163 filtered = []
164
165 # Remember used rules as tuples of (rule, variant), where variant is "" for
166 # variant-independent rules.
174 used_rules = set() 167 used_rules = set()
168
175 for t in self.tests: 169 for t in self.tests:
176 slow = False 170 slow = False
177 pass_fail = False 171 pass_fail = False
178 testname = self.CommonTestName(t) 172 testname = self.CommonTestName(t)
179 if testname in self.rules: 173 variant = t.variant or ""
180 used_rules.add(testname) 174 if variants:
175 rules = self.rules[variant]
176 wildcards = self.wildcards[variant]
177 if testname in rules:
178 used_rules.add((testname, variant))
181 # Even for skipped tests, as the TestCase object stays around and 179 # Even for skipped tests, as the TestCase object stays around and
182 # PrintReport() uses it. 180 # PrintReport() uses it.
183 t.outcomes = self.rules[testname] 181 t.outcomes = rules[testname]
184 if statusfile.DoSkip(t.outcomes): 182 if statusfile.DoSkip(t.outcomes):
185 continue # Don't add skipped tests to |filtered|. 183 continue # Don't add skipped tests to |filtered|.
186 for outcome in t.outcomes: 184 for outcome in t.outcomes:
187 if outcome.startswith('Flags: '): 185 if outcome.startswith('Flags: '):
188 t.flags += outcome[7:].split() 186 t.flags += outcome[7:].split()
189 slow = statusfile.IsSlow(t.outcomes) 187 slow = statusfile.IsSlow(t.outcomes)
190 pass_fail = statusfile.IsPassOrFail(t.outcomes) 188 pass_fail = statusfile.IsPassOrFail(t.outcomes)
191 skip = False 189 skip = False
192 for rule in self.wildcards: 190 for rule in wildcards:
193 assert rule[-1] == '*' 191 assert rule[-1] == '*'
194 if testname.startswith(rule[:-1]): 192 if testname.startswith(rule[:-1]):
195 used_rules.add(rule) 193 used_rules.add((rule, variant))
196 t.outcomes |= self.wildcards[rule] 194 t.outcomes |= wildcards[rule]
197 if statusfile.DoSkip(t.outcomes): 195 if statusfile.DoSkip(t.outcomes):
198 skip = True 196 skip = True
199 break # "for rule in self.wildcards" 197 break # "for rule in wildcards"
200 slow = slow or statusfile.IsSlow(t.outcomes) 198 slow = slow or statusfile.IsSlow(t.outcomes)
201 pass_fail = pass_fail or statusfile.IsPassOrFail(t.outcomes) 199 pass_fail = pass_fail or statusfile.IsPassOrFail(t.outcomes)
202 if (skip 200 if (skip
203 or self._FilterSlow(slow, slow_tests) 201 or self._FilterSlow(slow, slow_tests)
204 or self._FilterPassFail(pass_fail, pass_fail_tests)): 202 or self._FilterPassFail(pass_fail, pass_fail_tests)):
205 continue # "for t in self.tests" 203 continue # "for t in self.tests"
206 filtered.append(t) 204 filtered.append(t)
207 self.tests = filtered 205 self.tests = filtered
208 206
209 if not warn_unused_rules: 207 if not warn_unused_rules:
210 return 208 return
211 209
212 for rule in self.rules: 210 if not variants:
213 if rule not in used_rules: 211 for rule in self.rules[""]:
214 print("Unused rule: %s -> %s" % (rule, self.rules[rule])) 212 if (rule, "") not in used_rules:
215 for rule in self.wildcards: 213 print("Unused rule: %s -> %s (variant independent)" % (
216 if rule not in used_rules: 214 rule, self.rules[""][rule]))
217 print("Unused rule: %s -> %s" % (rule, self.wildcards[rule])) 215 for rule in self.wildcards[""]:
216 if (rule, "") not in used_rules:
217 print("Unused rule: %s -> %s (variant independent)" % (
218 rule, self.wildcards[""][rule]))
219 else:
220 for variant in ALL_VARIANTS:
221 for rule in self.rules[variant]:
222 if (rule, variant) not in used_rules:
223 print("Unused rule: %s -> %s (variant: %s)" % (
224 rule, self.rules[variant][rule], variant))
225 for rule in self.wildcards[variant]:
226 if (rule, variant) not in used_rules:
227 print("Unused rule: %s -> %s (variant: %s)" % (
228 rule, self.wildcards[variant][rule], variant))
229
218 230
219 def FilterTestCasesByArgs(self, args): 231 def FilterTestCasesByArgs(self, args):
220 """Filter test cases based on command-line arguments. 232 """Filter test cases based on command-line arguments.
221 233
222 An argument with an asterisk in the end will match all test cases 234 An argument with an asterisk in the end will match all test cases
223 that have the argument as a prefix. Without asterisk, only exact matches 235 that have the argument as a prefix. Without asterisk, only exact matches
224 will be used with the exeption of the test-suite name as argument. 236 will be used with the exeption of the test-suite name as argument.
225 """ 237 """
226 filtered = [] 238 filtered = []
227 globs = [] 239 globs = []
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return (testcase.flags + ["--gtest_filter=" + testcase.path] + 342 return (testcase.flags + ["--gtest_filter=" + testcase.path] +
331 ["--gtest_random_seed=%s" % context.random_seed] + 343 ["--gtest_random_seed=%s" % context.random_seed] +
332 ["--gtest_print_time=0"] + 344 ["--gtest_print_time=0"] +
333 context.mode_flags) 345 context.mode_flags)
334 346
335 def _VariantGeneratorFactory(self): 347 def _VariantGeneratorFactory(self):
336 return StandardVariantGenerator 348 return StandardVariantGenerator
337 349
338 def shell(self): 350 def shell(self):
339 return self.name 351 return self.name
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698