diff --git a/fsw/src/mm_app.c b/fsw/src/mm_app.c index 5ff452e..19c7525 100644 --- a/fsw/src/mm_app.c +++ b/fsw/src/mm_app.c @@ -240,7 +240,10 @@ void MM_AppPipe(const CFE_SB_Buffer_t *BufPtr) ** Housekeeping telemetry request */ case MM_SEND_HK_MID: - MM_HousekeepingCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_NoArgsCmd_t))) + { + MM_HousekeepingCmd(BufPtr); + } break; /* @@ -253,55 +256,94 @@ void MM_AppPipe(const CFE_SB_Buffer_t *BufPtr) switch (CommandCode) { case MM_NOOP_CC: - CmdResult = MM_NoopCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_NoArgsCmd_t))) + { + CmdResult = MM_NoopCmd(BufPtr); + } break; case MM_RESET_CC: - CmdResult = MM_ResetCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_NoArgsCmd_t))) + { + CmdResult = MM_ResetCmd(BufPtr); + } break; case MM_PEEK_CC: - CmdResult = MM_PeekCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_PeekCmd_t))) + { + CmdResult = MM_PeekCmd(BufPtr); + } break; case MM_POKE_CC: - CmdResult = MM_PokeCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_PokeCmd_t))) + { + CmdResult = MM_PokeCmd(BufPtr); + } break; case MM_LOAD_MEM_WID_CC: - CmdResult = MM_LoadMemWIDCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_LoadMemWIDCmd_t))) + { + CmdResult = MM_LoadMemWIDCmd(BufPtr); + } break; case MM_LOAD_MEM_FROM_FILE_CC: - CmdResult = MM_LoadMemFromFileCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_LoadMemFromFileCmd_t))) + { + CmdResult = MM_LoadMemFromFileCmd(BufPtr); + } break; case MM_DUMP_MEM_TO_FILE_CC: - CmdResult = MM_DumpMemToFileCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_DumpMemToFileCmd_t))) + { + CmdResult = MM_DumpMemToFileCmd(BufPtr); + } break; case MM_DUMP_IN_EVENT_CC: - CmdResult = MM_DumpInEventCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_DumpInEventCmd_t))) + { + CmdResult = MM_DumpInEventCmd(BufPtr); + } break; case MM_FILL_MEM_CC: - CmdResult = MM_FillMemCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_FillMemCmd_t))) + { + CmdResult = MM_FillMemCmd(BufPtr); + } break; case MM_LOOKUP_SYM_CC: - CmdResult = MM_LookupSymbolCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_LookupSymCmd_t))) + { + CmdResult = MM_LookupSymbolCmd(BufPtr); + } break; case MM_SYMTBL_TO_FILE_CC: - CmdResult = MM_SymTblToFileCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_SymTblToFileCmd_t))) + { + CmdResult = MM_SymTblToFileCmd(BufPtr); + } break; - case MM_ENABLE_EEPROM_WRITE_CC: - CmdResult = MM_EepromWriteEnaCmd(BufPtr); + case MM_ENABLE_EEPROM_WRITE_CC: + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_EepromWriteEnaCmd_t))) + { + CmdResult = MM_EepromWriteEnaCmd(BufPtr); + } break; case MM_DISABLE_EEPROM_WRITE_CC: - CmdResult = MM_EepromWriteDisCmd(BufPtr); + if (MM_VerifyCmdLength(&BufPtr->Msg, sizeof(MM_EepromWriteDisCmd_t))) + { + CmdResult = MM_EepromWriteDisCmd(BufPtr); + } break; default: @@ -344,13 +386,6 @@ void MM_AppPipe(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void MM_HousekeepingCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(MM_NoArgsCmd_t); - - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { /* ** Send housekeeping telemetry packet */ @@ -360,8 +395,6 @@ void MM_HousekeepingCmd(const CFE_SB_Buffer_t *BufPtr) /* ** This command does not affect the command execution counter */ - - } /* end if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -371,19 +404,13 @@ void MM_HousekeepingCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool MM_NoopCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(MM_NoArgsCmd_t); bool Result = false; - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { + MM_AppData.HkPacket.LastAction = MM_NOOP; Result = true; CFE_EVS_SendEvent(MM_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", MM_MAJOR_VERSION, MM_MINOR_VERSION, MM_REVISION, MM_MISSION_REV); - } return Result; } @@ -395,20 +422,14 @@ bool MM_NoopCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool MM_ResetCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(MM_NoArgsCmd_t); bool Result = false; - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { + MM_AppData.HkPacket.LastAction = MM_RESET; MM_AppData.HkPacket.CmdCounter = 0; MM_AppData.HkPacket.ErrCounter = 0; CFE_EVS_SendEvent(MM_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command received"); Result = true; - } return Result; } @@ -423,15 +444,9 @@ bool MM_LookupSymbolCmd(const CFE_SB_Buffer_t *BufPtr) int32 OS_Status = OS_ERROR; /* Set to error instead of success since we explicitly test for success */ cpuaddr ResolvedAddr = 0; const MM_LookupSymCmd_t *CmdPtr = NULL; - size_t ExpectedLength = sizeof(MM_LookupSymCmd_t); bool Result = false; char SymName[OS_MAX_SYM_LEN]; - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_LookupSymCmd_t *)BufPtr); /* Make sure string is null terminated before attempting to process it */ @@ -469,8 +484,6 @@ bool MM_LookupSymbolCmd(const CFE_SB_Buffer_t *BufPtr) } /* end strlen(CmdPtr->SymName) == 0 else */ - } /* end MM_VerifyCmdLength if */ - return Result; } @@ -484,14 +497,8 @@ bool MM_SymTblToFileCmd(const CFE_SB_Buffer_t *BufPtr) int32 OS_Status = OS_ERROR; /* Set to error instead of success since we explicitly test for success */ char FileName[OS_MAX_PATH_LEN]; const MM_SymTblToFileCmd_t *CmdPtr = NULL; - size_t ExpectedLength = sizeof(MM_SymTblToFileCmd_t); bool Result = false; - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_SymTblToFileCmd_t *)BufPtr); /* Make sure string is null terminated before attempting to process it */ @@ -527,8 +534,6 @@ bool MM_SymTblToFileCmd(const CFE_SB_Buffer_t *BufPtr) } /* end strlen(FileName) == 0 else */ - } /* end MM_VerifyCmdLength if */ - return Result; } @@ -541,14 +546,8 @@ bool MM_EepromWriteEnaCmd(const CFE_SB_Buffer_t *BufPtr) { CFE_Status_t cFE_Status = CFE_PSP_ERROR; /* Set to error since we explicitly test for success */ MM_EepromWriteEnaCmd_t *CmdPtr = NULL; - size_t ExpectedLength = sizeof(MM_EepromWriteEnaCmd_t); bool Result = false; - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_EepromWriteEnaCmd_t *)BufPtr); /* @@ -573,8 +572,6 @@ bool MM_EepromWriteEnaCmd(const CFE_SB_Buffer_t *BufPtr) (unsigned int)cFE_Status); } - } /* end MM_VerifyCmdLength if */ - return Result; } @@ -587,14 +584,8 @@ bool MM_EepromWriteDisCmd(const CFE_SB_Buffer_t *BufPtr) { CFE_Status_t cFE_Status = CFE_PSP_ERROR; /* Set to error since we explicitly test for success */ MM_EepromWriteDisCmd_t *CmdPtr = NULL; - size_t ExpectedLength = sizeof(MM_EepromWriteDisCmd_t); bool Result = false; - /* - ** Verify command packet length - */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_EepromWriteDisCmd_t *)BufPtr); /* @@ -618,7 +609,5 @@ bool MM_EepromWriteDisCmd(const CFE_SB_Buffer_t *BufPtr) (unsigned int)cFE_Status); } - } /* end MM_VerifyCmdLength if */ - return Result; } diff --git a/fsw/src/mm_dump.c b/fsw/src/mm_dump.c index 77e73a7..9bd090e 100644 --- a/fsw/src/mm_dump.c +++ b/fsw/src/mm_dump.c @@ -50,13 +50,9 @@ bool MM_PeekCmd(const CFE_SB_Buffer_t *BufPtr) bool Valid; const MM_PeekCmd_t *CmdPtr; cpuaddr SrcAddress = 0; - size_t ExpectedLength = sizeof(MM_PeekCmd_t); bool Result = false; MM_SymAddr_t SrcSymAddress; - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_PeekCmd_t *)BufPtr); SrcSymAddress = CmdPtr->SrcSymAddress; @@ -86,8 +82,6 @@ bool MM_PeekCmd(const CFE_SB_Buffer_t *BufPtr) "Symbolic address can't be resolved: Name = '%s'", CmdPtr->SrcSymAddress.SymName); } - } /* end MM_VerifyCmdLength if */ - return Result; } @@ -198,11 +192,7 @@ bool MM_DumpMemToFileCmd(const CFE_SB_Buffer_t *BufPtr) const MM_DumpMemToFileCmd_t *CmdPtr; CFE_FS_Header_t CFEFileHeader; MM_LoadDumpFileHeader_t MMFileHeader; - size_t ExpectedLength = sizeof(MM_DumpMemToFileCmd_t); - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_DumpMemToFileCmd_t *)BufPtr); SrcSymAddress = CmdPtr->SrcSymAddress; @@ -361,8 +351,6 @@ bool MM_DumpMemToFileCmd(const CFE_SB_Buffer_t *BufPtr) "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); } - } /* end MM_VerifyCmdLength if */ - return Valid; } @@ -483,7 +471,6 @@ bool MM_DumpInEventCmd(const CFE_SB_Buffer_t *BufPtr) uint32 i; int32 EventStringTotalLength = 0; cpuaddr SrcAddress = 0; - size_t ExpectedLength = sizeof(MM_DumpInEventCmd_t); uint8 * BytePtr; char TempString[MM_DUMPINEVENT_TEMP_CHARS]; const char HeaderString[] = "Memory Dump: "; @@ -497,9 +484,6 @@ bool MM_DumpInEventCmd(const CFE_SB_Buffer_t *BufPtr) */ uint32 DumpBuffer[(MM_MAX_DUMP_INEVENT_BYTES + 3) / 4]; - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_DumpInEventCmd_t *)BufPtr); SrcSymAddress = CmdPtr->SrcSymAddress; @@ -567,8 +551,6 @@ bool MM_DumpInEventCmd(const CFE_SB_Buffer_t *BufPtr) "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); } - } /* end MM_VerifyCmdLength if */ - return Valid; } diff --git a/fsw/src/mm_load.c b/fsw/src/mm_load.c index c391de3..f14d5d2 100644 --- a/fsw/src/mm_load.c +++ b/fsw/src/mm_load.c @@ -52,12 +52,8 @@ bool MM_PokeCmd(const CFE_SB_Buffer_t *BufPtr) bool Valid = false; cpuaddr DestAddress = 0; const MM_PokeCmd_t *CmdPtr; - size_t ExpectedLength = sizeof(MM_PokeCmd_t); MM_SymAddr_t DestSymAddress; - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_PokeCmd_t *)BufPtr); DestSymAddress = CmdPtr->DestSymAddress; @@ -96,8 +92,6 @@ bool MM_PokeCmd(const CFE_SB_Buffer_t *BufPtr) "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); } - } /* end MM_VerifyCmdLength if */ - return Valid; } @@ -298,13 +292,9 @@ bool MM_LoadMemWIDCmd(const CFE_SB_Buffer_t *BufPtr) const MM_LoadMemWIDCmd_t *CmdPtr; uint32 ComputedCRC; cpuaddr DestAddress = 0; - size_t ExpectedLength = sizeof(MM_LoadMemWIDCmd_t); bool CmdResult = false; MM_SymAddr_t DestSymAddress; - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_LoadMemWIDCmd_t *)BufPtr); DestSymAddress = CmdPtr->DestSymAddress; @@ -355,8 +345,6 @@ bool MM_LoadMemWIDCmd(const CFE_SB_Buffer_t *BufPtr) "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); } - } /* end MM_VerifyCmdLength if */ - return CmdResult; } @@ -376,13 +364,9 @@ bool MM_LoadMemFromFileCmd(const CFE_SB_Buffer_t *BufPtr) CFE_FS_Header_t CFEFileHeader; MM_LoadDumpFileHeader_t MMFileHeader; uint32 ComputedCRC; - size_t ExpectedLength = sizeof(MM_LoadMemFromFileCmd_t); memset(&MMFileHeader, 0, sizeof(MMFileHeader)); - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { CmdPtr = ((MM_LoadMemFromFileCmd_t *)BufPtr); /* Make sure string is null terminated before attempting to process it */ @@ -545,8 +529,6 @@ bool MM_LoadMemFromFileCmd(const CFE_SB_Buffer_t *BufPtr) "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, CmdPtr->FileName); } - } /* end MM_VerifyCmdLength if */ - return Valid; } @@ -725,13 +707,9 @@ bool MM_FillMemCmd(const CFE_SB_Buffer_t *BufPtr) { cpuaddr DestAddress = 0; const MM_FillMemCmd_t *CmdPtr = (MM_FillMemCmd_t *)BufPtr; - size_t ExpectedLength = sizeof(MM_FillMemCmd_t); bool CmdResult = false; MM_SymAddr_t DestSymAddress = CmdPtr->DestSymAddress; - /* Verify command packet length */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { /* Resolve symbolic address */ if (MM_ResolveSymAddr(&(DestSymAddress), &DestAddress) == true) { @@ -786,7 +764,6 @@ bool MM_FillMemCmd(const CFE_SB_Buffer_t *BufPtr) CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); } - } return CmdResult; } diff --git a/unit-test/mm_app_tests.c b/unit-test/mm_app_tests.c index 09f2680..49e2252 100644 --- a/unit-test/mm_app_tests.c +++ b/unit-test/mm_app_tests.c @@ -388,7 +388,7 @@ void MM_AppInit_Test_SBSubscribeMMError(void) call_count_CFE_EVS_SendEvent); } -void MM_AppPipe_Test_SendHK(void) +void MM_AppPipe_Test_SendHKSuccess(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_SEND_HK_MID); @@ -409,6 +409,27 @@ void MM_AppPipe_Test_SendHK(void) call_count_CFE_EVS_SendEvent); } +void MM_AppPipe_Test_SendHKFail(void) +{ + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_SEND_HK_MID); + + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + + /* ignore dummy message length check */ + UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); + + /* Execute the function being tested */ + MM_AppPipe(&UT_CmdBuf.Buf); + + /* Verify results */ + UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); + UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); + + call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); + UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", + call_count_CFE_EVS_SendEvent); +} + void MM_AppPipe_Test_NoopSuccess(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); @@ -546,11 +567,10 @@ void MM_AppPipe_Test_PeekSuccess(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); CFE_MSG_FcnCode_t FcnCode = MM_PEEK_CC; - uint8 call_count_MM_PeekCmd = 0; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_PeekCmd), true); /* Execute the function being tested */ @@ -560,20 +580,17 @@ void MM_AppPipe_Test_PeekSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - call_count_MM_PeekCmd = UT_GetStubCount(UT_KEY(MM_PeekCmd)); - UtAssert_INT32_EQ(call_count_MM_PeekCmd, 1); + UtAssert_STUB_COUNT(MM_PeekCmd, 1); } void MM_AppPipe_Test_PeekFail(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); CFE_MSG_FcnCode_t FcnCode = MM_PEEK_CC; - uint8 call_count_MM_PeekCmd = 0; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - - UT_SetDefaultReturnValue(UT_KEY(MM_PeekCmd), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); /* Execute the function being tested */ MM_AppPipe(&UT_CmdBuf.Buf); @@ -582,8 +599,7 @@ void MM_AppPipe_Test_PeekFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - call_count_MM_PeekCmd = UT_GetStubCount(UT_KEY(MM_PeekCmd)); - UtAssert_INT32_EQ(call_count_MM_PeekCmd, 1); + UtAssert_STUB_COUNT(MM_PeekCmd, 0); } void MM_AppPipe_Test_PokeSuccess(void) @@ -594,6 +610,7 @@ void MM_AppPipe_Test_PokeSuccess(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_PokeCmd), true); /* Execute the function being tested */ @@ -603,9 +620,7 @@ void MM_AppPipe_Test_PokeSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - uint8 call_count_MM_PokeCmd = 0; - call_count_MM_PokeCmd = UT_GetStubCount(UT_KEY(MM_PokeCmd)); - UtAssert_INT32_EQ(call_count_MM_PokeCmd, 1); + UtAssert_STUB_COUNT(MM_PokeCmd, 1); } void MM_AppPipe_Test_PokeFail(void) @@ -616,6 +631,7 @@ void MM_AppPipe_Test_PokeFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); UT_SetDefaultReturnValue(UT_KEY(MM_PokeCmd), false); /* Execute the function being tested */ @@ -625,9 +641,7 @@ void MM_AppPipe_Test_PokeFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - uint8 call_count_MM_PokeCmd = 0; - call_count_MM_PokeCmd = UT_GetStubCount(UT_KEY(MM_PokeCmd)); - UtAssert_INT32_EQ(call_count_MM_PokeCmd, 1); + UtAssert_STUB_COUNT(MM_PokeCmd, 0); } void MM_AppPipe_Test_LoadMemWIDSuccess(void) @@ -638,6 +652,7 @@ void MM_AppPipe_Test_LoadMemWIDSuccess(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_LoadMemWIDCmd), true); /* Execute the function being tested */ @@ -647,9 +662,7 @@ void MM_AppPipe_Test_LoadMemWIDSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - uint8 call_count_MM_LoadMemWID = 0; - call_count_MM_LoadMemWID = UT_GetStubCount(UT_KEY(MM_LoadMemWIDCmd)); - UtAssert_INT32_EQ(call_count_MM_LoadMemWID, 1); + UtAssert_STUB_COUNT(MM_LoadMemWIDCmd, 1); } void MM_AppPipe_Test_LoadMemWIDFail(void) @@ -660,6 +673,7 @@ void MM_AppPipe_Test_LoadMemWIDFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); UT_SetDefaultReturnValue(UT_KEY(MM_LoadMemWIDCmd), false); /* Execute the function being tested */ @@ -669,9 +683,7 @@ void MM_AppPipe_Test_LoadMemWIDFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - uint8 call_count_MM_LoadMemWID = 0; - call_count_MM_LoadMemWID = UT_GetStubCount(UT_KEY(MM_LoadMemWIDCmd)); - UtAssert_INT32_EQ(call_count_MM_LoadMemWID, 1); + UtAssert_STUB_COUNT(MM_LoadMemWIDCmd, 0); } void MM_AppPipe_Test_LoadMemFromFileSuccess(void) @@ -682,6 +694,7 @@ void MM_AppPipe_Test_LoadMemFromFileSuccess(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_LoadMemFromFileCmd), true); /* Execute the function being tested */ @@ -691,9 +704,7 @@ void MM_AppPipe_Test_LoadMemFromFileSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - uint8 call_count_MM_LoadMemFromFile = 0; - call_count_MM_LoadMemFromFile = UT_GetStubCount(UT_KEY(MM_LoadMemFromFileCmd)); - UtAssert_INT32_EQ(call_count_MM_LoadMemFromFile, 1); + UtAssert_STUB_COUNT(MM_LoadMemFromFileCmd, 1); } void MM_AppPipe_Test_LoadMemFromFileFail(void) @@ -704,6 +715,7 @@ void MM_AppPipe_Test_LoadMemFromFileFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); UT_SetDefaultReturnValue(UT_KEY(MM_LoadMemFromFileCmd), false); /* Execute the function being tested */ @@ -713,9 +725,7 @@ void MM_AppPipe_Test_LoadMemFromFileFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - uint8 call_count_MM_LoadMemFromFile = 0; - call_count_MM_LoadMemFromFile = UT_GetStubCount(UT_KEY(MM_LoadMemFromFileCmd)); - UtAssert_INT32_EQ(call_count_MM_LoadMemFromFile, 1); + UtAssert_STUB_COUNT(MM_LoadMemFromFileCmd, 0); } void MM_AppPipe_Test_DumpMemToFileSuccess(void) @@ -726,6 +736,7 @@ void MM_AppPipe_Test_DumpMemToFileSuccess(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_DumpMemToFileCmd), true); /* Execute the function being tested */ @@ -735,9 +746,7 @@ void MM_AppPipe_Test_DumpMemToFileSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - uint8 call_count_MM_DumpMemToFile = 0; - call_count_MM_DumpMemToFile = UT_GetStubCount(UT_KEY(MM_DumpMemToFileCmd)); - UtAssert_INT32_EQ(call_count_MM_DumpMemToFile, 1); + UtAssert_STUB_COUNT(MM_DumpMemToFileCmd, 1); } void MM_AppPipe_Test_DumpMemToFileFail(void) @@ -748,6 +757,7 @@ void MM_AppPipe_Test_DumpMemToFileFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); UT_SetDefaultReturnValue(UT_KEY(MM_DumpMemToFileCmd), false); /* Execute the function being tested */ @@ -757,9 +767,7 @@ void MM_AppPipe_Test_DumpMemToFileFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - uint8 call_count_MM_DumpMemToFile = 0; - call_count_MM_DumpMemToFile = UT_GetStubCount(UT_KEY(MM_DumpMemToFileCmd)); - UtAssert_INT32_EQ(call_count_MM_DumpMemToFile, 1); + UtAssert_STUB_COUNT(MM_DumpMemToFileCmd, 0); } void MM_AppPipe_Test_DumpInEventSuccess(void) @@ -770,6 +778,7 @@ void MM_AppPipe_Test_DumpInEventSuccess(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_DumpInEventCmd), true); /* Execute the function being tested */ @@ -779,9 +788,7 @@ void MM_AppPipe_Test_DumpInEventSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - uint8 call_count_MM_DumpInEvent = 0; - call_count_MM_DumpInEvent = UT_GetStubCount(UT_KEY(MM_DumpInEventCmd)); - UtAssert_INT32_EQ(call_count_MM_DumpInEvent, 1); + UtAssert_STUB_COUNT(MM_DumpInEventCmd, 1); } void MM_AppPipe_Test_DumpInEventFail(void) @@ -792,6 +799,7 @@ void MM_AppPipe_Test_DumpInEventFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); UT_SetDefaultReturnValue(UT_KEY(MM_DumpInEventCmd), false); /* Execute the function being tested */ @@ -801,9 +809,7 @@ void MM_AppPipe_Test_DumpInEventFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - uint8 call_count_MM_DumpInEvent = 0; - call_count_MM_DumpInEvent = UT_GetStubCount(UT_KEY(MM_DumpInEventCmd)); - UtAssert_INT32_EQ(call_count_MM_DumpInEvent, 1); + UtAssert_STUB_COUNT(MM_DumpInEventCmd, 0); } void MM_AppPipe_Test_FillMemSuccess(void) @@ -814,6 +820,7 @@ void MM_AppPipe_Test_FillMemSuccess(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, true); UT_SetDefaultReturnValue(UT_KEY(MM_FillMemCmd), true); /* Execute the function being tested */ @@ -823,9 +830,7 @@ void MM_AppPipe_Test_FillMemSuccess(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 1); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - uint8 call_count_MM_FillMem = 0; - call_count_MM_FillMem = UT_GetStubCount(UT_KEY(MM_FillMemCmd)); - UtAssert_INT32_EQ(call_count_MM_FillMem, 1); + UtAssert_STUB_COUNT(MM_FillMemCmd, 1); } void MM_AppPipe_Test_FillMemFail(void) @@ -836,6 +841,7 @@ void MM_AppPipe_Test_FillMemFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); UT_SetDefaultReturnValue(UT_KEY(MM_FillMemCmd), false); /* Execute the function being tested */ @@ -845,9 +851,7 @@ void MM_AppPipe_Test_FillMemFail(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 1); - uint8 call_count_MM_FillMem = 0; - call_count_MM_FillMem = UT_GetStubCount(UT_KEY(MM_FillMemCmd)); - UtAssert_INT32_EQ(call_count_MM_FillMem, 1); + UtAssert_STUB_COUNT(MM_FillMemCmd, 0); } void MM_AppPipe_Test_LookupSymbolSuccess(void) @@ -1167,9 +1171,6 @@ void MM_HousekeepingCmd_Test(void) strncpy(MM_AppData.HkPacket.FileName, "name", sizeof(MM_AppData.HkPacket.FileName) - 1); - /* ignore dummy message length check */ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), true); - /* Execute the function being tested */ MM_HousekeepingCmd(&UT_CmdBuf.Buf); @@ -1191,38 +1192,6 @@ void MM_HousekeepingCmd_Test(void) call_count_CFE_EVS_SendEvent); } -void MM_HousekeepingCmd_Test_NoLengthVerify(void) -{ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - MM_HousekeepingCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); -} - -void MM_ResetCmd_Test_NoLengthVerify(void) -{ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - MM_ResetCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); -} - void MM_LookupSymbolCmd_Test_Nominal(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); @@ -1349,22 +1318,6 @@ void MM_LookupSymbolCmd_Test_SymbolLookupError(void) call_count_CFE_EVS_SendEvent); } -void MM_LookupSymbolCmd_Test_NoLengthVerify(void) -{ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - MM_LookupSymbolCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); -} - void MM_SymTblToFileCmd_Test_Nominal(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); @@ -1494,22 +1447,6 @@ void MM_SymTblToFileCmd_Test_SymbolTableDumpError(void) call_count_CFE_EVS_SendEvent); } -void MM_SymTblToFileCmd_Test_NoLengthVerify(void) -{ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - MM_SymTblToFileCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); -} - void MM_EepromWriteEnaCmd_Test_Nominal(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); @@ -1599,22 +1536,6 @@ void MM_EepromWriteEnaCmd_Test_Error(void) call_count_CFE_EVS_SendEvent); } -void MM_EepromWriteEnaCmd_Test_NoLengthVerify(void) -{ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - MM_EepromWriteEnaCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); -} - void MM_EepromWriteDisCmd_Test_Nominal(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(MM_CMD_MID); @@ -1704,22 +1625,6 @@ void MM_EepromWriteDisCmd_Test_Error(void) call_count_CFE_EVS_SendEvent); } -void MM_EepromWriteDisCmd_Test_NoLengthVerify(void) -{ - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - MM_EepromWriteDisCmd(&UT_CmdBuf.Buf); - - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); -} - /* * Register the test cases to execute with the unit test tool */ @@ -1736,7 +1641,8 @@ void UtTest_Setup(void) "MM_AppInit_Test_SBSubscribeHKError"); UtTest_Add(MM_AppInit_Test_SBSubscribeMMError, MM_Test_Setup, MM_Test_TearDown, "MM_AppInit_Test_SBSubscribeMMError"); - UtTest_Add(MM_AppPipe_Test_SendHK, MM_Test_Setup, MM_Test_TearDown, "MM_AppPipe_Test_SendHk"); + UtTest_Add(MM_AppPipe_Test_SendHKSuccess, MM_Test_Setup, MM_Test_TearDown, "MM_AppPipe_Test_SendHkSuccess"); + UtTest_Add(MM_AppPipe_Test_SendHKFail, MM_Test_Setup, MM_Test_TearDown, "MM_AppPipe_Test_SendHkFail"); UtTest_Add(MM_AppPipe_Test_NoopSuccess, MM_Test_Setup, MM_Test_TearDown, "MM_AppPipe_Test_NoopSuccess"); UtTest_Add(MM_AppPipe_Test_NoopFail, MM_Test_Setup, MM_Test_TearDown, "MM_AppPipe_Test_NoopFail"); UtTest_Add(MM_AppPipe_Test_ResetSuccess, MM_Test_Setup, MM_Test_TearDown, "MM_AppPipe_Test_ResetSuccess"); @@ -1777,34 +1683,22 @@ void UtTest_Setup(void) "MM_AppPipe_Test_InvalidCommandPipeMessageID"); UtTest_Add(MM_HousekeepingCmd_Test, MM_Test_Setup, MM_Test_TearDown, "MM_HousekeepingCmd_Test"); - UtTest_Add(MM_HousekeepingCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_HousekeepingCmd_Test_NoLengthVerify"); - - UtTest_Add(MM_ResetCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, "MM_ResetCmd_Test_NoLengthVerify"); UtTest_Add(MM_LookupSymbolCmd_Test_Nominal, MM_Test_Setup, MM_Test_TearDown, "MM_LookupSymbolCmd_Test_Nominal"); UtTest_Add(MM_LookupSymbolCmd_Test_SymbolNameNull, MM_Test_Setup, MM_Test_TearDown, "MM_LookupSymbolCmd_Test_SymbolNameNull"); UtTest_Add(MM_LookupSymbolCmd_Test_SymbolLookupError, MM_Test_Setup, MM_Test_TearDown, "MM_LookupSymbolCmd_Test_SymbolLookupError"); - UtTest_Add(MM_LookupSymbolCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_LookupSymbolCmd_Test_NoLengthVerify"); UtTest_Add(MM_SymTblToFileCmd_Test_Nominal, MM_Test_Setup, MM_Test_TearDown, "MM_SymTblToFileCmd_Test_Nominal"); UtTest_Add(MM_SymTblToFileCmd_Test_SymbolFilenameNull, MM_Test_Setup, MM_Test_TearDown, "MM_SymTblToFileCmd_Test_SymbolFilenameNull"); UtTest_Add(MM_SymTblToFileCmd_Test_SymbolTableDumpError, MM_Test_Setup, MM_Test_TearDown, "MM_SymTblToFileCmd_Test_SymbolTableDumpError"); - UtTest_Add(MM_SymTblToFileCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_SymTblToFileCmd_Test_NoLengthVerify"); UtTest_Add(MM_EepromWriteEnaCmd_Test_Nominal, MM_Test_Setup, MM_Test_TearDown, "MM_EepromWriteEnaCmd_Test_Nominal"); UtTest_Add(MM_EepromWriteEnaCmd_Test_Error, MM_Test_Setup, MM_Test_TearDown, "MM_EepromWriteEnaCmd_Test_Error"); - UtTest_Add(MM_EepromWriteEnaCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_EepromWriteEnaCmd_Test_NoLengthVerify"); UtTest_Add(MM_EepromWriteDisCmd_Test_Nominal, MM_Test_Setup, MM_Test_TearDown, "MM_EepromWriteDisCmd_Test_Nominal"); UtTest_Add(MM_EepromWriteDisCmd_Test_Error, MM_Test_Setup, MM_Test_TearDown, "MM_EepromWriteDisCmd_Test_Error"); - UtTest_Add(MM_EepromWriteDisCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_EepromWriteDisCmd_Test_NoLengthVerify"); } diff --git a/unit-test/mm_dump_tests.c b/unit-test/mm_dump_tests.c index 7788af1..424ce59 100644 --- a/unit-test/mm_dump_tests.c +++ b/unit-test/mm_dump_tests.c @@ -484,27 +484,6 @@ void MM_PeekMem_Test_DefaultSwitch(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_PeekMem_Test_NoLengthVerify(void) -{ - bool Result; - - UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - Result = MM_PeekCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* No command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_DumpMemToFileCmd_Test_RAM(void) { CFE_SB_MsgId_t TestMsgId; @@ -1365,28 +1344,6 @@ void MM_DumpMemToFileCmd_Test_NoVerifyDumpParams(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_DumpMemToFileCmd_Test_NoLengthVerify(void) -{ - bool Result; - - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - /* Execute the function being tested */ - Result = MM_DumpMemToFileCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* no command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_DumpMemToFileCmd_Test_NoWriteHeaders(void) { CFE_SB_MsgId_t TestMsgId; @@ -1828,30 +1785,6 @@ void MM_DumpInEventCmd_Test_SymNameError(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_DumpInEventCmd_Test_NoLengthVerify(void) -{ - bool Result; - - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyCmdLength), false); - - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyLoadDumpParams), true); - - /* Execute the function being tested */ - Result = MM_DumpInEventCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* no command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_DumpInEventCmd_Test_NoVerifyDumpParams(void) { CFE_SB_MsgId_t TestMsgId; @@ -2240,7 +2173,6 @@ void UtTest_Setup(void) UtTest_Add(MM_PeekMem_Test_DWord, MM_Test_Setup, MM_Test_TearDown, "MM_PeekMem_Test_DWord"); UtTest_Add(MM_PeekMem_Test_DWordError, MM_Test_Setup, MM_Test_TearDown, "MM_PeekMem_Test_DWordError"); UtTest_Add(MM_PeekMem_Test_DefaultSwitch, MM_Test_Setup, MM_Test_TearDown, "MM_PeekMem_Test_DefaultSwitch"); - UtTest_Add(MM_PeekMem_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, "MM_PeekMem_Test_NoLengthVerify"); UtTest_Add(MM_DumpMemToFileCmd_Test_RAM, MM_Test_Setup, MM_Test_TearDown, "MM_DumpMemToFileCmd_Test_RAM"); UtTest_Add(MM_DumpMemToFileCmd_Test_BadType, MM_Test_Setup, MM_Test_TearDown, "MM_DumpMemToFileCmd_Test_BadType"); @@ -2263,8 +2195,6 @@ void UtTest_Setup(void) "MM_DumpMemToFileCmd_Test_SymNameError"); UtTest_Add(MM_DumpMemToFileCmd_Test_NoVerifyDumpParams, MM_Test_Setup, MM_Test_TearDown, "MM_DumpMemToFileCmd_Test_NoVerifyDumpParams"); - UtTest_Add(MM_DumpMemToFileCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_DumpMemToFileCmd_Test_NoLengthVerify"); UtTest_Add(MM_DumpMemToFileCmd_Test_NoWriteHeaders, MM_Test_Setup, MM_Test_TearDown, "MM_DumpMemToFileCmd_Test_NoWriteHeaders"); @@ -2281,8 +2211,6 @@ void UtTest_Setup(void) UtTest_Add(MM_DumpInEventCmd_Test_Nominal, MM_Test_Setup, MM_Test_TearDown, "MM_DumpInEventCmd_Test_Nominal"); UtTest_Add(MM_DumpInEventCmd_Test_SymNameError, MM_Test_Setup, MM_Test_TearDown, "MM_DumpInEventCmd_Test_SymNameError"); - UtTest_Add(MM_DumpInEventCmd_Test_NoLengthVerify, MM_Test_Setup, MM_Test_TearDown, - "MM_DumpInEventCmd_Test_NoLengthVerify"); UtTest_Add(MM_DumpInEventCmd_Test_NoVerifyDumpParams, MM_Test_Setup, MM_Test_TearDown, "MM_DumpInEventCmd_Test_NoVerifyDumpParams"); UtTest_Add(MM_DumpInEventCmd_Test_FillDumpInvalid, MM_Test_Setup, MM_Test_TearDown, diff --git a/unit-test/mm_load_tests.c b/unit-test/mm_load_tests.c index f0114f1..60586f9 100644 --- a/unit-test/mm_load_tests.c +++ b/unit-test/mm_load_tests.c @@ -338,27 +338,6 @@ void MM_PokeCmd_Test_SymNameError(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_PokeCmd_Test_NoVerifyCmdLength(void) -{ - bool Result; - - UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - Result = MM_PokeCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* No command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_PokeCmd_Test_NoVerifyPeekPokeParams(void) { CFE_SB_MsgId_t TestMsgId; @@ -1042,27 +1021,6 @@ void MM_LoadMemWIDCmd_Test_Nominal(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_LoadMemWIDCmd_Test_NoVerifyCmdLength(void) -{ - bool Result; - - UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - Result = MM_LoadMemWIDCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* No command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_LoadMemWIDCmd_Test_CRCError(void) { CFE_SB_MsgId_t TestMsgId; @@ -1579,28 +1537,6 @@ void MM_LoadMemFromFileCmd_Test_MEM8(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_LoadMemFromFileCmd_Test_NoVerifyCmdLength(void) -{ - bool Result; - - UT_SetDefaultReturnValue(UT_KEY(MM_VerifyLoadDumpParams), true); - UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - Result = MM_LoadMemFromFileCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* No command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_LoadMemFromFileCmd_Test_NoReadFileHeaders(void) { int32 strCmpResult; @@ -2602,30 +2538,6 @@ void MM_FillMemCmd_Test_SymNameError(void) UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); } -void MM_FillMemCmd_Test_NoVerifyCmdLength(void) -{ - bool Result; - - /* Causes MM_AppData.HkPacket.LastAction == MM_FILL */ - UT_SetHookFunction(UT_KEY(MM_FillMem8), UT_MM_LOAD_TEST_MM_FillMemHook1, 0); - - UT_SetDeferredRetcode(UT_KEY(MM_VerifyCmdLength), 1, false); - - /* Execute the function being tested */ - Result = MM_FillMemCmd(&UT_CmdBuf.Buf); - - /* Verify results */ - UtAssert_True(Result == false, "Result == false"); - - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_True(call_count_CFE_EVS_SendEvent == 0, "CFE_EVS_SendEvent was called %u time(s), expected 0", - call_count_CFE_EVS_SendEvent); - - /* No command-handling function should be updating the cmd or err counter itself */ - UtAssert_INT32_EQ(MM_AppData.HkPacket.CmdCounter, 0); - UtAssert_INT32_EQ(MM_AppData.HkPacket.ErrCounter, 0); -} - void MM_FillMemCmd_Test_NoLastActionFill(void) { bool Result; @@ -2784,7 +2696,6 @@ void UtTest_Setup(void) UtTest_Add(MM_PokeCmd_Test_EEPROM, MM_Test_Setup, MM_Test_TearDown, "MM_PokeCmd_Test_EEPROM"); UtTest_Add(MM_PokeCmd_Test_NonEEPROM, MM_Test_Setup, MM_Test_TearDown, "MM_PokeCmd_Test_NonEEPROM"); UtTest_Add(MM_PokeCmd_Test_SymNameError, MM_Test_Setup, MM_Test_TearDown, "MM_PokeCmd_Test_SymNameError"); - UtTest_Add(MM_PokeCmd_Test_NoVerifyCmdLength, MM_Test_Setup, MM_Test_TearDown, "MM_PokeCmd_Test_NoVerifyCmdLength"); UtTest_Add(MM_PokeCmd_Test_NoVerifyPeekPokeParams, MM_Test_Setup, MM_Test_TearDown, "MM_PokeCmd_Test_NoVerifyPeekPokeParams"); UtTest_Add(MM_PokeMem_Test_NoDataSize, MM_Test_Setup, MM_Test_TearDown, "MM_PokeMem_Test_NoDataSize"); @@ -2803,8 +2714,6 @@ void UtTest_Setup(void) UtTest_Add(MM_PokeEeprom_Test_32bitError, MM_Test_Setup, MM_Test_TearDown, "MM_PokeEeprom_Test_32bitError"); UtTest_Add(MM_LoadMemWIDCmd_Test_Nominal, MM_Test_Setup, MM_Test_TearDown, "MM_LoadMemWIDCmd_Test_Nominal"); - UtTest_Add(MM_LoadMemWIDCmd_Test_NoVerifyCmdLength, MM_Test_Setup, MM_Test_TearDown, - "MM_LoadMemWIDCmd_Test_NoVerifyCmdLength"); UtTest_Add(MM_LoadMemWIDCmd_Test_CRCError, MM_Test_Setup, MM_Test_TearDown, "MM_LoadMemWIDCmd_Test_CRCError"); UtTest_Add(MM_LoadMemWIDCmd_Test_SymNameErr, MM_Test_Setup, MM_Test_TearDown, "MM_LoadMemWIDCmd_Test_SymNameErr"); UtTest_Add(MM_LoadMemWIDCmd_Test_NoVerifyLoadWIDParams, MM_Test_Setup, MM_Test_TearDown, @@ -2819,8 +2728,6 @@ void UtTest_Setup(void) "MM_LoadMemFromFileCmd_Test_MEM32Invalid"); UtTest_Add(MM_LoadMemFromFileCmd_Test_MEM16, MM_Test_Setup, MM_Test_TearDown, "MM_LoadMemFromFileCmd_Test_MEM16"); UtTest_Add(MM_LoadMemFromFileCmd_Test_MEM8, MM_Test_Setup, MM_Test_TearDown, "MM_LoadMemFromFileCmd_Test_MEM8"); - UtTest_Add(MM_LoadMemFromFileCmd_Test_NoVerifyCmdLength, MM_Test_Setup, MM_Test_TearDown, - "MM_LoadMemFromFileCmd_Test_NoVerifyCmdLength"); UtTest_Add(MM_LoadMemFromFileCmd_Test_NoReadFileHeaders, MM_Test_Setup, MM_Test_TearDown, "MM_LoadMemFromFileCmd_Test_NoReadFileHeaders"); UtTest_Add(MM_LoadMemFromFileCmd_Test_NoVerifyLoadFileSize, MM_Test_Setup, MM_Test_TearDown, @@ -2861,8 +2768,6 @@ void UtTest_Setup(void) UtTest_Add(MM_FillMemCmd_Test_MEM16, MM_Test_Setup, MM_Test_TearDown, "MM_FillMemCmd_Test_MEM16"); UtTest_Add(MM_FillMemCmd_Test_MEM8, MM_Test_Setup, MM_Test_TearDown, "MM_FillMemCmd_Test_MEM8"); UtTest_Add(MM_FillMemCmd_Test_SymNameError, MM_Test_Setup, MM_Test_TearDown, "MM_FillMemCmd_Test_SymNameError"); - UtTest_Add(MM_FillMemCmd_Test_NoVerifyCmdLength, MM_Test_Setup, MM_Test_TearDown, - "MM_FillMemCmd_Test_NoVerifyCmdLength"); UtTest_Add(MM_FillMemCmd_Test_NoLastActionFill, MM_Test_Setup, MM_Test_TearDown, "MM_FillMemCmd_Test_NoLastActionFill"); UtTest_Add(MM_FillMemCmd_Test_NoVerifyLoadDump, MM_Test_Setup, MM_Test_TearDown,