Skip to content

Commit

Permalink
kernel_api_tests: Add MAP_SHARED fault test
Browse files Browse the repository at this point in the history
Add a test that does a basic exercise of MAP_SHARED in anonymous memory,
since many boots don't actually get to exercise it at all.

Signed-off-by: Pedro Falcato <[email protected]>
  • Loading branch information
heatd committed Nov 12, 2023
1 parent ff6fda5 commit 4e8a750
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions usystem/tests/kernel_api_tests/src/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,13 @@ TEST(Vm, MprotectOverManyVmas)

ASSERT_EQ(munmap(ptr, page_size * npgs), 0);
}

TEST(Vm, MmapSharedFault)
{
/* Simple test that tests MAP_SHARED faults */
void* ptr = mmap(nullptr, page_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
ASSERT_NE(ptr, MAP_FAILED);
*(volatile unsigned char*) ptr;
*(volatile unsigned char*) ptr = 10;
ASSERT_EQ(munmap(ptr, page_size), 0);
}

0 comments on commit 4e8a750

Please sign in to comment.