aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-09-26 14:21:52 +0100
committerGitHub <noreply@github.com>2025-09-26 14:21:52 +0100
commit1222d40d3916c615781754a7aa37d61d66d0f050 (patch)
treeb1d85db2b83e5c732fb838fae25d5c6f59b5f42b /tests
parent51f79724ed25252088211f1128f1987499bb91f4 (diff)
parent710533975e6da554b943bc24fb6e38ba22fe959a (diff)
Merge pull request #5691 from rationalcoder/master
Fix out-of-band allocations in dynamic arenas
Diffstat (limited to 'tests')
-rw-r--r--tests/core/mem/test_mem_dynamic_pool.odin15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/core/mem/test_mem_dynamic_pool.odin b/tests/core/mem/test_mem_dynamic_pool.odin
index fa204d3b1..82cee89af 100644
--- a/tests/core/mem/test_mem_dynamic_pool.odin
+++ b/tests/core/mem/test_mem_dynamic_pool.odin
@@ -44,11 +44,11 @@ expect_pool_allocation :: proc(t: ^testing.T, expected_used_bytes, num_bytes, al
testing.expect(t, pool.used_blocks == nil)
}
-expect_pool_allocation_out_of_band :: proc(t: ^testing.T, num_bytes, out_band_size: int) {
+expect_pool_allocation_out_of_band :: proc(t: ^testing.T, num_bytes, block_size, out_band_size: int) {
testing.expect(t, num_bytes >= out_band_size, "Sanity check failed, your test call is flawed! Make sure that num_bytes >= out_band_size!")
pool: mem.Dynamic_Pool
- mem.dynamic_pool_init(&pool, out_band_size = out_band_size)
+ mem.dynamic_pool_init(&pool, block_size = block_size, out_band_size = out_band_size)
pool_allocator := mem.dynamic_pool_allocator(&pool)
element, err := mem.alloc(num_bytes, allocator = pool_allocator)
@@ -69,14 +69,15 @@ test_dynamic_pool_alloc_aligned :: proc(t: ^testing.T) {
@(test)
test_dynamic_pool_alloc_unaligned :: proc(t: ^testing.T) {
- expect_pool_allocation(t, expected_used_bytes = 8, num_bytes=1, alignment=8)
- expect_pool_allocation(t, expected_used_bytes = 16, num_bytes=9, alignment=8)
+ expect_pool_allocation(t, expected_used_bytes = 8, num_bytes = 1, alignment = 8)
+ expect_pool_allocation(t, expected_used_bytes = 16, num_bytes = 9, alignment = 8)
}
@(test)
test_dynamic_pool_alloc_out_of_band :: proc(t: ^testing.T) {
- expect_pool_allocation_out_of_band(t, num_bytes = 128, out_band_size = 128)
- expect_pool_allocation_out_of_band(t, num_bytes = 129, out_band_size = 128)
+ expect_pool_allocation_out_of_band(t, num_bytes = 128, block_size = 512, out_band_size = 128)
+ expect_pool_allocation_out_of_band(t, num_bytes = 129, block_size = 512, out_band_size = 128)
+ expect_pool_allocation_out_of_band(t, num_bytes = 513, block_size = 512, out_band_size = 128)
}
@(test)
@@ -98,4 +99,4 @@ intentionally_leaky_test :: proc(t: ^testing.T) {
leak_verifier :: proc(t: ^testing.T, ta: ^mem.Tracking_Allocator) {
testing.expect_value(t, len(ta.allocation_map), 1)
testing.expect_value(t, len(ta.bad_free_array), 1)
-} \ No newline at end of file
+}