OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Expand all Loading... |
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 | 30 |
| 31 import json |
| 32 import math |
31 import multiprocessing | 33 import multiprocessing |
32 import optparse | 34 import optparse |
33 import os | 35 import os |
34 from os.path import join | 36 from os.path import join |
| 37 import random |
35 import shlex | 38 import shlex |
36 import subprocess | 39 import subprocess |
37 import sys | 40 import sys |
38 import time | 41 import time |
39 | 42 |
40 from testrunner.local import execution | 43 from testrunner.local import execution |
41 from testrunner.local import progress | 44 from testrunner.local import progress |
42 from testrunner.local import testsuite | 45 from testrunner.local import testsuite |
43 from testrunner.local import utils | 46 from testrunner.local import utils |
44 from testrunner.local import verbose | 47 from testrunner.local import verbose |
45 from testrunner.network import network_execution | |
46 from testrunner.objects import context | 48 from testrunner.objects import context |
47 | 49 |
48 | 50 |
49 ARCH_GUESS = utils.DefaultArch() | 51 ARCH_GUESS = utils.DefaultArch() |
50 DEFAULT_TESTS = ["mjsunit", "cctest", "message", "preparser"] | 52 DEFAULT_TESTS = ["mjsunit", "webkit"] |
51 TIMEOUT_DEFAULT = 60 | 53 TIMEOUT_DEFAULT = 60 |
52 TIMEOUT_SCALEFACTOR = {"debug" : 4, | 54 TIMEOUT_SCALEFACTOR = {"debug" : 4, |
53 "release" : 1 } | 55 "release" : 1 } |
54 | 56 |
55 # Use this to run several variants of the tests. | |
56 VARIANT_FLAGS = [[], | |
57 ["--stress-opt", "--always-opt"], | |
58 ["--nocrankshaft"]] | |
59 MODE_FLAGS = { | 57 MODE_FLAGS = { |
60 "debug" : ["--nobreak-on-abort", "--nodead-code-elimination", | 58 "debug" : ["--nobreak-on-abort", "--nodead-code-elimination", |
61 "--nofold-constants", "--enable-slow-asserts", | 59 "--nofold-constants", "--enable-slow-asserts", |
62 "--debug-code", "--verify-heap"], | 60 "--debug-code", "--verify-heap", |
| 61 "--noparallel-recompilation"], |
63 "release" : ["--nobreak-on-abort", "--nodead-code-elimination", | 62 "release" : ["--nobreak-on-abort", "--nodead-code-elimination", |
64 "--nofold-constants"]} | 63 "--nofold-constants", "--noparallel-recompilation"]} |
65 | 64 |
66 SUPPORTED_ARCHS = ["android_arm", | 65 SUPPORTED_ARCHS = ["android_arm", |
67 "android_ia32", | 66 "android_ia32", |
68 "arm", | 67 "arm", |
69 "ia32", | 68 "ia32", |
70 "mipsel", | 69 "mipsel", |
71 "nacl_ia32", | 70 "nacl_ia32", |
72 "nacl_x64", | 71 "nacl_x64", |
73 "x64", | 72 "x64"] |
74 "a64"] | |
75 # Double the timeout for these: | 73 # Double the timeout for these: |
76 SLOW_ARCHS = ["android_arm", | 74 SLOW_ARCHS = ["android_arm", |
77 "android_ia32", | 75 "android_ia32", |
78 "arm", | 76 "arm", |
79 "mipsel", | 77 "mipsel", |
80 "nacl_ia32", | 78 "nacl_ia32", |
81 "nacl_x64", | 79 "nacl_x64"] |
82 "a64"] | 80 MAX_DEOPT = 1000000000 |
| 81 DISTRIBUTION_MODES = ["smooth", "random"] |
| 82 |
| 83 |
| 84 class RandomDistribution: |
| 85 def __init__(self, seed=None): |
| 86 seed = seed or random.randint(1, sys.maxint) |
| 87 print "Using random distribution with seed %d" % seed |
| 88 self._random = random.Random(seed) |
| 89 |
| 90 def Distribute(self, n, m): |
| 91 if n > m: |
| 92 n = m |
| 93 return self._random.sample(xrange(1, m + 1), n) |
| 94 |
| 95 |
| 96 class SmoothDistribution: |
| 97 """Distribute n numbers into the interval [1:m]. |
| 98 F1: Factor of the first derivation of the distribution function. |
| 99 F2: Factor of the second derivation of the distribution function. |
| 100 With F1 and F2 set to 0, the distribution will be equal. |
| 101 """ |
| 102 def __init__(self, factor1=2.0, factor2=0.2): |
| 103 self._factor1 = factor1 |
| 104 self._factor2 = factor2 |
| 105 |
| 106 def Distribute(self, n, m): |
| 107 if n > m: |
| 108 n = m |
| 109 if n <= 1: |
| 110 return [ 1 ] |
| 111 |
| 112 result = [] |
| 113 x = 0.0 |
| 114 dx = 1.0 |
| 115 ddx = self._factor1 |
| 116 dddx = self._factor2 |
| 117 for i in range(0, n): |
| 118 result += [ x ] |
| 119 x += dx |
| 120 dx += ddx |
| 121 ddx += dddx |
| 122 |
| 123 # Project the distribution into the interval [0:M]. |
| 124 result = [ x * m / result[-1] for x in result ] |
| 125 |
| 126 # Equalize by n. The closer n is to m, the more equal will be the |
| 127 # distribution. |
| 128 for (i, x) in enumerate(result): |
| 129 # The value of x if it was equally distributed. |
| 130 equal_x = i / float(n - 1) * float(m - 1) + 1 |
| 131 |
| 132 # Difference factor between actual and equal distribution. |
| 133 diff = 1 - (x / equal_x) |
| 134 |
| 135 # Equalize x dependent on the number of values to distribute. |
| 136 result[i] = int(x + (i + 1) * diff) |
| 137 return result |
| 138 |
| 139 |
| 140 def Distribution(options): |
| 141 if options.distribution_mode == "random": |
| 142 return RandomDistribution(options.seed) |
| 143 if options.distribution_mode == "smooth": |
| 144 return SmoothDistribution(options.distribution_factor1, |
| 145 options.distribution_factor2) |
83 | 146 |
84 | 147 |
85 def BuildOptions(): | 148 def BuildOptions(): |
86 result = optparse.OptionParser() | 149 result = optparse.OptionParser() |
87 result.add_option("--arch", | 150 result.add_option("--arch", |
88 help=("The architecture to run tests for, " | 151 help=("The architecture to run tests for, " |
89 "'auto' or 'native' for auto-detect"), | 152 "'auto' or 'native' for auto-detect"), |
90 default="ia32,x64,arm") | 153 default="ia32,x64,arm") |
91 result.add_option("--arch-and-mode", | 154 result.add_option("--arch-and-mode", |
92 help="Architecture and mode in the format 'arch.mode'", | 155 help="Architecture and mode in the format 'arch.mode'", |
93 default=None) | 156 default=None) |
94 result.add_option("--buildbot", | 157 result.add_option("--buildbot", |
95 help="Adapt to path structure used on buildbots", | 158 help="Adapt to path structure used on buildbots", |
96 default=False, action="store_true") | 159 default=False, action="store_true") |
97 result.add_option("--cat", help="Print the source of the tests", | |
98 default=False, action="store_true") | |
99 result.add_option("--command-prefix", | 160 result.add_option("--command-prefix", |
100 help="Prepended to each shell command used to run a test", | 161 help="Prepended to each shell command used to run a test", |
101 default="") | 162 default="") |
| 163 result.add_option("--coverage", help=("Exponential test coverage " |
| 164 "(range 0.0, 1.0) -- 0.0: one test, 1.0 all tests (slow)"), |
| 165 default=0.4, type="float") |
| 166 result.add_option("--coverage-lift", help=("Lifts test coverage for tests " |
| 167 "with a small number of deopt points (range 0, inf)"), |
| 168 default=20, type="int") |
102 result.add_option("--download-data", help="Download missing test suite data", | 169 result.add_option("--download-data", help="Download missing test suite data", |
103 default=False, action="store_true") | 170 default=False, action="store_true") |
| 171 result.add_option("--distribution-factor1", help=("Factor of the first " |
| 172 "derivation of the distribution function"), default=2.0, |
| 173 type="float") |
| 174 result.add_option("--distribution-factor2", help=("Factor of the second " |
| 175 "derivation of the distribution function"), default=0.7, |
| 176 type="float") |
| 177 result.add_option("--distribution-mode", help=("How to select deopt points " |
| 178 "for a given test (smooth|random)"), |
| 179 default="smooth") |
| 180 result.add_option("--dump-results-file", help=("Dump maximum number of " |
| 181 "deopt points per test to a file")) |
104 result.add_option("--extra-flags", | 182 result.add_option("--extra-flags", |
105 help="Additional flags to pass to each test command", | 183 help="Additional flags to pass to each test command", |
106 default="") | 184 default="") |
107 result.add_option("--isolates", help="Whether to test isolates", | 185 result.add_option("--isolates", help="Whether to test isolates", |
108 default=False, action="store_true") | 186 default=False, action="store_true") |
109 result.add_option("-j", help="The number of parallel tasks to run", | 187 result.add_option("-j", help="The number of parallel tasks to run", |
110 default=0, type="int") | 188 default=0, type="int") |
111 result.add_option("-m", "--mode", | 189 result.add_option("-m", "--mode", |
112 help="The test modes in which to run (comma-separated)", | 190 help="The test modes in which to run (comma-separated)", |
113 default="release,debug") | 191 default="release,debug") |
114 result.add_option("--no-network", "--nonetwork", | |
115 help="Don't distribute tests on the network", | |
116 default=(utils.GuessOS() != "linux"), | |
117 dest="no_network", action="store_true") | |
118 result.add_option("--no-presubmit", "--nopresubmit", | |
119 help='Skip presubmit checks', | |
120 default=False, dest="no_presubmit", action="store_true") | |
121 result.add_option("--no-stress", "--nostress", | |
122 help="Don't run crankshaft --always-opt --stress-op test", | |
123 default=False, dest="no_stress", action="store_true") | |
124 result.add_option("--outdir", help="Base directory with compile output", | 192 result.add_option("--outdir", help="Base directory with compile output", |
125 default="out") | 193 default="out") |
126 result.add_option("-p", "--progress", | 194 result.add_option("-p", "--progress", |
127 help=("The style of progress indicator" | 195 help=("The style of progress indicator" |
128 " (verbose, dots, color, mono)"), | 196 " (verbose, dots, color, mono)"), |
129 choices=progress.PROGRESS_INDICATORS.keys(), default="mono") | 197 choices=progress.PROGRESS_INDICATORS.keys(), |
130 result.add_option("--report", help="Print a summary of the tests to be run", | 198 default="mono") |
131 default=False, action="store_true") | |
132 result.add_option("--shard-count", | 199 result.add_option("--shard-count", |
133 help="Split testsuites into this number of shards", | 200 help="Split testsuites into this number of shards", |
134 default=1, type="int") | 201 default=1, type="int") |
135 result.add_option("--shard-run", | 202 result.add_option("--shard-run", |
136 help="Run this shard from the split up tests.", | 203 help="Run this shard from the split up tests.", |
137 default=1, type="int") | 204 default=1, type="int") |
138 result.add_option("--shell", help="DEPRECATED! use --shell-dir", default="") | |
139 result.add_option("--shell-dir", help="Directory containing executables", | 205 result.add_option("--shell-dir", help="Directory containing executables", |
140 default="") | 206 default="") |
141 result.add_option("--dont-skip-slow-simulator-tests", | 207 result.add_option("--seed", help="The seed for the random distribution", |
142 help="Don't skip more slow tests when using a simulator.", | 208 type="int") |
143 default=False, action="store_true", | |
144 dest="dont_skip_simulator_slow_tests") | |
145 result.add_option("--stress-only", | |
146 help="Only run tests with --always-opt --stress-opt", | |
147 default=False, action="store_true") | |
148 result.add_option("--time", help="Print timing information after running", | |
149 default=False, action="store_true") | |
150 result.add_option("-t", "--timeout", help="Timeout in seconds", | 209 result.add_option("-t", "--timeout", help="Timeout in seconds", |
151 default= -1, type="int") | 210 default= -1, type="int") |
152 result.add_option("-v", "--verbose", help="Verbose output", | 211 result.add_option("-v", "--verbose", help="Verbose output", |
153 default=False, action="store_true") | 212 default=False, action="store_true") |
154 result.add_option("--valgrind", help="Run tests through valgrind", | |
155 default=False, action="store_true") | |
156 result.add_option("--warn-unused", help="Report unused rules", | |
157 default=False, action="store_true") | |
158 result.add_option("--junitout", help="File name of the JUnit output") | |
159 result.add_option("--junittestsuite", | |
160 help="The testsuite name in the JUnit output file", | |
161 default="v8tests") | |
162 return result | 213 return result |
163 | 214 |
164 | 215 |
165 def ProcessOptions(options): | 216 def ProcessOptions(options): |
166 global VARIANT_FLAGS | 217 global VARIANT_FLAGS |
167 | 218 |
168 # Architecture and mode related stuff. | 219 # Architecture and mode related stuff. |
169 if options.arch_and_mode: | 220 if options.arch_and_mode: |
170 tokens = options.arch_and_mode.split(".") | 221 tokens = options.arch_and_mode.split(".") |
171 options.arch = tokens[0] | 222 options.arch = tokens[0] |
172 options.mode = tokens[1] | 223 options.mode = tokens[1] |
173 options.mode = options.mode.split(",") | 224 options.mode = options.mode.split(",") |
174 for mode in options.mode: | 225 for mode in options.mode: |
175 if not mode.lower() in ["debug", "release"]: | 226 if not mode.lower() in ["debug", "release"]: |
176 print "Unknown mode %s" % mode | 227 print "Unknown mode %s" % mode |
177 return False | 228 return False |
178 if options.arch in ["auto", "native"]: | 229 if options.arch in ["auto", "native"]: |
179 options.arch = ARCH_GUESS | 230 options.arch = ARCH_GUESS |
180 options.arch = options.arch.split(",") | 231 options.arch = options.arch.split(",") |
181 for arch in options.arch: | 232 for arch in options.arch: |
182 if not arch in SUPPORTED_ARCHS: | 233 if not arch in SUPPORTED_ARCHS: |
183 print "Unknown architecture %s" % arch | 234 print "Unknown architecture %s" % arch |
184 return False | 235 return False |
185 | 236 |
186 # Special processing of other options, sorted alphabetically. | 237 # Special processing of other options, sorted alphabetically. |
187 | |
188 if options.buildbot: | |
189 # Buildbots run presubmit tests as a separate step. | |
190 options.no_presubmit = True | |
191 options.no_network = True | |
192 if options.command_prefix: | |
193 print("Specifying --command-prefix disables network distribution, " | |
194 "running tests locally.") | |
195 options.no_network = True | |
196 options.command_prefix = shlex.split(options.command_prefix) | 238 options.command_prefix = shlex.split(options.command_prefix) |
197 options.extra_flags = shlex.split(options.extra_flags) | 239 options.extra_flags = shlex.split(options.extra_flags) |
198 if options.j == 0: | 240 if options.j == 0: |
199 options.j = multiprocessing.cpu_count() | 241 options.j = multiprocessing.cpu_count() |
200 if options.no_stress: | 242 if not options.distribution_mode in DISTRIBUTION_MODES: |
201 VARIANT_FLAGS = [[], ["--nocrankshaft"]] | 243 print "Unknown distribution mode %s" % options.distribution_mode |
202 if not options.shell_dir: | 244 return False |
203 if options.shell: | 245 if options.distribution_factor1 < 0.0: |
204 print "Warning: --shell is deprecated, use --shell-dir instead." | 246 print ("Distribution factor1 %s is out of range. Defaulting to 0.0" |
205 options.shell_dir = os.path.dirname(options.shell) | 247 % options.distribution_factor1) |
206 if options.stress_only: | 248 options.distribution_factor1 = 0.0 |
207 VARIANT_FLAGS = [["--stress-opt", "--always-opt"]] | 249 if options.distribution_factor2 < 0.0: |
208 if options.valgrind: | 250 print ("Distribution factor2 %s is out of range. Defaulting to 0.0" |
209 run_valgrind = os.path.join("tools", "run-valgrind.py") | 251 % options.distribution_factor2) |
210 # This is OK for distributed running, so we don't need to set no_network. | 252 options.distribution_factor2 = 0.0 |
211 options.command_prefix = (["python", "-u", run_valgrind] + | 253 if options.coverage < 0.0 or options.coverage > 1.0: |
212 options.command_prefix) | 254 print ("Coverage %s is out of range. Defaulting to 0.4" |
| 255 % options.coverage) |
| 256 options.coverage = 0.4 |
| 257 if options.coverage_lift < 0: |
| 258 print ("Coverage lift %s is out of range. Defaulting to 0" |
| 259 % options.coverage_lift) |
| 260 options.coverage_lift = 0 |
213 return True | 261 return True |
214 | 262 |
215 | 263 |
216 def ShardTests(tests, shard_count, shard_run): | 264 def ShardTests(tests, shard_count, shard_run): |
217 if shard_count < 2: | 265 if shard_count < 2: |
218 return tests | 266 return tests |
219 if shard_run < 1 or shard_run > shard_count: | 267 if shard_run < 1 or shard_run > shard_count: |
220 print "shard-run not a valid number, should be in [1:shard-count]" | 268 print "shard-run not a valid number, should be in [1:shard-count]" |
221 print "defaulting back to running all tests" | 269 print "defaulting back to running all tests" |
222 return tests | 270 return tests |
223 count = 0 | 271 count = 0 |
224 shard = [] | 272 shard = [] |
225 for test in tests: | 273 for test in tests: |
226 if count % shard_count == shard_run - 1: | 274 if count % shard_count == shard_run - 1: |
227 shard.append(test) | 275 shard.append(test) |
228 count += 1 | 276 count += 1 |
229 return shard | 277 return shard |
230 | 278 |
231 | 279 |
232 def Main(): | 280 def Main(): |
233 parser = BuildOptions() | 281 parser = BuildOptions() |
234 (options, args) = parser.parse_args() | 282 (options, args) = parser.parse_args() |
235 if not ProcessOptions(options): | 283 if not ProcessOptions(options): |
236 parser.print_help() | 284 parser.print_help() |
237 return 1 | 285 return 1 |
238 | 286 |
239 exit_code = 0 | 287 exit_code = 0 |
240 workspace = os.path.abspath(join(os.path.dirname(sys.argv[0]), "..")) | 288 workspace = os.path.abspath(join(os.path.dirname(sys.argv[0]), "..")) |
241 if not options.no_presubmit: | |
242 print ">>> running presubmit tests" | |
243 code = subprocess.call( | |
244 [sys.executable, join(workspace, "tools", "presubmit.py")]) | |
245 exit_code = code | |
246 | 289 |
247 suite_paths = utils.GetSuitePaths(join(workspace, "test")) | 290 suite_paths = utils.GetSuitePaths(join(workspace, "test")) |
248 | 291 |
249 if len(args) == 0: | 292 if len(args) == 0: |
250 suite_paths = [ s for s in suite_paths if s in DEFAULT_TESTS ] | 293 suite_paths = [ s for s in suite_paths if s in DEFAULT_TESTS ] |
251 else: | 294 else: |
252 args_suites = set() | 295 args_suites = set() |
253 for arg in args: | 296 for arg in args: |
254 suite = arg.split(os.path.sep)[0] | 297 suite = arg.split(os.path.sep)[0] |
255 if not suite in args_suites: | 298 if not suite in args_suites: |
(...skipping 11 matching lines...) Expand all Loading... |
267 for s in suites: | 310 for s in suites: |
268 s.DownloadData() | 311 s.DownloadData() |
269 | 312 |
270 for mode in options.mode: | 313 for mode in options.mode: |
271 for arch in options.arch: | 314 for arch in options.arch: |
272 code = Execute(arch, mode, args, options, suites, workspace) | 315 code = Execute(arch, mode, args, options, suites, workspace) |
273 exit_code = exit_code or code | 316 exit_code = exit_code or code |
274 return exit_code | 317 return exit_code |
275 | 318 |
276 | 319 |
| 320 def CalculateNTests(m, options): |
| 321 """Calculates the number of tests from m deopt points with exponential |
| 322 coverage. |
| 323 The coverage is expected to be between 0.0 and 1.0. |
| 324 The 'coverage lift' lifts the coverage for tests with smaller m values. |
| 325 """ |
| 326 c = float(options.coverage) |
| 327 l = float(options.coverage_lift) |
| 328 return int(math.pow(m, (m * c + l) / (m + l))) |
| 329 |
| 330 |
277 def Execute(arch, mode, args, options, suites, workspace): | 331 def Execute(arch, mode, args, options, suites, workspace): |
278 print(">>> Running tests for %s.%s" % (arch, mode)) | 332 print(">>> Running tests for %s.%s" % (arch, mode)) |
279 | 333 |
| 334 dist = Distribution(options) |
| 335 |
280 shell_dir = options.shell_dir | 336 shell_dir = options.shell_dir |
281 if not shell_dir: | 337 if not shell_dir: |
282 if options.buildbot: | 338 if options.buildbot: |
283 shell_dir = os.path.join(workspace, options.outdir, mode) | 339 shell_dir = os.path.join(workspace, options.outdir, mode) |
284 mode = mode.lower() | 340 mode = mode.lower() |
285 else: | 341 else: |
286 shell_dir = os.path.join(workspace, options.outdir, | 342 shell_dir = os.path.join(workspace, options.outdir, |
287 "%s.%s" % (arch, mode)) | 343 "%s.%s" % (arch, mode)) |
288 shell_dir = os.path.relpath(shell_dir) | 344 shell_dir = os.path.relpath(shell_dir) |
289 | 345 |
290 # Populate context object. | 346 # Populate context object. |
291 mode_flags = MODE_FLAGS[mode] | 347 mode_flags = MODE_FLAGS[mode] |
292 timeout = options.timeout | 348 timeout = options.timeout |
293 if timeout == -1: | 349 if timeout == -1: |
294 # Simulators are slow, therefore allow a longer default timeout. | 350 # Simulators are slow, therefore allow a longer default timeout. |
295 if arch in SLOW_ARCHS: | 351 if arch in SLOW_ARCHS: |
296 timeout = 2 * TIMEOUT_DEFAULT; | 352 timeout = 2 * TIMEOUT_DEFAULT; |
297 else: | 353 else: |
298 timeout = TIMEOUT_DEFAULT; | 354 timeout = TIMEOUT_DEFAULT; |
299 | 355 |
300 timeout *= TIMEOUT_SCALEFACTOR[mode] | 356 timeout *= TIMEOUT_SCALEFACTOR[mode] |
301 ctx = context.Context(arch, mode, shell_dir, | 357 ctx = context.Context(arch, mode, shell_dir, |
302 mode_flags, options.verbose, | 358 mode_flags, options.verbose, |
303 timeout, options.isolates, | 359 timeout, options.isolates, |
304 options.command_prefix, | 360 options.command_prefix, |
305 options.extra_flags) | 361 options.extra_flags) |
306 | 362 |
307 simulator_run = not options.dont_skip_simulator_slow_tests and \ | |
308 arch in ['a64', 'arm', 'mips'] and ARCH_GUESS and arch != ARCH_GUESS | |
309 # Find available test suites and read test cases from them. | 363 # Find available test suites and read test cases from them. |
310 variables = { | 364 variables = { |
311 "mode": mode, | 365 "mode": mode, |
312 "arch": arch, | 366 "arch": arch, |
313 "system": utils.GuessOS(), | 367 "system": utils.GuessOS(), |
314 "isolates": options.isolates, | 368 "isolates": options.isolates, |
315 "simulator_run": simulator_run | 369 "deopt_fuzzer": True, |
316 } | 370 } |
317 all_tests = [] | 371 all_tests = [] |
318 num_tests = 0 | 372 num_tests = 0 |
319 test_id = 0 | 373 test_id = 0 |
| 374 |
| 375 # Remember test case prototypes for the fuzzing phase. |
| 376 test_backup = dict((s, []) for s in suites) |
| 377 |
320 for s in suites: | 378 for s in suites: |
321 s.ReadStatusFile(variables) | 379 s.ReadStatusFile(variables) |
322 s.ReadTestCases(ctx) | 380 s.ReadTestCases(ctx) |
323 if len(args) > 0: | 381 if len(args) > 0: |
324 s.FilterTestCasesByArgs(args) | 382 s.FilterTestCasesByArgs(args) |
325 all_tests += s.tests | 383 all_tests += s.tests |
326 s.FilterTestCasesByStatus(options.warn_unused) | 384 s.FilterTestCasesByStatus(False) |
327 if options.cat: | 385 test_backup[s] = s.tests |
328 verbose.PrintTestSource(s.tests) | 386 analysis_flags = ["--deopt-every-n-times", "%d" % MAX_DEOPT, |
329 continue | 387 "--print-deopt-stress"] |
330 variant_flags = s.VariantFlags() or VARIANT_FLAGS | 388 s.tests = [ t.CopyAddingFlags(analysis_flags) for t in s.tests ] |
331 s.tests = [ t.CopyAddingFlags(v) for t in s.tests for v in variant_flags ] | |
332 s.tests = ShardTests(s.tests, options.shard_count, options.shard_run) | |
333 num_tests += len(s.tests) | 389 num_tests += len(s.tests) |
334 for t in s.tests: | 390 for t in s.tests: |
335 t.id = test_id | 391 t.id = test_id |
336 test_id += 1 | 392 test_id += 1 |
337 | 393 |
338 if options.cat: | 394 if num_tests == 0: |
339 return 0 # We're done here. | 395 print "No tests to run." |
| 396 return 0 |
340 | 397 |
341 if options.report: | 398 try: |
342 verbose.PrintReport(all_tests) | 399 print(">>> Collection phase") |
| 400 progress_indicator = progress.PROGRESS_INDICATORS[options.progress]() |
| 401 runner = execution.Runner(suites, progress_indicator, ctx) |
| 402 |
| 403 exit_code = runner.Run(options.j) |
| 404 if runner.terminate: |
| 405 return exit_code |
| 406 |
| 407 except KeyboardInterrupt: |
| 408 return 1 |
| 409 |
| 410 print(">>> Analysis phase") |
| 411 num_tests = 0 |
| 412 test_id = 0 |
| 413 for s in suites: |
| 414 test_results = {} |
| 415 for t in s.tests: |
| 416 for line in t.output.stdout.splitlines(): |
| 417 if line.startswith("=== Stress deopt counter: "): |
| 418 test_results[t.path] = MAX_DEOPT - int(line.split(" ")[-1]) |
| 419 for t in s.tests: |
| 420 if t.path not in test_results: |
| 421 print "Missing results for %s" % t.path |
| 422 if options.dump_results_file: |
| 423 results_dict = dict((t.path, n) for (t, n) in test_results.iteritems()) |
| 424 with file("%s.%d.txt" % (dump_results_file, time.time()), "w") as f: |
| 425 f.write(json.dumps(results_dict)) |
| 426 |
| 427 # Reset tests and redistribute the prototypes from the collection phase. |
| 428 s.tests = [] |
| 429 if options.verbose: |
| 430 print "Test distributions:" |
| 431 for t in test_backup[s]: |
| 432 max_deopt = test_results.get(t.path, 0) |
| 433 if max_deopt == 0: |
| 434 continue |
| 435 n_deopt = CalculateNTests(max_deopt, options) |
| 436 distribution = dist.Distribute(n_deopt, max_deopt) |
| 437 if options.verbose: |
| 438 print "%s %s" % (t.path, distribution) |
| 439 for i in distribution: |
| 440 fuzzing_flags = ["--deopt-every-n-times", "%d" % i] |
| 441 s.tests.append(t.CopyAddingFlags(fuzzing_flags)) |
| 442 num_tests += len(s.tests) |
| 443 for t in s.tests: |
| 444 t.id = test_id |
| 445 test_id += 1 |
343 | 446 |
344 if num_tests == 0: | 447 if num_tests == 0: |
345 print "No tests to run." | 448 print "No tests to run." |
346 return 0 | 449 return 0 |
347 | 450 |
348 # Run the tests, either locally or distributed on the network. | |
349 try: | 451 try: |
350 start_time = time.time() | 452 print(">>> Deopt fuzzing phase (%d test cases)" % num_tests) |
351 progress_indicator = progress.PROGRESS_INDICATORS[options.progress]() | 453 progress_indicator = progress.PROGRESS_INDICATORS[options.progress]() |
352 if options.junitout: | 454 runner = execution.Runner(suites, progress_indicator, ctx) |
353 progress_indicator = progress.JUnitTestProgressIndicator( | |
354 progress_indicator, options.junitout, options.junittestsuite) | |
355 | |
356 run_networked = not options.no_network | |
357 if not run_networked: | |
358 print("Network distribution disabled, running tests locally.") | |
359 elif utils.GuessOS() != "linux": | |
360 print("Network distribution is only supported on Linux, sorry!") | |
361 run_networked = False | |
362 peers = [] | |
363 if run_networked: | |
364 peers = network_execution.GetPeers() | |
365 if not peers: | |
366 print("No connection to distribution server; running tests locally.") | |
367 run_networked = False | |
368 elif len(peers) == 1: | |
369 print("No other peers on the network; running tests locally.") | |
370 run_networked = False | |
371 elif num_tests <= 100: | |
372 print("Less than 100 tests, running them locally.") | |
373 run_networked = False | |
374 | |
375 if run_networked: | |
376 runner = network_execution.NetworkedRunner(suites, progress_indicator, | |
377 ctx, peers, workspace) | |
378 else: | |
379 runner = execution.Runner(suites, progress_indicator, ctx) | |
380 | 455 |
381 exit_code = runner.Run(options.j) | 456 exit_code = runner.Run(options.j) |
382 if runner.terminate: | 457 if runner.terminate: |
383 return exit_code | 458 return exit_code |
384 overall_duration = time.time() - start_time | 459 |
385 except KeyboardInterrupt: | 460 except KeyboardInterrupt: |
386 return 1 | 461 return 1 |
387 | 462 |
388 if options.time: | |
389 verbose.PrintTestDurations(suites, overall_duration) | |
390 return exit_code | 463 return exit_code |
391 | 464 |
392 | 465 |
393 if __name__ == "__main__": | 466 if __name__ == "__main__": |
394 sys.exit(Main()) | 467 sys.exit(Main()) |
OLD | NEW |