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 | |
37 from pylib.linker import setup as linker_setup | 34 from pylib.linker import setup as linker_setup |
38 from pylib.host_driven import setup as host_driven_setup | 35 from pylib.host_driven import setup as host_driven_setup |
39 from pylib.instrumentation import setup as instrumentation_setup | 36 from pylib.instrumentation import setup as instrumentation_setup |
40 from pylib.instrumentation import test_options as instrumentation_test_options | 37 from pylib.instrumentation import test_options as instrumentation_test_options |
41 from pylib.junit import setup as junit_setup | 38 from pylib.junit import setup as junit_setup |
42 from pylib.junit import test_dispatcher as junit_dispatcher | 39 from pylib.junit import test_dispatcher as junit_dispatcher |
43 from pylib.monkey import setup as monkey_setup | 40 from pylib.monkey import setup as monkey_setup |
44 from pylib.monkey import test_options as monkey_test_options | 41 from pylib.monkey import test_options as monkey_test_options |
45 from pylib.perf import setup as perf_setup | 42 from pylib.perf import setup as perf_setup |
46 from pylib.perf import test_options as perf_test_options | 43 from pylib.perf import test_options as perf_test_options |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 '(use --tool help to list them)')) | 183 '(use --tool help to list them)')) |
187 group.add_argument('-d', '--device', dest='test_device', | 184 group.add_argument('-d', '--device', dest='test_device', |
188 help=('Target device for the test suite ' | 185 help=('Target device for the test suite ' |
189 'to run on.')) | 186 'to run on.')) |
190 group.add_argument('--blacklist-file', help='Device blacklist file.') | 187 group.add_argument('--blacklist-file', help='Device blacklist file.') |
191 | 188 |
192 | 189 |
193 def AddGTestOptions(parser): | 190 def AddGTestOptions(parser): |
194 """Adds gtest options to |parser|.""" | 191 """Adds gtest options to |parser|.""" |
195 | 192 |
196 gtest_suites = list(gtest_config.STABLE_TEST_SUITES | |
197 + gtest_config.EXPERIMENTAL_TEST_SUITES) | |
198 | |
199 group = parser.add_argument_group('GTest Options') | 193 group = parser.add_argument_group('GTest Options') |
200 group.add_argument('-s', '--suite', dest='suite_name', | 194 group.add_argument('-s', '--suite', dest='suite_name', |
201 nargs='+', metavar='SUITE_NAME', required=True, | 195 nargs='+', metavar='SUITE_NAME', required=True, |
202 help=('Executable name of the test suite to run. ' | 196 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))) | |
205 group.add_argument('--gtest_also_run_disabled_tests', | 197 group.add_argument('--gtest_also_run_disabled_tests', |
206 '--gtest-also-run-disabled-tests', | 198 '--gtest-also-run-disabled-tests', |
207 dest='run_disabled', action='store_true', | 199 dest='run_disabled', action='store_true', |
208 help='Also run disabled tests if applicable.') | 200 help='Also run disabled tests if applicable.') |
209 group.add_argument('-a', '--test-arguments', dest='test_arguments', | 201 group.add_argument('-a', '--test-arguments', dest='test_arguments', |
210 default='', | 202 default='', |
211 help='Additional arguments to pass to the test.') | 203 help='Additional arguments to pass to the test.') |
212 group.add_argument('-t', dest='timeout', type=int, default=60, | 204 group.add_argument('-t', dest='timeout', type=int, default=60, |
213 help='Timeout to wait for each test ' | 205 help='Timeout to wait for each test ' |
214 '(default: %(default)s).') | 206 '(default: %(default)s).') |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 635 |
644 def AddPythonTestOptions(parser): | 636 def AddPythonTestOptions(parser): |
645 group = parser.add_argument_group('Python Test Options') | 637 group = parser.add_argument_group('Python Test Options') |
646 group.add_argument( | 638 group.add_argument( |
647 '-s', '--suite', dest='suite_name', metavar='SUITE_NAME', | 639 '-s', '--suite', dest='suite_name', metavar='SUITE_NAME', |
648 choices=constants.PYTHON_UNIT_TEST_SUITES.keys(), | 640 choices=constants.PYTHON_UNIT_TEST_SUITES.keys(), |
649 help='Name of the test suite to run.') | 641 help='Name of the test suite to run.') |
650 AddCommonOptions(parser) | 642 AddCommonOptions(parser) |
651 | 643 |
652 | 644 |
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 | |
691 def _RunLinkerTests(args, devices): | 645 def _RunLinkerTests(args, devices): |
692 """Subcommand of RunTestsCommands which runs linker tests.""" | 646 """Subcommand of RunTestsCommands which runs linker tests.""" |
693 runner_factory, tests = linker_setup.Setup(args, devices) | 647 runner_factory, tests = linker_setup.Setup(args, devices) |
694 | 648 |
695 results, exit_code = test_dispatcher.RunTests( | 649 results, exit_code = test_dispatcher.RunTests( |
696 tests, runner_factory, devices, shard=True, test_timeout=60, | 650 tests, runner_factory, devices, shard=True, test_timeout=60, |
697 num_retries=args.num_retries) | 651 num_retries=args.num_retries) |
698 | 652 |
699 report_results.LogFull( | 653 report_results.LogFull( |
700 results=results, | 654 results=results, |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 if e.is_infra_error: | 1015 if e.is_infra_error: |
1062 return constants.INFRA_EXIT_CODE | 1016 return constants.INFRA_EXIT_CODE |
1063 return constants.ERROR_EXIT_CODE | 1017 return constants.ERROR_EXIT_CODE |
1064 except: # pylint: disable=W0702 | 1018 except: # pylint: disable=W0702 |
1065 logging.exception('Unrecognized error occurred.') | 1019 logging.exception('Unrecognized error occurred.') |
1066 return constants.ERROR_EXIT_CODE | 1020 return constants.ERROR_EXIT_CODE |
1067 | 1021 |
1068 | 1022 |
1069 if __name__ == '__main__': | 1023 if __name__ == '__main__': |
1070 sys.exit(main()) | 1024 sys.exit(main()) |
OLD | NEW |