| 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 58dd56ac9ee8a01abcde63f65744733a8f7d046b..23a26e7477ee6a6879732bbb7256f2319c8dd9d4 100755
|
| --- a/build/android/pylib/device/device_utils_test.py
|
| +++ b/build/android/pylib/device/device_utils_test.py
|
| @@ -1049,56 +1049,33 @@ class DeviceUtilsPullFileTest(DeviceUtilsNewImplTest):
|
| '/test/file/host/path')
|
|
|
|
|
| -class DeviceUtilsReadFileTest(DeviceUtilsOldImplTest):
|
| +class DeviceUtilsReadFileTest(DeviceUtilsNewImplTest):
|
|
|
| def testReadFile_exists(self):
|
| - with self.assertCallsSequence([
|
| - ("adb -s 0123456789abcdef shell "
|
| - "'cat \"/read/this/test/file\" 2>/dev/null'",
|
| - 'this is a test file')]):
|
| - self.assertEqual(['this is a test file'],
|
| + with self.assertCall(
|
| + self.call.adb.Shell('cat /read/this/test/file'),
|
| + 'this is a test file\r\n'):
|
| + self.assertEqual('this is a test file\n',
|
| self.device.ReadFile('/read/this/test/file'))
|
|
|
| def testReadFile_doesNotExist(self):
|
| - with self.assertCalls(
|
| - "adb -s 0123456789abcdef shell "
|
| - "'cat \"/this/file/does.not.exist\" 2>/dev/null'",
|
| - ''):
|
| - self.device.ReadFile('/this/file/does.not.exist')
|
| -
|
| - def testReadFile_asRoot_withRoot(self):
|
| - self.device.old_interface._privileged_command_runner = (
|
| - self.device.old_interface.RunShellCommand)
|
| - self.device.old_interface._protected_file_access_method_initialized = True
|
| - with self.assertCallsSequence([
|
| - ("adb -s 0123456789abcdef shell "
|
| - "'cat \"/this/file/must.be.read.by.root\" 2> /dev/null'",
|
| - 'this is a test file\nread by root')]):
|
| - self.assertEqual(
|
| - ['this is a test file', 'read by root'],
|
| - self.device.ReadFile('/this/file/must.be.read.by.root',
|
| - as_root=True))
|
| + with self.assertCall(
|
| + self.call.adb.Shell('cat /this/file/does.not.exist'),
|
| + self.ShellError('/system/bin/sh: cat: /this/file/does.not.exist: '
|
| + 'No such file or directory')):
|
| + with self.assertRaises(device_errors.AdbCommandFailedError):
|
| + self.device.ReadFile('/this/file/does.not.exist')
|
|
|
| - def testReadFile_asRoot_withSu(self):
|
| - self.device.old_interface._privileged_command_runner = (
|
| - self.device.old_interface.RunShellCommandWithSU)
|
| - self.device.old_interface._protected_file_access_method_initialized = True
|
| - with self.assertCallsSequence([
|
| - ("adb -s 0123456789abcdef shell "
|
| - "'su -c cat \"/this/file/can.be.read.with.su\" 2> /dev/null'",
|
| - 'this is a test file\nread with su')]):
|
| + def testReadFile_withSU(self):
|
| + with self.assertCalls(
|
| + (self.call.device.NeedsSU(), True),
|
| + (self.call.adb.Shell("su -c sh -c 'cat /this/file/can.be.read.with.su'"),
|
| + 'this is a test file\nread with su')):
|
| self.assertEqual(
|
| - ['this is a test file', 'read with su'],
|
| + 'this is a test file\nread with su\n',
|
| self.device.ReadFile('/this/file/can.be.read.with.su',
|
| as_root=True))
|
|
|
| - def testReadFile_asRoot_rejected(self):
|
| - self.device.old_interface._privileged_command_runner = None
|
| - self.device.old_interface._protected_file_access_method_initialized = True
|
| - with self.assertRaises(device_errors.CommandFailedError):
|
| - self.device.ReadFile('/this/file/cannot.be.read.by.user',
|
| - as_root=True)
|
| -
|
|
|
| class DeviceUtilsWriteFileTest(DeviceUtilsNewImplTest):
|
|
|
|
|