diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-07-22 10:40:16 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-07-22 10:40:16 -0400 |
| commit | 58f32cd6909aa83c107175ecf1e03c1148b7bc26 (patch) | |
| tree | dd073240fdb407ffb4cffbb5009ad86d21ce4c20 | |
| parent | 19a075211f4b14c5e2bb999b987ff4ed099f2af1 (diff) | |
Fix Linux-specific optimized test failure
The stack was not aligned as expected for `buddy_allocator_init` when
`-o:speed` was enabled, making this a test failure that only appeared
with optimizations enabled.
The data is now aligned specifically, as it should be.
| -rw-r--r-- | tests/core/mem/test_core_mem.odin | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/core/mem/test_core_mem.odin b/tests/core/mem/test_core_mem.odin index c1cb59c68..9d64e50a3 100644 --- a/tests/core/mem/test_core_mem.odin +++ b/tests/core/mem/test_core_mem.odin @@ -282,13 +282,18 @@ test_dynamic_arena :: proc(t: ^testing.T) { @test test_buddy :: proc(t: ^testing.T) { - N :: 4096 + N :: 8192 buf: [N]u8 + base := &buf[0] + address := mem.align_forward(base, size_of(mem.Buddy_Block)) + delta := uintptr(address) - uintptr(base) + ba: mem.Buddy_Allocator - mem.buddy_allocator_init(&ba, buf[:], align_of(u8)) - basic_sanity_test(t, mem.buddy_allocator(&ba), N / 8) - basic_sanity_test(t, mem.buddy_allocator(&ba), N / 8) + + mem.buddy_allocator_init(&ba, buf[delta:delta+N/2], size_of(mem.Buddy_Block)) + basic_sanity_test(t, mem.buddy_allocator(&ba), N / 16) + basic_sanity_test(t, mem.buddy_allocator(&ba), N / 16) } @test |