| Index: build/android/pylib/device/device_utils_test.py
|
| diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py
|
| index 4f47021e2dcb7ba66cc02c45f68dc3ac9597289e..eb1fd93ceb46f189649536076465f9266edeb616 100755
|
| --- a/build/android/pylib/device/device_utils_test.py
|
| +++ b/build/android/pylib/device/device_utils_test.py
|
| @@ -21,6 +21,7 @@ import sys
|
| import unittest
|
|
|
| from pylib import android_commands
|
| +from pylib import cmd_helper
|
| from pylib import constants
|
| from pylib.device import adb_wrapper
|
| from pylib.device import device_errors
|
| @@ -72,6 +73,7 @@ class MockTempFile(object):
|
| def __init__(self, name='/tmp/some/file'):
|
| self.file = mock.MagicMock(spec=file)
|
| self.file.name = name
|
| + self.file.name_quoted = cmd_helper.SingleQuote(name)
|
|
|
| def __enter__(self):
|
| return self.file
|
| @@ -621,6 +623,32 @@ class DeviceUtilsRunShellCommandTest(DeviceUtilsNewImplTest):
|
| self.call.adb.Shell("cd '/some test/path with/spaces' && ls"), ''):
|
| self.device.RunShellCommand('ls', cwd='/some test/path with/spaces')
|
|
|
| + def testRunShellCommand_withHugeCmd(self):
|
| + payload = 'hi! ' * 1024
|
| + expected_cmd = "echo '%s'" % payload
|
| + with self.assertCalls(
|
| + (mock.call.pylib.utils.device_temp_file.DeviceTempFile(
|
| + self.device, suffix='.sh'), MockTempFile('/sdcard/temp-123.sh')),
|
| + self.call.device.WriteFile(
|
| + '/sdcard/temp-123.sh', expected_cmd, as_root=False, force_push=True),
|
| + (self.call.adb.Shell('sh /sdcard/temp-123.sh'), payload + '\n')):
|
| + self.assertEquals([payload],
|
| + self.device.RunShellCommand(['echo', payload]))
|
| +
|
| + def testRunShellCommand_withHugeCmdAmdSU(self):
|
| + payload = 'hi! ' * 1024
|
| + expected_cmd = """su -c sh -c 'echo '"'"'%s'"'"''""" % payload
|
| + with self.assertCalls(
|
| + (self.call.device.NeedsSU(), True),
|
| + (mock.call.pylib.utils.device_temp_file.DeviceTempFile(
|
| + self.device, suffix='.sh'), MockTempFile('/sdcard/temp-123.sh')),
|
| + self.call.device.WriteFile(
|
| + '/sdcard/temp-123.sh', expected_cmd, as_root=False, force_push=True),
|
| + (self.call.adb.Shell('sh /sdcard/temp-123.sh'), payload + '\n')):
|
| + self.assertEquals(
|
| + [payload],
|
| + self.device.RunShellCommand(['echo', payload], as_root=True))
|
| +
|
| def testRunShellCommand_withSu(self):
|
| with self.assertCalls(
|
| (self.call.device.NeedsSU(), True),
|
|
|