[libc-commits] [libc] [libc] remove fragile test for mincore (PR #74026)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Thu Nov 30 18:00:13 PST 2023


https://github.com/SchrodingerZhu created https://github.com/llvm/llvm-project/pull/74026

None

>From e0a66d364cfe9d83ceb9c43b30c9c1abc9096e65 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Thu, 30 Nov 2023 20:59:42 -0500
Subject: [PATCH] [libc] remove fragile test for mincore

---
 libc/test/src/sys/mman/linux/mincore_test.cpp | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/libc/test/src/sys/mman/linux/mincore_test.cpp b/libc/test/src/sys/mman/linux/mincore_test.cpp
index 655fd8631af89a2..1b0ed157483eb02 100644
--- a/libc/test/src/sys/mman/linux/mincore_test.cpp
+++ b/libc/test/src/sys/mman/linux/mincore_test.cpp
@@ -41,23 +41,13 @@ static char *aligned_addr(void *addr, size_t alignment) {
 
 TEST(LlvmLibcMincoreTest, InvalidVec) {
   size_t page_size = static_cast<size_t>(LIBC_NAMESPACE::sysconf(_SC_PAGESIZE));
-  void *addr = LIBC_NAMESPACE::mmap(nullptr, 5 * page_size, PROT_READ,
+  void *addr = LIBC_NAMESPACE::mmap(nullptr, page_size, PROT_READ,
                                     MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
   EXPECT_NE(addr, MAP_FAILED);
-  // Since we allocated 5 pages, we can find an aligned boundary after which
-  // there are at least 4 pages
   char *aligned = aligned_addr(addr, page_size);
-  libc_errno = 0;
   int res = LIBC_NAMESPACE::mincore(aligned, 1, nullptr);
   EXPECT_THAT(res, Fails(EFAULT, -1));
-  void *area = LIBC_NAMESPACE::mmap(nullptr, page_size, PROT_READ | PROT_WRITE,
-                                    MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
-  EXPECT_NE(area, MAP_FAILED);
-  unsigned char *ptr = static_cast<unsigned char *>(area) + page_size - 3;
-  res = LIBC_NAMESPACE::mincore(aligned, 4 * page_size, ptr);
-  EXPECT_THAT(res, Fails(EFAULT, -1));
-  EXPECT_THAT(LIBC_NAMESPACE::munmap(addr, 5 * page_size), Succeeds());
-  EXPECT_THAT(LIBC_NAMESPACE::munmap(area, page_size), Succeeds());
+  EXPECT_THAT(LIBC_NAMESPACE::munmap(addr, page_size), Succeeds());
 }
 
 TEST(LlvmLibcMincoreTest, UnalignedAddr) {



More information about the libc-commits mailing list