Chromium Code Reviews| 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 |