MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / TEST_F

Function TEST_F

tests/unit_test/virtual_memory_test.cpp:95–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93};
94
95TEST_F(VirtualMemoryTest, MapPageBasic) {
96 VirtualMemory vm;
97
98 auto* page_dir = aligned_alloc(cpu_io::virtual_memory::kPageSize,
99 cpu_io::virtual_memory::kPageSize);
100 ASSERT_NE(page_dir, nullptr);
101 std::memset(page_dir, 0, cpu_io::virtual_memory::kPageSize);
102
103 void* virt_addr = reinterpret_cast<void*>(0x1000);
104 void* phys_addr = reinterpret_cast<void*>(0x80001000);
105
106 // 映射页面
107 auto result = vm.MapPage(page_dir, virt_addr, phys_addr,
108 cpu_io::virtual_memory::GetUserPagePermissions());
109
110 EXPECT_TRUE(result.has_value());
111
112 // 验证映射
113 auto mapped = vm.GetMapping(page_dir, virt_addr);
114 EXPECT_TRUE(mapped.has_value());
115 if (mapped) {
116 EXPECT_EQ(*mapped, phys_addr);
117 }
118}
119
120TEST_F(VirtualMemoryTest, UnmapPage) {
121 VirtualMemory vm;

Callers

nothing calls this directly

Calls 9

memsetFunction · 0.85
GetUserPagePermissionsFunction · 0.85
MapPageMethod · 0.80
GetMappingMethod · 0.80
UnmapPageMethod · 0.80
GetAllocatedCountMethod · 0.80
DestroyPageDirectoryMethod · 0.80
ClonePageDirectoryMethod · 0.80
aligned_allocFunction · 0.70

Tested by

no test coverage detected