[libc-commits] [libc] fc121d0 - [libc][NFC] Remove the unused FDReader testutil.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Mon Apr 17 10:44:58 PDT 2023


Author: Siva Chandra Reddy
Date: 2023-04-17T17:44:47Z
New Revision: fc121d0c73a2d950434653089cf8b9747dfda3bb

URL: https://github.com/llvm/llvm-project/commit/fc121d0c73a2d950434653089cf8b9747dfda3bb
DIFF: https://github.com/llvm/llvm-project/commit/fc121d0c73a2d950434653089cf8b9747dfda3bb.diff

LOG: [libc][NFC] Remove the unused FDReader testutil.

Differential Revision: https://reviews.llvm.org/D148454

Added: 
    

Modified: 
    libc/test/src/fcntl/creat_test.cpp
    libc/test/src/fcntl/openat_test.cpp
    libc/test/src/stdio/remove_test.cpp
    libc/test/src/sys/sendfile/sendfile_test.cpp
    libc/test/src/sys/stat/chmod_test.cpp
    libc/test/src/sys/stat/fchmod_test.cpp
    libc/test/src/sys/stat/fchmodat_test.cpp
    libc/test/src/sys/stat/fstat_test.cpp
    libc/test/src/sys/stat/lstat_test.cpp
    libc/test/src/sys/stat/mkdirat_test.cpp
    libc/test/src/sys/stat/stat_test.cpp
    libc/test/src/unistd/access_test.cpp
    libc/test/src/unistd/chdir_test.cpp
    libc/test/src/unistd/dup2_test.cpp
    libc/test/src/unistd/dup3_test.cpp
    libc/test/src/unistd/dup_test.cpp
    libc/test/src/unistd/fchdir_test.cpp
    libc/test/src/unistd/lseek_test.cpp
    libc/test/src/unistd/pread_pwrite_test.cpp
    libc/test/src/unistd/read_write_test.cpp
    libc/test/src/unistd/rmdir_test.cpp
    libc/test/src/unistd/unlink_test.cpp
    libc/test/src/unistd/unlinkat_test.cpp
    libc/utils/testutils/CMakeLists.txt
    utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel

Removed: 
    libc/utils/testutils/FDReader.h
    libc/utils/testutils/FDReaderUnix.cpp


################################################################################
diff  --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp
index b7d577ad461ce..8a2dd1955b8eb 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 5310d4647f851..17626e641d89d 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 <fcntl.h>
 

diff  --git a/libc/test/src/stdio/remove_test.cpp b/libc/test/src/stdio/remove_test.cpp
index b6e8b64058262..3dc05684834e6 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 <unistd.h>

diff  --git a/libc/test/src/sys/sendfile/sendfile_test.cpp b/libc/test/src/sys/sendfile/sendfile_test.cpp
index c77965ea96409..e3ed29926d51c 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/sys/stat/chmod_test.cpp b/libc/test/src/sys/stat/chmod_test.cpp
index d8da9e390301a..55e68bcabfa40 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/sys/stat/fchmod_test.cpp b/libc/test/src/sys/stat/fchmod_test.cpp
index c75688bac9d3b..9dc033f8169d0 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/sys/stat/fchmodat_test.cpp b/libc/test/src/sys/stat/fchmodat_test.cpp
index fd2a053d12336..68a3ef398cca6 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/sys/stat/fstat_test.cpp b/libc/test/src/sys/stat/fstat_test.cpp
index 66d9d3c83f908..6105046a69fe0 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/sys/stat/lstat_test.cpp b/libc/test/src/sys/stat/lstat_test.cpp
index 6cedb2fc5fcf8..ae8ea600a36ab 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/sys/stat/mkdirat_test.cpp b/libc/test/src/sys/stat/mkdirat_test.cpp
index 7f302a41b54b2..30fbd9782df45 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 <fcntl.h>
 

diff  --git a/libc/test/src/sys/stat/stat_test.cpp b/libc/test/src/sys/stat/stat_test.cpp
index 0a3eb3e070a15..97cb559316e92 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 <fcntl.h>
 #include <sys/stat.h>

diff  --git a/libc/test/src/unistd/access_test.cpp b/libc/test/src/unistd/access_test.cpp
index 92e7685567d84..24e4943312842 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 <unistd.h>
 

diff  --git a/libc/test/src/unistd/chdir_test.cpp b/libc/test/src/unistd/chdir_test.cpp
index 05e3e5dcbca28..de64f6e76317d 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 <fcntl.h>
 

diff  --git a/libc/test/src/unistd/dup2_test.cpp b/libc/test/src/unistd/dup2_test.cpp
index 545ea2eff80be..1a5ff0f570345 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 575e1291b9a27..75825bc0ec4ed 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 ff877727b0470..5d8c9b9b340e8 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 35d3cd3b76eab..f004af91d2cb6 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 <fcntl.h>
 

diff  --git a/libc/test/src/unistd/lseek_test.cpp b/libc/test/src/unistd/lseek_test.cpp
index f235f7fcb12eb..07cd89551a63f 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 <unistd.h>
 

diff  --git a/libc/test/src/unistd/pread_pwrite_test.cpp b/libc/test/src/unistd/pread_pwrite_test.cpp
index 4cfbeaf6c7936..9da4cf98d390e 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 68299f639878a..6e6887fd925bf 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 a5eb8d3a974c5..55e2c261704b4 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 <fcntl.h>
 

diff  --git a/libc/test/src/unistd/unlink_test.cpp b/libc/test/src/unistd/unlink_test.cpp
index 2f6eeb1cc0c5f..515378ff4fa7b 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 dbec719dc6635..24c14bf8720ac 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 9ec358f3839cb..6e426f4802f6e 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 8a39a92dcc33c..0000000000000
--- 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 be6cde331f370..0000000000000
--- 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 <cassert>
-#include <cstring>
-#include <iostream>
-#include <unistd.h>
-
-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 f0e477ad6e6d8..9f58814937180 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 = [


        


More information about the libc-commits mailing list