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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 result.add_option("--valgrind", help="Run tests through valgrind", | 296 result.add_option("--valgrind", help="Run tests through valgrind", |
297 default=False, action="store_true") | 297 default=False, action="store_true") |
298 result.add_option("--warn-unused", help="Report unused rules", | 298 result.add_option("--warn-unused", help="Report unused rules", |
299 default=False, action="store_true") | 299 default=False, action="store_true") |
300 result.add_option("--junitout", help="File name of the JUnit output") | 300 result.add_option("--junitout", help="File name of the JUnit output") |
301 result.add_option("--junittestsuite", | 301 result.add_option("--junittestsuite", |
302 help="The testsuite name in the JUnit output file", | 302 help="The testsuite name in the JUnit output file", |
303 default="v8tests") | 303 default="v8tests") |
304 result.add_option("--random-seed", default=0, dest="random_seed", | 304 result.add_option("--random-seed", default=0, dest="random_seed", |
305 help="Default seed for initializing random generator") | 305 help="Default seed for initializing random generator") |
306 result.add_option("--random-seed-stress-count", default=1, type="int", | |
307 dest="random_seed_stress_count", | |
308 help="Number of runs with different random seeds") | |
306 result.add_option("--msan", | 309 result.add_option("--msan", |
307 help="Regard test expectations for MSAN", | 310 help="Regard test expectations for MSAN", |
308 default=False, action="store_true") | 311 default=False, action="store_true") |
309 return result | 312 return result |
310 | 313 |
311 | 314 |
315 def RandomSeed(): | |
316 seed = 0 | |
317 while not seed: | |
318 seed = random.SystemRandom().randint(-2147483648, 2147483647) | |
319 return seed | |
320 | |
321 | |
312 def ProcessOptions(options): | 322 def ProcessOptions(options): |
313 global VARIANT_FLAGS | 323 global VARIANT_FLAGS |
314 global VARIANTS | 324 global VARIANTS |
315 | 325 |
316 # Architecture and mode related stuff. | 326 # Architecture and mode related stuff. |
317 if options.arch_and_mode: | 327 if options.arch_and_mode: |
318 options.arch_and_mode = [arch_and_mode.split(".") | 328 options.arch_and_mode = [arch_and_mode.split(".") |
319 for arch_and_mode in options.arch_and_mode.split(",")] | 329 for arch_and_mode in options.arch_and_mode.split(",")] |
320 options.arch = ",".join([tokens[0] for tokens in options.arch_and_mode]) | 330 options.arch = ",".join([tokens[0] for tokens in options.arch_and_mode]) |
321 options.mode = ",".join([tokens[1] for tokens in options.arch_and_mode]) | 331 options.mode = ",".join([tokens[1] for tokens in options.arch_and_mode]) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 VARIANTS = ["default"] | 376 VARIANTS = ["default"] |
367 suppressions_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), | 377 suppressions_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
368 'sanitizers', 'tsan_suppressions.txt') | 378 'sanitizers', 'tsan_suppressions.txt') |
369 tsan_options = '%s suppressions=%s' % ( | 379 tsan_options = '%s suppressions=%s' % ( |
370 os.environ.get('TSAN_OPTIONS', ''), suppressions_file) | 380 os.environ.get('TSAN_OPTIONS', ''), suppressions_file) |
371 os.environ['TSAN_OPTIONS'] = tsan_options | 381 os.environ['TSAN_OPTIONS'] = tsan_options |
372 | 382 |
373 if options.j == 0: | 383 if options.j == 0: |
374 options.j = multiprocessing.cpu_count() | 384 options.j = multiprocessing.cpu_count() |
375 | 385 |
376 while options.random_seed == 0: | 386 if options.random_seed_stress_count <= 1: |
Jakob Kummerow
2015/06/11 08:50:35
Shouldn't this condition include a check that opti
Michael Achenbach
2015/06/11 09:45:05
Good catch!
| |
377 options.random_seed = random.SystemRandom().randint(-2147483648, 2147483647) | 387 options.random_seed = RandomSeed() |
378 | 388 |
379 def excl(*args): | 389 def excl(*args): |
380 """Returns true if zero or one of multiple arguments are true.""" | 390 """Returns true if zero or one of multiple arguments are true.""" |
381 return reduce(lambda x, y: x + y, args) <= 1 | 391 return reduce(lambda x, y: x + y, args) <= 1 |
382 | 392 |
383 if not excl(options.no_stress, options.stress_only, options.no_variants, | 393 if not excl(options.no_stress, options.stress_only, options.no_variants, |
384 bool(options.variants)): | 394 bool(options.variants)): |
385 print("Use only one of --no-stress, --stress-only, --no-variants, " | 395 print("Use only one of --no-stress, --stress-only, --no-variants, " |
386 "or --variants.") | 396 "or --variants.") |
387 return False | 397 return False |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 verbose_output = ( | 555 verbose_output = ( |
546 options.verbose or | 556 options.verbose or |
547 utils.IsWindows() and options.progress == "verbose" | 557 utils.IsWindows() and options.progress == "verbose" |
548 ) | 558 ) |
549 ctx = context.Context(arch, MODES[mode]["execution_mode"], shell_dir, | 559 ctx = context.Context(arch, MODES[mode]["execution_mode"], shell_dir, |
550 mode_flags, verbose_output, | 560 mode_flags, verbose_output, |
551 timeout, options.isolates, | 561 timeout, options.isolates, |
552 options.command_prefix, | 562 options.command_prefix, |
553 options.extra_flags, | 563 options.extra_flags, |
554 options.no_i18n, | 564 options.no_i18n, |
555 options.random_seed, | 565 options.random_seed, |
Jakob Kummerow
2015/06/11 08:50:35
In case of --random-seed=1 --random-seed-stress-co
Michael Achenbach
2015/06/11 09:45:05
Done.
| |
556 options.no_sorting, | 566 options.no_sorting, |
557 options.rerun_failures_count, | 567 options.rerun_failures_count, |
558 options.rerun_failures_max, | 568 options.rerun_failures_max, |
559 options.predictable, | 569 options.predictable, |
560 options.no_harness) | 570 options.no_harness) |
561 | 571 |
562 # TODO(all): Combine "simulator" and "simulator_run". | 572 # TODO(all): Combine "simulator" and "simulator_run". |
563 simulator_run = not options.dont_skip_simulator_slow_tests and \ | 573 simulator_run = not options.dont_skip_simulator_slow_tests and \ |
564 arch in ['arm64', 'arm', 'mipsel', 'mips', 'mips64el', \ | 574 arch in ['arm64', 'arm', 'mipsel', 'mips', 'mips64el', \ |
565 'ppc', 'ppc64'] and \ | 575 'ppc', 'ppc64'] and \ |
(...skipping 23 matching lines...) Expand all Loading... | |
589 s.ReadTestCases(ctx) | 599 s.ReadTestCases(ctx) |
590 if len(args) > 0: | 600 if len(args) > 0: |
591 s.FilterTestCasesByArgs(args) | 601 s.FilterTestCasesByArgs(args) |
592 all_tests += s.tests | 602 all_tests += s.tests |
593 s.FilterTestCasesByStatus(options.warn_unused, options.flaky_tests, | 603 s.FilterTestCasesByStatus(options.warn_unused, options.flaky_tests, |
594 options.slow_tests, options.pass_fail_tests) | 604 options.slow_tests, options.pass_fail_tests) |
595 if options.cat: | 605 if options.cat: |
596 verbose.PrintTestSource(s.tests) | 606 verbose.PrintTestSource(s.tests) |
597 continue | 607 continue |
598 variant_flags = [VARIANT_FLAGS[var] for var in VARIANTS] | 608 variant_flags = [VARIANT_FLAGS[var] for var in VARIANTS] |
599 s.tests = [ t.CopyAddingFlags(v) | 609 variant_tests = [ t.CopyAddingFlags(v) |
600 for t in s.tests | 610 for t in s.tests |
601 for v in s.VariantFlags(t, variant_flags) ] | 611 for v in s.VariantFlags(t, variant_flags) ] |
612 | |
613 if options.random_seed_stress_count > 1: | |
614 # Duplicate test for random seed stress mode. | |
615 def iter_seed_flags(): | |
616 for i in range(0, options.random_seed_stress_count): | |
617 # Use given random seed for all runs or a new random seed if none | |
618 # is specified. | |
619 seed = options.random_seed or RandomSeed() | |
620 yield ["--random-seed=%s" % str(seed)] | |
Jakob Kummerow
2015/06/11 08:50:35
nit: explicit str() is not necessary when using %s
Michael Achenbach
2015/06/11 09:45:05
Done.
| |
621 s.tests = [ | |
622 t.CopyAddingFlags(v) | |
623 for t in variant_tests | |
624 for v in iter_seed_flags() | |
625 ] | |
626 else: | |
627 s.tests = variant_tests | |
628 | |
602 s.tests = ShardTests(s.tests, options.shard_count, options.shard_run) | 629 s.tests = ShardTests(s.tests, options.shard_count, options.shard_run) |
603 num_tests += len(s.tests) | 630 num_tests += len(s.tests) |
604 | 631 |
605 if options.cat: | 632 if options.cat: |
606 return 0 # We're done here. | 633 return 0 # We're done here. |
607 | 634 |
608 if options.report: | 635 if options.report: |
609 verbose.PrintReport(all_tests) | 636 verbose.PrintReport(all_tests) |
610 | 637 |
611 # Run the tests, either locally or distributed on the network. | 638 # Run the tests, either locally or distributed on the network. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 exit_code = runner.Run(options.j) | 674 exit_code = runner.Run(options.j) |
648 overall_duration = time.time() - start_time | 675 overall_duration = time.time() - start_time |
649 | 676 |
650 if options.time: | 677 if options.time: |
651 verbose.PrintTestDurations(suites, overall_duration) | 678 verbose.PrintTestDurations(suites, overall_duration) |
652 return exit_code | 679 return exit_code |
653 | 680 |
654 | 681 |
655 if __name__ == "__main__": | 682 if __name__ == "__main__": |
656 sys.exit(Main()) | 683 sys.exit(Main()) |
OLD | NEW |