emrekultursay updated this revision to Diff 252622.
emrekultursay added a comment.
- Added comments to Android-specific test cases, as suggested by labath@.
- Reformatted lines that exceeded 80 chars.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76736/new/
https://reviews.llvm.org/D76736
Files:
lldb/source/Utility/UriParser.cpp
lldb/unittests/Utility/UriParserTest.cpp
Index: lldb/unittests/Utility/UriParserTest.cpp
===================================================================
--- lldb/unittests/Utility/UriParserTest.cpp
+++ lldb/unittests/Utility/UriParserTest.cpp
@@ -74,12 +74,19 @@
VALIDATE
}
-TEST(UriParserTest, TypicalPortPath) {
+TEST(UriParserTest, TypicalPortPathIPv4) {
const UriTestCase testCase("connect://192.168.100.132:5432/", "connect",
"192.168.100.132", 5432, "/");
VALIDATE;
}
+TEST(UriParserTest, TypicalPortPathIPv6) {
+ const UriTestCase testCase(
+ "connect://[2601:600:107f:db64:a42b:4faa:284:3082]:5432/", "connect",
+ "2601:600:107f:db64:a42b:4faa:284:3082", 5432, "/");
+ VALIDATE;
+}
+
TEST(UriParserTest, BracketedHostnamePort) {
const UriTestCase testCase("connect://[192.168.100.132]:5432/", "connect",
"192.168.100.132", 5432, "/");
@@ -102,6 +109,21 @@
VALIDATE
}
+TEST(UriParserTest, BracketedHostnameWithPortIPv4) {
+ // Android device over IPv4: port is a part of the hostname.
+ const UriTestCase testCase("connect://[192.168.100.132:1234]", "connect",
+ "192.168.100.132:1234", -1, "/");
+ VALIDATE
+}
+
+TEST(UriParserTest, BracketedHostnameWithPortIPv6) {
+ // Android device over IPv6: port is a part of the hostname.
+ const UriTestCase testCase(
+ "connect://[[2601:600:107f:db64:a42b:4faa:284]:1234]", "connect",
+ "[2601:600:107f:db64:a42b:4faa:284]:1234", -1, "/");
+ VALIDATE
+}
+
TEST(UriParserTest, BracketedHostnameWithColon) {
const UriTestCase testCase("connect://[192.168.100.132:5555]:1234",
"connect",
"192.168.100.132:5555", 1234, "/");
Index: lldb/source/Utility/UriParser.cpp
===================================================================
--- lldb/source/Utility/UriParser.cpp
+++ lldb/source/Utility/UriParser.cpp
@@ -42,7 +42,7 @@
// Extract hostname
if (!host_port.empty() && host_port[0] == '[') {
// hostname is enclosed with square brackets.
- pos = host_port.find(']');
+ pos = host_port.rfind(']');
if (pos == std::string::npos)
return false;
Index: lldb/unittests/Utility/UriParserTest.cpp
===================================================================
--- lldb/unittests/Utility/UriParserTest.cpp
+++ lldb/unittests/Utility/UriParserTest.cpp
@@ -74,12 +74,19 @@
VALIDATE
}
-TEST(UriParserTest, TypicalPortPath) {
+TEST(UriParserTest, TypicalPortPathIPv4) {
const UriTestCase testCase("connect://192.168.100.132:5432/", "connect",
"192.168.100.132", 5432, "/");
VALIDATE;
}
+TEST(UriParserTest, TypicalPortPathIPv6) {
+ const UriTestCase testCase(
+ "connect://[2601:600:107f:db64:a42b:4faa:284:3082]:5432/", "connect",
+ "2601:600:107f:db64:a42b:4faa:284:3082", 5432, "/");
+ VALIDATE;
+}
+
TEST(UriParserTest, BracketedHostnamePort) {
const UriTestCase testCase("connect://[192.168.100.132]:5432/", "connect",
"192.168.100.132", 5432, "/");
@@ -102,6 +109,21 @@
VALIDATE
}
+TEST(UriParserTest, BracketedHostnameWithPortIPv4) {
+ // Android device over IPv4: port is a part of the hostname.
+ const UriTestCase testCase("connect://[192.168.100.132:1234]", "connect",
+ "192.168.100.132:1234", -1, "/");
+ VALIDATE
+}
+
+TEST(UriParserTest, BracketedHostnameWithPortIPv6) {
+ // Android device over IPv6: port is a part of the hostname.
+ const UriTestCase testCase(
+ "connect://[[2601:600:107f:db64:a42b:4faa:284]:1234]", "connect",
+ "[2601:600:107f:db64:a42b:4faa:284]:1234", -1, "/");
+ VALIDATE
+}
+
TEST(UriParserTest, BracketedHostnameWithColon) {
const UriTestCase testCase("connect://[192.168.100.132:5555]:1234", "connect",
"192.168.100.132:5555", 1234, "/");
Index: lldb/source/Utility/UriParser.cpp
===================================================================
--- lldb/source/Utility/UriParser.cpp
+++ lldb/source/Utility/UriParser.cpp
@@ -42,7 +42,7 @@
// Extract hostname
if (!host_port.empty() && host_port[0] == '[') {
// hostname is enclosed with square brackets.
- pos = host_port.find(']');
+ pos = host_port.rfind(']');
if (pos == std::string::npos)
return false;
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits