diff --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp --- a/libc/test/src/fcntl/creat_test.cpp +++ b/libc/test/src/fcntl/creat_test.cpp @@ -12,7 +12,6 @@ #include "src/unistd/close.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcCreatTest, CreatAndOpen) { using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; diff --git a/libc/test/src/fcntl/openat_test.cpp b/libc/test/src/fcntl/openat_test.cpp --- a/libc/test/src/fcntl/openat_test.cpp +++ b/libc/test/src/fcntl/openat_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/read.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/stdio/remove_test.cpp b/libc/test/src/stdio/remove_test.cpp --- a/libc/test/src/stdio/remove_test.cpp +++ b/libc/test/src/stdio/remove_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/close.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include "src/errno/libc_errno.h" #include diff --git a/libc/test/src/sys/sendfile/sendfile_test.cpp b/libc/test/src/sys/sendfile/sendfile_test.cpp --- a/libc/test/src/sys/sendfile/sendfile_test.cpp +++ b/libc/test/src/sys/sendfile/sendfile_test.cpp @@ -16,7 +16,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/sys/stat/chmod_test.cpp b/libc/test/src/sys/stat/chmod_test.cpp --- a/libc/test/src/sys/stat/chmod_test.cpp +++ b/libc/test/src/sys/stat/chmod_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/sys/stat/fchmod_test.cpp b/libc/test/src/sys/stat/fchmod_test.cpp --- a/libc/test/src/sys/stat/fchmod_test.cpp +++ b/libc/test/src/sys/stat/fchmod_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/sys/stat/fchmodat_test.cpp b/libc/test/src/sys/stat/fchmodat_test.cpp --- a/libc/test/src/sys/stat/fchmodat_test.cpp +++ b/libc/test/src/sys/stat/fchmodat_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/sys/stat/fstat_test.cpp b/libc/test/src/sys/stat/fstat_test.cpp --- a/libc/test/src/sys/stat/fstat_test.cpp +++ b/libc/test/src/sys/stat/fstat_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/unlink.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/sys/stat/lstat_test.cpp b/libc/test/src/sys/stat/lstat_test.cpp --- a/libc/test/src/sys/stat/lstat_test.cpp +++ b/libc/test/src/sys/stat/lstat_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/unlink.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/sys/stat/mkdirat_test.cpp b/libc/test/src/sys/stat/mkdirat_test.cpp --- a/libc/test/src/sys/stat/mkdirat_test.cpp +++ b/libc/test/src/sys/stat/mkdirat_test.cpp @@ -10,7 +10,6 @@ #include "src/unistd/rmdir.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/sys/stat/stat_test.cpp b/libc/test/src/sys/stat/stat_test.cpp --- a/libc/test/src/sys/stat/stat_test.cpp +++ b/libc/test/src/sys/stat/stat_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/unlink.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include #include diff --git a/libc/test/src/unistd/access_test.cpp b/libc/test/src/unistd/access_test.cpp --- a/libc/test/src/unistd/access_test.cpp +++ b/libc/test/src/unistd/access_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/unlink.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/unistd/chdir_test.cpp b/libc/test/src/unistd/chdir_test.cpp --- a/libc/test/src/unistd/chdir_test.cpp +++ b/libc/test/src/unistd/chdir_test.cpp @@ -12,7 +12,6 @@ #include "src/unistd/close.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/unistd/dup2_test.cpp b/libc/test/src/unistd/dup2_test.cpp --- a/libc/test/src/unistd/dup2_test.cpp +++ b/libc/test/src/unistd/dup2_test.cpp @@ -15,7 +15,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcdupTest, ReadAndWriteViaDup) { constexpr int DUPFD = 0xD0; diff --git a/libc/test/src/unistd/dup3_test.cpp b/libc/test/src/unistd/dup3_test.cpp --- a/libc/test/src/unistd/dup3_test.cpp +++ b/libc/test/src/unistd/dup3_test.cpp @@ -15,7 +15,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" // The tests here are exactly the same as those of dup2. We only test the // plumbing of the dup3 syscall and not the dup3 functionality itself as it is diff --git a/libc/test/src/unistd/dup_test.cpp b/libc/test/src/unistd/dup_test.cpp --- a/libc/test/src/unistd/dup_test.cpp +++ b/libc/test/src/unistd/dup_test.cpp @@ -15,7 +15,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcdupTest, ReadAndWriteViaDup) { libc_errno = 0; diff --git a/libc/test/src/unistd/fchdir_test.cpp b/libc/test/src/unistd/fchdir_test.cpp --- a/libc/test/src/unistd/fchdir_test.cpp +++ b/libc/test/src/unistd/fchdir_test.cpp @@ -12,7 +12,6 @@ #include "src/unistd/fchdir.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/unistd/lseek_test.cpp b/libc/test/src/unistd/lseek_test.cpp --- a/libc/test/src/unistd/lseek_test.cpp +++ b/libc/test/src/unistd/lseek_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/read.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/unistd/pread_pwrite_test.cpp b/libc/test/src/unistd/pread_pwrite_test.cpp --- a/libc/test/src/unistd/pread_pwrite_test.cpp +++ b/libc/test/src/unistd/pread_pwrite_test.cpp @@ -16,7 +16,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcUniStd, PWriteAndPReadBackTest) { // The strategy here is that we first create a file and write to it. Next, diff --git a/libc/test/src/unistd/read_write_test.cpp b/libc/test/src/unistd/read_write_test.cpp --- a/libc/test/src/unistd/read_write_test.cpp +++ b/libc/test/src/unistd/read_write_test.cpp @@ -14,7 +14,6 @@ #include "src/unistd/write.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcUniStd, WriteAndReadBackTest) { using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; diff --git a/libc/test/src/unistd/rmdir_test.cpp b/libc/test/src/unistd/rmdir_test.cpp --- a/libc/test/src/unistd/rmdir_test.cpp +++ b/libc/test/src/unistd/rmdir_test.cpp @@ -11,7 +11,6 @@ #include "src/unistd/rmdir.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" #include diff --git a/libc/test/src/unistd/unlink_test.cpp b/libc/test/src/unistd/unlink_test.cpp --- a/libc/test/src/unistd/unlink_test.cpp +++ b/libc/test/src/unistd/unlink_test.cpp @@ -12,7 +12,6 @@ #include "src/unistd/unlink.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcUnlinkTest, CreateAndUnlink) { using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; diff --git a/libc/test/src/unistd/unlinkat_test.cpp b/libc/test/src/unistd/unlinkat_test.cpp --- a/libc/test/src/unistd/unlinkat_test.cpp +++ b/libc/test/src/unistd/unlinkat_test.cpp @@ -13,7 +13,6 @@ #include "src/unistd/unlinkat.h" #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "utils/testutils/FDReader.h" TEST(LlvmLibcUnlinkatTest, CreateAndDeleteTest) { using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds; diff --git a/libc/utils/testutils/CMakeLists.txt b/libc/utils/testutils/CMakeLists.txt --- a/libc/utils/testutils/CMakeLists.txt +++ b/libc/utils/testutils/CMakeLists.txt @@ -1,13 +1,10 @@ if(CMAKE_HOST_UNIX) set(EFFile ExecuteFunctionUnix.cpp) - set(FDReaderFile FDReaderUnix.cpp) endif() add_library( libc_test_utils ${EFFile} ExecuteFunction.h - ${FDReaderFile} - FDReader.h RoundingModeUtils.cpp ) diff --git a/libc/utils/testutils/FDReader.h b/libc/utils/testutils/FDReader.h deleted file mode 100644 --- a/libc/utils/testutils/FDReader.h +++ /dev/null @@ -1,29 +0,0 @@ -//===-- FDReader.h ----------------------------------------------*- C++ -*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_UTILS_TESTUTILS_FDREADER_H -#define LLVM_LIBC_UTILS_TESTUTILS_FDREADER_H - -namespace __llvm_libc { -namespace testutils { - -class FDReader { - int pipefd[2]; - -public: - FDReader(); - ~FDReader(); - - int get_write_fd() { return pipefd[1]; } - bool match_written(const char *); -}; - -} // namespace testutils -} // namespace __llvm_libc - -#endif // LLVM_LIBC_UTILS_TESTUTILS_FDREADER_H diff --git a/libc/utils/testutils/FDReaderUnix.cpp b/libc/utils/testutils/FDReaderUnix.cpp deleted file mode 100644 --- a/libc/utils/testutils/FDReaderUnix.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===-- FDReader.cpp ------------------------------------------------------===// -// -// 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 "FDReader.h" -#include -#include -#include -#include - -namespace __llvm_libc { -namespace testutils { - -FDReader::FDReader() { - if (::pipe(pipefd)) { - std::cerr << "pipe(2) failed"; - abort(); - } -} - -FDReader::~FDReader() { - ::close(pipefd[0]); - ::close(pipefd[1]); -} - -bool FDReader::match_written(const char *str) { - - ::close(pipefd[1]); - - constexpr ssize_t ChunkSize = 4096 * 4; - - char Buffer[ChunkSize]; - std::string PipeStr; - std::string InputStr(str); - - for (int BytesRead; (BytesRead = ::read(pipefd[0], Buffer, ChunkSize));) { - if (BytesRead > 0) { - PipeStr.insert(PipeStr.size(), Buffer, BytesRead); - } else { - assert(0 && "Error reading from pipe"); - return false; - } - } - - return PipeStr == InputStr; -} - -} // namespace testutils -} // namespace __llvm_libc diff --git a/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel @@ -10,12 +10,10 @@ name = "libc_test_utils", srcs = [ "ExecuteFunctionUnix.cpp", - "FDReaderUnix.cpp", "RoundingModeUtils.cpp", ], hdrs = [ "ExecuteFunction.h", - "FDReader.h", "RoundingModeUtils.h", ], deps = [