diff --git a/unit-test/ds_app_tests.c b/unit-test/ds_app_tests.c index 2a72a7f..abc4dce 100644 --- a/unit-test/ds_app_tests.c +++ b/unit-test/ds_app_tests.c @@ -34,7 +34,6 @@ #include "ds_events.h" #include "ds_version.h" #include "ds_test_utils.h" -/*#include "ut_utils_lib.h"*/ #include "ds_cmds.h" #include "ds_file.h" @@ -79,23 +78,12 @@ void DS_AppMain_Test_Nominal(void) DS_AppMain(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - - call_count_CFE_ES_WriteToSysLog = UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)); - UtAssert_INT32_EQ(call_count_CFE_ES_WriteToSysLog, 0); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 0); } /* end DS_AppMain_Test_Nominal */ void DS_AppMain_Test_AppInitializeError(void) { - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Application terminating, err = 0x%%08X"); - - char ExpectedSysLogString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedSysLogString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "DS application terminating, err = 0x%%08X\n"); - /* Set to exit loop after first run */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_RunLoop), 2, false); @@ -110,37 +98,15 @@ void DS_AppMain_Test_AppInitializeError(void) DS_AppMain(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_EXIT_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_CRITICAL); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_ES_ExitApp)), 1); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - - call_count_CFE_ES_WriteToSysLog = UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)); - UtAssert_INT32_EQ(call_count_CFE_ES_WriteToSysLog, 1); - - strCmpResult = strncmp(ExpectedSysLogString, context_CFE_ES_WriteToSysLog.Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_ES_WriteToSysLog.Spec); - + UtAssert_STUB_COUNT(CFE_ES_ExitApp, 1); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); } /* end DS_AppMain_Test_AppInitializeError */ void DS_AppMain_Test_SBError(void) { - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Application terminating, err = 0x%%08X"); - - char ExpectedSysLogString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedSysLogString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "DS application terminating, err = 0x%%08X\n"); - /* Set to exit loop after first run */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RunLoop), true); UT_SetDeferredRetcode(UT_KEY(CFE_ES_RunLoop), 2, false); @@ -152,26 +118,11 @@ void DS_AppMain_Test_SBError(void) DS_AppMain(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); - - /* Generates 1 event message we don't care about in this test */ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_EXIT_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_CRITICAL); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_ES_ExitApp)), 1); - - call_count_CFE_ES_WriteToSysLog = UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)); - UtAssert_INT32_EQ(call_count_CFE_ES_WriteToSysLog, 1); - strCmpResult = strncmp(ExpectedSysLogString, context_CFE_ES_WriteToSysLog.Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_ES_WriteToSysLog.Spec); - + UtAssert_STUB_COUNT(CFE_ES_ExitApp, 1); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); } /* end DS_AppMain_Test_SBError */ void DS_AppMain_Test_SBTimeout(void) @@ -187,29 +138,20 @@ void DS_AppMain_Test_SBTimeout(void) DS_AppMain(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_FileTestAge)), 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UtAssert_STUB_COUNT(DS_FileTestAge, 1); } /* end DS_AppMain_Test_SBTimeout */ void DS_AppInitialize_Test_Nominal(void) { - int32 Result; - int32 strCmpResult; - - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Application initialized, version %%d.%%d.%%d.%%d, data at %%p"); - memset(&DS_AppData, 1, sizeof(DS_AppData)); /* Execute the function being tested */ - Result = DS_AppInitialize(); + UtAssert_INT32_EQ(DS_AppInitialize(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE, "DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE"); + UtAssert_UINT32_EQ(DS_AppData.AppEnableState, DS_DEF_ENABLE_STATE); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[0].FileHandle)); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle)); @@ -218,33 +160,21 @@ void DS_AppInitialize_Test_Nominal(void) /* Note: not verifying the rest of DS_AppData is set to 0, because some elements of DS_AppData * are modified by subfunctions, which we're not testing here */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION); - - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_AppInitialize_Test_Nominal */ void DS_AppInitialize_Test_EVSRegisterError(void) { - int32 Result; - /* Set to generate error message DS_INIT_ERR_EID for EVS services */ UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, -1); /* Execute the function being tested */ - Result = DS_AppInitialize(); + UtAssert_INT32_EQ(DS_AppInitialize(), -1); /* Verify results */ - UtAssert_True(DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE, "DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE"); + UtAssert_UINT32_EQ(DS_AppData.AppEnableState, DS_DEF_ENABLE_STATE); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[0].FileHandle)); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle)); @@ -252,30 +182,22 @@ void DS_AppInitialize_Test_EVSRegisterError(void) /* Note: not verifying that rest of DS_AppData is set to 0, because some elements of DS_AppData * are modified by subfunctions, which we're not testing here */ - /* - UtAssert_True - (Ut_CFE_EVS_EventSent(DS_INIT_ERR_EID, CFE_EVS_ERROR, "Unable to register for EVS services, err = - 0xFFFFFFFF"), "Unable to register for EVS services, err = 0xFFFFFFFF"); - */ - UtAssert_True(Result == -1, "Result == -1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); } /* end DS_AppInitialize_Test_EVSRegisterError */ void DS_AppInitialize_Test_SBCreatePipeError(void) { - int32 Result; - /* Set to generate error message DS_INIT_ERR_EID for input pipe */ UT_SetDeferredRetcode(UT_KEY(CFE_SB_CreatePipe), 1, -1); /* Execute the function being tested */ - Result = DS_AppInitialize(); + UtAssert_INT32_EQ(DS_AppInitialize(), -1); /* Verify results */ - UtAssert_True(DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE, "DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE"); + UtAssert_UINT32_EQ(DS_AppData.AppEnableState, DS_DEF_ENABLE_STATE); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[0].FileHandle)); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle)); @@ -283,31 +205,22 @@ void DS_AppInitialize_Test_SBCreatePipeError(void) /* Note: not verifying that the rest of DS_AppData is set to 0, because some elements of DS_AppData * are modified by subfunctions, which we're not testing here */ - - /*UtAssert_True - (Ut_CFE_EVS_EventSent(DS_INIT_ERR_EID, CFE_EVS_ERROR, "Unable to create input pipe, err = 0xFFFFFFFF"), - "Unable to create input pipe, err = 0xFFFFFFFF"); -*/ - - UtAssert_True(Result == -1, "Result == -1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); } /* end DS_AppInitialize_Test_SBCreatePipeError */ void DS_AppInitialize_Test_SBSubscribeHKError(void) { - int32 Result; - /* Set to generate error message DS_INIT_ERR_EID for HK request */ UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 1, -1); /* Execute the function being tested */ - Result = DS_AppInitialize(); + UtAssert_INT32_EQ(DS_AppInitialize(), -1); /* Verify results */ - UtAssert_True(DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE, "DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE"); + UtAssert_UINT32_EQ(DS_AppData.AppEnableState, DS_DEF_ENABLE_STATE); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[0].FileHandle)); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle)); @@ -315,31 +228,22 @@ void DS_AppInitialize_Test_SBSubscribeHKError(void) /* Note: not verifying that the rest of DS_AppData is set to 0, because some elements of DS_AppData * are modified by subfunctions, which we're not testing here */ - /* - UtAssert_True - (Ut_CFE_EVS_EventSent(DS_INIT_ERR_EID, CFE_EVS_ERROR, "Unable to subscribe to HK request, err = - 0xFFFFFFFF"), "Unable to subscribe to HK request, err = 0xFFFFFFFF"); - */ - - UtAssert_True(Result == -1, "Result == -1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); } /* end DS_AppInitialize_Test_SBSubscribeHKError */ void DS_AppInitialize_Test_SBSubscribeDSError(void) { - int32 Result; - /* Set to generate error message DS_INIT_ERR_EID for DS commands */ UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 2, -1); /* Execute the function being tested */ - Result = DS_AppInitialize(); + UtAssert_INT32_EQ(DS_AppInitialize(), -1); /* Verify results */ - UtAssert_True(DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE, "DS_AppData.AppEnableState == DS_DEF_ENABLE_STATE"); + UtAssert_UINT32_EQ(DS_AppData.AppEnableState, DS_DEF_ENABLE_STATE); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[0].FileHandle)); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle)); @@ -347,22 +251,15 @@ void DS_AppInitialize_Test_SBSubscribeDSError(void) /* Note: not verifying that the rest of DS_AppData is set to 0, because some elements of DS_AppData * are modified by subfunctions, which we're not testing here */ - - /* UtAssert_True - (Ut_CFE_EVS_EventSent(DS_INIT_ERR_EID, CFE_EVS_ERROR, "Unable to subscribe to DS commands, err = - 0xFFFFFFFF"), "Unable to subscribe to DS commands, err = 0xFFFFFFFF"); - */ - UtAssert_True(Result == -1, "Result == -1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); } /* end DS_AppInitialize_Test_SBSubscribeDSError */ void DS_AppProcessMsg_Test_CmdStore(void) { DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; size_t forced_Size = sizeof(DS_NoopCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; @@ -371,7 +268,6 @@ void DS_AppProcessMsg_Test_CmdStore(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); @@ -384,9 +280,7 @@ void DS_AppProcessMsg_Test_CmdStore(void) DS_AppProcessMsg(&UT_CmdBuf.Buf); /* Verify results */ - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* Verifying that the DisabledPktCounter == 1 confirms that an attempt was * made to store this packet (setting AppEnableState to DS_DISABLED forces @@ -401,7 +295,6 @@ void DS_AppProcessMsg_Test_CmdStore(void) void DS_AppProcessMsg_Test_CmdNoStore(void) { DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; size_t forced_Size = sizeof(DS_NoopCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; @@ -410,7 +303,6 @@ void DS_AppProcessMsg_Test_CmdNoStore(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); @@ -423,9 +315,7 @@ void DS_AppProcessMsg_Test_CmdNoStore(void) DS_AppProcessMsg(&UT_CmdBuf.Buf); /* Verify results */ - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* Verifying that the DisabledPktCounter == 0 confirms that no attempt was * made to store this packet (setting AppEnableState to DS_DISABLED forces @@ -439,16 +329,14 @@ void DS_AppProcessMsg_Test_CmdNoStore(void) void DS_AppProcessMsg_Test_HKStore(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; - size_t forced_Size = sizeof(DS_NoopCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); + DS_HashLink_t HashLink; + size_t forced_Size = sizeof(DS_NoopCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); DS_AppData.AppEnableState = DS_DISABLED; DS_AppData.HashTable[188] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); @@ -460,7 +348,7 @@ void DS_AppProcessMsg_Test_HKStore(void) DS_AppProcessMsg(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1); + UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); /* verifying a sent message indirectly verifies that DS_AppProcessHK was * called */ @@ -469,23 +357,20 @@ void DS_AppProcessMsg_Test_HKStore(void) * this counter to increment when the attempt is made). */ UtAssert_INT32_EQ(DS_AppData.DisabledPktCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppProcessMsg_Test_HKStore */ void DS_AppProcessMsg_Test_HKNoStore(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; - size_t forced_Size = sizeof(DS_NoopCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); + DS_HashLink_t HashLink; + size_t forced_Size = sizeof(DS_NoopCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); DS_AppData.AppEnableState = DS_DISABLED; DS_AppData.HashTable[188] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); @@ -497,7 +382,7 @@ void DS_AppProcessMsg_Test_HKNoStore(void) DS_AppProcessMsg(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1); + UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); /* verifying a sent message indirectly verifies that DS_AppProcessHK was * called */ @@ -506,8 +391,7 @@ void DS_AppProcessMsg_Test_HKNoStore(void) * this counter to increment when the attempt is made). */ UtAssert_INT32_EQ(DS_AppData.DisabledPktCounter, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppProcessMsg_Test_HKNoStore */ @@ -524,12 +408,9 @@ void DS_AppProcessMsg_Test_HKInvalidRequest(void) DS_AppProcessMsg(&UT_CmdBuf.Buf); /* Verify results */ - /*UtAssert_True - (Ut_CFE_EVS_EventSent(DS_HK_REQUEST_ERR_EID, CFE_EVS_ERROR, "Invalid HK request length: expected = 8, actual = - 0"), "Invalid HK request length: expected = 8, actual = 0"); -*/ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_HK_REQUEST_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); } /* end DS_AppProcessMsg_Test_HKInvalidRequest */ @@ -546,8 +427,7 @@ void DS_AppProcessMsg_Test_UnknownMID(void) DS_AppProcessMsg(&UT_CmdBuf.Buf); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppProcessMsg_Test_UnknownMID */ @@ -565,7 +445,7 @@ void DS_AppProcessCmd_Test_Noop(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdNoop)), 1); + UtAssert_STUB_COUNT(DS_CmdNoop, 1); } /* end DS_AppProcessCmd_Test_Noop */ @@ -583,7 +463,7 @@ void DS_AppProcessCmd_Test_Reset(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdReset)), 1); + UtAssert_STUB_COUNT(DS_CmdReset, 1); } /* end DS_AppProcessCmd_Test_Reset */ @@ -601,7 +481,7 @@ void DS_AppProcessCmd_Test_SetAppState(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetAppState)), 1); + UtAssert_STUB_COUNT(DS_CmdSetAppState, 1); } /* end DS_AppProcessCmd_Test_SetAppState */ void DS_AppProcessCmd_Test_SetFilterFile(void) @@ -618,7 +498,7 @@ void DS_AppProcessCmd_Test_SetFilterFile(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetFilterFile)), 1); + UtAssert_STUB_COUNT(DS_CmdSetFilterFile, 1); } /* end DS_AppProcessCmd_Test_SetFilterFile */ void DS_AppProcessCmd_Test_SetFilterType(void) @@ -635,7 +515,7 @@ void DS_AppProcessCmd_Test_SetFilterType(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetFilterType)), 1); + UtAssert_STUB_COUNT(DS_CmdSetFilterType, 1); } /* end DS_AppProcessCmd_Test_SetFilterType */ @@ -653,7 +533,7 @@ void DS_AppProcessCmd_Test_SetFilterParms(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetFilterParms)), 1); + UtAssert_STUB_COUNT(DS_CmdSetFilterParms, 1); } /* end DS_AppProcessCmd_Test_SetFilterParms */ void DS_AppProcessCmd_Test_SetDestType(void) @@ -670,7 +550,7 @@ void DS_AppProcessCmd_Test_SetDestType(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestType)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestType, 1); } /* end DS_AppProcessCmd_Test_SetDestType */ void DS_AppProcessCmd_Test_SetDestState(void) @@ -687,7 +567,7 @@ void DS_AppProcessCmd_Test_SetDestState(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestState)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestState, 1); } /* end DS_AppProcessCmd_Test_SetDestState */ void DS_AppProcessCmd_Test_SetDestPath(void) @@ -704,7 +584,7 @@ void DS_AppProcessCmd_Test_SetDestPath(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestPath)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestPath, 1); } /* end DS_AppProcessCmd_Test_SetDestPath */ void DS_AppProcessCmd_Test_SetDestBase(void) @@ -721,7 +601,7 @@ void DS_AppProcessCmd_Test_SetDestBase(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestBase)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestBase, 1); } /* end DS_AppProcessCmd_Test_SetDestBase */ void DS_AppProcessCmd_Test_SetDestExt(void) @@ -738,7 +618,7 @@ void DS_AppProcessCmd_Test_SetDestExt(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestExt)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestExt, 1); } /* end DS_AppProcessCmd_Test_SetDestExt */ @@ -756,7 +636,7 @@ void DS_AppProcessCmd_Test_SetDestSize(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestSize)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestSize, 1); } /* end DS_AppProcessCmd_Test_SetDestSize */ void DS_AppProcessCmd_Test_SetDestAge(void) @@ -773,7 +653,7 @@ void DS_AppProcessCmd_Test_SetDestAge(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestAge)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestAge, 1); } /* end DS_AppProcessCmd_Test_SetDestAge */ void DS_AppProcessCmd_Test_SetDestCount(void) @@ -790,7 +670,7 @@ void DS_AppProcessCmd_Test_SetDestCount(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdSetDestCount)), 1); + UtAssert_STUB_COUNT(DS_CmdSetDestCount, 1); } /* end DS_AppProcessCmd_Test_SetDestCount */ void DS_AppProcessCmd_Test_CloseFile(void) @@ -813,7 +693,7 @@ void DS_AppProcessCmd_Test_CloseFile(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdCloseFile)), 1); + UtAssert_STUB_COUNT(DS_CmdCloseFile, 1); } /* end DS_AppProcessCmd_Test_CloseFile */ void DS_AppProcessCmd_Test_GetFileInfo(void) @@ -830,7 +710,7 @@ void DS_AppProcessCmd_Test_GetFileInfo(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdGetFileInfo)), 1); + UtAssert_STUB_COUNT(DS_CmdGetFileInfo, 1); } /* end DS_AppProcessCmd_Test_GetFileInfo */ void DS_AppProcessCmd_Test_AddMID(void) @@ -847,7 +727,7 @@ void DS_AppProcessCmd_Test_AddMID(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdAddMID)), 1); + UtAssert_STUB_COUNT(DS_CmdAddMID, 1); } /* end DS_AppProcessCmd_Test_AddMID */ void DS_AppProcessCmd_Test_CloseAll(void) @@ -870,7 +750,7 @@ void DS_AppProcessCmd_Test_CloseAll(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_CmdCloseAll)), 1); + UtAssert_STUB_COUNT(DS_CmdCloseAll, 1); } /* end DS_AppProcessCmd_Test_CloseAll */ void DS_AppProcessCmd_Test_InvalidCommandCode(void) @@ -887,10 +767,9 @@ void DS_AppProcessCmd_Test_InvalidCommandCode(void) DS_AppProcessCmd(&UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.CmdRejectedCounter == 1, "DS_AppData.CmdRejectedCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.CmdRejectedCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } /* end DS_AppProcessCmd_Test_InvalidCommandCode */ @@ -909,27 +788,21 @@ void DS_AppProcessHK_Test(void) DS_AppProcessHK(); /* Verify results */ - UtAssert_True(DS_AppData.FileStatus[0].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[0].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[0].FileGrowth == 0, "DS_AppData.FileStatus[0].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileGrowth, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileGrowth == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileGrowth, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth, 0); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1); + UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); /* Verify command struct size minus header is at least explicitly padded to 32-bit boundaries */ - UtAssert_True(TLM_STRUCT_DATA_IS_32_ALIGNED(DS_HkPacket_t), "DS_HkPacket_t is 32-bit aligned"); + UtAssert_BOOL_TRUE(TLM_STRUCT_DATA_IS_32_ALIGNED(DS_HkPacket_t)); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppProcessHK_Test */ @@ -950,24 +823,19 @@ void DS_AppProcessHK_Test_SnprintfFail(void) DS_AppProcessHK(); /* Verify results */ - UtAssert_True(DS_AppData.FileStatus[0].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[0].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[0].FileGrowth == 0, "DS_AppData.FileStatus[0].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileGrowth, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileGrowth == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileGrowth, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth, 0); UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); /* Verify command struct size minus header is at least explicitly padded to 32-bit boundaries */ - UtAssert_True(TLM_STRUCT_DATA_IS_32_ALIGNED(DS_HkPacket_t), "DS_HkPacket_t is 32-bit aligned"); + UtAssert_BOOL_TRUE(TLM_STRUCT_DATA_IS_32_ALIGNED(DS_HkPacket_t)); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_APPHK_FILTER_TBL_PRINT_ERR_EID); @@ -991,58 +859,45 @@ void DS_AppProcessHK_Test_TblFail(void) DS_AppProcessHK(); /* Verify results */ - UtAssert_True(DS_AppData.FileStatus[0].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[0].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[0].FileGrowth == 0, "DS_AppData.FileStatus[0].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileGrowth, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileGrowth == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileGrowth, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate == 99 / DS_SECS_PER_HK_CYCLE, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate == 99 / DS_SECS_PER_HK_CYCLE"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileRate, 99 / DS_SECS_PER_HK_CYCLE); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileGrowth, 0); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1); + UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); /* Verify command struct size minus header is at least explicitly padded to 32-bit boundaries */ - UtAssert_True(TLM_STRUCT_DATA_IS_32_ALIGNED(DS_HkPacket_t), "DS_HkPacket_t is 32-bit aligned"); + UtAssert_BOOL_TRUE(TLM_STRUCT_DATA_IS_32_ALIGNED(DS_HkPacket_t)); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } void DS_AppStorePacket_Test_Nominal(void) { - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_DestFileTable_t destTable; - DS_FilterTable_t filterTable; - size_t forced_Size = sizeof(DS_CloseAllCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); - CFE_MSG_FcnCode_t forced_CmdCode = 99; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + size_t forced_Size = sizeof(DS_CloseAllCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); + CFE_MSG_FcnCode_t forced_CmdCode = 99; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); DS_AppData.AppEnableState = DS_ENABLED; - DS_AppData.DestFileTblPtr = &destTable; - DS_AppData.FilterTblPtr = &filterTable; /* Execute the function being tested */ DS_AppStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results -- IgnoredPktCounter increments in call to DS_FileStorePacket() */ - UtAssert_True(DS_AppData.IgnoredPktCounter == 0, "DS_AppData.IgnoredPktCounter == 0"); - - UtAssert_True(DS_AppData.DisabledPktCounter == 0, "DS_AppData.DisabledPktCounter == 0"); + UtAssert_UINT32_EQ(DS_AppData.IgnoredPktCounter, 0); + UtAssert_UINT32_EQ(DS_AppData.DisabledPktCounter, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_FileStorePacket)), 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(DS_FileStorePacket, 1); } /* end DS_AppStorePacket_Test_Nominal */ void DS_AppStorePacket_Test_DSDisabled(void) @@ -1062,44 +917,39 @@ void DS_AppStorePacket_Test_DSDisabled(void) DS_AppStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.DisabledPktCounter == 1, "DS_AppData.DisabledPktCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.DisabledPktCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppStorePacket_Test_DSDisabled */ void DS_AppStorePacket_Test_FilterTableNotLoaded(void) { - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_DestFileTable_t destTable; - size_t forced_Size = sizeof(DS_CloseAllCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); - CFE_MSG_FcnCode_t forced_CmdCode = 99; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + size_t forced_Size = sizeof(DS_CloseAllCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); + CFE_MSG_FcnCode_t forced_CmdCode = 99; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); DS_AppData.AppEnableState = DS_ENABLED; - DS_AppData.DestFileTblPtr = &destTable; /* force to non-zero so filter table is tested */ DS_AppData.FilterTblPtr = 0; /* Execute the function being tested */ DS_AppStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.IgnoredPktCounter == 1, "DS_AppData.IgnoredPktCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.IgnoredPktCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppStorePacket_Test_FilterTableNotLoaded */ void DS_AppStorePacket_Test_DestFileTableNotLoaded(void) { - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t filterTable; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; size_t forced_Size = sizeof(DS_CloseAllCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); CFE_MSG_FcnCode_t forced_CmdCode = 99; @@ -1109,82 +959,66 @@ void DS_AppStorePacket_Test_DestFileTableNotLoaded(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); DS_AppData.AppEnableState = DS_ENABLED; - DS_AppData.FilterTblPtr = &filterTable; /* Force to non-zero so destination table is tested */ DS_AppData.DestFileTblPtr = 0; /* Execute the function being tested */ DS_AppStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.IgnoredPktCounter == 1, "DS_AppData.IgnoredPktCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.IgnoredPktCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_AppStorePacket_Test_DestFileTableNotLoaded */ void UtTest_Setup(void) { - UtTest_Add(DS_AppMain_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_AppMain_Test_Nominal"); - UtTest_Add(DS_AppMain_Test_AppInitializeError, DS_Test_Setup, DS_Test_TearDown, - "DS_AppMain_Test_AppInitializeError"); - UtTest_Add(DS_AppMain_Test_SBError, DS_Test_Setup, DS_Test_TearDown, "DS_AppMain_Test_SBError"); - UtTest_Add(DS_AppMain_Test_SBTimeout, DS_Test_Setup, DS_Test_TearDown, "DS_AppMain_Test_SBTimeout"); - - UtTest_Add(DS_AppInitialize_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_AppInitialize_Test_Nominal"); - UtTest_Add(DS_AppInitialize_Test_EVSRegisterError, DS_Test_Setup, DS_Test_TearDown, - "DS_AppInitialize_Test_EVSRegisterError"); - UtTest_Add(DS_AppInitialize_Test_SBCreatePipeError, DS_Test_Setup, DS_Test_TearDown, - "DS_AppInitialize_Test_SBCreatePipeError"); - UtTest_Add(DS_AppInitialize_Test_SBSubscribeHKError, DS_Test_Setup, DS_Test_TearDown, - "DS_AppInitialize_Test_SBSubscribeHKError"); - UtTest_Add(DS_AppInitialize_Test_SBSubscribeDSError, DS_Test_Setup, DS_Test_TearDown, - "DS_AppInitialize_Test_SBSubscribeDSError"); - - UtTest_Add(DS_AppProcessMsg_Test_CmdStore, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessMsg_Test_CmdStore"); - UtTest_Add(DS_AppProcessMsg_Test_CmdNoStore, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessMsg_Test_CmdNoStore"); - UtTest_Add(DS_AppProcessMsg_Test_HKStore, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessMsg_Test_HKStore"); - UtTest_Add(DS_AppProcessMsg_Test_HKNoStore, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessMsg_Test_HKNoStore"); - UtTest_Add(DS_AppProcessMsg_Test_HKInvalidRequest, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessMsg_Test_HKInvalidRequest"); - UtTest_Add(DS_AppProcessMsg_Test_UnknownMID, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessMsg_Test_UnknownMID"); - - UtTest_Add(DS_AppProcessCmd_Test_Noop, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_Noop"); - UtTest_Add(DS_AppProcessCmd_Test_Reset, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_Reset"); - UtTest_Add(DS_AppProcessCmd_Test_SetAppState, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetAppState"); - UtTest_Add(DS_AppProcessCmd_Test_SetFilterFile, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessCmd_Test_SetFilterFile"); - UtTest_Add(DS_AppProcessCmd_Test_SetFilterType, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessCmd_Test_SetFilterType"); - UtTest_Add(DS_AppProcessCmd_Test_SetFilterParms, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessCmd_Test_SetFilterParms"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestType, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetDestType"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestState, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessCmd_Test_SetDestState"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestPath, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetDestPath"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestBase, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetDestBase"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestExt, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetDestExt"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestSize, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetDestSize"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestAge, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_SetDestAge"); - UtTest_Add(DS_AppProcessCmd_Test_SetDestCount, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessCmd_Test_SetDestCount"); - UtTest_Add(DS_AppProcessCmd_Test_CloseFile, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_CloseFile"); - UtTest_Add(DS_AppProcessCmd_Test_GetFileInfo, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_GetFileInfo"); - UtTest_Add(DS_AppProcessCmd_Test_AddMID, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_AddMID"); - UtTest_Add(DS_AppProcessCmd_Test_CloseAll, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessCmd_Test_CloseAll"); - UtTest_Add(DS_AppProcessCmd_Test_InvalidCommandCode, DS_Test_Setup, DS_Test_TearDown, - "DS_AppProcessCmd_Test_InvalidCommandCode"); - - UtTest_Add(DS_AppProcessHK_Test, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessHK_Test"); - UtTest_Add(DS_AppProcessHK_Test_SnprintfFail, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessHK_Test_SnprintfFail"); - UtTest_Add(DS_AppProcessHK_Test_TblFail, DS_Test_Setup, DS_Test_TearDown, "DS_AppProcessHK_Test_TblFail"); - - UtTest_Add(DS_AppStorePacket_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_AppStorePacket_Test_Nominal"); - UtTest_Add(DS_AppStorePacket_Test_DSDisabled, DS_Test_Setup, DS_Test_TearDown, "DS_AppStorePacket_Test_DSDisabled"); - UtTest_Add(DS_AppStorePacket_Test_FilterTableNotLoaded, DS_Test_Setup, DS_Test_TearDown, - "DS_AppStorePacket_Test_FilterTableNotLoaded"); - UtTest_Add(DS_AppStorePacket_Test_DestFileTableNotLoaded, DS_Test_Setup, DS_Test_TearDown, - "DS_AppStorePacket_Test_DestFileTableNotLoaded"); + UT_DS_TEST_ADD(DS_AppMain_Test_Nominal); + UT_DS_TEST_ADD(DS_AppMain_Test_AppInitializeError); + UT_DS_TEST_ADD(DS_AppMain_Test_SBError); + UT_DS_TEST_ADD(DS_AppMain_Test_SBTimeout); + + UT_DS_TEST_ADD(DS_AppInitialize_Test_Nominal); + UT_DS_TEST_ADD(DS_AppInitialize_Test_EVSRegisterError); + UT_DS_TEST_ADD(DS_AppInitialize_Test_SBCreatePipeError); + UT_DS_TEST_ADD(DS_AppInitialize_Test_SBSubscribeHKError); + UT_DS_TEST_ADD(DS_AppInitialize_Test_SBSubscribeDSError); + + UT_DS_TEST_ADD(DS_AppProcessMsg_Test_CmdStore); + UT_DS_TEST_ADD(DS_AppProcessMsg_Test_CmdNoStore); + UT_DS_TEST_ADD(DS_AppProcessMsg_Test_HKStore); + UT_DS_TEST_ADD(DS_AppProcessMsg_Test_HKNoStore); + UT_DS_TEST_ADD(DS_AppProcessMsg_Test_HKInvalidRequest); + UT_DS_TEST_ADD(DS_AppProcessMsg_Test_UnknownMID); + + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_Noop); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_Reset); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetAppState); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetFilterFile); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetFilterType); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetFilterParms); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestType); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestState); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestPath); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestBase); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestExt); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestSize); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestAge); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_SetDestCount); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_CloseFile); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_GetFileInfo); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_AddMID); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_CloseAll); + UT_DS_TEST_ADD(DS_AppProcessCmd_Test_InvalidCommandCode); + + UT_DS_TEST_ADD(DS_AppProcessHK_Test); + UT_DS_TEST_ADD(DS_AppProcessHK_Test_SnprintfFail); + UT_DS_TEST_ADD(DS_AppProcessHK_Test_TblFail); + + UT_DS_TEST_ADD(DS_AppStorePacket_Test_Nominal); + UT_DS_TEST_ADD(DS_AppStorePacket_Test_DSDisabled); + UT_DS_TEST_ADD(DS_AppStorePacket_Test_FilterTableNotLoaded); + UT_DS_TEST_ADD(DS_AppStorePacket_Test_DestFileTableNotLoaded); } /* end UtTest_Setup */ /************************/ diff --git a/unit-test/ds_cmds_tests.c b/unit-test/ds_cmds_tests.c index 0889ef9..fe91440 100644 --- a/unit-test/ds_cmds_tests.c +++ b/unit-test/ds_cmds_tests.c @@ -36,7 +36,6 @@ #include "ds_version.h" #include "ds_file.h" #include "ds_test_utils.h" -/*#include "ut_utils_lib.h"*/ /* UT includes */ #include "uttest.h" @@ -330,8 +329,7 @@ void DS_CmdSetAppState_Test_InvalidAppState(void) void DS_CmdSetFilterFile_Test_Nominal(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterFileCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -353,7 +351,6 @@ void DS_CmdSetFilterFile_Test_Nominal(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; DS_AppData.FilterTblPtr->Packet[forced_FilterTableIndex] .Filter[UT_CmdBuf.FilterFileCmd.FilterParmsIndex] @@ -560,6 +557,9 @@ void DS_CmdSetFilterFile_Test_FilterTableNotLoaded(void) UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); + /* Reset table pointer to NULL (set in test setup) */ + DS_AppData.FilterTblPtr = NULL; + /* Execute the function being tested */ DS_CmdSetFilterFile(&UT_CmdBuf.Buf); @@ -581,8 +581,7 @@ void DS_CmdSetFilterFile_Test_FilterTableNotLoaded(void) void DS_CmdSetFilterFile_Test_MessageIDNotInFilterTable(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterFileCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -603,7 +602,6 @@ void DS_CmdSetFilterFile_Test_MessageIDNotInFilterTable(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); @@ -630,8 +628,7 @@ void DS_CmdSetFilterFile_Test_MessageIDNotInFilterTable(void) void DS_CmdSetFilterType_Test_Nominal(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterTypeCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -640,8 +637,6 @@ void DS_CmdSetFilterType_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&FilterTable, 0, sizeof(FilterTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -654,7 +649,6 @@ void DS_CmdSetFilterType_Test_Nominal(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyType), true); @@ -853,6 +847,9 @@ void DS_CmdSetFilterType_Test_FilterTableNotLoaded(void) UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyType), true); + /* Reset table pointer to NULL (set in test setup) */ + DS_AppData.FilterTblPtr = NULL; + /* Execute the function being tested */ DS_CmdSetFilterType(&UT_CmdBuf.Buf); @@ -873,8 +870,7 @@ void DS_CmdSetFilterType_Test_FilterTableNotLoaded(void) void DS_CmdSetFilterType_Test_MessageIDNotInFilterTable(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterTypeCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -895,7 +891,6 @@ void DS_CmdSetFilterType_Test_MessageIDNotInFilterTable(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyType), true); @@ -922,8 +917,7 @@ void DS_CmdSetFilterType_Test_MessageIDNotInFilterTable(void) void DS_CmdSetFilterParms_Test_Nominal(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterParmsCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -932,8 +926,6 @@ void DS_CmdSetFilterParms_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&FilterTable, 0, sizeof(FilterTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -948,7 +940,6 @@ void DS_CmdSetFilterParms_Test_Nominal(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyParms), true); @@ -1099,8 +1090,7 @@ void DS_CmdSetFilterParms_Test_InvalidFilterParametersIndex(void) void DS_CmdSetFilterParms_Test_InvalidFilterAlgorithm(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterParmsCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1123,7 +1113,6 @@ void DS_CmdSetFilterParms_Test_InvalidFilterAlgorithm(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; /* Execute the function being tested */ @@ -1166,6 +1155,9 @@ void DS_CmdSetFilterParms_Test_FilterTableNotLoaded(void) UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyParms), true); + /* Reset table pointer to NULL (set in test setup) */ + DS_AppData.FilterTblPtr = NULL; + /* Execute the function being tested */ DS_CmdSetFilterParms(&UT_CmdBuf.Buf); @@ -1187,8 +1179,7 @@ void DS_CmdSetFilterParms_Test_FilterTableNotLoaded(void) void DS_CmdSetFilterParms_Test_MessageIDNotInFilterTable(void) { - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_FilterParmsCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1208,7 +1199,6 @@ void DS_CmdSetFilterParms_Test_MessageIDNotInFilterTable(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyParms), true); @@ -1235,7 +1225,6 @@ void DS_CmdSetFilterParms_Test_MessageIDNotInFilterTable(void) void DS_CmdSetDestType_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestTypeCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1244,8 +1233,6 @@ void DS_CmdSetDestType_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -1255,8 +1242,6 @@ void DS_CmdSetDestType_Test_Nominal(void) UT_CmdBuf.DestTypeCmd.FileTableIndex = 1; UT_CmdBuf.DestTypeCmd.FileNameType = 2; - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyType), true); @@ -1441,7 +1426,6 @@ void DS_CmdSetDestType_Test_FileTableNotLoaded(void) void DS_CmdSetDestState_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestStateCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1450,8 +1434,6 @@ void DS_CmdSetDestState_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -1461,8 +1443,6 @@ void DS_CmdSetDestState_Test_Nominal(void) UT_CmdBuf.DestStateCmd.FileTableIndex = 1; UT_CmdBuf.DestStateCmd.EnableState = 1; - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyState), true); @@ -1648,7 +1628,6 @@ void DS_CmdSetDestState_Test_FileTableNotLoaded(void) void DS_CmdSetDestPath_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestPathCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1657,8 +1636,6 @@ void DS_CmdSetDestPath_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -1668,8 +1645,6 @@ void DS_CmdSetDestPath_Test_Nominal(void) UT_CmdBuf.DestPathCmd.FileTableIndex = 1; strncpy(UT_CmdBuf.DestPathCmd.Pathname, "pathname", sizeof(UT_CmdBuf.DestPathCmd.Pathname) - 1); - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); /* Execute the function being tested */ @@ -1679,7 +1654,7 @@ void DS_CmdSetDestPath_Test_Nominal(void) UtAssert_True(DS_AppData.CmdAcceptedCounter == 1, "DS_AppData.CmdAcceptedCounter == 1"); UtAssert_True(strncmp(DS_AppData.DestFileTblPtr->File[UT_CmdBuf.DestPathCmd.FileTableIndex].Pathname, "pathname", - sizeof(DestFileTable.File[0].Pathname)) == 0, + sizeof(DS_AppData.DestFileTblPtr->File[0].Pathname)) == 0, "strncmp (DS_AppData.DestFileTblPtr->File[UT_CmdBuf.DestPathCmd.FileTableIndex].Pathname, " "'pathname', sizeof(DestFileTable.File[0].Pathname) - 1) == 0"); @@ -1814,7 +1789,6 @@ void DS_CmdSetDestPath_Test_FileTableNotLoaded(void) void DS_CmdSetDestBase_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestBaseCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1823,8 +1797,6 @@ void DS_CmdSetDestBase_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -1834,8 +1806,6 @@ void DS_CmdSetDestBase_Test_Nominal(void) UT_CmdBuf.DestBaseCmd.FileTableIndex = 1; strncpy(UT_CmdBuf.DestBaseCmd.Basename, "base", sizeof(UT_CmdBuf.DestBaseCmd.Basename) - 1); - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); /* Execute the function being tested */ @@ -1845,7 +1815,7 @@ void DS_CmdSetDestBase_Test_Nominal(void) UtAssert_True(DS_AppData.CmdAcceptedCounter == 1, "DS_AppData.CmdAcceptedCounter == 1"); UtAssert_True(strncmp(DS_AppData.DestFileTblPtr->File[UT_CmdBuf.DestBaseCmd.FileTableIndex].Basename, "base", - sizeof(DestFileTable.File[0].Basename)) == 0, + sizeof(DS_AppData.DestFileTblPtr->File[0].Basename)) == 0, "strncmp (DS_AppData.DestFileTblPtr->File[UT_CmdBuf.DestBaseCmd.FileTableIndex].Basename, 'base', " "sizeof(DestFileTable.File[0].Basename)) == 0"); @@ -1980,7 +1950,6 @@ void DS_CmdSetDestBase_Test_FileTableNotLoaded(void) void DS_CmdSetDestExt_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestExtCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -1989,8 +1958,6 @@ void DS_CmdSetDestExt_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -2000,8 +1967,6 @@ void DS_CmdSetDestExt_Test_Nominal(void) UT_CmdBuf.DestExtCmd.FileTableIndex = 1; strncpy(UT_CmdBuf.DestExtCmd.Extension, "txt", DS_EXTENSION_BUFSIZE); - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); /* Execute the function being tested */ @@ -2147,7 +2112,6 @@ void DS_CmdSetDestExt_Test_FileTableNotLoaded(void) void DS_CmdSetDestSize_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestSizeCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -2156,8 +2120,6 @@ void DS_CmdSetDestSize_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -2167,8 +2129,6 @@ void DS_CmdSetDestSize_Test_Nominal(void) UT_CmdBuf.DestSizeCmd.FileTableIndex = 1; UT_CmdBuf.DestSizeCmd.MaxFileSize = 100000000; - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifySize), true); @@ -2359,7 +2319,6 @@ void DS_CmdSetDestSize_Test_FileTableNotLoaded(void) void DS_CmdSetDestAge_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestAgeCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -2368,8 +2327,6 @@ void DS_CmdSetDestAge_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -2379,8 +2336,6 @@ void DS_CmdSetDestAge_Test_Nominal(void) UT_CmdBuf.DestAgeCmd.FileTableIndex = 1; UT_CmdBuf.DestAgeCmd.MaxFileAge = 1000; - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyAge), true); @@ -2570,7 +2525,6 @@ void DS_CmdSetDestAge_Test_FileTableNotLoaded(void) void DS_CmdSetDestCount_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_DestCountCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -2579,8 +2533,6 @@ void DS_CmdSetDestCount_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -2590,8 +2542,6 @@ void DS_CmdSetDestCount_Test_Nominal(void) UT_CmdBuf.DestCountCmd.FileTableIndex = 1; UT_CmdBuf.DestCountCmd.SequenceCount = 1; - DS_AppData.DestFileTblPtr = &DestFileTable; - UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyFileIndex), true); UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifyCount), true); @@ -2785,10 +2735,9 @@ void DS_CmdSetDestCount_Test_FileTableNotLoaded(void) void DS_CmdCloseFile_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; - uint32 i; - uint8 call_count_DS_FileUpdateHeader = 0; - uint8 call_count_DS_FileCloseDest = 0; + uint32 i; + uint8 call_count_DS_FileUpdateHeader = 0; + uint8 call_count_DS_FileCloseDest = 0; size_t forced_Size = sizeof(DS_CloseFileCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -2806,8 +2755,6 @@ void DS_CmdCloseFile_Test_Nominal(void) UT_CmdBuf.CloseFileCmd.FileTableIndex = 0; - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.FileStatus[UT_CmdBuf.CloseFileCmd.FileTableIndex].FileHandle = DS_UT_OBJID_1; for (i = 1; i < DS_DEST_FILE_CNT; i++) @@ -2846,10 +2793,9 @@ void DS_CmdCloseFile_Test_Nominal(void) void DS_CmdCloseFile_Test_NominalAlreadyClosed(void) { - DS_DestFileTable_t DestFileTable; - uint32 i; - uint8 call_count_DS_FileUpdateHeader = 0; - uint8 call_count_DS_FileCloseDest = 0; + uint32 i; + uint8 call_count_DS_FileUpdateHeader = 0; + uint8 call_count_DS_FileCloseDest = 0; size_t forced_Size = sizeof(DS_CloseFileCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -2867,8 +2813,6 @@ void DS_CmdCloseFile_Test_NominalAlreadyClosed(void) UT_CmdBuf.CloseFileCmd.FileTableIndex = 0; - DS_AppData.DestFileTblPtr = &DestFileTable; - for (i = 0; i < DS_DEST_FILE_CNT; i++) { DS_AppData.FileStatus[i].FileHandle = OS_OBJECT_ID_UNDEFINED; @@ -2981,10 +2925,7 @@ void DS_CmdCloseFile_Test_InvalidFileTableIndex(void) void DS_CmdCloseAll_Test_Nominal(void) { - DS_DestFileTable_t DestFileTable; - uint32 i; - - DS_AppData.DestFileTblPtr = &DestFileTable; + uint32 i; size_t forced_Size = sizeof(DS_CloseAllCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -3093,8 +3034,7 @@ void DS_CmdCloseAll_Test_InvalidCommandLength(void) void DS_CmdGetFileInfo_Test_EnabledOpen(void) { - DS_DestFileTable_t DestFileTable; - uint32 i; + uint32 i; size_t forced_Size = sizeof(DS_GetFileInfoCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -3108,8 +3048,6 @@ void DS_CmdGetFileInfo_Test_EnabledOpen(void) char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "GET FILE INFO command"); - DS_AppData.DestFileTblPtr = &DestFileTable; - for (i = 0; i < DS_DEST_FILE_CNT; i++) { DS_AppData.FileStatus[i].FileAge = 1; @@ -3170,6 +3108,9 @@ void DS_CmdGetFileInfo_Test_DisabledClosed(void) strncpy(DS_AppData.FileStatus[i].FileName, "filename", sizeof(DS_AppData.FileStatus[i].FileName) - 1); } + /* Also hits table NULL branch */ + DS_AppData.DestFileTblPtr = NULL; + /* Execute the function being tested */ DS_CmdGetFileInfo(&UT_CmdBuf.Buf); @@ -3191,7 +3132,6 @@ void DS_CmdGetFileInfo_Test_DisabledClosed(void) void DS_CmdGetFileInfo_Test_InvalidCommandLength(void) { - DS_DestFileTable_t DestFileTable; size_t forced_Size = sizeof(DS_GetFileInfoCmd_t) + 1; CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -3206,8 +3146,6 @@ void DS_CmdGetFileInfo_Test_InvalidCommandLength(void) snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Invalid GET FILE INFO command length: expected = %%d, actual = %%d"); - DS_AppData.DestFileTblPtr = &DestFileTable; - /* Execute the function being tested */ DS_CmdGetFileInfo(&UT_CmdBuf.Buf); @@ -3229,9 +3167,8 @@ void DS_CmdGetFileInfo_Test_InvalidCommandLength(void) void DS_CmdAddMID_Test_Nominal(void) { - DS_FilterTable_t FilterTable; - int32 FilterTableIndex; - DS_HashLink_t HashLink; + int32 FilterTableIndex; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_AddMidCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -3240,8 +3177,6 @@ void DS_CmdAddMID_Test_Nominal(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&FilterTable, 0, sizeof(FilterTable)); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); @@ -3253,9 +3188,6 @@ void DS_CmdAddMID_Test_Nominal(void) UT_CmdBuf.AddMidCmd.MessageID = DS_UT_MID_1; - /* This is the hash done in DS_TableHashFunction */ - DS_AppData.FilterTblPtr = &FilterTable; - DS_AppData.HashTable[0] = &HashLink; HashLink.Index = 0; DS_AppData.FilterTblPtr->Packet[HashLink.Index].MessageID = CFE_SB_INVALID_MSG_ID; @@ -3440,6 +3372,9 @@ void DS_CmdAddMID_Test_FilterTableNotLoaded(void) UT_CmdBuf.AddMidCmd.MessageID = DS_UT_MID_1; + /* Reset table pointer to NULL (set in test setup) */ + DS_AppData.FilterTblPtr = NULL; + /* Execute the function being tested */ DS_CmdAddMID(&UT_CmdBuf.Buf); @@ -3461,8 +3396,7 @@ void DS_CmdAddMID_Test_FilterTableNotLoaded(void) void DS_CmdAddMID_Test_MIDAlreadyInFilterTable(void) { - DS_FilterTable_t FilterTable; - DS_HashLink_t HashLink; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_AddMidCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -3481,7 +3415,6 @@ void DS_CmdAddMID_Test_MIDAlreadyInFilterTable(void) DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; - DS_AppData.FilterTblPtr = &FilterTable; DS_AppData.FilterTblPtr->Packet->MessageID = DS_UT_MID_1; UT_SetDeferredRetcode(UT_KEY(DS_TableFindMsgID), 1, 1); @@ -3507,7 +3440,6 @@ void DS_CmdAddMID_Test_MIDAlreadyInFilterTable(void) void DS_CmdAddMID_Test_FilterTableFull(void) { - DS_FilterTable_t FilterTable; size_t forced_Size = sizeof(DS_AddMidCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -3523,8 +3455,6 @@ void DS_CmdAddMID_Test_FilterTableFull(void) UT_CmdBuf.AddMidCmd.MessageID = DS_UT_MID_1; - DS_AppData.FilterTblPtr = &FilterTable; - /* both calls to DS_TableFindMsgID must return DS_INDEX_NONE */ UT_SetDefaultReturnValue(UT_KEY(DS_TableFindMsgID), DS_INDEX_NONE); diff --git a/unit-test/ds_file_tests.c b/unit-test/ds_file_tests.c index 6dc4eb0..4dd3bfa 100644 --- a/unit-test/ds_file_tests.c +++ b/unit-test/ds_file_tests.c @@ -146,13 +146,9 @@ void UT_DS_SetDestFileEntry(DS_DestFileEntry_t *DestFileEntryPtr) * Function Definitions */ -uint8 call_count_CFE_EVS_SendEvent; - void DS_FileStorePacket_Test_Nominal(void) { CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t FilterTable; - DS_DestFileTable_t DestFileTable; DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_NoopCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -165,17 +161,8 @@ void DS_FileStorePacket_Test_Nominal(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSequenceCount), &forced_SeqCount, sizeof(forced_SeqCount), false); UT_SetDefaultReturnValue(UT_KEY(DS_TableFindMsgID), 0); - DS_AppData.FilterTblPtr = &FilterTable; - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[0].MaxFileSize = forced_Size * 2; - for (int i = 0; i < DS_FILTERS_PER_PACKET; i++) - { - DS_AppData.FilterTblPtr->Packet[0].Filter[i].Algorithm_N = DS_UNUSED; - DS_AppData.FilterTblPtr->Packet[0].Filter[i].FileTableIndex = 0; - } - DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; DS_AppData.FilterTblPtr->Packet[0].MessageID = DS_UT_MID_1; @@ -192,18 +179,14 @@ void DS_FileStorePacket_Test_Nominal(void) DS_FileStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.PassedPktCounter == 1, "DS_AppData.PassedPktCounter == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(DS_AppData.PassedPktCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileStorePacket_Test_Nominal */ void DS_FileStorePacket_Test_PacketNotInTable(void) { - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t FilterTable; - DS_DestFileTable_t DestFileTable; - DS_HashLink_t HashLink; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_NoopCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -213,9 +196,6 @@ void DS_FileStorePacket_Test_PacketNotInTable(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); - DS_AppData.FilterTblPtr = &FilterTable; - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[0].MaxFileSize = 10; DS_AppData.HashTable[187] = &HashLink; @@ -228,17 +208,13 @@ void DS_FileStorePacket_Test_PacketNotInTable(void) /* Verify results */ UtAssert_INT32_EQ(DS_AppData.IgnoredPktCounter, 1); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileStorePacket_Test_PacketNotInTable */ void DS_FileStorePacket_Test_PassedFilterFalse(void) { CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t FilterTable; - DS_DestFileTable_t DestFileTable; DS_HashLink_t HashLink; size_t forced_Size = sizeof(DS_NoopCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); @@ -250,17 +226,8 @@ void DS_FileStorePacket_Test_PassedFilterFalse(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSequenceCount), &forced_SeqCount, sizeof(forced_SeqCount), false); - DS_AppData.FilterTblPtr = &FilterTable; - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[0].MaxFileSize = 10; - for (int i = 0; i < DS_FILTERS_PER_PACKET; i++) - { - DS_AppData.FilterTblPtr->Packet[0].Filter[i].Algorithm_N = DS_UNUSED; - DS_AppData.FilterTblPtr->Packet[0].Filter[i].FileTableIndex = 0; - } - DS_AppData.HashTable[187] = &HashLink; HashLink.Index = 0; DS_AppData.FilterTblPtr->Packet[0].MessageID = DS_UT_MID_1; @@ -274,35 +241,23 @@ void DS_FileStorePacket_Test_PassedFilterFalse(void) DS_FileStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.FilteredPktCounter == 1, "DS_AppData.FilteredPktCounter == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(DS_AppData.FilteredPktCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileStorePacket_Test_PassedFilterFalse */ void DS_FileStorePacket_Test_DisabledDest(void) { - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t FilterTable; - DS_DestFileTable_t DestFileTable; - DS_HashLink_t HashLink; - size_t forced_Size = sizeof(DS_NoopCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); - CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + DS_HashLink_t HashLink; + size_t forced_Size = sizeof(DS_NoopCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); + CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); - DS_AppData.FilterTblPtr = &FilterTable; - DS_AppData.DestFileTblPtr = &DestFileTable; - - for (int i = 0; i < DS_FILTERS_PER_PACKET; i++) - { - DS_AppData.FilterTblPtr->Packet[0].Filter[i].Algorithm_N = DS_UNUSED; - DS_AppData.FilterTblPtr->Packet[0].Filter[i].FileTableIndex = 0; - } DS_AppData.DestFileTblPtr->File[0].MaxFileSize = 10; DS_AppData.HashTable[187] = &HashLink; @@ -318,36 +273,23 @@ void DS_FileStorePacket_Test_DisabledDest(void) DS_FileStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.FilteredPktCounter == 1, "DS_AppData.FilteredPktCounter == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(DS_AppData.FilteredPktCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileStorePacket_Test_DisabledDest */ void DS_FileStorePacket_Test_InvalidIndex(void) { - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t FilterTable; - DS_DestFileTable_t DestFileTable; - DS_HashLink_t HashLink; - size_t forced_Size = sizeof(DS_NoopCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); - CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + DS_HashLink_t HashLink; + size_t forced_Size = sizeof(DS_NoopCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); + CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); - DS_AppData.FilterTblPtr = &FilterTable; - DS_AppData.DestFileTblPtr = &DestFileTable; - - for (int i = 0; i < DS_FILTERS_PER_PACKET; i++) - { - DS_AppData.FilterTblPtr->Packet[0].Filter[i].Algorithm_N = DS_UNUSED; - DS_AppData.FilterTblPtr->Packet[0].Filter[i].FileTableIndex = 0; - } - DS_AppData.DestFileTblPtr->File[0].MaxFileSize = 10; DS_AppData.HashTable[187] = &HashLink; @@ -364,19 +306,17 @@ void DS_FileStorePacket_Test_InvalidIndex(void) DS_FileStorePacket(MessageID, &UT_CmdBuf.Buf); /* Verify results */ - UtAssert_True(DS_AppData.FilteredPktCounter == 1, "DS_AppData.FilteredPktCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(DS_AppData.FilteredPktCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileStorePacket_Test_InvalidIndex */ void DS_FileSetupWrite_Test_Nominal(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - size_t forced_Size = sizeof(DS_NoopCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); - CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; + int32 FileIndex = 0; + size_t forced_Size = sizeof(DS_NoopCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); + CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); @@ -386,8 +326,6 @@ void DS_FileSetupWrite_Test_Nominal(void) DS_AppData.FileStatus[FileIndex].FileHandle = DS_UT_OBJID_1; - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[FileIndex].MaxFileSize = 100; DS_AppData.FileStatus[FileIndex].FileSize = 3; @@ -395,18 +333,16 @@ void DS_FileSetupWrite_Test_Nominal(void) DS_FileSetupWrite(FileIndex, &UT_CmdBuf.Buf); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileSetupWrite_Test_Nominal */ void DS_FileSetupWrite_Test_FileHandleClosed(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - size_t forced_Size = sizeof(DS_NoopCmd_t); - CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); - CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; + int32 FileIndex = 0; + size_t forced_Size = sizeof(DS_NoopCmd_t); + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); + CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); @@ -415,7 +351,6 @@ void DS_FileSetupWrite_Test_FileHandleClosed(void) UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); UT_SetHandlerFunction(UT_KEY(OS_OpenCreate), &UT_OS_write_SuccessHandler, NULL); - DS_AppData.DestFileTblPtr = &DestFileTable; DS_AppData.DestFileTblPtr->File[FileIndex].MaxFileSize = 100; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; @@ -434,18 +369,14 @@ void DS_FileSetupWrite_Test_FileHandleClosed(void) void DS_FileSetupWrite_Test_MaxFileSizeExceeded(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - size_t forced_Size = sizeof(DS_NoopCmd_t); - - memset(&DestFileTable, 0, sizeof(DestFileTable)); + int32 FileIndex = 0; + size_t forced_Size = sizeof(DS_NoopCmd_t); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &forced_Size, sizeof(forced_Size), false); UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); DS_AppData.FileStatus[FileIndex].FileHandle = DS_UT_OBJID_1; - DS_AppData.DestFileTblPtr = &DestFileTable; DS_AppData.DestFileTblPtr->File[FileIndex].MaxFileSize = 5; DS_AppData.FileStatus[FileIndex].FileSize = 10; @@ -466,8 +397,7 @@ void DS_FileSetupWrite_Test_MaxFileSizeExceeded(void) DS_FileSetupWrite(FileIndex, &UT_CmdBuf.Buf); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileSetupWrite_Test_MaxFileSizeExceeded */ @@ -492,23 +422,19 @@ void DS_FileWriteData_Test_Nominal(void) DS_FileWriteData(FileIndex, &UT_CmdBuf.Buf, DataLength); /* Verify results */ - UtAssert_True(DS_AppData.FileWriteCounter == 1, "DS_AppData.FileWriteCounter == 1"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileSize == 10, "DS_AppData.FileStatus[FileIndex].FileSize == 10"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileGrowth == 10, - "DS_AppData.FileStatus[FileIndex].FileGrowth == 10"); + UtAssert_UINT32_EQ(DS_AppData.FileWriteCounter, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileSize, 10); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileGrowth, 10); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileWriteData_Test_Nominal */ void DS_FileWriteData_Test_Error(void) { - int32 FileIndex = 0; - uint32 DataLength = 10; - DS_DestFileTable_t DestFileTable; + int32 FileIndex = 0; + uint32 DataLength = 10; - DS_AppData.DestFileTblPtr = &DestFileTable; size_t forced_Size = sizeof(DS_NoopCmd_t); CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(DS_CMD_MID); CFE_MSG_FcnCode_t forced_CmdCode = DS_NOOP_CC; @@ -518,7 +444,6 @@ void DS_FileWriteData_Test_Error(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &forced_CmdCode, sizeof(forced_CmdCode), false); /* Set to reach error case being tested (DS_FileWriteError) */ - // UT_SetHandlerFunction(UT_KEY(OS_write), &UT_OS_write_FailHandler, NULL); UT_SetDefaultReturnValue(UT_KEY(OS_write), -1); UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); @@ -530,45 +455,34 @@ void DS_FileWriteData_Test_Error(void) DS_FileWriteData(FileIndex, &UT_CmdBuf.Buf, DataLength); /* Verify results */ - /*UtAssert_True - (Ut_CFE_EVS_EventSent(DS_WRITE_FILE_ERR_EID, CFE_EVS_ERROR, "FILE WRITE error: result = -1, length = 10, dest = - 0, name = 'directory1/'"), "FILE WRITE error: result = -1, length = 10, dest = 0, name = 'directory1/'"); -*/ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_WRITE_FILE_ERR_EID); } /* end DS_FileWriteData_Test_Error */ #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE void DS_FileWriteHeader_Test_PlatformConfigCFE_Nominal(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = 1; /* Set to satisfy condition "if (Result == sizeof(CFE_FS_Header_t))" */ - // UT_SetHandlerFunction(UT_KEY(CFE_FS_WriteHeader), &UT_CFE_FS_WriteHeader_SuccessHandler, NULL); UT_SetDefaultReturnValue(UT_KEY(CFE_FS_WriteHeader), sizeof(CFE_FS_Header_t)); /* Set to satisfy condition "if (Result == sizeof(DS_FileHeader_t))" */ - // UT_SetHandlerFunction(UT_KEY(OS_write), &UT_OS_write_SuccessHandler, NULL); UT_SetDefaultReturnValue(UT_KEY(OS_write), sizeof(DS_FileHeader_t)); /* Execute the function being tested */ DS_FileWriteHeader(FileIndex); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_True(DS_AppData.FileWriteCounter == 2, "DS_AppData.FileWriteCounter == 2"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileSize == sizeof(CFE_FS_Header_t) + sizeof(DS_FileHeader_t), - "sizeof(CFE_FS_Header_t) + sizeof(DS_FileHeader_t)"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileGrowth == sizeof(CFE_FS_Header_t) + sizeof(DS_FileHeader_t), - "sizeof(CFE_FS_Header_t) + sizeof(DS_FileHeader_t)"); + UtAssert_UINT32_EQ(DS_AppData.FileWriteCounter, 2); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileSize, sizeof(CFE_FS_Header_t) + sizeof(DS_FileHeader_t)); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileGrowth, sizeof(CFE_FS_Header_t) + sizeof(DS_FileHeader_t)); } /* end DS_FileWriteHeader_Test_PlatformConfigCFE_Nominal */ #endif @@ -576,15 +490,11 @@ void DS_FileWriteHeader_Test_PlatformConfigCFE_Nominal(void) #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE void DS_FileWriteHeader_Test_PrimaryHeaderError(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable[2]; - - DS_AppData.DestFileTblPtr = DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = 1; DS_AppData.DestFileTblPtr->File[FileIndex].Movename[0] = '\0'; /* Set to generate primary header error */ - // UT_SetHandlerFunction(UT_KEY(CFE_FS_WriteHeader), &UT_CFE_FS_WriteHeader_FailHandler, NULL); UT_SetDefaultReturnValue(UT_KEY(CFE_FS_WriteHeader), -1); /* Handle closure in response to the error */ @@ -594,8 +504,7 @@ void DS_FileWriteHeader_Test_PrimaryHeaderError(void) DS_FileWriteHeader(FileIndex); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); /* Generates 1 event message we don't care about in this test */ } /* end DS_FileWriteHeader_Test_PrimaryHeaderError */ @@ -604,10 +513,7 @@ void DS_FileWriteHeader_Test_PrimaryHeaderError(void) #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE void DS_FileWriteHeader_Test_SecondaryHeaderError(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = 1; @@ -627,8 +533,7 @@ void DS_FileWriteHeader_Test_SecondaryHeaderError(void) DS_FileWriteHeader(FileIndex); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); /* Generates 1 event message we don't care about in this test */ } /* end DS_FileWriteHeader_Test_SecondaryHeaderError */ @@ -637,12 +542,9 @@ void DS_FileWriteHeader_Test_SecondaryHeaderError(void) #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE void DS_FileWriteError_Test(void) { - int32 FileIndex = 0; - uint32 DataLength = 10; - int32 WriteResult = -1; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + uint32 DataLength = 10; + int32 WriteResult = -1; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = 1; @@ -655,28 +557,18 @@ void DS_FileWriteError_Test(void) DS_FileWriteError(FileIndex, DataLength, WriteResult); /* Verify results */ - UtAssert_True(DS_AppData.FileWriteErrCounter == 1, "DS_AppData.FileWriteErrCounter == 1"); - /* - UtAssert_True - (Ut_CFE_EVS_EventSent(DS_WRITE_FILE_ERR_EID, CFE_EVS_ERROR, "FILE WRITE error: result = -1, length = 10, - dest = 0, name = 'filename'"), "FILE WRITE error: result = -1, length = 10, dest = 0, name = 'filename'"); - */ - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileState == DS_DISABLED, - "DS_AppData.FileStatus[FileIndex].FileState == DS_DISABLED"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_UINT32_EQ(DS_AppData.FileWriteErrCounter, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileState, DS_DISABLED); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_WRITE_FILE_ERR_EID); } /* end DS_FileWriteError_Test */ #endif void DS_FileCreateDest_Test_Nominal(void) { - uint32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - /* Setup for DS_FileCreateName to succeed */ - DS_AppData.DestFileTblPtr = &DestFileTable; + uint32 FileIndex = 0; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); strncpy(DS_AppData.FileStatus[FileIndex].FileName, "filename", sizeof(DS_AppData.FileStatus[FileIndex].FileName)); @@ -719,20 +611,14 @@ void DS_FileCreateDest_Test_Nominal(void) UtAssert_INT32_EQ(DS_AppData.FileStatus[FileIndex].FileCount, 2); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_TableUpdateCDS)), 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(DS_TableUpdateCDS, 1); } /* end DS_FileCreateDest_Test_Nominal */ void DS_FileCreateDest_Test_StringTerminate(void) { - uint32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - /* Setup for DS_FileCreateName to succeed */ - DS_AppData.DestFileTblPtr = &DestFileTable; + uint32 FileIndex = 0; DS_AppData.FileStatus[FileIndex].FileName[0] = DS_STRING_TERMINATOR; @@ -746,11 +632,7 @@ void DS_FileCreateDest_Test_StringTerminate(void) void DS_FileCreateDest_Test_NominalRollover(void) { - uint32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - /* Setup for DS_FileCreateName to succeed */ - DS_AppData.DestFileTblPtr = &DestFileTable; + uint32 FileIndex = 0; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); strncpy(DS_AppData.FileStatus[FileIndex].FileName, "filename", sizeof(DS_AppData.FileStatus[FileIndex].FileName)); @@ -793,19 +675,14 @@ void DS_FileCreateDest_Test_NominalRollover(void) UtAssert_INT32_EQ(DS_AppData.FileStatus[FileIndex].FileCount, 3); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(DS_TableUpdateCDS)), 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(DS_TableUpdateCDS, 1); } /* end DS_FileCreateDest_Test_NominalRollover */ void DS_FileCreateDest_Test_Error(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -820,31 +697,19 @@ void DS_FileCreateDest_Test_Error(void) DS_FileCreateDest(FileIndex); /* Verify results */ - UtAssert_True(DS_AppData.FileWriteErrCounter == 1, "DS_AppData.FileWriteErrCounter == 1"); - - /* For this test it doesn't matter what filename results from the call to DS_FileCreateName. */ - /* UtAssert_True - (Ut_CFE_EVS_EventSent(DS_CREATE_FILE_ERR_EID, CFE_EVS_ERROR, "FILE CREATE error: result = -1, dest = 0, name = - 'path/basename.extension'"), "FILE CREATE error: result = -1, dest = 0, name = 'path/basename.extension'"); - */ - UtAssert_True(strncmp(DS_AppData.FileStatus[FileIndex].FileName, "", DS_TOTAL_FNAME_BUFSIZE) == 0, - "strncmp (DS_AppData.FileStatus[FileIndex].FileName, " - ", DS_TOTAL_FNAME_BUFSIZE) == 0"); - - UtAssert_INT32_EQ(DS_AppData.FileStatus[FileIndex].FileState, DS_DISABLED); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_UINT32_EQ(DS_AppData.FileWriteErrCounter, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileName[0], 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileState, DS_DISABLED); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_CREATE_FILE_ERR_EID); } /* end DS_FileCreateDest_Test_Error */ void DS_FileCreateDest_Test_ClosedFileHandle(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - osal_id_t LocalFileHandle = OS_OBJECT_ID_UNDEFINED; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + osal_id_t LocalFileHandle = OS_OBJECT_ID_UNDEFINED; DS_AppData.DestFileTblPtr->File[FileIndex].SequenceCount = 5; @@ -873,20 +738,14 @@ void DS_FileCreateDest_Test_ClosedFileHandle(void) UtAssert_INT32_EQ(DS_AppData.FileWriteCounter, 1); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[FileIndex].FileHandle)); UtAssert_INT32_EQ(DS_AppData.FileStatus[FileIndex].FileCount, 1); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } /* end DS_FileCreateDest_Test_ClosedFileHandle */ void DS_FileCreateName_Test_Nominal(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - char StrCompare[] = "path/base00000001.ext"; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + char StrCompare[] = "path/base00000001.ext"; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -900,18 +759,14 @@ void DS_FileCreateName_Test_Nominal(void) UtAssert_STRINGBUF_EQ(DS_AppData.FileStatus[FileIndex].FileName, sizeof(DS_AppData.FileStatus[FileIndex].FileName), StrCompare, sizeof(StrCompare)); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCreateName_Test_Nominal */ void DS_FileCreateName_Test_NominalWithSeparator(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - char StrCompare[] = "path/base00000001.ext"; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + char StrCompare[] = "path/base00000001.ext"; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -927,18 +782,14 @@ void DS_FileCreateName_Test_NominalWithSeparator(void) UtAssert_STRINGBUF_EQ(DS_AppData.FileStatus[FileIndex].FileName, sizeof(DS_AppData.FileStatus[FileIndex].FileName), StrCompare, sizeof(StrCompare)); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCreateName_Test_NominalWithSeparator */ void DS_FileCreateName_Test_NominalWithPeriod(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - char StrCompare[] = "path/base00000001.ext"; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + char StrCompare[] = "path/base00000001.ext"; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -954,16 +805,13 @@ void DS_FileCreateName_Test_NominalWithPeriod(void) UtAssert_STRINGBUF_EQ(DS_AppData.FileStatus[FileIndex].FileName, sizeof(DS_AppData.FileStatus[FileIndex].FileName), StrCompare, sizeof(StrCompare)); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCreateName_Test_NominalWithPeriod */ void DS_FileCreateName_Test_EmptyPath(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -975,26 +823,17 @@ void DS_FileCreateName_Test_EmptyPath(void) DS_FileCreateName(FileIndex); /* Verify results */ - /* UtAssert_True - (Ut_CFE_EVS_EventSent(DS_FILE_CREATE_EMPTY_PATH_ERR_EID, CFE_EVS_ERROR, "FILE NAME error: Path empty. dest = - 0, path = ''"), "FILE NAME error: Path empty. dest = 0, path = ''"); - */ - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileState == DS_DISABLED, - "DS_AppData.FileStatus[FileIndex].FileState == DS_DISABLED"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileState, DS_DISABLED); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FILE_CREATE_EMPTY_PATH_ERR_EID); } /* end DS_FileCreateName_Test_EmptyPath */ void DS_FileCreateName_Test_Error(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - int32 i; - char EventMessage[300]; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + int32 i; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -1010,28 +849,18 @@ void DS_FileCreateName_Test_Error(void) DS_FileCreateName(FileIndex); /* Verify results */ - sprintf(EventMessage, "FILE NAME error: dest = 0, path = 'path', base = '%s', seq = ", - DS_AppData.DestFileTblPtr->File[FileIndex].Basename); - /*UtAssert_True - (Ut_CFE_EVS_EventSent(DS_FILE_NAME_ERR_EID, CFE_EVS_ERROR, EventMessage), - EventMessage); -*/ - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileState == DS_DISABLED, - "DS_AppData.FileStatus[FileIndex].FileState == DS_DISABLED"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileState, DS_DISABLED); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FILE_NAME_ERR_EID); } /* end DS_FileCreateName_Test_Error */ void DS_FileCreateName_Test_MaxPathnameLength(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - int32 WorknameLen = 2 * DS_TOTAL_FNAME_BUFSIZE; - int32 i; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + int32 WorknameLen = 2 * DS_TOTAL_FNAME_BUFSIZE; + int32 i; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -1054,10 +883,7 @@ void DS_FileCreateName_Test_MaxPathnameLength(void) void DS_FileCreateName_Test_PathBaseSeqTooLarge(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; DS_AppData.FileStatus[FileIndex].FileCount = 1; @@ -1084,10 +910,7 @@ void DS_FileCreateName_Test_PathBaseSeqTooLarge(void) void DS_FileCreateName_Test_PathBaseSeqExtTooLarge(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; DS_AppData.FileStatus[FileIndex].FileCount = 1; @@ -1117,11 +940,8 @@ void DS_FileCreateName_Test_PathBaseSeqExtTooLarge(void) void DS_FileCreateName_Test_ExtensionZero(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - char StrCompare[] = "path/base00000001"; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; + char StrCompare[] = "path/base00000001"; UT_DS_SetDestFileEntry(&DS_AppData.DestFileTblPtr->File[FileIndex]); @@ -1144,15 +964,12 @@ void DS_FileCreateName_Test_ExtensionZero(void) #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE void DS_FileCreateSequence_Test_ByCount(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; + int32 FileIndex = 0; char Sequence[DS_TOTAL_FNAME_BUFSIZE]; memset(Sequence, 0, sizeof(Sequence)); - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; DS_AppData.FileStatus[FileIndex].FileCount = 1; @@ -1162,11 +979,8 @@ void DS_FileCreateSequence_Test_ByCount(void) DS_AppData.FileStatus[FileIndex].FileCount); /* Verify results */ - UtAssert_True(strncmp(Sequence, "00000001", DS_TOTAL_FNAME_BUFSIZE) == 0, - "strncmp(Sequence, '00000001', DS_TOTAL_FNAME_BUFSIZE) == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(strncmp(Sequence, "00000001", DS_TOTAL_FNAME_BUFSIZE), 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCreateSequence_Test_ByCount */ #endif @@ -1175,18 +989,14 @@ void DS_FileCreateSequence_Test_ByCount(void) void DS_FileCreateSequence_Test_ByTime(void) { int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; CFE_TIME_SysTime_t FakeTime; char Sequence[DS_TOTAL_FNAME_BUFSIZE]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); memset(&FakeTime, 0, sizeof(FakeTime)); UT_SetDataBuffer(UT_KEY(CFE_TIME_GetTime), &FakeTime, sizeof(FakeTime), false); - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_TIME; DS_AppData.FileStatus[FileIndex].FileCount = 1; @@ -1208,15 +1018,12 @@ void DS_FileCreateSequence_Test_ByTime(void) #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE void DS_FileCreateSequence_Test_BadFilenameType(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; + int32 FileIndex = 0; char Sequence[DS_TOTAL_FNAME_BUFSIZE]; memset(Sequence, 0xFF, sizeof(Sequence)); - DS_AppData.DestFileTblPtr = &DestFileTable; - DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_TIME; DS_AppData.FileStatus[FileIndex].FileCount = 1; @@ -1225,12 +1032,8 @@ void DS_FileCreateSequence_Test_BadFilenameType(void) DS_FileCreateSequence(Sequence, 99, DS_AppData.FileStatus[FileIndex].FileCount); /* Verify results */ - UtAssert_True(strncmp(Sequence, "", DS_TOTAL_FNAME_BUFSIZE) == 0, - "strncmp(Sequence, '', DS_TOTAL_FNAME_BUFSIZE) == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - + UtAssert_UINT32_EQ(strncmp(Sequence, "", DS_TOTAL_FNAME_BUFSIZE), 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCreateSequence_Test_BadFilenameType */ #endif @@ -1249,11 +1052,8 @@ void DS_FileUpdateHeader_Test_PlatformConfigCFE_Nominal(void) DS_FileUpdateHeader(FileIndex); /* Verify results */ - UtAssert_True(DS_AppData.FileUpdateCounter == 1, "DS_AppData.FileUpdateCounter == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - + UtAssert_UINT32_EQ(DS_AppData.FileUpdateCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileUpdateHeader_Test_PlatformConfigCFE_Nominal */ #endif @@ -1272,11 +1072,8 @@ void DS_FileUpdateHeader_Test_WriteError(void) DS_FileUpdateHeader(FileIndex); /* Verify results */ - UtAssert_True(DS_AppData.FileUpdateErrCounter == 1, "DS_AppData.FileUpdateErrCounter == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - + UtAssert_UINT32_EQ(DS_AppData.FileUpdateErrCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileUpdateHeader_Test_WriteError */ #endif @@ -1292,10 +1089,8 @@ void DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError(void) DS_FileUpdateHeader(FileIndex); /* Verify results */ - UtAssert_True(DS_AppData.FileUpdateErrCounter == 1, "DS_AppData.FileUpdateErrCounter == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(DS_AppData.FileUpdateErrCounter, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError */ #endif @@ -1303,11 +1098,9 @@ void DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError(void) #if (DS_MOVE_FILES == true) void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; + int32 FileIndex = 0; UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); - DS_AppData.DestFileTblPtr = &DestFileTable; strncpy(DS_AppData.FileStatus[FileIndex].FileName, "directory1/filename", sizeof(DS_AppData.FileStatus[FileIndex].FileName)); @@ -1319,13 +1112,10 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void) /* Verify results */ UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[FileIndex].FileHandle)); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileAge == 0, "DS_AppData.FileStatus[FileIndex].FileAge == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileSize == 0, "DS_AppData.FileStatus[FileIndex].FileSize == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileName[0] == 0, - "DS_AppData.FileStatus[FileIndex].FileName[0] == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileAge, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileSize, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileName[0], 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal */ #endif @@ -1333,10 +1123,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void) #if (DS_MOVE_FILES == true) void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; strncpy(DS_AppData.FileStatus[FileIndex].FileName, "directory1/filename", sizeof(DS_AppData.FileStatus[FileIndex].FileName)); @@ -1351,20 +1138,12 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError(void) /* Execute the function being tested */ DS_FileCloseDest(FileIndex); - /* Verify results */ - /* UtAssert_True - (Ut_CFE_EVS_EventSent(DS_MOVE_FILE_ERR_EID, CFE_EVS_ERROR, "FILE MOVE error: src = 'directory1/filename', tgt - = 'directory2/movename/filename', result = -1"), "FILE MOVE error: src = 'directory1/filename', tgt = - 'directory2/movename/filename', result = -1"); - */ - UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[FileIndex].FileHandle)); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileAge == 0, "DS_AppData.FileStatus[FileIndex].FileAge == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileSize == 0, "DS_AppData.FileStatus[FileIndex].FileSize == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileName[0] == 0, - "DS_AppData.FileStatus[FileIndex].FileName[0] == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileAge, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileSize, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileName[0], 0); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_MOVE_FILE_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } /* end DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError */ #endif @@ -1372,10 +1151,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError(void) #if (DS_MOVE_FILES == true) void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; + int32 FileIndex = 0; UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); strncpy(DS_AppData.FileStatus[FileIndex].FileName, "directory1/filenamefilenamefilenamefilenamefilenamefilename", @@ -1386,20 +1162,12 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void) /* Execute the function being tested */ DS_FileCloseDest(FileIndex); - /* Verify results */ - /* UtAssert_True - (Ut_CFE_EVS_EventSent(DS_MOVE_FILE_ERR_EID, CFE_EVS_ERROR, "FILE MOVE error: dir name = 'directory2/movename', - filename = '/filenamefilenamefilenamefilenamefilenamefilename'"), "FILE MOVE error: dir name = - 'directory2/movename', filename = '/filenamefilenamefilen'"); - */ - UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[FileIndex].FileHandle)); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileAge == 0, "DS_AppData.FileStatus[FileIndex].FileAge == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileSize == 0, "DS_AppData.FileStatus[FileIndex].FileSize == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileName[0] == 0, - "DS_AppData.FileStatus[FileIndex].FileName[0] == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileAge, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileSize, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileName[0], 0); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_MOVE_FILE_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } /* end DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge */ #endif @@ -1407,11 +1175,9 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void) #if (DS_MOVE_FILES == true) void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull(void) { - int32 FileIndex = 0; - DS_DestFileTable_t DestFileTable; + int32 FileIndex = 0; UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); - DS_AppData.DestFileTblPtr = &DestFileTable; strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); @@ -1442,37 +1208,25 @@ void DS_FileCloseDest_Test_MoveFilesFalse(void) DS_FileCloseDest(FileIndex); /* Verify results */ - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileHandle == OS_OBJECT_ID_UNDEFINED, - "DS_AppData.FileStatus[FileIndex].FileHandle == OS_OBJECT_ID_UNDEFINED"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileAge == 0, "DS_AppData.FileStatus[FileIndex].FileAge == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileSize == 0, "DS_AppData.FileStatus[FileIndex].FileSize == 0"); - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileName[0] == 0, - "DS_AppData.FileStatus[FileIndex].FileName[0] == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileHandle, OS_OBJECT_ID_UNDEFINED); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileAge, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileSize, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileName[0], 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileCloseDest_Test_MoveFilesFalse */ #endif void DS_FileTestAge_Test_Nominal(void) { - int32 FileIndex = 0; - uint32 ElapsedSeconds = 2; - DS_DestFileTable_t DestFileTable; - uint32 i; + int32 FileIndex = 0; + uint32 ElapsedSeconds = 2; + uint32 i; UT_SetHandlerFunction(UT_KEY(OS_close), &UT_OS_CLOSE_SuccessHandler, NULL); - DS_AppData.DestFileTblPtr = &DestFileTable; for (i = 0; i < DS_DEST_FILE_CNT; i++) { strncpy(DS_AppData.FileStatus[i].FileName, "directory1/filename", sizeof(DS_AppData.FileStatus[i].FileName)); -#if (DS_MOVE_FILES == true) - DS_AppData.DestFileTblPtr->File[i].Movename[0] = '\0'; -#endif - - DS_AppData.FileStatus[i].FileHandle = OS_OBJECT_ID_UNDEFINED; } DS_AppData.FileStatus[FileIndex].FileHandle = DS_UT_OBJID_1; @@ -1483,45 +1237,31 @@ void DS_FileTestAge_Test_Nominal(void) DS_FileTestAge(ElapsedSeconds); /* Verify results */ - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileAge == 2, "DS_AppData.FileStatus[FileIndex].FileAge == 2"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileAge, 2); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileTestAge_Test_Nominal */ void DS_FileTestAge_Test_NullTable(void) { - uint32 ElapsedSeconds = 2; - uint8 call_count_OS_close = 0; - DS_AppData.DestFileTblPtr = NULL; + uint32 ElapsedSeconds = 2; + DS_AppData.DestFileTblPtr = NULL; /* Execute the function being tested */ DS_FileTestAge(ElapsedSeconds); /* Verify results */ - call_count_OS_close = UT_GetStubCount(UT_KEY(OS_close)); - UtAssert_INT32_EQ(call_count_OS_close, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(OS_close, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileTestAge_Test_NullTable */ void DS_FileTestAge_Test_ExceedMaxAge(void) { - int32 FileIndex = 0; - uint32 ElapsedSeconds = 2; - DS_DestFileTable_t DestFileTable; + int32 FileIndex = 0; + uint32 ElapsedSeconds = 2; - DS_AppData.DestFileTblPtr = &DestFileTable; - - DS_AppData.FileStatus[FileIndex].FileHandle = DS_UT_OBJID_1; - for (int32 i = 1; i < DS_DEST_FILE_CNT; i++) - { - DS_AppData.FileStatus[i].FileHandle = OS_OBJECT_ID_UNDEFINED; - } - DS_AppData.DestFileTblPtr->File[FileIndex].MaxFileAge = 1; - DS_AppData.DestFileTblPtr->File[FileIndex].Movename[0] = '\0'; + DS_AppData.FileStatus[FileIndex].FileHandle = DS_UT_OBJID_1; + DS_AppData.DestFileTblPtr->File[FileIndex].MaxFileAge = 1; UT_DS_SetupFileUpdateHeaderSuccess(); UT_DS_SetupFileCloseDestSuccess(); @@ -1530,11 +1270,8 @@ void DS_FileTestAge_Test_ExceedMaxAge(void) DS_FileTestAge(ElapsedSeconds); /* Verify results */ - UtAssert_True(DS_AppData.FileStatus[FileIndex].FileAge == 0, "DS_AppData.FileStatus[FileIndex].FileAge == 0"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - + UtAssert_UINT32_EQ(DS_AppData.FileStatus[FileIndex].FileAge, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_FileTestAge_Test_ExceedMaxAge */ void DS_IsPacketFiltered_Test_AlgX0(void) @@ -1762,122 +1499,86 @@ void DS_FileTransmit_Test_NoBuf(void) void UtTest_Setup(void) { - UtTest_Add(DS_FileStorePacket_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileStorePacket_Test_Nominal"); - UtTest_Add(DS_FileStorePacket_Test_PacketNotInTable, DS_Test_Setup, DS_Test_TearDown, - "DS_FileStorePacket_Test_PacketNotInTable"); - UtTest_Add(DS_FileStorePacket_Test_PassedFilterFalse, DS_Test_Setup, DS_Test_TearDown, - "DS_FileStorePacket_Test_PassedFilterFalse"); - UtTest_Add(DS_FileStorePacket_Test_DisabledDest, DS_Test_Setup, DS_Test_TearDown, - "DS_FileStorePacket_Test_DisabledDest"); - UtTest_Add(DS_FileStorePacket_Test_InvalidIndex, DS_Test_Setup, DS_Test_TearDown, - "DS_FileStorePacket_Test_InvalidIndex"); - - UtTest_Add(DS_FileSetupWrite_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileSetupWrite_Test_Nominal"); - UtTest_Add(DS_FileSetupWrite_Test_FileHandleClosed, DS_Test_Setup, DS_Test_TearDown, - "DS_FileSetupWrite_Test_FileHandleClosed"); - UtTest_Add(DS_FileSetupWrite_Test_MaxFileSizeExceeded, DS_Test_Setup, DS_Test_TearDown, - "DS_FileSetupWrite_Test_MaxFileSizeExceeded"); - - UtTest_Add(DS_FileWriteData_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileWriteData_Test_Nominal"); - UtTest_Add(DS_FileWriteData_Test_Error, DS_Test_Setup, DS_Test_TearDown, "DS_FileWriteData_Test_Error"); + UT_DS_TEST_ADD(DS_FileStorePacket_Test_Nominal); + UT_DS_TEST_ADD(DS_FileStorePacket_Test_PacketNotInTable); + UT_DS_TEST_ADD(DS_FileStorePacket_Test_PassedFilterFalse); + UT_DS_TEST_ADD(DS_FileStorePacket_Test_DisabledDest); + UT_DS_TEST_ADD(DS_FileStorePacket_Test_InvalidIndex); + + UT_DS_TEST_ADD(DS_FileSetupWrite_Test_Nominal); + UT_DS_TEST_ADD(DS_FileSetupWrite_Test_FileHandleClosed); + UT_DS_TEST_ADD(DS_FileSetupWrite_Test_MaxFileSizeExceeded); + + UT_DS_TEST_ADD(DS_FileWriteData_Test_Nominal); + UT_DS_TEST_ADD(DS_FileWriteData_Test_Error); #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE - UtTest_Add(DS_FileWriteHeader_Test_PlatformConfigCFE_Nominal, DS_Test_Setup, DS_Test_TearDown, - "DS_FileWriteHeader_Test_PlatformConfigCFE_Nominal"); - UtTest_Add(DS_FileWriteHeader_Test_PrimaryHeaderError, DS_Test_Setup, DS_Test_TearDown, - "DS_FileWriteHeader_Test_PrimaryHeaderError"); - UtTest_Add(DS_FileWriteHeader_Test_SecondaryHeaderError, DS_Test_Setup, DS_Test_TearDown, - "DS_FileWriteHeader_Test_SecondaryHeaderError"); + UT_DS_TEST_ADD(DS_FileWriteHeader_Test_PlatformConfigCFE_Nominal); + UT_DS_TEST_ADD(DS_FileWriteHeader_Test_PrimaryHeaderError); + UT_DS_TEST_ADD(DS_FileWriteHeader_Test_SecondaryHeaderError); #endif #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE - UtTest_Add(DS_FileWriteError_Test, DS_Test_Setup, DS_Test_TearDown, "DS_FileWriteError_Test"); + UT_DS_TEST_ADD(DS_FileWriteError_Test); #endif - UtTest_Add(DS_FileCreateDest_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileCreateDest_Test_Nominal"); - UtTest_Add(DS_FileCreateDest_Test_StringTerminate, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateDest_Test_StringTerminate"); - UtTest_Add(DS_FileCreateDest_Test_NominalRollover, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateDest_Test_NominalRollover"); - UtTest_Add(DS_FileCreateDest_Test_Error, DS_Test_Setup, DS_Test_TearDown, "DS_FileCreateDest_Test_Error"); + UT_DS_TEST_ADD(DS_FileCreateDest_Test_Nominal); + UT_DS_TEST_ADD(DS_FileCreateDest_Test_StringTerminate); + UT_DS_TEST_ADD(DS_FileCreateDest_Test_NominalRollover); + UT_DS_TEST_ADD(DS_FileCreateDest_Test_Error); #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE - UtTest_Add(DS_FileCreateDest_Test_ClosedFileHandle, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateDest_Test_ClosedFileHandle"); + UT_DS_TEST_ADD(DS_FileCreateDest_Test_ClosedFileHandle); #endif - UtTest_Add(DS_FileCreateName_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileCreateName_Test_Nominal"); - UtTest_Add(DS_FileCreateName_Test_NominalWithSeparator, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateName_Test_NominalWithSeparator"); - UtTest_Add(DS_FileCreateName_Test_NominalWithPeriod, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateName_Test_NominalWithPeriod"); - UtTest_Add(DS_FileCreateName_Test_EmptyPath, DS_Test_Setup, DS_Test_TearDown, "DS_FileCreateName_Test_EmptyPath"); - UtTest_Add(DS_FileCreateName_Test_Error, DS_Test_Setup, DS_Test_TearDown, "DS_FileCreateName_Test_Error"); - UtTest_Add(DS_FileCreateName_Test_MaxPathnameLength, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateName_Test_MaxPathnameLength"); - UtTest_Add(DS_FileCreateName_Test_PathBaseSeqTooLarge, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateName_Test_PathBaseSeqTooLarge"); - UtTest_Add(DS_FileCreateName_Test_PathBaseSeqExtTooLarge, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateName_Test_PathBaseSeqExtTooLarge"); - UtTest_Add(DS_FileCreateName_Test_ExtensionZero, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateName_Test_ExtensionZero"); + UT_DS_TEST_ADD(DS_FileCreateName_Test_Nominal); + UT_DS_TEST_ADD(DS_FileCreateName_Test_NominalWithSeparator); + UT_DS_TEST_ADD(DS_FileCreateName_Test_NominalWithPeriod); + UT_DS_TEST_ADD(DS_FileCreateName_Test_EmptyPath); + UT_DS_TEST_ADD(DS_FileCreateName_Test_Error); + UT_DS_TEST_ADD(DS_FileCreateName_Test_MaxPathnameLength); + UT_DS_TEST_ADD(DS_FileCreateName_Test_PathBaseSeqTooLarge); + UT_DS_TEST_ADD(DS_FileCreateName_Test_PathBaseSeqExtTooLarge); + UT_DS_TEST_ADD(DS_FileCreateName_Test_ExtensionZero); #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE - UtTest_Add(DS_FileCreateSequence_Test_ByCount, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateSequence_Test_ByCount"); - UtTest_Add(DS_FileCreateSequence_Test_ByTime, DS_Test_Setup, DS_Test_TearDown, "DS_FileCreateSequence_Test_ByTime"); - UtTest_Add(DS_FileCreateSequence_Test_BadFilenameType, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCreateSequence_Test_BadFilenameType"); + UT_DS_TEST_ADD(DS_FileCreateSequence_Test_ByCount); + UT_DS_TEST_ADD(DS_FileCreateSequence_Test_ByTime); + UT_DS_TEST_ADD(DS_FileCreateSequence_Test_BadFilenameType); #endif #if DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE - UtTest_Add(DS_FileUpdateHeader_Test_PlatformConfigCFE_Nominal, DS_Test_Setup, DS_Test_TearDown, - "DS_FileUpdateHeader_Test_PlatformConfigCFE_Nominal"); - UtTest_Add(DS_FileUpdateHeader_Test_WriteError, DS_Test_Setup, DS_Test_TearDown, - "DS_FileUpdateHeader_Test_WriteError"); - UtTest_Add(DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError, DS_Test_Setup, DS_Test_TearDown, - "DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError"); + UT_DS_TEST_ADD(DS_FileUpdateHeader_Test_PlatformConfigCFE_Nominal); + UT_DS_TEST_ADD(DS_FileUpdateHeader_Test_WriteError); + UT_DS_TEST_ADD(DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError); #endif #if (DS_MOVE_FILES == true) - UtTest_Add(DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal"); - UtTest_Add(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError"); - UtTest_Add(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge"); - UtTest_Add(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull"); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull); #else - UtTest_Add(DS_FileCloseDest_Test_MoveFilesFalse, DS_Test_Setup, DS_Test_TearDown, - "DS_FileCloseDest_Test_MoveFilesFalse"); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_MoveFilesFalse); #endif - UtTest_Add(DS_FileTestAge_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileTestAge_Test_Nominal"); - UtTest_Add(DS_FileTestAge_Test_ExceedMaxAge, DS_Test_Setup, DS_Test_TearDown, "DS_FileTestAge_Test_ExceedMaxAge"); - UtTest_Add(DS_FileTestAge_Test_NullTable, DS_Test_Setup, DS_Test_TearDown, "DS_FileTestAge_Test_NullTable"); - - UtTest_Add(DS_IsPacketFiltered_Test_AlgX0, DS_Test_Setup, DS_Test_TearDown, "DS_IsPacketFiltered_Test_AlgX0"); - UtTest_Add(DS_IsPacketFiltered_Test_AlgN0, DS_Test_Setup, DS_Test_TearDown, "DS_IsPacketFiltered_Test_AlgN0"); - UtTest_Add(DS_IsPacketFiltered_Test_AlgNGreaterX, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_AlgNGreaterX"); - UtTest_Add(DS_IsPacketFiltered_Test_Alg0GreaterX, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_Alg0GreaterThanX"); - UtTest_Add(DS_IsPacketFiltered_Test_Alg0EqualX, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_Alg0EqualX"); - UtTest_Add(DS_IsPacketFiltered_Test_InvalidFilterType, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_InvalidFilterType"); - UtTest_Add(DS_IsPacketFiltered_Test_SeqFilter, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_SeqFilter"); - UtTest_Add(DS_IsPacketFiltered_Test_TimeFilter1, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_TimeFilter1"); - UtTest_Add(DS_IsPacketFiltered_Test_TimeFilter2, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_TimeFilter2"); - UtTest_Add(DS_IsPacketFiltered_Test_TimeFilter3, DS_Test_Setup, DS_Test_TearDown, - "DS_IsPacketFiltered_Test_TimeFilter3"); - - UtTest_Add(DS_FileTransmit_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_FileTransmit_Test_Nominal"); - UtTest_Add(DS_FileTransmit_Test_NoBuf, DS_Test_Setup, DS_Test_TearDown, "DS_FileTransmit_Test_NoBuf"); + UT_DS_TEST_ADD(DS_FileTestAge_Test_Nominal); + UT_DS_TEST_ADD(DS_FileTestAge_Test_ExceedMaxAge); + UT_DS_TEST_ADD(DS_FileTestAge_Test_NullTable); + + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_AlgX0); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_AlgN0); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_AlgNGreaterX); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_Alg0GreaterX); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_Alg0EqualX); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_InvalidFilterType); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_SeqFilter); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_TimeFilter1); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_TimeFilter2); + UT_DS_TEST_ADD(DS_IsPacketFiltered_Test_TimeFilter3); + + UT_DS_TEST_ADD(DS_FileTransmit_Test_Nominal); + UT_DS_TEST_ADD(DS_FileTransmit_Test_NoBuf); } /* end DS_File_Test_AddTestCases */ diff --git a/unit-test/ds_table_tests.c b/unit-test/ds_table_tests.c index 8b7adad..0497b96 100644 --- a/unit-test/ds_table_tests.c +++ b/unit-test/ds_table_tests.c @@ -35,7 +35,6 @@ #include "ds_events.h" #include "ds_version.h" #include "ds_test_utils.h" -/*#include "ut_utils_lib.h"*/ /* UT includes */ #include "uttest.h" @@ -45,73 +44,23 @@ #include #include -DS_DestFileTable_t UT_DS_TABLE_TEST_DestFileTable; -int32 UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1(void *UserObj, int32 StubRetcode, uint32 CallCount, - const UT_StubContext_t *Context) -{ - DS_AppData.DestFileTblPtr = &UT_DS_TABLE_TEST_DestFileTable; - - return CFE_TBL_INFO_UPDATED; -} /* end UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1 */ - -int32 UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook2(void *UserObj, int32 StubRetcode, uint32 CallCount, - const UT_StubContext_t *Context) -{ - DS_AppData.DestFileTblPtr = &UT_DS_TABLE_TEST_DestFileTable; - - return CFE_TBL_ERR_NEVER_LOADED; -} /* end UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook2 */ - -DS_FilterTable_t UT_DS_TABLE_TEST_FilterTable; -int32 UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook3(void *UserObj, int32 StubRetcode, uint32 CallCount, - const UT_StubContext_t *Context) -{ - DS_AppData.FilterTblPtr = &UT_DS_TABLE_TEST_FilterTable; - - return CFE_TBL_INFO_UPDATED; -} /* end UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook3 */ - -int32 UT_DS_TABLE_TEST_CFE_TBL_GetStatusHook(void *UserObj, int32 StubRetcode, uint32 CallCount, - const UT_StubContext_t *Context) -{ - DS_AppData.DestFileTblPtr = &UT_DS_TABLE_TEST_DestFileTable; - - return CFE_TBL_INFO_UPDATE_PENDING; -} /* end UT_DS_TABLE_TEST_CFE_TBL_GetStatusHook */ - -uint8 call_count_CFE_EVS_SendEvent; - /* * Function Definitions */ void DS_TableInit_Test_Nominal(void) { - int32 Result; - /* Set to prevent unintended error messages */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Load), CFE_SUCCESS); /* Execute the function being tested */ - Result = DS_TableInit(); - - /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); + UtAssert_INT32_EQ(DS_TableInit(), CFE_SUCCESS); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableInit_Test_Nominal */ void DS_TableInit_Test_TableInfoRecovered(void) { - int32 Result; - - int32 strCmpResult; - char ExpectedEventString1[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString1, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Destination File Table data restored from CDS"); - snprintf(ExpectedEventString2, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Filter Table data restored from CDS"); - /* Set to generate both of the two error messages DS_INIT_TBL_CDS_EID */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Register), CFE_TBL_INFO_RECOVERED_TBL); @@ -119,41 +68,19 @@ void DS_TableInit_Test_TableInfoRecovered(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Load), CFE_SUCCESS); /* Execute the function being tested */ - Result = DS_TableInit(); + UtAssert_INT32_EQ(DS_TableInit(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_TBL_CDS_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_DEBUG); - - strCmpResult = strncmp(ExpectedEventString1, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_INIT_TBL_CDS_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_DEBUG); - strCmpResult = strncmp(ExpectedEventString2, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - } /* end DS_TableInit_Test_TableInfoRecovered */ void DS_TableInit_Test_RegisterDestTableError(void) { - int32 Result; - - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Unable to register Destination File Table: Error = 0x%%08X"); - /* Set to generate first instance of error message DS_INIT_TBL_ERR_EID */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Register), 0x99); @@ -161,33 +88,17 @@ void DS_TableInit_Test_RegisterDestTableError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Load), CFE_SUCCESS); /* Execute the function being tested */ - Result = DS_TableInit(); + UtAssert_INT32_EQ(DS_TableInit(), 0x99); /* Verify results */ - UtAssert_True(Result == 0x99, "Result == 0x99"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableInit_Test_RegisterDestTableError */ void DS_TableInit_Test_RegisterFilterTableError(void) { - int32 Result; - - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Unable to register Filter Table: Error = 0x%%08X"); - /* Set to generate second instance of error message DS_INIT_TBL_ERR_EID */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 2, 0x99); @@ -195,152 +106,101 @@ void DS_TableInit_Test_RegisterFilterTableError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Load), CFE_SUCCESS); /* Execute the function being tested */ - Result = DS_TableInit(); + UtAssert_INT32_EQ(DS_TableInit(), 0x99); /* Verify results */ - UtAssert_True(Result == 0x99, "Result == 0x99"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableInit_Test_RegisterFilterTableError */ void DS_TableInit_Test_LoadDestTableError(void) { - int32 Result; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Unable to load default Destination File Table: Filename = '%%s', Error = 0x%%08X"); - /* Fail on the first load (loading the dest table */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Load), 1, -1); /* Execute the function being tested */ - Result = DS_TableInit(); + UtAssert_INT32_EQ(DS_TableInit(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableInit_Test_LoadDestTableError */ void DS_TableInit_Test_LoadFilterTableError(void) { - int32 Result; - - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Unable to load default Filter Table: Filename = '%%s', Error = 0x%%08X"); - /* Set to generate error message DS_INIT_TBL_ERR_EID on 2nd call (but not 1st) */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Load), 2, -1); + /* Setting addresses to NULL will exercise table manage address NULL but unmatched GetAddress cases */ + DS_AppData.DestFileTblPtr = NULL; + DS_AppData.FilterTblPtr = NULL; + /* Execute the function being tested */ - Result = DS_TableInit(); + UtAssert_INT32_EQ(DS_TableInit(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableInit_Test_LoadFilterTableError */ void DS_TableManageDestFile_Test_TableInfoUpdated(void) { uint32 i; - DS_AppData.DestFileTblPtr = &UT_DS_TABLE_TEST_DestFileTable; - for (i = 0; i < DS_DEST_FILE_CNT; i++) { DS_AppData.DestFileTblPtr->File[i].EnableState = i; DS_AppData.DestFileTblPtr->File[i].SequenceCount = i; } - DS_AppData.DestFileTblPtr = (DS_DestFileTable_t *)NULL; - - /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_INFO_UPDATED)", and sets - * DS_AppData.DestFileTblPtr to the address of a local table defined globally in this file, to prevent segmentation - * fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1, NULL); + /* Reset table pointer to NULL, but cause the CFE_TBL_GetAddress handler to provide back the ut value */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); + UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &DS_AppData.DestFileTblPtr, sizeof(DS_AppData.DestFileTblPtr), true); + DS_AppData.DestFileTblPtr = NULL; /* Execute the function being tested */ DS_TableManageDestFile(); /* Verify results */ - UtAssert_True(DS_AppData.DestTblLoadCounter == 1, "DS_AppData.DestTblLoadCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.DestTblLoadCounter, 1); - UtAssert_True(DS_AppData.FileStatus[0].FileState == 0, "DS_AppData.FileStatus[0].FileState == 0"); - UtAssert_True(DS_AppData.FileStatus[0].FileCount == 0, "DS_AppData.FileStatus[0].FileCount == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileState, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileCount, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileState == DS_DEST_FILE_CNT / 2, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileState == DS_DEST_FILE_CNT/2"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount == DS_DEST_FILE_CNT / 2, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileCount == DS_DEST_FILE_CNT/2"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileState, DS_DEST_FILE_CNT / 2); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount, DS_DEST_FILE_CNT / 2); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileState == DS_DEST_FILE_CNT - 1, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileState == DS_DEST_FILE_CNT-1"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount == DS_DEST_FILE_CNT - 1, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileCount == DS_DEST_FILE_CNT-1"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileState, DS_DEST_FILE_CNT - 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount, DS_DEST_FILE_CNT - 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageDestFile_Test_TableInfoUpdated */ void DS_TableManageDestFile_Test_TableNeverLoaded(void) { - /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_ERR_NEVER_LOADED)", and sets - * DS_AppData.DestFileTblPtr to the address of a local table defined globally in this file, to prevent segmentation - * fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook2, NULL); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_NEVER_LOADED); + DS_AppData.DestFileTblPtr = NULL; /* Execute the function being tested */ DS_TableManageDestFile(); /* Verify results */ - UtAssert_True(DS_AppData.DestTblErrCounter == 1, "DS_AppData.DestTblErrCounter == 1"); - UtAssert_True(DS_AppData.DestFileTblPtr == (DS_DestFileTable_t *)NULL, - "DS_AppData.DestFileTblPtr == (DS_DestFileTable_t *) NULL"); + UtAssert_UINT32_EQ(DS_AppData.DestTblErrCounter, 1); + UtAssert_ADDRESS_EQ(DS_AppData.DestFileTblPtr, NULL); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } /* end DS_TableManageDestFile_Test_TableNeverLoaded */ void DS_TableManageDestFile_Test_TableInfoDumpPending(void) { - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; - /* Set to satisfy condition "if (Result == CFE_TBL_INFO_DUMP_PENDING)" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_TBL_INFO_DUMP_PENDING); @@ -348,16 +208,12 @@ void DS_TableManageDestFile_Test_TableInfoDumpPending(void) DS_TableManageDestFile(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + } /* end DS_TableManageDestFile_Test_TableInfoDumpPending */ void DS_TableManageDestFile_Test_TableInfoValidationPending(void) { - DS_DestFileTable_t DestFileTable; - - DS_AppData.DestFileTblPtr = &DestFileTable; - /* Set to satisfy condition "if (Result == CFE_TBL_INFO_VALIDATION_PENDING)" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_TBL_INFO_VALIDATION_PENDING); @@ -365,51 +221,39 @@ void DS_TableManageDestFile_Test_TableInfoValidationPending(void) DS_TableManageDestFile(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + } /* end DS_TableManageDestFile_Test_TableInfoValidationPending */ void DS_TableManageDestFile_Test_TableInfoUpdatePending(void) { uint32 i; - DS_AppData.DestFileTblPtr = &UT_DS_TABLE_TEST_DestFileTable; - for (i = 0; i < DS_DEST_FILE_CNT; i++) { DS_AppData.DestFileTblPtr->File[i].EnableState = i; DS_AppData.DestFileTblPtr->File[i].SequenceCount = i; } - /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_INFO_UPDATE_PENDING)", and sets - * DS_AppData.DestFileTblPtr to the address of a local table defined globally in this file, to prevent segmentation - * fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetStatus), &UT_DS_TABLE_TEST_CFE_TBL_GetStatusHook, NULL); - - /* Prevents segmentation fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1, NULL); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_TBL_INFO_UPDATE_PENDING); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ DS_TableManageDestFile(); /* Verify results */ - UtAssert_True(DS_AppData.DestTblLoadCounter == 1, "DS_AppData.DestTblLoadCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.DestTblLoadCounter, 1); - UtAssert_True(DS_AppData.FileStatus[0].FileState == 0, "DS_AppData.FileStatus[0].FileState == 0"); - UtAssert_True(DS_AppData.FileStatus[0].FileCount == 0, "DS_AppData.FileStatus[0].FileCount == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileState, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileCount, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileState == DS_DEST_FILE_CNT / 2, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileState == DS_DEST_FILE_CNT/2"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount == DS_DEST_FILE_CNT / 2, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileCount == DS_DEST_FILE_CNT/2"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileState, DS_DEST_FILE_CNT / 2); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount, DS_DEST_FILE_CNT / 2); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileState == DS_DEST_FILE_CNT - 1, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileState == DS_DEST_FILE_CNT-1"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount == DS_DEST_FILE_CNT - 1, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileCount == DS_DEST_FILE_CNT-1"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileState, DS_DEST_FILE_CNT - 1); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount, DS_DEST_FILE_CNT - 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageDestFile_Test_TableInfoUpdatePending */ @@ -417,60 +261,48 @@ void DS_TableManageDestFile_Test_TableSuccess(void) { uint32 i; - DS_AppData.DestFileTblPtr = &UT_DS_TABLE_TEST_DestFileTable; - for (i = 0; i < DS_DEST_FILE_CNT; i++) { DS_AppData.DestFileTblPtr->File[i].EnableState = i; DS_AppData.DestFileTblPtr->File[i].SequenceCount = i; } - /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_INFO_UPDATE_PENDING)", and sets - * DS_AppData.DestFileTblPtr to the address of a local table defined globally in this file, to prevent segmentation - * fault */ - // UT_SetHookFunction(UT_KEY(CFE_TBL_GetStatus), &UT_DS_TABLE_TEST_CFE_TBL_GetStatusHook, NULL); UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_SUCCESS); - /* Prevents segmentation fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1, NULL); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ DS_TableManageDestFile(); /* Verify results */ - UtAssert_True(DS_AppData.DestTblLoadCounter == 0, "DS_AppData.DestTblLoadCounter == 0"); + UtAssert_UINT32_EQ(DS_AppData.DestTblLoadCounter, 0); - UtAssert_True(DS_AppData.FileStatus[0].FileState == 0, "DS_AppData.FileStatus[0].FileState == 0"); - UtAssert_True(DS_AppData.FileStatus[0].FileCount == 0, "DS_AppData.FileStatus[0].FileCount == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileState, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileCount, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileState == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileState == 0"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileCount == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileState, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount, 0); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileState == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileState == 0"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileCount == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileState, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageDestFile_Test_TableInfoUpdatePending */ void DS_TableManageFilter_Test_TableInfoUpdated(void) { - /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_INFO_UPDATED)", and sets - * DS_AppData.FilterTblPtr to the address of a table defined globally in this file, to prevent segmentation fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook3, NULL); + /* Set handle back to NULL, but cause CFE_TBL_GetAddress to return valid address */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); + UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &DS_AppData.FilterTblPtr, sizeof(DS_AppData.FilterTblPtr), true); + DS_AppData.FilterTblPtr = NULL; /* Execute the function being tested */ DS_TableManageFilter(); /* Verify results */ - UtAssert_True(DS_AppData.FilterTblLoadCounter == 1, "DS_AppData.FilterTblLoadCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.FilterTblLoadCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageFilter_Test_TableInfoUpdated */ @@ -478,26 +310,21 @@ void DS_TableManageFilter_Test_TableNeverLoaded(void) { /* Set to satisfy condition "if (Result == CFE_TBL_ERR_NEVER_LOADED)" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_NEVER_LOADED); + DS_AppData.FilterTblPtr = NULL; /* Execute the function being tested */ DS_TableManageFilter(); /* Verify results */ - UtAssert_True(DS_AppData.FilterTblErrCounter == 1, "DS_AppData.FilterTblErrCounter == 1"); - UtAssert_True(DS_AppData.FilterTblPtr == (DS_FilterTable_t *)NULL, - "DS_AppData.FilterTblPtr == (DS_FilterTable_t *) NULL"); + UtAssert_UINT32_EQ(DS_AppData.FilterTblErrCounter, 1); + UtAssert_ADDRESS_EQ(DS_AppData.FilterTblPtr, NULL); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageFilter_Test_TableNeverLoaded */ void DS_TableManageFilter_Test_TableInfoDumpPending(void) { - DS_FilterTable_t FilterTable; - - DS_AppData.FilterTblPtr = &FilterTable; - /* Set to satisfy condition "if (Result == CFE_TBL_INFO_DUMP_PENDING)" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_TBL_INFO_DUMP_PENDING); @@ -505,17 +332,12 @@ void DS_TableManageFilter_Test_TableInfoDumpPending(void) DS_TableManageFilter(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageFilter_Test_TableInfoDumpPending */ void DS_TableManageFilter_Test_TableInfoValidationPending(void) { - DS_FilterTable_t FilterTable; - - DS_AppData.FilterTblPtr = &FilterTable; - /* Set to satisfy condition "CFE_TBL_INFO_VALIDATION_PENDING" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_TBL_INFO_VALIDATION_PENDING); @@ -523,69 +345,51 @@ void DS_TableManageFilter_Test_TableInfoValidationPending(void) DS_TableManageFilter(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageFilter_Test_TableInfoValidationPending */ void DS_TableManageFilter_Test_TableInfoUpdatePending(void) { - DS_AppData.FilterTblPtr = &UT_DS_TABLE_TEST_FilterTable; - /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_INFO_UPDATE_PENDING)", and sets - * DS_AppData.DestFileTblPtr to the address of a local table defined globally in this file, to prevent segmentation - * fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetStatus), &UT_DS_TABLE_TEST_CFE_TBL_GetStatusHook, NULL); - - /* Prevents segmentation fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1, NULL); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_TBL_INFO_UPDATE_PENDING); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ DS_TableManageFilter(); /* Verify results */ - UtAssert_True(DS_AppData.FilterTblLoadCounter == 1, "DS_AppData.FilterTblLoadCounter == 1"); + UtAssert_UINT32_EQ(DS_AppData.FilterTblLoadCounter, 1); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageFilter_Test_TableInfoUpdatePending */ void DS_TableManageFilter_Test_TableSuccess(void) { - DS_AppData.FilterTblPtr = &UT_DS_TABLE_TEST_FilterTable; /* Returns CFE_TBL_INFO_UPDATED to satisfy condition "if (Result == CFE_TBL_INFO_UPDATE_PENDING)", and sets * DS_AppData.DestFileTblPtr to the address of a local table defined globally in this file, to prevent segmentation * fault */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetStatus), CFE_SUCCESS); - /* Prevents segmentation fault */ - UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &UT_DS_TABLE_TEST_CFE_TBL_GetAddressHook1, NULL); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); /* Execute the function being tested */ DS_TableManageFilter(); /* Verify results */ - UtAssert_True(DS_AppData.FilterTblLoadCounter == 0, "DS_AppData.FilterTblLoadCounter == 0"); + UtAssert_UINT32_EQ(DS_AppData.FilterTblLoadCounter, 0); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableManageFilter_Test_TableInfoUpdatePending */ void DS_TableVerifyDestFile_Test_Nominal(void) { - int32 Result; DS_DestFileTable_t DestFileTable; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&DestFileTable, 0, sizeof(DestFileTable)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Destination file table verify results: desc text = %%s, good entries = %%d, bad = %%d, unused = %%d"); - strncpy(DestFileTable.File[0].Pathname, "path", DS_PATHNAME_BUFSIZE); strncpy(DestFileTable.File[0].Basename, "basename", DS_BASENAME_BUFSIZE); strncpy(DestFileTable.File[0].Extension, "ext", DS_EXTENSION_BUFSIZE); @@ -597,40 +401,22 @@ void DS_TableVerifyDestFile_Test_Nominal(void) DestFileTable.File[0].SequenceCount = DS_MAX_SEQUENCE_COUNT - 1; /* Execute the function being tested */ - Result = DS_TableVerifyDestFile(&DestFileTable); + UtAssert_INT32_EQ(DS_TableVerifyDestFile(&DestFileTable), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFile_Test_Nominal */ void DS_TableVerifyDestFile_Test_DestFileTableVerificationError(void) { - int32 Result; DS_DestFileTable_t DestFileTable; uint32 i; - int32 strCmpResult; - char ExpectedEventString1[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; memset(&DestFileTable, 0, sizeof(DestFileTable)); - snprintf(ExpectedEventString1, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Destination file table verify err: invalid descriptor text"); - - snprintf(ExpectedEventString2, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Destination file table verify results: desc text = %%s, good entries = %%d, bad = %%d, unused = %%d"); - memset(&DestFileTable.File[0], 1, sizeof(DestFileTable.File[0])); DestFileTable.File[0].FileNameType = DS_BY_TIME; DestFileTable.File[0].EnableState = DS_ENABLED; @@ -648,43 +434,23 @@ void DS_TableVerifyDestFile_Test_DestFileTableVerificationError(void) } /* Execute the function being tested */ - Result = DS_TableVerifyDestFile(&DestFileTable); + UtAssert_INT32_EQ(DS_TableVerifyDestFile(&DestFileTable), DS_TABLE_VERIFY_ERR); /* Verify results */ - UtAssert_True(Result == DS_TABLE_VERIFY_ERR, "Result == DS_TABLE_VERIFY_ERR"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - - strCmpResult = strncmp(ExpectedEventString1, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_FIL_TBL_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString2, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - } /* end DS_TableVerifyDestFile_Test_DestFileTableVerificationError */ void DS_TableVerifyDestFile_Test_CountBad(void) { - int32 Result; DS_DestFileTable_t DestFileTable; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; memset(&DestFileTable, 0, sizeof(DestFileTable)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Destination file table verify results: desc text = %%s, good entries = %%d, bad = %%d, unused = %%d"); - strncpy(DestFileTable.Descriptor, "descriptor", DS_DESCRIPTOR_BUFSIZE); DestFileTable.File[0].FileNameType = DS_BY_TIME; @@ -700,28 +466,18 @@ void DS_TableVerifyDestFile_Test_CountBad(void) memset(&DestFileTable.File[0], 1, sizeof(DestFileTable.File[0])); /* Execute the function being tested */ - Result = DS_TableVerifyDestFile(&DestFileTable); + UtAssert_INT32_EQ(DS_TableVerifyDestFile(&DestFileTable), DS_TABLE_VERIFY_ERR); /* Verify results */ - UtAssert_True(Result == DS_TABLE_VERIFY_ERR, "Result == DS_TABLE_VERIFY_ERR"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); /* this generates 1 event message we don't care about for this test */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_FIL_TBL_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - } /* end DS_TableVerifyDestFile_Test_CountBad */ void DS_TableVerifyDestFileEntry_Test_NominalErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; @@ -737,25 +493,18 @@ void DS_TableVerifyDestFileEntry_Test_NominalErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_TRUE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyDestFileEntry_Test_NominalErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidPathnameErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, invalid pathname text"); DestFileEntry.FileNameType = DS_BY_TIME; DestFileEntry.EnableState = DS_ENABLED; @@ -768,34 +517,21 @@ void DS_TableVerifyDestFileEntry_Test_InvalidPathnameErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidPathnameErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidBasenameErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, invalid basename text"); - DestFileEntry.FileNameType = DS_BY_TIME; DestFileEntry.EnableState = DS_ENABLED; DestFileEntry.MaxFileSize = 2048; @@ -807,35 +543,21 @@ void DS_TableVerifyDestFileEntry_Test_InvalidBasenameErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidBasenameErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, filename type = %%d"); - DestFileEntry.FileNameType = 99; DestFileEntry.EnableState = DS_ENABLED; DestFileEntry.MaxFileSize = 2048; @@ -847,35 +569,21 @@ void DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, file enable state = %%d"); - DestFileEntry.FileNameType = DS_BY_TIME; DestFileEntry.EnableState = 99; DestFileEntry.MaxFileSize = 2048; @@ -887,35 +595,21 @@ void DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, max file size = %%d"); - DestFileEntry.FileNameType = DS_BY_TIME; DestFileEntry.EnableState = DS_ENABLED; DestFileEntry.MaxFileSize = DS_FILE_MIN_SIZE_LIMIT - 1; @@ -927,35 +621,21 @@ void DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, max file age = %%d"); - DestFileEntry.FileNameType = DS_BY_TIME; DestFileEntry.EnableState = DS_ENABLED; DestFileEntry.MaxFileSize = 2048; @@ -967,35 +647,21 @@ void DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s index = %%d, sequence count = %%d"); - DestFileEntry.FileNameType = DS_BY_TIME; DestFileEntry.EnableState = DS_ENABLED; DestFileEntry.MaxFileSize = 2048; @@ -1007,27 +673,17 @@ void DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FIL_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrNonZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1043,19 +699,15 @@ void DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrNonZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrNonZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1071,19 +723,15 @@ void DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrNonZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidSizeErrNonZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1099,19 +747,15 @@ void DS_TableVerifyDestFileEntry_Test_InvalidSizeErrNonZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidAgeErrNonZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1127,19 +771,15 @@ void DS_TableVerifyDestFileEntry_Test_InvalidAgeErrNonZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero */ void DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrNonZero(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1155,30 +795,20 @@ void DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrNonZero(void) strncpy(DestFileEntry.Extension, "ext", DS_EXTENSION_BUFSIZE); /* Execute the function being tested */ - Result = DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyDestFileEntry(&DestFileEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero */ void DS_TableVerifyFilter_Test_Nominal(void) { - int32 Result; DS_FilterTable_t FilterTable; uint32 i; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&FilterTable, 0, sizeof(FilterTable)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Filter table verify results: desc text = %%s, good entries = %%d, bad = %%d, unused = %%d"); - FilterTable.Packet[0].MessageID = DS_UT_MID_1; FilterTable.Packet[0].Filter[0].FileTableIndex = 0; FilterTable.Packet[0].Filter[0].Algorithm_N = 1; @@ -1195,42 +825,22 @@ void DS_TableVerifyFilter_Test_Nominal(void) } /* Execute the function being tested */ - Result = DS_TableVerifyFilter(&FilterTable); + UtAssert_INT32_EQ(DS_TableVerifyFilter(&FilterTable), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FLT_TBL_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyFilter_Test_Nominal */ void DS_TableVerifyFilter_Test_FilterTableVerificationError(void) { - int32 Result; DS_FilterTable_t FilterTable; uint32 i; - int32 strCmpResult; - char ExpectedEventString1[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&FilterTable, 0, sizeof(FilterTable)); - snprintf(ExpectedEventString1, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "%%s MID = 0x%%08lX, index = %%d, filter = %%d, filter type = %%d"); - - snprintf(ExpectedEventString2, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Filter table verify results: desc text = %%s, good entries = %%d, bad = %%d, unused = %%d"); - FilterTable.Packet[0].MessageID = DS_UT_MID_1; FilterTable.Packet[0].Filter[0].FileTableIndex = 0; FilterTable.Packet[0].Filter[0].Algorithm_N = 1; @@ -1251,46 +861,24 @@ void DS_TableVerifyFilter_Test_FilterTableVerificationError(void) FilterTable.Packet[0].Filter[0].FilterType = 3; /* Execute the function being tested */ - Result = DS_TableVerifyFilter(&FilterTable); + UtAssert_INT32_EQ(DS_TableVerifyFilter(&FilterTable), DS_TABLE_VERIFY_ERR); /* Verify results */ - UtAssert_True(Result == DS_TABLE_VERIFY_ERR, "Result == DS_TABLE_VERIFY_ERR"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FLT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - - strCmpResult = strncmp(ExpectedEventString1, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_FLT_TBL_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString2, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - } /* end DS_TableVerifyFilter_Test_FilterTableVerificationError */ void DS_TableVerifyFilter_Test_CountBad(void) { - int32 Result; DS_FilterTable_t FilterTable; uint32 i; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&FilterTable, 0, sizeof(FilterTable)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "Filter table verify results: desc text = %%s, good entries = %%d, bad = %%d, unused = %%d"); - FilterTable.Packet[0].MessageID = DS_UT_MID_1; FilterTable.Packet[0].Filter[0].FileTableIndex = 0; FilterTable.Packet[0].Filter[0].Algorithm_N = 1; @@ -1307,28 +895,18 @@ void DS_TableVerifyFilter_Test_CountBad(void) } /* Execute the function being tested */ - Result = DS_TableVerifyFilter(&FilterTable); + UtAssert_INT32_EQ(DS_TableVerifyFilter(&FilterTable), DS_TABLE_VERIFY_ERR); /* Verify results */ - UtAssert_True(Result == DS_TABLE_VERIFY_ERR, "Result == DS_TABLE_VERIFY_ERR"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 2); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); /* this generates 1 event message we don't care about for this test */ - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_FLT_TBL_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_INFORMATION); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec); - } /* end DS_TableVerifyFilter_Test_CountBad */ void DS_TableVerifyFilterEntry_Test_Unused(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; @@ -1344,19 +922,15 @@ void DS_TableVerifyFilterEntry_Test_Unused(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_TRUE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFilterEntry_Test_Unused */ void DS_TableVerifyFilterEntry_Test_Nominal(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; @@ -1372,31 +946,21 @@ void DS_TableVerifyFilterEntry_Test_Nominal(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_TRUE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFilterEntry_Test_Nominal */ void DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrZero(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&PacketEntry, 0, sizeof(PacketEntry)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "%%s MID = 0x%%08lX, index = %%d, filter = %%d, file table index = %%d"); - PacketEntry.MessageID = DS_UT_MID_1; PacketEntry.Filter[0].FileTableIndex = DS_DEST_FILE_CNT + 1; PacketEntry.Filter[0].Algorithm_N = 1; @@ -1406,39 +970,23 @@ void DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrZero(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FLT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrZero */ void DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrZero(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&PacketEntry, 0, sizeof(PacketEntry)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "%%s MID = 0x%%08lX, index = %%d, filter = %%d, filter type = %%d"); - PacketEntry.MessageID = DS_UT_MID_1; PacketEntry.Filter[0].FileTableIndex = 0; PacketEntry.Filter[0].Algorithm_N = 1; @@ -1448,39 +996,23 @@ void DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrZero(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FLT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrZero */ void DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrZero(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - memset(&PacketEntry, 0, sizeof(PacketEntry)); - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "%%s MID = 0x%%08lX, index = %%d, filter = %%d, filter parms N = %%d, X = %%d, O = %%d"); - PacketEntry.MessageID = DS_UT_MID_1; PacketEntry.Filter[0].FileTableIndex = 0; PacketEntry.Filter[0].Algorithm_N = 1; @@ -1490,27 +1022,17 @@ void DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrZero(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_FLT_TBL_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrZero */ void DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrNonZero(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1526,19 +1048,15 @@ void DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrNonZero(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrNonZero */ void DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrNonZero(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1554,19 +1072,15 @@ void DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrNonZero(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrNonZero */ void DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrNonZero(void) { - int32 Result; DS_PacketEntry_t PacketEntry; uint32 TableIndex = 0; uint32 ErrorCount = 1; @@ -1582,638 +1096,422 @@ void DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrNonZero(void) DS_AppData.FileStatus[0].FileState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount); + UtAssert_BOOL_FALSE(DS_TableVerifyFilterEntry(&PacketEntry, TableIndex, ErrorCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrNonZero */ void DS_TableEntryUnused_Test_Nominal(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; memset(&DestFileEntry, DS_UNUSED, sizeof(DestFileEntry)); /* Execute the function being tested */ - Result = DS_TableEntryUnused(&DestFileEntry, sizeof(DestFileEntry)); + UtAssert_BOOL_TRUE(DS_TableEntryUnused(&DestFileEntry, sizeof(DestFileEntry))); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableEntryUnused_Test_Nominal */ void DS_TableEntryUnused_Test_Fail(void) { - int32 Result; DS_DestFileEntry_t DestFileEntry; memset(&DestFileEntry, 99, sizeof(DestFileEntry)); /* Execute the function being tested */ - Result = DS_TableEntryUnused(&DestFileEntry, sizeof(DestFileEntry)); + UtAssert_BOOL_FALSE(DS_TableEntryUnused(&DestFileEntry, sizeof(DestFileEntry))); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableEntryUnused_Test_Fail */ void DS_TableVerifyFileIndex_Test_Nominal(void) { - int32 Result; uint16 FileTableIndex = 0; /* Execute the function being tested */ - Result = DS_TableVerifyFileIndex(FileTableIndex); + UtAssert_BOOL_TRUE(DS_TableVerifyFileIndex(FileTableIndex)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFileIndex_Test_Nominal */ void DS_TableVerifyFileIndex_Test_Fail(void) { - int32 Result; uint16 FileTableIndex = DS_DEST_FILE_CNT; /* Execute the function being tested */ - Result = DS_TableVerifyFileIndex(FileTableIndex); + UtAssert_BOOL_FALSE(DS_TableVerifyFileIndex(FileTableIndex)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyFileIndex_Test_Fail */ void DS_TableVerifyParms_Test_NominalOnlyXNonZero(void) { - int32 Result; uint16 Algorithm_N = 0; uint16 Algorithm_X = 1; uint16 Algorithm_O = 0; /* Execute the function being tested */ - Result = DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O); + UtAssert_BOOL_TRUE(DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyParms_Test_NominalOnlyXNonZero */ void DS_TableVerifyParms_Test_NGreaterThanXOnlyNNonZero(void) { - int32 Result; uint16 Algorithm_N = 1; uint16 Algorithm_X = 0; uint16 Algorithm_O = 0; /* Execute the function being tested */ - Result = DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O); + UtAssert_BOOL_FALSE(DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyParms_Test_NGreaterThanXOnlyNNonZero */ void DS_TableVerifyParms_Test_OGreaterThanXOnlyONonZero(void) { - int32 Result; uint16 Algorithm_N = 0; uint16 Algorithm_X = 0; uint16 Algorithm_O = 1; /* Execute the function being tested */ - Result = DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O); + UtAssert_BOOL_FALSE(DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyParms_Test_OGreaterThanXOnlyONonZero */ void DS_TableVerifyParms_Test_AllZero(void) { - int32 Result; uint16 Algorithm_N = 0; uint16 Algorithm_X = 0; uint16 Algorithm_O = 0; /* Execute the function being tested */ - Result = DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O); + UtAssert_BOOL_TRUE(DS_TableVerifyParms(Algorithm_N, Algorithm_X, Algorithm_O)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyParms_Test_AllZero */ void DS_TableVerifyType_Test_Nominal(void) { - int32 Result; uint16 TimeVsCount = DS_BY_TIME; /* Execute the function being tested */ - Result = DS_TableVerifyType(TimeVsCount); + UtAssert_BOOL_TRUE(DS_TableVerifyType(TimeVsCount)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyType_Test_Nominal */ void DS_TableVerifyType_Test_Fail(void) { - int32 Result; uint16 TimeVsCount = 99; /* Execute the function being tested */ - Result = DS_TableVerifyType(TimeVsCount); + UtAssert_BOOL_FALSE(DS_TableVerifyType(TimeVsCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyType_Test_Fail */ void DS_TableVerifyState_Test_NominalEnabled(void) { - int32 Result; uint16 EnableState = DS_ENABLED; /* Execute the function being tested */ - Result = DS_TableVerifyState(EnableState); + UtAssert_BOOL_TRUE(DS_TableVerifyState(EnableState)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyState_Test_NominalEnabled */ void DS_TableVerifyState_Test_NominalDisabled(void) { - int32 Result; uint16 EnableState = DS_DISABLED; /* Execute the function being tested */ - Result = DS_TableVerifyState(EnableState); + UtAssert_BOOL_TRUE(DS_TableVerifyState(EnableState)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyState_Test_NominalDisabled */ void DS_TableVerifyState_Test_Fail(void) { - int32 Result; uint16 EnableState = 99; /* Execute the function being tested */ - Result = DS_TableVerifyState(EnableState); + UtAssert_BOOL_FALSE(DS_TableVerifyState(EnableState)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyState_Test_Fail */ void DS_TableVerifySize_Test_Nominal(void) { - int32 Result; uint32 MaxFileSize = DS_FILE_MIN_SIZE_LIMIT; /* Execute the function being tested */ - Result = DS_TableVerifySize(MaxFileSize); + UtAssert_BOOL_TRUE(DS_TableVerifySize(MaxFileSize)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifySize_Test_Nominal */ void DS_TableVerifySize_Test_Fail(void) { - int32 Result; uint32 MaxFileSize = DS_FILE_MIN_SIZE_LIMIT - 1; /* Execute the function being tested */ - Result = DS_TableVerifySize(MaxFileSize); + UtAssert_BOOL_FALSE(DS_TableVerifySize(MaxFileSize)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifySize_Test_Fail */ void DS_TableVerifyAge_Test_Nominal(void) { - int32 Result; uint32 MaxFileAge = DS_FILE_MIN_AGE_LIMIT; /* Execute the function being tested */ - Result = DS_TableVerifyAge(MaxFileAge); + UtAssert_BOOL_TRUE(DS_TableVerifyAge(MaxFileAge)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyAge_Test_Nominal */ void DS_TableVerifyAge_Test_Fail(void) { - int32 Result; uint32 MaxFileAge = DS_FILE_MIN_AGE_LIMIT - 1; /* Execute the function being tested */ - Result = DS_TableVerifyAge(MaxFileAge); + UtAssert_BOOL_FALSE(DS_TableVerifyAge(MaxFileAge)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyAge_Test_Fail */ void DS_TableVerifyCount_Test_Nominal(void) { - int32 Result; uint32 SequenceCount = DS_MAX_SEQUENCE_COUNT; /* Execute the function being tested */ - Result = DS_TableVerifyCount(SequenceCount); + UtAssert_BOOL_TRUE(DS_TableVerifyCount(SequenceCount)); /* Verify results */ - UtAssert_True(Result == true, "Result == true"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyCount_Test_Nominal */ void DS_TableVerifyCount_Test_Fail(void) { - int32 Result; uint32 SequenceCount = DS_MAX_SEQUENCE_COUNT + 1; /* Execute the function being tested */ - Result = DS_TableVerifyCount(SequenceCount); + UtAssert_BOOL_FALSE(DS_TableVerifyCount(SequenceCount)); /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableVerifyCount_Test_Fail */ void DS_TableSubscribe_Test_Unused(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_SubscribeEx = 0; - DS_AppData.FilterTblPtr = &FilterTable; - - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } /* Execute the function being tested */ DS_TableSubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_SubscribeEx = UT_GetStubCount(UT_KEY(CFE_SB_SubscribeEx)); - UtAssert_INT32_EQ(call_count_CFE_SB_SubscribeEx, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_SubscribeEx, 0); } /* end DS_TableSubscribe_Test_Unused */ void DS_TableSubscribe_Test_Cmd(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_SubscribeEx = 0; - DS_AppData.FilterTblPtr = &FilterTable; - - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - FilterTable.Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_CMD_MID); + DS_AppData.FilterTblPtr->Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_CMD_MID); /* Execute the function being tested */ DS_TableSubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_SubscribeEx = UT_GetStubCount(UT_KEY(CFE_SB_SubscribeEx)); - UtAssert_INT32_EQ(call_count_CFE_SB_SubscribeEx, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_SubscribeEx, 0); } /* end DS_TableSubscribe_Test_Cmd */ void DS_TableSubscribe_Test_SendHk(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_SubscribeEx = 0; - DS_AppData.FilterTblPtr = &FilterTable; - - for (int i = 1; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - FilterTable.Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); + DS_AppData.FilterTblPtr->Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); /* Execute the function being tested */ DS_TableSubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_SubscribeEx = UT_GetStubCount(UT_KEY(CFE_SB_SubscribeEx)); - UtAssert_INT32_EQ(call_count_CFE_SB_SubscribeEx, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_SubscribeEx, 0); } /* end DS_TableSubscribe_Test_SendHk*/ void DS_TableSubscribe_Test_Data(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_SubscribeEx = 0; - DS_AppData.FilterTblPtr = &FilterTable; - - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - FilterTable.Packet[0].MessageID = DS_UT_MID_1; /* NOT the CMD or SEND_HK MIDs */ + DS_AppData.FilterTblPtr->Packet[0].MessageID = DS_UT_MID_1; /* NOT the CMD or SEND_HK MIDs */ /* Execute the function being tested */ DS_TableSubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_SubscribeEx = UT_GetStubCount(UT_KEY(CFE_SB_SubscribeEx)); - UtAssert_INT32_EQ(call_count_CFE_SB_SubscribeEx, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_SubscribeEx, 1); } /* end DS_TableSubscribe_Test_Data */ void DS_TableUnsubscribe_Test_Unused(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_Unsubscribe = 0; - - DS_AppData.FilterTblPtr = &FilterTable; - - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - /* Execute the function being tested */ DS_TableUnsubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_Unsubscribe = UT_GetStubCount(UT_KEY(CFE_SB_Unsubscribe)); - UtAssert_INT32_EQ(call_count_CFE_SB_Unsubscribe, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_Unsubscribe, 0); } /* end DS_TableUnsubscribe_Test_Unused */ void DS_TableUnsubscribe_Test_Cmd(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_Unsubscribe = 0; - - DS_AppData.FilterTblPtr = &FilterTable; - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - - FilterTable.Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_CMD_MID); + DS_AppData.FilterTblPtr->Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_CMD_MID); /* Execute the function being tested */ DS_TableUnsubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_Unsubscribe = UT_GetStubCount(UT_KEY(CFE_SB_Unsubscribe)); - UtAssert_INT32_EQ(call_count_CFE_SB_Unsubscribe, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_Unsubscribe, 0); } /* end DS_TableUnsubscribe_Test_Cmd */ void DS_TableUnsubscribe_Test_SendHk(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_Unsubscribe = 0; - - DS_AppData.FilterTblPtr = &FilterTable; - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - - FilterTable.Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); + DS_AppData.FilterTblPtr->Packet[0].MessageID = CFE_SB_ValueToMsgId(DS_SEND_HK_MID); /* Execute the function being tested */ DS_TableUnsubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_Unsubscribe = UT_GetStubCount(UT_KEY(CFE_SB_Unsubscribe)); - UtAssert_INT32_EQ(call_count_CFE_SB_Unsubscribe, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_Unsubscribe, 0); } /* end DS_TableUnsubscribe_Test_SendHk */ void DS_TableUnsubscribe_Test_Data(void) { - DS_FilterTable_t FilterTable; - uint8 call_count_CFE_SB_Unsubscribe = 0; - - DS_AppData.FilterTblPtr = &FilterTable; - for (int i = 0; i < DS_PACKETS_IN_FILTER_TABLE; i++) - { - FilterTable.Packet[i].MessageID = CFE_SB_INVALID_MSG_ID; - } - - FilterTable.Packet[0].MessageID = DS_UT_MID_1; /* NOT the CMD or SEND_HK MIDs */ + DS_AppData.FilterTblPtr->Packet[0].MessageID = DS_UT_MID_1; /* NOT the CMD or SEND_HK MIDs */ /* Execute the function being tested */ DS_TableUnsubscribe(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - - call_count_CFE_SB_Unsubscribe = UT_GetStubCount(UT_KEY(CFE_SB_Unsubscribe)); - UtAssert_INT32_EQ(call_count_CFE_SB_Unsubscribe, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_SB_Unsubscribe, 1); } /* end DS_TableUnsubscribe_Test_Data */ void DS_TableCreateCDS_Test_NewCDSArea(void) { - int32 Result; - /* Execute the function being tested */ - Result = DS_TableCreateCDS(); + UtAssert_INT32_EQ(DS_TableCreateCDS(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableCreateCDS_Test_NewCDSArea */ void DS_TableCreateCDS_Test_PreExistingCDSArea(void) { - int32 Result; - /* Set to satisfy condition "if (Result == CFE_ES_CDS_ALREADY_EXISTS)", which is the main thing we're testing here */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); /* Execute the function being tested */ - Result = DS_TableCreateCDS(); + UtAssert_INT32_EQ(DS_TableCreateCDS(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); - - UtAssert_True(DS_AppData.FileStatus[0].FileCount == 0, "DS_AppData.FileStatus[0].FileCount == 0"); - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT/2].FileCount == 0"); - - UtAssert_True(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount == 0, - "DS_AppData.FileStatus[DS_DEST_FILE_CNT-1].FileCount == 0"); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[0].FileCount, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileCount, 0); + UtAssert_UINT32_EQ(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileCount, 0); #if (DS_CDS_ENABLE_STATE == 1) /* only test if configured */ - UtAssert_True(DS_AppData.AppEnableState == 0, "DS_AppData.AppEnableState == 0"); + UtAssert_UINT32_EQ(DS_AppData.AppEnableState, 0); #endif - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableCreateCDS_Test_PreExistingCDSArea */ void DS_TableCreateCDS_Test_RestoreFail(void) { - int32 Result; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Critical Data Store access error = 0x%%08X"); - /* Set to satisfy condition "if (Result == CFE_ES_CDS_ALREADY_EXISTS)", which is the main thing we're testing here */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), -1); /* Execute the function being tested */ - Result = DS_TableCreateCDS(); + UtAssert_INT32_EQ(DS_TableCreateCDS(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(DS_AppData.DataStoreHandle, CFE_ES_CDS_BAD_HANDLE), - "CFE_RESOURCEID_TEST_EQUAL(DS_AppData.DataStoreHandle, CFE_ES_CDS_BAD_HANDLE"); - - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); /* CFE_SUCCESS because error is not fatal */ - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_BOOL_TRUE(CFE_RESOURCEID_TEST_EQUAL(DS_AppData.DataStoreHandle, CFE_ES_CDS_BAD_HANDLE)); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_CDS_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableCreateCDS_Test_RestoreFail */ void DS_TableCreateCDS_Test_Error(void) { - int32 Result; - - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Critical Data Store access error = 0x%%08X"); - /* Set to generate error message DS_INIT_CDS_ERR_EID */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), -1); /* Execute the function being tested */ - Result = DS_TableCreateCDS(); + UtAssert_INT32_EQ(DS_TableCreateCDS(), CFE_SUCCESS); /* Verify results */ - UtAssert_True(CFE_RESOURCEID_TEST_EQUAL(DS_AppData.DataStoreHandle, CFE_ES_CDS_BAD_HANDLE), - "CFE_RESOURCEID_TEST_EQUAL(DS_AppData.DataStoreHandle, CFE_ES_CDS_BAD_HANDLE"); - - UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); /* CFE_SUCCESS because error is not fatal */ - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); + UtAssert_BOOL_TRUE(CFE_RESOURCEID_TEST_EQUAL(DS_AppData.DataStoreHandle, CFE_ES_CDS_BAD_HANDLE)); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_CDS_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableCreateCDS_Test_Error */ void DS_TableUpdateCDS_Test_Nominal(void) @@ -2224,17 +1522,12 @@ void DS_TableUpdateCDS_Test_Nominal(void) DS_TableUpdateCDS(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableUpdateCDS_Test_Nominal */ void DS_TableUpdateCDS_Test_Error(void) { - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Critical Data Store access error = 0x%%08X"); - DS_AppData.DataStoreHandle = DS_UT_CDSHANDLE_1; /* Set to generate error message DS_INIT_CDS_ERR_EID */ @@ -2244,17 +1537,10 @@ void DS_TableUpdateCDS_Test_Error(void) DS_TableUpdateCDS(); /* Verify results */ - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); - + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_CDS_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); - strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); - - UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); - } /* end DS_TableUpdateCDS_Test_Error */ void DS_TableHashFunction_Test(void) @@ -2264,21 +1550,16 @@ void DS_TableHashFunction_Test(void) /* Execute the function being tested */ UtAssert_UINT32_LT(DS_TableHashFunction(MessageID), DS_HASH_TABLE_ENTRIES); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableHashFunction_Test */ void DS_TableCreateHash_Test_Nominal(void) { - DS_FilterTable_t FilterTable; - uint32 HashIndex; + uint32 HashIndex; - memset(&FilterTable, 0, sizeof(FilterTable)); - FilterTable.Packet[0].MessageID = DS_UT_MID_1; - HashIndex = DS_TableHashFunction(FilterTable.Packet[0].MessageID); - - DS_AppData.FilterTblPtr = &FilterTable; + DS_AppData.FilterTblPtr->Packet[0].MessageID = DS_UT_MID_1; + HashIndex = DS_TableHashFunction(DS_AppData.FilterTblPtr->Packet[0].MessageID); /* Execute the function being tested */ DS_TableCreateHash(); @@ -2288,47 +1569,32 @@ void DS_TableCreateHash_Test_Nominal(void) UtAssert_BOOL_TRUE(CFE_SB_MsgId_Equal(DS_AppData.HashLinks[0].MessageID, DS_UT_MID_1)); UtAssert_ADDRESS_EQ(DS_AppData.HashTable[HashIndex], &DS_AppData.HashLinks[0]); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableCreateHash_Test_Nominal */ void DS_TableFindMsgID_Test(void) { - int32 Result; - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; - uint32 HashIndex; - - HashIndex = DS_TableHashFunction(MessageID); - - DS_AppData.FilterTblPtr = &FilterTable; - - DS_AppData.HashTable[HashIndex] = &HashLink; - - HashLink.Index = 1; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + DS_HashLink_t HashLink; + uint32 HashIndex; + HashIndex = DS_TableHashFunction(MessageID); + DS_AppData.HashTable[HashIndex] = &HashLink; + HashLink.Index = 1; DS_AppData.FilterTblPtr->Packet[HashLink.Index].MessageID = MessageID; /* Execute the function being tested */ - Result = DS_TableFindMsgID(MessageID); + UtAssert_INT32_EQ(DS_TableFindMsgID(MessageID), HashLink.Index); /* Verify results */ - UtAssert_True(Result == 1, "Result == 1"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableFindMsgID_Test */ void DS_TableFindMsgID_Test_NullTable(void) { - int32 Result; - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_FilterTable_t FilterTable; - - DS_AppData.FilterTblPtr = &FilterTable; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; for (int i = 0; i < DS_HASH_TABLE_ENTRIES; i++) { @@ -2336,28 +1602,20 @@ void DS_TableFindMsgID_Test_NullTable(void) } /* Execute the function being tested */ - Result = DS_TableFindMsgID(MessageID); + UtAssert_INT32_EQ(DS_TableFindMsgID(MessageID), DS_INDEX_NONE); /* Verify results */ - UtAssert_INT32_EQ(Result, DS_INDEX_NONE); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableFindMsgID_Test_NullTable */ void DS_TableFindMsgID_Test_Mismatch(void) { - int32 Result; - CFE_SB_MsgId_t MessageID = DS_UT_MID_1; - DS_HashLink_t HashLink; - DS_FilterTable_t FilterTable; - uint32 HashIndex; - - HashIndex = DS_TableHashFunction(MessageID); - - DS_AppData.FilterTblPtr = &FilterTable; + CFE_SB_MsgId_t MessageID = DS_UT_MID_1; + DS_HashLink_t HashLink; + uint32 HashIndex; + HashIndex = DS_TableHashFunction(MessageID); DS_AppData.HashTable[HashIndex] = &HashLink; HashLink.Index = 1; @@ -2366,169 +1624,118 @@ void DS_TableFindMsgID_Test_Mismatch(void) DS_AppData.FilterTblPtr->Packet[HashLink.Index].MessageID = DS_UT_MID_2; /* Execute the function being tested */ - Result = DS_TableFindMsgID(MessageID); + UtAssert_INT32_EQ(DS_TableFindMsgID(MessageID), DS_INDEX_NONE); /* Verify results */ - UtAssert_INT32_EQ(Result, DS_INDEX_NONE); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } /* end DS_TableFindMsgID_Test_Mismatch */ void UtTest_Setup(void) { - UtTest_Add(DS_TableInit_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableInit_Test_Nominal"); - UtTest_Add(DS_TableInit_Test_TableInfoRecovered, DS_Test_Setup, DS_Test_TearDown, - "DS_TableInit_Test_TableInfoRecovered"); - UtTest_Add(DS_TableInit_Test_RegisterDestTableError, DS_Test_Setup, DS_Test_TearDown, - "DS_TableInit_Test_RegisterDestTableError"); - UtTest_Add(DS_TableInit_Test_RegisterFilterTableError, DS_Test_Setup, DS_Test_TearDown, - "DS_TableInit_Test_RegisterFilterTableError"); - UtTest_Add(DS_TableInit_Test_LoadDestTableError, DS_Test_Setup, DS_Test_TearDown, - "DS_TableInit_Test_LoadDestTableError"); - UtTest_Add(DS_TableInit_Test_LoadFilterTableError, DS_Test_Setup, DS_Test_TearDown, - "DS_TableInit_Test_LoadFilterTableError"); - - UtTest_Add(DS_TableManageDestFile_Test_TableInfoUpdated, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageDestFile_Test_TableInfoUpdated"); - UtTest_Add(DS_TableManageDestFile_Test_TableNeverLoaded, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageDestFile_Test_TableNeverLoaded"); - UtTest_Add(DS_TableManageDestFile_Test_TableInfoDumpPending, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageDestFile_Test_TableInfoDumpPending"); - UtTest_Add(DS_TableManageDestFile_Test_TableInfoValidationPending, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageDestFile_Test_TableInfoValidationPending"); - UtTest_Add(DS_TableManageDestFile_Test_TableInfoUpdatePending, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageDestFile_Test_TableInfoUpdatePending"); - UtTest_Add(DS_TableManageDestFile_Test_TableSuccess, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageDestFile_Test_TableSuccess"); - - UtTest_Add(DS_TableManageFilter_Test_TableInfoUpdated, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageFilter_Test_TableInfoUpdated"); - UtTest_Add(DS_TableManageFilter_Test_TableNeverLoaded, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageFilter_Test_TableNeverLoaded"); - UtTest_Add(DS_TableManageFilter_Test_TableInfoDumpPending, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageFilter_Test_TableInfoDumpPending"); - UtTest_Add(DS_TableManageFilter_Test_TableInfoValidationPending, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageFilter_Test_TableInfoValidationPending"); - UtTest_Add(DS_TableManageFilter_Test_TableInfoUpdatePending, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageFilter_Test_TableInfoUpdatePending"); - UtTest_Add(DS_TableManageFilter_Test_TableSuccess, DS_Test_Setup, DS_Test_TearDown, - "DS_TableManageFilter_Test_TableSuccess"); - - UtTest_Add(DS_TableVerifyDestFile_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFile_Test_Nominal"); - UtTest_Add(DS_TableVerifyDestFile_Test_CountBad, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFile_Test_CountBad"); - - UtTest_Add(DS_TableVerifyDestFileEntry_Test_NominalErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_NominalErrZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero"); - - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrNonZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrNonZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidSizeErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidSizeErrNonZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidAgeErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidAgeErrNonZero"); - UtTest_Add(DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrNonZero"); - - UtTest_Add(DS_TableVerifyFilter_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyFilter_Test_Nominal"); - UtTest_Add(DS_TableVerifyFilter_Test_FilterTableVerificationError, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilter_Test_FilterTableVerificationError"); - UtTest_Add(DS_TableVerifyFilter_Test_CountBad, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilter_Test_CountBad"); - - UtTest_Add(DS_TableVerifyFilterEntry_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_Nominal"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_Unused, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_Unused"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrZero"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrZero"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrZero"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrNonZero"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrNonZero"); - UtTest_Add(DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrNonZero"); - - UtTest_Add(DS_TableEntryUnused_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableEntryUnused_Test_Nominal"); - UtTest_Add(DS_TableEntryUnused_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableEntryUnused_Test_Fail"); - - UtTest_Add(DS_TableVerifyFileIndex_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyFileIndex_Test_Nominal"); - UtTest_Add(DS_TableVerifyFileIndex_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyFileIndex_Test_Fail"); - - UtTest_Add(DS_TableVerifyParms_Test_NominalOnlyXNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyParms_Test_NominalOnlyXNonZero"); - UtTest_Add(DS_TableVerifyParms_Test_NGreaterThanXOnlyNNonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyParms_Test_NGreaterThanXOnlyNNonZero"); - UtTest_Add(DS_TableVerifyParms_Test_OGreaterThanXOnlyONonZero, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyParms_Test_OGreaterThanXOnlyONonZero"); - UtTest_Add(DS_TableVerifyParms_Test_AllZero, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyParms_Test_AllZero"); - - UtTest_Add(DS_TableVerifyType_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyType_Test_Nominal"); - UtTest_Add(DS_TableVerifyType_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyType_Test_Fail"); - - UtTest_Add(DS_TableVerifyState_Test_NominalEnabled, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyState_Test_NominalEnabled"); - UtTest_Add(DS_TableVerifyState_Test_NominalDisabled, DS_Test_Setup, DS_Test_TearDown, - "DS_TableVerifyState_Test_NominalDisabled"); - UtTest_Add(DS_TableVerifyState_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyState_Test_Fail"); - - UtTest_Add(DS_TableVerifySize_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifySize_Test_Nominal"); - UtTest_Add(DS_TableVerifySize_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifySize_Test_Fail"); - - UtTest_Add(DS_TableVerifyAge_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyAge_Test_Nominal"); - UtTest_Add(DS_TableVerifyAge_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyAge_Test_Fail"); - - UtTest_Add(DS_TableVerifyCount_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyCount_Test_Nominal"); - UtTest_Add(DS_TableVerifyCount_Test_Fail, DS_Test_Setup, DS_Test_TearDown, "DS_TableVerifyCount_Test_Fail"); - - UtTest_Add(DS_TableSubscribe_Test_Unused, DS_Test_Setup, DS_Test_TearDown, "DS_TableSubscribe_Test_Unused"); - UtTest_Add(DS_TableSubscribe_Test_Cmd, DS_Test_Setup, DS_Test_TearDown, "DS_TableSubscribe_Test_Cmd"); - UtTest_Add(DS_TableSubscribe_Test_SendHk, DS_Test_Setup, DS_Test_TearDown, "DS_TableSubscribe_Test_SendHk"); - UtTest_Add(DS_TableSubscribe_Test_Data, DS_Test_Setup, DS_Test_TearDown, "DS_TableSubscribe_Test_Data"); - - UtTest_Add(DS_TableUnsubscribe_Test_Unused, DS_Test_Setup, DS_Test_TearDown, "DS_TableUnsubscribe_Test_Unused"); - UtTest_Add(DS_TableUnsubscribe_Test_Cmd, DS_Test_Setup, DS_Test_TearDown, "DS_TableUnsubscribe_Test_Cmd"); - UtTest_Add(DS_TableUnsubscribe_Test_SendHk, DS_Test_Setup, DS_Test_TearDown, "DS_TableUnsubscribe_Test_SendHk"); - UtTest_Add(DS_TableUnsubscribe_Test_Data, DS_Test_Setup, DS_Test_TearDown, "DS_TableUnsubscribe_Test_Data"); - - UtTest_Add(DS_TableCreateCDS_Test_NewCDSArea, DS_Test_Setup, DS_Test_TearDown, "DS_TableCreateCDS_Test_NewCDSArea"); - UtTest_Add(DS_TableCreateCDS_Test_PreExistingCDSArea, DS_Test_Setup, DS_Test_TearDown, - "DS_TableCreateCDS_Test_PreExistingCDSArea"); - UtTest_Add(DS_TableCreateCDS_Test_RestoreFail, DS_Test_Setup, DS_Test_TearDown, - "DS_TableCreateCDS_Test_RestoreFail"); - UtTest_Add(DS_TableCreateCDS_Test_Error, DS_Test_Setup, DS_Test_TearDown, "DS_TableCreateCDS_Test_Error"); - - UtTest_Add(DS_TableUpdateCDS_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableUpdateCDS_Test_Nominal"); - UtTest_Add(DS_TableUpdateCDS_Test_Error, DS_Test_Setup, DS_Test_TearDown, "DS_TableUpdateCDS_Test_Error"); - - UtTest_Add(DS_TableHashFunction_Test, DS_Test_Setup, DS_Test_TearDown, "DS_TableHashFunction_Test"); - - UtTest_Add(DS_TableCreateHash_Test_Nominal, DS_Test_Setup, DS_Test_TearDown, "DS_TableCreateHash_Test_Nominal"); - - UtTest_Add(DS_TableFindMsgID_Test, DS_Test_Setup, DS_Test_TearDown, "DS_TableFindMsgID_Test"); - UtTest_Add(DS_TableFindMsgID_Test_NullTable, DS_Test_Setup, DS_Test_TearDown, "DS_TableFindMsgID_Test_NullTable"); - - UtTest_Add(DS_TableFindMsgID_Test_Mismatch, DS_Test_Setup, DS_Test_TearDown, "DS_TableFindMsgID_Test_Mismatch"); + UT_DS_TEST_ADD(DS_TableInit_Test_Nominal); + UT_DS_TEST_ADD(DS_TableInit_Test_TableInfoRecovered); + UT_DS_TEST_ADD(DS_TableInit_Test_RegisterDestTableError); + UT_DS_TEST_ADD(DS_TableInit_Test_RegisterFilterTableError); + UT_DS_TEST_ADD(DS_TableInit_Test_LoadDestTableError); + UT_DS_TEST_ADD(DS_TableInit_Test_LoadFilterTableError); + + UT_DS_TEST_ADD(DS_TableManageDestFile_Test_TableInfoUpdated); + UT_DS_TEST_ADD(DS_TableManageDestFile_Test_TableNeverLoaded); + UT_DS_TEST_ADD(DS_TableManageDestFile_Test_TableInfoDumpPending); + UT_DS_TEST_ADD(DS_TableManageDestFile_Test_TableInfoValidationPending); + UT_DS_TEST_ADD(DS_TableManageDestFile_Test_TableInfoUpdatePending); + UT_DS_TEST_ADD(DS_TableManageDestFile_Test_TableSuccess); + + UT_DS_TEST_ADD(DS_TableManageFilter_Test_TableInfoUpdated); + UT_DS_TEST_ADD(DS_TableManageFilter_Test_TableNeverLoaded); + UT_DS_TEST_ADD(DS_TableManageFilter_Test_TableInfoDumpPending); + UT_DS_TEST_ADD(DS_TableManageFilter_Test_TableInfoValidationPending); + UT_DS_TEST_ADD(DS_TableManageFilter_Test_TableInfoUpdatePending); + UT_DS_TEST_ADD(DS_TableManageFilter_Test_TableSuccess); + + UT_DS_TEST_ADD(DS_TableVerifyDestFile_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyDestFile_Test_CountBad); + + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_NominalErrZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidSizeErrZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidAgeErrZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrZero); + + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidFilenameTypeErrNonZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidFileEnableStateErrNonZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidSizeErrNonZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidAgeErrNonZero); + UT_DS_TEST_ADD(DS_TableVerifyDestFileEntry_Test_InvalidSequenceCountErrNonZero); + + UT_DS_TEST_ADD(DS_TableVerifyFilter_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyFilter_Test_FilterTableVerificationError); + UT_DS_TEST_ADD(DS_TableVerifyFilter_Test_CountBad); + + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_Unused); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrZero); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrZero); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrZero); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_InvalidFileTableIndexErrNonZero); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_InvalidFilterTypeErrNonZero); + UT_DS_TEST_ADD(DS_TableVerifyFilterEntry_Test_InvalidFilterParmsErrNonZero); + + UT_DS_TEST_ADD(DS_TableEntryUnused_Test_Nominal); + UT_DS_TEST_ADD(DS_TableEntryUnused_Test_Fail); + + UT_DS_TEST_ADD(DS_TableVerifyFileIndex_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyFileIndex_Test_Fail); + + UT_DS_TEST_ADD(DS_TableVerifyParms_Test_NominalOnlyXNonZero); + UT_DS_TEST_ADD(DS_TableVerifyParms_Test_NGreaterThanXOnlyNNonZero); + UT_DS_TEST_ADD(DS_TableVerifyParms_Test_OGreaterThanXOnlyONonZero); + UT_DS_TEST_ADD(DS_TableVerifyParms_Test_AllZero); + + UT_DS_TEST_ADD(DS_TableVerifyType_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyType_Test_Fail); + + UT_DS_TEST_ADD(DS_TableVerifyState_Test_NominalEnabled); + UT_DS_TEST_ADD(DS_TableVerifyState_Test_NominalDisabled); + UT_DS_TEST_ADD(DS_TableVerifyState_Test_Fail); + + UT_DS_TEST_ADD(DS_TableVerifySize_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifySize_Test_Fail); + + UT_DS_TEST_ADD(DS_TableVerifyAge_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyAge_Test_Fail); + + UT_DS_TEST_ADD(DS_TableVerifyCount_Test_Nominal); + UT_DS_TEST_ADD(DS_TableVerifyCount_Test_Fail); + + UT_DS_TEST_ADD(DS_TableSubscribe_Test_Unused); + UT_DS_TEST_ADD(DS_TableSubscribe_Test_Cmd); + UT_DS_TEST_ADD(DS_TableSubscribe_Test_SendHk); + UT_DS_TEST_ADD(DS_TableSubscribe_Test_Data); + + UT_DS_TEST_ADD(DS_TableUnsubscribe_Test_Unused); + UT_DS_TEST_ADD(DS_TableUnsubscribe_Test_Cmd); + UT_DS_TEST_ADD(DS_TableUnsubscribe_Test_SendHk); + UT_DS_TEST_ADD(DS_TableUnsubscribe_Test_Data); + + UT_DS_TEST_ADD(DS_TableCreateCDS_Test_NewCDSArea); + UT_DS_TEST_ADD(DS_TableCreateCDS_Test_PreExistingCDSArea); + UT_DS_TEST_ADD(DS_TableCreateCDS_Test_RestoreFail); + UT_DS_TEST_ADD(DS_TableCreateCDS_Test_Error); + + UT_DS_TEST_ADD(DS_TableUpdateCDS_Test_Nominal); + UT_DS_TEST_ADD(DS_TableUpdateCDS_Test_Error); + + UT_DS_TEST_ADD(DS_TableHashFunction_Test); + + UT_DS_TEST_ADD(DS_TableCreateHash_Test_Nominal); + + UT_DS_TEST_ADD(DS_TableFindMsgID_Test); + UT_DS_TEST_ADD(DS_TableFindMsgID_Test_NullTable); + + UT_DS_TEST_ADD(DS_TableFindMsgID_Test_Mismatch); } /* end DS_Table_Test_AddTestCases */ /************************/ diff --git a/unit-test/utilities/ds_test_utils.c b/unit-test/utilities/ds_test_utils.c index c835b79..a21650b 100644 --- a/unit-test/utilities/ds_test_utils.c +++ b/unit-test/utilities/ds_test_utils.c @@ -76,6 +76,9 @@ void UT_Handler_CFE_ES_WriteToSysLog(void *UserObj, UT_EntryKey_t FuncKey, const void DS_Test_Setup(void) { + static DS_FilterTable_t FilterTable; + static DS_DestFileTable_t DestFileTable; + /* initialize test environment to default state for every test */ UT_ResetState(0); @@ -83,6 +86,12 @@ void DS_Test_Setup(void) memset(context_CFE_EVS_SendEvent, 0, sizeof(context_CFE_EVS_SendEvent)); memset(&context_CFE_ES_WriteToSysLog, 0, sizeof(context_CFE_ES_WriteToSysLog)); memset(&UT_CmdBuf, 0, sizeof(UT_CmdBuf)); + memset(&FilterTable, 0, sizeof(FilterTable)); + memset(&DestFileTable, 0, sizeof(DestFileTable)); + + /* Set up the default table pointers */ + DS_AppData.FilterTblPtr = &FilterTable; + DS_AppData.DestFileTblPtr = &DestFileTable; /* Register custom handlers */ UT_SetVaHandlerFunction(UT_KEY(CFE_EVS_SendEvent), UT_Handler_CFE_EVS_SendEvent, NULL); diff --git a/unit-test/utilities/ds_test_utils.h b/unit-test/utilities/ds_test_utils.h index 9129d10..1dce701 100644 --- a/unit-test/utilities/ds_test_utils.h +++ b/unit-test/utilities/ds_test_utils.h @@ -77,7 +77,7 @@ extern UT_CmdBuf_t UT_CmdBuf; /* * Macro to add a test case to the list of tests to execute */ -#define ADD_TEST(test) UtTest_Add((Test_##test), DS_UT_Setup, DS_UT_TearDown, #test) +#define UT_DS_TEST_ADD(test) UtTest_Add(test, DS_Test_Setup, DS_Test_TearDown, #test) /* Unit test MID */ #define DS_UT_MID_1 CFE_SB_ValueToMsgId(CFE_PLATFORM_TLM_MID_BASE + 1)