am d66e949b: am 2e7c39ec: Merge ""adb tcpip" should require a numeric argument."

* commit 'd66e949b14305b367d3de4ba00901bff1122bb0e':
  "adb tcpip" should require a numeric argument.
This commit is contained in:
Elliott Hughes 2015-07-21 23:50:12 +00:00 committed by Android Git Automerger
commit 86da352c43
3 changed files with 15 additions and 3 deletions

View file

@ -1208,10 +1208,12 @@ int adb_commandline(int argc, const char **argv) {
return 0;
}
}
else if (!strcmp(argv[0], "tcpip") && argc > 1) {
return adb_connect_command(android::base::StringPrintf("tcpip:%s", argv[1]));
}
else if (!strcmp(argv[0], "remount") ||
!strcmp(argv[0], "reboot") ||
!strcmp(argv[0], "reboot-bootloader") ||
!strcmp(argv[0], "tcpip") ||
!strcmp(argv[0], "usb") ||
!strcmp(argv[0], "root") ||
!strcmp(argv[0], "unroot") ||

View file

@ -486,7 +486,7 @@ int service_to_fd(const char *name)
} else if(!strncmp(name, "tcpip:", 6)) {
int port;
if (sscanf(name + 6, "%d", &port) != 1) {
port = 0;
return -1;
}
ret = create_service_thread(restart_tcp_service, (void *) (uintptr_t) port);
} else if(!strncmp(name, "usb:", 4)) {

View file

@ -186,7 +186,7 @@ class AdbWrapper(object):
remote))
def tcpip(self, port):
return call_checked(self.adb_cmd + "tcpip {}".format(port))
return call_combined(self.adb_cmd + "tcpip {}".format(port))
def usb(self):
return call_checked(self.adb_cmd + "usb")
@ -326,6 +326,16 @@ class AdbBasic(unittest.TestCase):
else:
self.assertEqual(output, "Linux\n")
def test_tcpip(self):
"""adb tcpip requires a port. http://b/22636927"""
output, status_code = AdbWrapper().tcpip("")
self.assertEqual(1, status_code)
self.assertIn("help message", output)
output, status_code = AdbWrapper().tcpip("blah")
self.assertEqual(1, status_code)
self.assertIn("error", output)
class AdbFile(unittest.TestCase):
SCRATCH_DIR = "/data/local/tmp"