Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 def AddCommonOptions(parser): | 52 def AddCommonOptions(parser): |
| 53 """Adds all common options to |parser|.""" | 53 """Adds all common options to |parser|.""" |
| 54 | 54 |
| 55 group = parser.add_argument_group('Common Options') | 55 group = parser.add_argument_group('Common Options') |
| 56 | 56 |
| 57 default_build_type = os.environ.get('BUILDTYPE', 'Debug') | 57 default_build_type = os.environ.get('BUILDTYPE', 'Debug') |
| 58 | 58 |
| 59 debug_or_release_group = group.add_mutually_exclusive_group() | 59 debug_or_release_group = group.add_mutually_exclusive_group() |
| 60 debug_or_release_group.add_argument( | 60 debug_or_release_group.add_argument( |
| 61 '--debug', action='store_const', const='Debug', dest='build_type', | 61 '--debug', action='store_const', const='Default', dest='build_type', |
|
Bernhard Bauer
2016/08/16 23:37:35
What's up with this change again?
dozsa
2016/08/17 10:40:26
I need this change and the one below to be able to
| |
| 62 default=default_build_type, | 62 default=default_build_type, |
| 63 help=('If set, run test suites under out/Debug. ' | 63 help=('If set, run test suites under out/Debug. ' |
| 64 'Default is env var BUILDTYPE or Debug.')) | 64 'Default is env var BUILDTYPE or Debug.')) |
| 65 debug_or_release_group.add_argument( | 65 debug_or_release_group.add_argument( |
| 66 '--release', action='store_const', const='Release', dest='build_type', | 66 '--release', action='store_const', const='Release', dest='build_type', |
| 67 help=('If set, run test suites under out/Release. ' | 67 help=('If set, run test suites under out/Release. ' |
| 68 'Default is env var BUILDTYPE or Debug.')) | 68 'Default is env var BUILDTYPE or Debug.')) |
| 69 | 69 |
| 70 group.add_argument('--build-directory', dest='build_directory', | 70 group.add_argument('--build-directory', dest='build_directory', |
| 71 help=('Path to the directory in which build files are' | 71 help=('Path to the directory in which build files are' |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 'Did not find device %s among attached device. Attached devices: %s' | 786 'Did not find device %s among attached device. Attached devices: %s' |
| 787 % (test_device, ', '.join(attached_devices))) | 787 % (test_device, ', '.join(attached_devices))) |
| 788 return test_device | 788 return test_device |
| 789 | 789 |
| 790 else: | 790 else: |
| 791 if not attached_devices: | 791 if not attached_devices: |
| 792 raise device_errors.NoDevicesError() | 792 raise device_errors.NoDevicesError() |
| 793 return sorted(attached_devices) | 793 return sorted(attached_devices) |
| 794 | 794 |
| 795 | 795 |
| 796 _DEFAULT_PLATFORM_MODE_TESTS = ['gtest', 'instrumentation', 'perf'] | 796 # TODO(rnephew): Add perf when ready to switch to platform mode as default. |
| 797 _DEFAULT_PLATFORM_MODE_TESTS = ['gtest', 'instrumentation'] | |
| 797 | 798 |
| 798 | 799 |
| 799 def RunTestsCommand(args): # pylint: disable=too-many-return-statements | 800 def RunTestsCommand(args): # pylint: disable=too-many-return-statements |
| 800 """Checks test type and dispatches to the appropriate function. | 801 """Checks test type and dispatches to the appropriate function. |
| 801 | 802 |
| 802 Args: | 803 Args: |
| 803 args: argparse.Namespace object. | 804 args: argparse.Namespace object. |
| 804 | 805 |
| 805 Returns: | 806 Returns: |
| 806 Integer indicated exit code. | 807 Integer indicated exit code. |
| 807 | 808 |
| 808 Raises: | 809 Raises: |
| 809 Exception: Unknown command name passed in, or an exception from an | 810 Exception: Unknown command name passed in, or an exception from an |
| 810 individual test runner. | 811 individual test runner. |
| 811 """ | 812 """ |
| 812 command = args.command | 813 command = args.command |
| 813 | 814 |
| 814 ProcessCommonOptions(args) | 815 ProcessCommonOptions(args) |
| 815 logging.info('command: %s', ' '.join(sys.argv)) | 816 logging.info('command: %s', ' '.join(sys.argv)) |
| 816 if args.enable_platform_mode or command in _DEFAULT_PLATFORM_MODE_TESTS: | 817 if args.enable_platform_mode or command in _DEFAULT_PLATFORM_MODE_TESTS: |
| 817 return RunTestsInPlatformMode(args) | 818 return RunTestsInPlatformMode(args) |
| 818 | 819 |
| 819 forwarder.Forwarder.RemoveHostLog() | 820 forwarder.Forwarder.RemoveHostLog() |
| 820 if not ports.ResetTestServerPortAllocation(): | 821 if not ports.ResetTestServerPortAllocation(): |
| 821 raise Exception('Failed to reset test server port.') | 822 raise Exception('Failed to reset test server port.') |
| 822 | 823 |
| 823 # pylint: disable=protected-access | |
| 824 if os.path.exists(ports._TEST_SERVER_PORT_LOCKFILE): | |
| 825 os.unlink(ports._TEST_SERVER_PORT_LOCKFILE) | |
| 826 # pylint: enable=protected-access | |
| 827 | |
| 828 def get_devices(): | 824 def get_devices(): |
| 829 return _GetAttachedDevices(args.blacklist_file, args.test_device, | 825 return _GetAttachedDevices(args.blacklist_file, args.test_device, |
| 830 args.enable_device_cache, args.num_retries) | 826 args.enable_device_cache, args.num_retries) |
| 831 | 827 |
| 832 if command == 'linker': | 828 if command == 'linker': |
| 833 return _RunLinkerTests(args, get_devices()) | 829 return _RunLinkerTests(args, get_devices()) |
| 834 elif command == 'junit': | 830 elif command == 'junit': |
| 835 return _RunJUnitTests(args) | 831 return _RunJUnitTests(args) |
| 836 elif command == 'monkey': | 832 elif command == 'monkey': |
| 837 return _RunMonkeyTests(args, get_devices()) | 833 return _RunMonkeyTests(args, get_devices()) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 | 926 |
| 931 logging.critical('%s of %s tests passed in all %s runs', | 927 logging.critical('%s of %s tests passed in all %s runs', |
| 932 str(all_pass), | 928 str(all_pass), |
| 933 str(tot_tests), | 929 str(tot_tests), |
| 934 str(iteration_count)) | 930 str(iteration_count)) |
| 935 | 931 |
| 936 if args.json_results_file: | 932 if args.json_results_file: |
| 937 json_results.GenerateJsonResultsFile( | 933 json_results.GenerateJsonResultsFile( |
| 938 all_raw_results, args.json_results_file) | 934 all_raw_results, args.json_results_file) |
| 939 | 935 |
| 940 if args.command == 'perf' and (args.steps or args.single_step): | |
| 941 return 0 | |
| 942 | |
| 943 return (0 if all(r.DidRunPass() for r in all_iteration_results) | 936 return (0 if all(r.DidRunPass() for r in all_iteration_results) |
| 944 else constants.ERROR_EXIT_CODE) | 937 else constants.ERROR_EXIT_CODE) |
| 945 | 938 |
| 946 | 939 |
| 947 CommandConfigTuple = collections.namedtuple( | 940 CommandConfigTuple = collections.namedtuple( |
| 948 'CommandConfigTuple', | 941 'CommandConfigTuple', |
| 949 ['add_options_func', 'help_txt']) | 942 ['add_options_func', 'help_txt']) |
| 950 VALID_COMMANDS = { | 943 VALID_COMMANDS = { |
| 951 'gtest': CommandConfigTuple( | 944 'gtest': CommandConfigTuple( |
| 952 AddGTestOptions, | 945 AddGTestOptions, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 if e.is_infra_error: | 995 if e.is_infra_error: |
| 1003 return constants.INFRA_EXIT_CODE | 996 return constants.INFRA_EXIT_CODE |
| 1004 return constants.ERROR_EXIT_CODE | 997 return constants.ERROR_EXIT_CODE |
| 1005 except: # pylint: disable=W0702 | 998 except: # pylint: disable=W0702 |
| 1006 logging.exception('Unrecognized error occurred.') | 999 logging.exception('Unrecognized error occurred.') |
| 1007 return constants.ERROR_EXIT_CODE | 1000 return constants.ERROR_EXIT_CODE |
| 1008 | 1001 |
| 1009 | 1002 |
| 1010 if __name__ == '__main__': | 1003 if __name__ == '__main__': |
| 1011 sys.exit(main()) | 1004 sys.exit(main()) |
| OLD | NEW |