60 #include "Mock_rkhsm.h"
61 #include "Mock_rkhsma.h"
63 #include "Mock_rkhport.h"
64 #include "Mock_rkhassert.h"
65 #include "Mock_rkhtrc_out.h"
66 #include "Mock_rkhtrc_stream.h"
67 #include "Mock_rkhtrc_filter.h"
74 static RKHROM
RKH_ROM_T base = {0, 0,
"receiver"};
78 static RKH_ST_T state = {{RKH_BASIC,
"state"}};
79 static RKH_ST_T pseudoState = {{RKH_CHOICE,
"pseudoState"}};
85 expectU8(rui8_t expectData)
87 chk = (rui8_t)(chk + expectData);
91 rkh_trc_put_Expect((rui8_t)(expectData ^
RKH_XOR));
95 rkh_trc_put_Expect(expectData);
100 expectHeader(rui8_t evtId, rui8_t nSeq, rui32_t tStamp,
int isCritical)
104 rkh_enter_critical_Expect();
108 rkh_trc_getts_ExpectAndReturn(tStamp);
109 expectU8((rui8_t)tStamp);
110 expectU8((rui8_t)(tStamp >> 8));
111 expectU8((rui8_t)(tStamp >> 16));
112 expectU8((rui8_t)(tStamp >> 24));
116 expectObjectAddress(
void *obj)
120 value = (rui32_t)obj;
121 expectU8((rui8_t)value);
122 expectU8((rui8_t)(value >> 8));
123 expectU8((rui8_t)(value >> 16));
124 expectU8((rui8_t)(value >> 24));
128 expectString(
const char *str)
132 for (p = str; *p !=
'\0'; ++p)
134 expectU8((rui8_t)*p);
136 expectU8((rui8_t)
'\0');
140 expectTrailer(
int isCritical)
142 chk = (rui8_t)(~chk + 1);
145 rkh_trc_put_IgnoreArg_b();
148 rkh_exit_critical_Expect();
153 expectU32(rui32_t value)
155 expectU8((rui8_t)value);
156 expectU8((rui8_t)(value >> 8));
157 expectU8((rui8_t)(value >> 16));
158 expectU8((rui8_t)(value >> 24));
162 expectU16(rui16_t value)
164 expectU8((rui8_t)value);
165 expectU8((rui8_t)(value >> 8));
172 rkh_trcStream_init_Expect();
179 Mock_rkhassert_Init();
180 Mock_rkhtrc_out_Init();
181 Mock_rkhtrc_stream_Init();
182 Mock_rkhtrc_filter_Init();
195 Mock_rkhsma_Verify();
197 Mock_rkhport_Verify();
198 Mock_rkhassert_Verify();
199 Mock_rkhtrc_out_Verify();
200 Mock_rkhtrc_stream_Verify();
201 Mock_rkhtrc_filter_Verify();
202 Mock_rkhsm_Destroy();
203 Mock_rkhsma_Destroy();
205 Mock_rkhport_Destroy();
206 Mock_rkhassert_Destroy();
207 Mock_rkhtrc_out_Destroy();
208 Mock_rkhtrc_stream_Destroy();
209 Mock_rkhtrc_filter_Destroy();
219 test_InsertRecordHeader(
void)
221 rkh_trc_put_Expect(8);
222 rkh_trc_put_Expect(0);
224 rkh_trc_getts_ExpectAndReturn(0x01234567);
225 rkh_trc_put_Expect(0x67);
226 rkh_trc_put_Expect(0x45);
227 rkh_trc_put_Expect(0x23);
228 rkh_trc_put_Expect(0x01);
234 test_InsertRecordEnd(
void)
239 checksum = (rui8_t)(~checksum + 1);
240 rkh_trc_put_Expect(checksum);
247 test_InsertU8Value(
void)
251 rkh_trc_put_Expect(value);
256 test_InsertEscapedValues(
void)
260 rkh_trc_put_Expect((rui8_t)(value ^
RKH_XOR));
266 rkh_trc_put_Expect((rui8_t)(value ^
RKH_XOR));
272 test_InsertU16Value(
void)
274 rui16_t value = 0x1234;
276 rkh_trc_put_Expect(0x34);
277 rkh_trc_put_Expect(0x12);
282 test_InsertU32Value(
void)
284 rui32_t value = 0x12345678;
286 rkh_trc_put_Expect(0x78);
287 rkh_trc_put_Expect(0x56);
288 rkh_trc_put_Expect(0x34);
289 rkh_trc_put_Expect(0x12);
296 test_InsertString(
void)
298 const char *expected =
"Hello world!";
301 for (p = expected; *p !=
'\0'; ++p)
303 rkh_trc_put_Expect(*p);
305 rkh_trc_put_Expect(
'\0');
311 test_InsertObject(
void)
314 const char *objName =
"obj";
316 expectHeader(evtId, 0, 0x12345678, 1);
317 expectObjectAddress(&obj);
318 expectString(objName);
320 rkh_trc_flush_Expect();
326 test_InsertSignal(
void)
330 const char *signalName =
"buttonPressed";
332 expectHeader(evtId, 0, 0x12345678, 1);
334 expectString(signalName);
336 rkh_trc_flush_Expect();
345 expectObjectAddress(&receiver);
348 rkh_trc_flush_Expect();
354 test_InsertState(
void)
361 expectObjectAddress(&receiver);
362 expectObjectAddress(&state);
363 expectString(
"state");
365 rkh_trc_flush_Expect();
371 test_InsertRecord(
void)
376 test_InsertFwkEpoolRecord(
void)
379 const char *poolName =
"ep0";
383 expectString(poolName);
385 rkh_trc_flush_Expect();
391 test_InsertFwkActorRecord(
void)
394 const char *actorName =
"Actor";
397 expectObjectAddress(&actor);
398 expectString(actorName);
400 rkh_trc_flush_Expect();
406 test_InsertSmaActivateRecord(
void)
409 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
412 expectObjectAddress(&receiver);
421 test_InsertSmaGetRecord(
void)
423 rui8_t nElem = 4, nMin = 2;
426 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
428 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSignal, event.
e,
RKH_TRUE);
430 expectObjectAddress(&receiver);
432 expectU8(event.
pool);
433 expectU8(event.
nref);
442 test_InsertSmaPostFifoRecord(
void)
444 rui8_t nElem = 4, nMin = 2;
447 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
449 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSignal, event.
e,
RKH_TRUE);
451 expectObjectAddress(&receiver);
453 expectObjectAddress(&sender);
454 expectU8(event.
pool);
455 expectU8(event.
nref);
465 test_InsertSmaPostLifoRecord(
void)
467 rui8_t nElem = 4, nMin = 2;
470 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
472 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSignal, event.
e,
RKH_TRUE);
474 expectObjectAddress(&receiver);
476 expectObjectAddress(&sender);
477 expectU8(event.
pool);
478 expectU8(event.
nref);
488 test_InsertFwkAeRecord(
void)
494 expectU8(event.
pool - 1);
495 expectU8(event.
nref);
498 expectObjectAddress(&receiver);
505 test_InsertFwkGcrRecord(
void)
510 expectU8(event.
pool - 1);
511 expectU8(event.
nref);
514 expectObjectAddress(&receiver);
521 test_InsertFwkEpregRecord(
void)
535 test_InsertFwkStateRecord(
void)
538 expectObjectAddress(&receiver);
539 expectObjectAddress(&state);
542 rkh_trc_flush_Expect();
548 test_InsertFwkPseudoStateRecord(
void)
551 expectObjectAddress(&receiver);
552 expectObjectAddress(&pseudoState);
553 expectString(pseudoState.
base.
name);
555 rkh_trc_flush_Expect();
561 test_InsertDispatchRecordWithInvalidSignal(
void)
566 rkh_trc_symFil_isoff_ExpectAndReturn(RKHFilterSma,
RKH_GET_PRIO(&receiver),
569 expectObjectAddress(&receiver);
571 expectObjectAddress(&state);
#define RKH_TRUE
Standard define.
#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_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...
#define RKH_TR_SMA_GET(actObj_, evt_, poolID_, refCntr_, nElem_, nMin_)
Get an event from the active object's queue.
#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...
#define RKH_TR_FWK_EPREG(evtPool_, storageSize_, evtSize_, poolSize_)
Registers a new event pool into the event pool list.
#define RKH_TR_FWK_GCR(evt_, nUsed_, nMin_, sender_)
Effective recycling event.
#define RKH_TR_FWK_PSTATE(actObj_, pseudoStObj_)
Entry symbol table for pseudostate object.
#define RKH_TR_FWK_ACTOR(actorObj_, nm_)
Entry symbol table for actor object.
#define RKH_TR_FWK_EPOOL(poolId_, poolName_)
Entry symbol table for event pool object.
#define RKH_TR_FWK_AE(evtSize_, evt_, nUsed_, nMin_, sender_)
Allocates an event from the previously created event pool.
#define RKH_TR_FWK_STATE(actObj_, stateObj_)
Entry symbol table for state object.
#define RKH_TR_SM_DCH(actObj_, evt_, state_)
Executes a state machine in a run-to-completation (RTC) model.
#define RKH_COMPLETION_EVENT
This macro is used to indicate the completion event.
#define RKH_GET_PRIO(_ao)
Retrieves the priority number of an registered active object (SMA).
#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_FWK_EPOOL
Entry symbol table for event pool object.
#define RKH_TE_SM_DCH
Executes a state machine in a run-to-completation (RTC) model.
#define RKH_TE_FWK_ACTOR
Entry symbol table for actor object.
#define RKH_TE_FWK_OBJ
Entry symbol table for memory object.
#define RKH_TE_FWK_SIG
Entry symbol table for event signal.
#define RKH_TE_FWK_AE
Allocates an event from the previously created event pool.
#define RKH_TE_FWK_STATE
Entry symbol table for state object.
#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_FWK_EPREG
Registers a new event pool into the event pool list.
#define RKH_TE_FWK_PSTATE
Entry symbol table for pseudostate object.
#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_FWK_AO
Entry symbol table for active object.
#define RKH_TE_FWK_GCR
Effective recycling event.
Defines the trace records.
void rkh_trc_obj(RKH_TE_ID_T tre, rui8_t *obj, const char *obj_name)
Output object symbol record.
void rkh_trc_begin(RKH_TE_ID_T eid)
Store the trace record header in the stream.
void rkh_trc_ao(void *ao)
Output active object (AO) symbol record.
void rkh_trc_end(void)
Terminate the recorded trace event.
void rkh_trc_str(const char *s)
Store a string terminated in '\0' into the current trace event buffer without format information.
void rkh_trc_u8(rui8_t d)
Store a 8-bit data into the current trace event buffer without format information.
void rkh_trc_init(void)
Initializes the RKH's trace record service.
void rkh_trc_sig(RKH_SIG_T sig, const char *sig_name)
Output signal symbol record.
void rkh_trc_u16(rui16_t d)
Store a 16-bit data into the current trace event buffer without format information.
void rkh_trc_state(void *ao, rui8_t *state)
Output state symbol record.
void rkh_trc_u32(rui32_t d)
Store a 32-bit data into the current trace event buffer without format information.
const char * name
Name of state or pseudostate.
Represents events without parameters.
RKH_SIG_T e
Signal of the event instance.
rui8_t nref
Attribute of dynamic events.
rui8_t pool
Attribute of dynamic events (0 for static event).
Constant parameters of state machine.
const char * name
Name of State Machine Application (a.k.a Active Object).
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.
Describes the common properties of regular states (basic, composite, and submachine).
RKH_BASE_T base
Maintains the basic information of state.