Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Side by Side Diff: build/android/test_runner.py

Issue 1394173002: Android test_runner.py: Add --enable-device-cache to speed up file pushing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review1 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/local/device/local_device_environment.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 """Adds device options to |parser|.""" 179 """Adds device options to |parser|."""
180 group = parser.add_argument_group(title='Device Options') 180 group = parser.add_argument_group(title='Device Options')
181 group.add_argument('--tool', 181 group.add_argument('--tool',
182 dest='tool', 182 dest='tool',
183 help=('Run the test under a tool ' 183 help=('Run the test under a tool '
184 '(use --tool help to list them)')) 184 '(use --tool help to list them)'))
185 group.add_argument('-d', '--device', dest='test_device', 185 group.add_argument('-d', '--device', dest='test_device',
186 help=('Target device for the test suite ' 186 help=('Target device for the test suite '
187 'to run on.')) 187 'to run on.'))
188 group.add_argument('--blacklist-file', help='Device blacklist file.') 188 group.add_argument('--blacklist-file', help='Device blacklist file.')
189 group.add_argument('--enable-device-cache', action='store_true',
190 help='Cache device state to disk between runs')
189 191
190 192
191 def AddGTestOptions(parser): 193 def AddGTestOptions(parser):
192 """Adds gtest options to |parser|.""" 194 """Adds gtest options to |parser|."""
193 195
194 group = parser.add_argument_group('GTest Options') 196 group = parser.add_argument_group('GTest Options')
195 group.add_argument('-s', '--suite', dest='suite_name', 197 group.add_argument('-s', '--suite', dest='suite_name',
196 nargs='+', metavar='SUITE_NAME', required=True, 198 nargs='+', metavar='SUITE_NAME', required=True,
197 help='Executable name of the test suite to run.') 199 help='Executable name of the test suite to run.')
198 group.add_argument('--gtest_also_run_disabled_tests', 200 group.add_argument('--gtest_also_run_disabled_tests',
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 try: 862 try:
861 suite = unittest.TestSuite() 863 suite = unittest.TestSuite()
862 suite.addTests(unittest.defaultTestLoader.loadTestsFromName(m) 864 suite.addTests(unittest.defaultTestLoader.loadTestsFromName(m)
863 for m in suite_test_modules) 865 for m in suite_test_modules)
864 runner = unittest.TextTestRunner(verbosity=1+args.verbose_count) 866 runner = unittest.TextTestRunner(verbosity=1+args.verbose_count)
865 return 0 if runner.run(suite).wasSuccessful() else 1 867 return 0 if runner.run(suite).wasSuccessful() else 1
866 finally: 868 finally:
867 sys.path = sys.path[1:] 869 sys.path = sys.path[1:]
868 870
869 871
870 def _GetAttachedDevices(blacklist_file, test_device): 872 def _GetAttachedDevices(blacklist_file, test_device, enable_cache):
871 """Get all attached devices. 873 """Get all attached devices.
872 874
873 Args: 875 Args:
876 blacklist_file: Path to device blacklist.
874 test_device: Name of a specific device to use. 877 test_device: Name of a specific device to use.
878 enable_cache: Whether to enable checksum caching.
875 879
876 Returns: 880 Returns:
877 A list of attached devices. 881 A list of attached devices.
878 """ 882 """
879 blacklist = (device_blacklist.Blacklist(blacklist_file) 883 blacklist = (device_blacklist.Blacklist(blacklist_file)
880 if blacklist_file 884 if blacklist_file
881 else None) 885 else None)
882 886
883 attached_devices = device_utils.DeviceUtils.HealthyDevices(blacklist) 887 attached_devices = device_utils.DeviceUtils.HealthyDevices(
888 blacklist, enable_device_files_cache=enable_cache)
884 if test_device: 889 if test_device:
885 test_device = [d for d in attached_devices if d == test_device] 890 test_device = [d for d in attached_devices if d == test_device]
886 if not test_device: 891 if not test_device:
887 raise device_errors.DeviceUnreachableError( 892 raise device_errors.DeviceUnreachableError(
888 'Did not find device %s among attached device. Attached devices: %s' 893 'Did not find device %s among attached device. Attached devices: %s'
889 % (test_device, ', '.join(attached_devices))) 894 % (test_device, ', '.join(attached_devices)))
890 return test_device 895 return test_device
891 896
892 else: 897 else:
893 if not attached_devices: 898 if not attached_devices:
(...skipping 18 matching lines...) Expand all
912 command = args.command 917 command = args.command
913 918
914 ProcessCommonOptions(args) 919 ProcessCommonOptions(args)
915 920
916 if args.enable_platform_mode: 921 if args.enable_platform_mode:
917 return RunTestsInPlatformMode(args, parser) 922 return RunTestsInPlatformMode(args, parser)
918 923
919 if command in constants.LOCAL_MACHINE_TESTS: 924 if command in constants.LOCAL_MACHINE_TESTS:
920 devices = [] 925 devices = []
921 else: 926 else:
922 devices = _GetAttachedDevices(args.blacklist_file, args.test_device) 927 devices = _GetAttachedDevices(args.blacklist_file, args.test_device,
928 args.enable_device_cache)
923 929
924 forwarder.Forwarder.RemoveHostLog() 930 forwarder.Forwarder.RemoveHostLog()
925 if not ports.ResetTestServerPortAllocation(): 931 if not ports.ResetTestServerPortAllocation():
926 raise Exception('Failed to reset test server port.') 932 raise Exception('Failed to reset test server port.')
927 933
928 if command == 'gtest': 934 if command == 'gtest':
929 return RunTestsInPlatformMode(args, parser) 935 return RunTestsInPlatformMode(args, parser)
930 elif command == 'linker': 936 elif command == 'linker':
931 return _RunLinkerTests(args, devices) 937 return _RunLinkerTests(args, devices)
932 elif command == 'instrumentation': 938 elif command == 'instrumentation':
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 if e.is_infra_error: 1056 if e.is_infra_error:
1051 return constants.INFRA_EXIT_CODE 1057 return constants.INFRA_EXIT_CODE
1052 return constants.ERROR_EXIT_CODE 1058 return constants.ERROR_EXIT_CODE
1053 except: # pylint: disable=W0702 1059 except: # pylint: disable=W0702
1054 logging.exception('Unrecognized error occurred.') 1060 logging.exception('Unrecognized error occurred.')
1055 return constants.ERROR_EXIT_CODE 1061 return constants.ERROR_EXIT_CODE
1056 1062
1057 1063
1058 if __name__ == '__main__': 1064 if __name__ == '__main__':
1059 sys.exit(main()) 1065 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/local/device/local_device_environment.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698