57 #include "unity_fixture.h"
61 #include "smPseudoTest.h"
62 #include "smPseudoTestAct.h"
79 TEST_GROUP(pseudostate);
86 loadStateMachineSymbols(
void)
111 setRKHTraceFilters(
void)
120 TEST_SETUP(pseudostate)
127 loadStateMachineSymbols();
128 setRKHTraceFilters();
131 TEST_TEAR_DOWN(pseudostate)
145 TEST(pseudostate, firstStateAfterInit)
149 sm_init_expect(RKH_STATE_CAST(&smPT_waiting));
150 sm_enstate_expect(RKH_STATE_CAST(&smPT_waiting));
154 p = unitrazer_getLastOut();
155 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
158 TEST(pseudostate, trnToEmptyShallowHistoryWithoutDefaultTrn)
163 RKH_STATE_CAST(&smPT_s1Hist), RKH_STATE_CAST(&smPT_s1),
168 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
172 RKH_STATE_CAST(&smPT_s1), RKH_STATE_CAST(&smPT_s11), RKH_STATE_CAST(0)
175 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
176 RKH_STATE_CAST(&smPT_s0), targetStates,
177 entryStates, exitStates,
178 RKH_STATE_CAST(&smPT_s11), 0, TRN_NOT_INTERNAL, 1, &evB,
179 RKH_STATE_CAST(&smPT_s0));
183 p = unitrazer_getLastOut();
184 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
187 TEST(pseudostate, trnToLoadedShallowHistoryWithoutDefaultTrn)
192 RKH_STATE_CAST(&smPT_s1Hist), RKH_STATE_CAST(&smPT_s12),
197 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
201 RKH_STATE_CAST(&smPT_s1), RKH_STATE_CAST(&smPT_s12),
202 RKH_STATE_CAST(&smPT_s121), RKH_STATE_CAST(0)
205 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
206 RKH_STATE_CAST(&smPT_s0), targetStates,
207 entryStates, exitStates,
208 RKH_STATE_CAST(&smPT_s121), 0, TRN_NOT_INTERNAL, 1, &evB,
209 RKH_STATE_CAST(&smPT_s0));
211 setHistory(&smPT_s1Hist, RKH_STATE_CAST(&smPT_s12));
214 p = unitrazer_getLastOut();
215 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
218 TEST(pseudostate, exitFromCompositeWithLoadedShallowHistory)
224 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
228 RKH_STATE_CAST(&smPT_s121), RKH_STATE_CAST(&smPT_s12),
229 RKH_STATE_CAST(&smPT_s1), RKH_STATE_CAST(0)
233 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
236 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s121),
237 RKH_STATE_CAST(&smPT_s1), targetStates,
238 entryStates, exitStates,
239 RKH_STATE_CAST(&smPT_s0), 0, TRN_NOT_INTERNAL, 1, &evA,
240 RKH_STATE_CAST(&smPT_s121));
243 state = getHistory(&smPT_s1Hist);
244 TEST_ASSERT_EQUAL_PTR(RKH_STATE_CAST(&smPT_s12), state);
246 p = unitrazer_getLastOut();
247 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
250 TEST(pseudostate, trnToEmptyDeepHistoryWithoutDefaultTrn)
255 RKH_STATE_CAST(&smPT_s12Hist), RKH_STATE_CAST(&smPT_s12),
260 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
264 RKH_STATE_CAST(&smPT_s1), RKH_STATE_CAST(&smPT_s12),
265 RKH_STATE_CAST(&smPT_s121), RKH_STATE_CAST(0)
268 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
269 RKH_STATE_CAST(&smPT_s0), targetStates,
270 entryStates, exitStates,
271 RKH_STATE_CAST(&smPT_s121), 0, TRN_NOT_INTERNAL, 1, &evC,
272 RKH_STATE_CAST(&smPT_s0));
276 p = unitrazer_getLastOut();
277 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
280 TEST(pseudostate, trnToLoadedDeepHistoryWithoutDefaultTrn)
285 RKH_STATE_CAST(&smPT_s12Hist), RKH_STATE_CAST(&smPT_s122),
290 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
294 RKH_STATE_CAST(&smPT_s1), RKH_STATE_CAST(&smPT_s12),
295 RKH_STATE_CAST(&smPT_s122), RKH_STATE_CAST(0)
298 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
299 RKH_STATE_CAST(&smPT_s0), targetStates,
300 entryStates, exitStates,
301 RKH_STATE_CAST(&smPT_s122), 0, TRN_NOT_INTERNAL, 1, &evC,
302 RKH_STATE_CAST(&smPT_s0));
304 setHistory(&smPT_s12Hist, RKH_STATE_CAST(&smPT_s122));
307 p = unitrazer_getLastOut();
308 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
311 TEST(pseudostate, exitFromCompositeWithLoadedDeepHistory)
317 RKH_STATE_CAST(&smPT_s122), RKH_STATE_CAST(0)
321 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
325 RKH_STATE_CAST(&smPT_s1), RKH_STATE_CAST(&smPT_s12),
326 RKH_STATE_CAST(&smPT_s122), RKH_STATE_CAST(0)
329 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
330 RKH_STATE_CAST(&smPT_s0), targetStates,
331 entryStates, exitStates,
332 RKH_STATE_CAST(&smPT_s122), 0, TRN_NOT_INTERNAL, 1, &evD,
333 RKH_STATE_CAST(&smPT_s0));
336 state = getHistory(&smPT_s12Hist);
337 TEST_ASSERT_EQUAL_PTR(RKH_STATE_CAST(&smPT_s122), state);
339 p = unitrazer_getLastOut();
340 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
343 TEST(pseudostate, trnToEmptyShallowHistoryWithDefaultTrn)
348 RKH_STATE_CAST(&smPT_s2Hist), RKH_STATE_CAST(&smPT_s22),
353 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
357 RKH_STATE_CAST(&smPT_s2), RKH_STATE_CAST(&smPT_s22), RKH_STATE_CAST(0)
360 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
361 RKH_STATE_CAST(&smPT_s0), targetStates,
362 entryStates, exitStates,
363 RKH_STATE_CAST(&smPT_s22), 1, TRN_NOT_INTERNAL, 1, &evE,
364 RKH_STATE_CAST(&smPT_s0));
368 p = unitrazer_getLastOut();
369 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
372 TEST(pseudostate, trnToLoadedShallowHistoryWithDefaultTrn)
377 RKH_STATE_CAST(&smPT_s2Hist), RKH_STATE_CAST(&smPT_s21),
382 RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(0)
386 RKH_STATE_CAST(&smPT_s2), RKH_STATE_CAST(&smPT_s21), RKH_STATE_CAST(0)
389 setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_s0),
390 RKH_STATE_CAST(&smPT_s0), targetStates,
391 entryStates, exitStates,
392 RKH_STATE_CAST(&smPT_s21), 0, TRN_NOT_INTERNAL, 1, &evE,
393 RKH_STATE_CAST(&smPT_s0));
395 setHistory(&smPT_s2Hist, RKH_STATE_CAST(&smPT_s21));
398 p = unitrazer_getLastOut();
399 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
void rkh_sm_clear_history(RKHROM RKH_SHIST_T *h)
Erase the history of a state. It can be a shallow or deep history.
#define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp)
Emit (enable) all events in a specific group.
#define sm_cleanup()
Return the system under test to its initial state after the test.
#define RKH_TR_FWK_AO(actObj_)
Entry symbol table for active object.
Interface of unit test with Trazer application.
#define RKH_TG_SM
State Machine group (SM)
Describes the state machine.
void rkh_sm_init(RKH_SM_T *me)
Inits a previously created state machine calling its initializing action.
#define sm_init()
Establish the preconditions to the tests.
#define RKH_TR_FWK_STATE(actObj_, stateObj_)
Entry symbol table for state object.
#define sm_verify()
Makes sure there are no unused expectations, if there are, this function causes the test to fail...
#define RKH_TE_FWK_ASSERT
Assertion expression was evaluated to false.
ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e)
Executes a state machine in a run-to-completation (RTC) model.
Describes the common properties of regular states (basic, composite, and submachine).
#define RKH_TR_FWK_SIG(stateObj_)
Entry symbol table for event signal.
#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_FILTER_OFF_EVENT(evt)
Emit (enable) one trace event. Use the RKH_TRC_ALL_EVENTS to enable all trace events.
#define RKH_FILTER_OFF_ALL_SIGNALS()
Emmit all enabled trace events related to signals.
#define RKH_FILTER_OFF_SMA(sma)
Emmit the enabled trace events related to a specified active object.
Specifies the interface of dynamic event support.