RKH
test_utrzexecact.c
Go to the documentation of this file.
1 
13 /* -------------------------- Development history -------------------------- */
14 /*
15  * 2015.11.11 LeFr v1.0.00 Initial version
16  */
17 
18 /* -------------------------------- Authors -------------------------------- */
19 /*
20  * LeFr Leandro Francucci lf@vortexmakes.com
21  */
22 
23 /* --------------------------------- Notes --------------------------------- */
24 /* ----------------------------- Include files ----------------------------- */
25 
26 #include "unity_fixture.h"
27 #include "unitrazer.h"
28 #include "rkh.h"
29 #include "aotest.h"
30 #include "aotest_act.h"
31 #include "test_common.h"
32 
33 /* ----------------------------- Local macros ------------------------------ */
34 /* ------------------------------- Constants ------------------------------- */
35 /* ---------------------------- Local data types --------------------------- */
36 /* ---------------------------- Global variables --------------------------- */
37 
38 TEST_GROUP(utrzexeact);
39 
40 /* ---------------------------- Local variables ---------------------------- */
41 /* ----------------------- Local function prototypes ----------------------- */
42 /* ---------------------------- Local functions ---------------------------- */
43 /* ---------------------------- Global functions --------------------------- */
44 
45 TEST_SETUP(utrzexeact)
46 {
47  /* -------- Setup ---------------
48  * Establish the preconditions to the test
49  */
50  common_test_setup();
51 }
52 
53 TEST_TEAR_DOWN(utrzexeact)
54 {
55  /* -------- Cleanup -------------
56  * Return the system under test to its initial state after the test
57  */
58  common_tear_down();
59 }
60 
68 TEST(utrzexeact, expectEventOk)
69 {
70  UtrzProcessOut *p;
71 
72  /* -------- Expectations --------
73  * Record the trace event expectations to be met
74  */
75  sm_exeAct_expect(RKH_SUBTE_SM_EXE_ACT_EN,
76  CST(&s21), foo_set2zero );
77 
78  /* -------- Exercise ------------
79  * Do something to the system
80  */
81 
82  /* Each recorded trace event is checked to see that it matches */
83  /* the expected trace event exactly. If calls are out of order or */
84  /* parameters are wrong, the test immediately fails. */
85  RKH_TR_SM_EXE_ACT( RKH_SUBTE_SM_EXE_ACT_EN, aotest, &s21, foo_set2zero );
86 
87  /* -------- Verify --------------
88  * Check the expected outcome
89  */
90  p = unitrazer_getLastOut();
91  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
92 }
93 
94 TEST(utrzexeact, expectEventOutOfSequence)
95 {
96  UtrzProcessOut *p;
97 
98  sm_trn_expect(CST(&s21), CST(&s211));
99 
100  RKH_TR_SM_ENSTATE(aotest, CST(&s21));
101 
102  p = unitrazer_getLastOut();
103  TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
104  TEST_ASSERT_EQUAL_STRING("Out of order Trace event. occurred: 'ENSTATE' "
105  "expected: 'TRN'.", p->msg);
106 }
107 
108 TEST(utrzexeact, expectEventWithUnexpectedArg)
109 {
110  UtrzProcessOut *p;
111 
112  sm_trn_expect(CST(&s21), CST(&s211));
113 
114  RKH_TR_SM_TRN(aotest, &s21, &s21);
115 
116  p = unitrazer_getLastOut();
117  TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
118  TEST_ASSERT_EQUAL_STRING("Event 'TRN' occurred with unexpected "
119  "value for argument 'tst=s21' expected "
120  "value='s211'.", p->msg);
121 }
122 
123 TEST(utrzexeact, ignoreEvt)
124 {
125  UtrzProcessOut *p;
126 
127  sm_trn_ignore();
128  sm_evtProc_expect();
129 
130  RKH_TR_SM_TRN(aotest, &s21, &s21);
131 
132  p = unitrazer_getLastOut();
133  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
134 
135  RKH_TR_SM_EVT_PROC(aotest)
136 
137  p = unitrazer_getLastOut();
138  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
139 }
140 
141 TEST(utrzexeact, ignoreOneArg)
142 {
143  UtrzProcessOut *p;
144 
145  sm_trn_expect(CST(&s21), CST(&s211));
146  sm_trn_ignoreArg_sourceState();
147 
148  RKH_TR_SM_TRN(aotest, &s211, &s211);
149 
150  p = unitrazer_getLastOut();
151  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
152 }
153 
154 TEST(utrzexeact, ignoreOneArgBeforeExpect)
155 {
156  UtrzProcessOut *p;
157 
158  sm_trn_expect(CST(&s21), CST(&s211));
159  sm_evtProc_expect();
160  sm_trn_ignoreArg_sourceState();
161 
162  p = unitrazer_getLastOut();
163  TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
164  TEST_ASSERT_EQUAL_STRING("IgnoreArg called before Expect on event 'TRN'."
165  , p->msg);
166  RKH_TR_SM_TRN(aotest, &s21, &s211);
167  RKH_TR_SM_EVT_PROC(aotest);
168 }
169 
174 /* ------------------------------ End of file ------------------------------ */
#define RKH_TR_SM_EVT_PROC(actObj_)
The arrived event was succesfully processed and HSM resides in an allowed state.
#define RKH_TR_SM_ENSTATE(actObj_, state_)
Entered state.
#define RKH_TR_SM_EXE_ACT(actionType_, actObj_, state_, action_)
Executes a behavior (action) of state machine, it could be an entry, exit, effect,...
#define RKH_TR_SM_TRN(actObj_, sourceState_, targetState_)
Source and target state of the transition. The target could be either basic state,...
RKH framwwork platform - independent interface.
@ RKH_SUBTE_SM_EXE_ACT_EN
Executes a behavior (action) of state machine, it could be an entry, exit, effect,...
Interface of unit test with Trazer application.