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

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

Issue 11801016: [Android] Break GTest emulator launching into a separate function. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 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 | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 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 the native unit tests. 7 """Runs all the native unit tests.
8 8
9 1. Copy over test binary to /data/local on device. 9 1. Copy over test binary to /data/local on device.
10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) 10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 for t in all_test_suites] 100 for t in all_test_suites]
101 for t, q in zip(all_test_suites, qualified_test_suites): 101 for t, q in zip(all_test_suites, qualified_test_suites):
102 if not os.path.exists(q): 102 if not os.path.exists(q):
103 raise Exception('Test suite %s not found in %s.\n' 103 raise Exception('Test suite %s not found in %s.\n'
104 'Supported test suites:\n %s\n' 104 'Supported test suites:\n %s\n'
105 'Ensure it has been built.\n' % 105 'Ensure it has been built.\n' %
106 (t, q, _TEST_SUITES)) 106 (t, q, _TEST_SUITES))
107 return qualified_test_suites 107 return qualified_test_suites
108 108
109 109
110 def LaunchEmulators(emulator_count, fast_and_loose=False):
frankf 2013/01/07 18:27:23 I recall fast_and_loose option causing more harm t
craigdh 2013/01/07 22:50:41 Filed http://crbug.com/168653 and assigned it to m
111 """Launch multiple emulators and wait for them to boot.
112
113 Args:
114 emulator_count: number of emulators to launch.
115
116 Returns:
117 List of emulators.
118 """
119 emulators = []
120 for n in xrange(emulator_count):
121 t = time_profile.TimeProfile('Emulator launch %d' % n)
122 avd_name = None
123 if n > 0:
124 # Creates a temporary AVD for the extra emulators.
125 avd_name = 'run_tests_avd_%d' % n
126 emu = emulator.Emulator(avd_name, fast_and_loose)
frankf 2013/01/07 18:27:23 Is there any kind of logging done by the emulator
craigdh 2013/01/07 22:50:41 The emulator module logs at the info level already
127 emu.Launch(kill_all_emulators=n == 0)
128 t.Stop()
129 emulators.append(emu)
130 # Wait for all emulators to boot completed.
131 for emu in emulators:
132 emu.ConfirmLaunch(True)
133 return emulators
134
135
110 class TestSharder(BaseTestSharder): 136 class TestSharder(BaseTestSharder):
111 """Responsible for sharding the tests on the connected devices.""" 137 """Responsible for sharding the tests on the connected devices."""
112 138
113 def __init__(self, attached_devices, test_suite, gtest_filter, 139 def __init__(self, attached_devices, test_suite, gtest_filter,
114 test_arguments, timeout, cleanup_test_files, tool, 140 test_arguments, timeout, cleanup_test_files, tool,
115 log_dump_name, fast_and_loose, build_type, in_webkit_checkout, 141 log_dump_name, fast_and_loose, build_type, in_webkit_checkout,
116 flakiness_server=None): 142 flakiness_server=None):
117 BaseTestSharder.__init__(self, attached_devices, build_type) 143 BaseTestSharder.__init__(self, attached_devices, build_type)
118 self.test_suite = test_suite 144 self.test_suite = test_suite
119 self.gtest_filter = gtest_filter or '' 145 self.gtest_filter = gtest_filter or ''
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 266
241 Returns: 267 Returns:
242 0 if successful, number of failing tests otherwise. 268 0 if successful, number of failing tests otherwise.
243 """ 269 """
244 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') 270 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '')
245 buildbot_report.PrintNamedStep(step_name) 271 buildbot_report.PrintNamedStep(step_name)
246 attached_devices = [] 272 attached_devices = []
247 buildbot_emulators = [] 273 buildbot_emulators = []
248 274
249 if options.use_emulator: 275 if options.use_emulator:
250 for n in range(options.emulator_count): 276 buildbot_emulators = LaunchEmulators(options.emulator_count,
251 t = time_profile.TimeProfile('Emulator launch %d' % n) 277 fast_and_loose=options.fast_and_loose)
252 avd_name = None 278 attached_devices = [e.device for e in buildbot_emulators]
253 if n > 0:
254 # Creates a temporary AVD for the extra emulators.
255 avd_name = 'run_tests_avd_%d' % n
256 buildbot_emulator = emulator.Emulator(avd_name, options.fast_and_loose)
257 buildbot_emulator.Launch(kill_all_emulators=n == 0)
258 t.Stop()
259 buildbot_emulators.append(buildbot_emulator)
260 attached_devices.append(buildbot_emulator.device)
261 # Wait for all emulators to boot completed.
262 map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True),
263 buildbot_emulators)
264 elif options.test_device: 279 elif options.test_device:
265 attached_devices = [options.test_device] 280 attached_devices = [options.test_device]
266 else: 281 else:
267 attached_devices = android_commands.GetAttachedDevices() 282 attached_devices = android_commands.GetAttachedDevices()
268 283
269 if not attached_devices: 284 if not attached_devices:
270 logging.critical('A device must be attached and online.') 285 logging.critical('A device must be attached and online.')
271 buildbot_report.PrintError() 286 buildbot_report.PrintError()
272 return 1 287 return 1
273 288
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 # the batch (this happens because the exit status is a sum of all failures 430 # the batch (this happens because the exit status is a sum of all failures
416 # from all suites, but the buildbot associates the exit status only with the 431 # from all suites, but the buildbot associates the exit status only with the
417 # most recent step). 432 # most recent step).
418 if options.exit_code: 433 if options.exit_code:
419 return failed_tests_count 434 return failed_tests_count
420 return 0 435 return 0
421 436
422 437
423 if __name__ == '__main__': 438 if __name__ == '__main__':
424 sys.exit(main(sys.argv)) 439 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698