CORDET Framework - C2 Implementation
CrFwOutStreamTestCases.c
Go to the documentation of this file.
1 
19 #include <stdlib.h>
20 #include "CrFwOutStreamTestCases.h"
21 #include "CrFwOutStreamStub.h"
22 #include "CrFwRepErrStub.h"
23 /* Include FW Profile files */
24 #include "FwSmConstants.h"
25 #include "FwSmConfig.h"
26 #include "FwSmCore.h"
27 #include "FwPrConfig.h"
28 #include "FwPrCore.h"
29 #include "FwPrConstants.h"
30 /* Include configuration files */
31 #include "CrFwOutStreamUserPar.h"
32 #include "CrFwCmpData.h"
33 /* Include framework files */
35 #include "BaseCmp/CrFwBaseCmp.h"
37 #include "Pckt/CrFwPckt.h"
38 #include "CrFwTime.h"
39 #include "CrFwRepErr.h"
40 
41 /* ---------------------------------------------------------------------------------------------*/
43  FwSmDesc_t outStream0, outStreamBis;
44  CrFwPckt_t pckt, pckt1, pckt2;
45  CrFwCounterU2_t i, errRepPosLocal;
46 
47  /* Reset error reporting interface */
49 
50  /* Attempt to instantiate an OutStream with an illegal identifier */
52  return 0;
54  if (outStream0 != NULL)
55  return 0;
57  return 0;
58  CrFwSetAppErrCode(crNoAppErr); /* reset application error code */
59 
60  /* Create the first OutStream */
61  outStream0 = CrFwOutStreamMake(0);
62  if (outStream0 == NULL)
63  return 0;
64 
65  /* Create the first OutStream again and check that the same component is returned */
66  outStreamBis = CrFwOutStreamMake(0);
67  if (outStream0 != outStreamBis)
68  return 0;
69 
70  /* Check configuration of OutStream */
71  if (FwSmCheckRec(outStream0) != smSuccess)
72  return 0;
73 
74  if (FwPrCheck(CrFwCmpGetInitPr(outStream0)) != prSuccess)
75  return 0;
76 
77  if (FwPrCheck(CrFwCmpGetResetPr(outStream0)) != prSuccess)
78  return 0;
79 
80  if (FwPrCheck(CrFwCmpGetExecPr(outStream0)) != prSuccess)
81  return 0;
82 
83  /* Initialize and reset outStream and check success */
84  if (!CrFwCmpIsInCreated(outStream0))
85  return 0;
86 
87  CrFwCmpInit(outStream0);
88  if (!CrFwCmpIsInInitialized(outStream0))
89  return 0;
90 
91  CrFwCmpReset(outStream0);
92  if (!CrFwCmpIsInConfigured(outStream0))
93  return 0;
94  if (!CrFwOutStreamIsInReady(outStream0))
95  return 0;
96 
97  for (i=0; i<CrFwOutStreamGetNOfGroups(outStream0); i++)
98  if (CrFwOutStreamGetSeqCnt(outStream0,(CrFwGroup_t)i) != 1)
99  return 0;
100 
101  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
102  return 0;
103 
104  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
106 
107  /* Make a packet and assign it to the first group */
109  CrFwPcktSetGroup(pckt1,0);
110 
111  /* Send a packet to the OutStream and check outcome */
112  CrFwOutStreamSend(outStream0, pckt1);
113  if (!CrFwOutStreamIsInBuffering(outStream0))
114  return 0;
115  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 1)
116  return 0;
117  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
118  return 0;
119  if (CrFwPcktGetSeqCnt(pckt1) != 1)
120  return 0;
121  CrFwPcktRelease(pckt1);
122 
123  /* Fill up packet queue */
124  for (i=1; i<CrFwOutStreamGetPcktQueueSize(outStream0); i++) {
126  CrFwPcktSetGroup(pckt,0);
127  CrFwOutStreamSend(outStream0, pckt);
128  CrFwPcktRelease(pckt);
129  }
130  if (!CrFwOutStreamIsInBuffering(outStream0))
131  return 0;
132  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
133  return 0;
134  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
135  return 0;
136 
137  /* Make a new packet and send it (this overflows the packet queue) */
138  errRepPosLocal = CrFwRepErrStubGetPos();
140  for (i=1; i<CrFwPcktGetMaxLength(); i++)
141  pckt2[i] = 0; /* clear packet content */
142  CrFwOutStreamSend(outStream0, pckt2);
143  if (!CrFwOutStreamIsInBuffering(outStream0))
144  return 0;
145  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
146  return 0;
147  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
148  return 0;
149  if (CrFwPcktGetSeqCnt(pckt2) != 0)
150  return 0;
151  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
152  return 0;
153  if (CrFwRepErrStubGetErrCode(errRepPosLocal) != crOutStreamPQFull)
154  return 0;
155  if (CrFwRepErrStubGetTypeId(errRepPosLocal) != CR_FW_OUTSTREAM_TYPE)
156  return 0;
157  if (CrFwRepErrStubGetInstanceId(errRepPosLocal) != 0)
158  return 0;
159  CrFwPcktRelease(pckt2);
160 
161  /* Reset the OutStream */
162  CrFwCmpReset(outStream0);
163  if (!CrFwOutStreamIsInReady(outStream0))
164  return 0;
165  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
166  return 0;
167 
168  /* Shutdown the OutStream */
169  CrFwCmpShutdown(outStream0);
170 
171  if (CrFwCmpIsStarted(outStream0) != 0)
172  return 0;
173  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
174  return 0;
175 
176  /* Check that all packets have been de-allocated */
177  if (CrFwPcktGetNOfAllocated() != 0)
178  return 0;
179 
180  /* Check application errors */
181  if (CrFwGetAppErrCode() != crNoAppErr)
182  return 0;
183 
184  return 1;
185 }
186 
187 /* ---------------------------------------------------------------------------------------------*/
189  FwSmDesc_t outStream3;
190 
191  /* Create the fourth OutStream */
192  outStream3 = CrFwOutStreamMake(3);
193  if (outStream3 == NULL)
194  return 0;
195 
196  /* Configure initialization check and action until initialization succeeds */
199  if (!CrFwCmpIsInCreated(outStream3))
200  return 0;
201 
202  CrFwCmpInit(outStream3);
203  if (!CrFwCmpIsInCreated(outStream3))
204  return 0;
205 
208  CrFwCmpInit(outStream3);
209  if (!CrFwCmpIsInCreated(outStream3))
210  return 0;
211 
214  CrFwCmpInit(outStream3);
215  if (!CrFwCmpIsInCreated(outStream3))
216  return 0;
217 
220  CrFwCmpInit(outStream3);
221  if (!CrFwCmpIsInInitialized(outStream3))
222  return 0;
223 
224  /* Configure configuration check and action until configuration succeeds */
227  CrFwCmpReset(outStream3);
228  if (!CrFwCmpIsInInitialized(outStream3))
229  return 0;
230 
233  CrFwCmpReset(outStream3);
234  if (!CrFwCmpIsInInitialized(outStream3))
235  return 0;
236 
239  CrFwCmpReset(outStream3);
240  if (!CrFwCmpIsInInitialized(outStream3))
241  return 0;
242 
245  CrFwCmpReset(outStream3);
246  if (!CrFwCmpIsInConfigured(outStream3))
247  return 0;
248 
249  /* Configure configuration check and action to fail and then check that component reset fails */
251  CrFwCmpReset(outStream3);
252  if (!CrFwCmpIsInInitialized(outStream3))
253  return 0;
254 
255  /* Check application errors */
256  if (CrFwGetAppErrCode() != crNoAppErr)
257  return 0;
258 
259  return 1;
260 }
261 
262 /* ---------------------------------------------------------------------------------------------*/
264  FwSmDesc_t outStream0;
265  CrFwPckt_t pckt1, pckt2, pckt3, pckt;
267  CrFwCounterU2_t i;
268  CrFwCounterU2_t errRepPosLocal;
269 
270  /* Retrieve the first OutStream */
271  outStream0 = CrFwOutStreamMake(0);
272  if (outStream0 == NULL)
273  return 0;
274 
275  /* Check configuration of OutStream */
276  if (FwSmCheckRec(outStream0) != smSuccess)
277  return 0;
278 
279  /* Start, initialize and reset outStream and check its state */
280  FwSmStart(outStream0);
281  if (!CrFwCmpIsInCreated(outStream0))
282  return 0;
283 
284  CrFwCmpInit(outStream0);
285  if (!CrFwCmpIsInInitialized(outStream0))
286  return 0;
287 
288  CrFwCmpReset(outStream0);
289  if (!CrFwCmpIsInConfigured(outStream0))
290  return 0;
291  if (!CrFwOutStreamIsInReady(outStream0))
292  return 0;
293 
294  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
295  return 0;
296 
297  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
298  return 0;
299 
300  if (CrFwOutStreamGetDest(outStream0) != 1)
301  return 0;
302 
303  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
305 
306  /* Make a dummy packet and configure it to belong to the first group and
307  * with the source equal to the host application */
310  CrFwPcktSetGroup(pckt1,0);
311 
312  /* Send the packet to the OutStream and check outcome */
313  CrFwOutStreamSend(outStream0, pckt1);
314  if (!CrFwOutStreamIsInReady(outStream0))
315  return 0;
316  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
317  return 0;
318  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 2)
319  return 0;
320  if (CrFwPcktGetSeqCnt(pckt1) != 1)
321  return 0;
322  CrFwPcktRelease(pckt1);
323 
324  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
326 
327  /* Make, configure and send two more packets to the OutStream and check outcome */
330  CrFwPcktSetGroup(pckt2,0);
333  CrFwPcktSetGroup(pckt3,0);
334 
335  CrFwOutStreamSend(outStream0, pckt2);
336  if (!CrFwOutStreamIsInBuffering(outStream0))
337  return 0;
338  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 1)
339  return 0;
340  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 2)
341  return 0;
342  CrFwOutStreamSend(outStream0, pckt3);
343  if (!CrFwOutStreamIsInBuffering(outStream0))
344  return 0;
345  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 2)
346  return 0;
347  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 2)
348  return 0;
349  CrFwPcktRelease(pckt2);
350  CrFwPcktRelease(pckt3);
351 
352  /* Empty the packet factory and then attempt to send one more packet to the OutStream
353  * and verify that this results in error crOutStreamNoMorePckt */
354  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
355  pcktArray[i] = CrFwPcktMake(CrFwPcktGetMaxLength());
356 
357  errRepPosLocal = CrFwRepErrStubGetPos(); /* Store the current value of the error report counter */
358  CrFwOutStreamSend(outStream0, pcktArray[0]);
359  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
360  return 0;
362  return 0;
364  return 0;
365 
366  CrFwSetAppErrCode(crNoAppErr); /* Reset application error code */
367 
368  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
369  if (pcktArray[i] != NULL)
370  CrFwPcktRelease(pcktArray[i]);
371 
372  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
374 
375  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
376  CrFwOutStreamConnectionAvail(outStream0);
377  if (!CrFwOutStreamIsInReady(outStream0))
378  return 0;
379  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
380  return 0;
381  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 4)
382  return 0;
383 
384  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
386 
387  /* Fill up packet queue */
388  for (i=0; i<CrFwOutStreamGetPcktQueueSize(outStream0); i++) {
390  CrFwPcktSetGroup(pckt,0);
391  CrFwOutStreamSend(outStream0, pckt);
392  CrFwPcktRelease(pckt);
393  }
394  if (!CrFwOutStreamIsInBuffering(outStream0))
395  return 0;
396  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
397  return 0;
398 
399  /* Send the Connection Available signal to the OutStream and check that PQ is not flushed */
400  CrFwOutStreamConnectionAvail(outStream0);
401  if (!CrFwOutStreamIsInBuffering(outStream0))
402  return 0;
403  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
404  return 0;
405 
406  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
408 
409  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
410  CrFwOutStreamConnectionAvail(outStream0);
411  if (!CrFwOutStreamIsInReady(outStream0))
412  return 0;
413  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
414  return 0;
415 
416  /* Configure the middleware to be not ready to receive packets,
417  * empty the packet factory and then attempt to send one more packet to the OutStream
418  * and verify that this results in error crOutStreamNoMorePckt */
420 
421  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
422  pcktArray[i] = CrFwPcktMake(CrFwPcktGetMaxLength());
423 
424  errRepPosLocal = CrFwRepErrStubGetPos(); /* Store the current value of the error report counter */
425  CrFwOutStreamSend(outStream0, pcktArray[0]);
426  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
427  return 0;
429  return 0;
431  return 0;
432  if (!CrFwOutStreamIsInReady(outStream0))
433  return 0;
434  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
435  return 0;
436 
437  CrFwSetAppErrCode(crNoAppErr); /* Reset application error code */
438 
439  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
440  if (pcktArray[i] != NULL)
441  CrFwPcktRelease(pcktArray[i]);
442 
443  /* Reset the OutStream and check new state */
444  CrFwCmpReset(outStream0);
445  if (!CrFwOutStreamIsInReady(outStream0))
446  return 0;
447  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
448  return 0;
449 
450  /* Check that all packets have been de-allocated */
451  if (CrFwPcktGetNOfAllocated() != 0)
452  return 0;
453 
454  /* Check application errors */
455  if (CrFwGetAppErrCode() != crNoAppErr)
456  return 0;
457 
458  /* Shutdown the OutStream (the packets are released when they are flushed) */
459  CrFwCmpShutdown(outStream0);
460  /* FwSmStop(outStream0); */
461 
462  return 1;
463 }
464 
465 /* ---------------------------------------------------------------------------------------------*/
467  FwSmDesc_t outStream[CR_FW_NOF_OUTSTREAM];
470 
471  /* Initialize the destinations (the initialization values must be the same as
472  specified in <code>CrFwOutStreamUserPar.h</code>). */
473  for (i=0; i<CR_FW_NOF_OUTSTREAM; i++)
474  dest[i] = (CrFwDestSrc_t)(i+1);
475 
476  /* Make the OutStreams and associate them to their destinations */
477  for (i=0; i<CR_FW_NOF_OUTSTREAM; i++)
478  outStream[i] = CrFwOutStreamMake(i);
479 
480  /* Retrieve the OutStream from their destinations */
481  for (i=0; i<CR_FW_NOF_OUTSTREAM; i++) {
482  if (CrFwOutStreamGet(dest[i]) != outStream[i])
483  return 0;
484  }
485  if (CrFwGetAppErrCode() != crNoAppErr)
486  return 0;
487 
488  /* Check response to non-existent destination */
489  if (CrFwOutStreamGet(CR_FW_NOF_OUTSTREAM+1) != NULL)
490  return 0;
492  return 0;
493  CrFwSetAppErrCode(crNoAppErr); /* reset application error code */
494 
495  return 1;
496 }
497 
498 /* ---------------------------------------------------------------------------------------------*/
500  FwSmDesc_t outStream1;
501  CrFwCounterU1_t nShutdown;
502 
503  /* Create the first InStream */
504  outStream1 = CrFwOutStreamMake(1);
505  if (outStream1 == NULL)
506  return 0;
507 
508  /* Retrieve the shutdown counter for the OutStream Stub */
509  nShutdown = CrFwOutStreamStubGetShutdownCnt();
510 
511  /* Bring OutStream to state CONFIGURED */
512  if (CrFwCmpIsStarted(outStream1) == 0)
513  FwSmStart(outStream1);
514  CrFwCmpInit(outStream1);
515  CrFwCmpReset(outStream1);
516  if (!CrFwCmpIsInConfigured(outStream1))
517  return 0;
518 
519  /* Shutdown the newly-created InStream */
520  CrFwCmpShutdown(outStream1);
521  if (CrFwOutStreamStubGetShutdownCnt() != nShutdown+1)
522  return 0;
523 
524  if (CrFwCmpIsStarted(outStream1) != 0)
525  return 0;
526 
527  /* Check application errors */
528  if (CrFwGetAppErrCode() != crNoAppErr)
529  return 0;
530 
531  return 1;
532 }
533 
534 /* ---------------------------------------------------------------------------------------------*/
536  FwSmDesc_t outStream0;
537  CrFwPckt_t pckt1, pckt2, pckt3, pckt;
538  CrFwCounterU2_t i;
539 
540  /* Retrieve the first OutStream */
541  outStream0 = CrFwOutStreamMake(0);
542  if (outStream0 == NULL)
543  return 0;
544 
545  /* Check configuration of OutStream */
546  if (FwSmCheckRec(outStream0) != smSuccess)
547  return 0;
548 
549  /* Start, initialize and reset outStream and check its state */
550  FwSmStart(outStream0);
551  CrFwCmpInit(outStream0);
552  CrFwCmpReset(outStream0);
553  if (!CrFwCmpIsInConfigured(outStream0))
554  return 0;
555  if (!CrFwOutStreamIsInReady(outStream0))
556  return 0;
557 
558  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
559  return 0;
560 
561  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
562  return 0;
563 
564  if (CrFwOutStreamGetDest(outStream0) != 1)
565  return 0;
566 
567  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
569 
570  /* Make a dummy packet and configure it with the source equal to an external application */
573 
574  /* Set the sequence counter of the packet */
575  CrFwPcktSetSeqCnt(pckt1,100);
576 
577  /* Send the packet to the OutStream and check outcome */
578  CrFwOutStreamSend(outStream0, pckt1);
579  if (!CrFwOutStreamIsInReady(outStream0))
580  return 0;
581  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
582  return 0;
583  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
584  return 0;
585  if (CrFwPcktGetSeqCnt(pckt1) != 100)
586  return 0;
587  CrFwPcktRelease(pckt1);
588 
589  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
591 
592  /* Make, configure and send two more packets to the OutStream and check outcome */
595  CrFwPcktSetSeqCnt(pckt2,101);
598  CrFwPcktSetSeqCnt(pckt3,102);
599 
600  CrFwOutStreamSend(outStream0, pckt2);
601  if (!CrFwOutStreamIsInBuffering(outStream0))
602  return 0;
603  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 1)
604  return 0;
605  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
606  return 0;
607  CrFwOutStreamSend(outStream0, pckt3);
608  if (!CrFwOutStreamIsInBuffering(outStream0))
609  return 0;
610  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 2)
611  return 0;
612  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
613  return 0;
614  CrFwPcktRelease(pckt2);
615  CrFwPcktRelease(pckt3);
616 
617  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
619 
620  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
621  CrFwOutStreamConnectionAvail(outStream0);
622  if (!CrFwOutStreamIsInReady(outStream0))
623  return 0;
624  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
625  return 0;
626  if (CrFwOutStreamGetSeqCnt(outStream0,0) != 1)
627  return 0;
628  if (CrFwPcktGetSeqCnt(pckt2) != 101)
629  return 0;
630  if (CrFwPcktGetSeqCnt(pckt3) != 102)
631  return 0;
632 
633  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
635 
636  /* Fill up packet queue */
637  for (i=0; i<CrFwOutStreamGetPcktQueueSize(outStream0); i++) {
640  CrFwPcktSetSeqCnt(pckt,111);
641  CrFwOutStreamSend(outStream0, pckt);
642  CrFwPcktRelease(pckt);
643  }
644  if (!CrFwOutStreamIsInBuffering(outStream0))
645  return 0;
646  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
647  return 0;
648 
649  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
651 
652  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
653  CrFwOutStreamConnectionAvail(outStream0);
654  if (!CrFwOutStreamIsInReady(outStream0))
655  return 0;
656  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
657  return 0;
658 
659  /* Reset the OutStream and check new state */
660  CrFwCmpReset(outStream0);
661  if (!CrFwOutStreamIsInReady(outStream0))
662  return 0;
663  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
664  return 0;
665 
666  /* Check that all packets have been de-allocated */
667  if (CrFwPcktGetNOfAllocated() != 0)
668  return 0;
669 
670  /* Check application errors */
671  if (CrFwGetAppErrCode() != crNoAppErr)
672  return 0;
673 
674  /* Stop the OutStream (the packets are released when they are flushed) */
675  FwSmStop(outStream0);
676 
677  return 1;
678 }
679 
680 /* ---------------------------------------------------------------------------------------------*/
682  FwSmDesc_t outStream1;
683  CrFwPckt_t pckt1, pckt2, pckt3;
684  CrFwCounterU2_t errRepPosLocal;
685 
686  /* Retrieve the second OutStream */
687  outStream1 = CrFwOutStreamMake(1);
688  if (outStream1 == NULL)
689  return 0;
690 
691  /* Retrieve error report counter */
692  errRepPosLocal = CrFwRepErrStubGetPos();
693 
694  /* Check configuration of OutStream */
695  if (FwSmCheckRec(outStream1) != smSuccess)
696  return 0;
697 
698  /* Check number of groups of OutStream (this is set in CrFwOutStreamUserPar.h */
699  if (CrFwOutStreamGetNOfGroups(outStream1)!=2)
700  return 0;
701 
702  /* Start, initialize and reset outStream and check its state */
703  FwSmStart(outStream1);
704  CrFwCmpInit(outStream1);
705  CrFwCmpReset(outStream1);
706  if (!CrFwCmpIsInConfigured(outStream1))
707  return 0;
708  if (!CrFwOutStreamIsInReady(outStream1))
709  return 0;
710 
711  if (CrFwOutStreamGetSeqCnt(outStream1,0) != 1)
712  return 0;
713 
714  if (CrFwOutStreamGetSeqCnt(outStream1,1) != 1)
715  return 0;
716 
717  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
718  return 0;
719 
720  if (CrFwOutStreamGetDest(outStream1) != 2)
721  return 0;
722 
723  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
725 
726  /* Make three dummy packets, configure them to belong to the first, second and third group and
727  * with the source equal to the host application */
730  CrFwPcktSetGroup(pckt1,0);
731  CrFwPcktSetSeqCnt(pckt1,99);
734  CrFwPcktSetGroup(pckt2,1);
735  CrFwPcktSetSeqCnt(pckt2,99);
738  CrFwPcktSetGroup(pckt3,88); /* non-existent group */
739  CrFwPcktSetSeqCnt(pckt3,99);
740 
741  /* Send the packets to the OutStream and check outcome */
742  CrFwOutStreamSetSeqCnt(outStream1, 1, 2222);
743  CrFwOutStreamSend(outStream1, pckt1);
744  CrFwOutStreamSend(outStream1, pckt2);
745  CrFwOutStreamSend(outStream1, pckt3);
746  if (!CrFwOutStreamIsInReady(outStream1))
747  return 0;
748  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
749  return 0;
750  if (CrFwOutStreamGetSeqCnt(outStream1,0) != 2)
751  return 0;
752  if (CrFwOutStreamGetSeqCnt(outStream1,1) != 2223)
753  return 0;
754  if (CrFwPcktGetSeqCnt(pckt1) != 1)
755  return 0;
756  if (CrFwPcktGetSeqCnt(pckt2) != 2222)
757  return 0;
758  if (CrFwPcktGetSeqCnt(pckt3) != 99)
759  return 0;
760  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
761  return 0;
762  if (CrFwRepErrStubGetErrCode(errRepPosLocal) != crOutStreamIllGroup)
763  return 0;
764  CrFwPcktRelease(pckt1);
765  CrFwPcktRelease(pckt2);
766  CrFwPcktRelease(pckt3);
767 
768  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
770 
771  /* Make, configure and send three more packets to the OutStream and check outcome */
774  CrFwPcktSetGroup(pckt1,0);
775  CrFwPcktSetSeqCnt(pckt1,99);
778  CrFwPcktSetGroup(pckt2,1);
779  CrFwPcktSetSeqCnt(pckt2,99);
782  CrFwPcktSetGroup(pckt3,88); /* non-existent group */
783  CrFwPcktSetSeqCnt(pckt3,99);
784 
785  CrFwOutStreamSend(outStream1, pckt1);
786  CrFwOutStreamSend(outStream1, pckt2);
787  CrFwOutStreamSend(outStream1, pckt3);
788  if (!CrFwOutStreamIsInBuffering(outStream1))
789  return 0;
790  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 3)
791  return 0;
792  if (CrFwOutStreamGetSeqCnt(outStream1,0) != 2)
793  return 0;
794  if (CrFwOutStreamGetSeqCnt(outStream1,1) != 2223)
795  return 0;
796  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
797  return 0;
798  CrFwPcktRelease(pckt1);
799  CrFwPcktRelease(pckt2);
800  CrFwPcktRelease(pckt3);
801 
802  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
804 
805  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
806  CrFwOutStreamConnectionAvail(outStream1);
807  if (!CrFwOutStreamIsInReady(outStream1))
808  return 0;
809  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
810  return 0;
811  if (CrFwOutStreamGetSeqCnt(outStream1,0) != 3)
812  return 0;
813  if (CrFwOutStreamGetSeqCnt(outStream1,1) != 2224)
814  return 0;
815  if (CrFwRepErrStubGetPos() != errRepPosLocal+2)
816  return 0;
817  if (CrFwRepErrStubGetErrCode(errRepPosLocal) != crOutStreamIllGroup)
818  return 0;
819 
820  /* Reset the OutStream and check new state */
821  CrFwCmpReset(outStream1);
822  if (!CrFwOutStreamIsInReady(outStream1))
823  return 0;
824  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
825  return 0;
826 
827  /* Check that all packets have been de-allocated */
828  if (CrFwPcktGetNOfAllocated() != 0)
829  return 0;
830 
831  /* Check application errors */
832  if (CrFwGetAppErrCode() != crNoAppErr)
833  return 0;
834 
835  /* Stop the OutStream (the packets are released when they are flushed) */
836  FwSmStop(outStream1);
837 
838  return 1;
839 }
840 
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
CrFwBool_t CrFwOutStreamTestCase1()
Test the initialization and packet queue (PQ) management of the OutStream.
Interface through which framework components access the current time.
void CrFwOutStreamSend(FwSmDesc_t smDesc, CrFwPckt_t pckt)
Send a packet to the OutStream.
unsigned short CrFwInstanceId_t
Type used for instance identifiers.
void CrFwPcktSetSrc(CrFwPckt_t pckt, CrFwDestSrc_t src)
Set the source of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:321
void CrFwPcktSetGroup(CrFwPckt_t pckt, CrFwGroup_t group)
Set the group of the command/report encapsulated in a packet.
Definition: CrFwPckt.c:392
CrFwBool_t CrFwOutStreamTestCase2()
Test the OutStream with overridden initialization check and initialization action.
void CrFwCmpInit(FwSmDesc_t smDesc)
Initialize a framework component.
Definition: CrFwBaseCmp.c:112
Definition of the Framework Component Data (FCD) Type.
CrFwCounterU1_t CrFwOutStreamGetNOfPendingPckts(FwSmDesc_t smDesc)
Return the number of packets currently in the packet queue of an OutStream.
CrFwGroup_t CrFwOutStreamGetNOfGroups(FwSmDesc_t smDesc)
Return the number of groups associated to the OutStream.
#define CR_FW_NOF_OUTSTREAM
The number of OutStream components in the application.
FwPrDesc_t CrFwCmpGetExecPr(FwSmDesc_t smDesc)
Return the descriptor of the Execution Procedure of the argument component.
Definition: CrFwBaseCmp.c:144
CrFwBool_t CrFwCmpIsInConfigured(FwSmDesc_t smDesc)
Return true if the argument component is in state CONFIGURED.
Definition: CrFwBaseCmp.c:177
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
#define CR_FW_HOST_APP_ID
The identifier of the host application.
Interface for the OutStream stub.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:38
CrFwBool_t CrFwCmpIsInCreated(FwSmDesc_t smDesc)
Return true if the argument component is in state CREATED.
Definition: CrFwBaseCmp.c:167
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Definition: CrFwPckt.c:129
CrFwSeqCnt_t CrFwPcktGetSeqCnt(CrFwPckt_t pckt)
Return the sequence counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:223
Definition of the OutStream component.
Interface for creating and accessing a report or command packet.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
#define CR_FW_MAX_NOF_PCKTS
The maximum number of packets which can be created with the default packet implementation.
unsigned char CrFwGroup_t
Type used for the destination or source group of a packet.
static unsigned char pcktArray[CR_FW_MAX_NOF_PCKTS *CR_FW_MAX_PCKT_LENGTH]
The array holding the packets.
Definition: CrFwPckt.c:68
CrFwBool_t CrFwOutStreamTestCase3()
Test the packet flushing functionality of an OutStream for a packet originating from the host applica...
void CrFwPcktRelease(CrFwPckt_t pckt)
Release function for command or report packets.
Definition: CrFwPckt.c:156
A framework function has been called with an illegal OutStream identifier.
void CrFwRepErrStubReset()
Reset the error reporting interface.
Definition: CrFwRepErr.c:76
CrFwBool_t CrFwCmpIsInInitialized(FwSmDesc_t smDesc)
Return true if the argument component is in state INITIALIZED.
Definition: CrFwBaseCmp.c:172
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
An OutComponent has an illegal group.
An OutStream cannot buffer an out-going packet because no more packets are available (see CrFwOutStre...
void CrFwOutStreamConnectionAvail(FwSmDesc_t smDesc)
Signal that the out-going middleware connection has become available.
Interface for reporting an error detected by a framework component.
CrFwTypeId_t CrFwRepErrStubGetTypeId(CrFwCounterU2_t errRepPos)
Return the type identifier of the error report at position errRepPos.
Definition: CrFwRepErr.c:264
CrFwBool_t CrFwOutStreamIsInBuffering(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state BUFFERING.
CrFwCounterU1_t CrFwOutStreamGetPcktQueueSize(FwSmDesc_t smDesc)
Return the size of the packet queue of the OutStream.
CrFwRepErrCode_t CrFwRepErrStubGetErrCode(CrFwCounterU2_t errRepPos)
Return the error code of the error report at position errRepPos.
Definition: CrFwRepErr.c:259
The packet queue of an OutStream is full (see CrFwOutStream.h)
CrFwSeqCnt_t CrFwOutStreamGetSeqCnt(FwSmDesc_t smDesc, CrFwGroup_t group)
Return the value of the sequence counter for one of the groups maintained by an OutStream.
unsigned short CrFwCounterU2_t
Type used for unsigned integers with a "medium" range.
void CrFwOutStreamStubSetCheckFlag(CrFwBool_t flag)
Set the value of the check flag which determines the outcome of the dummy check of CrFwOutStreamStubD...
Declaration of the test cases for the OutStream Component (see CrFwOutStream.h).
Definition of the utility functions for the CORDET Framework.
FwSmDesc_t CrFwOutStreamGet(CrFwDestSrc_t dest)
Getter function for the OutStream corresponding to the argument destination.
CrFwPcktLength_t CrFwPcktGetMaxLength()
Return the maximum length of a packet in number of bytes.
Definition: CrFwPckt.c:201
FwPrDesc_t CrFwCmpGetInitPr(FwSmDesc_t smDesc)
Return the descriptor of the Initialization Procedure of the argument component.
Definition: CrFwBaseCmp.c:132
FwPrDesc_t CrFwCmpGetResetPr(FwSmDesc_t smDesc)
Return the descriptor of the Reset Procedure of the argument component.
Definition: CrFwBaseCmp.c:138
A framework function has been called with a destination attribute which is not associated to any OutS...
void CrFwOutStreamStubSetHandoverFlag(CrFwBool_t flag)
Set the value of the handover flag which determines the outcome of the packet handover in CrFwOutStre...
void CrFwOutStreamSetSeqCnt(FwSmDesc_t smDesc, CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
Sets the value of the sequence counter for one of the groups maintained by an OutStream.
CrFwBool_t CrFwOutStreamTestCase5()
Test the Shutdown Operation of an OutStream.
void CrFwCmpReset(FwSmDesc_t smDesc)
Reset a framework component.
Definition: CrFwBaseCmp.c:117
Definition of Base Component.
CrFwBool_t CrFwCmpIsStarted(FwSmDesc_t smDesc)
Return true if the state machine of the argument component has been started.
Definition: CrFwBaseCmp.c:162
static CrFwDestSrc_t dest
Destination.
The CORDET Framework defines an interface for generating error reports (see CrFwRepErr.h).
CrFwCounterU2_t CrFwPcktGetNOfAllocated()
Return the number of packets which are currently allocated.
Definition: CrFwPckt.c:196
CrFwDestSrc_t CrFwOutStreamGetDest(FwSmDesc_t smDesc)
Get the destination for an OutStream.
CrFwBool_t CrFwOutStreamTestCase4()
Test the registry functionality of an OutStream.
FwSmDesc_t CrFwOutStreamMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th OutStream State Machine instance.
CrFwBool_t CrFwOutStreamTestCase7()
Test the management of the sequence counters for different groups.
CrFwCounterU2_t CrFwRepErrStubGetPos()
Return the position in the error report array at which the next error report will be written...
Definition: CrFwRepErr.c:71
CrFwBool_t CrFwOutStreamIsInReady(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state READY.
void CrFwOutStreamStubSetActionFlag(CrFwBool_t flag)
Set the value of the action flag which determines the outcome of the initialization of configuration ...
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:229
#define CR_FW_OUTSTREAM_TYPE
Type identifier for the OutStream components.
User-modifiable parameters for the OutStream components (see CrFwOutStream.h).
CrFwInstanceId_t CrFwRepErrStubGetInstanceId(CrFwCounterU2_t errRepPos)
Return the type identifier of the error report at position errRepPos.
Definition: CrFwRepErr.c:269
CrFwCounterU1_t CrFwOutStreamStubGetShutdownCnt()
Return the value of the shutdown counter which is incremented by the packet shutdown function in CrFw...
void CrFwCmpShutdown(FwSmDesc_t smDesc)
Shutdown a framework component.
Definition: CrFwBaseCmp.c:122
No application errors have been detected.
CrFwBool_t CrFwOutStreamTestCase6()
Test the packet flushing functionality of an OutStream for a re-routed packet (as opposed to a packet...
CrFwAppErrCode_t CrFwGetAppErrCode()
Return the value of the application error code.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved