Skip to content

Commit

Permalink
test: Fix BootMem page alignment issues.
Browse files Browse the repository at this point in the history
Signed-off-by: TunaCici <[email protected]>
  • Loading branch information
TunaCici committed Jan 14, 2024
1 parent f263225 commit 23c1cc6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Tests/MemoryBootMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

TEST(MemoryBootMem, init)
{
uint8_t *playground = new uint8_t[BM_ARENA_SIZE * PAGE_SIZE];
uint8_t *playground = new uint8_t[(BM_ARENA_SIZE + 1) * PAGE_SIZE];
for (auto i = 0; i < BM_ARENA_SIZE * PAGE_SIZE; i++) {
playground[i] = 0;
}
Expand All @@ -21,11 +21,13 @@ TEST(MemoryBootMem, init)

TEST(MemoryBootMem, alloc)
{
uint8_t *playground = new uint8_t[BM_ARENA_SIZE * PAGE_SIZE];
uint8_t *playground = new uint8_t[(BM_ARENA_SIZE + 1) * PAGE_SIZE];
for (auto i = 0; i < BM_ARENA_SIZE * PAGE_SIZE; i++) {
playground[i] = 0;
}

playground = (uint8_t*) PALIGN(playground);

uint32_t pageCount = bootmem_init((void*) playground);
EXPECT_EQ(pageCount, BM_ARENA_SIZE);

Expand Down Expand Up @@ -54,4 +56,10 @@ TEST(MemoryBootMem, alloc)
/* no more space;( */
tmp = bootmem_alloc(1);
EXPECT_EQ(tmp, (void*) 0);

/* addresses are valid? */
for (auto i = 0; i < BM_ARENA_SIZE * PAGE_SIZE; i++) {
playground[i] = 42;
EXPECT_EQ(playground[i], 42);
}
}

0 comments on commit 23c1cc6

Please sign in to comment.