Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] remove fragile test from mincore #74026

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

SchrodingerZhu
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the libc label Dec 1, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 1, 2023

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

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

@SchrodingerZhu
Copy link
Contributor Author

@nickdesaulniers it turns out to be unstable to test vec with insufficient length. I think we may just remove that test.

@SchrodingerZhu
Copy link
Contributor Author

@SchrodingerZhu SchrodingerZhu changed the title [libc] remove fragile test for mincore [libc] remove fragile test from mincore Dec 1, 2023
@lntue lntue merged commit 54878b8 into llvm:main Dec 1, 2023
4 checks passed
SchrodingerZhu added a commit to SchrodingerZhu/llvm-project that referenced this pull request Dec 4, 2023
The test cases of mincore require getting correct page size from OS. As `sysconf` is not functioning correctly, these patches are
implemented in a somewhat confusing way. We revert such patches and will reintroduce mincore after we correct sysconf.

This reverts 54878b8, 985c0d1 and 418a3a4.
nickdesaulniers pushed a commit that referenced this pull request Dec 4, 2023
The test cases of mincore require getting correct page size from OS. As
`sysconf` is not functioning correctly, these patches are implemented in
a somewhat confusing way. We revert such patches and will reintroduce
mincore after we correct sysconf.

This reverts 54878b8, 985c0d1 and 418a3a4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants