From fc121d0c73a2d950434653089cf8b9747dfda3bb Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Sun, 16 Apr 2023 07:28:41 +0000 Subject: [PATCH] [libc][NFC] Remove the unused FDReader testutil. Differential Revision: https://reviews.llvm.org/D148454 --- libc/test/src/fcntl/creat_test.cpp | 1 - libc/test/src/fcntl/openat_test.cpp | 1 - libc/test/src/stdio/remove_test.cpp | 1 - libc/test/src/sys/sendfile/sendfile_test.cpp | 1 - libc/test/src/sys/stat/chmod_test.cpp | 1 - libc/test/src/sys/stat/fchmod_test.cpp | 1 - libc/test/src/sys/stat/fchmodat_test.cpp | 1 - libc/test/src/sys/stat/fstat_test.cpp | 1 - libc/test/src/sys/stat/lstat_test.cpp | 1 - libc/test/src/sys/stat/mkdirat_test.cpp | 1 - libc/test/src/sys/stat/stat_test.cpp | 1 - libc/test/src/unistd/access_test.cpp | 1 - libc/test/src/unistd/chdir_test.cpp | 1 - libc/test/src/unistd/dup2_test.cpp | 1 - libc/test/src/unistd/dup3_test.cpp | 1 - libc/test/src/unistd/dup_test.cpp | 1 - libc/test/src/unistd/fchdir_test.cpp | 1 - libc/test/src/unistd/lseek_test.cpp | 1 - libc/test/src/unistd/pread_pwrite_test.cpp | 1 - libc/test/src/unistd/read_write_test.cpp | 1 - libc/test/src/unistd/rmdir_test.cpp | 1 - libc/test/src/unistd/unlink_test.cpp | 1 - libc/test/src/unistd/unlinkat_test.cpp | 1 - libc/utils/testutils/CMakeLists.txt | 3 -- libc/utils/testutils/FDReader.h | 29 ------------ libc/utils/testutils/FDReaderUnix.cpp | 53 ---------------------- .../libc/utils/testutils/BUILD.bazel | 2 - 27 files changed, 110 deletions(-) delete mode 100644 libc/utils/testutils/FDReader.h delete mode 100644 libc/utils/testutils/FDReaderUnix.cpp diff --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp index b7d577a..8a2dd19 100644 --- 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 index 5310d46..17626e6 100644 --- 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 index b6e8b64..3dc0568 100644 --- 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 index c77965e..e3ed299 100644 --- 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 index d8da9e3..55e68bc 100644 --- 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 index c75688b..9dc033f 100644 --- 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 index fd2a053d..68a3ef3 100644 --- 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 index 66d9d3c..6105046 100644 --- 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 index 6cedb2f..ae8ea60 100644 --- 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 index 7f302a4..30fbd97 100644 --- 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 index 0a3eb3e..97cb5593 100644 --- 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 index 92e7685..24e4943 100644 --- 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 index 05e3e5d..de64f6e 100644 --- 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 index 545ea2e..1a5ff0f 100644 --- 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 index 575e129..75825bc 100644 --- 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 index ff87772..5d8c9b9 100644 --- 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 index 35d3cd3..f004af9 100644 --- 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 index f235f7f..07cd895 100644 --- 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 index 4cfbeaf..9da4cf98 100644 --- 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 index 68299f6..6e6887f 100644 --- 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 index a5eb8d3..55e2c26 100644 --- 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 index 2f6eeb1..515378f 100644 --- 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 index dbec719..24c14bf 100644 --- 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 index 9ec358f..6e426f4 100644 --- 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 index 8a39a92..0000000 --- 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 index be6cde3..0000000 --- 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 index f0e477a..9f58814 100644 --- 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 @@ cc_library( name = "libc_test_utils", srcs = [ "ExecuteFunctionUnix.cpp", - "FDReaderUnix.cpp", "RoundingModeUtils.cpp", ], hdrs = [ "ExecuteFunction.h", - "FDReader.h", "RoundingModeUtils.h", ], deps = [ -- 2.7.4