am 17f26790: Merge "Make Python tests only check the current device."
* commit '17f267905b6be932e1ff1559d84a5517e6b4b803': Make Python tests only check the current device.
This commit is contained in:
commit
e780a43eed
1 changed files with 19 additions and 46 deletions
|
|
@ -215,15 +215,13 @@ class AdbWrapper(object):
|
||||||
|
|
||||||
|
|
||||||
class AdbBasic(unittest.TestCase):
|
class AdbBasic(unittest.TestCase):
|
||||||
def test_devices(self):
|
def test_shell(self):
|
||||||
"""Get uptime for each device plugged in from /proc/uptime."""
|
"""Check that we can at least cat a file."""
|
||||||
dev_list = get_device_list()
|
adb = AdbWrapper()
|
||||||
for device in dev_list:
|
out = adb.shell("cat /proc/uptime")
|
||||||
out = call_checked(
|
self.assertEqual(len(out.split()), 2)
|
||||||
"adb -s {} shell cat /proc/uptime".format(device))
|
self.assertGreater(float(out.split()[0]), 0.0)
|
||||||
self.assertEqual(len(out.split()), 2)
|
self.assertGreater(float(out.split()[1]), 0.0)
|
||||||
self.assertGreater(float(out.split()[0]), 0.0)
|
|
||||||
self.assertGreater(float(out.split()[1]), 0.0)
|
|
||||||
|
|
||||||
def test_help(self):
|
def test_help(self):
|
||||||
"""Make sure we get _something_ out of help."""
|
"""Make sure we get _something_ out of help."""
|
||||||
|
|
@ -241,14 +239,13 @@ class AdbBasic(unittest.TestCase):
|
||||||
|
|
||||||
def test_root_unroot(self):
|
def test_root_unroot(self):
|
||||||
"""Make sure that adb root and adb unroot work, using id(1)."""
|
"""Make sure that adb root and adb unroot work, using id(1)."""
|
||||||
for device in get_device_list():
|
adb = AdbWrapper()
|
||||||
adb = AdbWrapper(device)
|
adb.root()
|
||||||
adb.root()
|
adb.wait()
|
||||||
adb.wait()
|
self.assertEqual("root", adb.shell("id -un").strip())
|
||||||
self.assertEqual("root", adb.shell("id -un").strip())
|
adb.unroot()
|
||||||
adb.unroot()
|
adb.wait()
|
||||||
adb.wait()
|
self.assertEqual("shell", adb.shell("id -un").strip())
|
||||||
self.assertEqual("shell", adb.shell("id -un").strip())
|
|
||||||
|
|
||||||
|
|
||||||
class AdbFile(unittest.TestCase):
|
class AdbFile(unittest.TestCase):
|
||||||
|
|
@ -257,15 +254,9 @@ class AdbFile(unittest.TestCase):
|
||||||
DEVICE_TEMP_DIR = SCRATCH_DIR + "/adb_test_dir"
|
DEVICE_TEMP_DIR = SCRATCH_DIR + "/adb_test_dir"
|
||||||
|
|
||||||
def test_push(self):
|
def test_push(self):
|
||||||
"""Push a file to all attached devices."""
|
|
||||||
dev_list = get_device_list()
|
|
||||||
for device in dev_list:
|
|
||||||
self.push_with_device(device)
|
|
||||||
|
|
||||||
def push_with_device(self, device):
|
|
||||||
"""Push a randomly generated file to specified device."""
|
"""Push a randomly generated file to specified device."""
|
||||||
kbytes = 512
|
kbytes = 512
|
||||||
adb = AdbWrapper(device)
|
adb = AdbWrapper()
|
||||||
with tempfile.NamedTemporaryFile(mode="w") as tmp:
|
with tempfile.NamedTemporaryFile(mode="w") as tmp:
|
||||||
rand_str = os.urandom(1024 * kbytes)
|
rand_str = os.urandom(1024 * kbytes)
|
||||||
tmp.write(rand_str)
|
tmp.write(rand_str)
|
||||||
|
|
@ -284,15 +275,9 @@ class AdbFile(unittest.TestCase):
|
||||||
# TODO: write push directory test.
|
# TODO: write push directory test.
|
||||||
|
|
||||||
def test_pull(self):
|
def test_pull(self):
|
||||||
"""Pull a file from all attached devices."""
|
|
||||||
dev_list = get_device_list()
|
|
||||||
for device in dev_list:
|
|
||||||
self.pull_with_device(device)
|
|
||||||
|
|
||||||
def pull_with_device(self, device):
|
|
||||||
"""Pull a randomly generated file from specified device."""
|
"""Pull a randomly generated file from specified device."""
|
||||||
kbytes = 512
|
kbytes = 512
|
||||||
adb = AdbWrapper(device)
|
adb = AdbWrapper()
|
||||||
adb.shell_nocheck("rm -r {}".format(AdbFile.DEVICE_TEMP_FILE))
|
adb.shell_nocheck("rm -r {}".format(AdbFile.DEVICE_TEMP_FILE))
|
||||||
try:
|
try:
|
||||||
adb.shell("dd if=/dev/urandom of={} bs=1024 count={}".format(
|
adb.shell("dd if=/dev/urandom of={} bs=1024 count={}".format(
|
||||||
|
|
@ -310,14 +295,8 @@ class AdbFile(unittest.TestCase):
|
||||||
adb.shell_nocheck("rm {}".format(AdbFile.DEVICE_TEMP_FILE))
|
adb.shell_nocheck("rm {}".format(AdbFile.DEVICE_TEMP_FILE))
|
||||||
|
|
||||||
def test_pull_dir(self):
|
def test_pull_dir(self):
|
||||||
"""Pull a directory from all attached devices."""
|
|
||||||
dev_list = get_device_list()
|
|
||||||
for device in dev_list:
|
|
||||||
self.pull_dir_with_device(device)
|
|
||||||
|
|
||||||
def pull_dir_with_device(self, device):
|
|
||||||
"""Pull a randomly generated directory of files from the device."""
|
"""Pull a randomly generated directory of files from the device."""
|
||||||
adb = AdbWrapper(device)
|
adb = AdbWrapper()
|
||||||
temp_files = {}
|
temp_files = {}
|
||||||
host_dir = None
|
host_dir = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -350,15 +329,9 @@ class AdbFile(unittest.TestCase):
|
||||||
os.removedirs(host_dir)
|
os.removedirs(host_dir)
|
||||||
|
|
||||||
def test_sync(self):
|
def test_sync(self):
|
||||||
"""Sync a directory with all attached devices."""
|
|
||||||
dev_list = get_device_list()
|
|
||||||
for device in dev_list:
|
|
||||||
self.sync_dir_with_device(device)
|
|
||||||
|
|
||||||
def sync_dir_with_device(self, device):
|
|
||||||
"""Sync a randomly generated directory of files to specified device."""
|
"""Sync a randomly generated directory of files to specified device."""
|
||||||
try:
|
try:
|
||||||
adb = AdbWrapper(device)
|
adb = AdbWrapper()
|
||||||
temp_files = {}
|
temp_files = {}
|
||||||
|
|
||||||
# create temporary host directory
|
# create temporary host directory
|
||||||
|
|
@ -373,7 +346,7 @@ class AdbFile(unittest.TestCase):
|
||||||
num_files=32)
|
num_files=32)
|
||||||
|
|
||||||
# clean up any trash on the device
|
# clean up any trash on the device
|
||||||
adb = AdbWrapper(device, out_dir=base_dir)
|
adb = AdbWrapper(out_dir=base_dir)
|
||||||
adb.shell_nocheck("rm -r {}".format(AdbFile.DEVICE_TEMP_DIR))
|
adb.shell_nocheck("rm -r {}".format(AdbFile.DEVICE_TEMP_DIR))
|
||||||
|
|
||||||
# issue the sync
|
# issue the sync
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue