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  /* Check that the type counter array has not yet been instantiated */
62  return 0;
63 
64  /* Create the first OutStream */
65  outStream0 = CrFwOutStreamMake(0);
66  if (outStream0 == NULL)
67  return 0;
68 
69  /* Check that the type counter array has been instantiated
70  (expected number is number of (type.sub-type) pairs defined in OutFactoryUserPar.h) )*/
72  return 0;
73 
74  /* Create the first OutStream again and check that the same component is returned */
75  outStreamBis = CrFwOutStreamMake(0);
76  if (outStream0 != outStreamBis)
77  return 0;
78 
79  /* Check configuration of OutStream */
80  if (FwSmCheckRec(outStream0) != smSuccess)
81  return 0;
82 
83  if (FwPrCheck(CrFwCmpGetInitPr(outStream0)) != prSuccess)
84  return 0;
85 
86  if (FwPrCheck(CrFwCmpGetResetPr(outStream0)) != prSuccess)
87  return 0;
88 
89  if (FwPrCheck(CrFwCmpGetExecPr(outStream0)) != prSuccess)
90  return 0;
91 
92  /* Initialize and reset outStream and check success */
93  if (!CrFwCmpIsInCreated(outStream0))
94  return 0;
95 
96  CrFwCmpInit(outStream0);
97  if (!CrFwCmpIsInInitialized(outStream0))
98  return 0;
99 
100  CrFwCmpReset(outStream0);
101  if (!CrFwCmpIsInConfigured(outStream0))
102  return 0;
103  if (!CrFwOutStreamIsInReady(outStream0))
104  return 0;
105 
106  for (i=0; i<CrFwOutStreamGetNOfGroups(); i++)
107  if (CrFwOutStreamGetSeqCnt((CrFwGroup_t)i) != 1)
108  return 0;
109 
110  /* Check the association between destination and outStream
111  (the (dest,outStream) pairs are defined in CR_FW_OUTSTREAM_DEST_PAIRS)*/
112  if (CrFwOutStreamGetNOfDest(outStream0) != 2)
113  return 0;
114  if (CrFwOutStreamGetDest(outStream0,1) != 1)
115  return 0;
116  if (CrFwOutStreamGetDest(outStream0,2) != 2)
117  return 0;
118 
119  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
120  return 0;
121 
122  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
124 
125  /* Make a packet and assign it to the first group */
127  CrFwPcktSetGroup(pckt1,0);
128  CrFwPcktSetTypeCnt(pckt1,0);
129  CrFwPcktSetSeqCnt(pckt1,0);
130 
131  /* Send a packet to the OutStream and check outcome */
132  CrFwOutStreamSend(outStream0, pckt1);
133  if (!CrFwOutStreamIsInBuffering(outStream0))
134  return 0;
135  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 1)
136  return 0;
137  if (CrFwOutStreamGetSeqCnt(0) != 1)
138  return 0;
139  if (CrFwPcktGetSeqCnt(pckt1) != 0)
140  return 0;
141  if (CrFwPcktGetTypeCnt(pckt1) != 0)
142  return 0;
143  CrFwPcktRelease(pckt1);
144 
145  /* Fill up packet queue */
146  for (i=1; i<CrFwOutStreamGetPcktQueueSize(outStream0); i++) {
148  CrFwPcktSetGroup(pckt,0);
149  CrFwOutStreamSend(outStream0, pckt);
150  CrFwPcktRelease(pckt);
151  }
152  if (!CrFwOutStreamIsInBuffering(outStream0))
153  return 0;
154  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
155  return 0;
156  if (CrFwOutStreamGetSeqCnt(0) != 1)
157  return 0;
158 
159  /* Make a new packet and send it (this overflows the packet queue) */
160  errRepPosLocal = CrFwRepErrStubGetPos();
162  for (i=1; i<CrFwPcktGetMaxLength(); i++)
163  pckt2[i] = 0; /* clear packet content */
164  CrFwOutStreamSend(outStream0, pckt2);
165  if (!CrFwOutStreamIsInBuffering(outStream0))
166  return 0;
167  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
168  return 0;
169  if (CrFwOutStreamGetSeqCnt(0) != 1)
170  return 0;
171  if (CrFwPcktGetSeqCnt(pckt2) != 0)
172  return 0;
173  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
174  return 0;
175  if (CrFwRepErrStubGetErrCode(errRepPosLocal) != crOutStreamPQFull)
176  return 0;
177  if (CrFwRepErrStubGetTypeId(errRepPosLocal) != CR_FW_OUTSTREAM_TYPE)
178  return 0;
179  if (CrFwRepErrStubGetInstanceId(errRepPosLocal) != 0)
180  return 0;
181  CrFwPcktRelease(pckt2);
182 
183  /* Reset the OutStream */
184  CrFwCmpReset(outStream0);
185  if (!CrFwOutStreamIsInReady(outStream0))
186  return 0;
187  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
188  return 0;
189 
190  /* Shutdown the OutStream */
191  CrFwCmpShutdown(outStream0);
192 
193  if (CrFwCmpIsStarted(outStream0) != 0)
194  return 0;
195  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
196  return 0;
197  if (CrFwOutStreamGetNOfDest(outStream0) != 0)
198  return 0;
199 
200  /* Check that all packets have been de-allocated */
201  if (CrFwPcktGetNOfAllocated() != 0)
202  return 0;
203 
204  /* Check application errors */
205  if (CrFwGetAppErrCode() != crNoAppErr)
206  return 0;
207 
208  return 1;
209 }
210 
211 /* ---------------------------------------------------------------------------------------------*/
213  FwSmDesc_t outStream3;
214 
215  /* Create the fourth OutStream */
216  outStream3 = CrFwOutStreamMake(3);
217  if (outStream3 == NULL)
218  return 0;
219 
220  /* Configure initialization check and action until initialization succeeds */
223  if (!CrFwCmpIsInCreated(outStream3))
224  return 0;
225 
226  CrFwCmpInit(outStream3);
227  if (!CrFwCmpIsInCreated(outStream3))
228  return 0;
229 
230  /* Shut down InStream to prevent memory leak when the component is initialized again */
231  CrFwCmpShutdown(outStream3);
232 
235  CrFwCmpInit(outStream3);
236  if (!CrFwCmpIsInCreated(outStream3))
237  return 0;
238 
239  /* Shut down InStream to prevent memory leak when the component is initialized again */
240  CrFwCmpShutdown(outStream3);
241 
244  CrFwCmpInit(outStream3);
245  if (!CrFwCmpIsInCreated(outStream3))
246  return 0;
247 
248  /* Shut down InStream to prevent memory leak when the component is initialized again */
249  CrFwCmpShutdown(outStream3);
250 
253  CrFwCmpInit(outStream3);
254  if (!CrFwCmpIsInInitialized(outStream3))
255  return 0;
256 
257  /* Configure configuration check and action until configuration succeeds */
260  CrFwCmpReset(outStream3);
261  if (!CrFwCmpIsInInitialized(outStream3))
262  return 0;
263 
266  CrFwCmpReset(outStream3);
267  if (!CrFwCmpIsInInitialized(outStream3))
268  return 0;
269 
272  CrFwCmpReset(outStream3);
273  if (!CrFwCmpIsInInitialized(outStream3))
274  return 0;
275 
278  CrFwCmpReset(outStream3);
279  if (!CrFwCmpIsInConfigured(outStream3))
280  return 0;
281 
282  /* Configure configuration check and action to fail and then check that component reset fails */
284  CrFwCmpReset(outStream3);
285  if (!CrFwCmpIsInInitialized(outStream3))
286  return 0;
287 
288  /* Shut down OutStream */
289  CrFwCmpShutdown(outStream3);
290 
291  /* Check application errors */
292  if (CrFwGetAppErrCode() != crNoAppErr)
293  return 0;
294 
295  return 1;
296 }
297 
298 /* ---------------------------------------------------------------------------------------------*/
300  FwSmDesc_t outStream0;
301  CrFwPckt_t pckt1, pckt2, pckt3, pckt;
303  CrFwCounterU2_t i;
304  CrFwCounterU2_t errRepPosLocal;
305 
306  /* Retrieve the first OutStream */
307  outStream0 = CrFwOutStreamMake(0);
308  if (outStream0 == NULL)
309  return 0;
310 
311  /* Check configuration of OutStream */
312  if (FwSmCheckRec(outStream0) != smSuccess)
313  return 0;
314 
315  /* Start, initialize and reset outStream and check its state */
316  FwSmStart(outStream0);
317  if (!CrFwCmpIsInCreated(outStream0))
318  return 0;
319  CrFwCmpInit(outStream0);
320  if (!CrFwCmpIsInInitialized(outStream0))
321  return 0;
322  CrFwCmpReset(outStream0);
323  if (!CrFwCmpIsInConfigured(outStream0))
324  return 0;
325  if (!CrFwOutStreamIsInReady(outStream0))
326  return 0;
327  if (CrFwOutStreamGetSeqCnt(0) != 1)
328  return 0;
329  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
330  return 0;
331 
332  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
334 
335  /* Make a dummy packet and configure it to belong to the first group and
336  * with the source equal to the host application */
339  CrFwPcktSetGroup(pckt1,0);
340 
341  /* Send the packet to the OutStream and check outcome */
342  CrFwOutStreamSend(outStream0, pckt1);
343  if (!CrFwOutStreamIsInReady(outStream0))
344  return 0;
345  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
346  return 0;
347  if (CrFwOutStreamGetSeqCnt(0) != 2)
348  return 0;
349  if (CrFwPcktGetSeqCnt(pckt1) != 1)
350  return 0;
351  CrFwPcktRelease(pckt1);
352 
353  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
355 
356  /* Make, configure and send two more packets to the OutStream and check outcome */
359  CrFwPcktSetGroup(pckt2,0);
362  CrFwPcktSetGroup(pckt3,0);
363 
364  CrFwOutStreamSend(outStream0, pckt2);
365  if (!CrFwOutStreamIsInBuffering(outStream0))
366  return 0;
367  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 1)
368  return 0;
369  if (CrFwOutStreamGetSeqCnt(0) != 2)
370  return 0;
371  CrFwOutStreamSend(outStream0, pckt3);
372  if (!CrFwOutStreamIsInBuffering(outStream0))
373  return 0;
374  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 2)
375  return 0;
376  if (CrFwOutStreamGetSeqCnt(0) != 2)
377  return 0;
378  CrFwPcktRelease(pckt2);
379  CrFwPcktRelease(pckt3);
380 
381  /* Empty the packet factory and then attempt to send one more packet to the OutStream
382  * and verify that this results in error crOutStreamNoMorePckt */
383  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
385 
386  errRepPosLocal = CrFwRepErrStubGetPos(); /* Store the current value of the error report counter */
387  CrFwOutStreamSend(outStream0, pcktArray[0]);
388  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
389  return 0;
391  return 0;
393  return 0;
394 
395  CrFwSetAppErrCode(crNoAppErr); /* Reset application error code */
396 
397  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
398  if (pcktArray[i] != NULL)
400 
401  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
403 
404  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
405  CrFwOutStreamConnectionAvail(outStream0);
406  if (!CrFwOutStreamIsInReady(outStream0))
407  return 0;
408  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
409  return 0;
410  if (CrFwOutStreamGetSeqCnt(0) != 4)
411  return 0;
412 
413  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
415 
416  /* Fill up packet queue */
417  for (i=0; i<CrFwOutStreamGetPcktQueueSize(outStream0); i++) {
419  CrFwPcktSetGroup(pckt,0);
420  CrFwOutStreamSend(outStream0, pckt);
421  CrFwPcktRelease(pckt);
422  }
423  if (!CrFwOutStreamIsInBuffering(outStream0))
424  return 0;
425  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
426  return 0;
427 
428  /* Send the Connection Available signal to the OutStream and check that PQ is not flushed */
429  CrFwOutStreamConnectionAvail(outStream0);
430  if (!CrFwOutStreamIsInBuffering(outStream0))
431  return 0;
432  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
433  return 0;
434 
435  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
437 
438  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
439  CrFwOutStreamConnectionAvail(outStream0);
440  if (!CrFwOutStreamIsInReady(outStream0))
441  return 0;
442  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
443  return 0;
444 
445  /* Configure the middleware to be not ready to receive packets,
446  * empty the packet factory and then attempt to send one more packet to the OutStream
447  * and verify that this results in error crOutStreamNoMorePckt */
449 
450  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
452 
453  errRepPosLocal = CrFwRepErrStubGetPos(); /* Store the current value of the error report counter */
454  CrFwOutStreamSend(outStream0, pcktArray[0]);
455  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
456  return 0;
458  return 0;
460  return 0;
461  if (!CrFwOutStreamIsInReady(outStream0))
462  return 0;
463  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
464  return 0;
465 
466  CrFwSetAppErrCode(crNoAppErr); /* Reset application error code */
467 
468  for (i=0; i<CR_FW_MAX_NOF_PCKTS; i++)
469  if (pcktArray[i] != NULL)
471 
472  /* Reset the OutStream and check new state */
473  CrFwCmpReset(outStream0);
474  if (!CrFwOutStreamIsInReady(outStream0))
475  return 0;
476  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
477  return 0;
478 
479  /* Check that all packets have been de-allocated */
480  if (CrFwPcktGetNOfAllocated() != 0)
481  return 0;
482 
483  /* Check application errors */
484  if (CrFwGetAppErrCode() != crNoAppErr)
485  return 0;
486 
487  /* Shutdown the OutStream (the packets are released when they are flushed) */
488  CrFwCmpShutdown(outStream0);
489  /* FwSmStop(outStream0); */
490 
491  return 1;
492 }
493 
494 /* ---------------------------------------------------------------------------------------------*/
496  FwSmDesc_t outStream[CR_FW_NOF_OUTSTREAM];
499 
500  /* Initialize the destinations (the initialization values must be the same as
501  specified in <code>CrFwOutStreamUserPar.h</code>). */
502  for (i=0; i<CR_FW_OUTSTREAM_NOF_DEST; i++)
503  dest[i] = (CrFwDestSrc_t)(i+1);
504 
505  /* Make the OutStreams and associate them to their destinations */
506  for (i=0; i<CR_FW_NOF_OUTSTREAM; i++)
507  outStream[i] = CrFwOutStreamMake(i);
508 
509  /* Retrieve the OutStream from their destinations (association between destination
510  and OutStream is in CR_FW_OUTSTREAM_DEST_PAIRS)*/
511  if (CrFwOutStreamGet(dest[0]) != outStream[0])
512  return 0;
513  if (CrFwOutStreamGet(dest[1]) != outStream[0])
514  return 0;
515  if (CrFwOutStreamGet(dest[2]) != outStream[2])
516  return 0;
517  if (CrFwOutStreamGet(dest[7]) != outStream[1])
518  return 0;
519  if (CrFwGetAppErrCode() != crNoAppErr)
520  return 0;
521 
522  /* Check response to non-existent destination */
523  if (CrFwOutStreamGet(255) != NULL)
524  return 0;
526  return 0;
527  CrFwSetAppErrCode(crNoAppErr); /* reset application error code */
528 
529  return 1;
530 }
531 
532 /* ---------------------------------------------------------------------------------------------*/
534  FwSmDesc_t outStream1;
535  CrFwCounterU1_t nShutdown;
536 
537  /* Create the first InStream */
538  outStream1 = CrFwOutStreamMake(1);
539  if (outStream1 == NULL)
540  return 0;
541 
542  /* Retrieve the shutdown counter for the OutStream Stub */
543  nShutdown = CrFwOutStreamStubGetShutdownCnt();
544 
545  /* Bring OutStream to state CONFIGURED */
546  if (CrFwCmpIsStarted(outStream1) == 0)
547  FwSmStart(outStream1);
548  CrFwCmpInit(outStream1);
549  CrFwCmpReset(outStream1);
550  if (!CrFwCmpIsInConfigured(outStream1))
551  return 0;
552 
553  /* Shutdown the newly-created InStream */
554  CrFwCmpShutdown(outStream1);
555  if (CrFwOutStreamStubGetShutdownCnt() != nShutdown+1)
556  return 0;
557 
558  if (CrFwCmpIsStarted(outStream1) != 0)
559  return 0;
560 
561  /* Check application errors */
562  if (CrFwGetAppErrCode() != crNoAppErr)
563  return 0;
564 
565  return 1;
566 }
567 
568 /* ---------------------------------------------------------------------------------------------*/
570  FwSmDesc_t outStream0;
571  CrFwPckt_t pckt1, pckt2, pckt3, pckt;
572  CrFwCounterU2_t i;
573 
574  /* Retrieve the first OutStream */
575  outStream0 = CrFwOutStreamMake(0);
576  if (outStream0 == NULL)
577  return 0;
578 
579  /* Check configuration of OutStream */
580  if (FwSmCheckRec(outStream0) != smSuccess)
581  return 0;
582 
583  /* Start, initialize and reset outStream and check its state */
584  FwSmStart(outStream0);
585  CrFwCmpInit(outStream0);
586  CrFwCmpReset(outStream0);
587  if (!CrFwCmpIsInConfigured(outStream0))
588  return 0;
589  if (!CrFwOutStreamIsInReady(outStream0))
590  return 0;
591 
592  if (CrFwOutStreamGetSeqCnt(0) != 1)
593  return 0;
594 
595  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
596  return 0;
597 
598  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
600 
601  /* Make a dummy packet and configure it with the source equal to an external application */
604 
605  /* Set the sequence counter of the packet */
606  CrFwPcktSetSeqCnt(pckt1,100);
607 
608  /* Send the packet to the OutStream and check outcome */
609  CrFwOutStreamSend(outStream0, pckt1);
610  if (!CrFwOutStreamIsInReady(outStream0))
611  return 0;
612  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
613  return 0;
614  if (CrFwOutStreamGetSeqCnt(0) != 1)
615  return 0;
616  if (CrFwPcktGetSeqCnt(pckt1) != 100)
617  return 0;
618  CrFwPcktRelease(pckt1);
619 
620  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
622 
623  /* Make, configure and send two more packets to the OutStream and check outcome */
626  CrFwPcktSetSeqCnt(pckt2,101);
629  CrFwPcktSetSeqCnt(pckt3,102);
630 
631  CrFwOutStreamSend(outStream0, pckt2);
632  if (!CrFwOutStreamIsInBuffering(outStream0))
633  return 0;
634  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 1)
635  return 0;
636  if (CrFwOutStreamGetSeqCnt(0) != 1)
637  return 0;
638  CrFwOutStreamSend(outStream0, pckt3);
639  if (!CrFwOutStreamIsInBuffering(outStream0))
640  return 0;
641  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 2)
642  return 0;
643  if (CrFwOutStreamGetSeqCnt(0) != 1)
644  return 0;
645  CrFwPcktRelease(pckt2);
646  CrFwPcktRelease(pckt3);
647 
648  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
650 
651  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
652  CrFwOutStreamConnectionAvail(outStream0);
653  if (!CrFwOutStreamIsInReady(outStream0))
654  return 0;
655  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
656  return 0;
657  if (CrFwOutStreamGetSeqCnt(0) != 1)
658  return 0;
659  if (CrFwPcktGetSeqCnt(pckt2) != 101)
660  return 0;
661  if (CrFwPcktGetSeqCnt(pckt3) != 102)
662  return 0;
663 
664  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
666 
667  /* Fill up packet queue */
668  for (i=0; i<CrFwOutStreamGetPcktQueueSize(outStream0); i++) {
671  CrFwPcktSetSeqCnt(pckt,111);
672  CrFwOutStreamSend(outStream0, pckt);
673  CrFwPcktRelease(pckt);
674  }
675  if (!CrFwOutStreamIsInBuffering(outStream0))
676  return 0;
677  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != CrFwOutStreamGetPcktQueueSize(outStream0))
678  return 0;
679 
680  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
682 
683  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
684  CrFwOutStreamConnectionAvail(outStream0);
685  if (!CrFwOutStreamIsInReady(outStream0))
686  return 0;
687  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
688  return 0;
689 
690  /* Reset the OutStream and check new state */
691  CrFwCmpReset(outStream0);
692  if (!CrFwOutStreamIsInReady(outStream0))
693  return 0;
694  if (CrFwOutStreamGetNOfPendingPckts(outStream0) != 0)
695  return 0;
696 
697  /* Check that all packets have been de-allocated */
698  if (CrFwPcktGetNOfAllocated() != 0)
699  return 0;
700 
701  /* Check application errors */
702  if (CrFwGetAppErrCode() != crNoAppErr)
703  return 0;
704 
705  /* Stop the OutStream (the packets are released when they are flushed) */
706  FwSmStop(outStream0);
707 
708  return 1;
709 }
710 
711 /* ---------------------------------------------------------------------------------------------*/
713  FwSmDesc_t outStream1;
714  CrFwPckt_t pckt1, pckt2, pckt3;
715  CrFwCounterU2_t errRepPosLocal;
716  CrFwCounterU1_t handoverSuccCnt;
717 
718  /* Retrieve the second OutStream */
719  outStream1 = CrFwOutStreamMake(1);
720  if (outStream1 == NULL)
721  return 0;
722 
723  /* Start, initialize and reset outStream and check its state */
724  FwSmStart(outStream1);
725  CrFwCmpInit(outStream1);
726  CrFwCmpReset(outStream1);
727  if (!CrFwCmpIsInConfigured(outStream1))
728  return 0;
729  if (!CrFwOutStreamIsInReady(outStream1))
730  return 0;
731 
732  /* Retrieve error report counter */
733  errRepPosLocal = CrFwRepErrStubGetPos();
734 
735  /* Check configuration of OutStream */
736  if (FwSmCheckRec(outStream1) != smSuccess)
737  return 0;
738 
739  /* Check number of groups of OutStreams (this is set in CrFwOutStreamUserPar.h */
740  if (CrFwOutStreamGetNOfGroups()!=2)
741  return 0;
742 
743  /* Check destination associated to outStream (given by CR_FW_OUTSTREAM_DEST_PAIRS)*/
744  if (CrFwOutStreamGetNOfDest(outStream1) != 1)
745  return 0;
746  if (CrFwOutStreamGetDest(outStream1,1) != 8)
747  return 0;
748 
749  /* Check number of type counters (this is set by function CrFwOutStreamDefSetDTS and
750  is equal to the number of distinct (type,sub-type) pairs in CR_FW_OUTCMP_INIT_KIND_DESC */
752  return 0;
753 
754  /* Start, initialize and reset outStream and check its state */
755  FwSmStart(outStream1);
756  CrFwCmpInit(outStream1);
757  CrFwCmpReset(outStream1);
758  if (!CrFwCmpIsInConfigured(outStream1))
759  return 0;
760  if (!CrFwOutStreamIsInReady(outStream1))
761  return 0;
762  if (CrFwOutStreamGetSeqCnt(0) != 1)
763  return 0;
764  if (CrFwOutStreamGetSeqCnt(1) != 1)
765  return 0;
766  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
767  return 0;
768 
769  /* Check the initial value of the type counters */
770  if (CrFwOutStreamGetTypeCounter(1,1,1) != 1) /* (1,1) is a type in CR_FW_OUTCMP_INIT_KIND_DESC */
771  return 0;
772  if (CrFwOutStreamGetTypeCounter(1,5,1) != 1) /* (5,1) is a type in CR_FW_OUTCMP_INIT_KIND_DESC */
773  return 0;
774  if (CrFwOutStreamGetTypeCounter(1,50,1) != 1) /* (50,1) is a type in CR_FW_OUTCMP_INIT_KIND_DESC */
775  return 0;
776  if (CrFwOutStreamGetTypeCounter(99,5,1) != 0) /* destination 99 is not in DTS_SET */
777  return 0;
778  if (CrFwOutStreamGetTypeCounter(1,5,99) != 0) /* (5,99) is not a type in CR_FW_OUTCMP_INIT_KIND_DESC */
779  return 0;
780  if (CrFwOutStreamGetTypeCounter(1,99,1) != 0) /* (5,99) is not a type in CR_FW_OUTCMP_INIT_KIND_DESC */
781  return 0;
782 
783  /* Check computation of DTS_SET */
784  if (CrFwOutStreamIsInDtsSet(1,1,1) != 1) /* (1,1) is a type in CR_FW_OUTCMP_INIT_KIND_DESC */
785  return 0;
786  if (CrFwOutStreamIsInDtsSet(1,5,1) != 1) /* (5,1) is a type in CR_FW_OUTCMP_INIT_KIND_DESC */
787  return 0;
788  if (CrFwOutStreamIsInDtsSet(1,50,1) != 1) /* (50,1) is a type in CR_FW_OUTCMP_INIT_KIND_DESC */
789  return 0;
790  if (CrFwOutStreamIsInDtsSet(99,5,1) != 0) /* destination 99 is not in DTS_SET */
791  return 0;
792  if (CrFwOutStreamIsInDtsSet(1,5,99) != 0) /* (5,99) is not a type in CR_FW_OUTCMP_INIT_KIND_DESC */
793  return 0;
794  if (CrFwOutStreamIsInDtsSet(1,99,1) != 0) /* (5,99) is not a type in CR_FW_OUTCMP_INIT_KIND_DESC */
795  return 0;
796 
797  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
799 
800  /* Make three dummy packets, configure them to belong to the first, second and third group and
801  * with the source equal to the host application. Also configure the first and second packets
802  to belong to the DTS_SET and the third one to be outside the DTS_SET */
805  CrFwPcktSetGroup(pckt1,0);
806  CrFwPcktSetSeqCnt(pckt1,99);
807  CrFwPcktSetDest(pckt1,1);
808  CrFwPcktSetServType(pckt1,5);
809  CrFwPcktSetServSubType(pckt1,1);
810  CrFwPcktSetTypeCnt(pckt1, 1000);
813  CrFwPcktSetGroup(pckt2,1);
814  CrFwPcktSetSeqCnt(pckt2,99);
815  CrFwPcktSetDest(pckt2,1);
816  CrFwPcktSetServType(pckt2,5);
817  CrFwPcktSetServSubType(pckt2,99); /* non-existent sub-type */
818  CrFwPcktSetTypeCnt(pckt2, 2000);
821  CrFwPcktSetGroup(pckt3,88); /* non-existent group */
822  CrFwPcktSetSeqCnt(pckt3,99);
823  CrFwPcktSetDest(pckt3,1);
824  CrFwPcktSetServType(pckt3,5);
825  CrFwPcktSetServSubType(pckt3,1);
826  CrFwPcktSetTypeCnt(pckt3, 3000);
827 
828  /* Send the packets to the OutStream and check outcome */
829  CrFwOutStreamSetSeqCnt(1, 2222);
830  CrFwOutStreamSend(outStream1, pckt1);
831  CrFwOutStreamSend(outStream1, pckt2);
832  CrFwOutStreamSend(outStream1, pckt3);
833  if (!CrFwOutStreamIsInReady(outStream1))
834  return 0;
835  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
836  return 0;
837  if (CrFwOutStreamGetSeqCnt(0) != 2)
838  return 0;
839  if (CrFwOutStreamGetSeqCnt(1) != 2223)
840  return 0;
841  if (CrFwPcktGetSeqCnt(pckt1) != 1)
842  return 0;
843  if (CrFwPcktGetTypeCnt(pckt1) != 1)
844  return 0;
845  if (CrFwPcktGetSeqCnt(pckt2) != 2222)
846  return 0;
847  if (CrFwPcktGetTypeCnt(pckt2) != 0)
848  return 0;
849  if (CrFwPcktGetSeqCnt(pckt3) != 0)
850  return 0;
851  if (CrFwPcktGetTypeCnt(pckt3) != 2)
852  return 0;
853  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
854  return 0;
855  if (CrFwRepErrStubGetErrCode(errRepPosLocal) != crOutStreamIllGroup)
856  return 0;
857  CrFwPcktRelease(pckt1);
858  CrFwPcktRelease(pckt2);
859  CrFwPcktRelease(pckt3);
860 
861  /* Configure the Packet Hand-Over Operation to return "hand-over failed" */
863 
864  /* Store the current value of the OutStream packet handover counter */
865  handoverSuccCnt = CrFwOutStreamStubGetHandoverSuccCnt();
866 
867  /* Make, configure and send three more packets to the OutStream and check outcome */
870  CrFwPcktSetGroup(pckt1,0);
871  CrFwPcktSetSeqCnt(pckt1,99);
872  CrFwPcktSetDest(pckt1,1);
873  CrFwPcktSetServType(pckt1,5);
874  CrFwPcktSetServSubType(pckt1,1);
875  CrFwPcktSetTypeCnt(pckt1, 1000);
878  CrFwPcktSetGroup(pckt2,1);
879  CrFwPcktSetSeqCnt(pckt2,99);
880  CrFwPcktSetDest(pckt2,1);
881  CrFwPcktSetServType(pckt2,5);
882  CrFwPcktSetServSubType(pckt2,99); /* non-existent sub-type */
883  CrFwPcktSetTypeCnt(pckt2, 2000);
886  CrFwPcktSetGroup(pckt3,88); /* non-existent group */
887  CrFwPcktSetSeqCnt(pckt3,99);
888  CrFwPcktSetDest(pckt3,1);
889  CrFwPcktSetServType(pckt3,5);
890  CrFwPcktSetServSubType(pckt3,1);
891  CrFwPcktSetTypeCnt(pckt3, 3000);
892 
893  CrFwOutStreamSend(outStream1, pckt1);
894  CrFwOutStreamSend(outStream1, pckt2);
895  CrFwOutStreamSend(outStream1, pckt3);
896  if (!CrFwOutStreamIsInBuffering(outStream1))
897  return 0;
898  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 3)
899  return 0;
900  if (CrFwOutStreamGetSeqCnt(0) != 2)
901  return 0;
902  if (CrFwOutStreamGetSeqCnt(1) != 2223)
903  return 0;
904  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
905  return 0;
906  if (CrFwOutStreamStubGetHandoverSuccCnt() != handoverSuccCnt)
907  return 0;
908  CrFwPcktRelease(pckt1);
909  CrFwPcktRelease(pckt2);
910  CrFwPcktRelease(pckt3);
911 
912  /* Configure the Packet Hand-Over Operation to return "hand-over successful" */
914 
915  /* Send the Connection Available signal to the OutStream and check that PQ is flushed */
916  CrFwOutStreamConnectionAvail(outStream1);
917  if (!CrFwOutStreamIsInReady(outStream1))
918  return 0;
919  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
920  return 0;
921  if (CrFwOutStreamGetSeqCnt(0) != 3)
922  return 0;
923  if (CrFwOutStreamGetSeqCnt(1) != 2224)
924  return 0;
925  if (CrFwOutStreamGetTypeCounter(1,5,1) != 5)
926  return 0;
927  if (CrFwRepErrStubGetPos() != errRepPosLocal+2)
928  return 0;
929  if (CrFwRepErrStubGetErrCode(errRepPosLocal) != crOutStreamIllGroup)
930  return 0;
931  if (CrFwOutStreamStubGetHandoverSuccCnt() != handoverSuccCnt+3)
932  return 0;
933  if (CrFwOutStreamStubGetTypeCnt(handoverSuccCnt+1) != 3)
934  return 0;
935  if (CrFwOutStreamStubGetTypeCnt(handoverSuccCnt+2) != 0)
936  return 0;
937  if (CrFwOutStreamStubGetTypeCnt(handoverSuccCnt+3) != 4)
938  return 0;
939 
940  /* Reset the OutStream and check new state */
941  CrFwCmpReset(outStream1);
942  if (!CrFwOutStreamIsInReady(outStream1))
943  return 0;
944  if (CrFwOutStreamGetNOfPendingPckts(outStream1) != 0)
945  return 0;
946 
947  /* Check that all packets have been de-allocated */
948  if (CrFwPcktGetNOfAllocated() != 0)
949  return 0;
950 
951  /* Check application errors */
952  if (CrFwGetAppErrCode() != crNoAppErr)
953  return 0;
954 
955  /* Stop the OutStream (the packets are released when they are flushed) */
956  FwSmStop(outStream1);
957 
958  return 1;
959 }
960 
CrFwBool_t CrFwCmpIsStarted(FwSmDesc_t smDesc)
Return true if the state machine of the argument component has been started.
Definition: CrFwBaseCmp.c:162
FwPrDesc_t CrFwCmpGetResetPr(FwSmDesc_t smDesc)
Return the descriptor of the Reset Procedure of the argument component.
Definition: CrFwBaseCmp.c:138
FwPrDesc_t CrFwCmpGetExecPr(FwSmDesc_t smDesc)
Return the descriptor of the Execution Procedure of the argument component.
Definition: CrFwBaseCmp.c:144
void CrFwCmpInit(FwSmDesc_t smDesc)
Initialize a framework component.
Definition: CrFwBaseCmp.c:112
CrFwBool_t CrFwCmpIsInInitialized(FwSmDesc_t smDesc)
Return true if the argument component is in state INITIALIZED.
Definition: CrFwBaseCmp.c:172
void CrFwCmpShutdown(FwSmDesc_t smDesc)
Shutdown a framework component.
Definition: CrFwBaseCmp.c:122
CrFwBool_t CrFwCmpIsInConfigured(FwSmDesc_t smDesc)
Return true if the argument component is in state CONFIGURED.
Definition: CrFwBaseCmp.c:177
void CrFwCmpReset(FwSmDesc_t smDesc)
Reset a framework component.
Definition: CrFwBaseCmp.c:117
CrFwBool_t CrFwCmpIsInCreated(FwSmDesc_t smDesc)
Return true if the argument component is in state CREATED.
Definition: CrFwBaseCmp.c:167
FwPrDesc_t CrFwCmpGetInitPr(FwSmDesc_t smDesc)
Return the descriptor of the Initialization Procedure of the argument component.
Definition: CrFwBaseCmp.c:132
Definition of Base Component.
Definition of the Framework Component Data (FCD) Type.
#define CR_FW_OUTSTREAM_TYPE
Type identifier for the OutStream components.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:38
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
static CrFwDestSrc_t dest
Destination.
FwSmDesc_t CrFwOutStreamGet(CrFwDestSrc_t dest)
Getter function for the OutStream corresponding to the argument destination.
CrFwCounterU2_t CrFwOutStreamGetNOfTypeCounters()
Return the number of type counters maintained by the OutStreams.
CrFwGroup_t CrFwOutStreamGetNOfGroups()
Return the number of groups associated to the OutStreams.
CrFwTypeCnt_t CrFwOutStreamGetTypeCounter(CrFwDestSrc_t dest, CrFwServType_t servType, CrFwServSubType_t servSubType)
Return the current type counter for a (destination, type, sub-type) triplet or zero if the triplet is...
CrFwCounterU1_t CrFwOutStreamGetNOfPendingPckts(FwSmDesc_t smDesc)
Return the number of packets currently in the packet queue of an OutStream.
CrFwSeqCnt_t CrFwOutStreamGetSeqCnt(CrFwGroup_t group)
Return the value of the sequence counter for one of the groups maintained by the OutStreams.
CrFwBool_t CrFwOutStreamIsInReady(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state READY.
void CrFwOutStreamSetSeqCnt(CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
Sets the value of the sequence counter for one of the groups maintained by the OutStreams.
CrFwDestSrc_t CrFwOutStreamGetDest(FwSmDesc_t outStream, CrFwCounterU1_t i)
Return the i-th destination associated to the argument outStream.
CrFwCounterU1_t CrFwOutStreamGetNOfDest(FwSmDesc_t outStream)
Return the number of destinations associated to the argument outStream.
FwSmDesc_t CrFwOutStreamMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th OutStream State Machine instance.
CrFwCounterU1_t CrFwOutStreamGetPcktQueueSize(FwSmDesc_t smDesc)
Return the size of the packet queue of the OutStream.
void CrFwOutStreamConnectionAvail(FwSmDesc_t smDesc)
Signal that the out-going middleware connection has become available.
CrFwBool_t CrFwOutStreamIsInBuffering(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state BUFFERING.
void CrFwOutStreamSend(FwSmDesc_t smDesc, CrFwPckt_t pckt)
Send a packet to the OutStream.
CrFwBool_t CrFwOutStreamIsInDtsSet(CrFwDestSrc_t dest, CrFwServType_t servType, CrFwServSubType_t servSubType)
Check whether the (destination, type, sub-type) triplet is in DTS_SET.
Definition of the OutStream component.
CrFwCounterU1_t CrFwOutStreamStubGetHandoverSuccCnt()
Return the value of the handover successful counter which is incremented by the packet handover funct...
CrFwSeqCnt_t CrFwOutStreamStubGetTypeCnt(CrFwCounterU1_t n)
Return the type counter of the n-th packet to have been handed over to the OutStream Stub.
void CrFwOutStreamStubSetCheckFlag(CrFwBool_t flag)
Set the value of the check flag which determines the outcome of the dummy check of CrFwOutStreamStubD...
CrFwCounterU1_t CrFwOutStreamStubGetShutdownCnt()
Return the value of the shutdown counter which is incremented by the packet shutdown function in CrFw...
void CrFwOutStreamStubSetActionFlag(CrFwBool_t flag)
Set the value of the action flag which determines the outcome of the initialization of configuration ...
void CrFwOutStreamStubSetHandoverFlag(CrFwBool_t flag)
Set the value of the handover flag which determines the outcome of the packet handover in CrFwOutStre...
Interface for the OutStream stub.
CrFwBool_t CrFwOutStreamTestCase2()
Test the OutStream with overridden initialization check and initialization action.
CrFwBool_t CrFwOutStreamTestCase5()
Test the Shutdown Operation of an OutStream.
CrFwBool_t CrFwOutStreamTestCase7()
Test the management of the sequence counters for different groups and of the type counters.
CrFwBool_t CrFwOutStreamTestCase1()
Test the initialization and packet queue (PQ) management of the OutStream.
CrFwBool_t CrFwOutStreamTestCase3()
Test the packet flushing functionality of an OutStream for a packet originating from the host applica...
CrFwBool_t CrFwOutStreamTestCase4()
Test the registry functionality of an OutStream.
CrFwBool_t CrFwOutStreamTestCase6()
Test the packet flushing functionality of an OutStream for a re-routed packet (as opposed to a packet...
Declaration of the test cases for the OutStream Component (see CrFwOutStream.h).
User-modifiable parameters for the OutStream components (see CrFwOutStream.h).
#define CR_FW_NOF_OUTSTREAM
The number of OutStream components in the application.
#define CR_FW_OUTSTREAM_NOF_DEST
Number of destinations for out-going packets.
static unsigned char pcktArray[CR_FW_MAX_NOF_PCKTS *CR_FW_MAX_PCKT_LENGTH]
The array holding the packets.
Definition: CrFwPckt.c:83
Interface for creating and accessing a report or command packet.
void CrFwPcktSetServSubType(CrFwPckt_t pckt, CrFwServSubType_t servSubType)
Set the service sub-type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:327
CrFwTypeCnt_t CrFwPcktGetTypeCnt(CrFwPckt_t pckt)
Return the type counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:253
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:247
CrFwSeqCnt_t CrFwPcktGetSeqCnt(CrFwPckt_t pckt)
Return the sequence counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:241
void CrFwPcktSetServType(CrFwPckt_t pckt, CrFwServType_t servType)
Set the service type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:315
CrFwCounterU2_t CrFwPcktGetNOfAllocated()
Return the number of packets which are currently allocated.
Definition: CrFwPckt.c:214
void CrFwPcktRelease(CrFwPckt_t pckt)
Release function for command or report packets.
Definition: CrFwPckt.c:174
CrFwPcktLength_t CrFwPcktGetMaxLength()
Return the maximum length of a packet in number of bytes.
Definition: CrFwPckt.c:219
void CrFwPcktSetSrc(CrFwPckt_t pckt, CrFwDestSrc_t src)
Set the source of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:351
void CrFwPcktSetDest(CrFwPckt_t pckt, CrFwDestSrc_t dest)
Set the destination of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:339
void CrFwPcktSetGroup(CrFwPckt_t pckt, CrFwGroup_t group)
Set the group of the command/report encapsulated in a packet.
Definition: CrFwPckt.c:422
void CrFwPcktSetTypeCnt(CrFwPckt_t pckt, CrFwTypeCnt_t typeCnt)
Set the type counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:259
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Definition: CrFwPckt.c:147
void CrFwRepErrStubReset()
Reset the error reporting interface.
Definition: CrFwRepErr.c:84
CrFwInstanceId_t CrFwRepErrStubGetInstanceId(CrFwCounterU2_t errRepPos)
Return the type identifier of the error report at position errRepPos.
Definition: CrFwRepErr.c:277
CrFwCounterU2_t CrFwRepErrStubGetPos()
Return the position in the error report array at which the next error report will be written.
Definition: CrFwRepErr.c:79
CrFwTypeId_t CrFwRepErrStubGetTypeId(CrFwCounterU2_t errRepPos)
Return the type identifier of the error report at position errRepPos.
Definition: CrFwRepErr.c:272
CrFwRepErrCode_t CrFwRepErrStubGetErrCode(CrFwCounterU2_t errRepPos)
Return the error code of the error report at position errRepPos.
Definition: CrFwRepErr.c:267
Interface for reporting an error detected by a framework component.
The CORDET Framework defines an interface for generating error reports (see CrFwRepErr....
Interface through which framework components access the current time.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
#define CR_FW_MAX_NOF_PCKTS
The maximum number of packets which can be created with the default implementation of the packet acce...
unsigned short CrFwCounterU2_t
Type used for unsigned integers with a "medium" range.
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
unsigned char CrFwGroup_t
Type used for the destination or source group of a packet.
@ crOutStreamNoMorePckt
An OutStream cannot buffer an out-going packet because no more packets are available (see CrFwOutStre...
@ crOutStreamIllGroup
An OutComponent has an illegal group.
@ crOutStreamPQFull
The packet queue of an OutStream is full (see CrFwOutStream.h)
@ crNoAppErr
No application errors have been detected.
@ crOutStreamUndefDest
A framework function has been called with a destination attribute which is not associated to any OutS...
@ crOutStreamIllId
A framework function has been called with an illegal OutStream identifier.
#define CR_FW_HOST_APP_ID
The identifier of the host application (i.e.
unsigned short CrFwInstanceId_t
Type used for instance identifiers.
CrFwAppErrCode_t CrFwGetAppErrCode()
Return the value of the application error code.
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
Definition of the utility functions for the CORDET Framework.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved