MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / test_mp_boundary_alloc_exceed

Function test_mp_boundary_alloc_exceed

src/utest/mempool_tc.c:99–127  ·  view source on GitHub ↗

Boundary test: allocate all blocks and try to allocate more */

Source from the content-addressed store, hash-verified

97
98/* Boundary test: allocate all blocks and try to allocate more */
99static 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 */
130static void test_mp_boundary_free_invalid(void)

Callers

nothing calls this directly

Calls 2

rt_mp_allocFunction · 0.85
rt_mp_freeFunction · 0.85

Tested by

no test coverage detected