OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 """A class to keep track of devices across builds and report state.""" | 7 """A class to keep track of devices across builds and report state.""" |
8 import logging | 8 import logging |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 sys.path.append(os.path.join(os.path.dirname(__file__), | 23 sys.path.append(os.path.join(os.path.dirname(__file__), |
24 os.pardir, os.pardir, 'util', 'lib', | 24 os.pardir, os.pardir, 'util', 'lib', |
25 'common')) | 25 'common')) |
26 import perf_tests_results_helper # pylint: disable=F0401 | 26 import perf_tests_results_helper # pylint: disable=F0401 |
27 | 27 |
28 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 28 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
29 from pylib import android_commands | 29 from pylib import android_commands |
30 from pylib import constants | 30 from pylib import constants |
31 from pylib.cmd_helper import GetCmdOutput | 31 from pylib.cmd_helper import GetCmdOutput |
32 | 32 from pylib.device import device_blacklist |
33 | 33 |
34 def DeviceInfo(serial, options): | 34 def DeviceInfo(serial, options): |
35 """Gathers info on a device via various adb calls. | 35 """Gathers info on a device via various adb calls. |
36 | 36 |
37 Args: | 37 Args: |
38 serial: The serial of the attached device to construct info about. | 38 serial: The serial of the attached device to construct info about. |
39 | 39 |
40 Returns: | 40 Returns: |
41 Tuple of device type, build id, report as a string, error messages, and | 41 Tuple of device type, build id, report as a string, error messages, and |
42 boolean indicating whether or not device can be used for testing. | 42 boolean indicating whether or not device can be used for testing. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 parser.add_option('--no-provisioning-check', action='store_true', | 286 parser.add_option('--no-provisioning-check', action='store_true', |
287 help='Will not check if devices are provisioned properly.') | 287 help='Will not check if devices are provisioned properly.') |
288 parser.add_option('--device-status-dashboard', action='store_true', | 288 parser.add_option('--device-status-dashboard', action='store_true', |
289 help='Output device status data for dashboard.') | 289 help='Output device status data for dashboard.') |
290 parser.add_option('--restart-usb', action='store_true', | 290 parser.add_option('--restart-usb', action='store_true', |
291 help='Restart USB ports before running device check.') | 291 help='Restart USB ports before running device check.') |
292 options, args = parser.parse_args() | 292 options, args = parser.parse_args() |
293 if args: | 293 if args: |
294 parser.error('Unknown options %s' % args) | 294 parser.error('Unknown options %s' % args) |
295 | 295 |
296 # Remove the last builds "bad devices" before checking device statuses. | 296 # Remove the last build's "bad devices" before checking device statuses. |
297 android_commands.ResetBadDevices() | 297 device_blacklist.ResetBlacklist() |
298 | 298 |
299 if options.restart_usb: | 299 if options.restart_usb: |
300 expected_devices = GetLastDevices(os.path.abspath(options.out_dir)) | 300 expected_devices = GetLastDevices(os.path.abspath(options.out_dir)) |
301 devices = android_commands.GetAttachedDevices() | 301 devices = android_commands.GetAttachedDevices() |
302 # Only restart usb if devices are missing. | 302 # Only restart usb if devices are missing. |
303 if set(expected_devices) != set(devices): | 303 if set(expected_devices) != set(devices): |
304 KillAllAdb() | 304 KillAllAdb() |
305 retries = 5 | 305 retries = 5 |
306 usb_restarted = True | 306 usb_restarted = True |
307 if not RestartUsb(): | 307 if not RestartUsb(): |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 # devices with critically low battery or install speed. Remove those devices | 368 # devices with critically low battery or install speed. Remove those devices |
369 # from testing, allowing build to continue with good devices. | 369 # from testing, allowing build to continue with good devices. |
370 return 1 | 370 return 1 |
371 | 371 |
372 if not devices: | 372 if not devices: |
373 return 1 | 373 return 1 |
374 | 374 |
375 | 375 |
376 if __name__ == '__main__': | 376 if __name__ == '__main__': |
377 sys.exit(main()) | 377 sys.exit(main()) |
OLD | NEW |