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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 '-f', '--test-filter', | 581 '-f', '--test-filter', |
582 help=('Test filter (will match against the names listed in --steps).')) | 582 help=('Test filter (will match against the names listed in --steps).')) |
583 group.add_argument( | 583 group.add_argument( |
584 '--dry-run', action='store_true', | 584 '--dry-run', action='store_true', |
585 help='Just print the steps without executing.') | 585 help='Just print the steps without executing.') |
586 # Uses 0.1 degrees C because that's what Android does. | 586 # Uses 0.1 degrees C because that's what Android does. |
587 group.add_argument( | 587 group.add_argument( |
588 '--max-battery-temp', type=int, | 588 '--max-battery-temp', type=int, |
589 help='Only start tests when the battery is at or below the given ' | 589 help='Only start tests when the battery is at or below the given ' |
590 'temperature (0.1 C)') | 590 'temperature (0.1 C)') |
591 group.add_argument('single_step_command', nargs='*', action=SingleStepAction, | 591 group.add_argument('single_step_command', nargs='*', action=SingleStepAction, |
jbudorick
2016/06/07 15:29:28
Can you drop these onto the next line to match the
rnephew (Reviews Here)
2016/06/09 22:06:39
Done. Except the ones that fully fit on one line.
| |
592 help='If --single-step is specified, the command to run.') | 592 help='If --single-step is specified, the command to run.') |
593 group.add_argument('--min-battery-level', type=int, | 593 group.add_argument('--min-battery-level', type=int, |
594 help='Only starts tests when the battery is charged above ' | 594 help='Only starts tests when the battery is charged above ' |
595 'given level.') | 595 'given level.') |
596 group.add_argument('--known-devices-file', help='Path to known device list.') | 596 group.add_argument('--known-devices-file', help='Path to known device list.') |
597 group.add_argument( | |
598 '--repeat', dest='repeat', type=int, default=0, | |
599 help='Number of times to repeat the specified set of tests.') | |
600 group.add_argument('--break-on-failure', '--break_on_failure', | |
601 dest='break_on_failure', action='store_true', | |
602 help='Whether to break on failure.') | |
603 group.add_argument('--write-buildbot-json', action='store_true', | |
604 help='Whether to output buildbot json.') | |
597 AddCommonOptions(parser) | 605 AddCommonOptions(parser) |
598 AddDeviceOptions(parser) | 606 AddDeviceOptions(parser) |
599 | 607 |
600 | 608 |
601 def ProcessPerfTestOptions(args): | 609 def ProcessPerfTestOptions(args): |
602 """Processes all perf test options. | 610 """Processes all perf test options. |
603 | 611 |
604 Args: | 612 Args: |
605 args: argparse.Namespace object. | 613 args: argparse.Namespace object. |
606 | 614 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 'Did not find device %s among attached device. Attached devices: %s' | 780 'Did not find device %s among attached device. Attached devices: %s' |
773 % (test_device, ', '.join(attached_devices))) | 781 % (test_device, ', '.join(attached_devices))) |
774 return test_device | 782 return test_device |
775 | 783 |
776 else: | 784 else: |
777 if not attached_devices: | 785 if not attached_devices: |
778 raise device_errors.NoDevicesError() | 786 raise device_errors.NoDevicesError() |
779 return sorted(attached_devices) | 787 return sorted(attached_devices) |
780 | 788 |
781 | 789 |
790 _DEFAULT_PLATFORM_MODE_TESTS = [' gtest', 'instrumentation', 'perf'] | |
jbudorick
2016/06/07 15:29:28
Again, this CL shouldn't jump perf tests to defaul
rnephew (Reviews Here)
2016/06/09 22:06:39
Thats why I added the do not submit to the name, I
rnephew (Reviews Here)
2016/06/27 20:23:25
Removed it, renaming to reflect that this is gone.
| |
782 def RunTestsCommand(args): # pylint: disable=too-many-return-statements | 791 def RunTestsCommand(args): # pylint: disable=too-many-return-statements |
783 """Checks test type and dispatches to the appropriate function. | 792 """Checks test type and dispatches to the appropriate function. |
784 | 793 |
785 Args: | 794 Args: |
786 args: argparse.Namespace object. | 795 args: argparse.Namespace object. |
787 | 796 |
788 Returns: | 797 Returns: |
789 Integer indicated exit code. | 798 Integer indicated exit code. |
790 | 799 |
791 Raises: | 800 Raises: |
792 Exception: Unknown command name passed in, or an exception from an | 801 Exception: Unknown command name passed in, or an exception from an |
793 individual test runner. | 802 individual test runner. |
794 """ | 803 """ |
795 command = args.command | 804 command = args.command |
796 | 805 |
797 ProcessCommonOptions(args) | 806 ProcessCommonOptions(args) |
798 logging.info('command: %s', ' '.join(sys.argv)) | 807 logging.info('command: %s', ' '.join(sys.argv)) |
799 | 808 if args.enable_platform_mode or command in _DEFAULT_PLATFORM_MODE_TESTS: |
800 if args.enable_platform_mode or command in ('gtest', 'instrumentation'): | |
801 return RunTestsInPlatformMode(args) | 809 return RunTestsInPlatformMode(args) |
802 | 810 |
803 forwarder.Forwarder.RemoveHostLog() | 811 forwarder.Forwarder.RemoveHostLog() |
804 if not ports.ResetTestServerPortAllocation(): | 812 if not ports.ResetTestServerPortAllocation(): |
805 raise Exception('Failed to reset test server port.') | 813 raise Exception('Failed to reset test server port.') |
806 | 814 |
807 def get_devices(): | 815 def get_devices(): |
808 return _GetAttachedDevices(args.blacklist_file, args.test_device, | 816 return _GetAttachedDevices(args.blacklist_file, args.test_device, |
809 args.enable_device_cache, args.num_retries) | 817 args.enable_device_cache, args.num_retries) |
810 | 818 |
811 if command == 'linker': | 819 if command == 'linker': |
812 return _RunLinkerTests(args, get_devices()) | 820 return _RunLinkerTests(args, get_devices()) |
813 elif command == 'junit': | 821 elif command == 'junit': |
814 return _RunJUnitTests(args) | 822 return _RunJUnitTests(args) |
815 elif command == 'monkey': | 823 elif command == 'monkey': |
816 return _RunMonkeyTests(args, get_devices()) | 824 return _RunMonkeyTests(args, get_devices()) |
817 elif command == 'perf': | 825 elif command == 'perf': |
818 return _RunPerfTests(args, get_devices()) | 826 return _RunPerfTests(args, get_devices()) |
819 elif command == 'python': | 827 elif command == 'python': |
820 return _RunPythonTests(args) | 828 return _RunPythonTests(args) |
821 else: | 829 else: |
822 raise Exception('Unknown test type.') | 830 raise Exception('Unknown test type.') |
823 | 831 |
824 | 832 |
825 _SUPPORTED_IN_PLATFORM_MODE = [ | 833 _SUPPORTED_IN_PLATFORM_MODE = [ |
826 # TODO(jbudorick): Add support for more test types. | 834 # TODO(jbudorick): Add support for more test types. |
827 'gtest', | 835 'gtest', |
828 'instrumentation', | 836 'instrumentation', |
837 'perf', | |
829 'uirobot', | 838 'uirobot', |
830 ] | 839 ] |
831 | 840 |
832 | 841 |
833 def RunTestsInPlatformMode(args): | 842 def RunTestsInPlatformMode(args): |
834 | 843 |
835 def infra_error(message): | 844 def infra_error(message): |
836 logging.fatal(message) | 845 logging.fatal(message) |
837 sys.exit(constants.INFRA_EXIT_CODE) | 846 sys.exit(constants.INFRA_EXIT_CODE) |
838 | 847 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 if e.is_infra_error: | 986 if e.is_infra_error: |
978 return constants.INFRA_EXIT_CODE | 987 return constants.INFRA_EXIT_CODE |
979 return constants.ERROR_EXIT_CODE | 988 return constants.ERROR_EXIT_CODE |
980 except: # pylint: disable=W0702 | 989 except: # pylint: disable=W0702 |
981 logging.exception('Unrecognized error occurred.') | 990 logging.exception('Unrecognized error occurred.') |
982 return constants.ERROR_EXIT_CODE | 991 return constants.ERROR_EXIT_CODE |
983 | 992 |
984 | 993 |
985 if __name__ == '__main__': | 994 if __name__ == '__main__': |
986 sys.exit(main()) | 995 sys.exit(main()) |
OLD | NEW |