Fix adb tcpip tests.
The test was assuming we still output the full help for every syntax error.
While I'm here, make the diagnostics suck less.
Bug: N/A
Test: ran tests
Change-Id: Idc28616f20c66391f32046cf4216f122998a84bd
diff --git a/commandline.cpp b/commandline.cpp
index 9f23473..d126f52 100644
--- a/commandline.cpp
+++ b/commandline.cpp
@@ -1588,9 +1588,13 @@
} else {
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], "tcpip")) {
+ if (argc != 2) return syntax_error("tcpip requires an argument");
+ int port;
+ if (!android::base::ParseInt(argv[1], &port, 1, 65535)) {
+ return syntax_error("tcpip: invalid port: %s", argv[1]);
+ }
+ return adb_connect_command(android::base::StringPrintf("tcpip:%d", port));
}
else if (!strcmp(argv[0], "remount") ||
!strcmp(argv[0], "reboot") ||