60 #include "smInstance.h"
61 #include "smPolymorphism.h"
62 #include "Mock_rkhport.h"
63 #include "Mock_rkhtrc.h"
64 #include "Mock_rkhtrc_record.h"
65 #include "Mock_rkhtrc_filter.h"
66 #include "Mock_rkhsm.h"
67 #include "Mock_rkhqueue.h"
68 #include "Mock_rkhassert.h"
76 static RKHROM
RKH_ROM_T base = {0, 0,
"receiver"};
85 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
90 TEST_ASSERT_EQUAL_PTR(activate, me->vptr->activate);
91 TEST_ASSERT_EQUAL_PTR(task, me->vptr->task);
92 TEST_ASSERT_EQUAL_PTR(postFifo, me->vptr->post_fifo);
93 TEST_ASSERT_EQUAL_PTR(postLifo, me->vptr->post_lifo);
98 void *stkSto, rui32_t stkSize)
132 setUp_polymorphism(
void)
134 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
146 Mock_rkhtrc_filter_Init();
152 Mock_rkhtrc_filter_Verify();
153 Mock_rkhtrc_filter_Destroy();
165 rkh_enter_critical_Expect();
167 rkh_exit_critical_Expect();
174 test_UnRegister(
void)
176 rkh_enter_critical_Expect();
178 rkh_exit_critical_Expect();
185 test_Constructor(
void)
187 rkh_sm_ctor_Expect(&(receiver.
sm));
193 test_TerminateOneRegisteredAO(
void)
195 rkh_enter_critical_Expect();
197 rkh_exit_critical_Expect();
201 rkh_enter_critical_Expect();
203 rkh_exit_critical_Expect();
212 test_ActivateOneAO(
void)
216 rkh_queue_init_Expect(&receiver.
equeue, (
const void **)&buff, 16,
219 rkh_enter_critical_Expect();
221 rkh_exit_critical_Expect();
223 rkh_sm_init_Expect((
RKH_SM_T *)&receiver);
233 rkh_enter_critical_Expect();
234 rkh_queue_put_fifo_Expect(&receiver.
equeue, &event);
236 rkh_exit_critical_Expect();
244 rkh_enter_critical_Expect();
245 rkh_queue_put_lifo_Expect(&receiver.
equeue, &event);
247 rkh_exit_critical_Expect();
257 rkh_queue_get_ExpectAndReturn(&receiver.
equeue, &event);
261 TEST_ASSERT_EQUAL(&event, e);
267 rkh_enter_critical_Expect();
268 rkh_queue_put_fifo_Expect(&receiver.
equeue, &event);
270 rkh_exit_critical_Expect();
280 rkh_queue_get_ExpectAndReturn(&receiver.
equeue, NULL);
283 TEST_ASSERT_EQUAL(NULL, e);
296 test_ctorOfStaticPrivateAO(
void)
301 TEST_ASSERT_EQUAL(4, Single_getFoo());
305 test_staticPublicAOWithoutRuntimeCtor(
void)
307 publicSingle->foo = 8;
308 TEST_ASSERT_EQUAL_STRING(
"publicSingle",
313 test_ctorOfStaticPublicAO(
void)
315 PublicSingle_ctor(8);
317 TEST_ASSERT_EQUAL_STRING(
"publicSingle",
319 TEST_ASSERT_EQUAL(8, publicSingle->foo);
323 test_ctorOfStaticOpaqueAO(
void)
325 Opaque_ctor(opaque, 4);
327 TEST_ASSERT_EQUAL(4, Opaque_getFoo(opaque));
331 test_ctorOfStaticMultipleAO(
void)
333 MultiplePublicSingle_ctor(single0, 8);
335 TEST_ASSERT_EQUAL_STRING(
"single0",
337 TEST_ASSERT_EQUAL(8, single0->foo);
341 test_ctorOfStaticArrayOfAO(
void)
344 MultiplePublicSingle_ctor(pSingle, 8);
346 TEST_ASSERT_EQUAL_STRING(
"single2",
348 TEST_ASSERT_EQUAL(8, pSingle->foo);
352 test_staticPrivateSMWithoutRuntimeCtor(
void)
354 TEST_ASSERT_EQUAL_STRING(
"stateMachine",
356 TEST_ASSERT_EQUAL_PTR(NULL, stateMachine->state);
360 test_staticPublicSMWithoutRuntimeCtor(
void)
362 TEST_ASSERT_EQUAL_STRING(
"publicStateMachine",
364 TEST_ASSERT_EQUAL(8, publicSingle->foo);
368 test_ctorOfStaticCompositePrivateSingletonAO(
void)
372 TEST_ASSERT_EQUAL_STRING(
"composite",
374 TEST_ASSERT_EQUAL_STRING(
"region",
376 TEST_ASSERT_EQUAL(16, Composite_getFoo());
380 test_ctorOfStaticCompositePublicAO(
void)
382 PublicComposite_ctor(publicComposite, 16);
384 TEST_ASSERT_EQUAL_STRING(
"publicComposite",
386 TEST_ASSERT_EQUAL_STRING(
"publicRegion",
388 TEST_ASSERT_EQUAL(16, publicComposite->foo);
392 test_ctorOfStaticCompositeAOWithDerivedPublicSM(
void)
394 PublicCompositeA_ctor(publicCompositeA, 16, 8);
396 TEST_ASSERT_EQUAL_STRING(
"publicCompositeA",
398 TEST_ASSERT_EQUAL_STRING(
"publicRegionA",
400 TEST_ASSERT_EQUAL(16, publicCompositeA->foo);
401 TEST_ASSERT_EQUAL(8, publicCompositeA->itsReactivePart.foo);
405 test_ctorOfDynamicCompositeAO(
void)
407 PublicSingle *actObj;
409 actObj = PublicSingle_dynCtor(8);
410 TEST_ASSERT_NOT_NULL(actObj);
411 TEST_ASSERT_EQUAL(8, actObj->foo);
413 TEST_ASSERT_EQUAL_STRING(
"publicSingleDyn",
416 PublicSingle_dynDtor(actObj);
429 test_defaultVirtualFunctions(
void)
431 setUp_polymorphism();
432 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
437 TEST_ASSERT_EQUAL_PTR(&
rkhSmaVtbl, singleton->vptr);
442 test_callVirtualFunction(
void)
444 setUp_polymorphism();
445 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
448 rkh_queue_init_Ignore();
449 rkh_enter_critical_Expect();
451 rkh_exit_critical_Expect();
452 rkh_sm_init_Ignore();
455 rkh_enter_critical_Expect();
456 rkh_queue_put_fifo_Ignore();
458 rkh_exit_critical_Expect();
460 rkh_enter_critical_Expect();
461 rkh_queue_put_lifo_Ignore();
463 rkh_exit_critical_Expect();
472 test_setVirtualTable(
void)
474 setUp_polymorphism();
475 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
479 testActivate, testTask, testPostFifo, testPostLifo
482 vptr = singleton->vptr = &vtbl;
485 testActivate, testTask, testPostFifo, testPostLifo);
490 test_runtimeSingletonAOCtor(
void)
492 setUp_polymorphism();
493 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
494 rkh_sm_ctor_Expect(&singleton->sm);
497 TEST_ASSERT_EQUAL(8, Singleton_getFoo());
500 TEST_ASSERT_EQUAL(0, Singleton_getFoo());
505 test_runtimeMultipleAOCtorWithVtblForObj(
void)
507 setUp_polymorphism();
508 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
509 rkh_sm_ctor_Ignore();
510 rkh_sm_ctor_Ignore();
512 Multiple_ctor(multA, 2, Multiple_postFifoA);
513 Multiple_ctor(multB, 4, Multiple_postFifoB);
519 TEST_ASSERT_EQUAL(2, Multiple_getFoobar(multA));
520 TEST_ASSERT_EQUAL(4, Multiple_getFoobar(multB));
525 TEST_ASSERT_EQUAL(0, Multiple_getFoobar(multA));
526 TEST_ASSERT_EQUAL(8, Multiple_getFoobar(multB));
531 test_runtimeMultipleAOCtorWithVtblForType(
void)
533 setUp_polymorphism();
534 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
535 rkh_sm_ctor_Expect((
RKH_SM_T *)cmdSignal);
536 rkh_sm_ctor_Expect((
RKH_SM_T *)cmdRegister);
538 Command_ctor(cmdSignal, 128);
539 Command_ctor(cmdRegister, 64);
543 Command_postFifo, Command_postLifo);
547 Command_postFifo, Command_postLifo);
552 test_runtimeSubObjectCtorOfSMAAndSM(
void)
554 setUp_polymorphism();
555 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
556 rkh_sm_ctor_Expect((
RKH_SM_T *)theCallControl);
557 CallControl_ctorA(16);
559 TEST_ASSERT_EQUAL(16, CallControl_getFoo());
561 CallControl_activate, CallControl_task,
567 test_runtimeSubObjectCtorOfSMAAndSMWithDefaultVtbl(
void)
569 setUp_polymorphism();
570 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
571 rkh_sm_ctor_Expect((
RKH_SM_T *)theCallControl);
572 CallControl_ctorB(8);
574 TEST_ASSERT_EQUAL(8, CallControl_getFoo());
void rkh_sma_dispatch(RKH_SMA_T *me, void *arg)
For cooperative scheduling policy, this function is used to dispatch the event to the active object b...
#define RKH_SMA_POST_LIFO(me_, e_, sender_)
Invoke the direct event posting facility rkh_sma_post_lifo(). If RKH_CFG_SMA_VFUNCT_EN is set RKH_ENA...
#define RKH_SMA_POST_FIFO(me_, e_, sender_)
Invoke the direct event posting facility rkh_sma_post_fifo(). If RKH_CFG_SMA_VFUNCT_EN is set RKH_ENA...
#define RKH_SMA_ACTIVATE(me_, qSto_, qStoSize, stkSto_, stkSize_)
Invoke the active object activation function rkh_sma_activate(). If RKH_CFG_SMA_VFUNCT_EN is set RKH_...
#define RKH_FALSE
Standard define.
void rkh_sma_post_lifo(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
Send an event to a state machine application (SMA) as known as active object through a queue using th...
void rkh_sma_terminate(RKH_SMA_T *me)
Terminate a state machine application (SMA) as known as active object.
void rkh_sma_post_fifo(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
Send an event to a state machine application (SMA) as known as active object through a queue using th...
RKH_EVT_T * rkh_sma_get(RKH_SMA_T *me)
Get an event from the event queue of an state machine application (SMA) as known as active object....
void rkh_sma_activate(RKH_SMA_T *me, const RKH_EVT_T **qSto, RKH_QUENE_T qSize, void *stkSto, rui32_t stkSize)
Initializes and activates a previously created state machine application (SMA) as known as active obj...
RKH_SMA_T * rkh_sptbl[RKH_CFG_FWK_MAX_SMA]
Priority arranged table of registered SMA.
rui8_t RKH_QUENE_T
This data type defines the maximum number of elements that any queue can contain.
Specifies the interface of the acive object (SMA state machine applications) manager.
void rkh_sma_register(RKH_SMA_T *me)
Registers a state machine application (SMA) as known as active object into the framework,...
void(* RKHTask)(RKH_SMA_T *me, void *arg)
RKH_EVT_T * rkh_sma_recall(RKH_SMA_T *me, RKH_QUEUE_T *q)
Recall a deferred event from a given event queue.
void rkh_sma_defer(RKH_QUEUE_T *q, const RKH_EVT_T *e)
Defer an event to a given separate event queue.
const RKHSmaVtbl rkhSmaVtbl
#define RKH_ARRAY_SMA(_arr, _ix)
Retrieves the pointer to active object from a SMA's array.
void(* RKHActivate)(RKH_SMA_T *me, const RKH_EVT_T **qSto, RKH_QUENE_T qSize, void *stkSto, rui32_t stkSize)
void rkh_sma_unregister(RKH_SMA_T *me)
Removes the SMA as known as active object from the priority table, and thus from the framework,...
void(* RKHPostLifo)(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
void(* RKHPostFifo)(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
#define RKH_SMA_ACCESS_CONST(me_, member_)
Macro for accessing to members of state machine structure.
void rkh_sma_ctor(RKH_SMA_T *me, const RKHSmaVtbl *vtbl)
Initializes the virtual table of the active object instance and calls the constructor operation of it...
#define RKH_TE_SMA_LIFO
Send an event to a state machine application (SMA) as known as active object through a queue using th...
#define RKH_TE_SMA_REG
Registers a state machine application (SMA) as known as active object into the framework,...
#define RKH_TE_SMA_UNREG
Removes the SMA as known as active object from the priority table, and thus from the framework,...
#define RKH_TE_SMA_TERM
Terminate a state machine application (SMA) as known as active object.
#define RKH_TE_SMA_DEFER
Defer an event to a given separate event queue.
#define RKH_TE_SMA_ACT
Initializes and activates a previously created state machine application (SMA) as known as active obj...
#define RKH_TE_SMA_GET
Get an event from the active object's queue.
#define RKH_TE_SMA_FIFO
Send an event to a state machine application (SMA) as known as active object through a queue using th...
Represents events without parameters.
Constant parameters of state machine.
rui8_t prio
SMA (a.k.a Active Object) priority.
Describes the state machine.
RKHROM RKH_ROM_T * romrkh
Points to constant parameters of state machine.
Describes the SMA (active object in UML).
RKH_SM_T sm
State machine.
RKH_EQ_TYPE equeue
Event queue of the SMA (a.k.a Active Object).
Represents the filter of signal and active object.
Virtual table for the RKH_SMA_T structure.