-
Notifications
You must be signed in to change notification settings - Fork 207
/
sb_UT.c
4360 lines (3339 loc) · 135 KB
/
sb_UT.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** GSC-18128-1, "Core Flight Executive Version 6.7"
**
** Copyright (c) 2006-2019 United States Government as represented by
** the Administrator of the National Aeronautics and Space Administration.
** All Rights Reserved.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
/*
** File:
** sb_UT.c
**
** Purpose:
** Software Bus Services unit test
**
** References:
** 1. cFE Application Developers Guide
** 2. unit test standard 092503
** 3. C Coding Standard 102904
**
** Notes:
** 1. This is unit test code only, not for use in flight
**
*/
/*
** Includes
*/
#include "sb_UT.h"
#include "cfe_msg_api.h"
/*
* A method to add an SB "Subtest"
*
* As SB has a lot of test cases it is helpful to group them.
* This allows each test routine to reported consistently as "GroupName.TestName"
*
* This also implicitly includes a call to SB_ResetUnitTest() as a setup function,
* so the test routines do _not_ need to do this explictly on every test case.
*/
#define SB_UT_ADD_SUBTEST(Func) UT_AddSubTest(Func, SB_ResetUnitTest, NULL, __func__, #Func)
/*
* MSG ID constants for unit testing:
* Unit test cases should not directly use integer MsgId values
*
* The following constants are of the CFE_SB_MsgId_t type
*/
const CFE_SB_MsgId_t SB_UT_CMD_MID = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE);
const CFE_SB_MsgId_t SB_UT_TLM_MID = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE);
const CFE_SB_MsgId_t SB_UT_CMD_MID1 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE+1);
const CFE_SB_MsgId_t SB_UT_CMD_MID2 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE+2);
const CFE_SB_MsgId_t SB_UT_CMD_MID3 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE+3);
const CFE_SB_MsgId_t SB_UT_CMD_MID4 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE+4);
const CFE_SB_MsgId_t SB_UT_CMD_MID5 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE+5);
const CFE_SB_MsgId_t SB_UT_CMD_MID6 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_CMD_MID_VALUE_BASE+6);
const CFE_SB_MsgId_t SB_UT_TLM_MID1 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE+1);
const CFE_SB_MsgId_t SB_UT_TLM_MID2 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE+2);
const CFE_SB_MsgId_t SB_UT_TLM_MID3 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE+3);
const CFE_SB_MsgId_t SB_UT_TLM_MID4 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE+4);
const CFE_SB_MsgId_t SB_UT_TLM_MID5 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE+5);
const CFE_SB_MsgId_t SB_UT_TLM_MID6 = CFE_SB_MSGID_WRAP_VALUE(SB_UT_TLM_MID_VALUE_BASE+6);
/*
* A MsgId value which still qualifies as valid
*
* This is a "borderline" value to test the limits of the validity checking
* The specific value depends on how MsgId is actually defined internally
*/
const CFE_SB_MsgId_t SB_UT_LAST_VALID_MID = CFE_SB_MSGID_WRAP_VALUE(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID);
/*
* A MsgId value which still qualifies as valid
*
* This is a "borderline" value to test the limits of the validity checking
* The specific value depends on how MsgId is actually defined internally
*/
const CFE_SB_MsgId_t SB_UT_FIRST_VALID_MID = CFE_SB_MSGID_WRAP_VALUE(0);
/*
* A MsgId value which is in the middle of the valid range
*
* The specific value depends on how MsgId is actually defined internally
*/
const CFE_SB_MsgId_t SB_UT_INTERMEDIATE_VALID_MID = CFE_SB_MSGID_WRAP_VALUE(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID / 2 + 1);
/*
* A MsgId value which is not valid but also not equal to CFE_SB_INVALID_MSG_ID
* Like CFE_SB_INVALID_MSG_ID, this should also _not_ pass the validity check.
*/
const CFE_SB_MsgId_t SB_UT_ALTERNATE_INVALID_MID = CFE_SB_MSGID_WRAP_VALUE(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1);
/*
* A MsgId value which is valid per CCSDS but does not have the secondary header bit set
*/
const CFE_SB_MsgId_t SB_UT_BARE_CMD_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x1003);
const CFE_SB_MsgId_t SB_UT_BARE_TLM_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x0003);
/*
* Helper function to "corrupt" a resource ID value in a consistent/predicatble way,
* which can also be un-done easily.
*/
uint32 UT_SB_ResourceID_Modify(uint32 InitialID, int32 Modifier)
{
uint32 NewValue = InitialID + Modifier;
return (NewValue);
}
/*
** Functions
*/
void UtTest_Setup(void)
{
UT_Init("sb");
UT_Text("cFE SB Unit Test Output File\n\n");
Test_SB_AppInit();
Test_SB_MainRoutine();
Test_SB_Cmds();
Test_SB_EarlyInit();
Test_CreatePipe_API();
Test_DeletePipe_API();
Test_PipeOpts_API();
Test_GetPipeName_API();
Test_GetPipeIdByName_API();
Test_Subscribe_API();
Test_Unsubscribe_API();
Test_SendMsg_API();
Test_RcvMsg_API();
SB_UT_ADD_SUBTEST(Test_CleanupApp_API);
Test_SB_Utils();
Test_SB_SpecialCases();
} /* end main */
/*
** Reset variable values and sockets prior to a test
*/
void SB_ResetUnitTest(void)
{
/* If any sockets were left open then report and close them */
UT_CheckForOpenSockets();
UT_InitData();
CFE_SB_EarlyInit();
} /* end SB_ResetUnitTest */
/*
** Function for calling SB application initialization
** test functions
*/
void Test_SB_AppInit(void)
{
SB_UT_ADD_SUBTEST(Test_SB_AppInit_ESRegFail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_EVSRegFail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_EVSSendEvtFail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_CrPipeFail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_Sub1Fail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_Sub2Fail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_GetPoolFail);
SB_UT_ADD_SUBTEST(Test_SB_AppInit_PutPoolFail);
} /* end Test_SB_AppInit */
/*
** Test task init with ES_RegisterApp returning error
*/
void Test_SB_AppInit_ESRegFail(void)
{
int32 ForcedRtnVal = -1;
UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterApp), 1, ForcedRtnVal);
ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal);
EVTCNT(0);
} /* end Test_SB_AppInit_ESRegFail */
/*
** Test task init with EVS_Register returning error
*/
void Test_SB_AppInit_EVSRegFail(void)
{
int32 ForcedRtnVal = -1;
UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, ForcedRtnVal);
ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal);
EVTCNT(0);
} /* end Test_SB_AppInit_EVSRegFail */
/*
** Test task init with EVS_SendEvent returning error on task init event
*/
void Test_SB_AppInit_EVSSendEvtFail(void)
{
int32 ForcedRtnVal = -1;
CFE_ES_TaskInfo_t TestTaskInfo;
/* To get coverage on CFE_SB_GetAppTskName(), this ensures that the
* path with different app/task names is followed on at least one event.
*/
memset(&TestTaskInfo, 0, sizeof(TestTaskInfo));
strncpy((char*)TestTaskInfo.TaskName, "test", sizeof(TestTaskInfo.TaskName)-1);
UT_SetDataBuffer(UT_KEY(CFE_ES_GetTaskInfo), &TestTaskInfo, sizeof(TestTaskInfo), false);
/* There are three events prior to init, pipe created (1) and subscription
* rcvd (2). Fourth is SB initialized, but it is the first to use SendEvent.
* (The others use SendEventWithAppID which is a different counter).
*/
UT_SetDeferredRetcode(UT_KEY(CFE_EVS_SendEvent), 1, ForcedRtnVal);
ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal);
EVTCNT(7);
TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe));
} /* end Test_SB_AppInit_EVSSendEvtFail */
/*
** Test task init with pipe create failure
*/
void Test_SB_AppInit_CrPipeFail(void)
{
/* To fail the pipe create, force the OS_QueueCreate call to return some
* type of error code.
*/
UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_ERROR);
ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_PIPE_CR_ERR);
EVTCNT(1);
EVTSENT(CFE_SB_CR_PIPE_ERR_EID);
} /* end Test_SB_AppInit_CrPipeFail */
/*
** Test task init with a failure on first subscription request
*/
void Test_SB_AppInit_Sub1Fail(void)
{
CFE_SB_PipeId_t PipeId = 0;
UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, -1);
ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR);
EVTCNT(3);
EVTSENT(CFE_SB_DEST_BLK_ERR_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_AppInit_Sub1Fail */
/*
** Test task init with a failure on second subscription request
*/
void Test_SB_AppInit_Sub2Fail(void)
{
CFE_SB_PipeId_t PipeId = 0;
UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 2, -1);
ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR);
EVTCNT(5);
EVTSENT(CFE_SB_DEST_BLK_ERR_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_AppInit_Sub2Fail */
/*
** Test task init with a GetPool failure
*/
void Test_SB_AppInit_GetPoolFail(void)
{
CFE_SB_PipeId_t PipeId = 0;
int32 ForcedRtnVal = -1;
UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 4, ForcedRtnVal);
ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal);
EVTCNT(7);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_AppInit_GetPoolFail */
/*
** Test task init with a PutPool failure
*/
void Test_SB_AppInit_PutPoolFail(void)
{
CFE_SB_PipeId_t PipeId = 0;
int32 ForcedRtnVal = -1;
UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, ForcedRtnVal);
ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal);
EVTCNT(7);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_AppInit_PutPoolFail */
/*
** Function for calling SB main task test functions
*/
void Test_SB_MainRoutine(void)
{
SB_UT_ADD_SUBTEST(Test_SB_Main_RcvErr);
SB_UT_ADD_SUBTEST(Test_SB_Main_InitErr);
} /* end Test_SB_MainRoutine */
/*
** Test main task with a packet receive error
*/
void Test_SB_Main_RcvErr(void)
{
CFE_SB_PipeId_t PipeId = 0;
UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, -1);
CFE_SB_TaskMain();
EVTCNT(10);
EVTSENT(CFE_SB_INIT_EID);
EVTSENT(CFE_SB_Q_RD_ERR_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_Main_RcvErr */
/*
** Test main task with an application initialization error
*/
void Test_SB_Main_InitErr(void)
{
CFE_SB_PipeId_t PipeId = 0;
UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1);
CFE_SB_TaskMain();
EVTCNT(7);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_Main_InitErr */
/*
** Function for calling SB command test functions
*/
void Test_SB_Cmds(void)
{
SB_UT_ADD_SUBTEST(Test_SB_Cmds_Noop);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_RstCtrs);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_Stats);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoDef);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoSpec);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoCreateFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoHdrFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoWriteFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoDef);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoSpec);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoCreateFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoHdrFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoWriteFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoDef);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoSpec);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoCreateFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoHdrFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoWriteFail);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteValParam);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteNonExist);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteInvParam);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteInvParam2);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteInvParam3);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteValParam);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteNonExist);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteInvParam);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteInvParam2);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteInvParam3);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_SendHK);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_SendPrevSubs);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptOn);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptOff);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_CmdUnexpCmdCode);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptUnexpCmdCode);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_BadCmdLength);
SB_UT_ADD_SUBTEST(Test_SB_Cmds_UnexpMsgId);
} /* end Test_SB_Cmds */
/*
** Test no-op command
*/
void Test_SB_Cmds_Noop(void)
{
CFE_SB_CmdHdr_t NoParamCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_NOOP_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(NoParamCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_CMD0_RCVD_EID);
} /* end Test_SB_Cmds_Noop */
/*
** Test reset counters command
*/
void Test_SB_Cmds_RstCtrs(void)
{
CFE_SB_CmdHdr_t NoParamCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_RESET_COUNTERS_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(NoParamCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_CMD1_RCVD_EID);
} /* Test_SB_Cmds_RstCtrs */
/*
** Test send SB stats command
*/
void Test_SB_Cmds_Stats(void)
{
CFE_SB_CmdHdr_t NoParamCmd;
CFE_MSG_FcnCode_t FcnCode;
CFE_SB_MsgId_t MsgId;
CFE_MSG_Size_t Size;
/* For internal SendMsg call */
MsgId = CFE_SB_ValueToMsgId(CFE_SB_STATS_TLM_MID);
Size = sizeof(CFE_SB.StatTlmMsg);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
/* For Generic command processing */
MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
Size = sizeof(NoParamCmd);
FcnCode = CFE_SB_SEND_SB_STATS_CC;
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd;
CFE_SB_ProcessCmdPipePkt();
/* No subs event and command processing event */
EVTCNT(2);
EVTSENT(CFE_SB_SND_STATS_EID);
} /* end Test_SB_Cmds_Stats */
/*
** Test send routing information command using the default file name
*/
void Test_SB_Cmds_RoutingInfoDef(void)
{
CFE_SB_PipeId_t PipeId = 0;
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_ROUTING_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename));
/* Make some routing info by calling CFE_SB_AppInit */
SETUP(CFE_SB_AppInit());
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(12);
EVTSENT(CFE_SB_INIT_EID);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);
EVTSENT(CFE_SB_INIT_EID);
EVTSENT(CFE_SB_SND_RTG_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_Cmds_RoutingInfoDef */
/*
** Test send routing information command using a specified file name
*/
void Test_SB_Cmds_RoutingInfoSpec(void)
{
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_ROUTING_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "RoutingTstFile", sizeof(WriteFileCmd.Payload.Filename));
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_SND_RTG_EID);
} /* end Test_SB_Cmds_RoutingInfoSpec */
/*
** Test send routing information command with a file creation failure
*/
void Test_SB_Cmds_RoutingInfoCreateFail(void)
{
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_ROUTING_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "RoutingTstFile", sizeof(WriteFileCmd.Payload.Filename));
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
/* Make function CFE_SB_SendRtgInfo return CFE_SB_FILE_IO_ERR */
UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR);
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_SND_RTG_ERR1_EID);
} /* end Test_SB_Cmds_RoutingInfoCreateFail */
/*
** Test send routing information command with a file header write failure
*/
void Test_SB_Cmds_RoutingInfoHdrFail(void)
{
UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1);
ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(1);
EVTSENT(CFE_SB_FILEWRITE_ERR_EID);
} /* end Test_SB_Cmds_RoutingInfoHdrFail */
/*
** Test send routing information command with a file write failure on
** the second write
*/
void Test_SB_Cmds_RoutingInfoWriteFail(void)
{
CFE_SB_PipeId_t PipeId = 0;
/* Make some routing info by calling CFE_SB_AppInit */
SETUP(CFE_SB_AppInit());
UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1);
ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(11);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);
EVTSENT(CFE_SB_INIT_EID);
EVTSENT(CFE_SB_FILEWRITE_ERR_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_Cmds_RoutingInfoWriteFail */
/*
** Test send pipe information command using the default file name
*/
void Test_SB_Cmds_PipeInfoDef(void)
{
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_SB_PipeId_t PipeId1;
CFE_SB_PipeId_t PipeId2;
CFE_SB_PipeId_t PipeId3;
uint16 PipeDepth = 10;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_PIPE_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename));
/* Create some pipe info */
SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"));
SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"));
SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"));
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(4);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_SND_RTG_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId1));
TEARDOWN(CFE_SB_DeletePipe(PipeId2));
TEARDOWN(CFE_SB_DeletePipe(PipeId3));
} /* end Test_SB_Cmds_PipeInfoDef */
/*
** Test send pipe information command using a specified file name
*/
void Test_SB_Cmds_PipeInfoSpec(void)
{
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_PIPE_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "PipeTstFile", sizeof(WriteFileCmd.Payload.Filename));
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_SND_RTG_EID);
} /* end Test_SB_Cmds_PipeInfoSpec */
/*
** Test send pipe information command with a file creation failure
*/
void Test_SB_Cmds_PipeInfoCreateFail(void)
{
UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR);
ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(1);
EVTSENT(CFE_SB_SND_RTG_ERR1_EID);
} /* end Test_SB_Cmds_PipeInfoCreateFail */
/*
** Test send pipe information command with a file header write failure
*/
void Test_SB_Cmds_PipeInfoHdrFail(void)
{
UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1);
ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(1);
EVTSENT(CFE_SB_FILEWRITE_ERR_EID);
} /* end Test_SB_Cmds_PipeInfoHdrFail */
/*
** Test send pipe information command with a file write failure on
** the second write
*/
void Test_SB_Cmds_PipeInfoWriteFail(void)
{
CFE_SB_PipeId_t PipeId1;
CFE_SB_PipeId_t PipeId2;
CFE_SB_PipeId_t PipeId3;
uint16 PipeDepth = 10;
SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"));
SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"));
SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"));
UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1);
ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(4);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_FILEWRITE_ERR_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId1));
TEARDOWN(CFE_SB_DeletePipe(PipeId2));
TEARDOWN(CFE_SB_DeletePipe(PipeId3));
} /* end Test_SB_Cmds_PipeInfoWriteFail */
/*
** Test send map information command using the default file name
*/
void Test_SB_Cmds_MapInfoDef(void)
{
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_SB_PipeId_t PipeId1;
CFE_SB_PipeId_t PipeId2;
CFE_SB_PipeId_t PipeId3;
CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1;
CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2;
CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3;
CFE_SB_MsgId_t MsgId3 = SB_UT_TLM_MID4;
CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID5;
CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6;
uint16 PipeDepth = 10;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_MAP_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename));
/* Create some map info */
SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"));
SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"));
SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"));
SETUP(CFE_SB_Subscribe(MsgId0, PipeId1));
SETUP(CFE_SB_Subscribe(MsgId0, PipeId2));
SETUP(CFE_SB_Subscribe(MsgId1, PipeId1));
SETUP(CFE_SB_Subscribe(MsgId2, PipeId3));
SETUP(CFE_SB_Subscribe(MsgId3, PipeId3));
SETUP(CFE_SB_Subscribe(MsgId4, PipeId3));
SETUP(CFE_SB_Subscribe(MsgId5, PipeId2));
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(18);
EVTSENT(CFE_SB_SND_RTG_EID);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId1));
TEARDOWN(CFE_SB_DeletePipe(PipeId2));
TEARDOWN(CFE_SB_DeletePipe(PipeId3));
} /* end Test_SB_Cmds_MapInfoDef */
/*
** Test send map information command using a specified file name
*/
void Test_SB_Cmds_MapInfoSpec(void)
{
CFE_SB_WriteFileInfoCmd_t WriteFileCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_SEND_MAP_INFO_CC;
CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(WriteFileCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
strncpy((char *)WriteFileCmd.Payload.Filename, "MapTstFile", sizeof(WriteFileCmd.Payload.Filename));
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_SND_RTG_EID);
} /* end Test_SB_Cmds_MapInfoSpec */
/*
** Test send map information command with a file creation failure
*/
void Test_SB_Cmds_MapInfoCreateFail(void)
{
UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR);
ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(1);
EVTSENT(CFE_SB_SND_RTG_ERR1_EID);
} /* end Test_SB_Cmds_MapInfoCreateFail */
/*
** Test send map information command with a file header write failure
*/
void Test_SB_Cmds_MapInfoHdrFail(void)
{
UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1);
ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(1);
EVTSENT(CFE_SB_FILEWRITE_ERR_EID);
} /* end Test_SB_Cmds_MapInfoHdrFail */
/*
** Test send map information command with a file write failure on
** the second write
*/
void Test_SB_Cmds_MapInfoWriteFail(void)
{
CFE_SB_PipeId_t PipeId1;
CFE_SB_PipeId_t PipeId2;
CFE_SB_PipeId_t PipeId3;
CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1;
CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2;
CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3;
CFE_SB_MsgId_t MsgId3 = SB_UT_TLM_MID4;
CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID5;
CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6;
uint16 PipeDepth = 10;
/* Create some map info */
SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"));
SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"));
SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"));
SETUP(CFE_SB_Subscribe(MsgId0, PipeId1));
SETUP(CFE_SB_Subscribe(MsgId0, PipeId2));
SETUP(CFE_SB_Subscribe(MsgId1, PipeId1));
SETUP(CFE_SB_Subscribe(MsgId2, PipeId3));
SETUP(CFE_SB_Subscribe(MsgId3, PipeId3));
SETUP(CFE_SB_Subscribe(MsgId4, PipeId3));
SETUP(CFE_SB_Subscribe(MsgId5, PipeId2));
UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1);
ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR);
EVTCNT(18);
EVTSENT(CFE_SB_FILEWRITE_ERR_EID);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId1));
TEARDOWN(CFE_SB_DeletePipe(PipeId2));
TEARDOWN(CFE_SB_DeletePipe(PipeId3));
} /* end Test_SB_Cmds_MapInfoWriteFail */
/*
** Test command to enable a specific route using a valid route
*/
void Test_SB_Cmds_EnRouteValParam(void)
{
CFE_SB_RouteCmd_t EnDisRouteCmd;
CFE_SB_PipeId_t PipeId;
CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID;
uint16 PipeDepth = 5;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_ENABLE_ROUTE_CC;
CFE_SB_MsgId_t MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(EnDisRouteCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "EnRouteTestPipe"));
SETUP(CFE_SB_Subscribe(MsgId, PipeId));
EnDisRouteCmd.Payload.MsgId = MsgId;
EnDisRouteCmd.Payload.Pipe = PipeId;
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(4);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);
EVTSENT(CFE_SB_ENBL_RTE2_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId));
} /* end Test_SB_Cmds_EnRouteValParam */
/*
** Test command to enable a specific route using a non-existent route
*/
void Test_SB_Cmds_EnRouteNonExist(void)
{
CFE_SB_RouteCmd_t EnDisRouteCmd;
CFE_SB_PipeId_t PipeId1;
CFE_SB_PipeId_t PipeId2;
CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID;
uint16 PipeDepth = 5;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_ENABLE_ROUTE_CC;
CFE_SB_MsgId_t MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(EnDisRouteCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "EnRouteTestPipe1"));
SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "EnRouteTestPipe2"));
SETUP(CFE_SB_Subscribe(MsgId, PipeId1));
EnDisRouteCmd.Payload.MsgId = MsgId;
EnDisRouteCmd.Payload.Pipe = PipeId2;
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(5);
EVTSENT(CFE_SB_PIPE_ADDED_EID);
EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID);
EVTSENT(CFE_SB_ENBL_RTE1_EID);
TEARDOWN(CFE_SB_DeletePipe(PipeId1));
TEARDOWN(CFE_SB_DeletePipe(PipeId2));
} /* end Test_SB_Cmds_EnRouteNonExist */
/*
** Test command to enable a specific route using an invalid pipe ID
*/
void Test_SB_Cmds_EnRouteInvParam(void)
{
CFE_SB_RouteCmd_t EnDisRouteCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_ENABLE_ROUTE_CC;
CFE_SB_MsgId_t MsgIdCmd = CFE_SB_ValueToMsgId(CFE_SB_CMD_MID);
CFE_MSG_Size_t Size = sizeof(EnDisRouteCmd);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgIdCmd, sizeof(MsgIdCmd), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);
EnDisRouteCmd.Payload.MsgId = SB_UT_LAST_VALID_MID;
EnDisRouteCmd.Payload.Pipe = 3;
CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd;
CFE_SB_ProcessCmdPipePkt();
EVTCNT(1);
EVTSENT(CFE_SB_ENBL_RTE3_EID);
} /* end Test_SB_Cmds_EnRouteInvParam */
/*
** Test command to enable a specific route using an invalid message ID
*/
void Test_SB_Cmds_EnRouteInvParam2(void)
{
CFE_SB_RouteCmd_t EnDisRouteCmd;
CFE_MSG_FcnCode_t FcnCode = CFE_SB_ENABLE_ROUTE_CC;