RKH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_utrzignore.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 francuccilea@gmail.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 "test_common.h"
31 
32 /* ----------------------------- Local macros ------------------------------ */
33 #define utrzOkCheck() \
34  { \
35  UtrzProcessOut *p; \
36  p = unitrazer_getLastOut(); \
37  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status); \
38  }
39 
40 #define utrzFailCheck() \
41  { \
42  UtrzProcessOut *p; \
43  p = unitrazer_getLastOut(); \
44  TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status); \
45  }
46 /* ------------------------------- Constants ------------------------------- */
47 /* ---------------------------- Local data types --------------------------- */
48 /* ---------------------------- Global variables --------------------------- */
49 
50 TEST_GROUP(utrzIgnore);
51 
52 /* ---------------------------- Local variables ---------------------------- */
53 /* ----------------------- Local function prototypes ----------------------- */
54 /* ---------------------------- Local functions ---------------------------- */
55 /* ---------------------------- Global functions --------------------------- */
56 
57 TEST_SETUP(utrzIgnore)
58 {
59  /* -------- Setup ---------------
60  * Establish the preconditions to the test
61  */
62  common_test_setup();
63 }
64 
65 TEST_TEAR_DOWN(utrzIgnore)
66 {
67  /* -------- Cleanup -------------
68  * Return the system under test to its initial state after the test
69  */
70  common_tear_down();
71 }
72 
80 TEST(utrzIgnore, sm_trn_Ok)
81 {
82  sm_trn_ignore();
83  sm_evtProc_expect();
84 
85  RKH_TR_SM_TRN(aotest, &s21, &s21);
86 
87  utrzOkCheck();
88 
89  RKH_TR_SM_EVT_PROC(aotest)
90 
91  utrzOkCheck();
92 }
93 
94 TEST(utrzIgnore, sm_trn_OneArg)
95 {
96  sm_trn_expect(CST(&s21), CST(&s211));
97  sm_trn_ignoreArg_sourceState();
98 
99  RKH_TR_SM_TRN(aotest, &s211, &s211);
100 
101  utrzOkCheck();
102 }
103 
104 TEST(utrzIgnore, sm_trn_OneArgBeforeExpect)
105 {
106  UtrzProcessOut *p;
107 
108  sm_trn_expect(CST(&s21), CST(&s211));
109  sm_evtProc_expect();
110  sm_trn_ignoreArg_sourceState();
111 
112  p = unitrazer_getLastOut();
113  TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
114  TEST_ASSERT_EQUAL_STRING("IgnoreArg called before Expect on event 'TRN'."
115  , p->msg);
116  RKH_TR_SM_TRN(aotest, &s21, &s211);
117  RKH_TR_SM_EVT_PROC(aotest);
118 }
119 
120 TEST(utrzIgnore, sm_exeAct_Ok)
121 {
122  sm_trn_ignore();
123  sm_evtProc_expect();
124 
125  RKH_TR_SM_TRN(aotest, &s21, &s21);
126 
127  utrzOkCheck();
128 
129  RKH_TR_SM_EVT_PROC(aotest)
130 
131  utrzOkCheck();
132 }
133 
134 TEST(utrzIgnore, sm_exeAct_OneArg)
135 {
136  sm_trn_expect(CST(&s21), CST(&s211));
137  sm_trn_ignoreArg_sourceState();
138 
139  RKH_TR_SM_TRN(aotest, &s211, &s211);
140 
141  utrzOkCheck();
142 }
143 
144 TEST(utrzIgnore, sm_exeAct_OneArgBeforeExpect)
145 {
146  UtrzProcessOut *p;
147 
148  sm_trn_expect(CST(&s21), CST(&s211));
149  sm_evtProc_expect();
150  sm_trn_ignoreArg_sourceState();
151 
152  p = unitrazer_getLastOut();
153  TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
154  TEST_ASSERT_EQUAL_STRING("IgnoreArg called before Expect on event 'TRN'."
155  , p->msg);
156  RKH_TR_SM_TRN(aotest, &s21, &s211);
157  RKH_TR_SM_EVT_PROC(aotest);
158 }
159 
160 
161 TEST(utrzIgnore, ignoreAnEventOfIgnoredGroup)
162 {
163  fwk_ignore();
164  sm_evtProc_expect();
165 
166  RKH_TR_FWK_AO(aotest);
167  RKH_TR_SM_EVT_PROC(aotest);
168 
169  utrzOkCheck();
170 }
171 
172 
173 TEST(utrzIgnore, ignoreAnOutOfRangeGroup)
174 {
175  unitrazer_ignoreGroup(__LINE__, RKH_TG_NGROUP);
176 
177  utrzOkCheck();
178 }
179 
180 TEST(utrzIgnore, ignoreAnOutOfRangeEvent)
181 {
183 
184  utrzOkCheck();
185 }
186 
187 TEST(utrzIgnore, verifyFail)
188 {
189  sm_trn_expect(CST(&s21), CST(&s211));
190 
192  utrzFailCheck();
193 
195 }
196 
201 /* ------------------------------ End of file ------------------------------ */
Timer expired.
Definition: rkhtrc.h:3369
#define RKH_TR_SM_EVT_PROC(actObj_)
The arrived event was succesfully processed and HSM resides in an allowed state.
Definition: rkhtrc.h:1817
#define RKH_TR_FWK_AO(actObj_)
Entry symbol table for active object.
Definition: rkhtrc.h:2653
Interface of unit test with Trazer application.
void unitrazer_cleanup(void)
Return the system under test to its initial state after the test.
void unitrazer_ignore(UNITY_LINE_TYPE cmockLine, rui8_t trcEvt)
Ignore a specific trace event.
void unitrazer_verify(void)
Makes sure there are no unused expectations, if there are, this function causes the test to fail...
void unitrazer_ignoreGroup(UNITY_LINE_TYPE cmockLine, RKH_TRC_GROUPS group)
Force to ignore every produced trace event from a specifc trace group.
RKH framwwork platform - independent interface.
#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.
Definition: rkhtrc.h:1655