diff --git a/fsw/src/mm_app.c b/fsw/src/mm_app.c index 5ff452e..a8929bf 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,24 +386,15 @@ 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 + ** Send housekeeping telemetry packet */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) - { - /* - ** Send housekeeping telemetry packet - */ - CFE_SB_TimeStampMsg(&MM_AppData.HkPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&MM_AppData.HkPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(&MM_AppData.HkPacket.TlmHeader.Msg); + CFE_SB_TransmitMsg(&MM_AppData.HkPacket.TlmHeader.Msg, true); - /* - ** This command does not affect the command execution counter - */ - - } /* end if */ + /* + ** This command does not affect the command execution counter + */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -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); - } + 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; - } + 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,53 +444,45 @@ 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]; + CmdPtr = ((MM_LookupSymCmd_t *)BufPtr); + + /* Make sure string is null terminated before attempting to process it */ + CFE_SB_MessageStringGet(SymName, CmdPtr->SymName, NULL, sizeof(SymName), sizeof(CmdPtr->SymName)); + /* - ** Verify command packet length + ** Check if the symbol name string is a nul string */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) + if (strlen(SymName) == 0) + { + CFE_EVS_SendEvent(MM_SYMNAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, + "NUL (empty) string specified as symbol name"); + } + else { - CmdPtr = ((MM_LookupSymCmd_t *)BufPtr); - - /* Make sure string is null terminated before attempting to process it */ - CFE_SB_MessageStringGet(SymName, CmdPtr->SymName, NULL, sizeof(SymName), sizeof(CmdPtr->SymName)); - /* - ** Check if the symbol name string is a nul string + ** If symbol name is not an empty string look it up using the OSAL API */ - if (strlen(SymName) == 0) + OS_Status = OS_SymbolLookup(&ResolvedAddr, SymName); + if (OS_Status == OS_SUCCESS) { - CFE_EVS_SendEvent(MM_SYMNAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, - "NUL (empty) string specified as symbol name"); + /* Update telemetry */ + MM_AppData.HkPacket.LastAction = MM_SYM_LOOKUP; + MM_AppData.HkPacket.Address = ResolvedAddr; + + CFE_EVS_SendEvent(MM_SYM_LOOKUP_INF_EID, CFE_EVS_EventType_INFORMATION, + "Symbol Lookup Command: Name = '%s' Addr = %p", SymName, (void *)ResolvedAddr); + Result = true; } else { - /* - ** If symbol name is not an empty string look it up using the OSAL API - */ - OS_Status = OS_SymbolLookup(&ResolvedAddr, SymName); - if (OS_Status == OS_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.LastAction = MM_SYM_LOOKUP; - MM_AppData.HkPacket.Address = ResolvedAddr; - - CFE_EVS_SendEvent(MM_SYM_LOOKUP_INF_EID, CFE_EVS_EventType_INFORMATION, - "Symbol Lookup Command: Name = '%s' Addr = %p", SymName, (void *)ResolvedAddr); - Result = true; - } - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", SymName); - } - - } /* end strlen(CmdPtr->SymName) == 0 else */ + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", SymName); + } - } /* end MM_VerifyCmdLength if */ + } /* end strlen(CmdPtr->SymName) == 0 else */ return Result; } @@ -484,50 +497,42 @@ 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; + CmdPtr = ((MM_SymTblToFileCmd_t *)BufPtr); + + /* Make sure string is null terminated before attempting to process it */ + CFE_SB_MessageStringGet(FileName, CmdPtr->FileName, NULL, sizeof(FileName), sizeof(CmdPtr->FileName)); + /* - ** Verify command packet length + ** Check if the filename string is a nul string */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) + if (strlen(FileName) == 0) { - CmdPtr = ((MM_SymTblToFileCmd_t *)BufPtr); - - /* Make sure string is null terminated before attempting to process it */ - CFE_SB_MessageStringGet(FileName, CmdPtr->FileName, NULL, sizeof(FileName), sizeof(CmdPtr->FileName)); - - /* - ** Check if the filename string is a nul string - */ - if (strlen(FileName) == 0) + CFE_EVS_SendEvent(MM_SYMFILENAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, + "NUL (empty) string specified as symbol dump file name"); + } + else + { + OS_Status = OS_SymbolTableDump(FileName, MM_MAX_DUMP_FILE_DATA_SYMTBL); + if (OS_Status == OS_SUCCESS) { - CFE_EVS_SendEvent(MM_SYMFILENAME_NUL_ERR_EID, CFE_EVS_EventType_ERROR, - "NUL (empty) string specified as symbol dump file name"); + /* Update telemetry */ + MM_AppData.HkPacket.LastAction = MM_SYMTBL_SAVE; + strncpy(MM_AppData.HkPacket.FileName, FileName, OS_MAX_PATH_LEN); + + CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, + "Symbol Table Dump to File Started: Name = '%s'", FileName); + Result = true; } else { - OS_Status = OS_SymbolTableDump(FileName, MM_MAX_DUMP_FILE_DATA_SYMTBL); - if (OS_Status == OS_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.LastAction = MM_SYMTBL_SAVE; - strncpy(MM_AppData.HkPacket.FileName, FileName, OS_MAX_PATH_LEN); - - CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Symbol Table Dump to File Started: Name = '%s'", FileName); - Result = true; - } - else - { - CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_FAIL_ERR_EID, CFE_EVS_EventType_ERROR, - "Error dumping symbol table, OS_Status= 0x%X, File='%s'", (unsigned int)OS_Status, - FileName); - } - - } /* end strlen(FileName) == 0 else */ + CFE_EVS_SendEvent(MM_SYMTBL_TO_FILE_FAIL_ERR_EID, CFE_EVS_EventType_ERROR, + "Error dumping symbol table, OS_Status= 0x%X, File='%s'", (unsigned int)OS_Status, + FileName); + } - } /* end MM_VerifyCmdLength if */ + } /* end strlen(FileName) == 0 else */ return Result; } @@ -541,39 +546,31 @@ 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; + CmdPtr = ((MM_EepromWriteEnaCmd_t *)BufPtr); + /* - ** Verify command packet length + ** Call the cFE to write-enable the requested bank */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) + cFE_Status = CFE_PSP_EepromWriteEnable(CmdPtr->Bank); + if (cFE_Status == CFE_PSP_SUCCESS) { - CmdPtr = ((MM_EepromWriteEnaCmd_t *)BufPtr); - - /* - ** Call the cFE to write-enable the requested bank - */ - cFE_Status = CFE_PSP_EepromWriteEnable(CmdPtr->Bank); - if (cFE_Status == CFE_PSP_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.LastAction = MM_EEPROMWRITE_ENA; - MM_AppData.HkPacket.MemType = MM_EEPROM; - - CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_INF_EID, CFE_EVS_EventType_INFORMATION, - "EEPROM bank %d write enabled, cFE_Status= 0x%X", (int)CmdPtr->Bank, - (unsigned int)cFE_Status); - Result = true; - } - else - { - CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_ERR_EID, CFE_EVS_EventType_ERROR, - "Error requesting EEPROM bank %d write enable, cFE_Status= 0x%X", (int)CmdPtr->Bank, - (unsigned int)cFE_Status); - } + /* Update telemetry */ + MM_AppData.HkPacket.LastAction = MM_EEPROMWRITE_ENA; + MM_AppData.HkPacket.MemType = MM_EEPROM; - } /* end MM_VerifyCmdLength if */ + CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_INF_EID, CFE_EVS_EventType_INFORMATION, + "EEPROM bank %d write enabled, cFE_Status= 0x%X", (int)CmdPtr->Bank, + (unsigned int)cFE_Status); + Result = true; + } + else + { + CFE_EVS_SendEvent(MM_EEPROM_WRITE_ENA_ERR_EID, CFE_EVS_EventType_ERROR, + "Error requesting EEPROM bank %d write enable, cFE_Status= 0x%X", (int)CmdPtr->Bank, + (unsigned int)cFE_Status); + } return Result; } @@ -587,38 +584,30 @@ 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; + CmdPtr = ((MM_EepromWriteDisCmd_t *)BufPtr); + /* - ** Verify command packet length + ** Call the cFE to write-enable the requested bank */ - if (MM_VerifyCmdLength(&BufPtr->Msg, ExpectedLength)) + cFE_Status = CFE_PSP_EepromWriteDisable(CmdPtr->Bank); + if (cFE_Status == CFE_PSP_SUCCESS) { - CmdPtr = ((MM_EepromWriteDisCmd_t *)BufPtr); - - /* - ** Call the cFE to write-enable the requested bank - */ - cFE_Status = CFE_PSP_EepromWriteDisable(CmdPtr->Bank); - if (cFE_Status == CFE_PSP_SUCCESS) - { - /* Update telemetry */ - MM_AppData.HkPacket.LastAction = MM_EEPROMWRITE_DIS; - MM_AppData.HkPacket.MemType = MM_EEPROM; - Result = true; - CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_INF_EID, CFE_EVS_EventType_INFORMATION, - "EEPROM bank %d write disabled, cFE_Status= 0x%X", (int)CmdPtr->Bank, - (unsigned int)cFE_Status); - } - else - { - CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_ERR_EID, CFE_EVS_EventType_ERROR, - "Error requesting EEPROM bank %d write disable, cFE_Status= 0x%X", (int)CmdPtr->Bank, - (unsigned int)cFE_Status); - } - - } /* end MM_VerifyCmdLength if */ + /* Update telemetry */ + MM_AppData.HkPacket.LastAction = MM_EEPROMWRITE_DIS; + MM_AppData.HkPacket.MemType = MM_EEPROM; + Result = true; + CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_INF_EID, CFE_EVS_EventType_INFORMATION, + "EEPROM bank %d write disabled, cFE_Status= 0x%X", (int)CmdPtr->Bank, + (unsigned int)cFE_Status); + } + else + { + CFE_EVS_SendEvent(MM_EEPROM_WRITE_DIS_ERR_EID, CFE_EVS_EventType_ERROR, + "Error requesting EEPROM bank %d write disable, cFE_Status= 0x%X", (int)CmdPtr->Bank, + (unsigned int)cFE_Status); + } return Result; } diff --git a/fsw/src/mm_dump.c b/fsw/src/mm_dump.c index 77e73a7..309f9c6 100644 --- a/fsw/src/mm_dump.c +++ b/fsw/src/mm_dump.c @@ -50,43 +50,37 @@ 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; + CmdPtr = ((MM_PeekCmd_t *)BufPtr); - /* Resolve the symbolic address in command message */ - Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + SrcSymAddress = CmdPtr->SrcSymAddress; - if (Valid == true) - { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyPeekPokeParams(SrcAddress, CmdPtr->MemType, CmdPtr->DataSize); + /* Resolve the symbolic address in command message */ + Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); - /* Check the specified memory type and call the appropriate routine */ - if (Valid == true) - { - /* - ** We use this single peek routine for all memory types - ** (including the optional ones) - */ - Result = MM_PeekMem(CmdPtr, SrcAddress); - } + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = MM_VerifyPeekPokeParams(SrcAddress, CmdPtr->MemType, CmdPtr->DataSize); - } /* end MM_ResolveSymAddr if */ - else + /* Check the specified memory type and call the appropriate routine */ + if (Valid == true) { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", CmdPtr->SrcSymAddress.SymName); + /* + ** We use this single peek routine for all memory types + ** (including the optional ones) + */ + Result = MM_PeekMem(CmdPtr, SrcAddress); } - } /* end MM_VerifyCmdLength if */ + } /* end MM_ResolveSymAddr if */ + else + { + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", CmdPtr->SrcSymAddress.SymName); + } return Result; } @@ -198,170 +192,164 @@ 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); + CmdPtr = ((MM_DumpMemToFileCmd_t *)BufPtr); - SrcSymAddress = CmdPtr->SrcSymAddress; + SrcSymAddress = CmdPtr->SrcSymAddress; - /* Make sure strings are null terminated before attempting to process them */ - CFE_SB_MessageStringGet(FileName, CmdPtr->FileName, NULL, sizeof(FileName), sizeof(CmdPtr->FileName)); + /* Make sure strings are null terminated before attempting to process them */ + CFE_SB_MessageStringGet(FileName, CmdPtr->FileName, NULL, sizeof(FileName), sizeof(CmdPtr->FileName)); - /* Resolve the symbolic address in command message */ - Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + /* Resolve the symbolic address in command message */ + Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->MemType, CmdPtr->NumOfBytes, MM_VERIFY_DUMP); if (Valid == true) { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->MemType, CmdPtr->NumOfBytes, MM_VERIFY_DUMP); - - if (Valid == true) + /* + ** Initialize the cFE primary file header structure + */ + CFE_FS_InitHeader(&CFEFileHeader, MM_CFE_HDR_DESCRIPTION, MM_CFE_HDR_SUBTYPE); + + /* + ** Initialize the MM secondary file header structure + */ + memset(&MMFileHeader, 0, sizeof(MMFileHeader)); + MMFileHeader.SymAddress.SymName[0] = MM_CLEAR_SYMNAME; + + /* + ** Copy command data to file secondary header + */ + MMFileHeader.SymAddress.Offset = SrcAddress; + MMFileHeader.MemType = CmdPtr->MemType; + MMFileHeader.NumOfBytes = CmdPtr->NumOfBytes; + + /* + ** Create and open dump file + */ + OS_Status = + OS_OpenCreate(&FileHandle, FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); + if (OS_Status == OS_SUCCESS) { - /* - ** Initialize the cFE primary file header structure - */ - CFE_FS_InitHeader(&CFEFileHeader, MM_CFE_HDR_DESCRIPTION, MM_CFE_HDR_SUBTYPE); - - /* - ** Initialize the MM secondary file header structure - */ - memset(&MMFileHeader, 0, sizeof(MMFileHeader)); - MMFileHeader.SymAddress.SymName[0] = MM_CLEAR_SYMNAME; - - /* - ** Copy command data to file secondary header - */ - MMFileHeader.SymAddress.Offset = SrcAddress; - MMFileHeader.MemType = CmdPtr->MemType; - MMFileHeader.NumOfBytes = CmdPtr->NumOfBytes; - - /* - ** Create and open dump file - */ - OS_Status = - OS_OpenCreate(&FileHandle, FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_READ_WRITE); - if (OS_Status == OS_SUCCESS) + /* Write the file headers */ + Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); + if (Valid == true) { - /* Write the file headers */ - Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); - if (Valid == true) + switch (MMFileHeader.MemType) { - switch (MMFileHeader.MemType) - { - case MM_RAM: - case MM_EEPROM: - Valid = MM_DumpMemToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_RAM: + case MM_EEPROM: + Valid = MM_DumpMemToFile(FileHandle, FileName, &MMFileHeader); + break; #ifdef MM_OPT_CODE_MEM32_MEMTYPE - case MM_MEM32: - Valid = MM_DumpMem32ToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_MEM32: + Valid = MM_DumpMem32ToFile(FileHandle, FileName, &MMFileHeader); + break; #endif /* MM_OPT_CODE_MEM32_MEMTYPE */ #ifdef MM_OPT_CODE_MEM16_MEMTYPE - case MM_MEM16: - Valid = MM_DumpMem16ToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_MEM16: + Valid = MM_DumpMem16ToFile(FileHandle, FileName, &MMFileHeader); + break; #endif /* MM_OPT_CODE_MEM16_MEMTYPE */ #ifdef MM_OPT_CODE_MEM8_MEMTYPE - case MM_MEM8: - Valid = MM_DumpMem8ToFile(FileHandle, FileName, &MMFileHeader); - break; + case MM_MEM8: + Valid = MM_DumpMem8ToFile(FileHandle, FileName, &MMFileHeader); + break; #endif /* MM_OPT_CODE_MEM8_MEMTYPE */ - default: - /* This branch will never be executed. MMFileHeader.MemType will always - * be valid value for this switch statement it is verified via - * MM_VerifyFileLoadDumpParams */ - Valid = false; - break; - } + default: + /* This branch will never be executed. MMFileHeader.MemType will always + * be valid value for this switch statement it is verified via + * MM_VerifyFileLoadDumpParams */ + Valid = false; + break; + } - if (Valid == true) + if (Valid == true) + { + /* + ** Compute CRC of dumped data + */ + OS_Status = OS_lseek( + FileHandle, (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t)), OS_SEEK_SET); + if (OS_Status != (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t))) { - /* - ** Compute CRC of dumped data - */ - OS_Status = OS_lseek( - FileHandle, (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t)), OS_SEEK_SET); - if (OS_Status != (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t))) + Valid = false; + } + else + { + OS_Status = MM_ComputeCRCFromFile(FileHandle, &MMFileHeader.Crc, MM_DUMP_FILE_CRC_TYPE); + if (OS_Status == OS_SUCCESS) { - Valid = false; - } + /* + ** Rewrite the file headers. The subfunctions will take care of moving + ** the file pointer to the beginning of the file so we don't need to do it + ** here. + */ + Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); + + } /* end MM_ComputeCRCFromFile if */ else { - OS_Status = MM_ComputeCRCFromFile(FileHandle, &MMFileHeader.Crc, MM_DUMP_FILE_CRC_TYPE); - if (OS_Status == OS_SUCCESS) - { - /* - ** Rewrite the file headers. The subfunctions will take care of moving - ** the file pointer to the beginning of the file so we don't need to do it - ** here. - */ - Valid = MM_WriteFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); - - } /* end MM_ComputeCRCFromFile if */ - else - { - Valid = false; - CFE_EVS_SendEvent(MM_COMPUTECRCFROMFILE_ERR_EID, CFE_EVS_EventType_ERROR, - "MM_ComputeCRCFromFile error received: RC = 0x%08X File = '%s'", - (unsigned int)OS_Status, FileName); - } + Valid = false; + CFE_EVS_SendEvent(MM_COMPUTECRCFROMFILE_ERR_EID, CFE_EVS_EventType_ERROR, + "MM_ComputeCRCFromFile error received: RC = 0x%08X File = '%s'", + (unsigned int)OS_Status, FileName); } - - } /* end Valid == true if */ - - if (Valid == true) - { - CFE_EVS_SendEvent( - MM_DMP_MEM_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Dump Memory To File Command: Dumped %d bytes from address %p to file '%s'", - (int)MM_AppData.HkPacket.BytesProcessed, (void *)SrcAddress, FileName); - /* - ** Update last action statistics - */ - MM_AppData.HkPacket.LastAction = MM_DUMP_TO_FILE; - strncpy(MM_AppData.HkPacket.FileName, FileName, OS_MAX_PATH_LEN); - MM_AppData.HkPacket.MemType = CmdPtr->MemType; - MM_AppData.HkPacket.Address = SrcAddress; - MM_AppData.HkPacket.BytesProcessed = CmdPtr->NumOfBytes; } - } /* end MM_WriteFileHeaders if */ + } /* end Valid == true if */ - /* Close dump file */ - if ((OS_Status = OS_close(FileHandle)) != OS_SUCCESS) + if (Valid == true) { - Valid = false; - CFE_EVS_SendEvent(MM_OS_CLOSE_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_close error received: RC = 0x%08X File = '%s'", (unsigned int)OS_Status, - FileName); + CFE_EVS_SendEvent( + MM_DMP_MEM_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, + "Dump Memory To File Command: Dumped %d bytes from address %p to file '%s'", + (int)MM_AppData.HkPacket.BytesProcessed, (void *)SrcAddress, FileName); + /* + ** Update last action statistics + */ + MM_AppData.HkPacket.LastAction = MM_DUMP_TO_FILE; + strncpy(MM_AppData.HkPacket.FileName, FileName, OS_MAX_PATH_LEN); + MM_AppData.HkPacket.MemType = CmdPtr->MemType; + MM_AppData.HkPacket.Address = SrcAddress; + MM_AppData.HkPacket.BytesProcessed = CmdPtr->NumOfBytes; } - } /* end OS_OpenCreate if */ - else + } /* end MM_WriteFileHeaders if */ + + /* Close dump file */ + if ((OS_Status = OS_close(FileHandle)) != OS_SUCCESS) { Valid = false; - CFE_EVS_SendEvent(MM_OS_CREAT_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, FileName); + CFE_EVS_SendEvent(MM_OS_CLOSE_ERR_EID, CFE_EVS_EventType_ERROR, + "OS_close error received: RC = 0x%08X File = '%s'", (unsigned int)OS_Status, + FileName); } - } /* end MM_VerifyFileLoadDumpParams if */ + } /* end OS_OpenCreate if */ + else + { + Valid = false; + CFE_EVS_SendEvent(MM_OS_CREAT_ERR_EID, CFE_EVS_EventType_ERROR, + "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, FileName); + } - } /* end MM_ResolveSymAddr if */ - else - { - Valid = false; - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); - } + } /* end MM_VerifyFileLoadDumpParams if */ - } /* end MM_VerifyCmdLength if */ + } /* end MM_ResolveSymAddr if */ + else + { + Valid = false; + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); + } 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,77 +484,72 @@ 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); + CmdPtr = ((MM_DumpInEventCmd_t *)BufPtr); - SrcSymAddress = CmdPtr->SrcSymAddress; + SrcSymAddress = CmdPtr->SrcSymAddress; - /* Resolve the symbolic source address in the command message */ - Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + /* Resolve the symbolic source address in the command message */ + Valid = MM_ResolveSymAddr(&(SrcSymAddress), &SrcAddress); + + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->MemType, CmdPtr->NumOfBytes, MM_VERIFY_EVENT); if (Valid == true) { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyLoadDumpParams(SrcAddress, CmdPtr->MemType, CmdPtr->NumOfBytes, MM_VERIFY_EVENT); + /* Fill a local data buffer with the dump words */ + Valid = MM_FillDumpInEventBuffer(SrcAddress, CmdPtr, (uint8 *)DumpBuffer); if (Valid == true) { - /* Fill a local data buffer with the dump words */ - Valid = MM_FillDumpInEventBuffer(SrcAddress, CmdPtr, (uint8 *)DumpBuffer); + /* + ** Prepare event message string header + ** 13 characters, not counting NUL terminator + */ + CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], HeaderString, NULL, + sizeof(EventString) - EventStringTotalLength, sizeof(HeaderString)); + EventStringTotalLength = strlen(EventString); - if (Valid == true) + /* + ** Build dump data string + ** Each byte of data requires 5 characters of string space + ** Note this really only allows up to ~15 bytes using default config + */ + BytePtr = (uint8 *)DumpBuffer; + for (i = 0; i < CmdPtr->NumOfBytes; i++) { - /* - ** Prepare event message string header - ** 13 characters, not counting NUL terminator - */ - CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], HeaderString, NULL, - sizeof(EventString) - EventStringTotalLength, sizeof(HeaderString)); - EventStringTotalLength = strlen(EventString); - - /* - ** Build dump data string - ** Each byte of data requires 5 characters of string space - ** Note this really only allows up to ~15 bytes using default config - */ - BytePtr = (uint8 *)DumpBuffer; - for (i = 0; i < CmdPtr->NumOfBytes; i++) - { - snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "%02X ", *BytePtr); - CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], TempString, NULL, - sizeof(EventString) - EventStringTotalLength, sizeof(TempString)); - EventStringTotalLength = strlen(EventString); - BytePtr++; - } - - /* - ** Append tail - ** This adds up to 33 characters depending on pointer representation including the NUL terminator - */ - snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "from address: %p", (void *)SrcAddress); + snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "%02X ", *BytePtr); CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], TempString, NULL, sizeof(EventString) - EventStringTotalLength, sizeof(TempString)); + EventStringTotalLength = strlen(EventString); + BytePtr++; + } - /* Send it out */ - CFE_EVS_SendEvent(MM_DUMP_INEVENT_INF_EID, CFE_EVS_EventType_INFORMATION, "%s", EventString); - - /* Update telemetry */ - MM_AppData.HkPacket.LastAction = MM_DUMP_INEVENT; - MM_AppData.HkPacket.MemType = CmdPtr->MemType; - MM_AppData.HkPacket.Address = SrcAddress; - MM_AppData.HkPacket.BytesProcessed = CmdPtr->NumOfBytes; - } /* end MM_FillDumpInEventBuffer if */ - } /* end MM_VerifyFileLoadDumpParams if */ - } /* end MM_ResolveSymAddr if */ - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); - } - - } /* end MM_VerifyCmdLength if */ + /* + ** Append tail + ** This adds up to 33 characters depending on pointer representation including the NUL terminator + */ + snprintf(TempString, MM_DUMPINEVENT_TEMP_CHARS, "from address: %p", (void *)SrcAddress); + CFE_SB_MessageStringGet(&EventString[EventStringTotalLength], TempString, NULL, + sizeof(EventString) - EventStringTotalLength, sizeof(TempString)); + + /* Send it out */ + CFE_EVS_SendEvent(MM_DUMP_INEVENT_INF_EID, CFE_EVS_EventType_INFORMATION, "%s", EventString); + + /* Update telemetry */ + MM_AppData.HkPacket.LastAction = MM_DUMP_INEVENT; + MM_AppData.HkPacket.MemType = CmdPtr->MemType; + MM_AppData.HkPacket.Address = SrcAddress; + MM_AppData.HkPacket.BytesProcessed = CmdPtr->NumOfBytes; + } /* end MM_FillDumpInEventBuffer if */ + } /* end MM_VerifyFileLoadDumpParams if */ + } /* end MM_ResolveSymAddr if */ + else + { + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", SrcSymAddress.SymName); + } return Valid; } diff --git a/fsw/src/mm_load.c b/fsw/src/mm_load.c index c391de3..c73a6b4 100644 --- a/fsw/src/mm_load.c +++ b/fsw/src/mm_load.c @@ -52,51 +52,45 @@ 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); + CmdPtr = ((MM_PokeCmd_t *)BufPtr); + + DestSymAddress = CmdPtr->DestSymAddress; - DestSymAddress = CmdPtr->DestSymAddress; + /* Resolve the symbolic address in command message */ + Valid = MM_ResolveSymAddr(&(DestSymAddress), &DestAddress); - /* Resolve the symbolic address in command message */ - Valid = MM_ResolveSymAddr(&(DestSymAddress), &DestAddress); + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = MM_VerifyPeekPokeParams(DestAddress, CmdPtr->MemType, CmdPtr->DataSize); + /* Check the specified memory type and call the appropriate routine */ if (Valid == true) { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyPeekPokeParams(DestAddress, CmdPtr->MemType, CmdPtr->DataSize); - - /* Check the specified memory type and call the appropriate routine */ - if (Valid == true) + /* Check if we need special EEPROM processing */ + if (CmdPtr->MemType == MM_EEPROM) { - /* Check if we need special EEPROM processing */ - if (CmdPtr->MemType == MM_EEPROM) - { - MM_PokeEeprom(CmdPtr, DestAddress); - } - else - { - /* - ** We can use this routine for all other memory types - * (including the optional ones) - */ - MM_PokeMem(CmdPtr, DestAddress); - } - - } /* end MM_VerifyPeekPokeParams if */ + MM_PokeEeprom(CmdPtr, DestAddress); + } + else + { + /* + ** We can use this routine for all other memory types + * (including the optional ones) + */ + MM_PokeMem(CmdPtr, DestAddress); + } - } /* end MM_ResolveSymAddr */ - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); - } + } /* end MM_VerifyPeekPokeParams if */ - } /* end MM_VerifyCmdLength if */ + } /* end MM_ResolveSymAddr */ + else + { + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); + } return Valid; } @@ -298,64 +292,58 @@ 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); + CmdPtr = ((MM_LoadMemWIDCmd_t *)BufPtr); - DestSymAddress = CmdPtr->DestSymAddress; + DestSymAddress = CmdPtr->DestSymAddress; - /* Resolve the symbolic address in command message */ - if (MM_ResolveSymAddr(&(DestSymAddress), &DestAddress) == true) + /* Resolve the symbolic address in command message */ + if (MM_ResolveSymAddr(&(DestSymAddress), &DestAddress) == true) + { + /* + ** Run some necessary checks on command parameters + ** NOTE: A load with interrupts disabled command is only valid for RAM addresses + */ + if (MM_VerifyLoadDumpParams(DestAddress, MM_RAM, CmdPtr->NumOfBytes, MM_VERIFY_WID) == true) { + /* Verify data integrity check value */ + ComputedCRC = CFE_ES_CalculateCRC(CmdPtr->DataArray, CmdPtr->NumOfBytes, 0, MM_LOAD_WID_CRC_TYPE); /* - ** Run some necessary checks on command parameters - ** NOTE: A load with interrupts disabled command is only valid for RAM addresses + ** If the CRC matches do the load */ - if (MM_VerifyLoadDumpParams(DestAddress, MM_RAM, CmdPtr->NumOfBytes, MM_VERIFY_WID) == true) + if (ComputedCRC == CmdPtr->Crc) { - /* Verify data integrity check value */ - ComputedCRC = CFE_ES_CalculateCRC(CmdPtr->DataArray, CmdPtr->NumOfBytes, 0, MM_LOAD_WID_CRC_TYPE); - /* - ** If the CRC matches do the load - */ - if (ComputedCRC == CmdPtr->Crc) - { - /* Load input data to input memory address */ - memcpy((void *)DestAddress, CmdPtr->DataArray, CmdPtr->NumOfBytes); - - CmdResult = true; - CFE_EVS_SendEvent(MM_LOAD_WID_INF_EID, CFE_EVS_EventType_INFORMATION, - "Load Memory WID Command: Wrote %d bytes to address: %p", (int)CmdPtr->NumOfBytes, - (void *)DestAddress); - - /* Update last action statistics */ - MM_AppData.HkPacket.LastAction = MM_LOAD_WID; - MM_AppData.HkPacket.Address = DestAddress; - MM_AppData.HkPacket.MemType = MM_RAM; - MM_AppData.HkPacket.BytesProcessed = CmdPtr->NumOfBytes; - } - else - { - CFE_EVS_SendEvent(MM_LOAD_WID_CRC_ERR_EID, CFE_EVS_EventType_ERROR, - "Interrupts Disabled Load CRC failure: Expected = 0x%X Calculated = 0x%X", - (unsigned int)CmdPtr->Crc, (unsigned int)ComputedCRC); - } - - } /* end MM_VerifyLoadWIDParams */ + /* Load input data to input memory address */ + memcpy((void *)DestAddress, CmdPtr->DataArray, CmdPtr->NumOfBytes); + + CmdResult = true; + CFE_EVS_SendEvent(MM_LOAD_WID_INF_EID, CFE_EVS_EventType_INFORMATION, + "Load Memory WID Command: Wrote %d bytes to address: %p", (int)CmdPtr->NumOfBytes, + (void *)DestAddress); + + /* Update last action statistics */ + MM_AppData.HkPacket.LastAction = MM_LOAD_WID; + MM_AppData.HkPacket.Address = DestAddress; + MM_AppData.HkPacket.MemType = MM_RAM; + MM_AppData.HkPacket.BytesProcessed = CmdPtr->NumOfBytes; + } + else + { + CFE_EVS_SendEvent(MM_LOAD_WID_CRC_ERR_EID, CFE_EVS_EventType_ERROR, + "Interrupts Disabled Load CRC failure: Expected = 0x%X Calculated = 0x%X", + (unsigned int)CmdPtr->Crc, (unsigned int)ComputedCRC); + } - } /* end MM_ResolveSymAddr if */ - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); - } + } /* end MM_VerifyLoadWIDParams */ - } /* end MM_VerifyCmdLength if */ + } /* end MM_ResolveSymAddr if */ + else + { + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); + } return CmdResult; } @@ -376,176 +364,170 @@ 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); + CmdPtr = ((MM_LoadMemFromFileCmd_t *)BufPtr); - /* Make sure string is null terminated before attempting to process it */ - CFE_SB_MessageStringGet(FileName, CmdPtr->FileName, NULL, sizeof(FileName), sizeof(CmdPtr->FileName)); + /* Make sure string is null terminated before attempting to process it */ + CFE_SB_MessageStringGet(FileName, CmdPtr->FileName, NULL, sizeof(FileName), sizeof(CmdPtr->FileName)); - /* Open load file for reading */ - OS_Status = OS_OpenCreate(&FileHandle, FileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (OS_Status == OS_SUCCESS) + /* Open load file for reading */ + OS_Status = OS_OpenCreate(&FileHandle, FileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); + if (OS_Status == OS_SUCCESS) + { + /* Read in the file headers */ + Valid = MM_ReadFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); + if (Valid == true) { - /* Read in the file headers */ - Valid = MM_ReadFileHeaders(FileName, FileHandle, &CFEFileHeader, &MMFileHeader); + /* Verify the file size is correct */ + Valid = MM_VerifyLoadFileSize(FileName, &MMFileHeader); if (Valid == true) { - /* Verify the file size is correct */ - Valid = MM_VerifyLoadFileSize(FileName, &MMFileHeader); - if (Valid == true) + /* Verify data integrity check value */ + OS_Status = MM_ComputeCRCFromFile(FileHandle, &ComputedCRC, MM_LOAD_FILE_CRC_TYPE); + if (OS_Status == OS_SUCCESS) { - /* Verify data integrity check value */ - OS_Status = MM_ComputeCRCFromFile(FileHandle, &ComputedCRC, MM_LOAD_FILE_CRC_TYPE); - if (OS_Status == OS_SUCCESS) + /* + ** Reset the file pointer to the start of the load data, need to do this + ** because MM_ComputeCRCFromFile reads to the end of file + */ + OS_Status = OS_lseek(FileHandle, (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t)), + OS_SEEK_SET); + if (OS_Status != (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t))) { - /* - ** Reset the file pointer to the start of the load data, need to do this - ** because MM_ComputeCRCFromFile reads to the end of file - */ - OS_Status = OS_lseek(FileHandle, (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t)), - OS_SEEK_SET); - if (OS_Status != (sizeof(CFE_FS_Header_t) + sizeof(MM_LoadDumpFileHeader_t))) - { - Valid = false; - } - /* Check the computed CRC against the file header CRC */ - if ((ComputedCRC == MMFileHeader.Crc) && (Valid == true)) - { - /* Resolve symbolic address in file header */ - Valid = MM_ResolveSymAddr(&(MMFileHeader.SymAddress), &DestAddress); + Valid = false; + } + /* Check the computed CRC against the file header CRC */ + if ((ComputedCRC == MMFileHeader.Crc) && (Valid == true)) + { + /* Resolve symbolic address in file header */ + Valid = MM_ResolveSymAddr(&(MMFileHeader.SymAddress), &DestAddress); + if (Valid == true) + { + /* Run necessary checks on command parameters */ + Valid = MM_VerifyLoadDumpParams(DestAddress, MMFileHeader.MemType, + MMFileHeader.NumOfBytes, MM_VERIFY_LOAD); if (Valid == true) { - /* Run necessary checks on command parameters */ - Valid = MM_VerifyLoadDumpParams(DestAddress, MMFileHeader.MemType, - MMFileHeader.NumOfBytes, MM_VERIFY_LOAD); - if (Valid == true) + /* Call the load routine for the specified memory type */ + switch (MMFileHeader.MemType) { - /* Call the load routine for the specified memory type */ - switch (MMFileHeader.MemType) - { - case MM_RAM: - case MM_EEPROM: - Valid = - MM_LoadMemFromFile(FileHandle, FileName, &MMFileHeader, DestAddress); - break; + case MM_RAM: + case MM_EEPROM: + Valid = + MM_LoadMemFromFile(FileHandle, FileName, &MMFileHeader, DestAddress); + break; #ifdef MM_OPT_CODE_MEM32_MEMTYPE - case MM_MEM32: - Valid = - MM_LoadMem32FromFile(FileHandle, FileName, &MMFileHeader, DestAddress); - break; + case MM_MEM32: + Valid = + MM_LoadMem32FromFile(FileHandle, FileName, &MMFileHeader, DestAddress); + break; #endif /* MM_OPT_CODE_MEM32_MEMTYPE */ #ifdef MM_OPT_CODE_MEM16_MEMTYPE - case MM_MEM16: - Valid = - MM_LoadMem16FromFile(FileHandle, FileName, &MMFileHeader, DestAddress); - break; + case MM_MEM16: + Valid = + MM_LoadMem16FromFile(FileHandle, FileName, &MMFileHeader, DestAddress); + break; #endif /* MM_OPT_CODE_MEM16_MEMTYPE */ #ifdef MM_OPT_CODE_MEM8_MEMTYPE - case MM_MEM8: - Valid = - MM_LoadMem8FromFile(FileHandle, FileName, &MMFileHeader, DestAddress); - break; + case MM_MEM8: + Valid = + MM_LoadMem8FromFile(FileHandle, FileName, &MMFileHeader, DestAddress); + break; #endif /* MM_OPT_CODE_MEM8_MEMTYPE */ - /* - ** We don't need a default case, a bad MemType will get caught - ** in the MM_VerifyFileLoadParams function and we won't get here - */ - default: - Valid = false; - break; - } - - if (Valid == true) - { - CFE_EVS_SendEvent(MM_LD_MEM_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, - "Load Memory From File Command: Loaded %d bytes to " - "address %p from file '%s'", - (int)MM_AppData.HkPacket.BytesProcessed, (void *)DestAddress, - FileName); - } - - } /* end MM_VerifyFileLoadParams if */ - else - { /* - ** We don't need to increment the error counter here, it was done by the - ** MM_VerifyFileLoadParams routine when the error was first discovered. - ** We send this event as a supplemental message with the filename attached. + ** We don't need a default case, a bad MemType will get caught + ** in the MM_VerifyFileLoadParams function and we won't get here */ - CFE_EVS_SendEvent(MM_FILE_LOAD_PARAMS_ERR_EID, CFE_EVS_EventType_ERROR, - "Load file failed parameters check: File = '%s'", FileName); + default: + Valid = false; + break; } - } /* end MM_ResolveSymAddr if */ + if (Valid == true) + { + CFE_EVS_SendEvent(MM_LD_MEM_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, + "Load Memory From File Command: Loaded %d bytes to " + "address %p from file '%s'", + (int)MM_AppData.HkPacket.BytesProcessed, (void *)DestAddress, + FileName); + } + + } /* end MM_VerifyFileLoadParams if */ else { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", - MMFileHeader.SymAddress.SymName); + /* + ** We don't need to increment the error counter here, it was done by the + ** MM_VerifyFileLoadParams routine when the error was first discovered. + ** We send this event as a supplemental message with the filename attached. + */ + CFE_EVS_SendEvent(MM_FILE_LOAD_PARAMS_ERR_EID, CFE_EVS_EventType_ERROR, + "Load file failed parameters check: File = '%s'", FileName); } - } /* end ComputedCRC == MMFileHeader.Crc if */ + } /* end MM_ResolveSymAddr if */ else { - Valid = false; - CFE_EVS_SendEvent(MM_LOAD_FILE_CRC_ERR_EID, CFE_EVS_EventType_ERROR, - "Load file CRC failure: Expected = 0x%X Calculated = 0x%X File = '%s'", - (unsigned int)MMFileHeader.Crc, (unsigned int)ComputedCRC, FileName); + CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Symbolic address can't be resolved: Name = '%s'", + MMFileHeader.SymAddress.SymName); } - } /* end MM_ComputeCRCFromFile if */ + } /* end ComputedCRC == MMFileHeader.Crc if */ else { Valid = false; - CFE_EVS_SendEvent(MM_COMPUTECRCFROMFILE_ERR_EID, CFE_EVS_EventType_ERROR, - "MM_ComputeCRCFromFile error received: RC = 0x%08X File = '%s'", - (unsigned int)OS_Status, FileName); + CFE_EVS_SendEvent(MM_LOAD_FILE_CRC_ERR_EID, CFE_EVS_EventType_ERROR, + "Load file CRC failure: Expected = 0x%X Calculated = 0x%X File = '%s'", + (unsigned int)MMFileHeader.Crc, (unsigned int)ComputedCRC, FileName); } - } /* end MM_VerifyLoadFileSize */ - - /* - ** Don't need an 'else' here. MM_VerifyLoadFileSize will increment - ** the error counter and generate an event message if needed. - */ + } /* end MM_ComputeCRCFromFile if */ + else + { + Valid = false; + CFE_EVS_SendEvent(MM_COMPUTECRCFROMFILE_ERR_EID, CFE_EVS_EventType_ERROR, + "MM_ComputeCRCFromFile error received: RC = 0x%08X File = '%s'", + (unsigned int)OS_Status, FileName); + } - } /* end MM_ReadFileHeaders if */ + } /* end MM_VerifyLoadFileSize */ /* - ** Don't need an 'else' here. MM_ReadFileHeaders will increment + ** Don't need an 'else' here. MM_VerifyLoadFileSize will increment ** the error counter and generate an event message if needed. */ - /* Close the load file for all cases after the open call succeeds */ - OS_Status = OS_close(FileHandle); - if (OS_Status != OS_SUCCESS) - { - Valid = false; - CFE_EVS_SendEvent(MM_OS_CLOSE_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_close error received: RC = 0x%08X File = '%s'", (unsigned int)OS_Status, - FileName); - } + } /* end MM_ReadFileHeaders if */ - } /* end OS_OpenCreate if */ - else + /* + ** Don't need an 'else' here. MM_ReadFileHeaders will increment + ** the error counter and generate an event message if needed. + */ + + /* Close the load file for all cases after the open call succeeds */ + OS_Status = OS_close(FileHandle); + if (OS_Status != OS_SUCCESS) { Valid = false; - CFE_EVS_SendEvent(MM_OS_OPEN_ERR_EID, CFE_EVS_EventType_ERROR, - "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, CmdPtr->FileName); + CFE_EVS_SendEvent(MM_OS_CLOSE_ERR_EID, CFE_EVS_EventType_ERROR, + "OS_close error received: RC = 0x%08X File = '%s'", (unsigned int)OS_Status, + FileName); } - } /* end MM_VerifyCmdLength if */ + } /* end OS_OpenCreate if */ + else + { + Valid = false; + CFE_EVS_SendEvent(MM_OS_OPEN_ERR_EID, CFE_EVS_EventType_ERROR, + "OS_OpenCreate error received: RC = %d File = '%s'", (int)OS_Status, CmdPtr->FileName); + } return Valid; } @@ -725,67 +707,62 @@ 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) { - /* Resolve symbolic address */ - if (MM_ResolveSymAddr(&(DestSymAddress), &DestAddress) == true) + /* Run necessary checks on command parameters */ + if (MM_VerifyLoadDumpParams(DestAddress, CmdPtr->MemType, CmdPtr->NumOfBytes, MM_VERIFY_FILL) == true) { - /* Run necessary checks on command parameters */ - if (MM_VerifyLoadDumpParams(DestAddress, CmdPtr->MemType, CmdPtr->NumOfBytes, MM_VERIFY_FILL) == true) + switch (CmdPtr->MemType) { - switch (CmdPtr->MemType) - { - case MM_RAM: - case MM_EEPROM: - CmdResult = MM_FillMem(DestAddress, CmdPtr); - break; + case MM_RAM: + case MM_EEPROM: + CmdResult = MM_FillMem(DestAddress, CmdPtr); + break; #ifdef MM_OPT_CODE_MEM32_MEMTYPE - case MM_MEM32: - CmdResult = MM_FillMem32(DestAddress, CmdPtr); - break; + case MM_MEM32: + CmdResult = MM_FillMem32(DestAddress, CmdPtr); + break; #endif #ifdef MM_OPT_CODE_MEM16_MEMTYPE - case MM_MEM16: - CmdResult = MM_FillMem16(DestAddress, CmdPtr); - break; + case MM_MEM16: + CmdResult = MM_FillMem16(DestAddress, CmdPtr); + break; #endif #ifdef MM_OPT_CODE_MEM8_MEMTYPE - case MM_MEM8: - CmdResult = MM_FillMem8(DestAddress, CmdPtr); - break; + case MM_MEM8: + CmdResult = MM_FillMem8(DestAddress, CmdPtr); + break; #endif - /* - ** We don't need a default case, a bad MemType will get caught - ** in the MM_VerifyLoadDumpParams function and we won't get here - */ - default: - CmdResult = false; - break; - } + /* + ** We don't need a default case, a bad MemType will get caught + ** in the MM_VerifyLoadDumpParams function and we won't get here + */ + default: + CmdResult = false; + break; + } - if (MM_AppData.HkPacket.LastAction == MM_FILL) - { - CFE_EVS_SendEvent(MM_FILL_INF_EID, CFE_EVS_EventType_INFORMATION, - "Fill Memory Command: Filled %d bytes at address: %p with pattern: 0x%08X", - (int)MM_AppData.HkPacket.BytesProcessed, (void *)DestAddress, - (unsigned int)MM_AppData.HkPacket.DataValue); - } + if (MM_AppData.HkPacket.LastAction == MM_FILL) + { + CFE_EVS_SendEvent(MM_FILL_INF_EID, CFE_EVS_EventType_INFORMATION, + "Fill Memory Command: Filled %d bytes at address: %p with pattern: 0x%08X", + (int)MM_AppData.HkPacket.BytesProcessed, (void *)DestAddress, + (unsigned int)MM_AppData.HkPacket.DataValue); } } - else - { - CFE_EVS_SendEvent(MM_SYMNAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Symbolic address can't be resolved: Name = '%s'", DestSymAddress.SymName); - } + } + else + { + 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,