| 1 | #include "mem/tests/test_internal.h" |
|---|---|
| 2 | |
| 3 | TEST_DECLARE_UNIT(mem, pmm_alloc_free_stress, |
| 4 | TEST_INTENSITY(256, 2048, 32768)) { |
| 5 | ABORT_IF_RAM_LOW(); |
| 6 | |
| 7 | size_t iters = ctx->intensity_val ? ctx->intensity_val : 2048; |
| 8 | paddr_t *pmm_stress_test_ptrs = kmalloc(sizeof(paddr_t) * iters); |
| 9 | TEST_ASSERT_NONNULL(pmm_stress_test_ptrs); |
| 10 | |
| 11 | for (size_t i = 0; i < iters; i++) { |
| 12 | pmm_stress_test_ptrs[i] = pmm_alloc_page(); |
| 13 | TEST_ASSERT_NE(pmm_stress_test_ptrs[i], 0); |
| 14 | } |
| 15 | |
| 16 | for (int64_t i = (int64_t) iters - 1; i >= 0; i--) { |
| 17 | pmm_free_page(addr: pmm_stress_test_ptrs[i]); |
| 18 | } |
| 19 | |
| 20 | kfree(pmm_stress_test_ptrs); |
| 21 | return TEST_SUCCESS; |
| 22 | } |
| 23 |