[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:20:31 PDT 2026
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/210700
>From be187f675d87569edd0e72d7c7fd3b164ca8a44a 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 | 3 ++-
libc/test/src/assert/assert_test.cpp | 5 ++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libc/test/src/assert/CMakeLists.txt b/libc/test/src/assert/CMakeLists.txt
index e66aca8307eeb..7b8d26bd157aa 100644
--- a/libc/test/src/assert/CMakeLists.txt
+++ b/libc/test/src/assert/CMakeLists.txt
@@ -1,6 +1,6 @@
add_custom_target(libc_assert_unittests)
-add_libc_unittest(
+add_libc_test(
assert_test
SUITE
libc_assert_unittests
@@ -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