Commit 2c2d879c authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Fix apk_operations.py disk-usage race condition

Caused by the way stdout and stderr were being combined. Never saw this
when I first added this logic, so I'd guess something changed on the
Android / adb side. This was failing 3/4 time on my O device.

Change-Id: I7b905a109a312fd57ab3c2e1d4dfa9521f505f02
Reviewed-on: https://chromium-review.googlesource.com/969148Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544202}
parent 390bef5d
...@@ -250,7 +250,8 @@ def _DuHelper(device, path_spec, run_as=None): ...@@ -250,7 +250,8 @@ def _DuHelper(device, path_spec, run_as=None):
# du: .*: No such file or directory # du: .*: No such file or directory
# The -d flag works differently across android version, so use -s instead. # The -d flag works differently across android version, so use -s instead.
cmd_str = 'du -s -k ' + path_spec # Without the explicit 2>&1, stderr and stdout get combined at random :(.
cmd_str = 'du -s -k ' + path_spec + ' 2>&1'
lines = device.RunShellCommand(cmd_str, run_as=run_as, shell=True, lines = device.RunShellCommand(cmd_str, run_as=run_as, shell=True,
check_return=False) check_return=False)
output = '\n'.join(lines) output = '\n'.join(lines)
...@@ -269,7 +270,9 @@ def _DuHelper(device, path_spec, run_as=None): ...@@ -269,7 +270,9 @@ def _DuHelper(device, path_spec, run_as=None):
ret[subpath] = int(size) ret[subpath] = int(size)
return ret return ret
except ValueError: except ValueError:
logging.error('du command was: %s', cmd_str)
logging.error('Failed to parse du output:\n%s', output) logging.error('Failed to parse du output:\n%s', output)
raise
def _RunDiskUsage(devices, package_name, verbose): def _RunDiskUsage(devices, package_name, verbose):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment