| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs all types of tests from one unified interface.""" | 7 """Runs all types of tests from one unified interface.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import collections | 10 import collections |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 from devil.utils import reraiser_thread | 24 from devil.utils import reraiser_thread |
| 25 from devil.utils import run_tests_helper | 25 from devil.utils import run_tests_helper |
| 26 | 26 |
| 27 from pylib import constants | 27 from pylib import constants |
| 28 from pylib import forwarder | 28 from pylib import forwarder |
| 29 from pylib.base import base_test_result | 29 from pylib.base import base_test_result |
| 30 from pylib.base import environment_factory | 30 from pylib.base import environment_factory |
| 31 from pylib.base import test_dispatcher | 31 from pylib.base import test_dispatcher |
| 32 from pylib.base import test_instance_factory | 32 from pylib.base import test_instance_factory |
| 33 from pylib.base import test_run_factory | 33 from pylib.base import test_run_factory |
| 34 from pylib.gtest import gtest_config |
| 35 from pylib.gtest import setup as gtest_setup |
| 36 from pylib.gtest import test_options as gtest_test_options |
| 34 from pylib.linker import setup as linker_setup | 37 from pylib.linker import setup as linker_setup |
| 35 from pylib.host_driven import setup as host_driven_setup | 38 from pylib.host_driven import setup as host_driven_setup |
| 36 from pylib.instrumentation import setup as instrumentation_setup | 39 from pylib.instrumentation import setup as instrumentation_setup |
| 37 from pylib.instrumentation import test_options as instrumentation_test_options | 40 from pylib.instrumentation import test_options as instrumentation_test_options |
| 38 from pylib.junit import setup as junit_setup | 41 from pylib.junit import setup as junit_setup |
| 39 from pylib.junit import test_dispatcher as junit_dispatcher | 42 from pylib.junit import test_dispatcher as junit_dispatcher |
| 40 from pylib.monkey import setup as monkey_setup | 43 from pylib.monkey import setup as monkey_setup |
| 41 from pylib.monkey import test_options as monkey_test_options | 44 from pylib.monkey import test_options as monkey_test_options |
| 42 from pylib.perf import setup as perf_setup | 45 from pylib.perf import setup as perf_setup |
| 43 from pylib.perf import test_options as perf_test_options | 46 from pylib.perf import test_options as perf_test_options |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 '(use --tool help to list them)')) | 186 '(use --tool help to list them)')) |
| 184 group.add_argument('-d', '--device', dest='test_device', | 187 group.add_argument('-d', '--device', dest='test_device', |
| 185 help=('Target device for the test suite ' | 188 help=('Target device for the test suite ' |
| 186 'to run on.')) | 189 'to run on.')) |
| 187 group.add_argument('--blacklist-file', help='Device blacklist file.') | 190 group.add_argument('--blacklist-file', help='Device blacklist file.') |
| 188 | 191 |
| 189 | 192 |
| 190 def AddGTestOptions(parser): | 193 def AddGTestOptions(parser): |
| 191 """Adds gtest options to |parser|.""" | 194 """Adds gtest options to |parser|.""" |
| 192 | 195 |
| 196 gtest_suites = list(gtest_config.STABLE_TEST_SUITES |
| 197 + gtest_config.EXPERIMENTAL_TEST_SUITES) |
| 198 |
| 193 group = parser.add_argument_group('GTest Options') | 199 group = parser.add_argument_group('GTest Options') |
| 194 group.add_argument('-s', '--suite', dest='suite_name', | 200 group.add_argument('-s', '--suite', dest='suite_name', |
| 195 nargs='+', metavar='SUITE_NAME', required=True, | 201 nargs='+', metavar='SUITE_NAME', required=True, |
| 196 help='Executable name of the test suite to run.') | 202 help=('Executable name of the test suite to run. ' |
| 203 'Available suites include (but are not limited to): ' |
| 204 '%s' % ', '.join('"%s"' % s for s in gtest_suites))) |
| 197 group.add_argument('--gtest_also_run_disabled_tests', | 205 group.add_argument('--gtest_also_run_disabled_tests', |
| 198 '--gtest-also-run-disabled-tests', | 206 '--gtest-also-run-disabled-tests', |
| 199 dest='run_disabled', action='store_true', | 207 dest='run_disabled', action='store_true', |
| 200 help='Also run disabled tests if applicable.') | 208 help='Also run disabled tests if applicable.') |
| 201 group.add_argument('-a', '--test-arguments', dest='test_arguments', | 209 group.add_argument('-a', '--test-arguments', dest='test_arguments', |
| 202 default='', | 210 default='', |
| 203 help='Additional arguments to pass to the test.') | 211 help='Additional arguments to pass to the test.') |
| 204 group.add_argument('-t', dest='timeout', type=int, default=60, | 212 group.add_argument('-t', dest='timeout', type=int, default=60, |
| 205 help='Timeout to wait for each test ' | 213 help='Timeout to wait for each test ' |
| 206 '(default: %(default)s).') | 214 '(default: %(default)s).') |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 643 |
| 636 def AddPythonTestOptions(parser): | 644 def AddPythonTestOptions(parser): |
| 637 group = parser.add_argument_group('Python Test Options') | 645 group = parser.add_argument_group('Python Test Options') |
| 638 group.add_argument( | 646 group.add_argument( |
| 639 '-s', '--suite', dest='suite_name', metavar='SUITE_NAME', | 647 '-s', '--suite', dest='suite_name', metavar='SUITE_NAME', |
| 640 choices=constants.PYTHON_UNIT_TEST_SUITES.keys(), | 648 choices=constants.PYTHON_UNIT_TEST_SUITES.keys(), |
| 641 help='Name of the test suite to run.') | 649 help='Name of the test suite to run.') |
| 642 AddCommonOptions(parser) | 650 AddCommonOptions(parser) |
| 643 | 651 |
| 644 | 652 |
| 653 def _RunGTests(args, devices): |
| 654 """Subcommand of RunTestsCommands which runs gtests.""" |
| 655 exit_code = 0 |
| 656 for suite_name in args.suite_name: |
| 657 # TODO(jbudorick): Either deprecate multi-suite or move its handling down |
| 658 # into the gtest code. |
| 659 gtest_options = gtest_test_options.GTestOptions( |
| 660 args.tool, |
| 661 args.test_filter, |
| 662 args.run_disabled, |
| 663 args.test_arguments, |
| 664 args.timeout, |
| 665 args.isolate_file_path, |
| 666 suite_name, |
| 667 args.app_data_files, |
| 668 args.app_data_file_dir, |
| 669 args.delete_stale_data) |
| 670 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) |
| 671 |
| 672 results, test_exit_code = test_dispatcher.RunTests( |
| 673 tests, runner_factory, devices, shard=True, test_timeout=None, |
| 674 num_retries=args.num_retries) |
| 675 |
| 676 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: |
| 677 exit_code = test_exit_code |
| 678 |
| 679 report_results.LogFull( |
| 680 results=results, |
| 681 test_type='Unit test', |
| 682 test_package=suite_name, |
| 683 flakiness_server=args.flakiness_dashboard_server) |
| 684 |
| 685 if args.json_results_file: |
| 686 json_results.GenerateJsonResultsFile(results, args.json_results_file) |
| 687 |
| 688 return exit_code |
| 689 |
| 690 |
| 645 def _RunLinkerTests(args, devices): | 691 def _RunLinkerTests(args, devices): |
| 646 """Subcommand of RunTestsCommands which runs linker tests.""" | 692 """Subcommand of RunTestsCommands which runs linker tests.""" |
| 647 runner_factory, tests = linker_setup.Setup(args, devices) | 693 runner_factory, tests = linker_setup.Setup(args, devices) |
| 648 | 694 |
| 649 results, exit_code = test_dispatcher.RunTests( | 695 results, exit_code = test_dispatcher.RunTests( |
| 650 tests, runner_factory, devices, shard=True, test_timeout=60, | 696 tests, runner_factory, devices, shard=True, test_timeout=60, |
| 651 num_retries=args.num_retries) | 697 num_retries=args.num_retries) |
| 652 | 698 |
| 653 report_results.LogFull( | 699 report_results.LogFull( |
| 654 results=results, | 700 results=results, |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 if e.is_infra_error: | 1061 if e.is_infra_error: |
| 1016 return constants.INFRA_EXIT_CODE | 1062 return constants.INFRA_EXIT_CODE |
| 1017 return constants.ERROR_EXIT_CODE | 1063 return constants.ERROR_EXIT_CODE |
| 1018 except: # pylint: disable=W0702 | 1064 except: # pylint: disable=W0702 |
| 1019 logging.exception('Unrecognized error occurred.') | 1065 logging.exception('Unrecognized error occurred.') |
| 1020 return constants.ERROR_EXIT_CODE | 1066 return constants.ERROR_EXIT_CODE |
| 1021 | 1067 |
| 1022 | 1068 |
| 1023 if __name__ == '__main__': | 1069 if __name__ == '__main__': |
| 1024 sys.exit(main()) | 1070 sys.exit(main()) |
| OLD | NEW |