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

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: Add logging. 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 23:13:07 if this is private to the module, prefix with unde
craigdh 2013/01/07 23:46:14 Moved to emulator.py so it can be reused.
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 logging.info('Emulator launch %d with avd_name=%s', n, avd_name)
127 emu = emulator.Emulator(avd_name, fast_and_loose)
128 emu.Launch(kill_all_emulators=n == 0)
129 t.Stop()
130 emulators.append(emu)
131 # Wait for all emulators to boot completed.
132 for emu in emulators:
133 emu.ConfirmLaunch(True)
134 return emulators
135
136
110 class TestSharder(BaseTestSharder): 137 class TestSharder(BaseTestSharder):
111 """Responsible for sharding the tests on the connected devices.""" 138 """Responsible for sharding the tests on the connected devices."""
112 139
113 def __init__(self, attached_devices, test_suite, gtest_filter, 140 def __init__(self, attached_devices, test_suite, gtest_filter,
114 test_arguments, timeout, cleanup_test_files, tool, 141 test_arguments, timeout, cleanup_test_files, tool,
115 log_dump_name, fast_and_loose, build_type, in_webkit_checkout, 142 log_dump_name, fast_and_loose, build_type, in_webkit_checkout,
116 flakiness_server=None): 143 flakiness_server=None):
117 BaseTestSharder.__init__(self, attached_devices, build_type) 144 BaseTestSharder.__init__(self, attached_devices, build_type)
118 self.test_suite = test_suite 145 self.test_suite = test_suite
119 self.gtest_filter = gtest_filter or '' 146 self.gtest_filter = gtest_filter or ''
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 267
241 Returns: 268 Returns:
242 0 if successful, number of failing tests otherwise. 269 0 if successful, number of failing tests otherwise.
243 """ 270 """
244 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') 271 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '')
245 buildbot_report.PrintNamedStep(step_name) 272 buildbot_report.PrintNamedStep(step_name)
246 attached_devices = [] 273 attached_devices = []
247 buildbot_emulators = [] 274 buildbot_emulators = []
248 275
249 if options.use_emulator: 276 if options.use_emulator:
250 for n in range(options.emulator_count): 277 buildbot_emulators = LaunchEmulators(options.emulator_count,
251 t = time_profile.TimeProfile('Emulator launch %d' % n) 278 fast_and_loose=options.fast_and_loose)
252 avd_name = None 279 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: 280 elif options.test_device:
265 attached_devices = [options.test_device] 281 attached_devices = [options.test_device]
266 else: 282 else:
267 attached_devices = android_commands.GetAttachedDevices() 283 attached_devices = android_commands.GetAttachedDevices()
268 284
269 if not attached_devices: 285 if not attached_devices:
270 logging.critical('A device must be attached and online.') 286 logging.critical('A device must be attached and online.')
271 buildbot_report.PrintError() 287 buildbot_report.PrintError()
272 return 1 288 return 1
273 289
(...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 431 # 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 432 # from all suites, but the buildbot associates the exit status only with the
417 # most recent step). 433 # most recent step).
418 if options.exit_code: 434 if options.exit_code:
419 return failed_tests_count 435 return failed_tests_count
420 return 0 436 return 0
421 437
422 438
423 if __name__ == '__main__': 439 if __name__ == '__main__':
424 sys.exit(main(sys.argv)) 440 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