OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import collections | 6 import collections |
7 import glob | 7 import glob |
8 import hashlib | 8 import hashlib |
9 import json | 9 import json |
10 import multiprocessing | 10 import multiprocessing |
11 import os | 11 import os |
12 import random | 12 import random |
13 import re | 13 import re |
14 import shutil | 14 import shutil |
15 import sys | 15 import sys |
16 | 16 |
17 import bb_utils | 17 import bb_utils |
18 import bb_annotations | 18 import bb_annotations |
19 | 19 |
20 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 20 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
21 import provision_devices | 21 import provision_devices |
22 from pylib import android_commands | 22 from pylib import android_commands |
23 from pylib import constants | 23 from pylib import constants |
| 24 from pylib.device import device_utils |
24 from pylib.gtest import gtest_config | 25 from pylib.gtest import gtest_config |
25 | 26 |
26 CHROME_SRC_DIR = bb_utils.CHROME_SRC | 27 CHROME_SRC_DIR = bb_utils.CHROME_SRC |
27 DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) | 28 DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) |
28 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR | 29 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR |
29 sys.path.append(os.path.join( | 30 sys.path.append(os.path.join( |
30 CHROME_SRC_DIR, 'third_party', 'android_testrunner')) | 31 CHROME_SRC_DIR, 'third_party', 'android_testrunner')) |
31 import errors | 32 import errors |
32 | 33 |
33 | 34 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 revision = options.build_properties.get('got_revision') | 96 revision = options.build_properties.get('got_revision') |
96 if not revision: | 97 if not revision: |
97 revision = options.build_properties.get('revision', 'testing') | 98 revision = options.build_properties.get('revision', 'testing') |
98 return revision | 99 return revision |
99 | 100 |
100 | 101 |
101 # multiprocessing map_async requires a top-level function for pickle library. | 102 # multiprocessing map_async requires a top-level function for pickle library. |
102 def RebootDeviceSafe(device): | 103 def RebootDeviceSafe(device): |
103 """Reboot a device, wait for it to start, and squelch timeout exceptions.""" | 104 """Reboot a device, wait for it to start, and squelch timeout exceptions.""" |
104 try: | 105 try: |
105 android_commands.AndroidCommands(device).Reboot(True) | 106 device_utils.DeviceUtils(device).old_interface.Reboot(True) |
106 except errors.DeviceUnresponsiveError as e: | 107 except errors.DeviceUnresponsiveError as e: |
107 return e | 108 return e |
108 | 109 |
109 | 110 |
110 def RebootDevices(): | 111 def RebootDevices(): |
111 """Reboot all attached and online devices.""" | 112 """Reboot all attached and online devices.""" |
112 # Early return here to avoid presubmit dependence on adb, | 113 # Early return here to avoid presubmit dependence on adb, |
113 # which might not exist in this checkout. | 114 # which might not exist in this checkout. |
114 if bb_utils.TESTING: | 115 if bb_utils.TESTING: |
115 return | 116 return |
116 devices = android_commands.GetAttachedDevices(emulator=False) | 117 devices = android_commands.GetAttachedDevices() |
117 print 'Rebooting: %s' % devices | 118 print 'Rebooting: %s' % devices |
118 if devices: | 119 if devices: |
119 pool = multiprocessing.Pool(len(devices)) | 120 pool = multiprocessing.Pool(len(devices)) |
120 results = pool.map_async(RebootDeviceSafe, devices).get(99999) | 121 results = pool.map_async(RebootDeviceSafe, devices).get(99999) |
121 | 122 |
122 for device, result in zip(devices, results): | 123 for device, result in zip(devices, results): |
123 if result: | 124 if result: |
124 print '%s failed to startup.' % device | 125 print '%s failed to startup.' % device |
125 | 126 |
126 if any(results): | 127 if any(results): |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 392 |
392 # Wait for logcat_monitor to pull existing logcat | 393 # Wait for logcat_monitor to pull existing logcat |
393 RunCmd(['sleep', '5']) | 394 RunCmd(['sleep', '5']) |
394 | 395 |
395 | 396 |
396 def ProvisionDevices(options): | 397 def ProvisionDevices(options): |
397 bb_annotations.PrintNamedStep('provision_devices') | 398 bb_annotations.PrintNamedStep('provision_devices') |
398 | 399 |
399 if not bb_utils.TESTING: | 400 if not bb_utils.TESTING: |
400 # Restart adb to work around bugs, sleep to wait for usb discovery. | 401 # Restart adb to work around bugs, sleep to wait for usb discovery. |
401 adb = android_commands.AndroidCommands() | 402 device_utils.DeviceUtils(None).old_interface.RestartAdbServer() |
402 adb.RestartAdbServer() | |
403 RunCmd(['sleep', '1']) | 403 RunCmd(['sleep', '1']) |
404 | 404 |
405 if not options.no_reboot: | 405 if not options.no_reboot: |
406 RebootDevices() | 406 RebootDevices() |
407 provision_cmd = ['build/android/provision_devices.py', '-t', options.target] | 407 provision_cmd = ['build/android/provision_devices.py', '-t', options.target] |
408 if options.auto_reconnect: | 408 if options.auto_reconnect: |
409 provision_cmd.append('--auto-reconnect') | 409 provision_cmd.append('--auto-reconnect') |
410 RunCmd(provision_cmd) | 410 RunCmd(provision_cmd) |
411 | 411 |
412 | 412 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 646 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
647 if options.coverage_bucket: | 647 if options.coverage_bucket: |
648 setattr(options, 'coverage_dir', | 648 setattr(options, 'coverage_dir', |
649 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) | 649 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) |
650 | 650 |
651 MainTestWrapper(options) | 651 MainTestWrapper(options) |
652 | 652 |
653 | 653 |
654 if __name__ == '__main__': | 654 if __name__ == '__main__': |
655 sys.exit(main(sys.argv)) | 655 sys.exit(main(sys.argv)) |
OLD | NEW |