From 6d2b81fca0efd40466b735062029daae25820416 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 11 May 2022 14:13:09 -0600 Subject: [PATCH] Fix #9, Resolve UT static analysis issues --- unit-test/cs_app_tests.c | 88 +++++++++++++ unit-test/cs_cmds_tests.c | 2 + unit-test/cs_compute_tests.c | 197 +++++++++++++++++----------- unit-test/cs_utils_tests.c | 2 +- unit-test/utilities/cs_test_utils.c | 2 +- 5 files changed, 212 insertions(+), 79 deletions(-) diff --git a/unit-test/cs_app_tests.c b/unit-test/cs_app_tests.c index 5a79a2f..f09ee06 100644 --- a/unit-test/cs_app_tests.c +++ b/unit-test/cs_app_tests.c @@ -945,6 +945,8 @@ void CS_AppPipe_Test_TableUpdateErrors(void) CFE_SB_MsgId_t TestMsgId; size_t MsgSize; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_SEND_HK_MID); @@ -973,6 +975,8 @@ void CS_AppPipe_Test_BackgroundCycle(void) CFE_SB_MsgId_t TestMsgId; size_t MsgSize; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_BACKGROUND_CYCLE_MID); @@ -1000,6 +1004,8 @@ void CS_AppPipe_Test_NoopCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1028,6 +1034,8 @@ void CS_AppPipe_Test_ResetCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1056,6 +1064,8 @@ void CS_AppPipe_Test_OneShotCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1084,6 +1094,8 @@ void CS_AppPipe_Test_CancelOneShotCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1112,6 +1124,8 @@ void CS_AppPipe_Test_EnableAllCSCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1140,6 +1154,8 @@ void CS_AppPipe_Test_DisableAllCSCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1168,6 +1184,8 @@ void CS_AppPipe_Test_EnableCfeCoreCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1196,6 +1214,8 @@ void CS_AppPipe_Test_DisableCfeCoreCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1224,6 +1244,8 @@ void CS_AppPipe_Test_ReportBaselineCfeCoreCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1252,6 +1274,8 @@ void CS_AppPipe_Test_RecomputeBaselineCfeCoreCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1280,6 +1304,8 @@ void CS_AppPipe_Test_EnableOSCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1308,6 +1334,8 @@ void CS_AppPipe_Test_DisableOSCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1336,6 +1364,8 @@ void CS_AppPipe_Test_ReportBaselineOSCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1364,6 +1394,8 @@ void CS_AppPipe_Test_RecomputeBaselineOSCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1392,6 +1424,8 @@ void CS_AppPipe_Test_EnableEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1420,6 +1454,8 @@ void CS_AppPipe_Test_DisableEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1448,6 +1484,8 @@ void CS_AppPipe_Test_ReportBaselineEntryIDEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1476,6 +1514,8 @@ void CS_AppPipe_Test_RecomputeBaselineEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1504,6 +1544,8 @@ void CS_AppPipe_Test_EnableEntryIDEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1532,6 +1574,8 @@ void CS_AppPipe_Test_DisableEntryIDEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1560,6 +1604,8 @@ void CS_AppPipe_Test_GetEntryIDEepromCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1588,6 +1634,8 @@ void CS_AppPipe_Test_EnableMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1616,6 +1664,8 @@ void CS_AppPipe_Test_DisableMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1644,6 +1694,8 @@ void CS_AppPipe_Test_ReportBaselineEntryIDMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1672,6 +1724,8 @@ void CS_AppPipe_Test_RecomputeBaselineMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1700,6 +1754,8 @@ void CS_AppPipe_Test_EnableEntryIDMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1728,6 +1784,8 @@ void CS_AppPipe_Test_DisableEntryIDMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1756,6 +1814,8 @@ void CS_AppPipe_Test_GetEntryIDMemoryCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1784,6 +1844,8 @@ void CS_AppPipe_Test_EnableTablesCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1812,6 +1874,8 @@ void CS_AppPipe_Test_DisableTablesCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1840,6 +1904,8 @@ void CS_AppPipe_Test_ReportBaselineTablesCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1868,6 +1934,8 @@ void CS_AppPipe_Test_RecomputeBaselineTablesCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1896,6 +1964,8 @@ void CS_AppPipe_Test_EnableNameTablesCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1924,6 +1994,8 @@ void CS_AppPipe_Test_DisableNameTablesCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1952,6 +2024,8 @@ void CS_AppPipe_Test_EnableAppCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -1980,6 +2054,8 @@ void CS_AppPipe_Test_DisableAppCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -2008,6 +2084,8 @@ void CS_AppPipe_Test_ReportBaselineAppCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -2036,6 +2114,8 @@ void CS_AppPipe_Test_RecomputeBaselineAppCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -2064,6 +2144,8 @@ void CS_AppPipe_Test_EnableNameAppCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -2092,6 +2174,8 @@ void CS_AppPipe_Test_DisableNameAppCmd(void) CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + CS_AppData.ChildTaskTable = -1; TestMsgId = CFE_SB_ValueToMsgId(CS_CMD_MID); @@ -2122,6 +2206,8 @@ void CS_AppPipe_Test_InvalidCCError(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Invalid ground command code: ID = 0x%%08lX, CC = %%d"); @@ -2161,6 +2247,8 @@ void CS_AppPipe_Test_InvalidMIDError(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&CmdBuf, 0, sizeof(CmdBuf)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Invalid command pipe message ID: 0x%%08lX"); CS_AppData.ChildTaskTable = -1; diff --git a/unit-test/cs_cmds_tests.c b/unit-test/cs_cmds_tests.c index a2d0c10..0acd968 100644 --- a/unit-test/cs_cmds_tests.c +++ b/unit-test/cs_cmds_tests.c @@ -172,6 +172,8 @@ void CS_BackgroundCheckCycle_Test_InvalidMsgLength(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&CmdPacket, 0, sizeof(CmdPacket)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Invalid msg length: ID = 0x%%08lX, CC = %%d, Len = %%lu, Expected = %%lu"); diff --git a/unit-test/cs_compute_tests.c b/unit-test/cs_compute_tests.c index a1425c7..4d975f8 100644 --- a/unit-test/cs_compute_tests.c +++ b/unit-test/cs_compute_tests.c @@ -89,10 +89,11 @@ void CS_ComputeEepromMemory_Test_Nominal(void) { int32 Result; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); - ResultsEntry.ByteOffset = 0; ResultsEntry.NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -122,10 +123,11 @@ void CS_ComputeEepromMemory_Test_Error(void) { int32 Result; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); - ResultsEntry.ByteOffset = 0; ResultsEntry.NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -155,10 +157,11 @@ void CS_ComputeEepromMemory_Test_FirstTimeThrough(void) { int32 Result; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); - ResultsEntry.ByteOffset = 0; ResultsEntry.NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -192,10 +195,11 @@ void CS_ComputeEepromMemory_Test_NotFinished(void) { int32 Result; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); - ResultsEntry.ByteOffset = 0; ResultsEntry.NumBytesToChecksum = 2; CS_AppData.MaxBytesPerCycle = 1; @@ -224,11 +228,13 @@ void CS_ComputeTables_Test_TableNeverLoaded(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Tables: Problem Getting table %%s info Share: 0x%%08X, GetInfo: 0x%%08X, GetAddress: 0x%%08X"); @@ -265,11 +271,13 @@ void CS_ComputeTables_Test_TableUnregisteredAndNeverLoaded(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Tables: Problem Getting table %%s info Share: 0x%%08X, GetInfo: 0x%%08X, GetAddress: 0x%%08X"); @@ -316,11 +324,13 @@ void CS_ComputeTables_Test_ResultShareNotSuccess(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Tables: Problem Getting table %%s info Share: 0x%%08X, GetInfo: 0x%%08X, GetAddress: 0x%%08X"); @@ -367,13 +377,14 @@ void CS_ComputeTables_Test_TblInfoUpdated(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; CFE_TBL_Info_t TblInfo; - ResultsEntry.TblHandle = 99; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); - ResultsEntry.ByteOffset = 0; + ResultsEntry.TblHandle = 99; CS_AppData.MaxBytesPerCycle = 5; /* Sets TblInfo.Size = 5 and returns CFE_TBL_INFO_UPDATED */ @@ -413,15 +424,16 @@ void CS_ComputeTables_Test_GetInfoResult(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; CFE_TBL_Info_t TblInfo; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + ResultsEntry.TblHandle = 99; - ResultsEntry.ByteOffset = 0; - ResultsEntry.NumBytesToChecksum = 0; - CS_AppData.MaxBytesPerCycle = 5; + CS_AppData.MaxBytesPerCycle = 5; /* Sets TblInfo.Size = 5 and returns CFE_TBL_INFO_UPDATED */ TblInfo.Size = 5; @@ -460,13 +472,15 @@ void CS_ComputeTables_Test_CSError(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; CFE_TBL_Info_t TblInfo; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + ResultsEntry.TblHandle = 99; - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 5; ResultsEntry.ComputedYet = true; @@ -510,13 +524,15 @@ void CS_ComputeTables_Test_NominalBadTableHandle(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; CFE_TBL_Info_t TblInfo; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + ResultsEntry.TblHandle = CFE_TBL_BAD_TABLE_HANDLE; - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 5; ResultsEntry.ComputedYet = true; @@ -565,13 +581,15 @@ void CS_ComputeTables_Test_FirstTimeThrough(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; CFE_TBL_Info_t TblInfo; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + ResultsEntry.TblHandle = CFE_TBL_BAD_TABLE_HANDLE; - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 5; ResultsEntry.ComputedYet = false; @@ -624,13 +642,15 @@ void CS_ComputeTables_Test_EntryNotFinished(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; CFE_TBL_Info_t TblInfo; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + ResultsEntry.TblHandle = CFE_TBL_BAD_TABLE_HANDLE; - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 3; ResultsEntry.ComputedYet = false; @@ -680,18 +700,20 @@ void CS_ComputeTables_Test_ComputeTablesReleaseError(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; CFE_TBL_Info_t TblInfo; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Tables: Could not release addresss for table %%s, returned: 0x%%08X"); ResultsEntry.TblHandle = CFE_TBL_BAD_TABLE_HANDLE; - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 3; ResultsEntry.ComputedYet = false; @@ -753,12 +775,15 @@ void CS_ComputeTables_Test_ComputeTablesError(void) { int32 Result; CS_Res_Tables_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; CFE_TBL_Info_t TblInfo; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Tables: Problem Getting table %%s info Share: 0x%%08X, GetInfo: 0x%%08X, GetAddress: 0x%%08X"); @@ -803,10 +828,11 @@ void CS_ComputeApp_Test_Nominal(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 5; ResultsEntry.ComputedYet = true; @@ -846,11 +872,13 @@ void CS_ComputeApp_Test_GetAppIDByNameError(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Apps: Problems getting app %%s info, GetAppID: 0x%%08X, GetAppInfo: 0x%%08X, AddressValid: %%d"); @@ -885,11 +913,13 @@ void CS_ComputeApp_Test_GetAppInfoError(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS Apps: Problems getting app %%s info, GetAppID: 0x%%08X, GetAppInfo: 0x%%08X, AddressValid: %%d"); @@ -924,11 +954,13 @@ void CS_ComputeApp_Test_ComputeAppPlatformError(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; int32 strCmpResult; char ExpectedEventString[2][CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + snprintf(ExpectedEventString[0], CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "CS cannot get a valid address for %%s, due to the platform"); @@ -975,9 +1007,11 @@ void CS_ComputeApp_Test_DifferFromSavedValue(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; - ResultsEntry.ByteOffset = 0; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + CS_AppData.MaxBytesPerCycle = 5; ResultsEntry.ComputedYet = true; @@ -1013,10 +1047,11 @@ void CS_ComputeApp_Test_FirstTimeThrough(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = false; + + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); - ResultsEntry.ByteOffset = 0; CS_AppData.MaxBytesPerCycle = 5; ResultsEntry.ComputedYet = false; @@ -1059,11 +1094,13 @@ void CS_ComputeApp_Test_EntryNotFinished(void) { int32 Result; CS_Res_App_Table_Entry_t ResultsEntry; - uint32 ComputedCSValue; - bool DoneWithEntry; + uint32 ComputedCSValue = 0; + bool DoneWithEntry = true; CFE_TBL_Info_t TblInfo; - ResultsEntry.ByteOffset = 0; + memset(&ResultsEntry, 0, sizeof(ResultsEntry)); + memset(&TblInfo, 0, sizeof(TblInfo)); + CS_AppData.MaxBytesPerCycle = 3; ResultsEntry.ComputedYet = true; @@ -1111,6 +1148,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTable(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefEepromTbl, 0, sizeof(DefEepromTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1127,7 +1167,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTable(void) DefEepromTbl[1].State = 1; - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1174,6 +1213,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_MemoryTable(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefMemoryTbl, 0, sizeof(DefMemoryTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1190,7 +1232,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_MemoryTable(void) DefMemoryTbl[1].State = 1; - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1237,6 +1278,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_CFECore(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefMemoryTbl, 0, sizeof(DefMemoryTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1253,7 +1297,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_CFECore(void) DefMemoryTbl[1].State = 1; - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1302,6 +1345,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_OSCore(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefMemoryTbl, 0, sizeof(DefMemoryTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1318,7 +1364,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_OSCore(void) DefMemoryTbl[1].State = 1; - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1367,6 +1412,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableEntryId(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefEepromTbl, 0, sizeof(DefEepromTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1383,9 +1431,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableEntryId(void) DefEepromTbl[1].State = 1; - CS_AppData.DefEepromTblPtr[CS_AppData.ChildTaskEntryID].State = 0; - - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1408,8 +1453,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableEntryId(void) "CS_AppData.RecomputeEepromMemoryEntryPtr->ComputedYet == true"); UtAssert_True(CS_AppData.RecomputeEepromMemoryEntryPtr->State == 99, "CS_AppData.RecomputeEepromMemoryEntryPtr->State == 99"); - UtAssert_True(CS_AppData.DefEepromTblPtr[CS_AppData.ChildTaskEntryID].State == 0, - "CS_AppData.DefEepromTblPtr[CS_AppData.ChildTaskEntryID].State == 0"); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, CS_RECOMPUTE_FINISH_EEPROM_MEMORY_INF_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION); @@ -1432,6 +1475,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableStartAddress(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefEepromTbl, 0, sizeof(DefEepromTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1448,7 +1494,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableStartAddress(void) DefEepromTbl[1].State = 1; - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1495,6 +1540,9 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableState(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + memset(&RecomputeEepromMemoryEntry, 0, sizeof(RecomputeEepromMemoryEntry)); + memset(DefEepromTbl, 0, sizeof(DefEepromTbl)); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "%%s entry %%d recompute finished. New baseline is 0X%%08X"); @@ -1511,7 +1559,6 @@ void CS_RecomputeEepromMemoryChildTask_Test_EEPROMTableState(void) DefEepromTbl[1].State = CS_STATE_EMPTY; - CS_AppData.RecomputeEepromMemoryEntryPtr->ByteOffset = 0; CS_AppData.RecomputeEepromMemoryEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1573,7 +1620,6 @@ void CS_RecomputeAppChildTask_Test_Nominal(void) DefAppTbl[1].State = 1; - CS_AppData.RecomputeAppEntryPtr->ByteOffset = 0; CS_AppData.RecomputeAppEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1702,7 +1748,6 @@ void CS_RecomputeAppChildTask_Test_DefEntryId(void) CS_AppData.ChildTaskEntryID = 1; - CS_AppData.RecomputeAppEntryPtr->ByteOffset = 0; CS_AppData.RecomputeAppEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1768,7 +1813,6 @@ void CS_RecomputeTablesChildTask_Test_Nominal(void) DefTablesTbl[1].State = 1; - CS_AppData.RecomputeTablesEntryPtr->ByteOffset = 0; CS_AppData.RecomputeTablesEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; @@ -1915,7 +1959,6 @@ void CS_RecomputeTablesChildTask_Test_DefEntryId(void) CS_AppData.ChildTaskEntryID = 1; - CS_AppData.RecomputeTablesEntryPtr->ByteOffset = 0; CS_AppData.RecomputeTablesEntryPtr->NumBytesToChecksum = 1; CS_AppData.MaxBytesPerCycle = 2; diff --git a/unit-test/cs_utils_tests.c b/unit-test/cs_utils_tests.c index 06e16db..73ed50f 100644 --- a/unit-test/cs_utils_tests.c +++ b/unit-test/cs_utils_tests.c @@ -657,7 +657,7 @@ void CS_AttemptTableReshare_Test(void) CFE_TBL_Handle_t LocalTblHandle = CFE_TBL_BAD_TABLE_HANDLE; CFE_TBL_Info_t TblInfo; cpuaddr LocalAddress; - int32 ResultGetInfo; + int32 ResultGetInfo = -1; memset(&TblEntry, 0, sizeof(TblEntry)); diff --git a/unit-test/utilities/cs_test_utils.c b/unit-test/utilities/cs_test_utils.c index ccb53a6..e8dc5b8 100644 --- a/unit-test/utilities/cs_test_utils.c +++ b/unit-test/utilities/cs_test_utils.c @@ -69,7 +69,7 @@ void UT_Handler_CFE_EVS_SendEvent(void *UserObj, UT_EntryKey_t FuncKey, const UT void UT_Handler_CFE_ES_WriteToSysLog(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, va_list va) { strncpy(context_CFE_ES_WriteToSysLog.Spec, UT_Hook_GetArgValueByName(Context, "SpecStringPtr", const char *), - CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); + CFE_MISSION_EVS_MAX_MESSAGE_LENGTH - 1); context_CFE_ES_WriteToSysLog.Spec[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH - 1] = '\0'; }