| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 from testrunner.local import execution | 44 from testrunner.local import execution |
| 45 from testrunner.local import progress | 45 from testrunner.local import progress |
| 46 from testrunner.local import testsuite | 46 from testrunner.local import testsuite |
| 47 from testrunner.local.testsuite import ALL_VARIANTS | 47 from testrunner.local.testsuite import ALL_VARIANTS |
| 48 from testrunner.local import utils | 48 from testrunner.local import utils |
| 49 from testrunner.local import verbose | 49 from testrunner.local import verbose |
| 50 from testrunner.network import network_execution | 50 from testrunner.network import network_execution |
| 51 from testrunner.objects import context | 51 from testrunner.objects import context |
| 52 | 52 |
| 53 | 53 |
| 54 # Base dir of the v8 checkout to be used as cwd. |
| 55 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 56 |
| 54 ARCH_GUESS = utils.DefaultArch() | 57 ARCH_GUESS = utils.DefaultArch() |
| 55 | 58 |
| 56 # Map of test name synonyms to lists of test suites. Should be ordered by | 59 # Map of test name synonyms to lists of test suites. Should be ordered by |
| 57 # expected runtimes (suites with slow test cases first). These groups are | 60 # expected runtimes (suites with slow test cases first). These groups are |
| 58 # invoked in seperate steps on the bots. | 61 # invoked in seperate steps on the bots. |
| 59 TEST_MAP = { | 62 TEST_MAP = { |
| 60 "default": [ | 63 "default": [ |
| 61 "mjsunit", | 64 "mjsunit", |
| 62 "cctest", | 65 "cctest", |
| 63 "message", | 66 "message", |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 count = 0 | 491 count = 0 |
| 489 shard = [] | 492 shard = [] |
| 490 for test in tests: | 493 for test in tests: |
| 491 if count % shard_count == shard_run - 1: | 494 if count % shard_count == shard_run - 1: |
| 492 shard.append(test) | 495 shard.append(test) |
| 493 count += 1 | 496 count += 1 |
| 494 return shard | 497 return shard |
| 495 | 498 |
| 496 | 499 |
| 497 def Main(): | 500 def Main(): |
| 501 # Use the v8 root as cwd as some test cases use "load" with relative paths. |
| 502 os.chdir(BASE_DIR) |
| 503 |
| 498 parser = BuildOptions() | 504 parser = BuildOptions() |
| 499 (options, args) = parser.parse_args() | 505 (options, args) = parser.parse_args() |
| 500 if not ProcessOptions(options): | 506 if not ProcessOptions(options): |
| 501 parser.print_help() | 507 parser.print_help() |
| 502 return 1 | 508 return 1 |
| 503 | 509 |
| 504 exit_code = 0 | 510 exit_code = 0 |
| 505 workspace = os.path.abspath(join(os.path.dirname(sys.argv[0]), "..")) | |
| 506 if not options.no_presubmit: | 511 if not options.no_presubmit: |
| 507 print ">>> running presubmit tests" | 512 print ">>> running presubmit tests" |
| 508 exit_code = subprocess.call( | 513 exit_code = subprocess.call( |
| 509 [sys.executable, join(workspace, "tools", "presubmit.py")]) | 514 [sys.executable, join(BASE_DIR, "tools", "presubmit.py")]) |
| 510 | 515 |
| 511 suite_paths = utils.GetSuitePaths(join(workspace, "test")) | 516 suite_paths = utils.GetSuitePaths(join(BASE_DIR, "test")) |
| 512 | 517 |
| 513 # Use default tests if no test configuration was provided at the cmd line. | 518 # Use default tests if no test configuration was provided at the cmd line. |
| 514 if len(args) == 0: | 519 if len(args) == 0: |
| 515 args = ["default"] | 520 args = ["default"] |
| 516 | 521 |
| 517 # Expand arguments with grouped tests. The args should reflect the list of | 522 # Expand arguments with grouped tests. The args should reflect the list of |
| 518 # suites as otherwise filters would break. | 523 # suites as otherwise filters would break. |
| 519 def ExpandTestGroups(name): | 524 def ExpandTestGroups(name): |
| 520 if name in TEST_MAP: | 525 if name in TEST_MAP: |
| 521 return [suite for suite in TEST_MAP[arg]] | 526 return [suite for suite in TEST_MAP[arg]] |
| 522 else: | 527 else: |
| 523 return [name] | 528 return [name] |
| 524 args = reduce(lambda x, y: x + y, | 529 args = reduce(lambda x, y: x + y, |
| 525 [ExpandTestGroups(arg) for arg in args], | 530 [ExpandTestGroups(arg) for arg in args], |
| 526 []) | 531 []) |
| 527 | 532 |
| 528 args_suites = OrderedDict() # Used as set | 533 args_suites = OrderedDict() # Used as set |
| 529 for arg in args: | 534 for arg in args: |
| 530 args_suites[arg.split('/')[0]] = True | 535 args_suites[arg.split('/')[0]] = True |
| 531 suite_paths = [ s for s in args_suites if s in suite_paths ] | 536 suite_paths = [ s for s in args_suites if s in suite_paths ] |
| 532 | 537 |
| 533 suites = [] | 538 suites = [] |
| 534 for root in suite_paths: | 539 for root in suite_paths: |
| 535 suite = testsuite.TestSuite.LoadTestSuite( | 540 suite = testsuite.TestSuite.LoadTestSuite( |
| 536 os.path.join(workspace, "test", root)) | 541 os.path.join(BASE_DIR, "test", root)) |
| 537 if suite: | 542 if suite: |
| 538 suites.append(suite) | 543 suites.append(suite) |
| 539 | 544 |
| 540 if options.download_data or options.download_data_only: | 545 if options.download_data or options.download_data_only: |
| 541 for s in suites: | 546 for s in suites: |
| 542 s.DownloadData() | 547 s.DownloadData() |
| 543 | 548 |
| 544 if options.download_data_only: | 549 if options.download_data_only: |
| 545 return exit_code | 550 return exit_code |
| 546 | 551 |
| 547 for (arch, mode) in options.arch_and_mode: | 552 for (arch, mode) in options.arch_and_mode: |
| 548 try: | 553 try: |
| 549 code = Execute(arch, mode, args, options, suites, workspace) | 554 code = Execute(arch, mode, args, options, suites) |
| 550 except KeyboardInterrupt: | 555 except KeyboardInterrupt: |
| 551 return 2 | 556 return 2 |
| 552 exit_code = exit_code or code | 557 exit_code = exit_code or code |
| 553 return exit_code | 558 return exit_code |
| 554 | 559 |
| 555 | 560 |
| 556 def Execute(arch, mode, args, options, suites, workspace): | 561 def Execute(arch, mode, args, options, suites): |
| 557 print(">>> Running tests for %s.%s" % (arch, mode)) | 562 print(">>> Running tests for %s.%s" % (arch, mode)) |
| 558 | 563 |
| 559 shell_dir = options.shell_dir | 564 shell_dir = options.shell_dir |
| 560 if not shell_dir: | 565 if not shell_dir: |
| 561 if options.buildbot: | 566 if options.buildbot: |
| 562 # TODO(machenbach): Get rid of different output folder location on | 567 # TODO(machenbach): Get rid of different output folder location on |
| 563 # buildbot. Currently this is capitalized Release and Debug. | 568 # buildbot. Currently this is capitalized Release and Debug. |
| 564 shell_dir = os.path.join(workspace, options.outdir, mode) | 569 shell_dir = os.path.join(BASE_DIR, options.outdir, mode) |
| 565 mode = BuildbotToV8Mode(mode) | 570 mode = BuildbotToV8Mode(mode) |
| 566 else: | 571 else: |
| 567 shell_dir = os.path.join( | 572 shell_dir = os.path.join( |
| 568 workspace, | 573 BASE_DIR, |
| 569 options.outdir, | 574 options.outdir, |
| 570 "%s.%s" % (arch, MODES[mode]["output_folder"]), | 575 "%s.%s" % (arch, MODES[mode]["output_folder"]), |
| 571 ) | 576 ) |
| 572 shell_dir = os.path.relpath(shell_dir) | |
| 573 if not os.path.exists(shell_dir): | 577 if not os.path.exists(shell_dir): |
| 574 raise Exception('Could not find shell_dir: "%s"' % shell_dir) | 578 raise Exception('Could not find shell_dir: "%s"' % shell_dir) |
| 575 | 579 |
| 576 # Populate context object. | 580 # Populate context object. |
| 577 mode_flags = MODES[mode]["flags"] | 581 mode_flags = MODES[mode]["flags"] |
| 578 timeout = options.timeout | 582 timeout = options.timeout |
| 579 if timeout == -1: | 583 if timeout == -1: |
| 580 # Simulators are slow, therefore allow a longer default timeout. | 584 # Simulators are slow, therefore allow a longer default timeout. |
| 581 if arch in SLOW_ARCHS: | 585 if arch in SLOW_ARCHS: |
| 582 timeout = 2 * TIMEOUT_DEFAULT; | 586 timeout = 2 * TIMEOUT_DEFAULT; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 run_networked = False | 710 run_networked = False |
| 707 elif len(peers) == 1: | 711 elif len(peers) == 1: |
| 708 print("No other peers on the network; running tests locally.") | 712 print("No other peers on the network; running tests locally.") |
| 709 run_networked = False | 713 run_networked = False |
| 710 elif num_tests <= 100: | 714 elif num_tests <= 100: |
| 711 print("Less than 100 tests, running them locally.") | 715 print("Less than 100 tests, running them locally.") |
| 712 run_networked = False | 716 run_networked = False |
| 713 | 717 |
| 714 if run_networked: | 718 if run_networked: |
| 715 runner = network_execution.NetworkedRunner(suites, progress_indicator, | 719 runner = network_execution.NetworkedRunner(suites, progress_indicator, |
| 716 ctx, peers, workspace) | 720 ctx, peers, BASE_DIR) |
| 717 else: | 721 else: |
| 718 runner = execution.Runner(suites, progress_indicator, ctx) | 722 runner = execution.Runner(suites, progress_indicator, ctx) |
| 719 | 723 |
| 720 exit_code = runner.Run(options.j) | 724 exit_code = runner.Run(options.j) |
| 721 overall_duration = time.time() - start_time | 725 overall_duration = time.time() - start_time |
| 722 | 726 |
| 723 if options.time: | 727 if options.time: |
| 724 verbose.PrintTestDurations(suites, overall_duration) | 728 verbose.PrintTestDurations(suites, overall_duration) |
| 725 | 729 |
| 726 if num_tests == 0: | 730 if num_tests == 0: |
| 727 print("Warning: no tests were run!") | 731 print("Warning: no tests were run!") |
| 728 | 732 |
| 729 return exit_code | 733 return exit_code |
| 730 | 734 |
| 731 | 735 |
| 732 if __name__ == "__main__": | 736 if __name__ == "__main__": |
| 733 sys.exit(Main()) | 737 sys.exit(Main()) |
| OLD | NEW |