[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 3 10:22:51 PST 2024


================
@@ -225,12 +247,29 @@ TEST_P(SocketTest, TCPListen0GetPort) {
   if (!HostSupportsIPv4())
     return;
   llvm::Expected<std::unique_ptr<TCPSocket>> sock =
-      Socket::TcpListen("10.10.12.3:0", false);
+      Socket::TcpListen("10.10.12.3:0", 5);
   ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
   ASSERT_TRUE(sock.get()->IsValid());
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
 }
 
+TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) {
+  if (!HostSupportsProtocol())
+    return;
+
+  std::string addr = llvm::formatv("[{0}]:0", GetParam().localhost_ip).str();
+  llvm::Expected<std::unique_ptr<TCPSocket>> sock = Socket::TcpListen(addr);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_TRUE(sock.get()->IsValid());
+
+  for (const auto &URI : sock.get()->GetListeningConnectionURI()) {
+    EXPECT_EQ(URI,
+              llvm::formatv("connection://[{0}]:{1}", GetParam().localhost_ip,
+                            sock->get()->GetLocalPortNumber())
+                  .str());
+  }
+}
----------------
ashgti wrote:

Applied suggestion

https://github.com/llvm/llvm-project/pull/118330


More information about the lldb-commits mailing list