[libc-commits] [libc] [llvm] [libc] Fix sockatmark test (PR #210655)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Mon Jul 20 07:53:33 PDT 2026


================
@@ -13,29 +13,40 @@
 
 #include "hdr/sys_socket_macros.h" // For AF_UNIX and SOCK_DGRAM
 #include "src/__support/CPP/scope.h"
+#include "src/sys/socket/send.h"
 #include "src/sys/socket/sockatmark.h"
 #include "src/sys/socket/socketpair.h"
 #include "src/unistd/close.h"
 #include "src/unistd/pipe.h"
 #include "test/UnitTest/ErrnoCheckingTest.h"
 #include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/TestLogger.h"
 
 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
 using LlvmLibcSockatmarkTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
 using LIBC_NAMESPACE::cpp::scope_exit;
 
-TEST_F(LlvmLibcSockatmarkTest, SocketpairReturnsFalse) {
+TEST_F(LlvmLibcSockatmarkTest, Socketpair) {
   int sockpair[2] = {-1, -1};
-  ASSERT_THAT(LIBC_NAMESPACE::socketpair(AF_UNIX, SOCK_DGRAM, 0, sockpair),
+  ASSERT_THAT(LIBC_NAMESPACE::socketpair(AF_UNIX, SOCK_STREAM, 0, sockpair),
               Succeeds(0));
+  if (LIBC_NAMESPACE::send(sockpair[0], ".", 1, MSG_OOB) != 1) {
+    ASSERT_ERRNO_EQ(EOPNOTSUPP);
+    LIBC_NAMESPACE::testing::tlog << "No kernel support for AF_UNIX OOB\n";
+    ASSERT_THAT(LIBC_NAMESPACE::sockatmark(sockpair[0]), Fails(ENOTTY));
+    return;
+  }
+
   scope_exit close_sockpair([&] {
----------------
kaladron wrote:

This should be moved to right after socketpair succeed, I think.  Otherwise the above assert could leak them.

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


More information about the libc-commits mailing list