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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 '--output-json-list', | 555 '--output-json-list', |
556 help='Write a simple list of names from --steps into the given file.') | 556 help='Write a simple list of names from --steps into the given file.') |
557 group.add_argument( | 557 group.add_argument( |
558 '--collect-chartjson-data', | 558 '--collect-chartjson-data', |
559 action='store_true', | 559 action='store_true', |
560 help='Cache the chartjson output from each step for later use.') | 560 help='Cache the chartjson output from each step for later use.') |
561 group.add_argument( | 561 group.add_argument( |
562 '--output-chartjson-data', | 562 '--output-chartjson-data', |
563 default='', | 563 default='', |
564 help='Write out chartjson into the given file.') | 564 help='Write out chartjson into the given file.') |
| 565 # TODO(rnephew): Remove this when everything moves to new option in platform |
| 566 # mode. |
565 group.add_argument( | 567 group.add_argument( |
566 '--get-output-dir-archive', metavar='FILENAME', | 568 '--get-output-dir-archive', metavar='FILENAME', |
567 help='Write the chached output directory archived by a step into the' | 569 help='Write the cached output directory archived by a step into the' |
| 570 ' given ZIP file.') |
| 571 group.add_argument( |
| 572 '--output-dir-archive-path', metavar='FILENAME', |
| 573 help='Write the cached output directory archived by a step into the' |
568 ' given ZIP file.') | 574 ' given ZIP file.') |
569 group.add_argument( | 575 group.add_argument( |
570 '--flaky-steps', | 576 '--flaky-steps', |
571 help=('A JSON file containing steps that are flaky ' | 577 help=('A JSON file containing steps that are flaky ' |
572 'and will have its exit code ignored.')) | 578 'and will have its exit code ignored.')) |
573 group.add_argument( | 579 group.add_argument( |
574 '--no-timeout', action='store_true', | 580 '--no-timeout', action='store_true', |
575 help=('Do not impose a timeout. Each perf step is responsible for ' | 581 help=('Do not impose a timeout. Each perf step is responsible for ' |
576 'implementing the timeout logic.')) | 582 'implementing the timeout logic.')) |
577 group.add_argument( | 583 group.add_argument( |
578 '-f', '--test-filter', | 584 '-f', '--test-filter', |
579 help=('Test filter (will match against the names listed in --steps).')) | 585 help=('Test filter (will match against the names listed in --steps).')) |
580 group.add_argument( | 586 group.add_argument( |
581 '--dry-run', action='store_true', | 587 '--dry-run', action='store_true', |
582 help='Just print the steps without executing.') | 588 help='Just print the steps without executing.') |
583 # Uses 0.1 degrees C because that's what Android does. | 589 # Uses 0.1 degrees C because that's what Android does. |
584 group.add_argument( | 590 group.add_argument( |
585 '--max-battery-temp', type=int, | 591 '--max-battery-temp', type=int, |
586 help='Only start tests when the battery is at or below the given ' | 592 help='Only start tests when the battery is at or below the given ' |
587 'temperature (0.1 C)') | 593 'temperature (0.1 C)') |
588 group.add_argument('single_step_command', nargs='*', action=SingleStepAction, | 594 group.add_argument( |
589 help='If --single-step is specified, the command to run.') | 595 'single_step_command', nargs='*', action=SingleStepAction, |
590 group.add_argument('--min-battery-level', type=int, | 596 help='If --single-step is specified, the command to run.') |
591 help='Only starts tests when the battery is charged above ' | 597 group.add_argument( |
592 'given level.') | 598 '--min-battery-level', type=int, |
| 599 help='Only starts tests when the battery is charged above ' |
| 600 'given level.') |
593 group.add_argument('--known-devices-file', help='Path to known device list.') | 601 group.add_argument('--known-devices-file', help='Path to known device list.') |
| 602 group.add_argument( |
| 603 '--repeat', dest='repeat', type=int, default=0, |
| 604 help='Number of times to repeat the specified set of tests.') |
| 605 group.add_argument( |
| 606 '--break-on-failure', '--break_on_failure', dest='break_on_failure', |
| 607 action='store_true', help='Whether to break on failure.') |
| 608 group.add_argument( |
| 609 '--write-buildbot-json', action='store_true', |
| 610 help='Whether to output buildbot json.') |
594 AddCommonOptions(parser) | 611 AddCommonOptions(parser) |
595 AddDeviceOptions(parser) | 612 AddDeviceOptions(parser) |
596 | 613 |
597 | 614 |
598 def ProcessPerfTestOptions(args): | 615 def ProcessPerfTestOptions(args): |
599 """Processes all perf test options. | 616 """Processes all perf test options. |
600 | 617 |
601 Args: | 618 Args: |
602 args: argparse.Namespace object. | 619 args: argparse.Namespace object. |
603 | 620 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 'Did not find device %s among attached device. Attached devices: %s' | 786 'Did not find device %s among attached device. Attached devices: %s' |
770 % (test_device, ', '.join(attached_devices))) | 787 % (test_device, ', '.join(attached_devices))) |
771 return test_device | 788 return test_device |
772 | 789 |
773 else: | 790 else: |
774 if not attached_devices: | 791 if not attached_devices: |
775 raise device_errors.NoDevicesError() | 792 raise device_errors.NoDevicesError() |
776 return sorted(attached_devices) | 793 return sorted(attached_devices) |
777 | 794 |
778 | 795 |
| 796 # TODO(rnephew): Add perf when ready to switch to platform mode as default. |
| 797 _DEFAULT_PLATFORM_MODE_TESTS = ['gtest', 'instrumentation'] |
| 798 |
| 799 |
779 def RunTestsCommand(args): # pylint: disable=too-many-return-statements | 800 def RunTestsCommand(args): # pylint: disable=too-many-return-statements |
780 """Checks test type and dispatches to the appropriate function. | 801 """Checks test type and dispatches to the appropriate function. |
781 | 802 |
782 Args: | 803 Args: |
783 args: argparse.Namespace object. | 804 args: argparse.Namespace object. |
784 | 805 |
785 Returns: | 806 Returns: |
786 Integer indicated exit code. | 807 Integer indicated exit code. |
787 | 808 |
788 Raises: | 809 Raises: |
789 Exception: Unknown command name passed in, or an exception from an | 810 Exception: Unknown command name passed in, or an exception from an |
790 individual test runner. | 811 individual test runner. |
791 """ | 812 """ |
792 command = args.command | 813 command = args.command |
793 | 814 |
794 ProcessCommonOptions(args) | 815 ProcessCommonOptions(args) |
795 logging.info('command: %s', ' '.join(sys.argv)) | 816 logging.info('command: %s', ' '.join(sys.argv)) |
796 | 817 if args.enable_platform_mode or command in _DEFAULT_PLATFORM_MODE_TESTS: |
797 if args.enable_platform_mode or command in ('gtest', 'instrumentation'): | |
798 return RunTestsInPlatformMode(args) | 818 return RunTestsInPlatformMode(args) |
799 | 819 |
800 forwarder.Forwarder.RemoveHostLog() | 820 forwarder.Forwarder.RemoveHostLog() |
801 if not ports.ResetTestServerPortAllocation(): | 821 if not ports.ResetTestServerPortAllocation(): |
802 raise Exception('Failed to reset test server port.') | 822 raise Exception('Failed to reset test server port.') |
803 | 823 |
804 def get_devices(): | 824 def get_devices(): |
805 return _GetAttachedDevices(args.blacklist_file, args.test_device, | 825 return _GetAttachedDevices(args.blacklist_file, args.test_device, |
806 args.enable_device_cache, args.num_retries) | 826 args.enable_device_cache, args.num_retries) |
807 | 827 |
808 if command == 'linker': | 828 if command == 'linker': |
809 return _RunLinkerTests(args, get_devices()) | 829 return _RunLinkerTests(args, get_devices()) |
810 elif command == 'junit': | 830 elif command == 'junit': |
811 return _RunJUnitTests(args) | 831 return _RunJUnitTests(args) |
812 elif command == 'monkey': | 832 elif command == 'monkey': |
813 return _RunMonkeyTests(args, get_devices()) | 833 return _RunMonkeyTests(args, get_devices()) |
814 elif command == 'perf': | 834 elif command == 'perf': |
815 return _RunPerfTests(args, get_devices()) | 835 return _RunPerfTests(args, get_devices()) |
816 elif command == 'python': | 836 elif command == 'python': |
817 return _RunPythonTests(args) | 837 return _RunPythonTests(args) |
818 else: | 838 else: |
819 raise Exception('Unknown test type.') | 839 raise Exception('Unknown test type.') |
820 | 840 |
821 | 841 |
822 _SUPPORTED_IN_PLATFORM_MODE = [ | 842 _SUPPORTED_IN_PLATFORM_MODE = [ |
823 # TODO(jbudorick): Add support for more test types. | 843 # TODO(jbudorick): Add support for more test types. |
824 'gtest', | 844 'gtest', |
825 'instrumentation', | 845 'instrumentation', |
| 846 'perf', |
826 'uirobot', | 847 'uirobot', |
827 ] | 848 ] |
828 | 849 |
829 | 850 |
830 def RunTestsInPlatformMode(args): | 851 def RunTestsInPlatformMode(args): |
831 | 852 |
832 def infra_error(message): | 853 def infra_error(message): |
833 logging.fatal(message) | 854 logging.fatal(message) |
834 sys.exit(constants.INFRA_EXIT_CODE) | 855 sys.exit(constants.INFRA_EXIT_CODE) |
835 | 856 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 if e.is_infra_error: | 995 if e.is_infra_error: |
975 return constants.INFRA_EXIT_CODE | 996 return constants.INFRA_EXIT_CODE |
976 return constants.ERROR_EXIT_CODE | 997 return constants.ERROR_EXIT_CODE |
977 except: # pylint: disable=W0702 | 998 except: # pylint: disable=W0702 |
978 logging.exception('Unrecognized error occurred.') | 999 logging.exception('Unrecognized error occurred.') |
979 return constants.ERROR_EXIT_CODE | 1000 return constants.ERROR_EXIT_CODE |
980 | 1001 |
981 | 1002 |
982 if __name__ == '__main__': | 1003 if __name__ == '__main__': |
983 sys.exit(main()) | 1004 sys.exit(main()) |
OLD | NEW |