adb: add tests for pushing/pulling empty dirs.

Change-Id: I840a31fc8f37939a1166ac39700363a8b79cc3be
This commit is contained in:
Josh Gao
2015-11-06 14:34:18 -08:00
parent 86d58fb9f8
commit cdf675849c

View File

@@ -607,6 +607,32 @@ class FileOperationsTest(DeviceTest):
if host_dir is not None: if host_dir is not None:
shutil.rmtree(host_dir) shutil.rmtree(host_dir)
@unittest.expectedFailure # b/25566053
def test_push_empty(self):
"""Push a directory containing an empty directory to the device."""
self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
self.device.shell(['mkdir', self.DEVICE_TEMP_DIR])
try:
host_dir = tempfile.mkdtemp()
# Make sure the temp directory isn't setuid, or else adb will complain.
os.chmod(host_dir, 0o700)
# Create an empty directory.
os.mkdir(os.path.join(host_dir, 'empty'))
self.device.push(host_dir, self.DEVICE_TEMP_DIR)
test_empty_cmd = ['[', '-d',
os.path.join(self.DEVICE_TEMP_DIR, 'empty')]
rc, _, _ = self.device.shell_nocheck(test_empty_cmd)
self.assertEqual(rc, 0)
self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
finally:
if host_dir is not None:
shutil.rmtree(host_dir)
def test_multiple_push(self): def test_multiple_push(self):
"""Push multiple files to the device in one adb push command. """Push multiple files to the device in one adb push command.
@@ -709,6 +735,20 @@ class FileOperationsTest(DeviceTest):
if host_dir is not None: if host_dir is not None:
shutil.rmtree(host_dir) shutil.rmtree(host_dir)
def test_pull_empty(self):
"""Pull a directory containing an empty directory from the device."""
try:
host_dir = tempfile.mkdtemp()
remote_empty_path = posixpath.join(self.DEVICE_TEMP_DIR, 'empty')
self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
self.device.shell(['mkdir', '-p', remote_empty_path])
self.device.pull(remote=self.DEVICE_TEMP_DIR, local=host_dir)
self.assertTrue(os.path.isdir(os.path.join(host_dir, 'empty')))
finally:
if host_dir is not None:
shutil.rmtree(host_dir)
def test_multiple_pull(self): def test_multiple_pull(self):
"""Pull a randomly generated directory of files from the device.""" """Pull a randomly generated directory of files from the device."""