Skip to content

Commit

Permalink
tests: add vmm page rounding test
Browse files Browse the repository at this point in the history
  • Loading branch information
FedorLap2006 committed Jun 21, 2024
1 parent 3ad6978 commit a66cffc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_vmm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <depthos/paging.h>
#include <depthos/stdtypes.h>
#include <depthos/tests.h>

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);
}

0 comments on commit a66cffc

Please sign in to comment.