RKH
test_rkhsm.c
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH site: http://vortexmakes.com/que-es/
28  * RKH GitHub: https://github.com/vortexmakes/RKH
29  * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30  * e-mail: lf@vortexmakes.com
31  * ---------------------------------------------------------------------------
32  */
33 
46 /* -------------------------- Development history -------------------------- */
47 /*
48  * 2016.12.15 LeFr v2.4.05 ---
49  */
50 
51 /* -------------------------------- Authors -------------------------------- */
52 /*
53  * LeFr Leandro Francucci lf@vortexmakes.com
54  */
55 
56 /* --------------------------------- Notes --------------------------------- */
57 /* ----------------------------- Include files ----------------------------- */
58 #include <unitrazer.h>
59 #include <tzlink.h>
60 #include <tzparse.h>
61 #include "rkhsm.h"
62 #include "common.h"
63 
64 #include "smTest.h"
65 #include "Mock_smTestAct.h"
66 
67 #include "smPseudoConditionalTest.h"
68 #include "Mock_smPseudoConditionalTestAct.h"
69 
70 #include "smPseudoTest.h"
71 #include "Mock_smPseudoTestAct.h"
72 
73 #include "smInitialPseudoTest.h"
74 #include "Mock_smInitialPseudoTestAct.h"
75 
76 #include "Mock_rkhassert.h"
77 #include "rkhport.h"
78 #include "rkhfwk_bittbl.h"
79 #include "rkhtrc.h"
80 #include "rkhtrc_filter.h"
81 #include "rkhtrc_record.h"
82 #include "rkhtrc_stream.h"
83 
84 /* ----------------------------- Local macros ------------------------------ */
85 /* ------------------------------- Constants ------------------------------- */
86 
87 static RKH_STATIC_EVENT(evA, A);
88 static RKH_STATIC_EVENT(evB, B);
89 static RKH_STATIC_EVENT(evC, C);
90 static RKH_STATIC_EVENT(evD, D);
91 static RKH_STATIC_EVENT(evE, E);
92 static RKH_STATIC_EVENT(evF, F);
93 static RKH_STATIC_EVENT(evG, G);
94 static RKH_STATIC_EVENT(evH, H);
95 static RKH_STATIC_EVENT(evI, I);
96 static RKH_STATIC_EVENT(evTerminate, TERMINATE);
97 extern const RKH_EVT_T evCompletion;
98 extern const RKH_EVT_T evCreation;
99 
100 /* ---------------------------- Local data types --------------------------- */
101 typedef struct StateMachine
102 {
103  RKH_SM_T sm;
104  int foo;
105 } StateMachine;
106 
107 typedef struct Composite
108 {
109  RKH_SMA_T ao;
110  int foo;
111  RKH_SM_T itsReactivePart;
112 } Composite;
113 
114 /* ---------------------------- Global variables --------------------------- */
115 /* ---------------------------- Local variables ---------------------------- */
116 static const RKH_ST_T *targetStates[16], *exitStates[16], *entryStates[16];
117 static RKH_ST_T *expectedState;
118 static RKH_RCODE_T result;
119 static int first = 1;
120 int GlobalExpectCount;
121 int GlobalVerifyOrder;
122 char *GlobalOrderError;
123 
124 /* ----------------------- Local function prototypes ----------------------- */
125 /* ---------------------------- Local functions ---------------------------- */
126 static
127 void
128 setUpUnitrazer(void)
129 {
130  if(first)
131  {
132  tzlink_open(0, NULL);
133  }
134 
135  first = 0;
136 
137  sm_init();
138  sm_ntrnact_ignore();
139 }
140 
141 static
142 void
143 setUpWoutUnitrazer(void)
144 {
145  sm_ignore();
146 }
147 
148 static
149 void
150 loadStateMachineSymbols(void)
151 {
152  RKH_TR_FWK_SIG(A);
153  RKH_TR_FWK_SIG(B);
154  RKH_TR_FWK_SIG(C);
155  RKH_TR_FWK_SIG(D);
156  RKH_TR_FWK_SIG(E);
157  RKH_TR_FWK_SIG(F);
158 
159  RKH_TR_FWK_AO(smTest);
160  RKH_TR_FWK_STATE(smTest, &waiting);
161  RKH_TR_FWK_STATE(smTest, &s0);
162  RKH_TR_FWK_STATE(smTest, &s1);
163  RKH_TR_FWK_STATE(smTest, &s2);
164  RKH_TR_FWK_STATE(smTest, &s21);
165  RKH_TR_FWK_STATE(smTest, &s22);
166  RKH_TR_FWK_STATE(smTest, &s221);
167  RKH_TR_FWK_STATE(smTest, &s2211);
168  RKH_TR_FWK_STATE(smTest, &s222);
169  RKH_TR_FWK_STATE(smTest, &s2221);
170  RKH_TR_FWK_STATE(smTest, &s22211);
171  RKH_TR_FWK_STATE(smTest, &s3);
172  RKH_TR_FWK_STATE(smTest, &s31);
173  RKH_TR_FWK_STATE(smTest, &s4);
174  RKH_TR_FWK_STATE(smTest, &s5);
175  RKH_TR_FWK_STATE(smTest, &s2Final);
176  RKH_TR_FWK_STATE(smTest, &SmTest_Final);
177 
178  RKH_TR_FWK_AO(smPseudoConditionalTest);
179  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_waiting);
180  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_choice1);
181  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_choice2);
182  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_choice3);
183  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_choice4);
184  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_choice5);
185  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_choice6);
186  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_s0);
187  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_s1);
188  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_s11);
189  RKH_TR_FWK_STATE(smPseudoConditionalTest, &smPCT_s12);
190 
191  RKH_TR_FWK_AO(smPseudoTest);
192  RKH_TR_FWK_STATE(smPseudoTest, &smPT_waiting);
193  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s0);
194  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s1);
195  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s11);
196  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s12);
197  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s1Hist);
198  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s121);
199  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s122);
200  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s12Hist);
201  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s2);
202  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s21);
203  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s22);
204  RKH_TR_FWK_STATE(smPseudoTest, &smPT_s2Hist);
205 
206  RKH_TR_FWK_AO(smInitialPseudoTest);
207  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s0);
208  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s1);
209  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s11);
210  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s12);
211  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s2);
212  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s21);
213  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s211);
214  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s3);
215  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s31);
216  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s32);
217  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s33);
218  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s331);
219  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s4);
220  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s41);
221  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s411);
222  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s5);
223  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s51);
224  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s511);
225  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s52);
226  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s6);
227  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s61);
228  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s62);
229  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s1Hist);
230  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s2Hist);
231  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s3Hist);
232  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s7);
233  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s71);
234  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s72);
235  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_choice1);
236  RKH_TR_FWK_STATE(smInitialPseudoTest, &smIPT_s5Final);
237 
238  RKH_TR_FWK_AO(smInitial6);
239  RKH_TR_FWK_STATE(smInitial6, &smI6_s0);
240  RKH_TR_FWK_STATE(smInitial6, &smI6_s1);
241 }
242 
243 static
244 void
245 setRKHTraceFilters(void)
246 {
249  RKH_FILTER_OFF_SMA(smTest);
250  RKH_FILTER_OFF_SMA(smPseudoConditionalTest);
251  RKH_FILTER_OFF_SMA(smPseudoTest);
252  RKH_FILTER_OFF_SMA(smInitialPseudoTest);
254 }
255 
256 /* ---------------------------- Global functions --------------------------- */
257 void
258 setUp(void)
259 {
260  setUpUnitrazer();
261 
262  Mock_smTestAct_Init();
263  Mock_smPseudoConditionalTestAct_Init();
264  Mock_smInitialPseudoTestAct_Init();
265 
266  loadStateMachineSymbols();
267  setRKHTraceFilters();
268 
269  rkh_sm_clear_history(&smPT_s1Hist);
270  rkh_sm_clear_history(&smPT_s12Hist);
271  rkh_sm_clear_history(&smPT_s2Hist);
272  rkh_sm_clear_history(&smIPT_s1Hist);
273 }
274 
275 void
276 tearDown(void)
277 {
278  sm_verify(); /* Makes sure there are no unused expectations, if */
279  /* there are, this function causes the test to fail. */
280  sm_cleanup();
281 
282  Mock_smTestAct_Verify();
283  Mock_smTestAct_Destroy();
284 
285  Mock_smPseudoConditionalTestAct_Verify();
286  Mock_smPseudoConditionalTestAct_Destroy();
287 
288  Mock_smInitialPseudoTestAct_Verify();
289  Mock_smInitialPseudoTestAct_Destroy();
290 }
291 
298 void
299 test_transitionFirstStateAfterInit(void)
300 {
301  UtrzProcessOut *p;
302 
303  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
304  sm_init_expect(RKH_STATE_CAST(&waiting));
305  sm_trn_expect(RKH_STATE_CAST(&waiting), RKH_STATE_CAST(&waiting));
306  sm_tsState_expect(RKH_STATE_CAST(&waiting));
307  sm_enstate_expect(RKH_STATE_CAST(&waiting));
308  sm_nenex_expect(1, 0);
309  sm_state_expect(RKH_STATE_CAST(&waiting));
310  sm_evtProc_expect();
311 
312  rkh_sm_init((RKH_SM_T *)smTest);
313 
314  p = unitrazer_getLastOut();
315  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
316 }
317 
318 void
319 test_transitionSimpleToSimpleAtEqualLevel(void)
320 {
321  UtrzProcessOut *p;
322 
323  stateList_create(targetStates, 1, &s1);
324  stateList_create(entryStates, 1, &s1);
325  stateList_create(exitStates, 1, &s0);
326 
327  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
328  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
329  smTest_tr11_Expect(RKH_CAST(SmTest, smTest), &evA);
330  smTest_nS1_Expect(RKH_CAST(SmTest, smTest));
331 
332  setProfile(smTest, RKH_STATE_CAST(&waiting),
333  RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
334  targetStates,
335  entryStates, exitStates, RKH_STATE_CAST(&s1), 1,
336  TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evA,
337  RKH_STATE_CAST(&s0));
338 
339  rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
340 
341  p = unitrazer_getLastOut();
342  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
343 }
344 
345 void
346 test_transitionSimpleToSimpleFromHighToLowLevel(void)
347 {
348  UtrzProcessOut *p;
349 
350  stateList_create(targetStates, 1, &s21);
351  stateList_create(entryStates, 2, &s2, &s21);
352  stateList_create(exitStates, 1, &s0);
353 
354  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
355  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
356  smTest_tr12_Expect(RKH_CAST(SmTest, smTest), &evB);
357  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
358  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
359 
360  setProfile(smTest, RKH_STATE_CAST(&waiting),
361  RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
362  targetStates,
363  entryStates, exitStates, RKH_STATE_CAST(&s21), 1,
364  TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evB,
365  RKH_STATE_CAST(&s0));
366 
367  rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
368 
369  p = unitrazer_getLastOut();
370  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
371 }
372 
373 void
374 test_transitionSimpleToSimpleFromLowToHighLevel(void)
375 {
376  UtrzProcessOut *p;
377 
378  stateList_create(targetStates, 1, &s0);
379  stateList_create(entryStates, 1, &s0);
380  stateList_create(exitStates, 2, &s21, &s2);
381 
382  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
383  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
384  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
385  smTest_tr13_Expect(RKH_CAST(SmTest, smTest), &evB);
386  smTest_nS0_Expect(RKH_CAST(SmTest, smTest));
387 
388  setProfile(smTest, RKH_STATE_CAST(&waiting),
389  RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s21),
390  targetStates,
391  entryStates, exitStates, RKH_STATE_CAST(&s0), 1,
392  TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evB,
393  RKH_STATE_CAST(&s21));
394 
395  rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
396 
397  p = unitrazer_getLastOut();
398  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
399 }
400 
401 void
402 test_transitionSimpleToCompositeAtEqualLevel(void)
403 {
404  UtrzProcessOut *p;
405  int nExSt, nEnSt;
406  RKH_EVT_T event;
407 
408  nEnSt = 2;
409  nExSt = 1;
410  event = evC;
411 
412  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
413  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
414  smTest_tr21_Expect(RKH_CAST(SmTest, smTest), &event);
415  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
416  smTest_iS2_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
417  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
418 
419  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
420  sm_dch_expect(event.e, RKH_STATE_CAST(&s0));
421  sm_trn_expect(RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s2));
422  sm_tsState_expect(RKH_STATE_CAST(&s2));
423  sm_exstate_expect(RKH_STATE_CAST(&s0));
424  sm_enstate_expect(RKH_STATE_CAST(&s2));
425  sm_tsState_expect(RKH_STATE_CAST(&s21));
426  sm_enstate_expect(RKH_STATE_CAST(&s21));
427  sm_nenex_expect(nEnSt, nExSt);
428  sm_state_expect(RKH_STATE_CAST(&s21));
429  sm_evtProc_expect();
430 
431  rkh_sm_init((RKH_SM_T *)smTest);
432  setState(smTest, RKH_STATE_CAST(&s0));
433  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
434 
435  p = unitrazer_getLastOut();
436  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
437 }
438 
439 void
440 test_transitionSimpleToCompositeFromHighToLowLevel(void)
441 {
442  UtrzProcessOut *p;
443  int nExSt, nEnSt;
444  RKH_EVT_T event;
445 
446  nEnSt = 4;
447  nExSt = 1;
448  event = evD;
449 
450  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
451  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
452  smTest_tr22_Expect(RKH_CAST(SmTest, smTest), &event);
453  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
454  smTest_nS22_Expect(RKH_CAST(SmTest, smTest));
455  smTest_iS22_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
456  smTest_nS221_Expect(RKH_CAST(SmTest, smTest));
457  smTest_iS221_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
458  smTest_nS2211_Expect(RKH_CAST(SmTest, smTest));
459 
460  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
461  sm_dch_expect(event.e, RKH_STATE_CAST(&s0));
462  sm_trn_expect(RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s22));
463  sm_tsState_expect(RKH_STATE_CAST(&s22));
464  sm_exstate_expect(RKH_STATE_CAST(&s0));
465  sm_enstate_expect(RKH_STATE_CAST(&s2));
466  sm_enstate_expect(RKH_STATE_CAST(&s22));
467  sm_tsState_expect(RKH_STATE_CAST(&s221));
468  sm_enstate_expect(RKH_STATE_CAST(&s221));
469  sm_tsState_expect(RKH_STATE_CAST(&s2211));
470  sm_enstate_expect(RKH_STATE_CAST(&s2211));
471  sm_nenex_expect(nEnSt, nExSt);
472  sm_state_expect(RKH_STATE_CAST(&s2211));
473  sm_evtProc_expect();
474 
475  rkh_sm_init((RKH_SM_T *)smTest);
476  setState(smTest, RKH_STATE_CAST(&s0));
477  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
478 
479  p = unitrazer_getLastOut();
480  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
481 }
482 
483 void
484 test_transitionSimpleToCompositeFromLowToHighLevel(void)
485 {
486  UtrzProcessOut *p;
487  int nExSt, nEnSt;
488  RKH_EVT_T event;
489 
490  nEnSt = 1;
491  nExSt = 1;
492  event = evC;
493 
494  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
495  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
496  smTest_tr23_Expect(RKH_CAST(SmTest, smTest), &event);
497  smTest_iS2_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
498  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
499 
500  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
501  sm_dch_expect(event.e, RKH_STATE_CAST(&s21));
502  sm_trn_expect(RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2));
503  sm_tsState_expect(RKH_STATE_CAST(&s2));
504  sm_exstate_expect(RKH_STATE_CAST(&s21));
505  sm_tsState_expect(RKH_STATE_CAST(&s21));
506  sm_enstate_expect(RKH_STATE_CAST(&s21));
507  sm_nenex_expect(nEnSt, nExSt);
508  sm_state_expect(RKH_STATE_CAST(&s21));
509  sm_evtProc_expect();
510 
511  rkh_sm_init((RKH_SM_T *)smTest);
512  setState(smTest, RKH_STATE_CAST(&s21));
513  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
514 
515  p = unitrazer_getLastOut();
516  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
517 }
518 
519 void
520 test_transitionCompositeToSimpleAtEqualLevel(void)
521 {
522  UtrzProcessOut *p;
523 
524  stateList_create(targetStates, 1, &s0);
525  stateList_create(entryStates, 1, &s0);
526  stateList_create(exitStates, 2, &s21, &s2);
527 
528  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
529  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
530  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
531  smTest_tr31_Expect(RKH_CAST(SmTest, smTest), &evA);
532  smTest_nS0_Expect(RKH_CAST(SmTest, smTest));
533 
534  setProfile(smTest, RKH_STATE_CAST(&waiting),
535  RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2),
536  targetStates,
537  entryStates, exitStates, RKH_STATE_CAST(&s0), 1,
538  TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evA,
539  RKH_STATE_CAST(&s21));
540 
541  rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
542 
543  p = unitrazer_getLastOut();
544  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
545 }
546 
547 void
548 test_transitionCompositeToSimpleFromHighToLowLevel(void)
549 {
550  UtrzProcessOut *p;
551 
552  stateList_create(targetStates, 1, &s21);
553  stateList_create(entryStates, 1, &s21);
554  stateList_create(exitStates, 1, &s21);
555 
556  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
557  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
558  smTest_tr32_Expect(RKH_CAST(SmTest, smTest), &evD);
559  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
560 
561  setProfile(smTest, RKH_STATE_CAST(&waiting),
562  RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2),
563  targetStates,
564  entryStates, exitStates, RKH_STATE_CAST(&s21), 1,
565  TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evD,
566  RKH_STATE_CAST(&s21));
567 
568  rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
569 
570  p = unitrazer_getLastOut();
571  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
572 }
573 
574 void
575 test_transitionLoopSimpleStateOnTop(void)
576 {
577  UtrzProcessOut *p;
578 
579  stateList_create(targetStates, 1, &s1);
580  stateList_create(entryStates, 1, &s1);
581  stateList_create(exitStates, 1, &s1);
582 
583  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
584  smTest_xS1_Expect(RKH_CAST(SmTest, smTest));
585  smTest_tr53_Expect(RKH_CAST(SmTest, smTest), &evA);
586  smTest_nS1_Expect(RKH_CAST(SmTest, smTest));
587 
588  setProfile(smTest, RKH_STATE_CAST(&waiting),
589  RKH_STATE_CAST(&s1), RKH_STATE_CAST(&s1),
590  targetStates,
591  entryStates, exitStates, RKH_STATE_CAST(&s1), 1,
592  TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evA,
593  RKH_STATE_CAST(&s1));
594 
595  rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
596 
597  p = unitrazer_getLastOut();
598  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
599 }
600 
601 void
602 test_transitionLoopNestedSimpleState(void)
603 {
604  UtrzProcessOut *p;
605 
606  stateList_create(targetStates, 1, &s31);
607  stateList_create(entryStates, 1, &s31);
608  stateList_create(exitStates, 1, &s31);
609 
610  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
611  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
612  smTest_tr52_Expect(RKH_CAST(SmTest, smTest), &evD);
613  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
614 
615  setProfile(smTest, RKH_STATE_CAST(&waiting),
616  RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s31),
617  targetStates, entryStates, exitStates,
618  RKH_STATE_CAST(&s31), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
619  &evD, RKH_STATE_CAST(&s31));
620 
621  rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
622 
623  p = unitrazer_getLastOut();
624  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
625 }
626 
627 void
628 test_transitionLoopCompositeStateOnTop(void)
629 {
630  UtrzProcessOut *p;
631  int nExSt, nEnSt;
632  RKH_EVT_T event;
633 
634  nEnSt = 1;
635  nExSt = 1;
636  event = evA;
637 
638  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
639  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
640  smTest_tr51_Expect(RKH_CAST(SmTest, smTest), &event);
641  smTest_iS3_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
642  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
643 
644  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
645  sm_dch_expect(event.e, RKH_STATE_CAST(&s31));
646  sm_trn_expect(RKH_STATE_CAST(&s3), RKH_STATE_CAST(&s3));
647  sm_tsState_expect(RKH_STATE_CAST(&s3));
648  sm_exstate_expect(RKH_STATE_CAST(&s31));
649  sm_tsState_expect(RKH_STATE_CAST(&s31));
650  sm_enstate_expect(RKH_STATE_CAST(&s31));
651  sm_nenex_expect(nEnSt, nExSt);
652  sm_state_expect(RKH_STATE_CAST(&s31));
653  sm_evtProc_expect();
654 
655  rkh_sm_init((RKH_SM_T *)smTest);
656  setState(smTest, RKH_STATE_CAST(&s31));
657  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
658 
659  p = unitrazer_getLastOut();
660  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
661 }
662 
663 void
664 test_transitionLoopNestedCompositeState(void)
665 {
666  UtrzProcessOut *p;
667  int nExSt, nEnSt;
668  RKH_EVT_T event;
669 
670  nEnSt = 2;
671  nExSt = 2;
672  event = evD;
673 
674  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
675  smTest_xS2211_Expect(RKH_CAST(SmTest, smTest));
676  smTest_xS221_Expect(RKH_CAST(SmTest, smTest));
677  smTest_tr54_Expect(RKH_CAST(SmTest, smTest), &event);
678  smTest_iS22_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
679  smTest_nS221_Expect(RKH_CAST(SmTest, smTest));
680  smTest_iS221_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
681  smTest_nS2211_Expect(RKH_CAST(SmTest, smTest));
682 
683  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
684  sm_dch_expect(event.e, RKH_STATE_CAST(&s2211));
685  sm_trn_expect(RKH_STATE_CAST(&s22), RKH_STATE_CAST(&s22));
686  sm_tsState_expect(RKH_STATE_CAST(&s22));
687  sm_exstate_expect(RKH_STATE_CAST(&s2211));
688  sm_exstate_expect(RKH_STATE_CAST(&s221));
689  sm_tsState_expect(RKH_STATE_CAST(&s221));
690  sm_enstate_expect(RKH_STATE_CAST(&s221));
691  sm_tsState_expect(RKH_STATE_CAST(&s2211));
692  sm_enstate_expect(RKH_STATE_CAST(&s2211));
693  sm_nenex_expect(nEnSt, nExSt);
694  sm_state_expect(RKH_STATE_CAST(&s2211));
695  sm_evtProc_expect();
696 
697  rkh_sm_init((RKH_SM_T *)smTest);
698  setState(smTest, RKH_STATE_CAST(&s2211));
699  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
700 
701  p = unitrazer_getLastOut();
702  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
703 }
704 
705 void
706 test_transitionCompositeToSimpleFromLowToHighLevel(void)
707 {
708  UtrzProcessOut *p;
709 
710  stateList_create(targetStates, 1, &s0);
711  stateList_create(entryStates, 1, &s0);
712  stateList_create(exitStates, 3, &s221, &s22, &s2);
713 
714  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
715  smTest_xS221_Expect(RKH_CAST(SmTest, smTest));
716  smTest_xS22_Expect(RKH_CAST(SmTest, smTest));
717  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
718  smTest_tr33_Expect(RKH_CAST(SmTest, smTest), &evB);
719  smTest_nS0_Expect(RKH_CAST(SmTest, smTest));
720 
721  setProfile(smTest, RKH_STATE_CAST(&waiting),
722  RKH_STATE_CAST(&s221), RKH_STATE_CAST(&s22),
723  targetStates, entryStates, exitStates,
724  RKH_STATE_CAST(&s0), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
725  &evB, RKH_STATE_CAST(&s221));
726 
727  rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
728 
729  p = unitrazer_getLastOut();
730  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
731 }
732 
733 void
734 test_transitionCompositeToCompositeAtEqualLevel(void)
735 {
736  UtrzProcessOut *p;
737  int nExSt, nEnSt;
738  RKH_EVT_T event;
739 
740  nEnSt = 2;
741  nExSt = 2;
742  event = evB;
743 
744  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
745  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
746  smTest_xS3_Expect(RKH_CAST(SmTest, smTest));
747  smTest_tr41_Expect(RKH_CAST(SmTest, smTest), &event);
748  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
749  smTest_iS2_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
750  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
751 
752  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
753  sm_dch_expect(event.e, RKH_STATE_CAST(&s31));
754  sm_trn_expect(RKH_STATE_CAST(&s3), RKH_STATE_CAST(&s2));
755  sm_tsState_expect(RKH_STATE_CAST(&s2));
756  sm_exstate_expect(RKH_STATE_CAST(&s31));
757  sm_exstate_expect(RKH_STATE_CAST(&s3));
758  sm_enstate_expect(RKH_STATE_CAST(&s2));
759  sm_tsState_expect(RKH_STATE_CAST(&s21));
760  sm_enstate_expect(RKH_STATE_CAST(&s21));
761  sm_nenex_expect(nEnSt, nExSt);
762  sm_state_expect(RKH_STATE_CAST(&s21));
763  sm_evtProc_expect();
764 
765  rkh_sm_init((RKH_SM_T *)smTest);
766  setState(smTest, RKH_STATE_CAST(&s31));
767  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
768 
769  p = unitrazer_getLastOut();
770  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
771 }
772 
773 void
774 test_transitionCompositeToCompositeFromHighToLowLevel(void)
775 {
776  UtrzProcessOut *p;
777  int nExSt, nEnSt;
778  RKH_EVT_T event;
779 
780  nEnSt = 4;
781  nExSt = 2;
782  event = evC;
783 
784  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
785  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
786  smTest_xS3_Expect(RKH_CAST(SmTest, smTest));
787  smTest_tr42_Expect(RKH_CAST(SmTest, smTest), &event);
788  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
789  smTest_nS22_Expect(RKH_CAST(SmTest, smTest));
790  smTest_iS22_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
791  smTest_nS221_Expect(RKH_CAST(SmTest, smTest));
792  smTest_iS221_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
793  smTest_nS2211_Expect(RKH_CAST(SmTest, smTest));
794 
795  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
796  sm_dch_expect(event.e, RKH_STATE_CAST(&s31));
797  sm_trn_expect(RKH_STATE_CAST(&s3), RKH_STATE_CAST(&s22));
798  sm_tsState_expect(RKH_STATE_CAST(&s22));
799  sm_exstate_expect(RKH_STATE_CAST(&s31));
800  sm_exstate_expect(RKH_STATE_CAST(&s3));
801  sm_enstate_expect(RKH_STATE_CAST(&s2));
802  sm_enstate_expect(RKH_STATE_CAST(&s22));
803  sm_tsState_expect(RKH_STATE_CAST(&s221));
804  sm_enstate_expect(RKH_STATE_CAST(&s221));
805  sm_tsState_expect(RKH_STATE_CAST(&s2211));
806  sm_enstate_expect(RKH_STATE_CAST(&s2211));
807  sm_nenex_expect(nEnSt, nExSt);
808  sm_state_expect(RKH_STATE_CAST(&s2211));
809  sm_evtProc_expect();
810 
811  rkh_sm_init((RKH_SM_T *)smTest);
812  setState(smTest, RKH_STATE_CAST(&s31));
813  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
814 
815  p = unitrazer_getLastOut();
816  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
817 }
818 
819 void
820 test_transitionCompositeToCompositeFromLowToHighLevel(void)
821 {
822  UtrzProcessOut *p;
823  int nExSt, nEnSt;
824  RKH_EVT_T event;
825 
826  nEnSt = 2;
827  nExSt = 4;
828  event = evC;
829 
830  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
831  smTest_xS2211_Expect(RKH_CAST(SmTest, smTest));
832  smTest_xS221_Expect(RKH_CAST(SmTest, smTest));
833  smTest_xS22_Expect(RKH_CAST(SmTest, smTest));
834  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
835  smTest_tr43_Expect(RKH_CAST(SmTest, smTest), &event);
836  smTest_nS3_Expect(RKH_CAST(SmTest, smTest));
837  smTest_iS3_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
838  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
839 
840  expInitSm((RKH_SMA_T *)smTest, RKH_STATE_CAST(&waiting));
841  sm_dch_expect(event.e, RKH_STATE_CAST(&s2211));
842  sm_trn_expect(RKH_STATE_CAST(&s22), RKH_STATE_CAST(&s3));
843  sm_tsState_expect(RKH_STATE_CAST(&s3));
844  sm_exstate_expect(RKH_STATE_CAST(&s2211));
845  sm_exstate_expect(RKH_STATE_CAST(&s221));
846  sm_exstate_expect(RKH_STATE_CAST(&s22));
847  sm_exstate_expect(RKH_STATE_CAST(&s2));
848  sm_enstate_expect(RKH_STATE_CAST(&s3));
849  sm_tsState_expect(RKH_STATE_CAST(&s31));
850  sm_enstate_expect(RKH_STATE_CAST(&s31));
851  sm_nenex_expect(nEnSt, nExSt);
852  sm_state_expect(RKH_STATE_CAST(&s31));
853  sm_evtProc_expect();
854 
855  rkh_sm_init((RKH_SM_T *)smTest);
856  setState(smTest, RKH_STATE_CAST(&s2211));
857  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
858 
859  p = unitrazer_getLastOut();
860  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
861 }
862 
863 void
864 test_transitionInternalInSimpleState(void)
865 {
866  UtrzProcessOut *p;
867 
868  stateList_create(targetStates, 1, &s1);
869  stateList_create(entryStates, 0);
870  stateList_create(exitStates, 0);
871 
872  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
873  smTest_tr14_Expect(RKH_CAST(SmTest, smTest), &evB);
874 
875  setProfile(smTest, RKH_STATE_CAST(&waiting),
876  RKH_STATE_CAST(&s1), RKH_STATE_CAST(&s1),
877  targetStates, entryStates, exitStates,
878  RKH_STATE_CAST(&s1), 1, TRN_INTERNAL, INIT_STATE_MACHINE,
879  &evB, RKH_STATE_CAST(&s1));
880 
881  rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
882 
883  p = unitrazer_getLastOut();
884  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
885 }
886 
887 void
888 test_transitionInternalInCompositeState(void)
889 {
890  UtrzProcessOut *p;
891 
892  stateList_create(targetStates, 1, &s3);
893  stateList_create(entryStates, 0);
894  stateList_create(exitStates, 0);
895 
896  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
897  smTest_tr15_Expect(RKH_CAST(SmTest, smTest), &evE);
898 
899  setProfile(smTest, RKH_STATE_CAST(&waiting),
900  RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3),
901  targetStates, entryStates, exitStates,
902  RKH_STATE_CAST(&s31), 1, TRN_INTERNAL, INIT_STATE_MACHINE,
903  &evE, RKH_STATE_CAST(&s31));
904 
905  rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
906 
907  p = unitrazer_getLastOut();
908  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
909 }
910 
911 void
912 test_transitionFails_EventNotFound(void)
913 {
914  UtrzProcessOut *p;
915 
916  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
917 
918  expInitSm(smTest, RKH_STATE_CAST(&waiting));
919  sm_dch_expect(evE.e, RKH_STATE_CAST(&s1));
920  sm_evtNotFound_expect(E);
921 
922  rkh_sm_init((RKH_SM_T *)smTest);
923  setState(smTest, RKH_STATE_CAST(&s1));
924  rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
925 
926  p = unitrazer_getLastOut();
927  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
928 }
929 
930 void
931 test_transitionFails_GuardFalse(void)
932 {
933  UtrzProcessOut *p;
934 
935  expInitSm(smTest, RKH_STATE_CAST(&waiting));
936  sm_grdFalse_expect();
937  sm_dch_expect(evC.e, RKH_STATE_CAST(&s1));
938  sm_evtNotFound_expect(C);
939 
940  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
941  smTest_falseGuard_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evC,
942  RKH_FALSE);
943 
944  rkh_sm_init((RKH_SM_T *)smTest);
945  setState(smTest, RKH_STATE_CAST(&s1));
946  rkh_sm_dispatch((RKH_SM_T *)smTest, &evC);
947 
948  p = unitrazer_getLastOut();
949  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
950 }
951 
952 void
953 test_transitionFails_ExceededHierarchicalLevel(void)
954 {
955  UtrzProcessOut *p;
956 
957  expInitSm(smTest, RKH_STATE_CAST(&waiting));
958  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
959  sm_dch_expect(evE.e, RKH_STATE_CAST(&s0));
960  sm_trn_expect(RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s22211));
961  sm_tsState_expect(RKH_STATE_CAST(&s22211));
962  sm_exHLevel_expect();
963  rkh_assert_Expect("rkhsm", 0);
964  rkh_assert_IgnoreArg_file();
965  rkh_assert_IgnoreArg_line();
966 
967  rkh_sm_init((RKH_SM_T *)smTest);
968  setState(smTest, RKH_STATE_CAST(&s0));
969  rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
970 
971  p = unitrazer_getLastOut();
972  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
973 }
974 
975 void
976 test_transitionMultipleEnabledTrn_FiringFirstTrueGuard(void)
977 {
978  UtrzProcessOut *p;
979 
980  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
981  smTest_guard4a_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evA, RKH_FALSE);
982  smTest_guard4b_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evA, RKH_TRUE);
983 
984  sm_init_ignore();
985  sm_tsState_ignore();
986  sm_nenex_ignore();
987  sm_state_ignore();
988  sm_enstate_ignore();
989  sm_ntrnact_ignore();
990  sm_dch_ignore();
991  sm_trn_ignore();
992  sm_evtProc_ignore();
993  sm_grdFalse_expect();
994 
995  rkh_sm_init((RKH_SM_T *)smTest);
996  setState(smTest, RKH_STATE_CAST(&s4));
997  rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
998 
999  p = unitrazer_getLastOut();
1000  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1001 }
1002 
1003 void
1004 test_transitionMultipleEnabledTrn_FiringFirstEmptyGuard(void)
1005 {
1006  UtrzProcessOut *p;
1007 
1008  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1009  smTest_guard4a_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evB, RKH_FALSE);
1010  smTest_guard4b_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evB, RKH_FALSE);
1011 
1012  sm_init_ignore();
1013  sm_nenex_ignore();
1014  sm_state_ignore();
1015  sm_enstate_ignore();
1016  sm_exstate_ignore();
1017  sm_ntrnact_ignore();
1018  sm_evtProc_ignore();
1019  sm_trn_ignore();
1020  sm_nenex_ignore();
1021  sm_state_ignore();
1022  sm_dch_ignore();
1023  sm_tsState_expect(RKH_STATE_CAST(&waiting));
1024  sm_grdFalse_expect();
1025  sm_grdFalse_expect();
1026  sm_tsState_expect(RKH_STATE_CAST(&s4));
1027 
1028  rkh_sm_init((RKH_SM_T *)smTest);
1029  setState(smTest, RKH_STATE_CAST(&s4));
1030  rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1031 
1032  p = unitrazer_getLastOut();
1033  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1034 }
1035 
1036 void
1037 test_transitionDefaultTrnWithAssociatedEffect(void)
1038 {
1039  UtrzProcessOut *p;
1040  int nExSt, nEnSt;
1041  RKH_EVT_T event;
1042 
1043  nEnSt = 2;
1044  nExSt = 1;
1045  event = evF;
1046 
1047  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1048  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
1049  smTest_tr55_Expect(RKH_CAST(SmTest, smTest), &event);
1050  smTest_nS3_Expect(RKH_CAST(SmTest, smTest));
1051  smTest_iS3_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&event);
1052  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
1053 
1054  expInitSm(smTest, RKH_STATE_CAST(&waiting));
1055  sm_dch_expect(event.e, RKH_STATE_CAST(&s0));
1056  sm_trn_expect(RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s3));
1057  sm_tsState_expect(RKH_STATE_CAST(&s3));
1058  sm_exstate_expect(RKH_STATE_CAST(&s0));
1059  sm_enstate_expect(RKH_STATE_CAST(&s3));
1060  sm_tsState_expect(RKH_STATE_CAST(&s31));
1061  sm_enstate_expect(RKH_STATE_CAST(&s31));
1062  sm_nenex_expect(nEnSt, nExSt);
1063  sm_state_expect(RKH_STATE_CAST(&s31));
1064  sm_evtProc_expect();
1065 
1066  rkh_sm_init((RKH_SM_T *)smTest);
1067  setState(smTest, RKH_STATE_CAST(&s0));
1068  rkh_sm_dispatch((RKH_SM_T *)smTest, &event);
1069 
1070  p = unitrazer_getLastOut();
1071  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1072 }
1073 
1074 void
1075 test_transitionGeneratedCompletionEventBySimpleState(void)
1076 {
1077  UtrzProcessOut *p;
1078 
1079  stateList_create(targetStates, 1, &s5);
1080  stateList_create(entryStates, 1, &s5);
1081  stateList_create(exitStates, 2, &s21, &s2);
1082 
1083  /* Expectations for transition to s5 */
1084  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1085  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1086  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1087  smTest_nS5_Expect(RKH_CAST(SmTest, smTest));
1088 
1089  setProfile(smTest, RKH_STATE_CAST(&waiting),
1090  RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2),
1091  targetStates, entryStates, exitStates,
1092  RKH_STATE_CAST(&s5), 0, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
1093  &evE, RKH_STATE_CAST(&s21));
1094 
1095  /* Expectations for completion transition */
1096  stateList_create(targetStates, 1, &s4);
1097  stateList_create(entryStates, 1, &s4);
1098  stateList_create(exitStates, 1, &s5);
1099 
1100  smTest_xS5_Expect(RKH_CAST(SmTest, smTest));
1101  smTest_tr61_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCompletion);
1102 
1103  setProfile(smTest, RKH_STATE_CAST(&waiting),
1104  NULL, RKH_STATE_CAST(&s5),
1105  targetStates, entryStates, exitStates,
1106  RKH_STATE_CAST(&s4), 1, TRN_NOT_INTERNAL,
1107  NO_INIT_STATE_MACHINE, &evCompletion, RKH_STATE_CAST(&s5));
1108 
1109  /* Exercices */
1110  rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
1111 
1112  p = unitrazer_getLastOut();
1113  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1114 }
1115 
1116 void
1117 test_transitionGeneratedCompletionEventByFinalState(void)
1118 {
1119  UtrzProcessOut *p;
1120 
1121  stateList_create(targetStates, 1, &s2Final);
1122  stateList_create(entryStates, 1, &s2Final);
1123  stateList_create(exitStates, 1, &s21);
1124 
1125  /* Expectations for transition to S2's FinalState */
1126  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1127  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1128 
1129  setProfile(smTest, RKH_STATE_CAST(&waiting),
1130  RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s21),
1131  targetStates, entryStates, exitStates,
1132  RKH_STATE_CAST(&s2Final), 0, TRN_NOT_INTERNAL,
1133  INIT_STATE_MACHINE, &evF, RKH_STATE_CAST(&s21));
1134 
1135  /* Expectations for completion transition */
1136  stateList_create(targetStates, 1, &s4);
1137  stateList_create(entryStates, 1, &s4);
1138  stateList_create(exitStates, 2, &s2Final, &s2);
1139 
1140  smTest_guardS2_ExpectAndReturn(RKH_CAST(SmTest, smTest),
1141  (RKH_EVT_T *)&evCompletion,
1142  RKH_TRUE);
1143  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1144  smTest_tr60_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCompletion);
1145 
1146  setProfile(smTest, RKH_STATE_CAST(&waiting),
1147  NULL, RKH_STATE_CAST(&s2),
1148  targetStates, entryStates, exitStates,
1149  RKH_STATE_CAST(&s4), 1, TRN_NOT_INTERNAL,
1150  NO_INIT_STATE_MACHINE, &evCompletion, RKH_STATE_CAST(&s2Final));
1151 
1152  /* Exercices */
1153  rkh_sm_dispatch((RKH_SM_T *)smTest, &evF);
1154 
1155  p = unitrazer_getLastOut();
1156  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1157 }
1158 
1159 void
1160 test_transitionSyncDispatchingToStateMachine(void)
1161 {
1162  TEST_IGNORE();
1163 }
1164 
1165 void
1166 test_transitionToStateMachineFinalState(void)
1167 {
1168  UtrzProcessOut *p;
1169 
1170  stateList_create(targetStates, 1, &SmTest_Final);
1171  stateList_create(entryStates, 1, &SmTest_Final);
1172  stateList_create(exitStates, 1, &waiting);
1173 
1174  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1175 
1176  setProfile(smTest, RKH_STATE_CAST(&waiting),
1177  RKH_STATE_CAST(&waiting), RKH_STATE_CAST(&waiting),
1178  targetStates, entryStates, exitStates,
1179  RKH_STATE_CAST(&SmTest_Final), 1, TRN_NOT_INTERNAL,
1180  INIT_STATE_MACHINE,
1181  &evB, RKH_STATE_CAST(&waiting));
1182 
1183  rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1184 
1185  p = unitrazer_getLastOut();
1186  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1187 }
1188 
1199 void
1200 test_trnWoutUnitrazerFirstStateAfterInit(void)
1201 {
1202  setUpWoutUnitrazer();
1203 
1204  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1205  expectedState = RKH_STATE_CAST(&waiting);
1206 
1207  rkh_sm_init((RKH_SM_T *)smTest);
1208 
1209  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1210 }
1211 
1212 void
1213 test_trnWoutUnitrazerSimpleToSimpleAtEqualLevel(void)
1214 {
1215  setUpWoutUnitrazer();
1216 
1217  expectedState = RKH_STATE_CAST(&s1);
1218 
1219  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1220  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
1221  smTest_tr11_Expect(RKH_CAST(SmTest, smTest), &evA);
1222  smTest_nS1_Expect(RKH_CAST(SmTest, smTest));
1223  setProfileWoutUnitrazer(smTest,
1224  RKH_STATE_CAST(&s0),
1225  RKH_STATE_CAST(&s0),
1226  expectedState,
1227  INIT_STATE_MACHINE);
1228 
1229  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
1230 
1231  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1232  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1233 }
1234 
1235 void
1236 test_trnWoutUnitrazerSimpleToSimpleFromHighToLowLevel(void)
1237 {
1238  setUpWoutUnitrazer();
1239 
1240  expectedState = RKH_STATE_CAST(&s21);
1241 
1242  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1243  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
1244  smTest_tr12_Expect(RKH_CAST(SmTest, smTest), &evB);
1245  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
1246  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
1247  setProfileWoutUnitrazer(smTest,
1248  RKH_STATE_CAST(&s0),
1249  RKH_STATE_CAST(&s0),
1250  expectedState,
1251  INIT_STATE_MACHINE);
1252 
1253  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1254 
1255  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1256  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1257 }
1258 
1259 void
1260 test_trnWoutUnitrazerSimpleToSimpleFromLowToHighLevel(void)
1261 {
1262  setUpWoutUnitrazer();
1263 
1264  expectedState = RKH_STATE_CAST(&s0);
1265 
1266  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1267  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1268  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1269  smTest_tr13_Expect(RKH_CAST(SmTest, smTest), &evB);
1270  smTest_nS0_Expect(RKH_CAST(SmTest, smTest));
1271  setProfileWoutUnitrazer(smTest,
1272  RKH_STATE_CAST(&s21),
1273  RKH_STATE_CAST(&s21),
1274  expectedState,
1275  INIT_STATE_MACHINE);
1276 
1277  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1278 
1279  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1280  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1281 }
1282 
1283 void
1284 test_trnWoutUnitrazerSimpleToCompositeAtEqualLevel(void)
1285 {
1286  setUpWoutUnitrazer();
1287 
1288  expectedState = RKH_STATE_CAST(&s21);
1289 
1290  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1291  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
1292  smTest_tr21_Expect(RKH_CAST(SmTest, smTest), &evC);
1293  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
1294  smTest_iS2_Expect(RKH_CAST(SmTest, smTest), &evC);
1295  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
1296  setProfileWoutUnitrazer(smTest,
1297  RKH_STATE_CAST(&s0),
1298  RKH_STATE_CAST(&s0),
1299  expectedState,
1300  INIT_STATE_MACHINE);
1301 
1302  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evC);
1303 
1304  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1305  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1306 }
1307 
1308 void
1309 test_trnWoutUnitrazerSimpleToCompositeFromHighToLowLevel(void)
1310 {
1311  setUpWoutUnitrazer();
1312 
1313  expectedState = RKH_STATE_CAST(&s2211);
1314 
1315  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1316  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
1317  smTest_tr22_Expect(RKH_CAST(SmTest, smTest), &evD);
1318  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
1319  smTest_nS22_Expect(RKH_CAST(SmTest, smTest));
1320  smTest_iS22_Expect(RKH_CAST(SmTest, smTest), &evD);
1321  smTest_nS221_Expect(RKH_CAST(SmTest, smTest));
1322  smTest_iS221_Expect(RKH_CAST(SmTest, smTest), &evD);
1323  smTest_nS2211_Expect(RKH_CAST(SmTest, smTest));
1324  setProfileWoutUnitrazer(smTest,
1325  RKH_STATE_CAST(&s0),
1326  RKH_STATE_CAST(&s0),
1327  expectedState,
1328  INIT_STATE_MACHINE);
1329 
1330  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
1331 
1332  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1333  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1334 }
1335 
1336 void
1337 test_trnWoutUnitrazerSimpleToCompositeFromLowToHighLevel(void)
1338 {
1339  setUpWoutUnitrazer();
1340 
1341  expectedState = RKH_STATE_CAST(&s21);
1342 
1343  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1344  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1345  smTest_tr23_Expect(RKH_CAST(SmTest, smTest), &evC);
1346  smTest_iS2_Expect(RKH_CAST(SmTest, smTest), &evC);
1347  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
1348  setProfileWoutUnitrazer(smTest,
1349  RKH_STATE_CAST(&s21),
1350  RKH_STATE_CAST(&s21),
1351  expectedState,
1352  INIT_STATE_MACHINE);
1353 
1354  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evC);
1355 
1356  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1357  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1358 }
1359 
1360 void
1361 test_trnWoutUnitrazerCompositeToSimpleAtEqualLevel(void)
1362 {
1363  setUpWoutUnitrazer();
1364 
1365  expectedState = RKH_STATE_CAST(&s0);
1366 
1367  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1368  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1369  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1370  smTest_tr31_Expect(RKH_CAST(SmTest, smTest), &evA);
1371  smTest_nS0_Expect(RKH_CAST(SmTest, smTest));
1372  setProfileWoutUnitrazer(smTest,
1373  RKH_STATE_CAST(&s21),
1374  RKH_STATE_CAST(&s2),
1375  expectedState,
1376  INIT_STATE_MACHINE);
1377 
1378  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
1379 
1380  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1381  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1382 }
1383 
1384 void
1385 test_trnWoutUnitrazerCompositeToSimpleFromHighToLowLevel(void)
1386 {
1387  setUpWoutUnitrazer();
1388 
1389  expectedState = RKH_STATE_CAST(&s21);
1390 
1391  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1392  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1393  smTest_tr32_Expect(RKH_CAST(SmTest, smTest), &evD);
1394  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
1395  setProfileWoutUnitrazer(smTest,
1396  RKH_STATE_CAST(&s21),
1397  RKH_STATE_CAST(&s2),
1398  expectedState,
1399  INIT_STATE_MACHINE);
1400 
1401  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
1402 
1403  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1404  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1405 }
1406 
1407 void
1408 test_trnWoutUnitrazerLoopSimpleStateOnTop(void)
1409 {
1410  setUpWoutUnitrazer();
1411 
1412  expectedState = RKH_STATE_CAST(&s1);
1413 
1414  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1415  smTest_xS1_Expect(RKH_CAST(SmTest, smTest));
1416  smTest_tr53_Expect(RKH_CAST(SmTest, smTest), &evA);
1417  smTest_nS1_Expect(RKH_CAST(SmTest, smTest));
1418  setProfileWoutUnitrazer(smTest,
1419  RKH_STATE_CAST(&s1),
1420  RKH_STATE_CAST(&s1),
1421  expectedState,
1422  INIT_STATE_MACHINE);
1423 
1424  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
1425 
1426  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1427  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1428 }
1429 
1430 void
1431 test_trnWoutUnitrazerLoopNestedSimpleState(void)
1432 {
1433  setUpWoutUnitrazer();
1434 
1435  expectedState = RKH_STATE_CAST(&s31);
1436 
1437  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1438  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
1439  smTest_tr52_Expect(RKH_CAST(SmTest, smTest), &evD);
1440  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
1441  setProfileWoutUnitrazer(smTest,
1442  RKH_STATE_CAST(&s31),
1443  RKH_STATE_CAST(&s31),
1444  expectedState,
1445  INIT_STATE_MACHINE);
1446 
1447  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
1448 
1449  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1450  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1451 }
1452 
1453 void
1454 test_trnWoutUnitrazerLoopCompositeStateOnTop(void)
1455 {
1456  setUpWoutUnitrazer();
1457 
1458  expectedState = RKH_STATE_CAST(&s31);
1459 
1460  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1461  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
1462  smTest_tr51_Expect(RKH_CAST(SmTest, smTest), &evA);
1463  smTest_iS3_Expect(RKH_CAST(SmTest, smTest), &evA);
1464  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
1465  setProfileWoutUnitrazer(smTest,
1466  RKH_STATE_CAST(&s31),
1467  RKH_STATE_CAST(&s3),
1468  expectedState,
1469  INIT_STATE_MACHINE);
1470 
1471  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
1472 
1473  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1474  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1475 }
1476 
1477 void
1478 test_trnWoutUnitrazerLoopNestedCompositeState(void)
1479 {
1480  setUpWoutUnitrazer();
1481 
1482  expectedState = RKH_STATE_CAST(&s2211);
1483 
1484  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1485  smTest_xS2211_Expect(RKH_CAST(SmTest, smTest));
1486  smTest_xS221_Expect(RKH_CAST(SmTest, smTest));
1487  smTest_tr54_Expect(RKH_CAST(SmTest, smTest), &evD);
1488  smTest_iS22_Expect(RKH_CAST(SmTest, smTest), &evD);
1489  smTest_nS221_Expect(RKH_CAST(SmTest, smTest));
1490  smTest_iS221_Expect(RKH_CAST(SmTest, smTest), &evD);
1491  smTest_nS2211_Expect(RKH_CAST(SmTest, smTest));
1492  setProfileWoutUnitrazer(smTest,
1493  RKH_STATE_CAST(&s2211),
1494  RKH_STATE_CAST(&s22),
1495  expectedState,
1496  INIT_STATE_MACHINE);
1497 
1498  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
1499 
1500  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1501  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1502 }
1503 
1504 void
1505 test_trnWoutUnitrazerCompositeToSimpleFromLowToHighLevel(void)
1506 {
1507  setUpWoutUnitrazer();
1508 
1509  expectedState = RKH_STATE_CAST(&s0);
1510 
1511  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1512  smTest_xS2211_Expect(RKH_CAST(SmTest, smTest));
1513  smTest_xS221_Expect(RKH_CAST(SmTest, smTest));
1514  smTest_xS22_Expect(RKH_CAST(SmTest, smTest));
1515  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1516  smTest_tr33_Expect(RKH_CAST(SmTest, smTest), &evB);
1517  smTest_nS0_Expect(RKH_CAST(SmTest, smTest));
1518  setProfileWoutUnitrazer(smTest,
1519  RKH_STATE_CAST(&s2211),
1520  RKH_STATE_CAST(&s22),
1521  expectedState,
1522  INIT_STATE_MACHINE);
1523 
1524  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1525 
1526  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1527  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1528 }
1529 
1530 void
1531 test_trnWoutUnitrazerCompositeToCompositeAtEqualLevel(void)
1532 {
1533  setUpWoutUnitrazer();
1534 
1535  expectedState = RKH_STATE_CAST(&s21);
1536 
1537  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1538  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
1539  smTest_xS3_Expect(RKH_CAST(SmTest, smTest));
1540  smTest_tr41_Expect(RKH_CAST(SmTest, smTest), &evB);
1541  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
1542  smTest_iS2_Expect(RKH_CAST(SmTest, smTest), &evB);
1543  smTest_nS21_Expect(RKH_CAST(SmTest, smTest));
1544  setProfileWoutUnitrazer(smTest,
1545  RKH_STATE_CAST(&s31),
1546  RKH_STATE_CAST(&s3),
1547  expectedState,
1548  INIT_STATE_MACHINE);
1549 
1550  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1551 
1552  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1553  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1554 }
1555 
1556 void
1557 test_trnWoutUnitrazerCompositeToCompositeFromHighToLowLevel(void)
1558 {
1559  setUpWoutUnitrazer();
1560 
1561  expectedState = RKH_STATE_CAST(&s2211);
1562 
1563  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1564  smTest_xS31_Expect(RKH_CAST(SmTest, smTest));
1565  smTest_xS3_Expect(RKH_CAST(SmTest, smTest));
1566  smTest_tr42_Expect(RKH_CAST(SmTest, smTest), &evC);
1567  smTest_nS2_Expect(RKH_CAST(SmTest, smTest));
1568  smTest_nS22_Expect(RKH_CAST(SmTest, smTest));
1569  smTest_iS22_Expect(RKH_CAST(SmTest, smTest), &evC);
1570  smTest_nS221_Expect(RKH_CAST(SmTest, smTest));
1571  smTest_iS221_Expect(RKH_CAST(SmTest, smTest), &evC);
1572  smTest_nS2211_Expect(RKH_CAST(SmTest, smTest));
1573  setProfileWoutUnitrazer(smTest,
1574  RKH_STATE_CAST(&s31),
1575  RKH_STATE_CAST(&s3),
1576  expectedState,
1577  INIT_STATE_MACHINE);
1578 
1579  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evC);
1580 
1581  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1582  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1583 }
1584 
1585 void
1586 test_trnWoutUnitrazerCompositeToCompositeFromLowToHighLevel(void)
1587 {
1588  setUpWoutUnitrazer();
1589 
1590  expectedState = RKH_STATE_CAST(&s31);
1591 
1592  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1593  smTest_xS2211_Expect(RKH_CAST(SmTest, smTest));
1594  smTest_xS221_Expect(RKH_CAST(SmTest, smTest));
1595  smTest_xS22_Expect(RKH_CAST(SmTest, smTest));
1596  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1597  smTest_tr43_Expect(RKH_CAST(SmTest, smTest), &evC);
1598  smTest_nS3_Expect(RKH_CAST(SmTest, smTest));
1599  smTest_iS3_Expect(RKH_CAST(SmTest, smTest), &evC);
1600  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
1601  setProfileWoutUnitrazer(smTest,
1602  RKH_STATE_CAST(&s2211),
1603  RKH_STATE_CAST(&s3),
1604  expectedState,
1605  INIT_STATE_MACHINE);
1606 
1607  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evC);
1608 
1609  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1610  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1611 }
1612 
1613 void
1614 test_trnWoutUnitrazerInternalInSimpleState(void)
1615 {
1616  setUpWoutUnitrazer();
1617 
1618  expectedState = RKH_STATE_CAST(&s1);
1619 
1620  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1621  smTest_tr14_Expect(RKH_CAST(SmTest, smTest), &evB);
1622  setProfileWoutUnitrazer(smTest,
1623  RKH_STATE_CAST(&s1),
1624  RKH_STATE_CAST(&s1),
1625  expectedState,
1626  INIT_STATE_MACHINE);
1627 
1628  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1629 
1630  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1631  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1632 }
1633 
1634 void
1635 test_trnWoutUnitrazerInternalInCompositeState(void)
1636 {
1637  setUpWoutUnitrazer();
1638 
1639  expectedState = RKH_STATE_CAST(&s31);
1640 
1641  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1642  smTest_tr15_Expect(RKH_CAST(SmTest, smTest), &evE);
1643  setProfileWoutUnitrazer(smTest,
1644  RKH_STATE_CAST(&s31),
1645  RKH_STATE_CAST(&s3),
1646  expectedState,
1647  INIT_STATE_MACHINE);
1648 
1649  rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
1650 
1651  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1652 }
1653 
1654 void
1655 test_trnWoutUnitrazerFails_EventNotFound(void)
1656 {
1657  setUpWoutUnitrazer();
1658 
1659  expectedState = RKH_STATE_CAST(&s1);
1660 
1661  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1662  setProfileWoutUnitrazer(smTest,
1663  RKH_STATE_CAST(&s1),
1664  RKH_STATE_CAST(&s1),
1665  expectedState,
1666  INIT_STATE_MACHINE);
1667 
1668  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
1669 
1670  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1671  TEST_ASSERT_EQUAL(RKH_EVT_NFOUND, result);
1672 }
1673 
1674 void
1675 test_trnWoutUnitrazerFails_GuardFalseOnInternalTrn(void)
1676 {
1677  setUpWoutUnitrazer();
1678 
1679  expectedState = RKH_STATE_CAST(&s1);
1680 
1681  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1682  smTest_falseGuard_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evC,
1683  RKH_FALSE);
1684  setProfileWoutUnitrazer(smTest,
1685  RKH_STATE_CAST(&s1),
1686  RKH_STATE_CAST(&s1),
1687  expectedState,
1688  INIT_STATE_MACHINE);
1689 
1690  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evC);
1691 
1692  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1693  TEST_ASSERT_EQUAL(RKH_EVT_NFOUND, result);
1694 }
1695 
1696 void
1697 test_trnWoutUnitrazerFails_GuardFalseOnExternalTrn(void)
1698 {
1699  setUpWoutUnitrazer();
1700 
1701  expectedState = RKH_STATE_CAST(&s1);
1702 
1703  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1704  smTest_falseGuard_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evD,
1705  RKH_FALSE);
1706  setProfileWoutUnitrazer(smTest,
1707  RKH_STATE_CAST(&s1),
1708  RKH_STATE_CAST(&s1),
1709  expectedState,
1710  INIT_STATE_MACHINE);
1711 
1712  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evD);
1713 
1714  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1715  TEST_ASSERT_EQUAL(RKH_EVT_NFOUND, result);
1716 }
1717 
1718 void
1719 test_trnWoutUnitrazerFails_ExceededHierarchicalLevel(void)
1720 {
1721  setUpWoutUnitrazer();
1722 
1723  expectedState = RKH_STATE_CAST(&s0);
1724 
1725  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1726  setProfileWoutUnitrazer(smTest,
1727  RKH_STATE_CAST(&s0),
1728  RKH_STATE_CAST(&s0),
1729  expectedState,
1730  INIT_STATE_MACHINE);
1731  rkh_assert_Expect("rkhsm", 0);
1732  rkh_assert_IgnoreArg_file();
1733  rkh_assert_IgnoreArg_line();
1734 
1735  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
1736 
1737  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1738  TEST_ASSERT_EQUAL(RKH_EX_HLEVEL, result);
1739 }
1740 
1741 void
1742 test_trnWoutUnitrazerMultipleEnabledTrn_FiringFirstTrueGuard(void)
1743 {
1744  setUpWoutUnitrazer();
1745 
1746  expectedState = RKH_STATE_CAST(&s4);
1747 
1748  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1749  smTest_guard4a_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evA, RKH_FALSE);
1750  smTest_guard4b_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evA, RKH_TRUE);
1751  setProfileWoutUnitrazer(smTest,
1752  RKH_STATE_CAST(&s4),
1753  RKH_STATE_CAST(&s4),
1754  expectedState,
1755  INIT_STATE_MACHINE);
1756 
1757  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evA);
1758 
1759  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1760  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1761 }
1762 
1763 void
1764 test_trnWoutUnitrazerMultipleEnabledTrn_FiringFirstEmptyGuard(void)
1765 {
1766  setUpWoutUnitrazer();
1767 
1768  expectedState = RKH_STATE_CAST(&s4);
1769 
1770  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1771  smTest_guard4a_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evB, RKH_FALSE);
1772  smTest_guard4b_ExpectAndReturn(RKH_CAST(SmTest, smTest), &evB, RKH_FALSE);
1773  setProfileWoutUnitrazer(smTest,
1774  RKH_STATE_CAST(&s4),
1775  RKH_STATE_CAST(&s4),
1776  expectedState,
1777  INIT_STATE_MACHINE);
1778 
1779  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evB);
1780 
1781  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1782  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1783 }
1784 
1785 void
1786 test_trnWoutUnitrazerDefaultTrnWithAssociatedEffect(void)
1787 {
1788  setUpWoutUnitrazer();
1789 
1790  expectedState = RKH_STATE_CAST(&s31);
1791 
1792  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1793  smTest_xS0_Expect(RKH_CAST(SmTest, smTest));
1794  smTest_tr55_Expect(RKH_CAST(SmTest, smTest), &evF);
1795  smTest_nS3_Expect(RKH_CAST(SmTest, smTest));
1796  smTest_iS3_Expect(RKH_CAST(SmTest, smTest), &evF);
1797  smTest_nS31_Expect(RKH_CAST(SmTest, smTest));
1798  setProfileWoutUnitrazer(smTest,
1799  RKH_STATE_CAST(&s0),
1800  RKH_STATE_CAST(&s0),
1801  expectedState,
1802  INIT_STATE_MACHINE);
1803 
1804  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evF);
1805 
1806  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1807  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1808 }
1809 
1810 void
1811 test_trnWoutUnitrazerGeneratedCompletionEventBySimpleState(void)
1812 {
1813  setUpWoutUnitrazer();
1814 
1815  expectedState = RKH_STATE_CAST(&s4);
1816 
1817  /* Expectations for transition to s5 */
1818  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1819  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1820  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1821  smTest_nS5_Expect(RKH_CAST(SmTest, smTest));
1822  /* Expectations for completion transition */
1823  smTest_xS5_Expect(RKH_CAST(SmTest, smTest));
1824  smTest_tr61_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCompletion);
1825  setProfileWoutUnitrazer(smTest,
1826  RKH_STATE_CAST(&s21),
1827  RKH_STATE_CAST(&s2),
1828  expectedState,
1829  INIT_STATE_MACHINE);
1830 
1831  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evE);
1832 
1833  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1834  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1835 }
1836 
1837 void
1838 test_trnWoutUnitrazerGeneratedCompletionEventByFinalState(void)
1839 {
1840  setUpWoutUnitrazer();
1841 
1842  expectedState = RKH_STATE_CAST(&s4);
1843 
1844  /* Expectations for transition to S2's FinalState */
1845  smTest_init_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCreation);
1846  smTest_xS21_Expect(RKH_CAST(SmTest, smTest));
1847  /* Expectations for completion transition */
1848  smTest_guardS2_ExpectAndReturn(RKH_CAST(SmTest, smTest),
1849  (RKH_EVT_T *)&evCompletion,
1850  RKH_TRUE);
1851  smTest_xS2_Expect(RKH_CAST(SmTest, smTest));
1852  smTest_tr60_Expect(RKH_CAST(SmTest, smTest), (RKH_EVT_T *)&evCompletion);
1853  setProfileWoutUnitrazer(smTest,
1854  RKH_STATE_CAST(&s21),
1855  RKH_STATE_CAST(&s21),
1856  expectedState,
1857  INIT_STATE_MACHINE);
1858 
1859  result = rkh_sm_dispatch((RKH_SM_T *)smTest, &evF);
1860 
1861  TEST_ASSERT_TRUE(expectedState == getState(smTest));
1862  TEST_ASSERT_EQUAL(RKH_EVT_PROC, result);
1863 }
1864 
1865 void
1866 test_trnWoutUnitrazerSyncDispatchingToStateMachine(void)
1867 {
1868  TEST_IGNORE();
1869 
1870  setUpWoutUnitrazer();
1871 }
1872 
1881 void
1882 test_pseudostateConditionalFirstStateAfterInit(void)
1883 {
1884  UtrzProcessOut *p;
1885 
1886  sm_init_expect(RKH_STATE_CAST(&smPCT_waiting));
1887  sm_trn_expect(RKH_STATE_CAST(&smPCT_waiting),
1888  RKH_STATE_CAST(&smPCT_waiting));
1889  sm_tsState_expect(RKH_STATE_CAST(&smPCT_waiting));
1890  sm_enstate_expect(RKH_STATE_CAST(&smPCT_waiting));
1891  sm_nenex_expect(1, 0);
1892  sm_state_expect(RKH_STATE_CAST(&smPCT_waiting));
1893  sm_evtProc_expect();
1894 
1895  rkh_sm_init((RKH_SM_T *)smPseudoConditionalTest);
1896 
1897  p = unitrazer_getLastOut();
1898  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1899 }
1900 
1901 void
1902 test_pseudostateConditionalTrnToChoiceWithTrueCondition(void)
1903 {
1904  UtrzProcessOut *p;
1905  SmPseudoConditionalTest *me = RKH_CAST(SmPseudoConditionalTest,
1906  smPseudoConditionalTest);
1907 
1908  /* Expect call actions */
1909  smPCT_setCondition_Expect(
1910  RKH_CAST(SmPseudoConditionalTest, me), &evA);
1911  smPCT_onEventA_ExpectAndReturn(
1912  RKH_CAST(SmPseudoConditionalTest, me),
1913  &evA, RKH_TRUE);
1914  smPCT_tr1_Expect(
1915  RKH_CAST(SmPseudoConditionalTest, me), &evA);
1916  /* Expect init state machine */
1917  expInitSm((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_waiting));
1918  /* Expect first transition segment */
1919  sm_dch_expect(evA.e, RKH_STATE_CAST(&smPCT_s0));
1920  sm_trn_expect(RKH_STATE_CAST(&smPCT_s0), RKH_STATE_CAST(&smPCT_choice1));
1921  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice1));
1922  //sm_ntrnact_expect(1, 1);
1923  /* Expect target state of last (second) transition */
1924  sm_tsState_expect(RKH_STATE_CAST(&smPCT_s1));
1925  /* Expect solve compoused transition */
1926  sm_exstate_expect(RKH_STATE_CAST(&smPCT_s0));
1927  //sm_ntrnact_expect(1, 2);
1928  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s1));
1929  sm_tsState_expect(RKH_STATE_CAST(&smPCT_s11));
1930  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s11));
1931  sm_nenex_expect(2, 1);
1932  /* Expect main target state */
1933  sm_state_expect(RKH_STATE_CAST(&smPCT_s11));
1934  sm_evtProc_expect();
1935 
1936  /* Initialize and set state */
1937  rkh_sm_init((RKH_SM_T *)me);
1938  setState((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_s0));
1939 
1940  rkh_sm_dispatch((RKH_SM_T *)me, &evA);
1941 
1942  p = unitrazer_getLastOut();
1943  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1944 }
1945 
1946 void
1947 test_pseudostateConditionalTrnToChoiceWithFalseCondition(void)
1948 {
1949  UtrzProcessOut *p;
1950  SmPseudoConditionalTest *me = RKH_CAST(SmPseudoConditionalTest,
1951  smPseudoConditionalTest);
1952 
1953  /* Expect call actions */
1954  smPCT_setCondition_Expect(
1955  RKH_CAST(SmPseudoConditionalTest, me), &evB);
1956  smPCT_onEventA_ExpectAndReturn(
1957  RKH_CAST(SmPseudoConditionalTest, me),
1958  &evB, RKH_FALSE);
1959  smPCT_onEventD_ExpectAndReturn(
1960  RKH_CAST(SmPseudoConditionalTest, me),
1961  &evB, RKH_FALSE);
1962  smPCT_tr2_Expect(
1963  RKH_CAST(SmPseudoConditionalTest, me), &evB);
1964  /* Expect init state machine */
1965  expInitSm((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_waiting));
1966  /* Expect first transition segment */
1967  sm_dch_expect(evB.e, RKH_STATE_CAST(&smPCT_s0));
1968  sm_trn_expect(RKH_STATE_CAST(&smPCT_s0), RKH_STATE_CAST(&smPCT_choice1));
1969  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice1));
1970  //sm_ntrnact_expect(1, 1);
1971  /* Expect target state of last (second) transition */
1972  sm_tsState_expect(RKH_STATE_CAST(&smPCT_s12));
1973  /* Expect solve compoused transition */
1974  sm_exstate_expect(RKH_STATE_CAST(&smPCT_s0));
1975  //sm_ntrnact_expect(1, 2);
1976  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s1));
1977  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s12));
1978  sm_nenex_expect(2, 1);
1979  /* Expect main target state */
1980  sm_state_expect(RKH_STATE_CAST(&smPCT_s12));
1981  sm_evtProc_expect();
1982  /* Initialize and set state */
1983  rkh_sm_init((RKH_SM_T *)me);
1984  setState((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_s0));
1985 
1986  rkh_sm_dispatch((RKH_SM_T *)me, &evB);
1987 
1988  p = unitrazer_getLastOut();
1989  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1990 }
1991 
1992 void
1993 test_pseudostateConditionalTrnToChoiceWithoutElse(void)
1994 {
1995  UtrzProcessOut *p;
1996  SmPseudoConditionalTest *me = RKH_CAST(SmPseudoConditionalTest,
1997  smPseudoConditionalTest);
1998 
1999  /* Expect call actions */
2000  smPCT_onEventA_ExpectAndReturn(
2001  RKH_CAST(SmPseudoConditionalTest, me),
2002  &evC, RKH_FALSE);
2003  /* Expect init state machine */
2004  expInitSm((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_waiting));
2005  /* Expect first transition segment */
2006  sm_dch_expect(evC.e, RKH_STATE_CAST(&smPCT_s0));
2007  sm_trn_expect(RKH_STATE_CAST(&smPCT_s0), RKH_STATE_CAST(&smPCT_choice2));
2008  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice2));
2009  //sm_ntrnact_expect(0, 1);
2010  sm_cndNotFound_expect();
2011  /* Initialize and set state */
2012  rkh_sm_init((RKH_SM_T *)me);
2013  setState((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_s0));
2014 
2015  rkh_sm_dispatch((RKH_SM_T *)me, &evC);
2016 
2017  p = unitrazer_getLastOut();
2018  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2019 }
2020 
2021 void
2022 test_pseudostateConditionalTrnToChoiceReturnToSource(void)
2023 {
2024  UtrzProcessOut *p;
2025  SmPseudoConditionalTest *me = RKH_CAST(SmPseudoConditionalTest,
2026  smPseudoConditionalTest);
2027 
2028  /* Expect call actions */
2029  smPCT_onEventA_ExpectAndReturn(RKH_CAST(SmPseudoConditionalTest, me),
2030  &evD, RKH_FALSE);
2031  smPCT_onEventD_ExpectAndReturn(RKH_CAST(SmPseudoConditionalTest, me),
2032  &evD, RKH_TRUE);
2033  smPCT_tr4_Expect(RKH_CAST(SmPseudoConditionalTest, me), &evD);
2034  /* Expect init state machine */
2035  expInitSm((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_waiting));
2036  /* Expect first transition segment */
2037  sm_dch_expect(evD.e, RKH_STATE_CAST(&smPCT_s0));
2038  sm_trn_expect(RKH_STATE_CAST(&smPCT_s0), RKH_STATE_CAST(&smPCT_choice1));
2039  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice1));
2040  //sm_ntrnact_expect(0, 1);
2041  /* Expect target state of last (second) transition */
2042  sm_tsState_expect(RKH_STATE_CAST(&smPCT_s0));
2043  /* Expect solve compoused transition */
2044  sm_exstate_expect(RKH_STATE_CAST(&smPCT_s0));
2045  //sm_ntrnact_expect(1, 2);
2046  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s0));
2047  sm_nenex_expect(1, 1);
2048  /* Expect main target state */
2049  sm_state_expect(RKH_STATE_CAST(&smPCT_s0));
2050  sm_evtProc_expect();
2051  /* Initialize and set state */
2052  rkh_sm_init((RKH_SM_T *)me);
2053  setState((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_s0));
2054 
2055  rkh_sm_dispatch((RKH_SM_T *)me, &evD);
2056 
2057  p = unitrazer_getLastOut();
2058  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2059 }
2060 
2061 void
2062 test_pseudostateConditionalFailsTrnSegmentsExceeded(void)
2063 {
2064  UtrzProcessOut *p;
2065  SmPseudoConditionalTest *me = RKH_CAST(SmPseudoConditionalTest,
2066  smPseudoConditionalTest);
2067 
2068  /* Expect call actions */
2069  smPCT_tr1_Expect(RKH_CAST(SmPseudoConditionalTest, me), &evE);
2070  smPCT_guardTrue_ExpectAndReturn(RKH_CAST(SmPseudoConditionalTest, me),
2071  &evE, RKH_TRUE);
2072  smPCT_tr1_Expect(RKH_CAST(SmPseudoConditionalTest, me), &evE);
2073  smPCT_guardTrue_ExpectAndReturn(RKH_CAST(SmPseudoConditionalTest, me),
2074  &evE, RKH_TRUE);
2075  smPCT_tr1_Expect(RKH_CAST(SmPseudoConditionalTest, me), &evE);
2076  smPCT_guardTrue_ExpectAndReturn(RKH_CAST(SmPseudoConditionalTest, me),
2077  &evE, RKH_TRUE);
2078  smPCT_tr1_Expect(RKH_CAST(SmPseudoConditionalTest, me), &evE);
2079  smPCT_guardTrue_ExpectAndReturn(RKH_CAST(SmPseudoConditionalTest, me),
2080  &evE, RKH_TRUE);
2081  smPCT_tr1_Expect(RKH_CAST(SmPseudoConditionalTest, me), &evE);
2082  /* Expect init state machine */
2083  expInitSm((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_waiting));
2084  /* Expect first transition segment */
2085  sm_dch_expect(evE.e, RKH_STATE_CAST(&smPCT_s0));
2086  sm_trn_expect(RKH_STATE_CAST(&smPCT_s0), RKH_STATE_CAST(&smPCT_choice3));
2087  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice3));
2088  //sm_ntrnact_expect(1, 1);
2089  /* Expect target state of next transition */
2090  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice4));
2091  //sm_ntrnact_expect(1, 2);
2092  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice5));
2093  //sm_ntrnact_expect(1, 3);
2094  sm_tsState_expect(RKH_STATE_CAST(&smPCT_choice6));
2095  //sm_ntrnact_expect(1, 4);
2096  sm_tsState_expect(RKH_STATE_CAST(&smPCT_s1));
2097  /* Expect solve compoused transition */
2098  sm_exstate_expect(RKH_STATE_CAST(&smPCT_s0));
2099  //sm_ntrnact_expect(1, 5);
2100  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s1));
2101  sm_tsState_expect(RKH_STATE_CAST(&smPCT_s11));
2102  sm_enstate_expect(RKH_STATE_CAST(&smPCT_s11));
2103  sm_nenex_expect(2, 1);
2104  /* Expect main target state */
2105  sm_state_expect(RKH_STATE_CAST(&smPCT_s11));
2106  sm_evtProc_expect();
2107  /* Initialize and set state */
2108  rkh_sm_init((RKH_SM_T *)me);
2109  setState((RKH_SMA_T *)me, RKH_STATE_CAST(&smPCT_s0));
2110 
2111  rkh_sm_dispatch((RKH_SM_T *)me, &evE);
2112 
2113  p = unitrazer_getLastOut();
2114  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2115 }
2125 void
2126 test_pseudostateFirstStateAfterInit(void)
2127 {
2128  UtrzProcessOut *p;
2129 
2130  sm_init_expect(RKH_STATE_CAST(&smPT_waiting));
2131  sm_trn_expect(RKH_STATE_CAST(&smPT_waiting),
2132  RKH_STATE_CAST(&smPT_waiting));
2133  sm_tsState_expect(RKH_STATE_CAST(&smPT_waiting));
2134  sm_enstate_expect(RKH_STATE_CAST(&smPT_waiting));
2135  sm_nenex_expect(1, 0);
2136  sm_state_expect(RKH_STATE_CAST(&smPT_waiting));
2137  sm_evtProc_expect();
2138 
2139  rkh_sm_init((RKH_SM_T *)smPseudoTest);
2140 
2141  p = unitrazer_getLastOut();
2142  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2143 }
2144 
2145 void
2146 test_pseudostateTrnToEmptyShallowHistoryWithoutDefaultTrn(void)
2147 {
2148  UtrzProcessOut *p;
2149  int nExSt, nEnSt;
2150  RKH_EVT_T event;
2151 
2152  nEnSt = 2;
2153  nExSt = 1;
2154  event = evB;
2155  expInitSm((RKH_SMA_T *)smPseudoTest, RKH_STATE_CAST(&smPT_waiting));
2156  sm_dch_expect(event.e, RKH_STATE_CAST(&smPT_s0));
2157  sm_trn_expect(RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(&smPT_s1Hist));
2158  sm_tsState_expect(RKH_STATE_CAST(&smPT_s1Hist));
2159  sm_tsState_expect(RKH_STATE_CAST(&smPT_s1));
2160  sm_exstate_expect(RKH_STATE_CAST(&smPT_s0));
2161  sm_enstate_expect(RKH_STATE_CAST(&smPT_s1));
2162  sm_tsState_expect(RKH_STATE_CAST(&smPT_s11));
2163  sm_enstate_expect(RKH_STATE_CAST(&smPT_s11));
2164  sm_nenex_expect(nEnSt, nExSt);
2165  sm_state_expect(RKH_STATE_CAST(&smPT_s11));
2166  sm_evtProc_expect();
2167 
2168  rkh_sm_init((RKH_SM_T *)smPseudoTest);
2169  setState((RKH_SMA_T *)smPseudoTest, RKH_STATE_CAST(&smPT_s0));
2170  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &event);
2171 
2172  p = unitrazer_getLastOut();
2173  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2174 }
2175 
2176 void
2177 test_pseudostateTrnToLoadedShallowHistoryWithoutDefaultTrn(void)
2178 {
2179  UtrzProcessOut *p;
2180  int nExSt, nEnSt;
2181  RKH_EVT_T event;
2182 
2183  nEnSt = 3;
2184  nExSt = 1;
2185  event = evB;
2186  expInitSm((RKH_SMA_T *)smPseudoTest, RKH_STATE_CAST(&smPT_waiting));
2187  sm_dch_expect(event.e, RKH_STATE_CAST(&smPT_s0));
2188  sm_trn_expect(RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(&smPT_s1Hist));
2189  sm_tsState_expect(RKH_STATE_CAST(&smPT_s1Hist));
2190  sm_tsState_expect(RKH_STATE_CAST(&smPT_s12));
2191  sm_exstate_expect(RKH_STATE_CAST(&smPT_s0));
2192  sm_enstate_expect(RKH_STATE_CAST(&smPT_s1));
2193  sm_enstate_expect(RKH_STATE_CAST(&smPT_s12));
2194  sm_tsState_expect(RKH_STATE_CAST(&smPT_s121));
2195  sm_enstate_expect(RKH_STATE_CAST(&smPT_s121));
2196  sm_nenex_expect(nEnSt, nExSt);
2197  sm_state_expect(RKH_STATE_CAST(&smPT_s121));
2198  sm_evtProc_expect();
2199 
2200  rkh_sm_init((RKH_SM_T *)smPseudoTest);
2201  setState((RKH_SMA_T *)smPseudoTest, RKH_STATE_CAST(&smPT_s0));
2202  setHistory(&smPT_s1Hist, RKH_STATE_CAST(&smPT_s12));
2203  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &event);
2204 
2205  p = unitrazer_getLastOut();
2206  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2207 }
2208 
2209 void
2210 test_pseudostateExitFromCompositeWithLoadedShallowHistory(void)
2211 {
2212  UtrzProcessOut *p;
2213  const RKH_ST_T *state;
2214 
2215  stateList_create(targetStates, 1, &smPT_s0);
2216  stateList_create(exitStates, 3, &smPT_s121, &smPT_s12, &smPT_s1);
2217  stateList_create(entryStates, 1, &smPT_s0);
2218  setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_waiting),
2219  RKH_STATE_CAST(&smPT_s121),
2220  RKH_STATE_CAST(&smPT_s1), targetStates,
2221  entryStates, exitStates,
2222  RKH_STATE_CAST(&smPT_s0), 0, TRN_NOT_INTERNAL, 1, &evA,
2223  RKH_STATE_CAST(&smPT_s121));
2224 
2225  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &evA);
2226  state = getHistory(&smPT_s1Hist);
2227  TEST_ASSERT_EQUAL_PTR(RKH_STATE_CAST(&smPT_s12), state);
2228 
2229  p = unitrazer_getLastOut();
2230  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2231 }
2232 
2233 void
2234 test_pseudostateTrnToEmptyDeepHistoryWithoutDefaultTrn(void)
2235 {
2236  UtrzProcessOut *p;
2237  int nExSt, nEnSt;
2238  RKH_EVT_T event;
2239 
2240  nEnSt = 3;
2241  nExSt = 1;
2242  event = evC;
2243  expInitSm((RKH_SMA_T *)smPseudoTest, RKH_STATE_CAST(&smPT_waiting));
2244  sm_dch_expect(event.e, RKH_STATE_CAST(&smPT_s0));
2245  sm_trn_expect(RKH_STATE_CAST(&smPT_s0), RKH_STATE_CAST(&smPT_s12Hist));
2246  sm_tsState_expect(RKH_STATE_CAST(&smPT_s12Hist));
2247  sm_tsState_expect(RKH_STATE_CAST(&smPT_s12));
2248  sm_exstate_expect(RKH_STATE_CAST(&smPT_s0));
2249  sm_enstate_expect(RKH_STATE_CAST(&smPT_s1));
2250  sm_enstate_expect(RKH_STATE_CAST(&smPT_s12));
2251  sm_tsState_expect(RKH_STATE_CAST(&smPT_s121));
2252  sm_enstate_expect(RKH_STATE_CAST(&smPT_s121));
2253  sm_nenex_expect(nEnSt, nExSt);
2254  sm_state_expect(RKH_STATE_CAST(&smPT_s121));
2255  sm_evtProc_expect();
2256 
2257  rkh_sm_init((RKH_SM_T *)smPseudoTest);
2258  setState((RKH_SMA_T *)smPseudoTest, RKH_STATE_CAST(&smPT_s0));
2259  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &event);
2260 
2261  p = unitrazer_getLastOut();
2262  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2263 }
2264 
2265 void
2266 test_pseudostateTrnToLoadedDeepHistoryWithoutDefaultTrn(void)
2267 {
2268  UtrzProcessOut *p;
2269 
2270  stateList_create(targetStates, 2, &smPT_s12Hist, &smPT_s122);
2271  stateList_create(exitStates, 1, &smPT_s0);
2272  stateList_create(entryStates, 3, &smPT_s1, &smPT_s12, &smPT_s122);
2273  setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_waiting),
2274  RKH_STATE_CAST(&smPT_s0),
2275  RKH_STATE_CAST(&smPT_s0), targetStates,
2276  entryStates, exitStates,
2277  RKH_STATE_CAST(&smPT_s122), 0, TRN_NOT_INTERNAL, 1, &evC,
2278  RKH_STATE_CAST(&smPT_s0));
2279 
2280  setHistory(&smPT_s12Hist, RKH_STATE_CAST(&smPT_s122));
2281  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &evC);
2282 
2283  p = unitrazer_getLastOut();
2284  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2285 }
2286 
2287 void
2288 test_pseudostateExitFromCompositeWithLoadedDeepHistory(void)
2289 {
2290  UtrzProcessOut *p;
2291  const RKH_ST_T *state;
2292 
2293  stateList_create(targetStates, 1, &smPT_s122);
2294  stateList_create(exitStates, 1, &smPT_s0);
2295  stateList_create(entryStates, 3, &smPT_s1, &smPT_s12, &smPT_s122);
2296  setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_waiting),
2297  RKH_STATE_CAST(&smPT_s0),
2298  RKH_STATE_CAST(&smPT_s0), targetStates,
2299  entryStates, exitStates,
2300  RKH_STATE_CAST(&smPT_s122), 0, TRN_NOT_INTERNAL, 1, &evD,
2301  RKH_STATE_CAST(&smPT_s0));
2302 
2303  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &evD);
2304  state = getHistory(&smPT_s12Hist);
2305  TEST_ASSERT_EQUAL_PTR(RKH_STATE_CAST(&smPT_s122), state);
2306 
2307  p = unitrazer_getLastOut();
2308  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2309 }
2310 
2311 void
2312 test_pseudostateTrnToEmptyShallowHistoryWithDefaultTrn(void)
2313 {
2314  UtrzProcessOut *p;
2315 
2316  smPT_trueGuard_ExpectAndReturn(RKH_CAST(SmPseudoTest, smPseudoTest),
2317  &evE, RKH_TRUE);
2318  smPT_trS2History_Expect(RKH_CAST(SmPseudoTest, smPseudoTest), &evE);
2319 
2320  stateList_create(targetStates, 2, &smPT_s2Hist, &smPT_s22);
2321  stateList_create(exitStates, 1, &smPT_s0);
2322  stateList_create(entryStates, 2, &smPT_s2, &smPT_s22);
2323  setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_waiting),
2324  RKH_STATE_CAST(&smPT_s0),
2325  RKH_STATE_CAST(&smPT_s0), targetStates,
2326  entryStates, exitStates,
2327  RKH_STATE_CAST(&smPT_s22), 1, TRN_NOT_INTERNAL, 1, &evE,
2328  RKH_STATE_CAST(&smPT_s0));
2329 
2330  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &evE);
2331 
2332  p = unitrazer_getLastOut();
2333  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2334 }
2335 
2336 void
2337 test_pseudostateTrnToLoadedShallowHistoryWithDefaultTrn(void)
2338 {
2339  UtrzProcessOut *p;
2340 
2341  stateList_create(targetStates, 2, &smPT_s2Hist, &smPT_s21);
2342  stateList_create(exitStates, 1, &smPT_s0);
2343  stateList_create(entryStates, 2, &smPT_s2, &smPT_s21);
2344  setProfile(smPseudoTest, RKH_STATE_CAST(&smPT_waiting),
2345  RKH_STATE_CAST(&smPT_s0),
2346  RKH_STATE_CAST(&smPT_s0), targetStates,
2347  entryStates, exitStates,
2348  RKH_STATE_CAST(&smPT_s21), 0, TRN_NOT_INTERNAL, 1, &evE,
2349  RKH_STATE_CAST(&smPT_s0));
2350 
2351  setHistory(&smPT_s2Hist, RKH_STATE_CAST(&smPT_s21));
2352  rkh_sm_dispatch((RKH_SM_T *)smPseudoTest, &evE);
2353 
2354  p = unitrazer_getLastOut();
2355  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2356 }
2357 
2367 void
2368 test_InitPseudostateFirstStateAfterInit(void)
2369 {
2370  UtrzProcessOut *p;
2371  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2372 
2373  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2374  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2375  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0, NULL, NULL, NULL,
2376  &evCreation);
2377 
2378  rkh_sm_init((RKH_SM_T *)me);
2379 
2380  p = unitrazer_getLastOut();
2381  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2382 }
2383 
2384 void
2385 test_InitPseudostateTrnToEmptyShHistoryToSimpleState(void)
2386 {
2387  UtrzProcessOut *p;
2388  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2389  TargetEntrySt tgEnSt[4] = {{(RKH_ST_T *)&smIPT_s1, (RKH_ST_T *)&smIPT_s1},
2390  {(RKH_ST_T *)&smIPT_s1Hist, NULL},
2391  {(RKH_ST_T *)&smIPT_s11, (RKH_ST_T *)&smIPT_s11},
2392  {NULL, NULL}};
2393 
2394  stateList_create(exitStates, 1, &smIPT_s0);
2395 
2396  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2397  smIPT_nS0_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2398  smIPT_xS0_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2399  smIPT_nS1_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2400  smIPT_tr1_Expect((SmInitialPseudoTest *)smInitialPseudoTest, &evA);
2401  smIPT_nS11_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2402 
2403  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2404  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evA);
2405 
2406  rkh_sm_init((RKH_SM_T *)me);
2407  rkh_sm_dispatch((RKH_SM_T *)smInitialPseudoTest, &evA);
2408 
2409  p = unitrazer_getLastOut();
2410  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2411 }
2412 
2413 void
2414 test_InitPseudostateTrnToLoadedShHistory(void)
2415 {
2416  UtrzProcessOut *p;
2417  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2418  TargetEntrySt tgEnSt[4] = {{(RKH_ST_T *)&smIPT_s1, (RKH_ST_T *)&smIPT_s1},
2419  {(RKH_ST_T *)&smIPT_s1Hist, NULL },
2420  {(RKH_ST_T *)&smIPT_s12, (RKH_ST_T *)&smIPT_s12},
2421  {NULL, NULL }};
2422 
2423  stateList_create(exitStates, 1, &smIPT_s0);
2424 
2425  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2426  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2427  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2428  smIPT_nS1_Expect((SmInitialPseudoTest *)me);
2429  smIPT_nS12_Expect((SmInitialPseudoTest *)me);
2430 
2431  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2432  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evA);
2433 
2434  rkh_sm_init((RKH_SM_T *)me);
2435  setHistory(&smIPT_s1Hist, RKH_STATE_CAST(&smIPT_s12));
2436  rkh_sm_dispatch((RKH_SM_T *)me, &evA);
2437 
2438  p = unitrazer_getLastOut();
2439  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2440 }
2441 
2442 void
2443 test_InitPseudostateTrnToEmptyShHistoryToCmpState(void)
2444 {
2445  UtrzProcessOut *p;
2446  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2447  TargetEntrySt tgEnSt[5] = {{(RKH_ST_T *)&smIPT_s2, (RKH_ST_T *)&smIPT_s2},
2448  {(RKH_ST_T *)&smIPT_s2Hist, NULL},
2449  {(RKH_ST_T *)&smIPT_s21, (RKH_ST_T *)&smIPT_s21},
2450  {(RKH_ST_T *)&smIPT_s211, (RKH_ST_T *)&smIPT_s211 },
2451  {NULL, NULL}};
2452 
2453  stateList_create(exitStates, 1, &smIPT_s0);
2454 
2455  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2456  smIPT_nS0_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2457  smIPT_xS0_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2458  smIPT_nS2_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2459  smIPT_nS21_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2460  smIPT_nS211_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2461 
2462  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2463  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evD);
2464 
2465  rkh_sm_init((RKH_SM_T *)me);
2466  rkh_sm_dispatch((RKH_SM_T *)smInitialPseudoTest, &evD);
2467 
2468  p = unitrazer_getLastOut();
2469  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2470 }
2471 
2472 void
2473 test_InitPseudostateTrnToEmptyDeepHistoryToSimpleState(void)
2474 {
2475  UtrzProcessOut *p;
2476  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2477  TargetEntrySt tgEnSt[4] = {{(RKH_ST_T *)&smIPT_s3, (RKH_ST_T *)&smIPT_s3},
2478  {(RKH_ST_T *)&smIPT_s3Hist, NULL},
2479  {(RKH_ST_T *)&smIPT_s31, (RKH_ST_T *)&smIPT_s31 },
2480  {NULL, NULL}};
2481 
2482  stateList_create(exitStates, 1, &smIPT_s0);
2483 
2484  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2485  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2486  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2487  smIPT_nS3_Expect((SmInitialPseudoTest *)me);
2488  smIPT_nS31_Expect((SmInitialPseudoTest *)me);
2489 
2490  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2491  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evB);
2492 
2493  rkh_sm_init((RKH_SM_T *)me);
2494  rkh_sm_dispatch((RKH_SM_T *)smInitialPseudoTest, &evB);
2495 
2496  p = unitrazer_getLastOut();
2497  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2498 }
2499 
2500 void
2501 test_InitPseudostateTrnToLoadedDeepHistory(void)
2502 {
2503  UtrzProcessOut *p;
2504  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2505  TargetEntrySt tgEnSt[4] = {{(RKH_ST_T *)&smIPT_s3, (RKH_ST_T *)&smIPT_s3},
2506  {(RKH_ST_T *)&smIPT_s3Hist, NULL},
2507  {(RKH_ST_T *)&smIPT_s32, (RKH_ST_T *)&smIPT_s32},
2508  {NULL, NULL}};
2509 
2510  stateList_create(exitStates, 1, &smIPT_s0);
2511 
2512  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2513  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2514  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2515  smIPT_nS3_Expect((SmInitialPseudoTest *)me);
2516  smIPT_nS32_Expect((SmInitialPseudoTest *)me);
2517 
2518  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2519  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evB);
2520 
2521  rkh_sm_init((RKH_SM_T *)me);
2522  setHistory(&smIPT_s3Hist, RKH_STATE_CAST(&smIPT_s32));
2523  rkh_sm_dispatch((RKH_SM_T *)smInitialPseudoTest, &evB);
2524 
2525  p = unitrazer_getLastOut();
2526  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2527 }
2528 
2529 void
2530 test_InitPseudostateTrnToLoadedDeepHistoryToNestedState(void)
2531 {
2532  UtrzProcessOut *p;
2533  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2534  TargetEntrySt tgEnSt[5] = {{(RKH_ST_T *)&smIPT_s3, (RKH_ST_T *)&smIPT_s3 },
2535  {(RKH_ST_T *)&smIPT_s3Hist, NULL},
2536  {(RKH_ST_T *)&smIPT_s331, (RKH_ST_T *)&smIPT_s33},
2537  {NULL, (RKH_ST_T *)&smIPT_s331},
2538  {NULL, NULL}};
2539 
2540  stateList_create(exitStates, 1, &smIPT_s0);
2541 
2542  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2543  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2544  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2545  smIPT_nS3_Expect((SmInitialPseudoTest *)me);
2546  smIPT_nS33_Expect((SmInitialPseudoTest *)me);
2547  smIPT_nS331_Expect((SmInitialPseudoTest *)me);
2548 
2549  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2550  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evB);
2551 
2552  rkh_sm_init((RKH_SM_T *)me);
2553  setHistory(&smIPT_s3Hist, RKH_STATE_CAST(&smIPT_s331));
2554  rkh_sm_dispatch((RKH_SM_T *)smInitialPseudoTest, &evB);
2555 
2556  p = unitrazer_getLastOut();
2557  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2558 }
2559 
2560 void
2561 test_InitPseudostateTrnToEmptyShHistoryToNestedSimpleState(void)
2562 {
2563  UtrzProcessOut *p;
2564  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2565  TargetEntrySt tgEnSt[5] = {{(RKH_ST_T *)&smIPT_s4, (RKH_ST_T *)&smIPT_s4},
2566  {(RKH_ST_T *)&smIPT_s4Hist, NULL},
2567  {(RKH_ST_T *)&smIPT_s411, (RKH_ST_T *)&smIPT_s41},
2568  {NULL, (RKH_ST_T *)&smIPT_s411},
2569  {NULL, NULL}};
2570 
2571  stateList_create(exitStates, 1, &smIPT_s0);
2572 
2573  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2574  smIPT_nS0_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2575  smIPT_xS0_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2576  smIPT_nS4_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2577  smIPT_nS41_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2578  smIPT_nS411_Expect((SmInitialPseudoTest *)smInitialPseudoTest);
2579 
2580  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2581  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evC);
2582 
2583  rkh_sm_init((RKH_SM_T *)me);
2584  rkh_sm_dispatch((RKH_SM_T *)smInitialPseudoTest, &evC);
2585 
2586  p = unitrazer_getLastOut();
2587  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2588 }
2589 
2590 void
2591 test_InitPseudostateTrnToBranchToSimpleState(void)
2592 {
2593  UtrzProcessOut *p;
2594  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2595  TargetEntrySt tgEnSt[4] = {{(RKH_ST_T *)&smIPT_s5, (RKH_ST_T *)&smIPT_s5},
2596  {(RKH_ST_T *)&smIPT_choice1, NULL},
2597  {(RKH_ST_T *)&smIPT_s52, (RKH_ST_T *)&smIPT_s52},
2598  {NULL, NULL}};
2599 
2600  //stateList_create(targetStates, 3, &smIPT_s5, &smIPT_choice1, &smIPT_s52);
2601  stateList_create(exitStates, 1, &smIPT_s0);
2602  //stateList_create(entryStates, 2, &smIPT_s5, &smIPT_s52);
2603 
2604  /* Expect call actions */
2605  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2606  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2607  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2608  smIPT_nS5_Expect((SmInitialPseudoTest *)me);
2609  smIPT_tr2_Expect((SmInitialPseudoTest *)me, &evE);
2610  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_TRUE);
2611  smIPT_nS52_Expect((SmInitialPseudoTest *)me);
2612 
2613  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2614  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evE);
2615 
2616  rkh_sm_init((RKH_SM_T *)me);
2617  rkh_sm_dispatch((RKH_SM_T *)me, &evE);
2618 
2619  p = unitrazer_getLastOut();
2620  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2621 }
2622 
2623 void
2624 test_InitPseudostateTrnToBranchToCmpState(void)
2625 {
2626  UtrzProcessOut *p;
2627  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2628  TargetEntrySt tgEnSt[5] = {{(RKH_ST_T *)&smIPT_s5, (RKH_ST_T *)&smIPT_s5},
2629  {(RKH_ST_T *)&smIPT_choice1, NULL},
2630  {(RKH_ST_T *)&smIPT_s51, (RKH_ST_T *)&smIPT_s51},
2631  {(RKH_ST_T *)&smIPT_s511, (RKH_ST_T *)&smIPT_s511},
2632  {NULL, NULL}};
2633 
2634  //stateList_create(targetStates, 4, &smIPT_s5, &smIPT_choice1, &smIPT_s51,
2635  // &smIPT_s511);
2636  stateList_create(exitStates, 1, &smIPT_s0);
2637  //stateList_create(entryStates, 3, &smIPT_s5, &smIPT_s51, &smIPT_s511);
2638 
2639  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2640  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2641  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2642  smIPT_nS5_Expect((SmInitialPseudoTest *)me);
2643  smIPT_tr2_Expect((SmInitialPseudoTest *)me, &evE);
2644  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2645  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2646  smIPT_isC3_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2647  smIPT_isC4_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2648  smIPT_nS51_Expect((SmInitialPseudoTest *)me);
2649  smIPT_nS511_Expect((SmInitialPseudoTest *)me);
2650 
2651  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2652  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evE);
2653 
2654  rkh_sm_init((RKH_SM_T *)me);
2655  rkh_sm_dispatch((RKH_SM_T *)me, &evE);
2656 
2657  p = unitrazer_getLastOut();
2658  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2659 }
2660 
2661 void
2662 test_InitPseudostateTrnToBranchToNestedSimpleState(void)
2663 {
2664  UtrzProcessOut *p;
2665  SmInitialPseudoTest *me = RKH_CAST(SmInitialPseudoTest,
2666  smInitialPseudoTest);
2667  TargetEntrySt tgEnSt[5] = {{(RKH_ST_T *)&smIPT_s5, (RKH_ST_T *)&smIPT_s5},
2668  {(RKH_ST_T *)&smIPT_choice1, NULL},
2669  {(RKH_ST_T *)&smIPT_s511, (RKH_ST_T *)&smIPT_s51},
2670  {NULL, (RKH_ST_T *)&smIPT_s511},
2671  {NULL, NULL}};
2672 
2673  stateList_create(exitStates, 1, &smIPT_s0);
2674 
2675  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2676  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2677  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2678  smIPT_nS5_Expect((SmInitialPseudoTest *)me);
2679  smIPT_tr2_Expect((SmInitialPseudoTest *)me, &evE);
2680  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2681  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_TRUE);
2682  smIPT_nS51_Expect((SmInitialPseudoTest *)me);
2683  smIPT_nS511_Expect((SmInitialPseudoTest *)me);
2684 
2685  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2686  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evE);
2687 
2688  rkh_sm_init((RKH_SM_T *)me);
2689  rkh_sm_dispatch((RKH_SM_T *)me, &evE);
2690 
2691  p = unitrazer_getLastOut();
2692  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2693 }
2694 
2695 void
2696 test_InitPseudostateTrnToBranchToNestedCmpState(void)
2697 {
2698  UtrzProcessOut *p;
2699  SmInitialPseudoTest *me = RKH_CAST(SmInitialPseudoTest,
2700  smInitialPseudoTest);
2701  TargetEntrySt tgEnSt[6] = {{(RKH_ST_T *)&smIPT_s5, (RKH_ST_T *)&smIPT_s5},
2702  {(RKH_ST_T *)&smIPT_choice1, NULL},
2703  {(RKH_ST_T *)&smIPT_s512, (RKH_ST_T *)&smIPT_s51},
2704  {NULL, (RKH_ST_T *)&smIPT_s512},
2705  {(RKH_ST_T *)&smIPT_s5121, (RKH_ST_T *)&smIPT_s5121},
2706  {NULL, NULL}};
2707 
2708  stateList_create(exitStates, 1, &smIPT_s0);
2709 
2710  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2711  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2712  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2713  smIPT_nS5_Expect((SmInitialPseudoTest *)me);
2714  smIPT_tr2_Expect((SmInitialPseudoTest *)me, &evE);
2715  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2716  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2717  smIPT_isC3_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_TRUE);
2718  smIPT_nS51_Expect((SmInitialPseudoTest *)me);
2719  smIPT_nS512_Expect((SmInitialPseudoTest *)me);
2720  smIPT_nS5121_Expect((SmInitialPseudoTest *)me);
2721 
2722  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2723  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evE);
2724 
2725  rkh_sm_init((RKH_SM_T *)me);
2726  rkh_sm_dispatch((RKH_SM_T *)me, &evE);
2727 
2728  p = unitrazer_getLastOut();
2729  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2730 }
2731 
2732 void
2733 test_InitPseudostateTrnToBranchToFinalState(void)
2734 {
2735  UtrzProcessOut *p;
2736  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
2737  TargetEntrySt tgEnSt[4] =
2738  {{(RKH_ST_T *)&smIPT_s5, (RKH_ST_T *)&smIPT_s5},
2739  {(RKH_ST_T *)&smIPT_choice1, NULL},
2740  {(RKH_ST_T *)&smIPT_s5Final, (RKH_ST_T *)&smIPT_s5Final},
2741  {NULL, NULL}};
2742 
2743  //stateList_create(targetStates, 3, &smIPT_s5, &smIPT_choice1, &smIPT_s52);
2744  stateList_create(exitStates, 1, &smIPT_s0);
2745  //stateList_create(entryStates, 2, &smIPT_s5, &smIPT_s52);
2746 
2747  /* Expect call actions */
2748  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2749  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2750  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2751  smIPT_nS5_Expect((SmInitialPseudoTest *)me);
2752  smIPT_tr2_Expect((SmInitialPseudoTest *)me, &evE);
2753  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2754  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2755  smIPT_isC3_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_FALSE);
2756  smIPT_isC4_ExpectAndReturn((RKH_SM_T *)me, &evE, RKH_TRUE);
2757 
2758  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2759  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evE);
2760 
2761  /* Expectations for completion transition */
2762  stateList_create(targetStates, 1, &smIPT_s0);
2763  stateList_create(entryStates, 1, &smIPT_s0);
2764  stateList_create(exitStates, 2, &smIPT_s5Final, &smIPT_s5);
2765 
2766  smIPT_xS5_Expect((SmInitialPseudoTest *)me);
2767  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2768 
2769  setProfile(smInitialPseudoTest, RKH_STATE_CAST(&smIPT_s5),
2770  NULL, RKH_STATE_CAST(&smIPT_s5),
2771  targetStates, entryStates, exitStates,
2772  RKH_STATE_CAST(&smIPT_s0), 1, TRN_NOT_INTERNAL,
2773  NO_INIT_STATE_MACHINE, &evCompletion,
2774  RKH_STATE_CAST(&smIPT_s5Final));
2775 
2776  rkh_sm_init((RKH_SM_T *)me);
2777  rkh_sm_dispatch((RKH_SM_T *)me, &evE);
2778 
2779  p = unitrazer_getLastOut();
2780  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2781 }
2782 
2783 void
2784 test_InitPseudostateTrnToJunctionToSimpleState(void)
2785 {
2786  UtrzProcessOut *p;
2787  SmInitialPseudoTest *me = RKH_CAST(SmInitialPseudoTest,
2788  smInitialPseudoTest);
2789  TargetEntrySt tgEnSt[4] = {{(RKH_ST_T *)&smIPT_s6, (RKH_ST_T *)&smIPT_s6},
2790  {(RKH_ST_T *)&smIPT_junction1, NULL},
2791  {(RKH_ST_T *)&smIPT_s62, (RKH_ST_T *)&smIPT_s62},
2792  {NULL, NULL}};
2793 
2794  stateList_create(exitStates, 1, &smIPT_s0);
2795 
2796  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2797  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2798  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2799  smIPT_nS6_Expect((SmInitialPseudoTest *)me);
2800  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evF, RKH_TRUE);
2801  smIPT_tr3_Expect((SmInitialPseudoTest *)me, &evF);
2802  smIPT_nS62_Expect((SmInitialPseudoTest *)me);
2803 
2804  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2805  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evF);
2806 
2807  rkh_sm_init((RKH_SM_T *)me);
2808  rkh_sm_dispatch((RKH_SM_T *)me, &evF);
2809 
2810  p = unitrazer_getLastOut();
2811  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2812 }
2813 
2814 void
2815 test_InitPseudostateTrnToJunctionToCmpState(void)
2816 {
2817  UtrzProcessOut *p;
2818  SmInitialPseudoTest *me = RKH_CAST(SmInitialPseudoTest,
2819  smInitialPseudoTest);
2820  TargetEntrySt tgEnSt[5] = {{(RKH_ST_T *)&smIPT_s6, (RKH_ST_T *)&smIPT_s6},
2821  {(RKH_ST_T *)&smIPT_junction1, NULL},
2822  {(RKH_ST_T *)&smIPT_s61, (RKH_ST_T *)&smIPT_s61},
2823  {(RKH_ST_T *)&smIPT_s611, (RKH_ST_T *)&smIPT_s611},
2824  {NULL, NULL}};
2825 
2826  stateList_create(exitStates, 1, &smIPT_s0);
2827 
2828  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2829  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
2830  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
2831  smIPT_nS6_Expect((SmInitialPseudoTest *)me);
2832  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, &evF, RKH_FALSE);
2833  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, &evF, RKH_FALSE);
2834  smIPT_isC3_ExpectAndReturn((RKH_SM_T *)me, &evF, RKH_FALSE);
2835  smIPT_tr3_Expect((SmInitialPseudoTest *)me, &evF);
2836  smIPT_nS61_Expect((SmInitialPseudoTest *)me);
2837  smIPT_nS611_Expect((SmInitialPseudoTest *)me);
2838 
2839  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
2840  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evF);
2841 
2842  rkh_sm_init((RKH_SM_T *)me);
2843  rkh_sm_dispatch((RKH_SM_T *)me, &evF);
2844 
2845  p = unitrazer_getLastOut();
2846  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2847 }
2848 
2849 void
2850 test_InitPseudostateSMInitialToSimpleState(void)
2851 {
2852  UtrzProcessOut *p;
2853  RKH_SM_T *me = smInitial0;
2854 
2855  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2856  smI0_nS0_Expect((SmInitialPseudoTest *)me);
2857  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smI0_s0, NULL, NULL,
2858  NULL, &evCreation);
2859 
2860  rkh_sm_init(me);
2861 
2862  p = unitrazer_getLastOut();
2863  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2864 }
2865 
2866 void
2867 test_InitPseudostateSMInitialToCmpState(void)
2868 {
2869  UtrzProcessOut *p;
2870  RKH_SM_T *me = smInitial1;
2871 
2872  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2873  smI1_nS0_Expect((SmInitialPseudoTest *)me);
2874  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2875  smI1_nS01_Expect((SmInitialPseudoTest *)me);
2876  sm_init_expect(RKH_STATE_CAST(&smI1_s0));
2877  sm_trn_expect(RKH_STATE_CAST(&smI1_s0), RKH_STATE_CAST(&smI1_s0));
2878  sm_tsState_expect(RKH_STATE_CAST(&smI1_s0));
2879  sm_enstate_expect(RKH_STATE_CAST(&smI1_s0));
2880  sm_tsState_expect(RKH_STATE_CAST(&smI1_s01));
2881  sm_enstate_expect(RKH_STATE_CAST(&smI1_s01));
2882  sm_nenex_expect(2, 0);
2883  sm_state_expect(RKH_STATE_CAST(&smI1_s01));
2884  sm_evtProc_expect();
2885 
2886  rkh_sm_init(me);
2887 
2888  p = unitrazer_getLastOut();
2889  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2890 }
2891 
2892 void
2893 test_InitPseudostateSMInitialToNestedSimpleState(void)
2894 {
2895  UtrzProcessOut *p;
2896  RKH_SM_T *me = smInitial2;
2897 
2898  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2899  smI2_nS0_Expect((SmInitialPseudoTest *)me);
2900  smI2_nS01_Expect((SmInitialPseudoTest *)me);
2901  sm_init_expect(RKH_STATE_CAST(&smI2_s01));
2902  sm_trn_expect(RKH_STATE_CAST(&smI2_s01), RKH_STATE_CAST(&smI2_s01));
2903  sm_tsState_expect(RKH_STATE_CAST(&smI2_s01));
2904  sm_enstate_expect(RKH_STATE_CAST(&smI2_s0));
2905  sm_enstate_expect(RKH_STATE_CAST(&smI2_s01));
2906  sm_nenex_expect(2, 0);
2907  sm_state_expect(RKH_STATE_CAST(&smI2_s01));
2908  sm_evtProc_expect();
2909 
2910  rkh_sm_init(me);
2911 
2912  p = unitrazer_getLastOut();
2913  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2914 }
2915 
2916 void
2917 test_InitPseudostateSMInitialToNestedCmpState(void)
2918 {
2919  UtrzProcessOut *p;
2920  RKH_SM_T *me = smInitial3;
2921 
2922  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2923  smI3_nS0_Expect((SmInitialPseudoTest *)me);
2924  smI3_nS01_Expect((SmInitialPseudoTest *)me);
2925  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2926  smI3_nS011_Expect((SmInitialPseudoTest *)me);
2927  sm_init_expect(RKH_STATE_CAST(&smI3_s01));
2928  sm_trn_expect(RKH_STATE_CAST(&smI3_s01), RKH_STATE_CAST(&smI3_s01));
2929  sm_tsState_expect(RKH_STATE_CAST(&smI3_s01));
2930  sm_enstate_expect(RKH_STATE_CAST(&smI3_s0));
2931  sm_enstate_expect(RKH_STATE_CAST(&smI3_s01));
2932  sm_tsState_expect(RKH_STATE_CAST(&smI3_s011));
2933  sm_enstate_expect(RKH_STATE_CAST(&smI3_s011));
2934  sm_nenex_expect(3, 0);
2935  sm_state_expect(RKH_STATE_CAST(&smI3_s011));
2936  sm_evtProc_expect();
2937 
2938  rkh_sm_init(me);
2939 
2940  p = unitrazer_getLastOut();
2941  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2942 }
2943 
2944 void
2945 test_InitPseudostateSMInitialToJunctionToSimpleState(void)
2946 {
2947  UtrzProcessOut *p;
2948  RKH_SM_T *me = smInitial4;
2949 
2950  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, (RKH_EVT_T *)&evCreation,
2951  RKH_TRUE);
2952  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2953  smIPT_tr1_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2954  smI4_nS0_Expect((SmInitialPseudoTest *)me);
2955  sm_init_expect(RKH_STATE_CAST(&smI4_junction1));
2956  sm_trn_expect(RKH_STATE_CAST(&smI4_junction1),
2957  RKH_STATE_CAST(&smI4_junction1));
2958  sm_tsState_expect(RKH_STATE_CAST(&smI4_junction1));
2959  sm_tsState_expect(RKH_STATE_CAST(&smI4_s0));
2960  sm_enstate_expect(RKH_STATE_CAST(&smI4_s0));
2961  sm_nenex_expect(1, 0);
2962  sm_state_expect(RKH_STATE_CAST(&smI4_s0));
2963  sm_evtProc_expect();
2964 
2965  rkh_sm_init(me);
2966 
2967  p = unitrazer_getLastOut();
2968  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
2969 }
2970 
2971 void
2972 test_InitPseudostateSMInitialToJunctionToCmpState(void)
2973 {
2974  UtrzProcessOut *p;
2975  RKH_SM_T *me = smInitial4;
2976 
2977  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, (RKH_EVT_T *)&evCreation,
2978  RKH_FALSE);
2979  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, (RKH_EVT_T *)&evCreation,
2980  RKH_TRUE);
2981  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2982  smIPT_tr2_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2983  smI4_nS1_Expect((SmInitialPseudoTest *)me);
2984  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
2985  smI4_nS11_Expect((SmInitialPseudoTest *)me);
2986  sm_init_expect(RKH_STATE_CAST(&smI4_junction1));
2987  sm_trn_expect(RKH_STATE_CAST(&smI4_junction1),
2988  RKH_STATE_CAST(&smI4_junction1));
2989  sm_tsState_expect(RKH_STATE_CAST(&smI4_junction1));
2990  sm_tsState_expect(RKH_STATE_CAST(&smI4_s1));
2991  sm_enstate_expect(RKH_STATE_CAST(&smI4_s1));
2992  sm_tsState_expect(RKH_STATE_CAST(&smI4_s11));
2993  sm_enstate_expect(RKH_STATE_CAST(&smI4_s11));
2994  sm_nenex_expect(2, 0);
2995  sm_state_expect(RKH_STATE_CAST(&smI4_s11));
2996  sm_evtProc_expect();
2997 
2998  rkh_sm_init(me);
2999 
3000  p = unitrazer_getLastOut();
3001  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
3002 }
3003 
3004 void
3005 test_InitPseudostateSMInitialToBranchToSimpleState(void)
3006 {
3007  UtrzProcessOut *p;
3008  RKH_SM_T *me = smInitial5;
3009 
3010  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3011  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, (RKH_EVT_T *)&evCreation,
3012  RKH_TRUE);
3013  smIPT_tr1_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3014  smI5_nS0_Expect((SmInitialPseudoTest *)me);
3015  sm_init_expect(RKH_STATE_CAST(&smI5_branch1));
3016  sm_trn_expect(RKH_STATE_CAST(&smI5_branch1),
3017  RKH_STATE_CAST(&smI5_branch1));
3018  sm_tsState_expect(RKH_STATE_CAST(&smI5_branch1));
3019  sm_tsState_expect(RKH_STATE_CAST(&smI5_s0));
3020  sm_enstate_expect(RKH_STATE_CAST(&smI5_s0));
3021  sm_nenex_expect(1, 0);
3022  sm_state_expect(RKH_STATE_CAST(&smI5_s0));
3023  sm_evtProc_expect();
3024 
3025  rkh_sm_init(me);
3026 
3027  p = unitrazer_getLastOut();
3028  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
3029 }
3030 
3031 void
3032 test_InitPseudostateSMInitialToBranchToCmpState(void)
3033 {
3034  UtrzProcessOut *p;
3035  RKH_SM_T *me = smInitial5;
3036 
3037  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3038  smIPT_isC1_ExpectAndReturn((RKH_SM_T *)me, (RKH_EVT_T *)&evCreation,
3039  RKH_FALSE);
3040  smIPT_isC2_ExpectAndReturn((RKH_SM_T *)me, (RKH_EVT_T *)&evCreation,
3041  RKH_TRUE);
3042  smIPT_tr2_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3043  smI5_nS1_Expect((SmInitialPseudoTest *)me);
3044  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3045  smI5_nS11_Expect((SmInitialPseudoTest *)me);
3046  sm_init_expect(RKH_STATE_CAST(&smI5_branch1));
3047  sm_trn_expect(RKH_STATE_CAST(&smI5_branch1),
3048  RKH_STATE_CAST(&smI5_branch1));
3049  sm_tsState_expect(RKH_STATE_CAST(&smI5_branch1));
3050  sm_tsState_expect(RKH_STATE_CAST(&smI5_s1));
3051  sm_enstate_expect(RKH_STATE_CAST(&smI5_s1));
3052  sm_tsState_expect(RKH_STATE_CAST(&smI5_s11));
3053  sm_enstate_expect(RKH_STATE_CAST(&smI5_s11));
3054  sm_nenex_expect(2, 0);
3055  sm_state_expect(RKH_STATE_CAST(&smI5_s11));
3056  sm_evtProc_expect();
3057 
3058  rkh_sm_init(me);
3059 
3060  p = unitrazer_getLastOut();
3061  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
3062 }
3063 
3064 void
3065 test_InitPseudostateTrnToInitialToSimpleStateWithNullTrn(void)
3066 {
3067  UtrzProcessOut *p;
3068  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitialPseudoTest;
3069  TargetEntrySt tgEnSt[3] = {{(RKH_ST_T *)&smIPT_s7, (RKH_ST_T *)&smIPT_s7},
3070  {(RKH_ST_T *)&smIPT_s71, (RKH_ST_T *)&smIPT_s71},
3071  {NULL, NULL}};
3072 
3073  stateList_create(exitStates, 1, &smIPT_s0);
3074 
3075  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3076  smIPT_nS0_Expect((SmInitialPseudoTest *)me);
3077  smIPT_xS0_Expect((SmInitialPseudoTest *)me);
3078  smIPT_nS7_Expect((SmInitialPseudoTest *)me);
3079  smIPT_nS71_Expect((SmInitialPseudoTest *)me);
3080  smIPT_xS71_Expect((SmInitialPseudoTest *)me);
3081  smIPT_tr4_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCompletion);
3082  smIPT_nS72_Expect((SmInitialPseudoTest *)me);
3083 
3084  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smIPT_s0,
3085  (RKH_ST_T *)&smIPT_s0, tgEnSt, exitStates, &evG);
3086 
3087  /* Transition (null or completion) from s71 to s72 */
3088  sm_dch_expect(evCompletion.e, RKH_STATE_CAST(&smIPT_s71));
3089  sm_trn_expect(RKH_STATE_CAST(&smIPT_s71), RKH_STATE_CAST(&smIPT_s72));
3090  sm_tsState_expect(RKH_STATE_CAST(&smIPT_s72));
3091  sm_exstate_expect(RKH_STATE_CAST(&smIPT_s71));
3092  sm_enstate_expect(RKH_STATE_CAST(&smIPT_s72));
3093  sm_nenex_expect(1, 1);
3094  sm_state_expect(RKH_STATE_CAST(&smIPT_s72));
3095  sm_evtProc_expect();
3096 
3097  rkh_sm_init((RKH_SM_T *)me);
3098  rkh_sm_dispatch((RKH_SM_T *)me, &evG);
3099 
3100  p = unitrazer_getLastOut();
3101  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
3102 }
3103 
3104 void
3105 test_InitPseudostateSMInitialToSimpleStateWithNullTrn(void)
3106 {
3107  UtrzProcessOut *p;
3108  SmInitialPseudoTest *me = (SmInitialPseudoTest *)smInitial6;
3109 
3110  smIPT_init_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCreation);
3111  smIPT_tr4_Expect((SmInitialPseudoTest *)me, (RKH_EVT_T *)&evCompletion);
3112  trnStepExpect((RKH_SM_T *)me, (RKH_ST_T *)&smI6_s0, NULL, NULL,
3113  NULL, &evCreation);
3114 
3115  /* Transition (null or completion) from s0 to s1 */
3116  sm_dch_expect(evCompletion.e, RKH_STATE_CAST(&smI6_s0));
3117  sm_trn_expect(RKH_STATE_CAST(&smI6_s0), RKH_STATE_CAST(&smI6_s1));
3118  sm_tsState_expect(RKH_STATE_CAST(&smI6_s1));
3119  sm_exstate_expect(RKH_STATE_CAST(&smI6_s0));
3120  sm_enstate_expect(RKH_STATE_CAST(&smI6_s1));
3121  sm_nenex_expect(1, 1);
3122  sm_state_expect(RKH_STATE_CAST(&smI6_s1));
3123  sm_evtProc_expect();
3124 
3125  rkh_sm_init((RKH_SM_T *)me);
3126 
3127  p = unitrazer_getLastOut();
3128  TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
3129 }
3130 
3136 /* ------------------------------ End of file ------------------------------ */
#define RKH_FALSE
Standard define.
Definition: rkhdef.h:256
#define RKH_TRUE
Standard define.
Definition: rkhdef.h:257
#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...
ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e)
Executes a state machine in a run-to-completation (RTC) model.
RKH_RCODE_T
Return codes from rkh_sm_dispatch() function.
Definition: rkhsm.h:1558
void rkh_sm_init(RKH_SM_T *me)
Inits a previously created state machine calling its initializing action.
void rkh_sm_clear_history(RKHROM RKH_SHIST_T *h)
Erase the history of a state. It can be a shallow or deep history.
@ RKH_EVT_NFOUND
Definition: rkhsm.h:1568
@ RKH_EX_HLEVEL
Definition: rkhsm.h:1589
@ RKH_EVT_PROC
Definition: rkhsm.h:1563
#define RKH_FILTER_OFF_ALL_SIGNALS()
Emmit all enabled trace events related to signals.
#define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp)
Emit (enable) all events in a specific group.
#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_SMA(sma)
Emmit the enabled trace events related to a specified active object.
#define RKH_TR_FWK_AO(actObj_)
Entry symbol table for active object.
#define RKH_TR_FWK_SIG(stateObj_)
Entry symbol table for event signal.
#define RKH_TR_FWK_STATE(actObj_, stateObj_)
Entry symbol table for state object.
Specifies the interface of the mapping table manager to deal with native priority algorithm.
#define RKH_CAST(_type, _obj)
Perform downcast of a reference of a base class to one of its derived classes.
Definition: rkhfwk_cast.h:107
Specifies the interface of the state-machine manager.
Specifies the interface of trace facility.
#define RKH_TG_SM
State Machine group (SM)
#define RKH_TE_FWK_ASSERT
Assertion expression was evaluated to false.
Specifies the runtime filter operations for the trace facility.
Defines the trace records.
Specifies the trace stream manager (circular buffer).
Represents events without parameters.
Definition: rkhevt.h:170
RKH_SIG_T e
Signal of the event instance.
Definition: rkhevt.h:175
Describes the state machine.
Definition: rkhsm.h:1905
Describes the SMA (active object in UML).
Definition: rkhsma.h:772
Describes the common properties of regular states (basic, composite, and submachine).
Definition: rkhsm.h:2065
Interface of unit test with Trazer application.
#define sm_cleanup()
Return the system under test to its initial state after the test.
Definition: unitrazer.h:85
#define sm_init()
Establish the preconditions to the tests.
Definition: unitrazer.h:79
#define sm_verify()
Makes sure there are no unused expectations, if there are, this function causes the test to fail.
Definition: unitrazer.h:92