RKH
Loading...
Searching...
No Matches
test_utrzsm.c
Go to the documentation of this file.
1
14/* -------------------------- Development history -------------------------- */
15/*
16 * 2015.11.11 LeFr v1.0.00 Initial version
17 */
18
19/* -------------------------------- Authors -------------------------------- */
20/*
21 * LeFr Leandro Francucci lf@vortexmakes.com
22 */
23
24/* --------------------------------- Notes --------------------------------- */
25/* ----------------------------- Include files ----------------------------- */
26
27#include "unity_fixture.h"
28#include "unitrazer.h"
29#include "rkh.h"
30#include "aotest.h"
31#include "test_common.h"
32
33/* ----------------------------- Local macros ------------------------------ */
34/* ------------------------------- Constants ------------------------------- */
35/* ---------------------------- Local data types --------------------------- */
36/* ---------------------------- Global variables --------------------------- */
37
38TEST_GROUP(utrzsm);
39
40/* ---------------------------- Local variables ---------------------------- */
41
42static RKH_ROM_STATIC_EVENT( eA, A );
43static RKH_ROM_STATIC_EVENT( eB, B );
44static RKH_ROM_STATIC_EVENT( eC, C );
45static RKH_ROM_STATIC_EVENT( eD, D );
46static RKH_ROM_STATIC_EVENT( eE, E );
47static RKH_ROM_STATIC_EVENT( eF, F );
48static RKH_ROM_STATIC_EVENT( eG, G );
49static RKH_ROM_STATIC_EVENT( eH, H );
50static RKH_ROM_STATIC_EVENT( eI, I );
51static RKH_ROM_STATIC_EVENT( eTerm, TERMINATE );
52
53/* ----------------------- Local function prototypes ----------------------- */
54/* ---------------------------- Local functions ---------------------------- */
55/* ---------------------------- Global functions --------------------------- */
56
57TEST_SETUP(utrzsm)
58{
59 /* -------- Setup ---------------
60 * Establish the preconditions to the test
61 */
62 common_test_setup();
63}
64
65TEST_TEAR_DOWN(utrzsm)
66{
67 /* -------- Cleanup -------------
68 * Return the system under test to its initial state after the test
69 */
70 common_tear_down();
71}
72
80TEST(utrzsm, expectEventOk)
81{
82 UtrzProcessOut *p;
83
84 /* -------- Expectations --------
85 * Record the trace event expectations to be met
86 */
87 sm_trn_expect(CST(&s21), CST(&s211));
88
89 /* -------- Exercise ------------
90 * Do something to the system
91 */
92
93 /* Each recorded trace event is checked to see that it matches */
94 /* the expected trace event exactly. If calls are out of order or */
95 /* parameters are wrong, the test immediately fails. */
96 RKH_TR_SM_TRN(aotest, &s21, &s211);
97
98 /* -------- Verify --------------
99 * Check the expected outcome
100 */
101 p = unitrazer_getLastOut();
102 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
103}
104
105TEST(utrzsm, expectEventOutOfSequence)
106{
107 UtrzProcessOut *p;
108
109 sm_trn_expect(CST(&s21), CST(&s211));
110
111 RKH_TR_SM_ENSTATE(aotest, CST(&s21));
112
113 p = unitrazer_getLastOut();
114 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
115 TEST_ASSERT_EQUAL_STRING("Out of order Trace event. occurred: 'ENSTATE' "
116 "expected: 'TRN'.", p->msg);
117}
118
119TEST(utrzsm, expectEventWithUnexpectedArg)
120{
121 UtrzProcessOut *p;
122
123 sm_trn_expect(CST(&s21), CST(&s211));
124
125 RKH_TR_SM_TRN(aotest, &s21, &s21);
126
127 p = unitrazer_getLastOut();
128 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
129 TEST_ASSERT_EQUAL_STRING("Event 'TRN' occurred with unexpected "
130 "value for argument 'tst=s21' expected "
131 "value='s211'.", p->msg);
132}
133
134TEST(utrzsm, ignoreEvt)
135{
136 UtrzProcessOut *p;
137
138 sm_trn_ignore();
139 sm_evtProc_expect();
140
141 RKH_TR_SM_TRN(aotest, &s21, &s21);
142
143 p = unitrazer_getLastOut();
144 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
145
146 RKH_TR_SM_EVT_PROC(aotest)
147
148 p = unitrazer_getLastOut();
149 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
150}
151
152TEST(utrzsm, ignoreOneArg)
153{
154 UtrzProcessOut *p;
155
156 sm_trn_expect(CST(&s21), CST(&s211));
157 sm_trn_ignoreArg_sourceState();
158
159 RKH_TR_SM_TRN(aotest, &s211, &s211);
160
161 p = unitrazer_getLastOut();
162 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
163}
164
165TEST(utrzsm, ignoreOneArgBeforeExpect)
166{
167 UtrzProcessOut *p;
168
169 sm_trn_expect(CST(&s21), CST(&s211));
170 sm_evtProc_expect();
171 sm_trn_ignoreArg_sourceState();
172
173 p = unitrazer_getLastOut();
174 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
175 TEST_ASSERT_EQUAL_STRING("IgnoreArg called before Expect on event 'TRN'."
176 , p->msg);
177 RKH_TR_SM_TRN(aotest, &s21, &s211);
178 RKH_TR_SM_EVT_PROC(aotest);
179}
180
181TEST(utrzsm, eventMoreThanExpect)
182{
183 UtrzProcessOut *p;
184
185 sm_trn_expect(CST(&s21), CST(&s211));
186
187 RKH_TR_SM_TRN(aotest, &s21, &s211);
188
189 RKH_TR_SM_ENSTATE(aotest, CST(&s21));
190
191 p = unitrazer_getLastOut();
192 TEST_ASSERT_EQUAL(UT_PROC_FAIL, p->status);
193 TEST_ASSERT_EQUAL_STRING("Event 'ENSTATE' occurred more times than"
194 " expected.", p->msg);
195}
196
201/* ------------------------------ End of file ------------------------------ */
#define RKH_ROM_STATIC_EVENT(ev_obj, ev_sig)
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establish...
RKH framwwork platform - independent interface.
Interface of unit test with Trazer application.