From bbd220a3950550d631b7c844bf8fca7bee2247a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Fri, 29 Dec 2017 22:32:43 +0100 Subject: [PATCH] VMM -- test refactoring --- src/kernel/memory/vmm.tt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kernel/memory/vmm.tt b/src/kernel/memory/vmm.tt index b9b7d57..846c9ff 100644 --- a/src/kernel/memory/vmm.tt +++ b/src/kernel/memory/vmm.tt @@ -6,6 +6,8 @@ void *data; uintptr_t *p4, *p3, *p2, *p1; +#define ADDR1234 ((1UL<<39) + (2UL<<30) + (3UL<<21) + (4UL<<12)) + BEFORE() { data = calloc(PAGE_SIZE, 5); @@ -57,7 +59,7 @@ TEST(get_page_works_for_different_address) p2[3] |= PAGE_PRESENT; p1[4] = 0x34567890ABCDE000 | PAGE_PRESENT; - uintptr_t ret = vmm_get_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12)); + uintptr_t ret = vmm_get_page(p4, ADDR1234); ASSERT_EQ_PTR(ret, 0x34567890ABCDE000 | PAGE_PRESENT); } @@ -125,19 +127,19 @@ uintptr_t pmm_alloc() TEST(touch_page_adds_P3) { - touch_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12), 0); + touch_page(p4, ADDR1234, 0); ASSERT_EQ_PTR(p4[1], (uintptr_t)p3 | PAGE_PRESENT); } TEST(touch_page_adds_P2) { - touch_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12), 0); + touch_page(p4, ADDR1234, 0); ASSERT_EQ_PTR(p3[2], (uintptr_t)p2 | PAGE_PRESENT); } TEST(touch_page_adds_P1) { - touch_page(p4, (1UL<<39)+(2UL<<30)+(3UL<<21)+(4UL<<12), 0); + touch_page(p4, ADDR1234, 0); ASSERT_EQ_PTR(p2[3], (uintptr_t)p1 | PAGE_PRESENT); }