summaryrefslogtreecommitdiffstats
path: root/build/android
diff options
context:
space:
mode:
authornavabi@google.com <navabi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 15:41:07 +0000
committernavabi@google.com <navabi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 15:41:07 +0000
commit3d41478deea02db2f66b88f5c429a2af7b5871a4 (patch)
tree14a4bf9d50f11a97a4ad7ca7cd219c1c65180487 /build/android
parent46a0efcf5c5071830d143f62ff1d879b094c51d2 (diff)
downloadchromium_src-3d41478deea02db2f66b88f5c429a2af7b5871a4.zip
chromium_src-3d41478deea02db2f66b88f5c429a2af7b5871a4.tar.gz
chromium_src-3d41478deea02db2f66b88f5c429a2af7b5871a4.tar.bz2
Add option to output device status data in format for dashboard and cleanup.
Adds an option to print the device status information (i.e. online devices, offline devices and device battery levels). Example output: <*>RESULT OnlineDevices: OnlineDevices= 2 RESULT OfflineDevices: OfflineDevice= 0 RESULT DeviceBattery: 0149CC380F016011= 99 RESULT DeviceBattery: 014E378305007013= 60 Cleanup uses AndroidCommands for calling adb shell commands rather than its own GetCmdOutput function. BUG=254014 Review URL: https://chromiumcodereview.appspot.com/19284009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android')
-rwxr-xr-xbuild/android/device_status_check.py54
-rw-r--r--build/android/pylib/android_commands.py57
2 files changed, 89 insertions, 22 deletions
diff --git a/build/android/device_status_check.py b/build/android/device_status_check.py
index cd84153..97f6ed4 100755
--- a/build/android/device_status_check.py
+++ b/build/android/device_status_check.py
@@ -15,6 +15,7 @@ import re
from pylib import android_commands
from pylib import buildbot_report
from pylib import constants
+from pylib import perf_tests_helper
from pylib.cmd_helper import GetCmdOutput
@@ -29,21 +30,15 @@ def DeviceInfo(serial, options):
boolean indicating whether or not device can be used for testing.
"""
- def AdbShellCmd(cmd):
- return GetCmdOutput('adb -s %s shell %s' % (serial, cmd),
- shell=True).strip()
-
device_adb = android_commands.AndroidCommands(serial)
- # TODO(navabi): Replace AdbShellCmd with device_adb.
- device_type = AdbShellCmd('getprop ro.build.product')
- device_build = AdbShellCmd('getprop ro.build.id')
- device_build_type = AdbShellCmd('getprop ro.build.type')
- device_product_name = AdbShellCmd('getprop ro.product.name')
+ device_type = device_adb.GetBuildProduct()
+ device_build = device_adb.GetBuildId()
+ device_build_type = device_adb.GetBuildType()
+ device_product_name = device_adb.GetProductName()
- setup_wizard_disabled = AdbShellCmd(
- 'getprop ro.setupwizard.mode') == 'DISABLED'
- battery = AdbShellCmd('dumpsys battery')
+ setup_wizard_disabled = device_adb.GetSetupWizardStatus() == 'DISABLED'
+ battery = device_adb.GetBatteryInfo()
install_output = GetCmdOutput(
['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT, '--apk',
'%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT])
@@ -60,15 +55,15 @@ def DeviceInfo(serial, options):
ac_power = re.findall('AC powered: (\w+)', battery)[0]
battery_level = int(re.findall('level: (\d+)', battery)[0])
battery_temp = float(re.findall('temperature: (\d+)', battery)[0]) / 10
+ sub_info = device_adb.GetSubscriberInfo()
+ imei_slice = re.findall('Device ID = (\d+)', sub_info)[0][-6:]
report = ['Device %s (%s)' % (serial, device_type),
- ' Build: %s (%s)' % (device_build,
- AdbShellCmd('getprop ro.build.fingerprint')),
+ ' Build: %s (%s)' %
+ (device_build, device_adb.GetBuildFingerprint()),
' Battery: %s%%' % battery_level,
' Battery temp: %s' % battery_temp,
- ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo '
- '| grep Device'
- "| awk '{print $4}'")[-6:],
- ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'),
+ ' IMEI slice: %s' % imei_slice,
+ ' Wifi IP: %s' % device_adb.GetWifiIP(),
' Install Speed: %s KB/s' % install_speed,
'']
@@ -90,8 +85,9 @@ def DeviceInfo(serial, options):
# Turn off devices with low battery and the step does not fail.
if battery_level < 15:
device_adb.EnableAdbRoot()
- AdbShellCmd('reboot -p')
- return device_type, device_build, '\n'.join(report), errors, True
+ device_adb.Shutdown()
+ full_report = '\n'.join(report)
+ return device_type, device_build, battery_level, full_report, errors, True
def CheckForMissingDevices(options, adb_online_devs):
@@ -188,15 +184,19 @@ def main():
'..', 'out'))
parser.add_option('--no-provisioning-check',
help='Will not check if devices are provisioned properly.')
+ parser.add_option('--device-status-dashboard',
+ help='Output device status data for dashboard.')
options, args = parser.parse_args()
if args:
parser.error('Unknown options %s' % args)
devices = android_commands.GetAttachedDevices()
- types, builds, reports, errors = [], [], [], []
+ offline_devices = android_commands.GetAttachedOfflineDevices()
+
+ types, builds, batteries, reports, errors = [], [], [], [], []
fail_step_lst = []
if devices:
- types, builds, reports, errors, fail_step_lst = (
+ types, builds, batteries, reports, errors, fail_step_lst = (
zip(*[DeviceInfo(dev, options) for dev in devices]))
err_msg = CheckForMissingDevices(options, devices) or []
@@ -219,6 +219,16 @@ def main():
print msg
SendDeviceStatusAlert(msg)
+ if options.device_status_dashboard:
+ perf_tests_helper.PrintPerfResult('BotDevices', 'OnlineDevices',
+ [len(devices)], 'devices')
+ perf_tests_helper.PrintPerfResult('BotDevices', 'OfflineDevices',
+ [len(offline_devices)], 'devices',
+ 'unimportant')
+ for serial, battery in zip(devices, batteries):
+ perf_tests_helper.PrintPerfResult('DeviceBattery', serial, [battery], '%',
+ 'unimportant')
+
if False in fail_step_lst:
# TODO(navabi): Build fails on device status check step if there exists any
# devices with critically low battery or install speed. Remove those devices
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 48116b8..c7be5e1 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -114,7 +114,18 @@ def GetAttachedDevices():
return devices
+def GetAttachedOfflineDevices():
+ """Returns a list of attached, offline android devices.
+
+ Returns: List of devices with status 'offline'.
+ """
+ re_device = re.compile('^([a-zA-Z0-9_:.-]+)\toffline$', re.MULTILINE)
+ return re_device.findall(cmd_helper.GetCmdOutput([constants.ADB_PATH,
+ 'devices']))
+
+
def IsDeviceAttached(device):
+ """Return true if the device is attached and online."""
return device in GetAttachedDevices()
@@ -331,6 +342,10 @@ class AndroidCommands(object):
self.WaitForDevicePm()
self.WaitForSdCardReady(timeout)
+ def Shutdown(self):
+ """Shuts down the device."""
+ self._adb.SendCommand('reboot -p')
+
def Uninstall(self, package):
"""Uninstalls the specified package from the device.
@@ -920,6 +935,24 @@ class AndroidCommands(object):
assert build_type
return build_type
+ def GetBuildProduct(self):
+ """Returns the build product of the device (e.g. maguro)."""
+ build_product = self.RunShellCommand('getprop ro.build.product')[0]
+ assert build_product
+ return build_product
+
+ def GetProductName(self):
+ """Returns the product name of the device (e.g. takju)."""
+ name = self.RunShellCommand('getprop ro.product.name')[0]
+ assert name
+ return name
+
+ def GetBuildFingerprint(self):
+ """Returns the build fingerprint of the device."""
+ build_fingerprint = self.RunShellCommand('getprop ro.build.fingerprint')[0]
+ assert build_fingerprint
+ return build_fingerprint
+
def GetDescription(self):
"""Returns the description of the system.
@@ -935,6 +968,30 @@ class AndroidCommands(object):
assert model
return model
+ def GetWifiIP(self):
+ """Returns the wifi IP on the device."""
+ wifi_ip = self.RunShellCommand('getprop dhcp.wlan0.ipaddress')[0]
+ assert wifi_ip
+ return wifi_ip
+
+ def GetSubscriberInfo(self):
+ """Returns the device subscriber info (e.g. GSM and device ID) as string."""
+ iphone_sub = self.RunShellCommand('dumpsys iphonesubinfo')
+ assert iphone_sub
+ return '\n'.join(iphone_sub)
+
+ def GetBatteryInfo(self):
+ """Returns the device battery info (e.g. status, level, etc) as string."""
+ battery = self.RunShellCommand('dumpsys battery')
+ assert battery
+ return '\n'.join(battery)
+
+ def GetSetupWizardStatus(self):
+ """Returns the status of the device setup wizard (e.g. DISABLED)."""
+ status = self.RunShellCommand('getprop ro.setupwizard.mode')[0]
+ assert status
+ return status
+
def StartMonitoringLogcat(self, clear=True, logfile=None, filters=None):
"""Starts monitoring the output of logcat, for use with WaitForLogMatch.