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

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

Issue 2567603002: [test] Add mksnapshot stress test suite
Patch Set: [test] Add mksnapshot stress test suite Created 4 years 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 | « test/mksnapshot/testcfg.py ('k') | tools/testrunner/local/testsuite.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 18 matching lines...) Expand all
29 29
30 30
31 from collections import OrderedDict 31 from collections import OrderedDict
32 import itertools 32 import itertools
33 import json 33 import json
34 import multiprocessing 34 import multiprocessing
35 import optparse 35 import optparse
36 import os 36 import os
37 from os.path import getmtime, isdir, join 37 from os.path import getmtime, isdir, join
38 import platform 38 import platform
39 import random
40 import shlex 39 import shlex
41 import subprocess 40 import subprocess
42 import sys 41 import sys
43 import time 42 import time
44 43
45 from testrunner.local import execution 44 from testrunner.local import execution
46 from testrunner.local import progress 45 from testrunner.local import progress
47 from testrunner.local import testsuite 46 from testrunner.local import testsuite
48 from testrunner.local.variants import ALL_VARIANTS 47 from testrunner.local.variants import ALL_VARIANTS
49 from testrunner.local import utils 48 from testrunner.local import utils
(...skipping 18 matching lines...) Expand all
68 "mjsunit", 67 "mjsunit",
69 "cctest", 68 "cctest",
70 "debugger", 69 "debugger",
71 "inspector", 70 "inspector",
72 "webkit", 71 "webkit",
73 "fuzzer", 72 "fuzzer",
74 "message", 73 "message",
75 "preparser", 74 "preparser",
76 "intl", 75 "intl",
77 "unittests", 76 "unittests",
77 "mksnapshot",
78 ], 78 ],
79 # This needs to stay in sync with test/default.isolate. 79 # This needs to stay in sync with test/default.isolate.
80 "default": [ 80 "default": [
81 "mjsunit", 81 "mjsunit",
82 "cctest", 82 "cctest",
83 "debugger", 83 "debugger",
84 "inspector", 84 "inspector",
85 "fuzzer", 85 "fuzzer",
86 "message", 86 "message",
87 "preparser", 87 "preparser",
88 "intl", 88 "intl",
89 "unittests", 89 "unittests",
90 "mksnapshot",
90 ], 91 ],
91 # This needs to stay in sync with test/optimize_for_size.isolate. 92 # This needs to stay in sync with test/optimize_for_size.isolate.
92 "optimize_for_size": [ 93 "optimize_for_size": [
93 "mjsunit", 94 "mjsunit",
94 "cctest", 95 "cctest",
95 "debugger", 96 "debugger",
96 "inspector", 97 "inspector",
97 "webkit", 98 "webkit",
98 "intl", 99 "intl",
99 ], 100 ],
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 help="Default seed for initializing random generator") 367 help="Default seed for initializing random generator")
367 result.add_option("--random-seed-stress-count", default=1, type="int", 368 result.add_option("--random-seed-stress-count", default=1, type="int",
368 dest="random_seed_stress_count", 369 dest="random_seed_stress_count",
369 help="Number of runs with different random seeds") 370 help="Number of runs with different random seeds")
370 result.add_option("--msan", 371 result.add_option("--msan",
371 help="Regard test expectations for MSAN", 372 help="Regard test expectations for MSAN",
372 default=False, action="store_true") 373 default=False, action="store_true")
373 return result 374 return result
374 375
375 376
376 def RandomSeed():
377 seed = 0
378 while not seed:
379 seed = random.SystemRandom().randint(-2147483648, 2147483647)
380 return seed
381
382
383 def BuildbotToV8Mode(config): 377 def BuildbotToV8Mode(config):
384 """Convert buildbot build configs to configs understood by the v8 runner. 378 """Convert buildbot build configs to configs understood by the v8 runner.
385 379
386 V8 configs are always lower case and without the additional _x64 suffix for 380 V8 configs are always lower case and without the additional _x64 suffix for
387 64 bit builds on windows with ninja. 381 64 bit builds on windows with ninja.
388 """ 382 """
389 mode = config[:-4] if config.endswith('_x64') else config 383 mode = config[:-4] if config.endswith('_x64') else config
390 return mode.lower() 384 return mode.lower()
391 385
392 def SetupEnvironment(options): 386 def SetupEnvironment(options):
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if options.msan: 541 if options.msan:
548 VARIANTS = ["default"] 542 VARIANTS = ["default"]
549 543
550 if options.tsan: 544 if options.tsan:
551 VARIANTS = ["default"] 545 VARIANTS = ["default"]
552 546
553 if options.j == 0: 547 if options.j == 0:
554 options.j = multiprocessing.cpu_count() 548 options.j = multiprocessing.cpu_count()
555 549
556 if options.random_seed_stress_count <= 1 and options.random_seed == 0: 550 if options.random_seed_stress_count <= 1 and options.random_seed == 0:
557 options.random_seed = RandomSeed() 551 options.random_seed = utils.RandomSeed()
558 552
559 def excl(*args): 553 def excl(*args):
560 """Returns true if zero or one of multiple arguments are true.""" 554 """Returns true if zero or one of multiple arguments are true."""
561 return reduce(lambda x, y: x + y, args) <= 1 555 return reduce(lambda x, y: x + y, args) <= 1
562 556
563 if not excl(options.no_variants, bool(options.variants)): 557 if not excl(options.no_variants, bool(options.variants)):
564 print("Use only one of --no-variants or --variants.") 558 print("Use only one of --no-variants or --variants.")
565 return False 559 return False
566 if options.quickcheck: 560 if options.quickcheck:
567 VARIANTS = ["default", "stress"] 561 VARIANTS = ["default", "stress"]
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 if options.no_i18n: 606 if options.no_i18n:
613 TEST_MAP["bot_default"].remove("intl") 607 TEST_MAP["bot_default"].remove("intl")
614 TEST_MAP["default"].remove("intl") 608 TEST_MAP["default"].remove("intl")
615 if not options.enable_inspector: 609 if not options.enable_inspector:
616 TEST_MAP["default"].remove("inspector") 610 TEST_MAP["default"].remove("inspector")
617 TEST_MAP["bot_default"].remove("inspector") 611 TEST_MAP["bot_default"].remove("inspector")
618 TEST_MAP["optimize_for_size"].remove("inspector") 612 TEST_MAP["optimize_for_size"].remove("inspector")
619 TEST_MAP["default"].remove("debugger") 613 TEST_MAP["default"].remove("debugger")
620 TEST_MAP["bot_default"].remove("debugger") 614 TEST_MAP["bot_default"].remove("debugger")
621 TEST_MAP["optimize_for_size"].remove("debugger") 615 TEST_MAP["optimize_for_size"].remove("debugger")
616 if options.no_snap:
617 TEST_MAP["bot_default"].remove("mksnapshot")
618 TEST_MAP["default"].remove("mksnapshot")
622 return True 619 return True
623 620
624 621
625 def ShardTests(tests, options): 622 def ShardTests(tests, options):
626 # Read gtest shard configuration from environment (e.g. set by swarming). 623 # Read gtest shard configuration from environment (e.g. set by swarming).
627 # If none is present, use values passed on the command line. 624 # If none is present, use values passed on the command line.
628 shard_count = int(os.environ.get('GTEST_TOTAL_SHARDS', options.shard_count)) 625 shard_count = int(os.environ.get('GTEST_TOTAL_SHARDS', options.shard_count))
629 shard_run = os.environ.get('GTEST_SHARD_INDEX') 626 shard_run = os.environ.get('GTEST_SHARD_INDEX')
630 if shard_run is not None: 627 if shard_run is not None:
631 # The v8 shard_run starts at 1, while GTEST_SHARD_INDEX starts at 0. 628 # The v8 shard_run starts at 1, while GTEST_SHARD_INDEX starts at 0.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 "tsan": options.tsan, 797 "tsan": options.tsan,
801 "msan": options.msan, 798 "msan": options.msan,
802 "dcheck_always_on": options.dcheck_always_on, 799 "dcheck_always_on": options.dcheck_always_on,
803 "novfp3": options.novfp3, 800 "novfp3": options.novfp3,
804 "predictable": options.predictable, 801 "predictable": options.predictable,
805 "byteorder": sys.byteorder, 802 "byteorder": sys.byteorder,
806 } 803 }
807 all_tests = [] 804 all_tests = []
808 num_tests = 0 805 num_tests = 0
809 for s in suites: 806 for s in suites:
807 s.Setup()
810 s.ReadStatusFile(variables) 808 s.ReadStatusFile(variables)
811 s.ReadTestCases(ctx) 809 s.ReadTestCases(ctx)
812 if len(args) > 0: 810 if len(args) > 0:
813 s.FilterTestCasesByArgs(args) 811 s.FilterTestCasesByArgs(args)
814 all_tests += s.tests 812 all_tests += s.tests
815 813
816 # First filtering by status applying the generic rules (independent of 814 # First filtering by status applying the generic rules (independent of
817 # variants). 815 # variants).
818 s.FilterTestCasesByStatus(options.warn_unused, options.slow_tests, 816 s.FilterTestCasesByStatus(options.warn_unused, options.slow_tests,
819 options.pass_fail_tests) 817 options.pass_fail_tests)
820 818
821 if options.cat: 819 if options.cat:
822 verbose.PrintTestSource(s.tests) 820 verbose.PrintTestSource(s.tests)
823 continue 821 continue
824 variant_gen = s.CreateVariantGenerator(VARIANTS) 822 variant_gen = s.CreateVariantGenerator(VARIANTS)
825 variant_tests = [ t.CopyAddingFlags(v, flags) 823 variant_tests = [ t.CopyAddingFlags(v, flags)
826 for t in s.tests 824 for t in s.tests
827 for v in variant_gen.FilterVariantsByTest(t) 825 for v in variant_gen.FilterVariantsByTest(t)
828 for flags in variant_gen.GetFlagSets(t, v) ] 826 for flags in variant_gen.GetFlagSets(t, v) ]
829 827
830 if options.random_seed_stress_count > 1: 828 if options.random_seed_stress_count > 1:
831 # Duplicate test for random seed stress mode. 829 # Duplicate test for random seed stress mode.
832 def iter_seed_flags(): 830 def iter_seed_flags():
833 for i in range(0, options.random_seed_stress_count): 831 for i in range(0, options.random_seed_stress_count):
834 # Use given random seed for all runs (set by default in execution.py) 832 # Use given random seed for all runs (set by default in execution.py)
835 # or a new random seed if none is specified. 833 # or a new random seed if none is specified.
836 if options.random_seed: 834 if options.random_seed:
837 yield [] 835 yield []
838 else: 836 else:
839 yield ["--random-seed=%d" % RandomSeed()] 837 yield ["--random-seed=%d" % utils.RandomSeed()]
840 s.tests = [ 838 s.tests = [
841 t.CopyAddingFlags(t.variant, flags) 839 t.CopyAddingFlags(t.variant, flags)
842 for t in variant_tests 840 for t in variant_tests
843 for flags in iter_seed_flags() 841 for flags in iter_seed_flags()
844 ] 842 ]
845 else: 843 else:
846 s.tests = variant_tests 844 s.tests = variant_tests
847 845
848 # Second filtering by status applying the variant-dependent rules. 846 # Second filtering by status applying the variant-dependent rules.
849 s.FilterTestCasesByStatus(options.warn_unused, options.slow_tests, 847 s.FilterTestCasesByStatus(options.warn_unused, options.slow_tests,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 elif num_tests <= 100: 887 elif num_tests <= 100:
890 print("Less than 100 tests, running them locally.") 888 print("Less than 100 tests, running them locally.")
891 run_networked = False 889 run_networked = False
892 890
893 if run_networked: 891 if run_networked:
894 runner = network_execution.NetworkedRunner(suites, progress_indicator, 892 runner = network_execution.NetworkedRunner(suites, progress_indicator,
895 ctx, peers, BASE_DIR) 893 ctx, peers, BASE_DIR)
896 else: 894 else:
897 runner = execution.Runner(suites, progress_indicator, ctx) 895 runner = execution.Runner(suites, progress_indicator, ctx)
898 896
899 exit_code = runner.Run(options.j) 897 try:
898 exit_code = runner.Run(options.j)
899 finally:
900 for s in suites:
901 s.TearDown()
902
900 overall_duration = time.time() - start_time 903 overall_duration = time.time() - start_time
901 904
902 if options.time: 905 if options.time:
903 verbose.PrintTestDurations(suites, overall_duration) 906 verbose.PrintTestDurations(suites, overall_duration)
904 907
905 if num_tests == 0: 908 if num_tests == 0:
906 print("Warning: no tests were run!") 909 print("Warning: no tests were run!")
907 910
908 if exit_code == 1 and options.json_test_results: 911 if exit_code == 1 and options.json_test_results:
909 print("Force exit code 0 after failures. Json test results file generated " 912 print("Force exit code 0 after failures. Json test results file generated "
(...skipping 10 matching lines...) Expand all
920 "--coverage-dir=%s" % options.sancov_dir]) 923 "--coverage-dir=%s" % options.sancov_dir])
921 except: 924 except:
922 print >> sys.stderr, "Error: Merging sancov files failed." 925 print >> sys.stderr, "Error: Merging sancov files failed."
923 exit_code = 1 926 exit_code = 1
924 927
925 return exit_code 928 return exit_code
926 929
927 930
928 if __name__ == "__main__": 931 if __name__ == "__main__":
929 sys.exit(Main()) 932 sys.exit(Main())
OLDNEW
« no previous file with comments | « test/mksnapshot/testcfg.py ('k') | tools/testrunner/local/testsuite.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698