Lines Matching refs:device
43 if self.device.get_prop('ro.debuggable') != '1':
46 was_root = self.device.shell(['id', '-un'])[0].strip() == 'root'
48 self.device.root()
49 self.device.wait()
55 self.device.unroot()
56 self.device.wait()
63 was_root = self.device.shell(['id', '-un'])[0].strip() == 'root'
65 self.device.unroot()
66 self.device.wait()
72 self.device.root()
73 self.device.wait()
91 @mock.patch('adb.device.get_devices')
94 device = adb.get_device('foo')
95 self.assertEqual(device.serial, 'foo')
97 @mock.patch('adb.device.get_devices')
101 device = adb.get_device()
102 self.assertEqual(device.serial, 'foo')
104 @mock.patch('adb.device.get_devices')
108 device = adb.get_device('foo')
109 self.assertEqual(device.serial, 'foo')
111 @mock.patch('adb.device.get_devices')
119 @mock.patch('adb.device.get_devices')
122 device = adb.get_device()
123 self.assertEqual(device.serial, 'foo')
125 @mock.patch('adb.device.get_devices')
133 self.device = adb.get_device()
166 self._test_no_rebind('forward', self.device.forward_list,
167 self.device.forward, self.device.forward_no_rebind,
168 self.device.forward_remove_all)
171 self._test_no_rebind('reverse', self.device.reverse_list,
172 self.device.reverse, self.device.reverse_no_rebind,
173 self.device.reverse_remove_all)
176 msg = self.device.forward_list()
179 self.device.forward('tcp:5566', 'tcp:6655')
180 msg = self.device.forward_list()
182 self.device.forward('tcp:7788', 'tcp:8877')
183 msg = self.device.forward_list()
186 self.device.forward_remove('tcp:5566')
187 msg = self.device.forward_list()
190 self.device.forward_remove_all()
191 msg = self.device.forward_list()
195 msg = self.device.reverse_list()
198 self.device.reverse('tcp:5566', 'tcp:6655')
199 msg = self.device.reverse_list()
201 self.device.reverse('tcp:7788', 'tcp:8877')
202 msg = self.device.reverse_list()
205 self.device.reverse_remove('tcp:5566')
206 msg = self.device.reverse_list()
209 self.device.reverse_remove_all()
210 msg = self.device.reverse_list()
213 # Note: If you run this test when adb connect'd to a physical device over
226 self.device.forward(forward_spec, forward_spec)
229 self.device.reverse(forward_spec, reverse_spec)
263 self.device.reverse_remove(forward_spec)
265 self.device.forward_remove(forward_spec)
280 unittest.SkipTest: The device doesn't support exit codes.
282 if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
283 raise unittest.SkipTest('exit codes are unavailable on this device')
286 self.device.adb_cmd + ['shell'] + shell_args,
290 # to explicitly add an exit command to close the session from the device
297 out = self.device.shell(['cat', '/proc/uptime'])[0].strip()
306 self.assertRaises(adb.ShellError, self.device.shell, ['false'])
309 out = self.device.shell(['echo', 'foo'])[0]
310 self.assertEqual(out, 'foo' + self.device.linesep)
313 rc, out, _ = self.device.shell_nocheck(['false'])
318 rc, out, _ = self.device.shell_nocheck(['echo', 'foo'])
320 self.assertEqual(out, 'foo' + self.device.linesep)
326 rc, out, _ = self.device.shell_nocheck(['echo', '-n', '1'])
335 output = self.device.shell(['uname'])[0]
336 self.assertEqual(output, 'Linux' + self.device.linesep)
345 if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
346 raise unittest.SkipTest('PTY arguments unsupported on this device')
362 test_cmd = self.device.adb_cmd + ['shell'] + args + ['[ -t 0 ]']
390 """Tests the shell protocol on the device.
392 If the device supports shell protocol, this gives us the ability
397 if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
398 raise unittest.SkipTest('shell protocol unsupported on this device')
401 result = self.device.shell_nocheck(
404 self.assertEqual('foo' + self.device.linesep, result[1])
405 self.assertEqual('bar' + self.device.linesep, result[2])
410 result = self.device.shell_nocheck(
413 self.assertEqual('foo{0}bar{0}'.format(self.device.linesep), result[1])
427 if self.devicedevice.features:
428 raise unittest.SkipTest('shell protocol unsupported on this device')
432 self.device.adb_cmd + shlex.split('shell echo $$; sleep 60'),
440 self.device.shell(proc_query)
443 self.assertEqual(1, self.device.shell_nocheck(proc_query)[0],
448 if self.device.SHELL_PROTOCOL_FEATURE not in self.device.features:
450 'on this device')
458 proc = subprocess.Popen(self.device.adb_cmd + ['shell', 'cat'],
476 result = self.device.shell(
481 result = self.device.shell(
486 result = self.device.shell(shlex.split("'true && echo t'"))[0].strip()
488 result = self.device.shell(
493 result = self.device.shell(shlex.split('FOO=a BAR=b echo t'))[0].strip()
495 result = self.device.shell(
507 # Installing bogus .apks fails if the device supports exit codes.
509 output = self.device.install(tf.name)
519 message = self.device.root()
522 self.device.wait()
523 self.assertEqual('root', self.device.shell(['id', '-un'])[0].strip())
526 self.device.unroot()
527 self.device.wait()
528 self.assertEqual('shell', self.device.shell(['id', '-un'])[0].strip())
532 if self.device.get_prop('ro.debuggable') != '1':
535 original_user = self.device.shell(['id', '-un'])[0].strip()
545 self.device.root()
547 self.device.unroot()
548 self.device.wait()
558 subprocess.CalledProcessError, self.device.tcpip, '')
560 subprocess.CalledProcessError, self.device.tcpip, 'foo')
565 self.assertEqual(self.device.get_prop('init.svc.adbd'), 'running')
570 self.device.shell(['setprop', prop_name, '""'])
572 self.device.set_prop(prop_name, 'qux')
574 self.device.shell(['getprop', prop_name])[0].strip(), 'qux')
583 def get_md5_prog(device):
586 device.shell(['md5sum', '/proc/uptime'])
626 def make_random_device_files(device, in_dir, num_files, prefix='device_tmpfile'):
637 device.shell(['dd', 'if=/dev/urandom', 'of={}'.format(full_path),
639 dev_md5, _ = device.shell([get_md5_prog(device), full_path])[0].split()
651 dev_md5, _ = self.device.shell([get_md5_prog(self.device),
661 """Push a randomly generated file to specified device."""
668 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_FILE])
669 self.device.push(local=tmp.name, remote=self.DEVICE_TEMP_FILE)
672 self.device.shell(['rm', '-f', self.DEVICE_TEMP_FILE])
677 """Push a randomly generated directory of files to the device."""
678 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
679 self.device.shell(['mkdir', self.DEVICE_TEMP_DIR])
689 self.device.push(host_dir, self.DEVICE_TEMP_DIR)
696 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
703 """Push a directory containing an empty directory to the device."""
704 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
705 self.device.shell(['mkdir', self.DEVICE_TEMP_DIR])
716 self.device.push(host_dir, self.DEVICE_TEMP_DIR)
720 rc, _, _ = self.device.shell_nocheck(test_empty_cmd)
722 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
728 """Push multiple files to the device in one adb push command.
733 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
734 self.device.shell(['mkdir', self.DEVICE_TEMP_DIR])
749 self.device._simple_call(['push'] + paths + [self.DEVICE_TEMP_DIR])
764 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
779 self.device.push(local=tmp_file.name, remote='/system/')
789 self.device.pull(remote=remote_file, local=tmp_write.name)
798 self.device.shell(['touch', self.DEVICE_TEMP_FILE])
799 self.device.shell(['chmod', 'a-rwx', self.DEVICE_TEMP_FILE])
802 output = self.device.pull(remote=self.DEVICE_TEMP_FILE, local='x')
808 self.device.shell(['rm', '-f', self.DEVICE_TEMP_FILE])
811 """Pull a randomly generated file from specified device."""
813 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_FILE])
817 self.device.shell(cmd)
818 dev_md5, _ = self.device.shell(
819 [get_md5_prog(self.device), self.DEVICE_TEMP_FILE])[0].split()
821 self.device.shell_nocheck(['rm', self.DEVICE_TEMP_FILE])
824 """Pull a randomly generated directory of files from the device."""
828 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
829 self.device.shell(['mkdir', '-p', self.DEVICE_TEMP_DIR])
831 # Populate device directory with random files.
833 self.device, in_dir=self.DEVICE_TEMP_DIR, num_files=32)
835 self.device.pull(remote=self.DEVICE_TEMP_DIR, local=host_dir)
843 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
863 device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
864 self.device.shell(['mkdir', '-p', self.DEVICE_TEMP_DIR])
866 # Populate device directory with random files.
868 self.device, in_dir=self.DEVICE_TEMP_DIR, num_files=32)
870 self.device.pull(remote=self.DEVICE_TEMP_DIR, local=symlink)
878 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
896 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
897 self.device.shell(['mkdir', '-p', self.DEVICE_TEMP_DIR])
899 # Populate device directory with random files.
901 self.device, in_dir=self.DEVICE_TEMP_DIR, num_files=32)
903 self.device.pull(remote=self.DEVICE_TEMP_DIR, local=host_dir)
909 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
915 """Pull a directory of files from the device to a nonexistent path."""
920 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
921 self.device.shell(['mkdir', '-p', self.DEVICE_TEMP_DIR])
923 # Populate device directory with random files.
925 self.device, in_dir=self.DEVICE_TEMP_DIR, num_files=32)
927 self.device.pull(remote=self.DEVICE_TEMP_DIR, local=dest_dir)
933 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
947 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
948 self.device.shell(['mkdir', '-p', remote_dir, remote_links])
949 self.device.shell(['ln', '-s', remote_links, remote_symlink])
951 # Populate device directory with random files.
953 self.device, in_dir=remote_dir, num_files=32)
956 self.device.shell(
960 self.device.pull(remote=remote_symlink, local=host_dir)
967 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
973 """Pull a directory containing an empty directory from the device."""
978 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
979 self.device.shell(['mkdir', '-p', remote_empty_path])
981 self.device.pull(remote=remote_empty_path, local=host_dir)
988 """Pull a randomly generated directory of files from the device."""
994 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
995 self.device.shell(['mkdir', '-p', subdir])
999 self.device, in_dir=self.DEVICE_TEMP_DIR, num_files=4)
1002 self.device, in_dir=subdir, num_files=4, prefix='subdir_')
1006 self.device._simple_call(['pull'] + paths + [host_dir])
1018 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
1024 """Sync a randomly generated directory of files to specified device."""
1029 # Create mirror device directory hierarchy within base_dir.
1036 # Clean up any trash on the device.
1037 device = adb.get_device(product=base_dir)
1038 device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
1040 device.sync('data')
1042 # Confirm that every file on the device mirrors that on the host.
1046 dev_md5, _ = device.shell(
1047 [get_md5_prog(self.device), device_full_path])[0].split()
1050 self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR])
1059 self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])
1065 self.device.push(tf.name, remote_path)
1069 # Verify that the device ended up with the expected UTF-8 path
1070 output = self.device.shell(
1075 self.device.pull(remote_path, tf.name)
1078 self.device.shell(['rm', '-f', '/data/local/tmp/adb-test-*'])