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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 group.add_argument('--device-type', | 145 group.add_argument('--device-type', |
146 choices=constants.VALID_DEVICE_TYPES, | 146 choices=constants.VALID_DEVICE_TYPES, |
147 help=('Type of device to run on. iOS or android')) | 147 help=('Type of device to run on. iOS or android')) |
148 group.add_argument('--device-oem', action='append', | 148 group.add_argument('--device-oem', action='append', |
149 help='Device OEM to run on.') | 149 help='Device OEM to run on.') |
150 group.add_argument('--remote-device-file', | 150 group.add_argument('--remote-device-file', |
151 help=('File with JSON to select remote device. ' | 151 help=('File with JSON to select remote device. ' |
152 'Overrides all other flags.')) | 152 'Overrides all other flags.')) |
153 group.add_argument('--remote-device-timeout', type=int, | 153 group.add_argument('--remote-device-timeout', type=int, |
154 help='Times to retry finding remote device') | 154 help='Times to retry finding remote device') |
| 155 group.add_argument('--network-config', type=int, |
| 156 help='Integer that specifies the network environment ' |
| 157 'that the tests will be run in.') |
155 | 158 |
156 device_os_group = group.add_mutually_exclusive_group() | 159 device_os_group = group.add_mutually_exclusive_group() |
157 device_os_group.add_argument('--remote-device-minimum-os', | 160 device_os_group.add_argument('--remote-device-minimum-os', |
158 help='Minimum OS on device.') | 161 help='Minimum OS on device.') |
159 device_os_group.add_argument('--remote-device-os', action='append', | 162 device_os_group.add_argument('--remote-device-os', action='append', |
160 help='OS to have on the device.') | 163 help='OS to have on the device.') |
161 | 164 |
162 api_secret_group = group.add_mutually_exclusive_group() | 165 api_secret_group = group.add_mutually_exclusive_group() |
163 api_secret_group.add_argument('--api-secret', default='', | 166 api_secret_group.add_argument('--api-secret', default='', |
164 help='API secret for remote devices.') | 167 help='API secret for remote devices.') |
165 api_secret_group.add_argument('--api-secret-file', default='', | 168 api_secret_group.add_argument('--api-secret-file', default='', |
166 help='Path to file that contains API secret.') | 169 help='Path to file that contains API secret.') |
167 | 170 |
168 api_key_group = group.add_mutually_exclusive_group() | 171 api_key_group = group.add_mutually_exclusive_group() |
169 api_key_group.add_argument('--api-key', default='', | 172 api_key_group.add_argument('--api-key', default='', |
170 help='API key for remote devices.') | 173 help='API key for remote devices.') |
171 api_key_group.add_argument('--api-key-file', default='', | 174 api_key_group.add_argument('--api-key-file', default='', |
172 help='Path to file that contains API key.') | 175 help='Path to file that contains API key.') |
173 | 176 |
174 | 177 |
175 def AddDeviceOptions(parser): | 178 def AddDeviceOptions(parser): |
176 """Adds device options to |parser|.""" | 179 """Adds device options to |parser|.""" |
177 group = parser.add_argument_group(title='Device Options') | 180 group = parser.add_argument_group(title='Device Options') |
178 group.add_argument('-c', dest='cleanup_test_files', | |
179 help='Cleanup test files on the device after run', | |
180 action='store_true') | |
181 group.add_argument('--tool', | 181 group.add_argument('--tool', |
182 dest='tool', | 182 dest='tool', |
183 help=('Run the test under a tool ' | 183 help=('Run the test under a tool ' |
184 '(use --tool help to list them)')) | 184 '(use --tool help to list them)')) |
185 group.add_argument('-d', '--device', dest='test_device', | 185 group.add_argument('-d', '--device', dest='test_device', |
186 help=('Target device for the test suite ' | 186 help=('Target device for the test suite ' |
187 'to run on.')) | 187 'to run on.')) |
188 | 188 |
189 | 189 |
190 def AddGTestOptions(parser): | 190 def AddGTestOptions(parser): |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 constants.SDK_BUILD_TEST_JAVALIB_DIR, | 365 constants.SDK_BUILD_TEST_JAVALIB_DIR, |
366 '%s.jar' % args.test_apk) | 366 '%s.jar' % args.test_apk) |
367 args.test_support_apk_path = '%sSupport%s' % ( | 367 args.test_support_apk_path = '%sSupport%s' % ( |
368 os.path.splitext(args.test_apk_path)) | 368 os.path.splitext(args.test_apk_path)) |
369 | 369 |
370 args.test_runner = apk_helper.GetInstrumentationName(args.test_apk_path) | 370 args.test_runner = apk_helper.GetInstrumentationName(args.test_apk_path) |
371 | 371 |
372 # TODO(jbudorick): Get rid of InstrumentationOptions. | 372 # TODO(jbudorick): Get rid of InstrumentationOptions. |
373 return instrumentation_test_options.InstrumentationOptions( | 373 return instrumentation_test_options.InstrumentationOptions( |
374 args.tool, | 374 args.tool, |
375 args.cleanup_test_files, | |
376 args.annotations, | 375 args.annotations, |
377 args.exclude_annotations, | 376 args.exclude_annotations, |
378 args.test_filter, | 377 args.test_filter, |
379 args.test_data, | 378 args.test_data, |
380 args.save_perf_json, | 379 args.save_perf_json, |
381 args.screenshot_failures, | 380 args.screenshot_failures, |
382 args.wait_for_debugger, | 381 args.wait_for_debugger, |
383 args.coverage_dir, | 382 args.coverage_dir, |
384 args.test_apk, | 383 args.test_apk, |
385 args.test_apk_path, | 384 args.test_apk_path, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 args.uiautomator_jar = os.path.join( | 429 args.uiautomator_jar = os.path.join( |
431 constants.GetOutDirectory(), | 430 constants.GetOutDirectory(), |
432 constants.SDK_BUILD_JAVALIB_DIR, | 431 constants.SDK_BUILD_JAVALIB_DIR, |
433 '%s.dex.jar' % args.test_jar) | 432 '%s.dex.jar' % args.test_jar) |
434 args.uiautomator_info_jar = ( | 433 args.uiautomator_info_jar = ( |
435 args.uiautomator_jar[:args.uiautomator_jar.find('.dex.jar')] + | 434 args.uiautomator_jar[:args.uiautomator_jar.find('.dex.jar')] + |
436 '_java.jar') | 435 '_java.jar') |
437 | 436 |
438 return uiautomator_test_options.UIAutomatorOptions( | 437 return uiautomator_test_options.UIAutomatorOptions( |
439 args.tool, | 438 args.tool, |
440 args.cleanup_test_files, | |
441 args.annotations, | 439 args.annotations, |
442 args.exclude_annotations, | 440 args.exclude_annotations, |
443 args.test_filter, | 441 args.test_filter, |
444 args.test_data, | 442 args.test_data, |
445 args.save_perf_json, | 443 args.save_perf_json, |
446 args.screenshot_failures, | 444 args.screenshot_failures, |
447 args.uiautomator_jar, | 445 args.uiautomator_jar, |
448 args.uiautomator_info_jar, | 446 args.uiautomator_info_jar, |
449 args.package, | 447 args.package, |
450 args.set_asserts) | 448 args.set_asserts) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 627 |
630 | 628 |
631 def _RunGTests(args, devices): | 629 def _RunGTests(args, devices): |
632 """Subcommand of RunTestsCommands which runs gtests.""" | 630 """Subcommand of RunTestsCommands which runs gtests.""" |
633 exit_code = 0 | 631 exit_code = 0 |
634 for suite_name in args.suite_name: | 632 for suite_name in args.suite_name: |
635 # TODO(jbudorick): Either deprecate multi-suite or move its handling down | 633 # TODO(jbudorick): Either deprecate multi-suite or move its handling down |
636 # into the gtest code. | 634 # into the gtest code. |
637 gtest_options = gtest_test_options.GTestOptions( | 635 gtest_options = gtest_test_options.GTestOptions( |
638 args.tool, | 636 args.tool, |
639 args.cleanup_test_files, | |
640 args.test_filter, | 637 args.test_filter, |
641 args.run_disabled, | 638 args.run_disabled, |
642 args.test_arguments, | 639 args.test_arguments, |
643 args.timeout, | 640 args.timeout, |
644 args.isolate_file_path, | 641 args.isolate_file_path, |
645 suite_name) | 642 suite_name) |
646 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) | 643 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) |
647 | 644 |
648 results, test_exit_code = test_dispatcher.RunTests( | 645 results, test_exit_code = test_dispatcher.RunTests( |
649 tests, runner_factory, devices, shard=True, test_timeout=None, | 646 tests, runner_factory, devices, shard=True, test_timeout=None, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 | 758 |
762 if args.json_results_file: | 759 if args.json_results_file: |
763 json_results.GenerateJsonResultsFile(results, args.json_results_file) | 760 json_results.GenerateJsonResultsFile(results, args.json_results_file) |
764 | 761 |
765 return exit_code | 762 return exit_code |
766 | 763 |
767 | 764 |
768 def _RunJUnitTests(args): | 765 def _RunJUnitTests(args): |
769 """Subcommand of RunTestsCommand which runs junit tests.""" | 766 """Subcommand of RunTestsCommand which runs junit tests.""" |
770 runner_factory, tests = junit_setup.Setup(args) | 767 runner_factory, tests = junit_setup.Setup(args) |
771 _, exit_code = junit_dispatcher.RunTests(tests, runner_factory) | 768 results, exit_code = junit_dispatcher.RunTests(tests, runner_factory) |
| 769 |
| 770 report_results.LogFull( |
| 771 results=results, |
| 772 test_type='JUnit', |
| 773 test_package=args.test_suite) |
| 774 |
| 775 if args.json_results_file: |
| 776 json_results.GenerateJsonResultsFile(results, args.json_results_file) |
| 777 |
772 return exit_code | 778 return exit_code |
773 | 779 |
774 | 780 |
775 def _RunMonkeyTests(args, devices): | 781 def _RunMonkeyTests(args, devices): |
776 """Subcommand of RunTestsCommands which runs monkey tests.""" | 782 """Subcommand of RunTestsCommands which runs monkey tests.""" |
777 monkey_options = ProcessMonkeyTestOptions(args) | 783 monkey_options = ProcessMonkeyTestOptions(args) |
778 | 784 |
779 runner_factory, tests = monkey_setup.Setup(monkey_options) | 785 runner_factory, tests = monkey_setup.Setup(monkey_options) |
780 | 786 |
781 results, exit_code = test_dispatcher.RunTests( | 787 results, exit_code = test_dispatcher.RunTests( |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 return constants.INFRA_EXIT_CODE | 1029 return constants.INFRA_EXIT_CODE |
1024 else: | 1030 else: |
1025 return constants.ERROR_EXIT_CODE | 1031 return constants.ERROR_EXIT_CODE |
1026 except: # pylint: disable=W0702 | 1032 except: # pylint: disable=W0702 |
1027 logging.exception('Unrecognized error occurred.') | 1033 logging.exception('Unrecognized error occurred.') |
1028 return constants.ERROR_EXIT_CODE | 1034 return constants.ERROR_EXIT_CODE |
1029 | 1035 |
1030 | 1036 |
1031 if __name__ == '__main__': | 1037 if __name__ == '__main__': |
1032 sys.exit(main()) | 1038 sys.exit(main()) |
OLD | NEW |