[libc-commits] [libc] [libc] Make assert_test hermetic (PR #210700)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Mon Jul 20 05:19:55 PDT 2026
https://github.com/labath created https://github.com/llvm/llvm-project/pull/210700
Call our own close() instead of the system one.
>From a070f428d6a2ad5b793e99b000a5b7e4c0143b2b Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Mon, 20 Jul 2026 12:15:42 +0000
Subject: [PATCH] [libc] Make assert_test hermetic
Call our own close() instead of the system one.
---
libc/test/src/assert/CMakeLists.txt | 1 +
libc/test/src/assert/assert_test.cpp | 5 ++---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/test/src/assert/CMakeLists.txt b/libc/test/src/assert/CMakeLists.txt
index e66aca8307eeb..a07f114c5b3a3 100644
--- a/libc/test/src/assert/CMakeLists.txt
+++ b/libc/test/src/assert/CMakeLists.txt
@@ -8,6 +8,7 @@ add_libc_unittest(
assert_test.cpp
DEPENDS
libc.src.assert.__assert_fail
+ libc.src.unistd.close
# These are necessary for now because dependencies are not properly added.
libc.src.signal.raise
libc.src.stdlib._Exit
diff --git a/libc/test/src/assert/assert_test.cpp b/libc/test/src/assert/assert_test.cpp
index 410241693a83c..5af6713dc7edc 100644
--- a/libc/test/src/assert/assert_test.cpp
+++ b/libc/test/src/assert/assert_test.cpp
@@ -9,16 +9,15 @@
#undef NDEBUG
#include "hdr/signal_macros.h"
#include "src/assert/assert.h"
+#include "src/unistd/close.h"
#include "test/UnitTest/Test.h"
-extern "C" int close(int);
-
TEST(LlvmLibcAssert, Enabled) {
// Close standard error for the child process so we don't print the assertion
// failure message.
EXPECT_DEATH(
[] {
- close(2);
+ LIBC_NAMESPACE::close(2);
assert(0);
},
WITH_SIGNAL(SIGABRT));
More information about the libc-commits
mailing list