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

Side by Side Diff: tools/run-tests.py

Issue 1180473003: [test] Add random seed stress mode to test runner. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review Created 5 years, 6 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
« no previous file with comments | « no previous file | tools/testrunner/local/execution.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 result.add_option("-v", "--verbose", help="Verbose output", 294 result.add_option("-v", "--verbose", help="Verbose output",
295 default=False, action="store_true") 295 default=False, action="store_true")
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", type="int",
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
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 and options.random_seed == 0:
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (set by default in execution.py)
618 # or a new random seed if none is specified.
619 if options.random_seed:
620 yield []
621 else:
622 yield ["--random-seed=%d" % RandomSeed()]
623 s.tests = [
624 t.CopyAddingFlags(v)
625 for t in variant_tests
626 for v in iter_seed_flags()
627 ]
628 else:
629 s.tests = variant_tests
630
602 s.tests = ShardTests(s.tests, options.shard_count, options.shard_run) 631 s.tests = ShardTests(s.tests, options.shard_count, options.shard_run)
603 num_tests += len(s.tests) 632 num_tests += len(s.tests)
604 633
605 if options.cat: 634 if options.cat:
606 return 0 # We're done here. 635 return 0 # We're done here.
607 636
608 if options.report: 637 if options.report:
609 verbose.PrintReport(all_tests) 638 verbose.PrintReport(all_tests)
610 639
611 # Run the tests, either locally or distributed on the network. 640 # Run the tests, either locally or distributed on the network.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 exit_code = runner.Run(options.j) 676 exit_code = runner.Run(options.j)
648 overall_duration = time.time() - start_time 677 overall_duration = time.time() - start_time
649 678
650 if options.time: 679 if options.time:
651 verbose.PrintTestDurations(suites, overall_duration) 680 verbose.PrintTestDurations(suites, overall_duration)
652 return exit_code 681 return exit_code
653 682
654 683
655 if __name__ == "__main__": 684 if __name__ == "__main__":
656 sys.exit(Main()) 685 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | tools/testrunner/local/execution.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698