[Lldb-commits] [lldb] Fix connecting via abstract socket (PR #136466)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 24 00:20:34 PDT 2025


================
@@ -339,6 +342,48 @@ TEST_F(SocketTest, DomainGetConnectURI) {
 }
 #endif
 
+#if LLDB_ENABLE_POSIX
+TEST_F(SocketTest, DomainSocketFromBoundNativeSocket) {
+  // Generate a name for the domain socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+      "DomainSocketFromBoundNativeSocket", name);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(name, "test");
+
+  DomainSocket socket(true);
+  Status error = socket.Listen(name, /*backlog=*/10);
+  ASSERT_FALSE(error.ToError());
+  NativeSocket native_socket = socket.GetNativeSocket();
+
+  llvm::Expected<std::unique_ptr<DomainSocket>> sock =
+      DomainSocket::FromBoundNativeSocket(native_socket, /*should_close=*/true);
+  ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
+  ASSERT_EQ(Socket::ProtocolUnixDomain, sock->get()->GetSocketProtocol());
+}
+#endif
+
+#if __linux__
+TEST_F(SocketTest, AbstractSocketFromBoundNativeSocket) {
+  // Generate a name for the abstract socket.
+  llvm::SmallString<64> name;
+  std::error_code EC = llvm::sys::fs::createUniqueDirectory(
+      "AbstractSocketFromBoundNativeSocket", name);
----------------
labath wrote:

This shouldn't be necessary as the abstract sockets are not tied to the file system. You can use eg. `createUniquePath` to create the socket name directly.

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


More information about the lldb-commits mailing list