From a66cffc7eceeab086326297fef9ebfa64acf5a79 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin Date: Fri, 21 Jun 2024 21:18:43 +0300 Subject: [PATCH] tests: add vmm page rounding test --- tests/test_vmm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/test_vmm.c diff --git a/tests/test_vmm.c b/tests/test_vmm.c new file mode 100644 index 0000000..1be96c5 --- /dev/null +++ b/tests/test_vmm.c @@ -0,0 +1,17 @@ +#include +#include +#include + +void test_vmm_page_rounding() { + TEST("VMM page rounding"); +#define CASE(addr, size, npages, rounded_size) \ + { \ + uintptr_t end = PG_RND_DOWN(addr + size); \ + uintptr_t start = PG_RND_UP(addr); \ + assert((end - start) == rounded_size); \ + assert(((end - start) / PAGE_SIZE) == npages); \ + } + + CASE(0x1000 - 2, 4096, 0, 0); + CASE(0x1000 - 2, 4096 + 2, 1, 4096); +}