56 #include "unity_fixture.h"
59 #include "Mock_rkhsm.h"
60 #include "Mock_rkhsma.h"
62 #include "Mock_rkhport.h"
63 #include "Mock_rkhassert.h"
64 #include "Mock_rkhtrc_out.h"
65 #include "Mock_rkhtrc_stream.h"
66 #include "Mock_rkhtrc_filter.h"
75 static RKHROM
RKH_ROM_T base = {0, 0,
"receiver"};
79 static RKH_ST_T state = {{RKH_BASIC,
"state"}};
80 static RKH_ST_T pseudoState = {{RKH_CHOICE,
"pseudoState"}};
85 expectU8(rui8_t expectData)
90 rkh_trc_put_Expect((rui8_t)(expectData ^
RKH_XOR));
94 rkh_trc_put_Expect(expectData);
99 expectHeader(rui8_t evtId, rui8_t nSeq, rui32_t tStamp,
int isCritical)
103 rkh_enter_critical_Expect();
107 rkh_trc_getts_ExpectAndReturn(tStamp);
108 expectU8((rui8_t)tStamp);
109 expectU8((rui8_t)(tStamp >> 8));
110 expectU8((rui8_t)(tStamp >> 16));
111 expectU8((rui8_t)(tStamp >> 24));
115 expectObjectAddress(
void *obj)
119 value = (rui32_t)obj;
120 expectU8((rui8_t)value);
121 expectU8((rui8_t)(value >> 8));
122 expectU8((rui8_t)(value >> 16));
123 expectU8((rui8_t)(value >> 24));
127 expectString(
const char *str)
131 for (p = str; *p !=
'\0'; ++p)
133 rkh_trc_put_Expect(*p);
135 rkh_trc_put_Expect(
'\0');
139 expectTrailer(
int isCritical)
141 rkh_trc_put_Expect(0);
142 rkh_trc_put_IgnoreArg_b();
146 rkh_exit_critical_Expect();
151 expectU32(rui32_t value)
153 expectU8((rui8_t)value);
154 expectU8((rui8_t)(value >> 8));
155 expectU8((rui8_t)(value >> 16));
156 expectU8((rui8_t)(value >> 24));
160 expectU16(rui16_t value)
162 expectU8((rui8_t)value);
163 expectU8((rui8_t)(value >> 8));
169 rkh_trcStream_init_Expect();
176 Mock_rkhassert_Init();
177 Mock_rkhtrc_out_Init();
178 Mock_rkhtrc_stream_Init();
179 Mock_rkhtrc_filter_Init();
182 TEST_TEAR_DOWN(record)
190 Mock_rkhsma_Verify();
192 Mock_rkhport_Verify();
193 Mock_rkhassert_Verify();
194 Mock_rkhtrc_out_Verify();
195 Mock_rkhtrc_stream_Verify();
196 Mock_rkhtrc_filter_Verify();
197 Mock_rkhsm_Destroy();
198 Mock_rkhsma_Destroy();
200 Mock_rkhport_Destroy();
201 Mock_rkhassert_Destroy();
202 Mock_rkhtrc_out_Destroy();
203 Mock_rkhtrc_stream_Destroy();
204 Mock_rkhtrc_filter_Destroy();
213 TEST(record, InsertRecordHeader)
215 rkh_trc_put_Expect(8);
216 rkh_trc_put_Expect(0);
218 rkh_trc_getts_ExpectAndReturn(0x01234567);
219 rkh_trc_put_Expect(0x67);
220 rkh_trc_put_Expect(0x45);
221 rkh_trc_put_Expect(0x23);
222 rkh_trc_put_Expect(0x01);
227 TEST(record, InsertRecordEnd)
232 checksum = (rui8_t)(~checksum + 1);
233 rkh_trc_put_Expect(checksum);
239 TEST(record, InsertU8Value)
243 rkh_trc_put_Expect(value);
247 TEST(record, InsertEscapedValues)
251 rkh_trc_put_Expect((rui8_t)(value ^
RKH_XOR));
257 rkh_trc_put_Expect((rui8_t)(value ^
RKH_XOR));
262 TEST(record, InsertU16Value)
264 rui16_t value = 0x1234;
266 rkh_trc_put_Expect(0x34);
267 rkh_trc_put_Expect(0x12);
271 TEST(record, InsertU32Value)
273 rui32_t value = 0x12345678;
275 rkh_trc_put_Expect(0x78);
276 rkh_trc_put_Expect(0x56);
277 rkh_trc_put_Expect(0x34);
278 rkh_trc_put_Expect(0x12);
284 TEST(record, InsertString)
286 const char *expected =
"Hello world!";
289 for (p = expected; *p !=
'\0'; ++p)
291 rkh_trc_put_Expect(*p);
293 rkh_trc_put_Expect(
'\0');
298 TEST(record, InsertObject)
301 const char *objName =
"obj";
303 expectHeader(evtId, 0, 0x1234567, 1);
304 expectObjectAddress(&obj);
305 expectString(objName);
307 rkh_trc_flush_Expect();
312 TEST(record, InsertSignal)
316 const char *signalName =
"buttonPressed";
318 expectHeader(evtId, 0, 0x1234567, 1);
320 expectString(signalName);
322 rkh_trc_flush_Expect();
327 TEST(record, InsertAO)
330 expectObjectAddress(&receiver);
331 expectString(
"receiver");
333 rkh_trc_flush_Expect();
338 TEST(record, InsertState)
344 expectObjectAddress(&receiver);
345 expectObjectAddress(&state);
346 expectString(
"state");
348 rkh_trc_flush_Expect();
353 TEST(record, InsertRecord)
357 TEST(record, InsertFwkEpoolRecord)
360 const char *poolName =
"ep0";
364 expectString(poolName);
366 rkh_trc_flush_Expect();
371 TEST(record, InsertFwkActorRecord)
374 const char *actorName =
"Actor";
377 expectObjectAddress(&actor);
378 expectString(actorName);
380 rkh_trc_flush_Expect();
385 TEST(record, InsertSmaActivateRecord)
388 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
391 expectObjectAddress(&receiver);
399 TEST(record, InsertSmaGetRecord)
401 rui8_t nElem = 4, nMin = 2;
404 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
406 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSignal, event.
e,
RKH_TRUE);
408 expectObjectAddress(&receiver);
410 expectU8(event.
pool);
411 expectU8(event.
nref);
419 TEST(record, InsertSmaPostFifoRecord)
421 rui8_t nElem = 4, nMin = 2;
424 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
426 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSignal, event.
e,
RKH_TRUE);
428 expectObjectAddress(&receiver);
430 expectObjectAddress(&sender);
431 expectU8(event.
pool);
432 expectU8(event.
nref);
441 TEST(record, InsertSmaPostLifoRecord)
443 rui8_t nElem = 4, nMin = 2;
446 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
448 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSignal, event.
e,
RKH_TRUE);
450 expectObjectAddress(&receiver);
452 expectObjectAddress(&sender);
453 expectU8(event.
pool);
454 expectU8(event.
nref);
463 TEST(record, InsertFwkAeRecord)
469 expectU8(event.
pool - 1);
470 expectU8(event.
nref);
473 expectObjectAddress(&receiver);
479 TEST(record, InsertFwkGcrRecord)
484 expectU8(event.
pool - 1);
485 expectU8(event.
nref);
488 expectObjectAddress(&receiver);
494 TEST(record, InsertFwkEpregRecord)
507 TEST(record, InsertFwkStateRecord)
510 expectObjectAddress(&receiver);
511 expectObjectAddress(&state);
514 rkh_trc_flush_Expect();
519 TEST(record, InsertFwkPseudoStateRecord)
522 expectObjectAddress(&receiver);
523 expectObjectAddress(&pseudoState);
524 expectString(pseudoState.
base.
name);
526 rkh_trc_flush_Expect();
531 TEST(record, InsertDispatchRecordWithInvalidSignal)
536 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
539 expectObjectAddress(&receiver);
541 expectObjectAddress(&state);
RKH_SIG_T e
Signal of the event instance.
void rkh_trc_str(const char *s)
Store a string terminated in '\0' into the current trace event buffer without format information...
RKHROM RKH_ROM_T * romrkh
Points to constant parameters of state machine.
void rkh_trc_obj(RKH_TE_ID_T tre, rui8_t *obj, const char *obj_name)
Output object symbol record.
#define RKH_TR_SMA_FIFO(actObj_, evt_, sender_, poolID_, refCntr_, nElem_, nMin_)
Send an event to a state machine application (SMA) as known as active object through a queue using th...
rui8_t pool
Attribute of dynamic events (0 for static event).
#define RKH_TE_FWK_EPOOL
Entry symbol table for event pool object.
#define RKH_COMPLETION_EVENT
This macro is used to indicate the completion event.
#define RKH_TR_SMA_ACT(actObj_, actObjPrio_, actObjQueSize_)
Initializes and activates a previously created state machine application (SMA) as known as active obj...
#define RKH_TR_FWK_PSTATE(actObj_, pseudoStObj_)
Entry symbol table for pseudostate object.
#define RKH_TE_FWK_AE
Allocates an event from the previously created event pool.
Describes the SMA (active object in UML).
#define RKH_TE_FWK_AO
Entry symbol table for active object.
void rkh_trc_init(void)
Initializes the RKH's trace record service.
Represents events without parameters.
#define RKH_TE_FWK_OBJ
Entry symbol table for memory object.
void rkh_trc_u32(rui32_t d)
Store a 32-bit data into the current trace event buffer without format information.
Specifies the runtime filter operations for the trace facility.
#define RKH_TE_FWK_STATE
Entry symbol table for state object.
RKH_SM_T sm
State machine.
#define RKH_TR_SMA_GET(actObj_, evt_, poolID_, refCntr_, nElem_, nMin_)
Get an event from the active object's queue.
#define RKH_TE_FWK_SIG
Entry symbol table for event signal.
void rkh_trc_ao(void *ao)
Output active object (AO) symbol record.
#define RKH_GET_PRIO(_ao)
Retrieves the priority number of an registered active object (SMA).
Defines the trace records.
#define RKH_TR_FWK_EPREG(evtPool_, storageSize_, evtSize_, poolSize_)
Registers a new event pool into the event pool list.
Constant parameters of state machine.
void rkh_trc_u8(rui8_t d)
Store a 8-bit data into the current trace event buffer without format information.
void rkh_trc_begin(RKH_TE_ID_T eid)
Store the trace record header in the stream.
#define RKH_TR_FWK_STATE(actObj_, stateObj_)
Entry symbol table for state object.
#define RKH_TR_FWK_ACTOR(actorObj_, nm_)
Entry symbol table for actor object.
#define RKH_TR_SM_DCH(actObj_, evt_, state_)
Executes a state machine in a run-to-completation (RTC) model.
#define RKH_TE_FWK_EPREG
Registers a new event pool into the event pool list.
void rkh_trc_u16(rui16_t d)
Store a 16-bit data into the current trace event buffer without format information.
#define RKH_TE_SMA_LIFO
Send an event to a state machine application (SMA) as known as active object through a queue using th...
Describes the common properties of regular states (basic, composite, and submachine).
#define RKH_TRUE
Standard define.
#define RKH_TE_FWK_GCR
Effective recycling event.
void rkh_trc_end(void)
Terminate the recorded trace event.
void rkh_trc_state(void *ao, rui8_t *state)
Output state symbol record.
#define RKH_TR_FWK_GCR(evt_, nUsed_, nMin_, sender_)
Effective recycling event.
#define RKH_TE_SMA_FIFO
Send an event to a state machine application (SMA) as known as active object through a queue using th...
#define RKH_TE_SMA_ACT
Initializes and activates a previously created state machine application (SMA) as known as active obj...
#define RKH_TR_FWK_AE(evtSize_, evt_, nUsed_, nMin_, sender_)
Allocates an event from the previously created event pool.
#define RKH_TE_SM_DCH
Executes a state machine in a run-to-completation (RTC) model.
rui8_t nref
Attribute of dynamic events.
#define RKH_TE_FWK_ACTOR
Entry symbol table for actor object.
#define RKH_TE_SMA_GET
Get an event from the active object's queue.
#define RKH_TR_FWK_EPOOL(poolId_, poolName_)
Entry symbol table for event pool object.
RKH_BASE_T base
Maintains the basic information of state.
const char * name
Name of state or pseudostate.
#define RKH_TE_FWK_PSTATE
Entry symbol table for pseudostate object.
void rkh_trc_sig(RKH_SIG_T sig, const char *sig_name)
Output signal symbol record.
#define RKH_TR_SMA_LIFO(actObj_, evt_, sender_, poolID_, refCntr_, nElem_, nMin_)
Send an event to a state machine application (SMA) as known as active object through a queue using th...