summaryrefslogtreecommitdiff
path: root/libc/test/src/stdlib
diff options
context:
space:
mode:
authorShreeyash Pandey <shreeyash335@gmail.com>2025-11-14 23:57:32 +0530
committerGitHub <noreply@github.com>2025-11-14 13:27:32 -0500
commite7db040b796df5e7bda5226492038a3af34803ef (patch)
tree9a288aefbc7d093e606533ce3c0c71dad714c716 /libc/test/src/stdlib
parentac6daa8181894e34b8cf8e5c3e065f64035fcd36 (diff)
[libc][test] split exit tests into two separate tests (#166355)
_Exit(3) is a fairly simple syscall wrapper whereas exit(3) calls atexit-registered functions + whole lot of stuff that require support for sync primitives. Splitting the tests allows testing the former easily (especially for new port projects) --------- Signed-off-by: Shreeyash Pandey <shreeyash335@gmail.com>
Diffstat (limited to 'libc/test/src/stdlib')
-rw-r--r--libc/test/src/stdlib/CMakeLists.txt13
-rw-r--r--libc/test/src/stdlib/_Exit_test.cpp4
-rw-r--r--libc/test/src/stdlib/exit_test.cpp15
3 files changed, 28 insertions, 4 deletions
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 42e8faa3fd69..80aab080e36d 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -399,6 +399,19 @@ if(LLVM_LIBC_FULL_BUILD)
SRCS
_Exit_test.cpp
DEPENDS
+ libc.src.__support.OSUtil.osutil
+ libc.src.stdlib._Exit
+ )
+
+ add_libc_test(
+ exit_test
+ # The EXPECT_EXITS test is only availible for unit tests.
+ UNIT_TEST_ONLY
+ SUITE
+ libc-stdlib-tests
+ SRCS
+ exit_test.cpp
+ DEPENDS
libc.src.stdlib._Exit
libc.src.stdlib.exit
)
diff --git a/libc/test/src/stdlib/_Exit_test.cpp b/libc/test/src/stdlib/_Exit_test.cpp
index 333277dc01dc..57c432828c2f 100644
--- a/libc/test/src/stdlib/_Exit_test.cpp
+++ b/libc/test/src/stdlib/_Exit_test.cpp
@@ -7,13 +7,9 @@
//===----------------------------------------------------------------------===//
#include "src/stdlib/_Exit.h"
-#include "src/stdlib/exit.h"
#include "test/UnitTest/Test.h"
TEST(LlvmLibcStdlib, _Exit) {
EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(1); }, 1);
EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(65); }, 65);
-
- EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1);
- EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65);
}
diff --git a/libc/test/src/stdlib/exit_test.cpp b/libc/test/src/stdlib/exit_test.cpp
new file mode 100644
index 000000000000..5c82d8303036
--- /dev/null
+++ b/libc/test/src/stdlib/exit_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for exit -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdlib/exit.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcStdlib, exit) {
+ EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1);
+ EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65);
+}