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 """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 17 matching lines...) Expand all Loading... |
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_type = AdbShellCmd('getprop ro.build.product') | 36 device_type = AdbShellCmd('getprop ro.build.product') |
37 device_build = AdbShellCmd('getprop ro.build.id') | 37 device_build = AdbShellCmd('getprop ro.build.id') |
| 38 device_build_type = AdbShellCmd('getprop ro.build.type') |
38 device_product_name = AdbShellCmd('getprop ro.product.name') | 39 device_product_name = AdbShellCmd('getprop ro.product.name') |
39 | 40 |
40 setup_wizard_disabled = AdbShellCmd( | 41 setup_wizard_disabled = AdbShellCmd( |
41 'getprop ro.setupwizard.mode') == 'DISABLED' | 42 'getprop ro.setupwizard.mode') == 'DISABLED' |
42 battery = AdbShellCmd('dumpsys battery') | 43 battery = AdbShellCmd('dumpsys battery') |
43 install_output = GetCmdOutput( | 44 install_output = GetCmdOutput( |
44 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk', | 45 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk', |
45 '%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT]) | 46 '%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT]) |
46 install_speed_found = re.findall('(\d+) KB/s', install_output) | 47 install_speed_found = re.findall('(\d+) KB/s', install_output) |
47 if install_speed_found: | 48 if install_speed_found: |
(...skipping 16 matching lines...) Expand all Loading... |
64 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' | 65 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' |
65 '| grep Device' | 66 '| grep Device' |
66 "| awk '{print $4}'")[-6:], | 67 "| awk '{print $4}'")[-6:], |
67 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), | 68 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), |
68 ' Install Speed: %s KB/s' % install_speed, | 69 ' Install Speed: %s KB/s' % install_speed, |
69 ''] | 70 ''] |
70 | 71 |
71 errors = [] | 72 errors = [] |
72 if battery_level < 5: | 73 if battery_level < 5: |
73 errors += ['Device critically low in battery. Do not use for testing.'] | 74 errors += ['Device critically low in battery. Do not use for testing.'] |
74 if not setup_wizard_disabled: | 75 if not setup_wizard_disabled and device_build_type != 'user': |
75 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] | 76 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] |
76 if device_product_name == 'mantaray' and ac_power != 'true': | 77 if device_product_name == 'mantaray' and ac_power != 'true': |
77 errors += ['Mantaray device not connected to AC power.'] | 78 errors += ['Mantaray device not connected to AC power.'] |
78 if install_speed < 800: | 79 if install_speed < 800: |
79 errors += ['Device install speed too low. Do not use for testing.'] | 80 errors += ['Device install speed too low. Do not use for testing.'] |
80 | 81 |
81 # TODO(navabi): Determine if device status check step should fail on slow | 82 # TODO(navabi): Determine if device status check step should fail on slow |
82 # install speed. The original CL caused the step to fail but was reverted | 83 # install speed. The original CL caused the step to fail but was reverted |
83 # because it caused too many early failures. Determine if it was just flake. | 84 # because it caused too many early failures. Determine if it was just flake. |
84 # Also, do not fail on 'Unknown' caused by offline device, because other | 85 # Also, do not fail on 'Unknown' caused by offline device, because other |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 # devices with critically low battery or install speed. Remove those devices | 216 # devices with critically low battery or install speed. Remove those devices |
216 # from testing, allowing build to continue with good devices. | 217 # from testing, allowing build to continue with good devices. |
217 return 1 | 218 return 1 |
218 | 219 |
219 if not devices: | 220 if not devices: |
220 return 1 | 221 return 1 |
221 | 222 |
222 | 223 |
223 if __name__ == '__main__': | 224 if __name__ == '__main__': |
224 sys.exit(main()) | 225 sys.exit(main()) |
OLD | NEW |