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

Side by Side Diff: build/android/device_status_check.py

Issue 16950029: Turn off devices with low battery and don't fail device status step. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """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 15 matching lines...) Expand all
26 26
27 Returns: 27 Returns:
28 Tuple of device type, build id, report as a string, error messages, and 28 Tuple of device type, build id, report as a string, error messages, and
29 boolean indicating whether or not device can be used for testing. 29 boolean indicating whether or not device can be used for testing.
30 """ 30 """
31 31
32 def AdbShellCmd(cmd): 32 def AdbShellCmd(cmd):
33 return GetCmdOutput('adb -s %s shell %s' % (serial, cmd), 33 return GetCmdOutput('adb -s %s shell %s' % (serial, cmd),
34 shell=True).strip() 34 shell=True).strip()
35 35
36 device_adb = android_commands.AndroidCommands(serial)
36 device_type = AdbShellCmd('getprop ro.build.product') 37 device_type = AdbShellCmd('getprop ro.build.product')
37 device_build = AdbShellCmd('getprop ro.build.id') 38 device_build = AdbShellCmd('getprop ro.build.id')
38 device_build_type = AdbShellCmd('getprop ro.build.type') 39 device_build_type = AdbShellCmd('getprop ro.build.type')
39 device_product_name = AdbShellCmd('getprop ro.product.name') 40 device_product_name = AdbShellCmd('getprop ro.product.name')
40 41
41 setup_wizard_disabled = AdbShellCmd( 42 setup_wizard_disabled = AdbShellCmd(
42 'getprop ro.setupwizard.mode') == 'DISABLED' 43 'getprop ro.setupwizard.mode') == 'DISABLED'
43 battery = AdbShellCmd('dumpsys battery') 44 battery = AdbShellCmd('dumpsys battery')
44 install_output = GetCmdOutput( 45 install_output = GetCmdOutput(
45 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk', 46 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk',
(...skipping 18 matching lines...) Expand all
64 ' Battery temp: %s' % battery_temp, 65 ' Battery temp: %s' % battery_temp,
65 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' 66 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo '
66 '| grep Device' 67 '| grep Device'
67 "| awk '{print $4}'")[-6:], 68 "| awk '{print $4}'")[-6:],
68 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), 69 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'),
69 ' Install Speed: %s KB/s' % install_speed, 70 ' Install Speed: %s KB/s' % install_speed,
70 ''] 71 '']
71 72
72 errors = [] 73 errors = []
73 if battery_level < 15: 74 if battery_level < 15:
74 errors += ['Device critically low in battery. Do not use for testing.'] 75 errors += ['Device critically low in battery. Turning off device.']
75 if not setup_wizard_disabled and device_build_type != 'user': 76 if not setup_wizard_disabled and device_build_type != 'user':
76 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] 77 errors += ['Setup wizard not disabled. Was it provisioned correctly?']
77 if device_product_name == 'mantaray' and ac_power != 'true': 78 if device_product_name == 'mantaray' and ac_power != 'true':
78 errors += ['Mantaray device not connected to AC power.'] 79 errors += ['Mantaray device not connected to AC power.']
79 # TODO(navabi): Insert warning once we have a better handle of what install 80 # TODO(navabi): Insert warning once we have a better handle of what install
80 # speeds to expect. The following lines were causing too many alerts. 81 # speeds to expect. The following lines were causing too many alerts.
81 # if install_speed < 500: 82 # if install_speed < 500:
82 # errors += ['Device install speed too low. Do not use for testing.'] 83 # errors += ['Device install speed too low. Do not use for testing.']
83 84
84 # TODO(navabi): Determine if device status check step should fail on slow 85 # Causing the device status check step fail for slow install speed or low
85 # install speed. The original CL caused the step to fail but was reverted 86 # battery currently is too disruptive to the bots (especially try bots).
86 # because it caused too many early failures. Determine if it was just flake. 87 # Turn off devices with low battery and the step does not fail.
87 # Also, do not fail on 'Unknown' caused by offline device, because other 88 device_adb.EnableAdbRoot()
88 # devices can still be used for tests. 89 AdbShellCmd('reboot -p')
frankf 2013/06/22 00:03:50 Why don't you use device_adb instead of AdbShellCm
89 fail_step = (battery_level == 'Unknown' or battery_level >= 15) 90 return device_type, device_build, '\n'.join(report), errors, True
90 return device_type, device_build, '\n'.join(report), errors, fail_step
91 91
92 92
93 def CheckForMissingDevices(options, adb_online_devs): 93 def CheckForMissingDevices(options, adb_online_devs):
94 """Uses file of previous online devices to detect broken phones. 94 """Uses file of previous online devices to detect broken phones.
95 95
96 Args: 96 Args:
97 options: out_dir parameter of options argument is used as the base 97 options: out_dir parameter of options argument is used as the base
98 directory to load and update the cache file. 98 directory to load and update the cache file.
99 adb_online_devs: A list of serial numbers of the currently visible 99 adb_online_devs: A list of serial numbers of the currently visible
100 and online attached devices. 100 and online attached devices.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 # devices with critically low battery or install speed. Remove those devices 218 # devices with critically low battery or install speed. Remove those devices
219 # from testing, allowing build to continue with good devices. 219 # from testing, allowing build to continue with good devices.
220 return 1 220 return 1
221 221
222 if not devices: 222 if not devices:
223 return 1 223 return 1
224 224
225 225
226 if __name__ == '__main__': 226 if __name__ == '__main__':
227 sys.exit(main()) 227 sys.exit(main())
OLDNEW
« 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