61 #include "Mock_rkhtrc_record.h"
62 #include "Mock_rkhtrc_filter.h"
63 #include "Mock_rkhmempool.h"
64 #include "Mock_rkhassert.h"
71 static rui8_t *stoStart;
72 static rui16_t stoSize;
78 MockAssertCallback(
const char*
const file,
int line,
int cmock_num_calls)
84 MockMemPoolInitCallback(
RKH_MEMPOOL_T *mp,
void* sstart, rui16_t ssize,
94 Mock_rkhmempool_Init();
95 Mock_rkhassert_Init();
96 rkh_trc_isoff__IgnoreAndReturn(
RKH_FALSE);
98 rkh_assert_StubWithCallback(MockAssertCallback);
99 rkh_memPool_init_StubWithCallback(MockMemPoolInitCallback);
101 stoStart = (
void *)0xdeadbeaf;
109 Mock_rkhmempool_Verify();
110 Mock_rkhmempool_Destroy();
111 Mock_rkhassert_Verify();
112 Mock_rkhassert_Destroy();
122 test_AfterInitAllEvtPoolAvailable(
void)
130 sprintf(name,
"memPool%1d", i);
132 rkh_trc_obj_IgnoreArg_obj();
133 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
134 rkh_memPool_init_IgnoreArg_mp();
137 TEST_ASSERT_NOT_NULL(ep);
143 test_GetOneEvtPool(
void)
148 strcpy(name,
"memPool0");
150 rkh_trc_obj_IgnoreArg_obj();
151 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
152 rkh_memPool_init_IgnoreArg_mp();
155 TEST_ASSERT_NOT_NULL(ep);
159 test_GetMultipleEvtPool(
void)
167 sprintf(name,
"memPool%1d", i);
169 rkh_trc_obj_IgnoreArg_obj();
170 rkh_memPool_init_Expect(0, stoStart + (stoSize * i),
171 stoSize, (
RKH_MPBS_T)evtSize * (2 * (i + 1)));
172 rkh_memPool_init_IgnoreArg_mp();
174 evtSize * (2 * (i + 1)));
175 TEST_ASSERT_NOT_NULL(ep[i]);
178 TEST_ASSERT_TRUE((ep[0] != ep[1]) && (ep[0] != ep[2]));
179 TEST_ASSERT_TRUE(ep[1] != ep[2]);
183 test_Fails_ExceedsMaxAvailableEvtPool(
void)
191 sprintf(name,
"memPool%1d", i);
193 rkh_trc_obj_IgnoreArg_obj();
194 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
195 rkh_memPool_init_IgnoreArg_mp();
197 TEST_ASSERT_NOT_NULL(ep);
200 TEST_ASSERT_NULL(ep);
204 test_GetBlockSize(
void)
209 strcpy(name,
"memPool0");
211 rkh_trc_obj_IgnoreArg_obj();
212 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
213 rkh_memPool_init_IgnoreArg_mp();
220 test_Fails_GetBlockSizeInvalidInstance(
void)
222 rkh_assert_Expect(
"rkhfwk_evtpool", 0);
223 rkh_assert_IgnoreArg_file();
224 rkh_assert_IgnoreArg_line();
236 strcpy(name,
"memPool0");
238 rkh_trc_obj_IgnoreArg_obj();
239 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
240 rkh_memPool_init_IgnoreArg_mp();
241 rkh_memPool_get_ExpectAndReturn(0, (
void *)0xdead);
242 rkh_memPool_get_IgnoreArg_mp();
247 TEST_ASSERT_EQUAL_PTR((
RKH_EVT_T *)0xdead, evt);
251 test_Fails_GetBlockInvalidInstance(
void)
253 rkh_assert_Expect(
"rkhfwk_evtpool", 0);
254 rkh_assert_IgnoreArg_file();
255 rkh_assert_IgnoreArg_line();
267 strcpy(name,
"memPool0");
269 rkh_trc_obj_IgnoreArg_obj();
270 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
271 rkh_memPool_init_IgnoreArg_mp();
272 rkh_memPool_put_Expect(0, evt);
273 rkh_memPool_put_IgnoreArg_mp();
280 test_Fails_PutBlockInvalidInstance(
void)
284 rkh_assert_Expect(
"rkhfwk_evtpool", 0);
285 rkh_assert_IgnoreArg_file();
286 rkh_assert_IgnoreArg_line();
292 test_GetNumUsed(
void)
297 strcpy(name,
"memPool0");
299 rkh_trc_obj_IgnoreArg_obj();
300 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
301 rkh_memPool_init_IgnoreArg_mp();
308 test_Fails_GetNumUsedInvalidInstance(
void)
310 rkh_assert_Expect(
"rkhfwk_evtpool", 0);
311 rkh_assert_IgnoreArg_file();
312 rkh_assert_IgnoreArg_line();
323 strcpy(name,
"memPool0");
325 rkh_trc_obj_IgnoreArg_obj();
326 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
327 rkh_memPool_init_IgnoreArg_mp();
334 test_Fails_GetNumMinInvalidInstance(
void)
336 rkh_assert_Expect(
"rkhfwk_evtpool", 0);
337 rkh_assert_IgnoreArg_file();
338 rkh_assert_IgnoreArg_line();
344 test_GetNumBlock(
void)
349 strcpy(name,
"memPool0");
351 rkh_trc_obj_IgnoreArg_obj();
352 rkh_memPool_init_Expect(0, stoStart, stoSize, (
RKH_MPBS_T)evtSize);
353 rkh_memPool_init_IgnoreArg_mp();
360 test_Fails_GetNumBlockInvalidInstance(
void)
362 rkh_assert_Expect(
"rkhfwk_evtpool", 0);
363 rkh_assert_IgnoreArg_file();
364 rkh_assert_IgnoreArg_line();
#define RKH_FALSE
Standard define.
#define RKH_CFG_FWK_MAX_EVT_POOL
If the dynamic event support is enabled (see RKH_CFG_FWK_DYN_EVT_EN) then the RKH_CFG_FWK_MAX_EVT_POO...
Specifies the event pool interface.
void rkh_evtPool_init()
Encapsulates the initialization of event pool manager.
rui8_t rkh_evtPool_getBlockSize(RKHEvtPool *const me)
Encapsulates how RKH should obtain the block size of an event pool.
rui8_t rkh_evtPool_getNumMin(RKHEvtPool *const me)
Encapsulates how RKH should return the lowest number of free blocks ever present in the pool me....
RKH_EVT_T * rkh_evtPool_get(RKHEvtPool *const me)
Encapsulates how RKH should obtain an event evt from the event pool me.
rui8_t rkh_evtPool_getNumBlock(RKHEvtPool *const me)
Encapsulates how RKH should return the total number of blocks in the pool me.
rui8_t rkh_evtPool_getNumUsed(RKHEvtPool *const me)
Encapsulates how RKH should return the current number of memory blocks used in the pool me.
RKHEvtPool * rkh_evtPool_getPool(void *stoStart, rui16_t stoSize, RKH_ES_T evtSize)
Encapsulates the creation of an event pool.
void rkh_evtPool_put(RKHEvtPool *const me, RKH_EVT_T *evt)
Encapsulates how RKH should return an event evt to the event pool me.
#define RKH_TE_FWK_OBJ
Entry symbol table for memory object.
Represents events without parameters.
Defines the data structure used to memory block pool facility.
RKH_MPNB_T nblocks
Total number of blocks in bytes.