Skip to content

Commit 09a866c

Browse files
committed
[libc][test] split exit tests into two separate tests
_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 <[email protected]>
1 parent 0bba851 commit 09a866c

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

libc/test/src/stdlib/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,19 @@ if(LLVM_LIBC_FULL_BUILD)
397397
libc-stdlib-tests
398398
SRCS
399399
_Exit_test.cpp
400+
DEPENDS
401+
libc.src.__support.OSUtil.osutil
402+
libc.src.stdlib._Exit
403+
)
404+
405+
add_libc_test(
406+
exit_test
407+
# The EXPECT_EXITS test is only availible for unit tests.
408+
UNIT_TEST_ONLY
409+
SUITE
410+
libc-stdlib-tests
411+
SRCS
412+
exit_test.cpp
400413
DEPENDS
401414
libc.src.stdlib._Exit
402415
libc.src.stdlib.exit

libc/test/src/stdlib/_Exit_test.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/stdlib/_Exit.h"
10-
#include "src/stdlib/exit.h"
1110
#include "test/UnitTest/Test.h"
1211

1312
TEST(LlvmLibcStdlib, _Exit) {
1413
EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(1); }, 1);
1514
EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(65); }, 65);
16-
17-
EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1);
18-
EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65);
1915
}

libc/test/src/stdlib/exit_test.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- Unittests for _Exit -----------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/stdlib/_Exit.h"
10+
#include "src/stdlib/exit.h"
11+
#include "test/UnitTest/Test.h"
12+
13+
TEST(LlvmLibcStdlib, _Exit) {
14+
EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(1); }, 1);
15+
EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(65); }, 65);
16+
17+
EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1);
18+
EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65);
19+
}

0 commit comments

Comments
 (0)