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

Unified Diff: build/android/provision_devices.py

Issue 1370873002: [Android] remount file system as writeable when failing to push files to external storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/provision_devices.py
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py
index faf980f73dfd14ed9c7e917294d0010421327618..8188803b31f5ac337ee49fab62f4f1326ca50c4a 100755
--- a/build/android/provision_devices.py
+++ b/build/android/provision_devices.py
@@ -16,6 +16,7 @@ import json
import logging
import os
import posixpath
+import random
import re
import subprocess
import sys
@@ -99,6 +100,7 @@ def ProvisionDevice(device, blacklist, options):
device.adb.WaitForDevice()
try:
+ CheckExternalStorage(device)
if should_run_phase(_PHASES.WIPE):
if options.chrome_specific_wipe:
run_phase(WipeChromeData)
@@ -126,6 +128,24 @@ def ProvisionDevice(device, blacklist, options):
str(device))
blacklist.Extend([str(device)])
+def CheckExternalStorage(device):
+ """Checks that storage is writable and if not makes it writable.
+
+ Arguments:
+ device: The device to check.
+ """
+ # Write a file with random name to $EXTERNAL_STORAGE to test writability.
jbudorick 2015/09/28 18:01:17 Use DeviceTempFile with dir=device.GetExternalStor
rnephew (Reviews Here) 2015/09/28 18:34:06 Done.
+ file_path = (
+ device.GetExternalStoragePath() + '/' + str(random.randint(0, 9999999)))
+ try:
+ device.WriteFile(file_path, 'test')
+ except device_errors.CommandFailedError:
+ logging.info('External storage not writable. Remounting / as RW')
+ device.RunShellCommand(['mount', '-o', 'remount,rw', '/'],
+ check_return=True, as_root=True)
+ device.WriteFile(file_path, 'test')
+ finally:
+ device.RunShellCommand(['rm', file_path], check_return=True)
def WipeChromeData(device, options):
"""Wipes chrome specific data from device
@@ -392,7 +412,6 @@ def _LaunchHostHeartbeat():
subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT,
'build/android/host_heartbeat.py')])
-
def KillHostHeartbeat():
ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
stdout, _ = ps.communicate()
@@ -402,7 +421,6 @@ def KillHostHeartbeat():
pid = re.findall(r'(\S+)', match)[1]
subprocess.call(['kill', str(pid)])
-
def main():
# Recommended options on perf bots:
# --disable-network
« 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