[libc-commits] [libc] [libc] Use internal::clock_gettime in socketopt_test (PR #208667)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Fri Jul 10 02:08:57 PDT 2026
https://github.com/labath created https://github.com/llvm/llvm-project/pull/208667
The external entry point is not available in overlay mode, causing this test to not run there. Other tests also use the internal function.
>From 93b7b106d93348321c5c02ba810be19bfacb1703 Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Fri, 10 Jul 2026 09:05:09 +0000
Subject: [PATCH] [libc] Use internal::clock_gettime in socketopt_test
The external entry point is not available in overlay mode, causing this
test to not run there. Other tests also use the internal function.
---
libc/test/src/sys/socket/linux/CMakeLists.txt | 2 +-
libc/test/src/sys/socket/linux/socketopt_test.cpp | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/libc/test/src/sys/socket/linux/CMakeLists.txt b/libc/test/src/sys/socket/linux/CMakeLists.txt
index 44b9fea16a40d..1f28b99601e61 100644
--- a/libc/test/src/sys/socket/linux/CMakeLists.txt
+++ b/libc/test/src/sys/socket/linux/CMakeLists.txt
@@ -129,10 +129,10 @@ add_libc_unittest(
libc.src.sys.socket.socket
libc.src.sys.socket.socketpair
libc.src.sys.socket.recv
- libc.src.time.clock_gettime
libc.src.unistd.close
libc.src.unistd.pipe
libc.src.__support.CPP.scope
+ libc.src.__support.time.clock_gettime
libc.test.UnitTest.ErrnoCheckingTest
libc.test.UnitTest.ErrnoSetterMatcher
)
diff --git a/libc/test/src/sys/socket/linux/socketopt_test.cpp b/libc/test/src/sys/socket/linux/socketopt_test.cpp
index 3af47c3f18a7d..8fd03c2cf24d4 100644
--- a/libc/test/src/sys/socket/linux/socketopt_test.cpp
+++ b/libc/test/src/sys/socket/linux/socketopt_test.cpp
@@ -11,13 +11,12 @@
#include "hdr/types/struct_linger.h"
#include "hdr/types/struct_timespec.h"
#include "hdr/types/struct_timeval.h"
+#include "src/__support/time/clock_gettime.h"
#include "src/sys/socket/getsockopt.h"
#include "src/sys/socket/recv.h"
#include "src/sys/socket/setsockopt.h"
#include "src/sys/socket/socket.h"
#include "src/sys/socket/socketpair.h"
-#include "src/time/clock_gettime.h"
-
#include "src/unistd/close.h"
#include "src/unistd/pipe.h"
@@ -145,11 +144,13 @@ TEST_F(LlvmLibcSocketOptTest, ReceiveTimeout) {
char buffer[10];
struct timespec start, end;
- ASSERT_EQ(LIBC_NAMESPACE::clock_gettime(CLOCK_MONOTONIC, &start), 0);
+ ASSERT_TRUE(LIBC_NAMESPACE::internal::clock_gettime(CLOCK_MONOTONIC, &start)
+ .has_value());
// Read/recv on empty socket should block for ~1s and fail with EAGAIN.
ASSERT_THAT(LIBC_NAMESPACE::recv(sv[0], buffer, sizeof(buffer), 0),
Fails<ssize_t>(EAGAIN));
- ASSERT_EQ(LIBC_NAMESPACE::clock_gettime(CLOCK_MONOTONIC, &end), 0);
+ ASSERT_TRUE(LIBC_NAMESPACE::internal::clock_gettime(CLOCK_MONOTONIC, &end)
+ .has_value());
int64_t elapsed_seconds = end.tv_sec - start.tv_sec;
int64_t elapsed_nseconds = end.tv_nsec - start.tv_nsec;
More information about the libc-commits
mailing list