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

via libc-commits libc-commits at lists.llvm.org
Thu Nov 30 18:00:45 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/74026.diff


1 Files Affected:

- (modified) libc/test/src/sys/mman/linux/mincore_test.cpp (+2-12) 


``````````diff
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) {

``````````

</details>


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


More information about the libc-commits mailing list