OLD | NEW |
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 27 matching lines...) Expand all Loading... |
38 import copy | 38 import copy |
39 import fnmatch | 39 import fnmatch |
40 import logging | 40 import logging |
41 import optparse | 41 import optparse |
42 import os | 42 import os |
43 import signal | 43 import signal |
44 import subprocess | 44 import subprocess |
45 import sys | 45 import sys |
46 import time | 46 import time |
47 | 47 |
48 import emulator | |
49 from pylib import android_commands | 48 from pylib import android_commands |
50 from pylib import buildbot_report | 49 from pylib import buildbot_report |
51 from pylib import cmd_helper | 50 from pylib import cmd_helper |
52 from pylib import ports | 51 from pylib import ports |
53 from pylib.base_test_sharder import BaseTestSharder | 52 from pylib.base_test_sharder import BaseTestSharder |
54 from pylib.gtest import debug_info | 53 from pylib.gtest import debug_info |
55 from pylib.gtest.single_test_runner import SingleTestRunner | 54 from pylib.gtest.single_test_runner import SingleTestRunner |
| 55 from pylib.utils import emulator |
56 from pylib.utils import run_tests_helper | 56 from pylib.utils import run_tests_helper |
57 from pylib.utils import test_options_parser | 57 from pylib.utils import test_options_parser |
58 from pylib.utils import time_profile | 58 from pylib.utils import time_profile |
59 from pylib.utils import xvfb | 59 from pylib.utils import xvfb |
60 | 60 |
61 | 61 |
62 _TEST_SUITES = ['base_unittests', | 62 _TEST_SUITES = ['base_unittests', |
63 'cc_unittests', | 63 'cc_unittests', |
64 'content_unittests', | 64 'content_unittests', |
65 'gpu_unittests', | 65 'gpu_unittests', |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 Returns: | 238 Returns: |
239 0 if successful, number of failing tests otherwise. | 239 0 if successful, number of failing tests otherwise. |
240 """ | 240 """ |
241 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') | 241 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') |
242 buildbot_report.PrintNamedStep(step_name) | 242 buildbot_report.PrintNamedStep(step_name) |
243 attached_devices = [] | 243 attached_devices = [] |
244 buildbot_emulators = [] | 244 buildbot_emulators = [] |
245 | 245 |
246 if options.use_emulator: | 246 if options.use_emulator: |
247 for n in range(options.emulator_count): | 247 buildbot_emulators = emulator.LaunchEmulators(options.emulator_count, |
248 t = time_profile.TimeProfile('Emulator launch %d' % n) | 248 wait_for_boot=True) |
249 avd_name = None | 249 attached_devices = [e.device for e in buildbot_emulators] |
250 if n > 0: | |
251 # Creates a temporary AVD for the extra emulators. | |
252 avd_name = 'run_tests_avd_%d' % n | |
253 buildbot_emulator = emulator.Emulator(avd_name) | |
254 buildbot_emulator.Launch(kill_all_emulators=n == 0) | |
255 t.Stop() | |
256 buildbot_emulators.append(buildbot_emulator) | |
257 attached_devices.append(buildbot_emulator.device) | |
258 # Wait for all emulators to boot completed. | |
259 map(lambda buildbot_emulator: buildbot_emulator.ConfirmLaunch(True), | |
260 buildbot_emulators) | |
261 elif options.test_device: | 250 elif options.test_device: |
262 attached_devices = [options.test_device] | 251 attached_devices = [options.test_device] |
263 else: | 252 else: |
264 attached_devices = android_commands.GetAttachedDevices() | 253 attached_devices = android_commands.GetAttachedDevices() |
265 | 254 |
266 if not attached_devices: | 255 if not attached_devices: |
267 logging.critical('A device must be attached and online.') | 256 logging.critical('A device must be attached and online.') |
268 buildbot_report.PrintError() | 257 buildbot_report.PrintError() |
269 return 1 | 258 return 1 |
270 | 259 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 # the batch (this happens because the exit status is a sum of all failures | 352 # the batch (this happens because the exit status is a sum of all failures |
364 # from all suites, but the buildbot associates the exit status only with the | 353 # from all suites, but the buildbot associates the exit status only with the |
365 # most recent step). | 354 # most recent step). |
366 if options.exit_code: | 355 if options.exit_code: |
367 return failed_tests_count | 356 return failed_tests_count |
368 return 0 | 357 return 0 |
369 | 358 |
370 | 359 |
371 if __name__ == '__main__': | 360 if __name__ == '__main__': |
372 sys.exit(main(sys.argv)) | 361 sys.exit(main(sys.argv)) |
OLD | NEW |