| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 import emulator | 48 import emulator |
| 49 from pylib import android_commands | 49 from pylib import android_commands |
| 50 from pylib import buildbot_report | 50 from pylib import buildbot_report |
| 51 from pylib import cmd_helper | 51 from pylib import cmd_helper |
| 52 from pylib import debug_info | 52 from pylib import debug_info |
| 53 from pylib import ports | 53 from pylib import ports |
| 54 from pylib import run_tests_helper | 54 from pylib import run_tests_helper |
| 55 from pylib import test_options_parser | 55 from pylib import test_options_parser |
| 56 from pylib.base_test_sharder import BaseTestSharder | 56 from pylib.base_test_sharder import BaseTestSharder |
| 57 from pylib.single_test_runner import SingleTestRunner | 57 from pylib.single_test_runner import SingleTestRunner |
| 58 from pylib.utils import time_profile | |
| 59 from pylib.utils import xvfb | 58 from pylib.utils import xvfb |
| 60 | 59 |
| 61 | 60 |
| 62 _TEST_SUITES = ['base_unittests', | 61 _TEST_SUITES = ['base_unittests', |
| 63 'cc_unittests', | 62 'cc_unittests', |
| 64 'content_unittests', | 63 'content_unittests', |
| 65 'gpu_unittests', | 64 'gpu_unittests', |
| 66 'ipc_tests', | 65 'ipc_tests', |
| 67 'media_unittests', | 66 'media_unittests', |
| 68 'net_unittests', | 67 'net_unittests', |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 239 |
| 241 Returns: | 240 Returns: |
| 242 0 if successful, number of failing tests otherwise. | 241 0 if successful, number of failing tests otherwise. |
| 243 """ | 242 """ |
| 244 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') | 243 step_name = os.path.basename(options.test_suite).replace('-debug.apk', '') |
| 245 buildbot_report.PrintNamedStep(step_name) | 244 buildbot_report.PrintNamedStep(step_name) |
| 246 attached_devices = [] | 245 attached_devices = [] |
| 247 buildbot_emulators = [] | 246 buildbot_emulators = [] |
| 248 | 247 |
| 249 if options.use_emulator: | 248 if options.use_emulator: |
| 250 for n in range(options.emulator_count): | 249 buildbot_emulators = emulator.LaunchEmulators(options.emulator_count, |
| 251 t = time_profile.TimeProfile('Emulator launch %d' % n) | 250 fast_and_loose=options.fast_and_loose) |
| 252 avd_name = None | 251 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: | 252 elif options.test_device: |
| 265 attached_devices = [options.test_device] | 253 attached_devices = [options.test_device] |
| 266 else: | 254 else: |
| 267 attached_devices = android_commands.GetAttachedDevices() | 255 attached_devices = android_commands.GetAttachedDevices() |
| 268 | 256 |
| 269 if not attached_devices: | 257 if not attached_devices: |
| 270 logging.critical('A device must be attached and online.') | 258 logging.critical('A device must be attached and online.') |
| 271 buildbot_report.PrintError() | 259 buildbot_report.PrintError() |
| 272 return 1 | 260 return 1 |
| 273 | 261 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 # the batch (this happens because the exit status is a sum of all failures | 403 # 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 | 404 # from all suites, but the buildbot associates the exit status only with the |
| 417 # most recent step). | 405 # most recent step). |
| 418 if options.exit_code: | 406 if options.exit_code: |
| 419 return failed_tests_count | 407 return failed_tests_count |
| 420 return 0 | 408 return 0 |
| 421 | 409 |
| 422 | 410 |
| 423 if __name__ == '__main__': | 411 if __name__ == '__main__': |
| 424 sys.exit(main(sys.argv)) | 412 sys.exit(main(sys.argv)) |
| OLD | NEW |