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

Unified Diff: build/android/buildbot/bb_device_status_check.py

Issue 128083002: Android: wait for at least one device if usb restart fails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Variable name Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/buildbot/bb_device_status_check.py
diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py
index cba8132003959872a82ad8c425fa6522bd1c8320..7b656013f2870d605288d00e10074a2c50b7687e 100755
--- a/build/android/buildbot/bb_device_status_check.py
+++ b/build/android/buildbot/bb_device_status_check.py
@@ -225,7 +225,7 @@ def RestartUsb():
if not os.path.isfile('/usr/bin/restart_usb'):
print ('ERROR: Could not restart usb. /usr/bin/restart_usb not installed '
'on host (see BUG=305769).')
- return 1
+ return False
lsusb_proc = bb_utils.SpawnCmd(['lsusb'], stdout=subprocess.PIPE)
lsusb_output, _ = lsusb_proc.communicate()
@@ -236,7 +236,7 @@ def RestartUsb():
usb_devices = [re.findall('Bus (\d\d\d) Device (\d\d\d)', lsusb_line)[0]
for lsusb_line in lsusb_output.strip().split('\n')]
- failed_restart = False
+ all_restarted = True
# Walk USB devices from leaves up (i.e reverse sorted) restarting the
# connection. If a parent node (e.g. usb hub) is restarted before the
# devices connected to it, the (bus, dev) for the hub can change, making the
@@ -247,14 +247,11 @@ def RestartUsb():
return_code = bb_utils.RunCmd(['/usr/bin/restart_usb', bus, dev])
if return_code:
print 'Error restarting USB device /dev/bus/usb/%s/%s' % (bus, dev)
- failed_restart = True
+ all_restarted = False
else:
print 'Restarted USB device /dev/bus/usb/%s/%s' % (bus, dev)
- if failed_restart:
- return 1
-
- return 0
+ return all_restarted
def KillAllAdb():
@@ -299,18 +296,24 @@ def main():
if options.restart_usb:
expected_devices = GetLastDevices(os.path.abspath(options.out_dir))
devices = android_commands.GetAttachedDevices()
- # Only restart usb if devices are missing
+ # Only restart usb if devices are missing.
if set(expected_devices) != set(devices):
KillAllAdb()
retries = 5
- if RestartUsb():
+ usb_restarted = True
+ if not RestartUsb():
+ usb_restarted = False
bb_annotations.PrintWarning()
- print "USB reset stage failed, continuing anyway."
- retries = 0
+ print 'USB reset stage failed, wait for any device to come back.'
while retries:
time.sleep(1)
devices = android_commands.GetAttachedDevices()
if set(expected_devices) == set(devices):
+ # All devices are online, keep going.
+ break
+ if not usb_restarted and devices:
+ # The USB wasn't restarted, but there's at least one device online.
+ # No point in trying to wait for all devices.
break
retries -= 1
« 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