[libc-commits] [libc] [libc] fix EXPECT_EXIT suspend/timeout for darwin (PR #166065)
Shreeyash Pandey via libc-commits
libc-commits at lists.llvm.org
Sun Nov 2 05:22:56 PST 2025
https://github.com/bojle updated https://github.com/llvm/llvm-project/pull/166065
>From ab85f49f93c777b94648b5c5bf721753950b4308 Mon Sep 17 00:00:00 2001
From: Shreeyash Pandey <shreeyash335 at gmail.com>
Date: Sun, 2 Nov 2025 16:38:36 +0530
Subject: [PATCH 1/3] [libc] allow UnitTest suite to be compiled on darwin
ExecuteFunctionUnix.cpp which is guarded by this check should reliably work
on darwin as it only uses POSIX API - nothing specific to linux.
---
libc/test/UnitTest/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index 31d1e9dce8204..028e8e3a2ea67 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -83,7 +83,7 @@ add_unittest_framework_library(
)
set(libc_death_test_srcs LibcDeathTestExecutors.cpp)
-if(${LIBC_TARGET_OS} STREQUAL "linux")
+if(${LIBC_TARGET_OS} STREQUAL "linux" OR ${LIBC_TARGET_OS} STREQUAL "darwin")
list(APPEND libc_death_test_srcs ExecuteFunctionUnix.cpp)
endif()
>From 9a5455df48b18bd31f425353841f41f54d99ef4a Mon Sep 17 00:00:00 2001
From: Shreeyash Pandey <shreeyash335 at gmail.com>
Date: Sun, 2 Nov 2025 17:21:01 +0530
Subject: [PATCH 2/3] [libc] fix EXPECT_EXIT suspend/timeout for darwin
Fixes: https://github.com/llvm/llvm-project/issues/166059
Signed-off-by: Shreeyash Pandey <shreeyash335 at gmail.com>
---
libc/test/UnitTest/ExecuteFunctionUnix.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/test/UnitTest/ExecuteFunctionUnix.cpp b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
index c0e85c2144005..0b450578adde2 100644
--- a/libc/test/UnitTest/ExecuteFunctionUnix.cpp
+++ b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
@@ -13,6 +13,7 @@
#include <poll.h>
#include <signal.h>
#include <stdio.h>
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
@@ -58,7 +59,7 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, int timeout_ms) {
::close(pipe_fds[1]);
struct pollfd poll_fd {
- pipe_fds[0], 0, 0
+ pipe_fds[0], POLLIN, 0
};
// No events requested so this call will only return after the timeout or if
// the pipes peer was closed, signaling the process exited.
>From 34f4b8b04f29d57bfc3aced106302ab91a4a1bff Mon Sep 17 00:00:00 2001
From: Shreeyash Pandey <shreeyash335 at gmail.com>
Date: Sun, 2 Nov 2025 18:50:43 +0530
Subject: [PATCH 3/3] [libc] fix formatting
---
libc/test/UnitTest/ExecuteFunctionUnix.cpp | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libc/test/UnitTest/ExecuteFunctionUnix.cpp b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
index 0b450578adde2..7c2eb7c6e887c 100644
--- a/libc/test/UnitTest/ExecuteFunctionUnix.cpp
+++ b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
@@ -13,7 +13,6 @@
#include <poll.h>
#include <signal.h>
#include <stdio.h>
-#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
@@ -58,9 +57,7 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, int timeout_ms) {
}
::close(pipe_fds[1]);
- struct pollfd poll_fd {
- pipe_fds[0], POLLIN, 0
- };
+ struct pollfd poll_fd{pipe_fds[0], POLLIN, 0};
// No events requested so this call will only return after the timeout or if
// the pipes peer was closed, signaling the process exited.
if (::poll(&poll_fd, 1, timeout_ms) == -1) {
More information about the libc-commits
mailing list