@@ -1287,7 +1287,16 @@ void Test_SB_Cmds_SendPrevSubs(void)
1287
1287
CFE_SB_ProcessCmdPipePkt ();
1288
1288
1289
1289
NumEvts += 8 ; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */
1290
- EVTCNT (NumEvts );
1290
+
1291
+ /* Event count is only exact if there were no collisions */
1292
+ if (UT_EventIsInHistory (CFE_SB_HASHCOLLISION_EID ))
1293
+ {
1294
+ ASSERT_TRUE (UT_GetNumEventsSent () > NumEvts );
1295
+ }
1296
+ else
1297
+ {
1298
+ EVTCNT (NumEvts );
1299
+ }
1291
1300
1292
1301
/* Round out the number to three full pkts in order to test branch path
1293
1302
* coverage, MSGID 0x0D was skipped in previous subscription loop
@@ -1321,7 +1330,15 @@ void Test_SB_Cmds_SendPrevSubs(void)
1321
1330
1322
1331
NumEvts += 8 ; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */
1323
1332
1324
- EVTCNT (NumEvts );
1333
+ /* Event count is only exact if there were no collisions */
1334
+ if (UT_EventIsInHistory (CFE_SB_HASHCOLLISION_EID ))
1335
+ {
1336
+ ASSERT_TRUE (UT_GetNumEventsSent () > NumEvts );
1337
+ }
1338
+ else
1339
+ {
1340
+ EVTCNT (NumEvts );
1341
+ }
1325
1342
1326
1343
EVTSENT (CFE_SB_SUBSCRIPTION_RCVD_EID );
1327
1344
EVTSENT (CFE_SB_SEND_NO_SUBS_EID );
@@ -1704,7 +1721,7 @@ void Test_DeletePipe_WithSubs(void)
1704
1721
SETUP (CFE_SB_Subscribe (MsgId3 , PipedId ));
1705
1722
ASSERT (CFE_SB_DeletePipe (PipedId ));
1706
1723
1707
- EVTCNT (14 );
1724
+ EVTCNT (10 );
1708
1725
1709
1726
EVTSENT (CFE_SB_PIPE_ADDED_EID );
1710
1727
EVTSENT (CFE_SB_PIPE_DELETED_EID );
@@ -1772,7 +1789,7 @@ void Test_DeletePipe_WithAppid(void)
1772
1789
1773
1790
ASSERT (CFE_SB_DeletePipeWithAppId (PipedId , AppId ));
1774
1791
1775
- EVTCNT (14 );
1792
+ EVTCNT (10 );
1776
1793
1777
1794
} /* end Test_DeletePipe_WithAppid */
1778
1795
@@ -2030,7 +2047,6 @@ void Test_Subscribe_API(void)
2030
2047
SB_UT_ADD_SUBTEST (Test_Subscribe_MaxDestCount );
2031
2048
SB_UT_ADD_SUBTEST (Test_Subscribe_MaxMsgIdCount );
2032
2049
SB_UT_ADD_SUBTEST (Test_Subscribe_SendPrevSubs );
2033
- SB_UT_ADD_SUBTEST (Test_Subscribe_FindGlobalMsgIdCnt );
2034
2050
SB_UT_ADD_SUBTEST (Test_Subscribe_PipeNonexistent );
2035
2051
SB_UT_ADD_SUBTEST (Test_Subscribe_SubscriptionReporting );
2036
2052
SB_UT_ADD_SUBTEST (Test_Subscribe_InvalidPipeOwner );
@@ -2274,9 +2290,6 @@ void Test_Subscribe_SendPrevSubs(void)
2274
2290
SETUP (CFE_SB_Subscribe (MsgId2 , PipeId1 ));
2275
2291
SETUP (CFE_SB_Subscribe (MsgId0 , PipeId2 ));
2276
2292
2277
- /* Set the last list header pointer to NULL to get branch path coverage */
2278
- CFE_SB .RoutingTbl [2 ].ListHeadPtr = NULL ;
2279
-
2280
2293
/* For internal SendMsg call */
2281
2294
MsgIdCmd = CFE_SB_ValueToMsgId (CFE_SB_ALLSUBS_TLM_MID );
2282
2295
Size = sizeof (CFE_SB .PrevSubMsg );
@@ -2295,46 +2308,6 @@ void Test_Subscribe_SendPrevSubs(void)
2295
2308
2296
2309
} /* end Test_Subscribe_SendPrevSubs */
2297
2310
2298
- /*
2299
- ** Test function to get a count of the global message ids in use
2300
- */
2301
- void Test_Subscribe_FindGlobalMsgIdCnt (void )
2302
- {
2303
- CFE_SB_PipeId_t PipeId0 ;
2304
- CFE_SB_PipeId_t PipeId1 ;
2305
- CFE_SB_PipeId_t PipeId2 ;
2306
- CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1 ;
2307
- CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2 ;
2308
- CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3 ;
2309
- uint16 PipeDepth = 50 ;
2310
- uint16 MsgLim = 4 ;
2311
-
2312
- SETUP (CFE_SB_CreatePipe (& PipeId0 , PipeDepth , "TestPipe0" ));
2313
- SETUP (CFE_SB_CreatePipe (& PipeId1 , PipeDepth , "TestPipe1" ));
2314
- SETUP (CFE_SB_CreatePipe (& PipeId2 , PipeDepth , "TestPipe2" ));
2315
- SETUP (CFE_SB_Subscribe (MsgId0 , PipeId0 ));
2316
- SETUP (CFE_SB_Subscribe (MsgId1 , PipeId0 ));
2317
- SETUP (CFE_SB_Subscribe (MsgId2 , PipeId0 ));
2318
- SETUP (CFE_SB_Subscribe (MsgId0 , PipeId1 ));
2319
- SETUP (CFE_SB_Subscribe (MsgId1 , PipeId1 ));
2320
- SETUP (CFE_SB_Subscribe (MsgId2 , PipeId1 ));
2321
- SETUP (CFE_SB_SubscribeLocal (MsgId0 , PipeId2 , MsgLim ));
2322
-
2323
- /* Set the last list head pointer to NULL for branch path coverage */
2324
- CFE_SB .RoutingTbl [2 ].ListHeadPtr = NULL ;
2325
-
2326
- ASSERT_EQ (CFE_SB_FindGlobalMsgIdCnt (), 2 ); /* 2 unique msg ids; the third is set to skip */
2327
-
2328
- EVTCNT (17 );
2329
-
2330
- EVTSENT (CFE_SB_PIPE_ADDED_EID );
2331
-
2332
- TEARDOWN (CFE_SB_DeletePipe (PipeId0 ));
2333
- TEARDOWN (CFE_SB_DeletePipe (PipeId1 ));
2334
- TEARDOWN (CFE_SB_DeletePipe (PipeId2 ));
2335
-
2336
- } /* end Test_Subscribe_FindGlobalMsgIdCnt */
2337
-
2338
2311
/*
2339
2312
** Test message subscription response to nonexistent pipe
2340
2313
*/
@@ -2366,29 +2339,29 @@ void Test_Subscribe_SubscriptionReporting(void)
2366
2339
SETUP (CFE_SB_CreatePipe (& PipeId , PipeDepth , "TestPipe" ));
2367
2340
2368
2341
/* Enable subscription reporting */
2369
- CFE_SB_SetSubscriptionReporting (CFE_SB_ENABLE );
2342
+ CFE_SB_SetSubscriptionReporting (CFE_SB_ENABLE );
2370
2343
2371
2344
/* For internal SendMsg call that will report subscription */
2372
2345
MsgIdRpt = CFE_SB_ValueToMsgId (CFE_SB_ONESUB_TLM_MID );
2373
2346
Size = sizeof (CFE_SB .SubRprtMsg );
2374
2347
UT_SetDataBuffer (UT_KEY (CFE_MSG_GetMsgId ), & MsgIdRpt , sizeof (MsgIdRpt ), false);
2375
2348
UT_SetDataBuffer (UT_KEY (CFE_MSG_GetSize ), & Size , sizeof (Size ), false);
2376
2349
2377
- /* Subscribe to message: GLOBAL */
2378
- SETUP (CFE_SB_Subscribe (MsgId , PipeId ));
2350
+ /* Subscribe to message: GLOBAL */
2351
+ SETUP (CFE_SB_Subscribe (MsgId , PipeId ));
2379
2352
2380
- /* Unsubscribe so that a local subscription can be tested */
2381
- SETUP (CFE_SB_Unsubscribe (MsgId , PipeId ));
2353
+ /* Unsubscribe so that a local subscription can be tested */
2354
+ SETUP (CFE_SB_Unsubscribe (MsgId , PipeId ));
2382
2355
2383
- /* Subscribe to message: LOCAL */
2384
- ASSERT (CFE_SB_SubscribeFull (MsgId , PipeId , Quality , CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT , CFE_SB_LOCAL ));
2356
+ /* Subscribe to message: LOCAL */
2357
+ ASSERT (CFE_SB_SubscribeFull (MsgId , PipeId , Quality , CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT , CFE_SB_LOCAL ));
2385
2358
2386
- EVTCNT (8 );
2359
+ EVTCNT (8 );
2387
2360
2388
- EVTSENT (CFE_SB_SUBSCRIPTION_RPT_EID );
2361
+ EVTSENT (CFE_SB_SUBSCRIPTION_RPT_EID );
2389
2362
2390
- /* Disable subscription reporting */
2391
- CFE_SB_SetSubscriptionReporting (CFE_SB_DISABLE );
2363
+ /* Disable subscription reporting */
2364
+ CFE_SB_SetSubscriptionReporting (CFE_SB_DISABLE );
2392
2365
2393
2366
TEARDOWN (CFE_SB_DeletePipe (PipeId ));
2394
2367
@@ -2538,22 +2511,21 @@ void Test_Unsubscribe_NoMatch(void)
2538
2511
{
2539
2512
CFE_SB_PipeId_t TestPipe ;
2540
2513
CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID ;
2541
- CFE_SB_MsgRouteIdx_t Idx ;
2542
2514
uint16 PipeDepth = 50 ;
2543
2515
2516
+ /* Create pipe, subscribe, unsubscribe */
2544
2517
SETUP (CFE_SB_CreatePipe (& TestPipe , PipeDepth , "TestPipe" ));
2545
2518
SETUP (CFE_SB_Subscribe (MsgId , TestPipe ));
2519
+ SETUP (CFE_SB_Unsubscribe (MsgId , TestPipe ));
2520
+ UT_ClearEventHistory ();
2546
2521
2522
+ /* Check that unsubscribe to msgid that was never subscribed reports error */
2547
2523
ASSERT (CFE_SB_Unsubscribe (SB_UT_TLM_MID1 , TestPipe ));
2524
+ EVTSENT (CFE_SB_UNSUB_NO_SUBS_EID );
2525
+ UT_ClearEventHistory ();
2548
2526
2549
- /* Get index into routing table */
2550
- Idx = CFE_SB_GetRoutingTblIdx (CFE_SB_ConvertMsgIdtoMsgKey (MsgId ));
2551
- CFE_SB .RoutingTbl [CFE_SB_RouteIdxToValue (Idx )].ListHeadPtr -> PipeId = 1 ;
2552
- CFE_SB .RoutingTbl [CFE_SB_RouteIdxToValue (Idx )].ListHeadPtr -> Next = NULL ;
2527
+ /* Check that repeated unsubscribe to msgid that was subscribted reports error */
2553
2528
ASSERT (CFE_SB_Unsubscribe (MsgId , TestPipe ));
2554
-
2555
- EVTCNT (7 );
2556
-
2557
2529
EVTSENT (CFE_SB_UNSUB_NO_SUBS_EID );
2558
2530
2559
2531
TEARDOWN (CFE_SB_DeletePipe (TestPipe ));
@@ -2681,18 +2653,21 @@ void Test_Unsubscribe_MiddleDestWithMany(void)
2681
2653
*/
2682
2654
void Test_Unsubscribe_GetDestPtr (void )
2683
2655
{
2684
- CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID ;
2685
- CFE_SB_PipeId_t TestPipe1 ;
2686
- CFE_SB_PipeId_t TestPipe2 ;
2687
- uint16 PipeDepth = 50 ;
2656
+ CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID ;
2657
+ CFE_SB_PipeId_t TestPipe1 ;
2658
+ CFE_SB_PipeId_t TestPipe2 ;
2659
+ uint16 PipeDepth = 50 ;
2660
+ CFE_SBR_RouteId_t RouteId ;
2688
2661
2689
2662
SETUP (CFE_SB_CreatePipe (& TestPipe1 , PipeDepth , "TestPipe1" ));
2690
2663
SETUP (CFE_SB_CreatePipe (& TestPipe2 , PipeDepth , "TestPipe2" ));
2691
2664
SETUP (CFE_SB_Subscribe (MsgId , TestPipe1 ));
2692
2665
SETUP (CFE_SB_Subscribe (MsgId , TestPipe2 ));
2693
2666
SETUP (CFE_SB_Unsubscribe (MsgId , TestPipe2 ));
2694
2667
2695
- ASSERT_TRUE (CFE_SB_GetDestPtr (CFE_SB_ConvertMsgIdtoMsgKey (MsgId ), TestPipe2 ) == NULL );
2668
+ /* TODO for now just get route id and use it, will need update when stubbed */
2669
+ RouteId = CFE_SBR_GetRouteId (MsgId );
2670
+ ASSERT_TRUE (CFE_SB_GetDestPtr (RouteId , TestPipe2 ) == NULL );
2696
2671
2697
2672
EVTCNT (7 );
2698
2673
@@ -3252,12 +3227,15 @@ void Test_SendMsg_DisabledDestination(void)
3252
3227
int32 PipeDepth ;
3253
3228
CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm ;
3254
3229
CFE_MSG_Size_t Size = sizeof (TlmPkt );
3230
+ CFE_SBR_RouteId_t RouteId ;
3255
3231
3256
3232
PipeDepth = 2 ;
3257
3233
3258
3234
SETUP (CFE_SB_CreatePipe (& PipeId , PipeDepth , "TestPipe" ));
3259
3235
SETUP (CFE_SB_Subscribe (MsgId , PipeId ));
3260
- DestPtr = CFE_SB_GetDestPtr (CFE_SB_ConvertMsgIdtoMsgKey (MsgId ), PipeId );
3236
+
3237
+ RouteId = CFE_SBR_GetRouteId (MsgId );
3238
+ DestPtr = CFE_SB_GetDestPtr (RouteId , PipeId );
3261
3239
DestPtr -> Active = CFE_SB_INACTIVE ;
3262
3240
3263
3241
UT_SetDataBuffer (UT_KEY (CFE_MSG_GetMsgId ), & MsgId , sizeof (MsgId ), false);
@@ -3857,41 +3835,8 @@ void Test_SB_SpecialCases(void)
3857
3835
SB_UT_ADD_SUBTEST (Test_SB_SendMsgPaths_IgnoreOpt );
3858
3836
SB_UT_ADD_SUBTEST (Test_RcvMsg_UnsubResubPath );
3859
3837
SB_UT_ADD_SUBTEST (Test_MessageString );
3860
- SB_UT_ADD_SUBTEST (Test_SB_IdxPushPop );
3861
3838
} /* end Test_SB_SpecialCases */
3862
3839
3863
- /*
3864
- ** Test msg key idx push pop
3865
- */
3866
- void Test_SB_IdxPushPop ()
3867
- {
3868
- int32 i ;
3869
- CFE_SB_MsgRouteIdx_t Idx ;
3870
-
3871
- CFE_SB_InitIdxStack ();
3872
-
3873
- for (i = 0 ; i < CFE_PLATFORM_SB_MAX_MSG_IDS ; i ++ )
3874
- {
3875
- /* Subscribe to maximum number of messages */
3876
- Idx = CFE_SB_RouteIdxPop_Unsync ();
3877
- ASSERT_EQ (CFE_SB_RouteIdxToValue (Idx ), i );
3878
- }
3879
-
3880
-
3881
- Idx = CFE_SB_RouteIdxPop_Unsync ();
3882
- ASSERT_EQ (CFE_SB_RouteIdxToValue (Idx ), CFE_SB_RouteIdxToValue (CFE_SB_INVALID_ROUTE_IDX ));
3883
-
3884
- for (i = 0 ; i < CFE_PLATFORM_SB_MAX_MSG_IDS ; i ++ )
3885
- {
3886
- /* Un-subscribe from all messages */
3887
- CFE_SB_RouteIdxPush_Unsync (CFE_SB_ValueToRouteIdx (i ));
3888
- }
3889
-
3890
- CFE_SB_RouteIdxPush_Unsync (CFE_SB_ValueToRouteIdx (i ));
3891
-
3892
-
3893
- } /* end Test_SB_IdxPushPop */
3894
-
3895
3840
/*
3896
3841
** Test pipe creation with semaphore take and give failures
3897
3842
*/
@@ -4037,10 +3982,10 @@ void Test_CFE_SB_BadPipeInfo(void)
4037
3982
4038
3983
4039
3984
} /* end Test_CFE_SB_BadPipeInfo */
3985
+
4040
3986
/*
4041
3987
** Test send housekeeping information command
4042
3988
*/
4043
-
4044
3989
void Test_SB_SendMsgPaths_Nominal (void )
4045
3990
{
4046
3991
CFE_SB_CmdHdr_t NoParamCmd ;
@@ -4062,12 +4007,17 @@ void Test_SB_SendMsgPaths_Nominal(void)
4062
4007
MsgId = CFE_SB_ValueToMsgId (CFE_SB_SEND_HK_MID );
4063
4008
UT_SetDataBuffer (UT_KEY (CFE_MSG_GetMsgId ), & MsgId , sizeof (MsgId ), false);
4064
4009
4010
+ /* Repress sending the no subscriptions event and process request */
4011
+ CFE_SB .HKTlmMsg .Payload .NoSubscribersCounter = 0 ;
4065
4012
CFE_SB .CmdPipePktPtr = (CFE_SB_MsgPtr_t ) & NoParamCmd ;
4066
4013
CFE_SB .StopRecurseFlags [1 ] |= CFE_BIT (CFE_SB_SEND_NO_SUBS_EID_BIT );
4067
4014
CFE_SB_ProcessCmdPipePkt ();
4068
4015
4016
+ /* The no subs event should not be in history but count should increment */
4069
4017
ASSERT_TRUE (!UT_EventIsInHistory (CFE_SB_SEND_NO_SUBS_EID ));
4018
+ ASSERT_EQ (CFE_SB .HKTlmMsg .Payload .NoSubscribersCounter , 1 );
4070
4019
4020
+ /* Repress get buffer error */
4071
4021
CFE_SB .HKTlmMsg .Payload .MsgSendErrorCounter = 0 ;
4072
4022
CFE_SB .StopRecurseFlags [1 ] |= CFE_BIT (CFE_SB_GET_BUF_ERR_EID_BIT );
4073
4023
@@ -4081,7 +4031,6 @@ void Test_SB_SendMsgPaths_Nominal(void)
4081
4031
MsgId = CFE_SB_ValueToMsgId (CFE_SB_SEND_HK_MID );
4082
4032
UT_SetDataBuffer (UT_KEY (CFE_MSG_GetMsgId ), & MsgId , sizeof (MsgId ), false);
4083
4033
4084
- CFE_SB .MsgMap [CFE_SB_MsgKeyToValue (CFE_SB_ConvertMsgIdtoMsgKey (CFE_SB_HK_TLM_MID ))] = CFE_SB_INVALID_ROUTE_IDX ;
4085
4034
UT_SetDeferredRetcode (UT_KEY (CFE_ES_GetPoolBuf ), 1 , CFE_ES_ERR_MEM_BLOCK_SIZE );
4086
4035
CFE_SB_ProcessCmdPipePkt ();
4087
4036
ASSERT_EQ (CFE_SB .HKTlmMsg .Payload .MsgSendErrorCounter , 0 );
0 commit comments