diff --git a/libc/test/UnitTest/ExecuteFunctionUnix.cpp b/libc/test/UnitTest/ExecuteFunctionUnix.cpp index 7c2eb7c6e887c..ab18f7a2ebf52 100644 --- a/libc/test/UnitTest/ExecuteFunctionUnix.cpp +++ b/libc/test/UnitTest/ExecuteFunctionUnix.cpp @@ -57,7 +57,7 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, int timeout_ms) { } ::close(pipe_fds[1]); - struct pollfd poll_fd{pipe_fds[0], POLLIN, 0}; + 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) { diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt index bcd3d139aa46c..05a74be4ca21f 100644 --- a/libc/test/src/stdlib/CMakeLists.txt +++ b/libc/test/src/stdlib/CMakeLists.txt @@ -448,6 +448,19 @@ if(LLVM_LIBC_FULL_BUILD) libc-stdlib-tests 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 333277dc01dca..57c432828c2f3 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 0000000000000..5c82d8303036a --- /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); +}