60 #include "Mock_rkhfwk_bittbl.h"
61 #include "Mock_rkhassert.h"
65 static const rui8_t bitMaskTbl[] =
67 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
70 static const rui8_t leastBitSetTbl[] =
72 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
73 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
74 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
75 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
76 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
77 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
78 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
79 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
80 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
81 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
82 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
83 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
84 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
85 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
86 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
87 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
91 typedef struct DerivedRdyCbArg DerivedRdyCbArg;
92 struct DerivedRdyCbArg
101 static DerivedRdyCbArg rdyCbArg;
102 static rui8_t prio[] = {0, 3, 9, 17, 27, 33, 41, 55, 63};
107 MockAssertCallback(
const char*
const file,
int line,
int cmock_num_calls)
115 TEST_ASSERT_EQUAL(prio[((DerivedRdyCbArg *)arg)->cnt++], arg->aoRdyPrio);
122 Mock_rkhfwk_bittbl_Init();
123 Mock_rkhassert_Init();
130 Mock_rkhfwk_bittbl_Verify();
131 Mock_rkhfwk_bittbl_Destroy();
132 Mock_rkhassert_Verify();
133 Mock_rkhassert_Destroy();
143 test_ClearAfterInit(
void)
148 TEST_ASSERT_EQUAL(0, result);
152 test_SetOneActiveObjectReady(
void)
155 rui8_t prio = 1, resultPrio, column, row;
159 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
160 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
164 TEST_ASSERT_EQUAL(1, result);
166 rkh_bittbl_getLeastBitSetPos_ExpectAndReturn(1, leastBitSetTbl[1]);
167 rkh_bittbl_getLeastBitSetPos_ExpectAndReturn(2, leastBitSetTbl[2]);
169 TEST_ASSERT_EQUAL(prio, resultPrio);
173 test_SetMultipleActiveObjectsReady(
void)
175 rui8_t prioA = 1, prioC = 0, prioB = 15, resultPrio, column, row;
179 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
180 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
185 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
186 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
191 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
192 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
195 rkh_bittbl_getLeastBitSetPos_ExpectAndReturn(3, leastBitSetTbl[3]);
196 rkh_bittbl_getLeastBitSetPos_ExpectAndReturn(3, leastBitSetTbl[3]);
198 TEST_ASSERT_EQUAL(prioC, resultPrio);
202 test_SetOneActiveObjectUnready(
void)
205 rui8_t prio = 1, resultPrio, column, row;
209 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
210 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
214 rkh_bittbl_getLeastBitSetPos_ExpectAndReturn(1, leastBitSetTbl[1]);
215 rkh_bittbl_getLeastBitSetPos_ExpectAndReturn(2, leastBitSetTbl[2]);
217 TEST_ASSERT_EQUAL(prio, resultPrio);
219 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
220 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
223 TEST_ASSERT_EQUAL(0, result);
227 test_SetMultipleActiveObjectsUnready(
void)
230 rui8_t prioA = 1, prioC = 0, prioB = 15, column, row;
234 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
235 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
240 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
241 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
246 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
247 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
252 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
257 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
258 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
263 rkh_bittbl_getBitMask_ExpectAndReturn(row, bitMaskTbl[row]);
264 rkh_bittbl_getBitMask_ExpectAndReturn(column, bitMaskTbl[column]);
268 TEST_ASSERT_EQUAL(0, result);
272 test_Fails_InvalidActiveObjectOnSet(
void)
276 rkh_assert_Expect(
"rkhfwk_rdygrp", 0);
277 rkh_assert_IgnoreArg_file();
278 rkh_assert_IgnoreArg_line();
279 rkh_assert_StubWithCallback(MockAssertCallback);
285 test_TraverseWithOneReadyActiveObject(
void)
287 rui8_t nRdyAo, resultNRdyAo;
289 rkh_bittbl_getBitMask_IgnoreAndReturn(bitMaskTbl[prio[0] >> 3]);
290 rkh_bittbl_getBitMask_IgnoreAndReturn(bitMaskTbl[prio[0] & 7]);
296 TEST_ASSERT_EQUAL(nRdyAo, resultNRdyAo);
297 TEST_ASSERT_EQUAL(nRdyAo, rdyCbArg.cnt);
301 test_TraverseWithMultipleReadyActiveObject(
void)
303 rui8_t nRdyAo, resultNRdyAo, ix;
306 for (ix = 0; ix < nRdyAo; ++ix)
308 rkh_bittbl_getBitMask_IgnoreAndReturn(bitMaskTbl[prio[ix] >> 3]);
309 rkh_bittbl_getBitMask_IgnoreAndReturn(bitMaskTbl[prio[ix] & 7]);
315 TEST_ASSERT_EQUAL(nRdyAo, resultNRdyAo);
316 TEST_ASSERT_EQUAL(nRdyAo, rdyCbArg.cnt);
320 test_TraverseWithWithoutReadyActiveObject(
void)
322 rui8_t nRdyAo, resultNRdyAo;
327 TEST_ASSERT_EQUAL(nRdyAo, resultNRdyAo);
328 TEST_ASSERT_EQUAL(nRdyAo, rdyCbArg.cnt);
#define RKH_CFG_FWK_MAX_SMA
Specify the maximum number of state machine applications (SMA) to be used by the application (can be ...
void rkh_rdygrp_setReady(RKHRdyGrp *const me, rui8_t prio)
Making an active object ready inserting it into the ready list.
rbool_t rkh_rdygrp_isReady(RKHRdyGrp *const me)
Evaluates to true if any active object is ready.
void rkh_rdygrp_setUnready(RKHRdyGrp *const me, rui8_t prio)
Removing an active object from the ready list.
rui8_t rkh_rdygrp_findHighest(RKHRdyGrp *const me)
Finding the highest priority active object ready.
rui8_t rkh_rdygrp_traverse(RKHRdyGrp *const me, void(*rdyCb)(RdyCbArg *), RdyCbArg *rdyCbArg)
Traverse a ready list to find the ready active objects and thus invoking a callback function.
void rkh_rdygrp_init(RKHRdyGrp *const me)
Initializes the ready mechanism for active objects.