Stress test: allocate and free repeatedly */
| 138 | |
| 139 | /* Stress test: allocate and free repeatedly */ |
| 140 | static void test_mp_stress_alloc_free(void) |
| 141 | { |
| 142 | void *blocks[MEMPOOL_BLOCK_COUNT]; |
| 143 | int i, j; |
| 144 | |
| 145 | for (j = 0; j < 100; j++) /* Repeat 100 times */ |
| 146 | { |
| 147 | /* Allocate all blocks */ |
| 148 | for (i = 0; i < MEMPOOL_BLOCK_COUNT; i++) |
| 149 | { |
| 150 | blocks[i] = rt_mp_alloc(&mp_static, 0); |
| 151 | uassert_not_null(blocks[i]); |
| 152 | } |
| 153 | |
| 154 | /* Check free count */ |
| 155 | uassert_true(mp_static.block_free_count == 0); |
| 156 | |
| 157 | /* Free all blocks */ |
| 158 | for (i = 0; i < MEMPOOL_BLOCK_COUNT; i++) |
| 159 | { |
| 160 | rt_mp_free(blocks[i]); |
| 161 | } |
| 162 | |
| 163 | /* Check free count */ |
| 164 | uassert_true(mp_static.block_free_count == MEMPOOL_BLOCK_COUNT); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | static rt_err_t utest_tc_init(void) |
| 169 | { |
nothing calls this directly
no test coverage detected