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

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

Issue 204353011: If install of test apk fails because of storage, wipe device data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update description to include removal from status check. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | 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) 2013 The Chromium Authors. All rights reserved. 3 # Copyright (c) 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 """Provisions Android devices with settings required for bots. 7 """Provisions Android devices with settings required for bots.
8 8
9 Usage: 9 Usage:
10 ./provision_devices.py [-d <device serial number>] 10 ./provision_devices.py [-d <device serial number>]
11 """ 11 """
12 12
13 import logging 13 import logging
14 import optparse 14 import optparse
15 import os 15 import os
16 import re 16 import re
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import time 19 import time
20 20
21 from pylib import android_commands 21 from pylib import android_commands
22 from pylib import constants 22 from pylib import constants
23 from pylib import device_settings 23 from pylib import device_settings
24 from pylib.cmd_helper import GetCmdOutput
24 25
25 26
26 def KillHostHeartbeat(): 27 def KillHostHeartbeat():
27 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) 28 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE)
28 stdout, _ = ps.communicate() 29 stdout, _ = ps.communicate()
29 matches = re.findall('\\n.*host_heartbeat.*', stdout) 30 matches = re.findall('\\n.*host_heartbeat.*', stdout)
30 for match in matches: 31 for match in matches:
31 print 'An instance of host heart beart running... will kill' 32 print 'An instance of host heart beart running... will kill'
32 pid = re.findall('(\d+)', match)[1] 33 pid = re.findall('(\d+)', match)[1]
33 subprocess.call(['kill', str(pid)]) 34 subprocess.call(['kill', str(pid)])
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 android_commands.LOCAL_PROPERTIES_PATH) 84 android_commands.LOCAL_PROPERTIES_PATH)
84 85
85 86
86 def ProvisionDevices(options): 87 def ProvisionDevices(options):
87 if options.device is not None: 88 if options.device is not None:
88 devices = [options.device] 89 devices = [options.device]
89 else: 90 else:
90 devices = android_commands.GetAttachedDevices() 91 devices = android_commands.GetAttachedDevices()
91 for device in devices: 92 for device in devices:
92 android_cmd = android_commands.AndroidCommands(device) 93 android_cmd = android_commands.AndroidCommands(device)
94 install_output = GetCmdOutput(
95 ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT,
96 '--apk',
97 '%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT
98 ])
99 failure_string = 'Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]'
100 if failure_string not in install_output:
navabi 2014/03/21 00:12:14 oops, this was for testing. should be "failure_str
101 # Wipe data before provisioning device.
102 android_cmd.RunShellCommandWithSU('wipe data')
93 _ConfigureLocalProperties(android_cmd) 103 _ConfigureLocalProperties(android_cmd)
94 device_settings.ConfigureContentSettingsDict( 104 device_settings.ConfigureContentSettingsDict(
95 android_cmd, device_settings.DETERMINISTIC_DEVICE_SETTINGS) 105 android_cmd, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
96 # TODO(tonyg): We eventually want network on. However, currently radios 106 # TODO(tonyg): We eventually want network on. However, currently radios
97 # can cause perfbots to drain faster than they charge. 107 # can cause perfbots to drain faster than they charge.
98 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower(): 108 if 'perf' in os.environ.get('BUILDBOT_BUILDERNAME', '').lower():
99 device_settings.ConfigureContentSettingsDict( 109 device_settings.ConfigureContentSettingsDict(
100 android_cmd, device_settings.NETWORK_DISABLED_SETTINGS) 110 android_cmd, device_settings.NETWORK_DISABLED_SETTINGS)
101 android_cmd.RunShellCommandWithSU('date -u %f' % time.time()) 111 android_cmd.RunShellCommandWithSU('date -u %f' % time.time())
102 if options.auto_reconnect: 112 if options.auto_reconnect:
(...skipping 15 matching lines...) Expand all
118 128
119 if args: 129 if args:
120 print >> sys.stderr, 'Unused args %s' % args 130 print >> sys.stderr, 'Unused args %s' % args
121 return 1 131 return 1
122 132
123 ProvisionDevices(options) 133 ProvisionDevices(options)
124 134
125 135
126 if __name__ == '__main__': 136 if __name__ == '__main__':
127 sys.exit(main(sys.argv)) 137 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698