Boundary test: allocate all blocks and try to allocate more */
| 97 | |
| 98 | /* Boundary test: allocate all blocks and try to allocate more */ |
| 99 | static void test_mp_boundary_alloc_exceed(void) |
| 100 | { |
| 101 | void *blocks[MEMPOOL_BLOCK_COUNT]; |
| 102 | void *extra_block; |
| 103 | int i; |
| 104 | |
| 105 | /* Allocate all blocks */ |
| 106 | for (i = 0; i < MEMPOOL_BLOCK_COUNT; i++) |
| 107 | { |
| 108 | blocks[i] = rt_mp_alloc(&mp_static, 0); |
| 109 | uassert_not_null(blocks[i]); |
| 110 | } |
| 111 | |
| 112 | /* Check free count */ |
| 113 | uassert_true(mp_static.block_free_count == 0); |
| 114 | |
| 115 | /* Try to allocate one more (should fail) */ |
| 116 | extra_block = rt_mp_alloc(&mp_static, 0); |
| 117 | uassert_null(extra_block); |
| 118 | |
| 119 | /* Free all blocks */ |
| 120 | for (i = 0; i < MEMPOOL_BLOCK_COUNT; i++) |
| 121 | { |
| 122 | rt_mp_free(blocks[i]); |
| 123 | } |
| 124 | |
| 125 | /* Check free count */ |
| 126 | uassert_true(mp_static.block_free_count == MEMPOOL_BLOCK_COUNT); |
| 127 | } |
| 128 | |
| 129 | /* Boundary test: free invalid block */ |
| 130 | static void test_mp_boundary_free_invalid(void) |
nothing calls this directly
no test coverage detected