diff --git a/Userland/Tests/LibC/CMakeLists.txt b/Userland/Tests/LibC/CMakeLists.txt index 070badc55c..0cc745d060 100644 --- a/Userland/Tests/LibC/CMakeLists.txt +++ b/Userland/Tests/LibC/CMakeLists.txt @@ -3,6 +3,7 @@ set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/strlcpy-correctness.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCTime.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCMkTemp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCExec.cpp ) file(GLOB CMD_SOURCES CONFIGURE_DEPENDS "*.cpp") diff --git a/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp b/Userland/Tests/LibC/TestLibCExec.cpp similarity index 67% rename from Userland/Tests/LibC/exec-should-not-search-current-directory.cpp rename to Userland/Tests/LibC/TestLibCExec.cpp index 66d5e472e2..25eefa5f46 100644 --- a/Userland/Tests/LibC/exec-should-not-search-current-directory.cpp +++ b/Userland/Tests/LibC/TestLibCExec.cpp @@ -4,11 +4,12 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include -int main() +TEST_CASE(exec_should_not_search_current_directory) { int fd = open("hax", O_CREAT | O_RDWR, 0755); ftruncate(fd, 0); @@ -16,11 +17,9 @@ int main() int rc = execlp("hax", "hax", nullptr); int saved_errno = errno; + perror("execlp"); unlink("hax"); - if (rc == -1 && saved_errno == ENOEXEC) { - printf("FAIL\n"); - return 1; - } - printf("PASS\n"); - return 0; + + EXPECT_EQ(rc, -1); + EXPECT_NE(saved_errno, ENOEXEC); }