From 6049cf37833c1fb45e9c774abd3d560daf565291 Mon Sep 17 00:00:00 2001 From: Avi Date: Mon, 14 Nov 2022 09:57:49 +1000 Subject: [PATCH] Fix #49, Move variables declared mid-function to the top --- unit-test/lc_action_tests.c | 3 +- unit-test/lc_app_tests.c | 15 ++-- unit-test/lc_cmds_tests.c | 165 +++++++++++++++--------------------- unit-test/lc_utils_tests.c | 21 +++-- unit-test/lc_watch_tests.c | 61 ++++++------- 5 files changed, 115 insertions(+), 150 deletions(-) diff --git a/unit-test/lc_action_tests.c b/unit-test/lc_action_tests.c index 8c49fba..0e9c1e4 100644 --- a/unit-test/lc_action_tests.c +++ b/unit-test/lc_action_tests.c @@ -1685,12 +1685,13 @@ void LC_ValidateRPN_Test_StackDepthZero2(void) void LC_ValidateRPN_Test_MaxRPNSize(void) { + int i; uint8 Result; int32 IndexValue = 0; int32 StackDepthValue = 0; - for (int i = 0; i < LC_MAX_RPN_EQU_SIZE; i++) + for (i = 0; i < LC_MAX_RPN_EQU_SIZE; i++) { LC_OperData.ADTPtr[0].RPNEquation[i] = LC_MAX_WATCHPOINTS - 1; } diff --git a/unit-test/lc_app_tests.c b/unit-test/lc_app_tests.c index 9083a34..f728766 100644 --- a/unit-test/lc_app_tests.c +++ b/unit-test/lc_app_tests.c @@ -1343,12 +1343,11 @@ void LC_CreateTaskCDS_Test_Nominal(void) void LC_CreateTaskCDS_Test_WRTRegisterCDSError(void) { int32 Result; - - UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDS), 1, -1); - int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDS), 1, -1); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error registering WRT CDS Area, RC=0x%%08X"); Result = LC_CreateTaskCDS(); @@ -1367,12 +1366,11 @@ void LC_CreateTaskCDS_Test_WRTRegisterCDSError(void) void LC_CreateTaskCDS_Test_ARTRegisterCDSError(void) { int32 Result; - - UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDS), 2, -1); - int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDS), 2, -1); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error registering ART CDS Area, RC=0x%%08X"); Result = LC_CreateTaskCDS(); @@ -1391,12 +1389,11 @@ void LC_CreateTaskCDS_Test_ARTRegisterCDSError(void) void LC_CreateTaskCDS_Test_AppDataRegisterCDSError(void) { int32 Result; - - UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDS), 3, -1); - int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterCDS), 3, -1); + snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error registering application data CDS Area, RC=0x%%08X"); diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index 071f97e..eebf4ad 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -131,6 +131,8 @@ void LC_SampleAPReq_Test_ArrayIndexOutOfRange(void) { CFE_SB_MsgId_t TestMsgId; LC_SampleAP_Payload_t *PayloadPtr = &UT_CmdBuf.SampleAPCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -139,9 +141,6 @@ void LC_SampleAPReq_Test_ArrayIndexOutOfRange(void) PayloadPtr->StartIndex = 2; PayloadPtr->EndIndex = 1; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Sample AP error: invalid AP number, start = %%d, end = %%d"); @@ -163,13 +162,12 @@ void LC_SampleAPReq_Test_BadSampleAllArgs(void) { CFE_SB_MsgId_t TestMsgId; LC_SampleAP_Payload_t *PayloadPtr = &UT_CmdBuf.SampleAPCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Sample AP error: invalid AP number, start = %%d, end = %%d"); @@ -196,13 +194,12 @@ void LC_SampleAPReq_Test_ArrayEndIndexTooHigh(void) { CFE_SB_MsgId_t TestMsgId; LC_SampleAP_Payload_t *PayloadPtr = &UT_CmdBuf.SampleAPCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_SAMPLE_AP_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Sample AP error: invalid AP number, start = %%d, end = %%d"); @@ -876,13 +873,12 @@ void LC_SetLCStateCmd_Test_Active(void) { CFE_SB_MsgId_t TestMsgId; LC_SetLCState_Payload_t *PayloadPtr = &UT_CmdBuf.SetLCStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set LC state command: new state = %%d"); PayloadPtr->NewLCState = LC_STATE_ACTIVE; @@ -908,13 +904,12 @@ void LC_SetLCStateCmd_Test_Passive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetLCState_Payload_t *PayloadPtr = &UT_CmdBuf.SetLCStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set LC state command: new state = %%d"); PayloadPtr->NewLCState = LC_STATE_PASSIVE; @@ -940,13 +935,12 @@ void LC_SetLCStateCmd_Test_Disabled(void) { CFE_SB_MsgId_t TestMsgId; LC_SetLCState_Payload_t *PayloadPtr = &UT_CmdBuf.SetLCStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set LC state command: new state = %%d"); PayloadPtr->NewLCState = LC_STATE_DISABLED; @@ -972,13 +966,12 @@ void LC_SetLCStateCmd_Test_Default(void) { CFE_SB_MsgId_t TestMsgId; LC_SetLCState_Payload_t *PayloadPtr = &UT_CmdBuf.SetLCStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set LC state error: invalid state = %%d"); PayloadPtr->NewLCState = 99; @@ -1003,13 +996,12 @@ void LC_SetAPStateCmd_Test_Default(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: AP = %%d, Invalid new state = %%d"); @@ -1037,13 +1029,12 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsActive(void) uint16 TableIndex; CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1090,13 +1081,12 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsActiveOneNotUsed(void) uint16 TableIndex; CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1144,13 +1134,12 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsActiveOnePermOff(void) uint16 TableIndex; CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1198,13 +1187,12 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsPassive(void) uint16 TableIndex; CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1251,13 +1239,12 @@ void LC_SetAPStateCmd_Test_SetAllActionPointsDisabled(void) uint16 TableIndex; CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1303,13 +1290,12 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointActive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1339,13 +1325,12 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointNotUsed(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: AP = %%d, Invalid current AP state = %%d"); @@ -1375,13 +1360,12 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointPassive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1411,13 +1395,12 @@ void LC_SetAPStateCmd_Test_UpdateSingleActionPointDisabled(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state command: AP = %%d, New state = %%d"); @@ -1447,13 +1430,12 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStateActive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: AP = %%d, Invalid current AP state = %%d"); @@ -1482,13 +1464,12 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStatePassive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: AP = %%d, Invalid current AP state = %%d"); @@ -1517,13 +1498,12 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStateDisabled(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: AP = %%d, Invalid current AP state = %%d"); @@ -1553,13 +1533,12 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberActive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: Invalid AP number = %%d"); PayloadPtr->NewAPState = LC_APSTATE_ACTIVE; @@ -1587,13 +1566,12 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberPassive(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: Invalid AP number = %%d"); PayloadPtr->NewAPState = LC_APSTATE_PASSIVE; @@ -1620,13 +1598,12 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberDisabled(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPState_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPStateCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP state error: Invalid AP number = %%d"); PayloadPtr->NewAPState = LC_APSTATE_DISABLED; @@ -1652,13 +1629,12 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberMaxActionpoints(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP perm off error: Invalid AP number = %%d"); PayloadPtr->APNumber = LC_MAX_ACTIONPOINTS; @@ -1682,13 +1658,12 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberAllActionpoints(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP perm off error: Invalid AP number = %%d"); PayloadPtr->APNumber = LC_ALL_ACTIONPOINTS; @@ -1712,13 +1687,12 @@ void LC_SetAPPermOffCmd_Test_APNotDisabled(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP perm off error, AP NOT Disabled: AP = %%d, Current state = %%d"); @@ -1745,13 +1719,12 @@ void LC_SetAPPermOffCmd_Test_Nominal(void) { CFE_SB_MsgId_t TestMsgId; LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Set AP permanently off command: AP = %%d"); PayloadPtr->APNumber = 1; @@ -1779,13 +1752,12 @@ void LC_ResetAPStatsCmd_Test_AllActionPoints(void) { CFE_SB_MsgId_t TestMsgId; LC_ResetAPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset AP stats command: AP = %%d"); PayloadPtr->APNumber = LC_ALL_ACTIONPOINTS; @@ -1809,13 +1781,12 @@ void LC_ResetAPStatsCmd_Test_SingleActionPoint(void) { CFE_SB_MsgId_t TestMsgId; LC_ResetAPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset AP stats command: AP = %%d"); PayloadPtr->APNumber = LC_MAX_ACTIONPOINTS - 1; @@ -1839,13 +1810,12 @@ void LC_ResetAPStatsCmd_Test_InvalidAPNumber(void) { CFE_SB_MsgId_t TestMsgId; LC_ResetAPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset AP stats error: invalid AP number = %%d"); PayloadPtr->APNumber = LC_MAX_ACTIONPOINTS; @@ -1970,13 +1940,12 @@ void LC_ResetWPStatsCmd_Test_AllWatchPoints(void) { CFE_SB_MsgId_t TestMsgId; LC_ResetWPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetWPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset WP stats command: WP = %%d"); PayloadPtr->WPNumber = LC_ALL_WATCHPOINTS; @@ -2000,13 +1969,12 @@ void LC_ResetWPStatsCmd_Test_SingleWatchPoint(void) { CFE_SB_MsgId_t TestMsgId; LC_ResetWPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetWPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset WP stats command: WP = %%d"); PayloadPtr->WPNumber = LC_MAX_WATCHPOINTS - 1; @@ -2029,13 +1997,12 @@ void LC_ResetWPStatsCmd_Test_InvalidWPNumber(void) { CFE_SB_MsgId_t TestMsgId; LC_ResetWPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetWPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Reset WP stats error: invalid WP number = %%d"); PayloadPtr->WPNumber = LC_MAX_WATCHPOINTS; diff --git a/unit-test/lc_utils_tests.c b/unit-test/lc_utils_tests.c index e3a4df3..1303f4b 100644 --- a/unit-test/lc_utils_tests.c +++ b/unit-test/lc_utils_tests.c @@ -40,6 +40,8 @@ uint8 call_count_CFE_EVS_SendEvent; void LC_ManageTables_Test_Nominal(void) { int32 Result; + uint8 call_count_LC_ResetResultsWP; + uint8 call_count_LC_ResetResultsAP; UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); @@ -52,8 +54,8 @@ void LC_ManageTables_Test_Nominal(void) call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - uint8 call_count_LC_ResetResultsWP = UT_GetStubCount(UT_KEY(LC_ResetResultsWP)); - uint8 call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); + call_count_LC_ResetResultsWP = UT_GetStubCount(UT_KEY(LC_ResetResultsWP)); + call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); UtAssert_INT32_EQ(call_count_LC_ResetResultsWP, 0); UtAssert_INT32_EQ(call_count_LC_ResetResultsAP, 0); @@ -62,6 +64,8 @@ void LC_ManageTables_Test_Nominal(void) void LC_ManageTables_Test_InfoUpdated(void) { int32 Result; + uint8 call_count_LC_ResetResultsWP; + uint8 call_count_LC_ResetResultsAP; /* Set to satisfy all instances of condition "Result == CFE_TBL_INFO_UPDATED" */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); @@ -75,8 +79,8 @@ void LC_ManageTables_Test_InfoUpdated(void) call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); - uint8 call_count_LC_ResetResultsWP = UT_GetStubCount(UT_KEY(LC_ResetResultsWP)); - uint8 call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); + call_count_LC_ResetResultsWP = UT_GetStubCount(UT_KEY(LC_ResetResultsWP)); + call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); UtAssert_INT32_EQ(call_count_LC_ResetResultsWP, 1); UtAssert_INT32_EQ(call_count_LC_ResetResultsAP, 1); @@ -87,6 +91,8 @@ void LC_ManageTables_Test_WDTGetAddressError(void) int32 Result; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + uint8 call_count_LC_ResetResultsWP; + uint8 call_count_LC_ResetResultsAP; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error getting WDT address, RC=0x%%08X"); @@ -107,8 +113,8 @@ void LC_ManageTables_Test_WDTGetAddressError(void) 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); - uint8 call_count_LC_ResetResultsWP = UT_GetStubCount(UT_KEY(LC_ResetResultsWP)); - uint8 call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); + call_count_LC_ResetResultsWP = UT_GetStubCount(UT_KEY(LC_ResetResultsWP)); + call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); UtAssert_INT32_EQ(call_count_LC_ResetResultsWP, 0); UtAssert_INT32_EQ(call_count_LC_ResetResultsAP, 0); @@ -119,6 +125,7 @@ void LC_ManageTables_Test_ADTGetAddressError(void) int32 Result; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + uint8 call_count_LC_ResetResultsAP; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error getting ADT address, RC=0x%%08X"); @@ -139,7 +146,7 @@ void LC_ManageTables_Test_ADTGetAddressError(void) 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); - uint8 call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); + call_count_LC_ResetResultsAP = UT_GetStubCount(UT_KEY(LC_ResetResultsAP)); UtAssert_INT32_EQ(call_count_LC_ResetResultsAP, 0); } diff --git a/unit-test/lc_watch_tests.c b/unit-test/lc_watch_tests.c index b6615ef..9ba1615 100644 --- a/unit-test/lc_watch_tests.c +++ b/unit-test/lc_watch_tests.c @@ -500,12 +500,11 @@ void LC_ProcessWP_Test_OperatorCompareWatchFalsePreviousStale(void) { uint16 WatchIndex = 0; CFE_TIME_SysTime_t Timestamp; + CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; Timestamp.Seconds = 3; Timestamp.Subseconds = 5; - CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; @@ -544,12 +543,11 @@ void LC_ProcessWP_Test_OperatorCompareWatchFalsePreviousTrue(void) { uint16 WatchIndex = 0; CFE_TIME_SysTime_t Timestamp; + CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; Timestamp.Seconds = 3; Timestamp.Subseconds = 5; - CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; @@ -612,10 +610,10 @@ void LC_ProcessWP_Test_OperatorCompareWatchTruePreviousTrue(void) { uint16 WatchIndex = 0; CFE_TIME_SysTime_t Timestamp; + CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - Timestamp.Seconds = 3; - Timestamp.Subseconds = 5; - CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + Timestamp.Seconds = 3; + Timestamp.Subseconds = 5; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -655,12 +653,11 @@ void LC_ProcessWP_Test_OperatorCompareWatchFalsePreviousFalse(void) { uint16 WatchIndex = 0; CFE_TIME_SysTime_t Timestamp; + CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; Timestamp.Seconds = 3; Timestamp.Subseconds = 5; - CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_BYTE; @@ -857,6 +854,8 @@ void LC_OperatorCompare_Test_DataTypeError(void) uint8 Result; uint16 WatchIndex = 0; uint32 ProcessedWPData = 0; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; LC_OperData.WDTPtr[WatchIndex].DataType = 99; LC_OperData.WDTPtr[WatchIndex].OperatorID = LC_OPER_LE; @@ -866,9 +865,6 @@ void LC_OperatorCompare_Test_DataTypeError(void) LC_OperData.WDTPtr[WatchIndex].ComparisonValue.Float32 = 1.0; LC_OperData.WRTPtr[WatchIndex].EvaluationCount = 0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WP has undefined data type: WP = %%d, DataType = %%d"); @@ -1001,12 +997,11 @@ void LC_SignedCompare_Test_InvalidOperatorID(void) uint16 WatchIndex = 0; int32 WPValue = 1; int32 CompareValue = 0; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; LC_OperData.WDTPtr[WatchIndex].OperatorID = 99; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WP has invalid operator ID: WP = %%d, OperID = %%d"); @@ -1336,13 +1331,13 @@ void LC_FloatCompare_Test_InvalidOperatorID(void) uint16 WatchIndex = 0; LC_MultiType_t WPMultiType; LC_MultiType_t CompareMultiType; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; WPMultiType.Float32 = 1.0; CompareMultiType.Float32 = 0.0; LC_OperData.WDTPtr[WatchIndex].OperatorID = 99; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WP has invalid operator ID: WP = %%d, OperID = %%d"); @@ -1368,12 +1363,12 @@ void LC_FloatCompare_Test_NaN(void) uint16 WatchIndex = 0; LC_MultiType_t WPMultiType; LC_MultiType_t CompareMultiType; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; WPMultiType.Float32 = 1.0; WPMultiType.Unsigned32 = 0x7F8FFFFF; CompareMultiType.Float32 = 0.0; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WP data value is a float NAN: WP = %%d, Value = 0x%%08X"); @@ -1400,10 +1395,10 @@ void LC_WPOffsetValid_Test_DataUByte(void) bool Result; uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UBYTE; @@ -1423,10 +1418,10 @@ void LC_WPOffsetValid_Test_UWordLE(void) bool Result; uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UWORD_LE; @@ -1446,10 +1441,10 @@ void LC_WPOffsetValid_Test_UDWordLE(void) bool Result; uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UDWORD_LE; @@ -1469,9 +1464,10 @@ void LC_WPOffsetValid_Test_FloatLE(void) bool Result; uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + size_t MsgSize = 16; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - size_t MsgSize = 16; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_FLOAT_LE; @@ -1491,12 +1487,11 @@ void LC_WPOffsetValid_Test_DataTypeError(void) bool Result; uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WP has undefined data type: WP = %%d, DataType = %%d"); @@ -1527,13 +1522,13 @@ void LC_WPOffsetValid_Test_OffsetError(void) bool Result; uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; + size_t MsgSize = 0; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - size_t MsgSize = 0; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WP offset error: MID = 0x%%08lX, WP = %%d, Offset = %%d, DataSize = %%d, MsgLen = %%d"); @@ -1828,12 +1823,11 @@ void LC_ValidateWDT_Test_AllDataTypes(void) int32 TableIndex; int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WDT verify err: WP = %%d, Err = %%d, DType = %%d, Oper = %%d, MID = 0x%%08lX"); - char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString2, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WDT verify results: good = %%d, bad = %%d, unused = %%d"); @@ -1885,12 +1879,11 @@ void LC_ValidateWDT_Test_AllOperatorIDs(void) int32 strCmpResult; char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WDT verify err: WP = %%d, Err = %%d, DType = %%d, Oper = %%d, MID = 0x%%08lX"); - char ExpectedEventString2[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - snprintf(ExpectedEventString2, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "WDT verify results: good = %%d, bad = %%d, unused = %%d");