| 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 17 matching lines...) Expand all Loading... |
| 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 | 36 |
| 37 # Use this to run several variants of the tests. | 37 # Use this to run several variants of the tests. |
| 38 VARIANT_FLAGS = { | 38 ALL_VARIANT_FLAGS = { |
| 39 "default": [], | 39 "default": [[]], |
| 40 "stress": ["--stress-opt", "--always-opt"], | 40 "stress": [["--stress-opt", "--always-opt"]], |
| 41 "turbofan": ["--turbo", "--always-opt"], | 41 "turbofan": [["--turbo", "--always-opt"]], |
| 42 "nocrankshaft": ["--nocrankshaft"]} | 42 "nocrankshaft": [["--nocrankshaft"]], |
| 43 } |
| 43 | 44 |
| 44 FAST_VARIANT_FLAGS = [ | 45 # FAST_VARIANTS implies no --always-opt. |
| 45 f for v, f in VARIANT_FLAGS.iteritems() if v in ["default", "turbofan"] | 46 FAST_VARIANT_FLAGS = { |
| 46 ] | 47 "default": [[]], |
| 48 "stress": [["--stress-opt"]], |
| 49 "turbofan": [["--turbo"]], |
| 50 "nocrankshaft": [["--nocrankshaft"]], |
| 51 } |
| 52 |
| 53 ALL_VARIANTS = set(["default", "stress", "turbofan", "nocrankshaft"]) |
| 54 FAST_VARIANTS = set(["default", "turbofan"]) |
| 55 STANDARD_VARIANT = set(["default"]) |
| 56 |
| 57 |
| 58 class VariantGenerator(object): |
| 59 def __init__(self, suite, variants): |
| 60 self.suite = suite |
| 61 self.all_variants = ALL_VARIANTS & variants |
| 62 self.fast_variants = FAST_VARIANTS & variants |
| 63 self.standard_variant = STANDARD_VARIANT & variants |
| 64 |
| 65 def FilterVariantsByTest(self, testcase): |
| 66 if testcase.outcomes and statusfile.OnlyStandardVariant( |
| 67 testcase.outcomes): |
| 68 return self.standard_variant |
| 69 if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes): |
| 70 return self.fast_variants |
| 71 return self.all_variants |
| 72 |
| 73 def GetFlagSets(self, testcase, variant): |
| 74 if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes): |
| 75 return FAST_VARIANT_FLAGS[variant] |
| 76 else: |
| 77 return ALL_VARIANT_FLAGS[variant] |
| 78 |
| 47 | 79 |
| 48 class TestSuite(object): | 80 class TestSuite(object): |
| 49 | 81 |
| 50 @staticmethod | 82 @staticmethod |
| 51 def LoadTestSuite(root): | 83 def LoadTestSuite(root): |
| 52 name = root.split(os.path.sep)[-1] | 84 name = root.split(os.path.sep)[-1] |
| 53 f = None | 85 f = None |
| 54 try: | 86 try: |
| 55 (f, pathname, description) = imp.find_module("testcfg", [root]) | 87 (f, pathname, description) = imp.find_module("testcfg", [root]) |
| 56 module = imp.load_module("testcfg", f, pathname, description) | 88 module = imp.load_module("testcfg", f, pathname, description) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 82 # Used in the status file and for stdout printing. | 114 # Used in the status file and for stdout printing. |
| 83 def CommonTestName(self, testcase): | 115 def CommonTestName(self, testcase): |
| 84 if utils.IsWindows(): | 116 if utils.IsWindows(): |
| 85 return testcase.path.replace("\\", "/") | 117 return testcase.path.replace("\\", "/") |
| 86 else: | 118 else: |
| 87 return testcase.path | 119 return testcase.path |
| 88 | 120 |
| 89 def ListTests(self, context): | 121 def ListTests(self, context): |
| 90 raise NotImplementedError | 122 raise NotImplementedError |
| 91 | 123 |
| 92 def VariantFlags(self, testcase, default_flags): | 124 def _VariantGeneratorFactory(self): |
| 93 if testcase.outcomes and statusfile.OnlyStandardVariant(testcase.outcomes): | 125 """The variant generator class to be used.""" |
| 94 return [[]] | 126 return VariantGenerator |
| 95 if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes): | 127 |
| 96 # FAST_VARIANTS implies no --always-opt. | 128 def CreateVariantGenerator(self, variants): |
| 97 return [ filter(lambda flag: flag != "--always-opt", f) | 129 """Return a generator for the testing variants of this suite. |
| 98 for f in filter(lambda flags: flags in FAST_VARIANT_FLAGS, | 130 |
| 99 default_flags) ] | 131 Args: |
| 100 return default_flags | 132 variants: List of variant names to be run as specified by the test |
| 133 runner. |
| 134 Returns: An object of type VariantGenerator. |
| 135 """ |
| 136 return self._VariantGeneratorFactory()(self, set(variants)) |
| 101 | 137 |
| 102 def DownloadData(self): | 138 def DownloadData(self): |
| 103 pass | 139 pass |
| 104 | 140 |
| 105 def ReadStatusFile(self, variables): | 141 def ReadStatusFile(self, variables): |
| 106 (self.rules, self.wildcards) = \ | 142 (self.rules, self.wildcards) = \ |
| 107 statusfile.ReadStatusFile(self.status_file(), variables) | 143 statusfile.ReadStatusFile(self.status_file(), variables) |
| 108 | 144 |
| 109 def ReadTestCases(self, context): | 145 def ReadTestCases(self, context): |
| 110 self.tests = self.ListTests(context) | 146 self.tests = self.ListTests(context) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 testcase.output.stdout = "" | 281 testcase.output.stdout = "" |
| 246 testcase.output.stderr = "" | 282 testcase.output.stderr = "" |
| 247 | 283 |
| 248 def CalculateTotalDuration(self): | 284 def CalculateTotalDuration(self): |
| 249 self.total_duration = 0.0 | 285 self.total_duration = 0.0 |
| 250 for t in self.tests: | 286 for t in self.tests: |
| 251 self.total_duration += t.duration | 287 self.total_duration += t.duration |
| 252 return self.total_duration | 288 return self.total_duration |
| 253 | 289 |
| 254 | 290 |
| 291 class StandardVariantGenerator(VariantGenerator): |
| 292 def FilterVariantsByTest(self, testcase): |
| 293 return self.standard_variant |
| 294 |
| 295 |
| 255 class GoogleTestSuite(TestSuite): | 296 class GoogleTestSuite(TestSuite): |
| 256 def __init__(self, name, root): | 297 def __init__(self, name, root): |
| 257 super(GoogleTestSuite, self).__init__(name, root) | 298 super(GoogleTestSuite, self).__init__(name, root) |
| 258 | 299 |
| 259 def ListTests(self, context): | 300 def ListTests(self, context): |
| 260 shell = os.path.abspath(os.path.join(context.shell_dir, self.shell())) | 301 shell = os.path.abspath(os.path.join(context.shell_dir, self.shell())) |
| 261 if utils.IsWindows(): | 302 if utils.IsWindows(): |
| 262 shell += ".exe" | 303 shell += ".exe" |
| 263 output = commands.Execute(context.command_prefix + | 304 output = commands.Execute(context.command_prefix + |
| 264 [shell, "--gtest_list_tests"] + | 305 [shell, "--gtest_list_tests"] + |
| (...skipping 13 matching lines...) Expand all Loading... |
| 278 tests.append(test) | 319 tests.append(test) |
| 279 tests.sort() | 320 tests.sort() |
| 280 return tests | 321 return tests |
| 281 | 322 |
| 282 def GetFlagsForTestCase(self, testcase, context): | 323 def GetFlagsForTestCase(self, testcase, context): |
| 283 return (testcase.flags + ["--gtest_filter=" + testcase.path] + | 324 return (testcase.flags + ["--gtest_filter=" + testcase.path] + |
| 284 ["--gtest_random_seed=%s" % context.random_seed] + | 325 ["--gtest_random_seed=%s" % context.random_seed] + |
| 285 ["--gtest_print_time=0"] + | 326 ["--gtest_print_time=0"] + |
| 286 context.mode_flags) | 327 context.mode_flags) |
| 287 | 328 |
| 288 def VariantFlags(self, testcase, default_flags): | 329 def _VariantGeneratorFactory(self): |
| 289 return [[]] | 330 return StandardVariantGenerator |
| 290 | 331 |
| 291 def shell(self): | 332 def shell(self): |
| 292 return self.name | 333 return self.name |
| OLD | NEW |