| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 def AddRemoteDeviceOptions(parser): | 122 def AddRemoteDeviceOptions(parser): |
| 123 group = parser.add_argument_group('Remote Device Options') | 123 group = parser.add_argument_group('Remote Device Options') |
| 124 | 124 |
| 125 group.add_argument('--trigger', default='', | 125 group.add_argument('--trigger', default='', |
| 126 help=('Only triggers the test if set. Stores test_run_id ' | 126 help=('Only triggers the test if set. Stores test_run_id ' |
| 127 'in given file path. ')) | 127 'in given file path. ')) |
| 128 group.add_argument('--collect', default='', | 128 group.add_argument('--collect', default='', |
| 129 help=('Only collects the test results if set. ' | 129 help=('Only collects the test results if set. ' |
| 130 'Gets test_run_id from given file path.')) | 130 'Gets test_run_id from given file path.')) |
| 131 group.add_argument('--remote-device', default='Nexus 5', | 131 group.add_argument('--remote-device', default='', |
| 132 help=('Device type to run test on.')) | 132 help=('Device type to run test on.')) |
| 133 group.add_argument('--remote-device-os', default='4.4.2', | 133 group.add_argument('--remote-device-os', default='', |
| 134 help=('OS to have on the device.')) | 134 help=('OS to have on the device.')) |
| 135 group.add_argument('--results-path', default='', | 135 group.add_argument('--results-path', default='', |
| 136 help=('File path to download results to.')) | 136 help=('File path to download results to.')) |
| 137 group.add_argument('--api-protocol', | 137 group.add_argument('--api-protocol', |
| 138 help=('HTTP protocol to use. (http or https)')) | 138 help=('HTTP protocol to use. (http or https)')) |
| 139 group.add_argument('--api-address', help=('Address to send HTTP requests.')) | 139 group.add_argument('--api-address', help=('Address to send HTTP requests.')) |
| 140 group.add_argument('--api-port', help=('Port to send HTTP requests to.')) | 140 group.add_argument('--api-port', help=('Port to send HTTP requests to.')) |
| 141 group.add_argument('--runner-type', default='', | 141 group.add_argument('--runner-type', default='', |
| 142 help=('Type of test to run as.')) | 142 help=('Type of test to run as.')) |
| 143 group.add_argument('--runner-package', default='', | 143 group.add_argument('--runner-package', default='', |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 help='Saves the JSON file for each UI Perf test.') | 240 help='Saves the JSON file for each UI Perf test.') |
| 241 argument_group.add_argument( | 241 argument_group.add_argument( |
| 242 '--official-build', action='store_true', help='Run official build tests.') | 242 '--official-build', action='store_true', help='Run official build tests.') |
| 243 argument_group.add_argument( | 243 argument_group.add_argument( |
| 244 '--test_data', '--test-data', action='append', default=[], | 244 '--test_data', '--test-data', action='append', default=[], |
| 245 help=('Each instance defines a directory of test data that should be ' | 245 help=('Each instance defines a directory of test data that should be ' |
| 246 'copied to the target(s) before running the tests. The argument ' | 246 'copied to the target(s) before running the tests. The argument ' |
| 247 'should be of the form <target>:<source>, <target> is relative to ' | 247 'should be of the form <target>:<source>, <target> is relative to ' |
| 248 'the device data directory, and <source> is relative to the ' | 248 'the device data directory, and <source> is relative to the ' |
| 249 'chromium build directory.')) | 249 'chromium build directory.')) |
| 250 argument_group.add_argument( |
| 251 '--disable-dalvik-asserts', dest='set_asserts', action='store_false', |
| 252 default=True, help='Removes the dalvik.vm.enableassertions property') |
| 253 |
| 250 | 254 |
| 251 | 255 |
| 252 def ProcessJavaTestOptions(args): | 256 def ProcessJavaTestOptions(args): |
| 253 """Processes options/arguments and populates |options| with defaults.""" | 257 """Processes options/arguments and populates |options| with defaults.""" |
| 254 | 258 |
| 255 # TODO(jbudorick): Handle most of this function in argparse. | 259 # TODO(jbudorick): Handle most of this function in argparse. |
| 256 if args.annotation_str: | 260 if args.annotation_str: |
| 257 args.annotations = args.annotation_str.split(',') | 261 args.annotations = args.annotation_str.split(',') |
| 258 elif args.test_filter: | 262 elif args.test_filter: |
| 259 args.annotations = [] | 263 args.annotations = [] |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 args.save_perf_json, | 353 args.save_perf_json, |
| 350 args.screenshot_failures, | 354 args.screenshot_failures, |
| 351 args.wait_for_debugger, | 355 args.wait_for_debugger, |
| 352 args.coverage_dir, | 356 args.coverage_dir, |
| 353 args.test_apk, | 357 args.test_apk, |
| 354 args.test_apk_path, | 358 args.test_apk_path, |
| 355 args.test_apk_jar_path, | 359 args.test_apk_jar_path, |
| 356 args.test_runner, | 360 args.test_runner, |
| 357 args.test_support_apk_path, | 361 args.test_support_apk_path, |
| 358 args.device_flags, | 362 args.device_flags, |
| 359 args.isolate_file_path | 363 args.isolate_file_path, |
| 364 args.set_asserts |
| 360 ) | 365 ) |
| 361 | 366 |
| 362 | 367 |
| 363 def AddUIAutomatorTestOptions(parser): | 368 def AddUIAutomatorTestOptions(parser): |
| 364 """Adds UI Automator test options to |parser|.""" | 369 """Adds UI Automator test options to |parser|.""" |
| 365 | 370 |
| 366 group = parser.add_argument_group('UIAutomator Test Options') | 371 group = parser.add_argument_group('UIAutomator Test Options') |
| 367 AddJavaTestOptions(group) | 372 AddJavaTestOptions(group) |
| 368 group.add_argument( | 373 group.add_argument( |
| 369 '--package', required=True, choices=constants.PACKAGE_INFO.keys(), | 374 '--package', required=True, choices=constants.PACKAGE_INFO.keys(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 args.tool, | 412 args.tool, |
| 408 args.cleanup_test_files, | 413 args.cleanup_test_files, |
| 409 args.annotations, | 414 args.annotations, |
| 410 args.exclude_annotations, | 415 args.exclude_annotations, |
| 411 args.test_filter, | 416 args.test_filter, |
| 412 args.test_data, | 417 args.test_data, |
| 413 args.save_perf_json, | 418 args.save_perf_json, |
| 414 args.screenshot_failures, | 419 args.screenshot_failures, |
| 415 args.uiautomator_jar, | 420 args.uiautomator_jar, |
| 416 args.uiautomator_info_jar, | 421 args.uiautomator_info_jar, |
| 417 args.package) | 422 args.package, |
| 423 args.set_asserts) |
| 418 | 424 |
| 419 | 425 |
| 420 def AddJUnitTestOptions(parser): | 426 def AddJUnitTestOptions(parser): |
| 421 """Adds junit test options to |parser|.""" | 427 """Adds junit test options to |parser|.""" |
| 422 | 428 |
| 423 group = parser.add_argument_group('JUnit Test Options') | 429 group = parser.add_argument_group('JUnit Test Options') |
| 424 group.add_argument( | 430 group.add_argument( |
| 425 '-s', '--test-suite', dest='test_suite', required=True, | 431 '-s', '--test-suite', dest='test_suite', required=True, |
| 426 help=('JUnit test suite to run.')) | 432 help=('JUnit test suite to run.')) |
| 427 group.add_argument( | 433 group.add_argument( |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 766 |
| 761 def _RunPerfTests(args): | 767 def _RunPerfTests(args): |
| 762 """Subcommand of RunTestsCommands which runs perf tests.""" | 768 """Subcommand of RunTestsCommands which runs perf tests.""" |
| 763 perf_options = ProcessPerfTestOptions(args) | 769 perf_options = ProcessPerfTestOptions(args) |
| 764 | 770 |
| 765 # Just save a simple json with a list of test names. | 771 # Just save a simple json with a list of test names. |
| 766 if perf_options.output_json_list: | 772 if perf_options.output_json_list: |
| 767 return perf_test_runner.OutputJsonList( | 773 return perf_test_runner.OutputJsonList( |
| 768 perf_options.steps, perf_options.output_json_list) | 774 perf_options.steps, perf_options.output_json_list) |
| 769 | 775 |
| 770 if perf_options.output_chartjson_data: | |
| 771 return perf_test_runner.OutputChartjson( | |
| 772 perf_options.print_step, perf_options.output_chartjson_data) | |
| 773 | |
| 774 # Just print the results from a single previously executed step. | 776 # Just print the results from a single previously executed step. |
| 775 if perf_options.print_step: | 777 if perf_options.print_step: |
| 776 return perf_test_runner.PrintTestOutput(perf_options.print_step) | 778 return perf_test_runner.PrintTestOutput( |
| 779 perf_options.print_step, perf_options.output_chartjson_data) |
| 777 | 780 |
| 778 runner_factory, tests, devices = perf_setup.Setup(perf_options) | 781 runner_factory, tests, devices = perf_setup.Setup(perf_options) |
| 779 | 782 |
| 780 # shard=False means that each device will get the full list of tests | 783 # shard=False means that each device will get the full list of tests |
| 781 # and then each one will decide their own affinity. | 784 # and then each one will decide their own affinity. |
| 782 # shard=True means each device will pop the next test available from a queue, | 785 # shard=True means each device will pop the next test available from a queue, |
| 783 # which increases throughput but have no affinity. | 786 # which increases throughput but have no affinity. |
| 784 results, _ = test_dispatcher.RunTests( | 787 results, _ = test_dispatcher.RunTests( |
| 785 tests, runner_factory, devices, shard=False, test_timeout=None, | 788 tests, runner_factory, devices, shard=False, test_timeout=None, |
| 786 num_retries=args.num_retries) | 789 num_retries=args.num_retries) |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 subparser = command_parsers.add_parser( | 981 subparser = command_parsers.add_parser( |
| 979 test_type, usage='%(prog)s [options]', help=config.help_txt) | 982 test_type, usage='%(prog)s [options]', help=config.help_txt) |
| 980 config.add_options_func(subparser) | 983 config.add_options_func(subparser) |
| 981 | 984 |
| 982 args = parser.parse_args() | 985 args = parser.parse_args() |
| 983 return RunTestsCommand(args, parser) | 986 return RunTestsCommand(args, parser) |
| 984 | 987 |
| 985 | 988 |
| 986 if __name__ == '__main__': | 989 if __name__ == '__main__': |
| 987 sys.exit(main()) | 990 sys.exit(main()) |
| OLD | NEW |