| 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 collections | 9 import collections |
| 10 import logging | 10 import logging |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 '-E', '--exclude-annotation', dest='exclude_annotation_str', | 170 '-E', '--exclude-annotation', dest='exclude_annotation_str', |
| 171 help=('Comma-separated list of annotations. Exclude tests with these ' | 171 help=('Comma-separated list of annotations. Exclude tests with these ' |
| 172 'annotations.')) | 172 'annotations.')) |
| 173 option_parser.add_option('--screenshot', dest='screenshot_failures', | 173 option_parser.add_option('--screenshot', dest='screenshot_failures', |
| 174 action='store_true', | 174 action='store_true', |
| 175 help='Capture screenshots of test failures') | 175 help='Capture screenshots of test failures') |
| 176 option_parser.add_option('--save-perf-json', action='store_true', | 176 option_parser.add_option('--save-perf-json', action='store_true', |
| 177 help='Saves the JSON file for each UI Perf test.') | 177 help='Saves the JSON file for each UI Perf test.') |
| 178 option_parser.add_option('--official-build', action='store_true', | 178 option_parser.add_option('--official-build', action='store_true', |
| 179 help='Run official build tests.') | 179 help='Run official build tests.') |
| 180 option_parser.add_option('--keep_test_server_ports', | |
| 181 action='store_true', | |
| 182 help=('Indicates the test server ports must be ' | |
| 183 'kept. When this is run via a sharder ' | |
| 184 'the test server ports should be kept and ' | |
| 185 'should not be reset.')) | |
| 186 option_parser.add_option('--test_data', action='append', default=[], | 180 option_parser.add_option('--test_data', action='append', default=[], |
| 187 help=('Each instance defines a directory of test ' | 181 help=('Each instance defines a directory of test ' |
| 188 'data that should be copied to the target(s) ' | 182 'data that should be copied to the target(s) ' |
| 189 'before running the tests. The argument ' | 183 'before running the tests. The argument ' |
| 190 'should be of the form <target>:<source>, ' | 184 'should be of the form <target>:<source>, ' |
| 191 '<target> is relative to the device data' | 185 '<target> is relative to the device data' |
| 192 'directory, and <source> is relative to the ' | 186 'directory, and <source> is relative to the ' |
| 193 'chromium build directory.')) | 187 'chromium build directory.')) |
| 194 | 188 |
| 195 | 189 |
| 196 def ProcessJavaTestOptions(options, error_func): | 190 def ProcessJavaTestOptions(options, error_func): |
| 197 """Processes options/arguments and populates |options| with defaults.""" | 191 """Processes options/arguments and populates |options| with defaults.""" |
| 198 | 192 |
| 199 if options.annotation_str: | 193 if options.annotation_str: |
| 200 options.annotations = options.annotation_str.split(',') | 194 options.annotations = options.annotation_str.split(',') |
| 201 elif options.test_filter: | 195 elif options.test_filter: |
| 202 options.annotations = [] | 196 options.annotations = [] |
| 203 else: | 197 else: |
| 204 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest', | 198 options.annotations = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest', |
| 205 'EnormousTest'] | 199 'EnormousTest'] |
| 206 | 200 |
| 207 if options.exclude_annotation_str: | 201 if options.exclude_annotation_str: |
| 208 options.exclude_annotations = options.exclude_annotation_str.split(',') | 202 options.exclude_annotations = options.exclude_annotation_str.split(',') |
| 209 else: | 203 else: |
| 210 options.exclude_annotations = [] | 204 options.exclude_annotations = [] |
| 211 | 205 |
| 212 if not options.keep_test_server_ports: | |
| 213 if not ports.ResetTestServerPortAllocation(): | |
| 214 raise Exception('Failed to reset test server port.') | |
| 215 | |
| 216 | 206 |
| 217 def AddInstrumentationTestOptions(option_parser): | 207 def AddInstrumentationTestOptions(option_parser): |
| 218 """Adds Instrumentation test options to |option_parser|.""" | 208 """Adds Instrumentation test options to |option_parser|.""" |
| 219 | 209 |
| 220 option_parser.usage = '%prog instrumentation [options]' | 210 option_parser.usage = '%prog instrumentation [options]' |
| 221 option_parser.commands_dict = {} | 211 option_parser.commands_dict = {} |
| 222 option_parser.example = ('%prog instrumentation ' | 212 option_parser.example = ('%prog instrumentation ' |
| 223 '--test-apk=ChromiumTestShellTest') | 213 '--test-apk=ChromiumTestShellTest') |
| 224 | 214 |
| 225 AddJavaTestOptions(option_parser) | 215 AddJavaTestOptions(option_parser) |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 if ((options.single_step and len(args) <= 2) or | 703 if ((options.single_step and len(args) <= 2) or |
| 714 (not options.single_step and len(args) > 2)): | 704 (not options.single_step and len(args) > 2)): |
| 715 option_parser.error('Unrecognized arguments: %s' % (' '.join(args))) | 705 option_parser.error('Unrecognized arguments: %s' % (' '.join(args))) |
| 716 return constants.ERROR_EXIT_CODE | 706 return constants.ERROR_EXIT_CODE |
| 717 | 707 |
| 718 ProcessCommonOptions(options) | 708 ProcessCommonOptions(options) |
| 719 | 709 |
| 720 devices = _GetAttachedDevices(options.test_device) | 710 devices = _GetAttachedDevices(options.test_device) |
| 721 | 711 |
| 722 forwarder.Forwarder.RemoveHostLog() | 712 forwarder.Forwarder.RemoveHostLog() |
| 713 if not ports.ResetTestServerPortAllocation(): |
| 714 raise Exception('Failed to reset test server port.') |
| 723 | 715 |
| 724 if command == 'gtest': | 716 if command == 'gtest': |
| 725 return _RunGTests(options, option_parser.error, devices) | 717 return _RunGTests(options, option_parser.error, devices) |
| 726 elif command == 'linker': | 718 elif command == 'linker': |
| 727 return _RunLinkerTests(options, option_parser.error, devices) | 719 return _RunLinkerTests(options, option_parser.error, devices) |
| 728 elif command == 'instrumentation': | 720 elif command == 'instrumentation': |
| 729 return _RunInstrumentationTests(options, option_parser.error, devices) | 721 return _RunInstrumentationTests(options, option_parser.error, devices) |
| 730 elif command == 'uiautomator': | 722 elif command == 'uiautomator': |
| 731 return _RunUIAutomatorTests(options, option_parser.error, devices) | 723 return _RunUIAutomatorTests(options, option_parser.error, devices) |
| 732 elif command == 'monkey': | 724 elif command == 'monkey': |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 798 |
| 807 def main(argv): | 799 def main(argv): |
| 808 signal.signal(signal.SIGUSR1, DumpThreadStacks) | 800 signal.signal(signal.SIGUSR1, DumpThreadStacks) |
| 809 option_parser = command_option_parser.CommandOptionParser( | 801 option_parser = command_option_parser.CommandOptionParser( |
| 810 commands_dict=VALID_COMMANDS) | 802 commands_dict=VALID_COMMANDS) |
| 811 return command_option_parser.ParseAndExecute(option_parser) | 803 return command_option_parser.ParseAndExecute(option_parser) |
| 812 | 804 |
| 813 | 805 |
| 814 if __name__ == '__main__': | 806 if __name__ == '__main__': |
| 815 sys.exit(main(sys.argv)) | 807 sys.exit(main(sys.argv)) |
| OLD | NEW |