Add a test for "adb pull" error reporting.
Bug: http://b/6205106 Change-Id: I2093c3d451361d48056b85c8017acb032a3ff478
This commit is contained in:
@@ -54,6 +54,23 @@ def requires_root(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
def requires_non_root(func):
|
||||
def wrapper(self, *args):
|
||||
was_root = self.device.shell(['id', '-un'])[0].strip() == 'root'
|
||||
if was_root:
|
||||
self.device.unroot()
|
||||
self.device.wait()
|
||||
|
||||
try:
|
||||
func(self, *args)
|
||||
finally:
|
||||
if was_root:
|
||||
self.device.root()
|
||||
self.device.wait()
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class GetDeviceTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.android_serial = os.getenv('ANDROID_SERIAL')
|
||||
@@ -496,6 +513,20 @@ class FileOperationsTest(DeviceTest):
|
||||
self.assertEqual(checksum, host_md5)
|
||||
os.remove(tmp_write.name)
|
||||
|
||||
@requires_non_root
|
||||
def test_pull_error_reporting(self):
|
||||
self.device.shell(['touch', self.DEVICE_TEMP_FILE])
|
||||
self.device.shell(['chmod', 'a-rwx', self.DEVICE_TEMP_FILE])
|
||||
|
||||
try:
|
||||
output = self.device.pull(remote=self.DEVICE_TEMP_FILE, local='x')
|
||||
except subprocess.CalledProcessError as e:
|
||||
output = e.output
|
||||
|
||||
self.assertIn('Permission denied', output)
|
||||
|
||||
self.device.shell(['rm', '-f', self.DEVICE_TEMP_FILE])
|
||||
|
||||
def test_pull(self):
|
||||
"""Pull a randomly generated file from specified device."""
|
||||
kbytes = 512
|
||||
|
||||
Reference in New Issue
Block a user