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 json | 8 import json |
9 import logging | 9 import logging |
10 import optparse | 10 import optparse |
(...skipping 13 matching lines...) Expand all Loading... | |
24 sys.path.append(os.path.join(os.path.dirname(__file__), | 24 sys.path.append(os.path.join(os.path.dirname(__file__), |
25 os.pardir, os.pardir, 'util', 'lib', | 25 os.pardir, os.pardir, 'util', 'lib', |
26 'common')) | 26 'common')) |
27 import perf_tests_results_helper # pylint: disable=F0401 | 27 import perf_tests_results_helper # pylint: disable=F0401 |
28 | 28 |
29 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 29 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
30 from pylib import android_commands | 30 from pylib import android_commands |
31 from pylib import constants | 31 from pylib import constants |
32 from pylib.cmd_helper import GetCmdOutput | 32 from pylib.cmd_helper import GetCmdOutput |
33 from pylib.device import device_blacklist | 33 from pylib.device import device_blacklist |
34 from pylib.device import device_errors | |
35 from pylib.device import device_list | 34 from pylib.device import device_list |
36 from pylib.device import device_utils | 35 from pylib.device import device_utils |
37 | 36 |
38 def DeviceInfo(serial, options): | 37 def DeviceInfo(serial, options): |
39 """Gathers info on a device via various adb calls. | 38 """Gathers info on a device via various adb calls. |
40 | 39 |
41 Args: | 40 Args: |
42 serial: The serial of the attached device to construct info about. | 41 serial: The serial of the attached device to construct info about. |
43 | 42 |
44 Returns: | 43 Returns: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 ' Current Battery Service state: ', | 75 ' Current Battery Service state: ', |
77 '\n'.join([' %s: %s' % (k, v) | 76 '\n'.join([' %s: %s' % (k, v) |
78 for k, v in battery_info.iteritems()]), | 77 for k, v in battery_info.iteritems()]), |
79 ' IMEI slice: %s' % imei_slice, | 78 ' IMEI slice: %s' % imei_slice, |
80 ' Wifi IP: %s' % device_adb.GetProp('dhcp.wlan0.ipaddress'), | 79 ' Wifi IP: %s' % device_adb.GetProp('dhcp.wlan0.ipaddress'), |
81 ''] | 80 ''] |
82 | 81 |
83 errors = [] | 82 errors = [] |
84 dev_good = True | 83 dev_good = True |
85 if battery_level < 15: | 84 if battery_level < 15: |
86 errors += ['Device critically low in battery. Turning off device.'] | 85 errors += ['Device critically low in battery. Will add to blacklist.'] |
87 dev_good = False | 86 dev_good = False |
88 if not options.no_provisioning_check: | 87 if not options.no_provisioning_check: |
89 setup_wizard_disabled = ( | 88 setup_wizard_disabled = ( |
90 device_adb.GetProp('ro.setupwizard.mode') == 'DISABLED') | 89 device_adb.GetProp('ro.setupwizard.mode') == 'DISABLED') |
91 if not setup_wizard_disabled and device_build_type != 'user': | 90 if not setup_wizard_disabled and device_build_type != 'user': |
92 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] | 91 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] |
93 if (device_product_name == 'mantaray' and | 92 if (device_product_name == 'mantaray' and |
94 battery_info.get('AC powered', None) != 'true'): | 93 battery_info.get('AC powered', None) != 'true'): |
95 errors += ['Mantaray device not connected to AC power.'] | 94 errors += ['Mantaray device not connected to AC power.'] |
96 | 95 |
97 # Turn off devices with low battery. | 96 # If battery low, device will be blacklisted. Ensure that device is charging. |
98 if battery_level < 15: | 97 if battery_level < 15: |
99 try: | 98 if not device_adb.old_interface.IsDeviceCharging(): |
jbudorick
2014/10/23 21:36:58
nit: Can't we do this in the first if battery_leve
navabi
2014/10/23 21:57:37
Done.
| |
100 device_adb.EnableRoot() | 99 if device_adb.old_interface.CanControlUsbCharging(): |
101 except device_errors.CommandFailedError as e: | 100 device_adb.old_interface.EnableUsbCharging() |
102 # Attempt shutdown anyway. | 101 else: |
103 # TODO(jbudorick) Handle this exception appropriately after interface | 102 logging.error('Device %s is not charging' % serial) |
104 # conversions are finished. | |
105 logging.error(str(e)) | |
106 device_adb.old_interface.Shutdown() | |
navabi
2014/10/23 21:13:41
we are no longer trying to turn the device off. In
jbudorick
2014/10/23 21:36:58
sgtm
| |
107 full_report = '\n'.join(report) | 103 full_report = '\n'.join(report) |
108 return device_type, device_build, battery_level, full_report, errors, dev_good | 104 return device_type, device_build, battery_level, full_report, errors, dev_good |
109 | 105 |
110 | 106 |
111 def CheckForMissingDevices(options, adb_online_devs): | 107 def CheckForMissingDevices(options, adb_online_devs): |
112 """Uses file of previous online devices to detect broken phones. | 108 """Uses file of previous online devices to detect broken phones. |
113 | 109 |
114 Args: | 110 Args: |
115 options: out_dir parameter of options argument is used as the base | 111 options: out_dir parameter of options argument is used as the base |
116 directory to load and update the cache file. | 112 directory to load and update the cache file. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 if options.json_output: | 366 if options.json_output: |
371 with open(options.json_output, 'wb') as f: | 367 with open(options.json_output, 'wb') as f: |
372 f.write(json.dumps({ | 368 f.write(json.dumps({ |
373 'online_devices': devices, | 369 'online_devices': devices, |
374 'offline_devices': offline_devices, | 370 'offline_devices': offline_devices, |
375 'expected_devices': expected_devices, | 371 'expected_devices': expected_devices, |
376 'unique_types': unique_types, | 372 'unique_types': unique_types, |
377 'unique_builds': unique_builds, | 373 'unique_builds': unique_builds, |
378 })) | 374 })) |
379 | 375 |
380 if False in fail_step_lst: | 376 index = 0 |
381 # TODO(navabi): Build fails on device status check step if there exists any | 377 num_failed_devs = 0 |
382 # devices with critically low battery. Remove those devices from testing, | 378 for fail_status in fail_step_lst: |
jbudorick
2014/10/23 21:36:58
nit: you could get rid of index with something lik
navabi
2014/10/23 21:57:37
Done. (i used zip instead of itertools.izip)
| |
383 # allowing build to continue with good devices. | 379 if not fail_status: |
380 device_blacklist.ExtendBlacklist([str(devices[index])]) | |
381 num_failed_devs += 1 | |
382 index += 1 | |
383 | |
384 if num_failed_devs == len(devices): | |
384 return 2 | 385 return 2 |
385 | 386 |
386 if not devices: | 387 if not devices: |
387 return 1 | 388 return 1 |
388 | 389 |
389 | 390 |
390 if __name__ == '__main__': | 391 if __name__ == '__main__': |
391 sys.exit(main()) | 392 sys.exit(main()) |
OLD | NEW |