26 #include "unity_fixture.h"
30 #include "aotest_act.h"
31 #include "test_common.h"
36 #define utrzExpect_Ok_check() \
39 p = unitrazer_getLastOut(); \
40 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status); \
43 #define utrzExpect_OutOfSequence_check(ex, rc) \
46 p = unitrazer_getLastOut(); \
47 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status); \
48 TEST_ASSERT_EQUAL_STRING("Out of order Trace event." \
49 " occurred: '"rc"' expected: '"ex"'.", p->msg); \
52 #define utrzExpect_WithUnexpectedArg_check( ev, an, e, r ) \
55 p = unitrazer_getLastOut(); \
56 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status); \
57 TEST_ASSERT_EQUAL_STRING("Event '"ev"' occurred with unexpected " \
58 "value for argument '"an"="r"' expected " \
59 "value='"e"'.", p->msg); \
62 #define utrzExpect_WithUnexpectedArgNoName_check( ev, e, r ) \
65 p = unitrazer_getLastOut(); \
66 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status); \
67 TEST_ASSERT_EQUAL_STRING("Event '"ev"' occurred with unexpected " \
68 "value for argument '"r"' expected " \
69 "value='"e"'.", p->msg); \
76 TEST_GROUP(utrzExpect);
83 TEST_SETUP(utrzExpect)
91 TEST_TEAR_DOWN(utrzExpect)
106 TEST(utrzExpect, sm_init_Ok)
108 sm_init_expect(CST(&s21));
112 utrzExpect_Ok_check();
115 TEST(utrzExpect, sm_init_OutOfSequence)
117 sm_init_expect(CST(&s21));
121 utrzExpect_OutOfSequence_check(
"INIT",
"ENSTATE" );
124 TEST(utrzExpect, sm_init_WithUnexpectedArg)
126 sm_init_expect(CST(&s21));
130 utrzExpect_WithUnexpectedArg_check(
"INIT",
"ist", str(s21), str(s211) );
133 TEST(utrzExpect, sm_clrh_Ok)
135 sm_clrh_expect(CST(&s21));
139 utrzExpect_Ok_check();
142 TEST(utrzExpect, sm_clrh_OutOfSequence)
144 sm_clrh_expect(CST(&s21));
148 utrzExpect_OutOfSequence_check(
"CLRH",
"ENSTATE" );
151 TEST(utrzExpect, sm_clrh_WithUnexpectedArg)
153 sm_clrh_expect(CST(&s21));
157 utrzExpect_WithUnexpectedArg_check(
"CLRH",
"h", str(s21), str(s211) );
160 TEST(utrzExpect, sm_trn_Ok)
162 sm_trn_expect(CST(&s21), CST(&s211));
166 utrzExpect_Ok_check();
169 TEST(utrzExpect, sm_trn_OutOfSequence)
171 sm_trn_expect(CST(&s21), CST(&s211));
175 utrzExpect_OutOfSequence_check(
"TRN",
"ENSTATE" );
178 TEST(utrzExpect, sm_trn_WithUnexpectedArg)
180 sm_trn_expect(CST(&s21), CST(&s211));
184 utrzExpect_WithUnexpectedArg_check(
"TRN",
"tst", str(s211), str(s21) );
186 sm_trn_expect(CST(&s21), CST(&s211));
190 utrzExpect_WithUnexpectedArg_check(
"TRN",
"sst", str(s21), str(s211) );
194 TEST(utrzExpect, sm_trn_WithAnyArgs)
196 sm_trn_expectAnyArgs();
200 utrzExpect_Ok_check();
203 TEST(utrzExpect, sm_state_Ok)
205 sm_state_expect(CST(&s21));
209 utrzExpect_Ok_check();
212 TEST(utrzExpect, sm_state_OutOfSequence)
214 sm_state_expect(CST(&s21));
218 utrzExpect_OutOfSequence_check(
"STATE",
"ENSTATE" );
221 TEST(utrzExpect, sm_state_WithUnexpectedArg)
223 sm_state_expect(CST(&s21));
227 utrzExpect_WithUnexpectedArg_check(
"STATE",
"nxtst", str(s21), str(s211) );
230 TEST(utrzExpect, sm_enstate_Ok)
232 sm_enstate_expect(CST(&s21));
236 utrzExpect_Ok_check();
239 TEST(utrzExpect, sm_enstate_OutOfSequence)
241 sm_enstate_expect(CST(&s21));
245 utrzExpect_OutOfSequence_check(
"ENSTATE",
"STATE" );
248 TEST(utrzExpect, sm_enstate_WithUnexpectedArg)
250 sm_enstate_expect(CST(&s21));
254 utrzExpect_WithUnexpectedArg_check(
"ENSTATE",
"st", str(s21), str(s211) );
257 TEST(utrzExpect, sm_exstate_Ok)
259 sm_exstate_expect(CST(&s21));
263 utrzExpect_Ok_check();
266 TEST(utrzExpect, sm_exstate_OutOfSequence)
268 sm_exstate_expect(CST(&s21));
272 utrzExpect_OutOfSequence_check(
"EXSTATE",
"STATE" );
275 TEST(utrzExpect, sm_exstate_WithUnexpectedArg)
277 sm_exstate_expect(CST(&s21));
281 utrzExpect_WithUnexpectedArg_check(
"EXSTATE",
"st", str(s21), str(s211) );
284 TEST(utrzExpect, sm_nenex_Ok)
286 sm_nenex_expect(2,3);
290 utrzExpect_Ok_check();
293 TEST(utrzExpect, sm_nenex_OutOfSequence)
295 sm_nenex_expect(2,3);
299 utrzExpect_OutOfSequence_check(
"NENEX",
"STATE" );
302 TEST(utrzExpect, sm_nenex_WithUnexpectedArg)
304 sm_nenex_expect(2,3);
308 utrzExpect_WithUnexpectedArg_check(
"NENEX",
"nen",
"2",
"3");
310 sm_nenex_expect(2,3);
314 utrzExpect_WithUnexpectedArg_check(
"NENEX",
"nex",
"3",
"2");
317 TEST(utrzExpect, sm_ntrnact_Ok)
319 sm_ntrnact_expect(2,3);
323 utrzExpect_Ok_check();
326 TEST(utrzExpect, sm_ntrnact_OutOfSequence)
328 sm_ntrnact_expect(2,3);
332 utrzExpect_OutOfSequence_check(
"NTRNACT",
"STATE" );
335 TEST(utrzExpect, sm_ntrnact_WithUnexpectedArg)
337 sm_ntrnact_expect(2,3);
341 utrzExpect_WithUnexpectedArg_check(
"NTRNACT",
"nta",
"2",
"3");
343 sm_ntrnact_expect(2,3);
347 utrzExpect_WithUnexpectedArg_check(
"NTRNACT",
"nts",
"3",
"2");
350 TEST(utrzExpect, sm_tsstate_Ok)
352 sm_tsState_expect(CST(&s21));
356 utrzExpect_Ok_check();
359 TEST(utrzExpect, sm_tsstate_OutOfSequence)
361 sm_tsState_expect(CST(&s21));
365 utrzExpect_OutOfSequence_check(
"TS_STATE",
"STATE" );
368 TEST(utrzExpect, sm_tsstate_WithUnexpectedArg)
370 sm_tsState_expect(CST(&s21));
374 utrzExpect_WithUnexpectedArg_check(
"TS_STATE",
"st", str(s21), str(s211) );
377 TEST(utrzExpect, sm_evtproc_Ok)
383 utrzExpect_Ok_check();
386 TEST(utrzExpect, sm_evtproc_OutOfSequence)
392 utrzExpect_OutOfSequence_check(
"EVT_PROC",
"STATE" );
395 TEST(utrzExpect, sm_evtnfound_Ok)
399 sm_evtNotFound_expect(A);
403 utrzExpect_Ok_check();
406 TEST(utrzExpect, sm_evtnfound_OutOfSequence)
408 sm_evtNotFound_expect(A);
412 utrzExpect_OutOfSequence_check(
"EVT_NFOUND",
"STATE" );
415 TEST(utrzExpect, sm_evtnfound_WithUnexpectedArg)
419 sm_evtNotFound_expect(A);
423 utrzExpect_WithUnexpectedArg_check(
"EVT_NFOUND",
"sig", str(A), str(B));
426 TEST(utrzExpect, sm_grdfalse_Ok)
428 sm_grdFalse_expect();
432 utrzExpect_Ok_check();
435 TEST(utrzExpect, sm_grdfalse_OutOfSequence)
437 sm_grdFalse_expect();
441 utrzExpect_OutOfSequence_check(
"GRD_FALSE",
"STATE" );
444 TEST(utrzExpect, sm_cndnfound_Ok)
446 sm_cndNotFound_expect();
450 utrzExpect_Ok_check();
453 TEST(utrzExpect, sm_cndnfound_OutOfSequence)
455 sm_cndNotFound_expect();
459 utrzExpect_OutOfSequence_check(
"CND_NFOUND",
"STATE" );
462 TEST(utrzExpect, sm_unkstate_Ok)
464 sm_unknState_expect();
468 utrzExpect_Ok_check();
471 TEST(utrzExpect, sm_unkstate_OutOfSequence)
473 sm_unknState_expect();
477 utrzExpect_OutOfSequence_check(
"UNKN_STATE",
"STATE" );
480 TEST(utrzExpect, sm_exhlevel_Ok)
482 sm_exHLevel_expect();
486 utrzExpect_Ok_check();
489 TEST(utrzExpect, sm_exhlevel_OutOfSequence)
491 sm_exHLevel_expect();
495 utrzExpect_OutOfSequence_check(
"EX_HLEVEL",
"STATE" );
498 TEST(utrzExpect, sm_extseg_Ok)
504 utrzExpect_Ok_check();
507 TEST(utrzExpect, sm_extseg_OutOfSequence)
513 utrzExpect_OutOfSequence_check(
"EX_TSEG",
"STATE" );
516 TEST(utrzExpect, sm_exeAct_Ok)
519 CST(&s21), foo_set2zero );
523 utrzExpect_Ok_check();
526 TEST(utrzExpect, sm_exeAct_OutOfSequence)
529 CST(&s21), foo_set2zero );
533 utrzExpect_OutOfSequence_check(
"EXE_ACT",
"ENSTATE" );
536 TEST(utrzExpect, sm_exeAct_WithUnexpectedArg)
539 CST(&s21), foo_set2zero );
543 utrzExpect_WithUnexpectedArg_check(
"EXE_ACT",
"st", str(s21), str(s211));
546 CST(&s21), foo_set2zero );
550 utrzExpect_WithUnexpectedArg_check(
"EXE_ACT",
"fn",
551 str(foo_set2zero), str(foo_set2one));
554 CST(&s21), foo_set2zero );
558 utrzExpect_WithUnexpectedArgNoName_check(
"EXE_ACT",
"Entry",
"Exit");
561 TEST(utrzExpect, sm_exeAct_WithAnyArgs)
563 sm_exeAct_expectAnyArgs();
567 utrzExpect_Ok_check();
#define RKH_TR_SM_EXE_ACT(actionType_, actObj_, state_, action_)
Executes a behavior (action) of state machine, it could be an entry, exit, effect, init, preprocessor or guard.
#define RKH_TR_SM_EVT_PROC(actObj_)
The arrived event was succesfully processed and HSM resides in an allowed state.
Executes a behavior (action) of state machine, it could be an entry, exit, effect, init, preprocessor or guard.
#define RKH_TR_SM_STATE(actObj_, state_)
Legal, stable and final state of transition.
#define RKH_TR_SM_EX_TSEG(actObj_)
The transition exceeded the allowed number of segments within a compound transtion.
#define RKH_TR_SM_NENEX(actObj_, nEnState_, nExState_)
Number of entry and exit states in transition.
#define RKH_TR_SM_TS_STATE(actObj_, state_)
Destination state or pseudostate of a transition segment.
#define RKH_TR_SM_INIT(actObj_, initState_)
Inits a previously created state machine calling its initializing action.
Interface of unit test with Trazer application.
#define RKH_TR_SM_UNKN_STATE(actObj_)
Unknown state.
#define RKH_TR_SM_CLRH(actObj_, history_)
Erase the history of a state. It can be a shallow or deep history.
#define RKH_TR_SM_EVT_NFOUND(actObj_, evt_)
The arrived event was't founded in the transition table.
#define RKH_TR_SM_CND_NFOUND(actObj_)
The branch function returned a value not founded in the branch table.
#define RKH_TR_SM_NTRNACT(actObj_, nta, nts)
Number of executed actions and segments of the transition.
RKH framwwork platform - independent interface.
Executes a behavior (action) of state machine, it could be an entry, exit, effect, init, preprocessor or guard.
Executes a behavior (action) of state machine, it could be an entry, exit, effect, init, preprocessor or guard.
#define RKH_STATIC_EVENT(ev_obj, ev_sig)
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establish...
#define RKH_TR_SM_EXSTATE(actObj_, state_)
Exited state.
#define RKH_TR_SM_EX_HLEVEL(actObj_)
The transition exceeded the allowed hierarchical level.
#define RKH_TR_SM_TRN(actObj_, sourceState_, targetState_)
Source and target state of the transition. The target could be either basic state, composite state or pseudostate.
#define RKH_TR_SM_ENSTATE(actObj_, state_)
Entered state.
#define RKH_TR_SM_GRD_FALSE(actObj_)
The transition was cancelled by guard function.