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