From 72c1c8d41262710e44aa55ba329fa78515f3212a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 22 Jun 2021 09:04:45 -0400 Subject: [PATCH] Partial #596, UtAssert macros for SBR test Update SBR coverage test to use preferred macros --- .../sbr/ut-coverage/test_cfe_sbr_map_direct.c | 22 +++++----- .../sbr/ut-coverage/test_cfe_sbr_map_hash.c | 18 ++++----- .../ut-coverage/test_cfe_sbr_route_unsorted.c | 40 +++++++++---------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c b/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c index d9c673abd..38800a178 100644 --- a/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c @@ -41,8 +41,8 @@ void Test_SBR_Map_Direct(void) uint32 i; UtPrintf("Invalid msg checks"); - CFE_UtAssert_EQUAL(CFE_SBR_SetRouteId(CFE_SB_ValueToMsgId(0), CFE_SBR_ValueToRouteId(0)), 0); - CFE_UtAssert_EQUAL(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(0))), false); + UtAssert_INT32_EQ(CFE_SBR_SetRouteId(CFE_SB_ValueToMsgId(0), CFE_SBR_ValueToRouteId(0)), 0); + CFE_UtAssert_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(0)))); UtPrintf("Initialize map"); CFE_SBR_Init_Map(); @@ -59,18 +59,18 @@ void Test_SBR_Map_Direct(void) count++; } } - CFE_UtAssert_EQUAL(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); + UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); UtPrintf("Set/Get a range of ids "); routeid = CFE_SBR_ValueToRouteId(CFE_PLATFORM_SB_MAX_MSG_IDS + 1); msgid = CFE_SB_ValueToMsgId(0); - CFE_UtAssert_EQUAL(CFE_SBR_SetRouteId(msgid, routeid), 0); - CFE_UtAssert_EQUAL(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); + UtAssert_INT32_EQ(CFE_SBR_SetRouteId(msgid, routeid), 0); + UtAssert_INT32_EQ(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); routeid = CFE_SBR_ValueToRouteId(0); msgid = CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); - CFE_UtAssert_EQUAL(CFE_SBR_SetRouteId(msgid, routeid), 0); - CFE_UtAssert_EQUAL(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); + UtAssert_INT32_EQ(CFE_SBR_SetRouteId(msgid, routeid), 0); + UtAssert_INT32_EQ(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); UtPrintf("Check there is now 1 valid entry in map"); count = 0; @@ -81,13 +81,13 @@ void Test_SBR_Map_Direct(void) count++; } } - CFE_UtAssert_EQUAL(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); + UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); UtPrintf("Set back to invalid and check again"); routeid = CFE_SBR_INVALID_ROUTE_ID; - CFE_UtAssert_EQUAL(CFE_SBR_SetRouteId(msgid, routeid), 0); - CFE_UtAssert_EQUAL(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); - CFE_UtAssert_EQUAL(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(msgid)), false); + UtAssert_INT32_EQ(CFE_SBR_SetRouteId(msgid, routeid), 0); + UtAssert_INT32_EQ(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); + CFE_UtAssert_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(msgid))); /* Performance check, 0xFFFFFF on 3.2GHz linux box is around 8-9 seconds */ count = 0; diff --git a/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c b/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c index f7a8a8110..1f173584a 100644 --- a/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c @@ -60,8 +60,8 @@ void Test_SBR_Map_Hash(void) uint32 collisions; UtPrintf("Invalid msg checks"); - CFE_UtAssert_EQUAL(CFE_SBR_SetRouteId(CFE_SB_ValueToMsgId(0), CFE_SBR_ValueToRouteId(0)), 0); - CFE_UtAssert_EQUAL(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(0))), false); + UtAssert_INT32_EQ(CFE_SBR_SetRouteId(CFE_SB_ValueToMsgId(0), CFE_SBR_ValueToRouteId(0)), 0); + CFE_UtAssert_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(0)))); UtPrintf("Initialize routing and map"); CFE_SBR_Init(); @@ -78,7 +78,7 @@ void Test_SBR_Map_Hash(void) count++; } } - CFE_UtAssert_EQUAL(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); + UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); /* Note AddRoute required for hash logic to work since it depends on MsgId in routing table */ UtPrintf("Add routes and check with a rollover and a skip"); @@ -86,15 +86,15 @@ void Test_SBR_Map_Hash(void) msgid[1] = Test_SBR_Unhash(0xFFFFFFFF); msgid[2] = Test_SBR_Unhash(0x7FFFFFFF); routeid[0] = CFE_SBR_AddRoute(msgid[0], &collisions); - CFE_UtAssert_EQUAL(collisions, 0); + UtAssert_INT32_EQ(collisions, 0); routeid[1] = CFE_SBR_AddRoute(msgid[1], &collisions); - CFE_UtAssert_EQUAL(collisions, 0); + UtAssert_INT32_EQ(collisions, 0); routeid[2] = CFE_SBR_AddRoute(msgid[2], &collisions); - CFE_UtAssert_EQUAL(collisions, 2); + UtAssert_INT32_EQ(collisions, 2); - CFE_UtAssert_EQUAL(CFE_SBR_RouteIdToValue(CFE_SBR_GetRouteId(msgid[0])), CFE_SBR_RouteIdToValue(routeid[0])); - CFE_UtAssert_EQUAL(CFE_SBR_RouteIdToValue(CFE_SBR_GetRouteId(msgid[1])), CFE_SBR_RouteIdToValue(routeid[1])); - CFE_UtAssert_EQUAL(CFE_SBR_RouteIdToValue(CFE_SBR_GetRouteId(msgid[2])), CFE_SBR_RouteIdToValue(routeid[2])); + UtAssert_INT32_EQ(CFE_SBR_RouteIdToValue(CFE_SBR_GetRouteId(msgid[0])), CFE_SBR_RouteIdToValue(routeid[0])); + UtAssert_INT32_EQ(CFE_SBR_RouteIdToValue(CFE_SBR_GetRouteId(msgid[1])), CFE_SBR_RouteIdToValue(routeid[1])); + UtAssert_INT32_EQ(CFE_SBR_RouteIdToValue(CFE_SBR_GetRouteId(msgid[2])), CFE_SBR_RouteIdToValue(routeid[2])); /* Performance check, 0xFFFFFF on 3.2GHz linux box is around 8-9 seconds */ count = 0; diff --git a/modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c b/modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c index b783f9a60..0b654041c 100644 --- a/modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c @@ -51,9 +51,9 @@ void Test_SBR_Route_Unsort_General(void) CFE_SBR_Init(); UtPrintf("Invalid msg checks"); - CFE_UtAssert_TRUE(!CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(0), NULL))); - CFE_UtAssert_TRUE(!CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(0), &collisions))); - CFE_UtAssert_EQUAL(collisions, 0); + CFE_UtAssert_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(0), NULL))); + CFE_UtAssert_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(0), &collisions))); + UtAssert_INT32_EQ(collisions, 0); /* * Force valid msgid responses @@ -65,18 +65,18 @@ void Test_SBR_Route_Unsort_General(void) UtPrintf("Callback test with no routes"); count = 0; CFE_SBR_ForEachRouteId(Test_SBR_Callback, &count, NULL); - CFE_UtAssert_EQUAL(count, 0); + UtAssert_INT32_EQ(count, 0); UtPrintf("Add maximum mesage id value"); msgid = CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); routeid = CFE_SBR_AddRoute(msgid, &collisions); - CFE_UtAssert_EQUAL(collisions, 0); + UtAssert_INT32_EQ(collisions, 0); CFE_UtAssert_TRUE(CFE_SBR_IsValidRouteId(routeid)); UtPrintf("Callback test with one route"); count = 0; CFE_SBR_ForEachRouteId(Test_SBR_Callback, &count, NULL); - CFE_UtAssert_EQUAL(count, 1); + UtAssert_INT32_EQ(count, 1); UtPrintf("Fill routing table"); count = 0; @@ -86,30 +86,30 @@ void Test_SBR_Route_Unsort_General(void) } /* Check for expected count indicating full routing table */ - CFE_UtAssert_EQUAL(count + 1, CFE_PLATFORM_SB_MAX_MSG_IDS); + UtAssert_INT32_EQ(count + 1, CFE_PLATFORM_SB_MAX_MSG_IDS); /* Try one more for good luck */ - CFE_UtAssert_TRUE(!CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(count), NULL))); + CFE_UtAssert_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(count), NULL))); /* Check that maximum msgid is still in the table */ - CFE_UtAssert_EQUAL(CFE_SB_MsgIdToValue(CFE_SBR_GetMsgId(routeid)), CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); - CFE_UtAssert_EQUAL(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); + UtAssert_INT32_EQ(CFE_SB_MsgIdToValue(CFE_SBR_GetMsgId(routeid)), CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); + UtAssert_INT32_EQ(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); UtPrintf("Callback test with full route"); count = 0; CFE_SBR_ForEachRouteId(Test_SBR_Callback, &count, NULL); - CFE_UtAssert_EQUAL(count, CFE_PLATFORM_SB_MAX_MSG_IDS); + UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_MAX_MSG_IDS); UtPrintf("Callback test throttled"); throttle.MaxLoop = CFE_PLATFORM_SB_MAX_MSG_IDS - 1; throttle.StartIndex = 0; count = 0; CFE_SBR_ForEachRouteId(Test_SBR_Callback, &count, &throttle); - CFE_UtAssert_EQUAL(count, CFE_PLATFORM_SB_MAX_MSG_IDS - 1); + UtAssert_UINT32_EQ(count, CFE_PLATFORM_SB_MAX_MSG_IDS - 1); count = 0; throttle.StartIndex = throttle.NextIndex; CFE_SBR_ForEachRouteId(Test_SBR_Callback, &count, &throttle); - CFE_UtAssert_EQUAL(count, 1); + UtAssert_INT32_EQ(count, 1); } void Test_SBR_Route_Unsort_GetSet(void) @@ -130,7 +130,7 @@ void Test_SBR_Route_Unsort_GetSet(void) { CFE_UtAssert_TRUE(CFE_SB_MsgId_Equal(CFE_SBR_GetMsgId(routeid[i]), CFE_SB_INVALID_MSG_ID)); UtAssert_ADDRESS_EQ(CFE_SBR_GetDestListHeadPtr(routeid[i]), NULL); - CFE_UtAssert_EQUAL(CFE_SBR_GetSequenceCounter(routeid[i]), 0); + UtAssert_INT32_EQ(CFE_SBR_GetSequenceCounter(routeid[i]), 0); } /* @@ -154,7 +154,7 @@ void Test_SBR_Route_Unsort_GetSet(void) count++; } } - CFE_UtAssert_EQUAL(count, 0); + UtAssert_INT32_EQ(count, 0); UtPrintf("Add routes and initialize values for testing"); msgid[0] = CFE_SB_ValueToMsgId(0); @@ -174,19 +174,19 @@ void Test_SBR_Route_Unsort_GetSet(void) CFE_UtAssert_TRUE(CFE_SB_MsgId_Equal(msgid[i], CFE_SBR_GetMsgId(routeid[i]))); CFE_SBR_IncrementSequenceCounter(routeid[0]); } - CFE_UtAssert_EQUAL(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 3); + UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 3); /* Increment route 1 once and set dest pointers */ UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), seqcntexpected[1]); CFE_SBR_IncrementSequenceCounter(routeid[1]); - CFE_UtAssert_EQUAL(UT_GetStubCount(UT_KEY(CFE_MSG_GetNextSequenceCount)), 4); + UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 4); CFE_SBR_SetDestListHeadPtr(routeid[1], &dest[1]); CFE_SBR_SetDestListHeadPtr(routeid[2], &dest[0]); UtPrintf("Verify remaining set values"); - CFE_UtAssert_EQUAL(CFE_SBR_GetSequenceCounter(routeid[0]), seqcntexpected[0]); - CFE_UtAssert_EQUAL(CFE_SBR_GetSequenceCounter(routeid[1]), seqcntexpected[1]); - CFE_UtAssert_EQUAL(CFE_SBR_GetSequenceCounter(routeid[2]), 0); + UtAssert_UINT32_EQ(CFE_SBR_GetSequenceCounter(routeid[0]), seqcntexpected[0]); + UtAssert_UINT32_EQ(CFE_SBR_GetSequenceCounter(routeid[1]), seqcntexpected[1]); + UtAssert_INT32_EQ(CFE_SBR_GetSequenceCounter(routeid[2]), 0); UtAssert_ADDRESS_EQ(CFE_SBR_GetDestListHeadPtr(routeid[0]), NULL); UtAssert_ADDRESS_EQ(CFE_SBR_GetDestListHeadPtr(routeid[1]), &dest[1]); UtAssert_ADDRESS_EQ(CFE_SBR_GetDestListHeadPtr(routeid[2]), &dest[0]);