[libc-commits] [libc] [libc] Add socket test support library (PR #193207)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Wed Apr 22 02:40:58 PDT 2026


================
@@ -33,15 +33,7 @@ TEST_F(LlvmLibcListenTest, ListenLocalSocket) {
   ASSERT_ERRNO_SUCCESS();
 
   struct sockaddr_un my_addr;
-
-  my_addr.sun_family = AF_UNIX;
-  unsigned int i = 0;
-  for (;
-       SOCK_PATH[i] != '\0' && (i < sizeof(sockaddr_un) - sizeof(sa_family_t));
-       ++i)
-    my_addr.sun_path[i] = SOCK_PATH[i];
-
-  my_addr.sun_path[i] = '\0';
+  ASSERT_TRUE(LIBC_NAMESPACE::testing::make_sockaddr_un(SOCK_PATH, my_addr));
----------------
labath wrote:

At the call site or inside the function?  I don't mind putting it inside the function, though I think it's kind of obvious.  I'd like to avoid putting the comment at (every) call site, as it gets repetitive, and I don't think it's that important -- a casual user only needs to know it has to check whether the function succeeded (and they can proceed with the test) or not.

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


More information about the libc-commits mailing list