/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void PrintHKPacket (uint8 source, void *packet) { FM_HousekeepingPkt_t *HousekeepingPkt = (FM_HousekeepingPkt_t *) packet; /* Output the FM housekeeping data */ UTF_put_text("\nFM HOUSEKEEPING DATA:\n"); UTF_put_text("CommandCounter = %d\n", HousekeepingPkt->CommandCounter); UTF_put_text("CommandErrCounter = %d\n", HousekeepingPkt->CommandErrCounter); UTF_put_text("NumOpenFiles = %d\n", HousekeepingPkt->NumOpenFiles); UTF_put_text("ChildCmdCounter = %d\n", HousekeepingPkt->ChildCmdCounter); UTF_put_text("ChildCmdErrCounter = %d\n", HousekeepingPkt->ChildCmdErrCounter); UTF_put_text("ChildCmdWarnCounter = %d\n", HousekeepingPkt->ChildCmdWarnCounter); UTF_put_text("ChildQueueCount = %d\n", HousekeepingPkt->ChildQueueCount); UTF_put_text("\n"); } /* End of PrintHKPacket() */
/****************************************************************************** ** Function: UTF_arg2uint() ** ** Purpose: ** This function converts a string to a unsigned long value. */ unsigned long UTF_arg2uint(char *val) { unsigned long ret_val; char *end; ret_val = strtoul(val, &end, 0); if (*end != 0) UTF_put_text("UTF Warning: %s at end of Unsigned Integer Value %s ignored.\n", end, val); return ret_val; }
int32 UTF_CFE_SB_Set_Api_Return_Code(int32 ApiIndex, int32 ReturnCode) { /* Check that ApiIndex is in the valid range */ if ( (ApiIndex >= NUM_OF_CFE_SB_API_PROCS ) || (ApiIndex < 0 ) ) { UTF_put_text("UTF Error: Invalid ApiIndex %d passed to UTF_CFE_SB_Set_Api_Return_Code\n", ApiIndex); return -1; } /* If index is valid, assign return value and report action */ cfe_sb_api_return_value[ApiIndex] = ReturnCode; if (ReturnCode == UTF_CFE_USE_DEFAULT_RETURN_CODE) { UTF_put_text("UTF Info: Return code for CFE SB Api #%d returned to default\n", ApiIndex); } else { UTF_put_text("UTF Info: Return value for CFE SB Api #%d set to %lx\n", ApiIndex, ReturnCode); } return CFE_SUCCESS; }
void UTF_SCRIPT_LoadTableFromGround(int argc,char *argv[]) { int debug = 1; int32 status; char Table_Name[30], File_Name[50]; if (argc != 3) { UTF_error("Error: Read %d args w/script cmd LOAD_TABLE_FROM_GROUND. Expected 2.\n", argc -1 ); UTF_exit(); } strcpy(Table_Name,argv[1]); strcpy(File_Name,argv[2]); if (debug) UTF_put_text("UTF_SCRIPT_LoadTableFromGround called for Table_Name = '%s', File_Name = '%s'\n", Table_Name, File_Name); status = UTF_TBL_LoadTableFromGround(Table_Name, File_Name); if (debug) UTF_put_text("UTF_TBL_LoadTableFromGround returned %d", status); return; }
/* ** Function Prologue ** ** Function Name: CFE_EVS_SendTimedEvent ** ** Purpose: This routine sends a timed event message, with message ID containing the ** current processor/box and task ID as well as the eventID. ** ** Assumptions and Notes: ** Original routine returns CFE_EVS_ERR or CFE_EVS_ERR_NONE. */ int32 CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, uint16 EventID, uint16 EventType, const char *Spec, ... ) { char BigBuf[CFE_EVS_MAX_MESSAGE_LENGTH]; char GTBigBuf[CFE_EVS_MAX_MESSAGE_LENGTH + 2]; va_list Ptr; CFE_EVS_Packet_t EVS_Packet; /* Handle Preset Return Code */ if (cfe_evs_api_return_value[CFE_EVS_SENDTIMEDEVENT_PROC] != UTF_CFE_USE_DEFAULT_RETURN_CODE) { return cfe_evs_api_return_value[CFE_EVS_SENDTIMEDEVENT_PROC]; } /* Initialize CCSDS event packet */ CFE_SB_InitMsg(&(EVS_Packet), CFE_EVS_EVENT_MSG_MID, sizeof(CFE_EVS_Packet_t), FALSE); /* Set the packet timestamp */ CFE_SB_SetMsgTime((CFE_SB_Msg_t *) &EVS_Packet, Time); EVS_Packet.Message[0] = '\0'; /* Copy message to event packet if long format is enabled */ va_start(Ptr, Spec); vsnprintf(GTBigBuf, CFE_EVS_MAX_MESSAGE_LENGTH +2, Spec, Ptr); va_end(Ptr); if (strlen(GTBigBuf) > CFE_EVS_MAX_MESSAGE_LENGTH) { UTF_put_text ("Max Event Message Size Exceeded. Permitted %d; Actual %d\n", CFE_EVS_MAX_MESSAGE_LENGTH, strlen(GTBigBuf)); } strncpy(BigBuf,GTBigBuf,CFE_EVS_MAX_MESSAGE_LENGTH); UTF_put_text("TIMED EVENT: %s\n", BigBuf); return CFE_SUCCESS; } /* End CFE_EVS_SendTimedEvent */
int main(void) { /*****************************************************/ /* Need to show that CFE_ES_MemHandle_t is available */ /*****************************************************/ CFE_ES_MemHandle_t MyMemHandle; /*****************************************************/ /* Need to show that CFE_EVS_Packet_t is available */ /*****************************************************/ CFE_EVS_Packet_t MyEVSPacket; uint8 *MemPtr; int32 retval; uint32 HandlePtr; /********************************/ /* Set up output file */ /********************************/ UTF_set_output_filename("utf_test9.ActualOutput"); MyMemHandle = 5; strcpy(MyEVSPacket.Message, "Very Important EVS Packet Message"); UTF_put_text("MyMemHandle = %d\n", MyMemHandle); UTF_put_text("MyEVSPacket.Message = <%s>\n",MyEVSPacket.Message); /*****************************************************/ /* Need to show that CFE_ES_PoolCreate is available */ /*****************************************************/ MemPtr = (uint8 *)malloc(2000); retval = CFE_ES_PoolCreate(&HandlePtr, MemPtr, 1000); UTF_put_text("Call to CFE_ES_PoolCreate returned %d\n", retval); return 0; }
/*-------------------------------------------------------------------------------------- Name: UTF_SetSymbolTableEntry Purpose: Set the next available entry to the contents of the argument Parameters: UTF_SymbolTable_t - the entry contents to copy to the Symbol Table Returns: OS_ERROR if the symbol could not be added to the Symbol Table OS_SUCCESS if the symbol was copied to the symbol table OS_INVALID_POINTER if the symbol name is null OS_ERR_NAME_TOO_LONG if the supplied symbol name contains more characters than allowed The address of the symbol will be stored in the pointer that is passed in. ---------------------------------------------------------------------------------------*/ int32 UTF_SetSymbolTableEntry (UTF_SymbolTable_t entry) { int32 returnStatus=OS_SUCCESS; boolean openSlotFound=FALSE; int i; /* Check argument validity */ if (strlen(entry.symbolName) == 0) { UTF_put_text("UTF Info: Null string passed to UTF_SetSymbolTableEntry\n"); return OS_INVALID_POINTER; } if (strlen(entry.symbolName) >= OS_MAX_API_NAME) { UTF_put_text("UTF Info: Symbol Name too long\n"); return (OS_ERR_NAME_TOO_LONG); } /* Copy the entry into the next available slot */ for (i=0; i<UTF_MAX_SYMBOLS; i++) { if (symbolTbl[i].RecordUsed == FALSE) { openSlotFound = TRUE; strcpy(symbolTbl[i].symbolName,entry.symbolName); symbolTbl[i].symbolAddr = entry.symbolAddr; symbolTbl[i].RecordUsed = TRUE; break; } } /* If a slot was not found, the Symbol Table is full */ if (openSlotFound == FALSE) returnStatus = OS_ERROR; return(returnStatus); }/* end UTF_SetSymbolTableEntry */
/****************************************************************************** ** Function: UTF_put_packet() ** ** Purpose: ** Display a packet. */ void UTF_put_packet (uint8 source, CCSDS_PriHdr_t *packet) { if (packet_output_disabled[CCSDS_RD_SID(*packet)]) return; if (custom_packet_handlers[CCSDS_RD_SID(*packet)]) custom_packet_handlers[CCSDS_RD_SID(*packet)](source, packet); else if (default_packet_handler) { (*default_packet_handler)(source, packet); } else { UTF_put_packet_header (source, packet); if (!packet_output_header_only [CCSDS_RD_SID(*packet)]) { UTF_put_text("PKT:"); UTF_put_data(((void *)packet), (uint16)(CCSDS_RD_LEN(*packet)), UTF_AS_WORD); } else { UTF_put_text("\n"); } } }
int main(void) { OS_time_t OS_time; double double_time[10]={0.57, 0.58, 256.51, 256.52, 256.53, 256.57, 256.58, 0.009999,0.009996, 0.009994}; int i; /********************************/ /* Set up output file */ /********************************/ UTF_set_output_filename("utf_test8.ActualOutput"); UTF_put_text("** Test time hook capability **\n"); UTF_put_text("** Set sim time to 500. **\n"); UTF_set_sim_time(500.0); OS_GetLocalTime(&OS_time); UTF_put_text("OS_GetLocalTime returned %lu. Expected 500.\n", OS_time.seconds); UTF_OSAPI_set_function_hook(OS_GETLOCALTIME_HOOK, time_hook); UTF_put_text("** Call OS_GetLocalTime 3 times. Expect return values of 501,502,503. **\n"); OS_GetLocalTime(&OS_time); UTF_put_text("OS_GetLocalTime returned %lu.\n", OS_time.seconds); OS_GetLocalTime(&OS_time); UTF_put_text("OS_GetLocalTime returned %lu.\n", OS_time.seconds); OS_GetLocalTime(&OS_time); UTF_put_text("OS_GetLocalTime returned %lu.\n", OS_time.seconds); UTF_put_text("** Test UTF_double_to_hwtime **\n"); for (i=0;i<=9;i++) { OS_time = UTF_double_to_hwtime(double_time[i]); UTF_put_text("UTF_double_to_hwtime returned %lu microsecs for %lf input.\n", OS_time.microsecs, double_time[i]); } exit(0); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 UTF_CFE_SB_Use_Default_Api_Return_Code(int32 ApiIndex) { int32 Success; /* Check that ApiIndex is in the valid range */ if ( (ApiIndex >= NUM_OF_CFE_SB_API_PROCS ) || (ApiIndex < 0 ) ) { UTF_put_text("UTF Error: Invalid ApiIndex %d passed to UTF_CFE_SB_Use_Default_Api_Return_Code\n", ApiIndex); return -1; } /* If index is valid, assign return value and report action */ Success = UTF_CFE_SB_Set_Api_Return_Code(ApiIndex, UTF_CFE_USE_DEFAULT_RETURN_CODE); return Success; }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void PrintListPacket (uint8 source, void *packet) { FM_DirListPkt_t *DirListPkt = (FM_DirListPkt_t *) packet; int i; /* Output the FM housekeeping data */ UTF_put_text("\nFM DIRECTORY LIST PACKET:\n"); UTF_put_text("DirName = %s\n", DirListPkt->DirName); UTF_put_text("TotalFiles = %d\n", DirListPkt->TotalFiles); UTF_put_text("PacketFiles = %d\n", DirListPkt->PacketFiles); UTF_put_text("FirstFile = %d\n", DirListPkt->FirstFile); for (i = 0; i < DirListPkt->PacketFiles; i++) UTF_put_text("File = %s, Size = %d, Time = %d\n", DirListPkt->FileList[i].EntryName, DirListPkt->FileList[i].EntrySize, DirListPkt->FileList[i].ModifyTime); UTF_put_text("\n"); } /* End of PrintListPacket() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void PrintInfoPacket (uint8 source, void *packet) { FM_FileInfoPkt_t *FileInfoPkt = (FM_FileInfoPkt_t *) packet; char *ps; /* Output the FM housekeeping data */ UTF_put_text("\nFM FILE INFO STATUS PACKET:\n"); if (FileInfoPkt->FileStatus == FM_NAME_IS_INVALID) ps = "invalid name"; if (FileInfoPkt->FileStatus == FM_NAME_IS_NOT_IN_USE) ps = "does not exist"; if (FileInfoPkt->FileStatus == FM_NAME_IS_FILE_OPEN) ps = "open file"; if (FileInfoPkt->FileStatus == FM_NAME_IS_FILE_CLOSED) ps = "closed file"; if (FileInfoPkt->FileStatus == FM_NAME_IS_DIRECTORY) ps = "directory"; UTF_put_text("FileStatus = %d, %s\n", FileInfoPkt->FileStatus, ps); UTF_put_text("CRC_Computed = %d\n", FileInfoPkt->CRC_Computed); UTF_put_text("CRC = 0x%08X\n", FileInfoPkt->CRC); UTF_put_text("FileSize = %d\n", FileInfoPkt->FileSize); UTF_put_text("LastModifiedTime = %d\n", FileInfoPkt->LastModifiedTime); UTF_put_text("Filename = %s\n", FileInfoPkt->Filename); UTF_put_text("\n"); } /* End of PrintInfoPacket() */
void TT_AccessCurrentData(void) { void *TblPointer; int32 Status; CFE_TBL_Manage(TT4_AppData.TblHandle); Status = CFE_TBL_GetAddress(&TblPointer,TT4_AppData.TblHandle); if (Status == CFE_TBL_INFO_UPDATED) { TT4_AppData.HkPacket.UpdateCount++; } UTF_put_text("The current table values are:%d %d %d %d\n", *(int8*)TblPointer,*(int8*)(TblPointer+1), *(int8*)(TblPointer+2),*(int8*)(TblPointer+3)); Status = CFE_TBL_ReleaseAddress(TT4_AppData.TblHandle); } /*TT_AccessCurrentData*/
/****************************************************************************** ** Function: UTF_write_sim_address() ** ** Purpose: ** This function writes the data contained in a buffer pointed to by data_ptr ** to a simulated hardware address. */ char UTF_write_sim_address(unsigned long int address, unsigned short int num_bytes, void *data_ptr) { void *sim_memory_ptr; if (write_sim_hook == NULL || write_sim_hook(address, num_bytes, data_ptr) == FALSE) { sim_memory_ptr = UTF_sim_address_lookup(address, num_bytes); if (sim_memory_ptr != NULL) { memcpy(sim_memory_ptr, data_ptr, num_bytes); return TRUE; } else { UTF_put_text("Sim Mem Memory Address Not Found 0x%8x\n", address); return FALSE; } } return TRUE; }
int32 CFE_PSP_EepromWrite16(uint32 Address, uint16 Data) { int32 Status; /* Handle the Function Hook */ if (UTF_PSP_HookTable.CFE_PSP_EepromWrite16) return(UTF_PSP_HookTable.CFE_PSP_EepromWrite16(Address,Data)); /* Check that the address is on a 16 bit boundary; the flight code will return the CFE_PSP_ERROR_ADDRESS_MISALIGNED return code. */ if ((Address % 2) != 0) { /* Address is not on 16 bit boundary */ UTF_put_text("Address Not On 16 Bit Boundary: 0x%08x\n", Address); return (CFE_PSP_ERROR); } else { /* Address is on 16 bit boundary */ Status = UTF_write_sim_address(Address, 2, &Data); if(Status == FALSE) return(CFE_PSP_ERROR); else return(CFE_PSP_SUCCESS); } }
/* ** Function Prologue ** ** Function Name: CFE_EVS_SendEventWithAppID ** ** Purpose: This routine sends an event message, with message ID containing the current ** processor/box and task ID as well as the eventID. Also forces the user to ** supply an AppID to be sent with the message. ** ** Assumptions and Notes: */ int32 CFE_EVS_SendEventWithAppID (uint16 EventID, uint16 EventType,uint32 AppID, const char *Spec, ... ) { int32 Status = CFE_SUCCESS; char BigBuf[CFE_EVS_MAX_MESSAGE_LENGTH]; char GTBigBuf[CFE_EVS_MAX_MESSAGE_LENGTH + 2]; va_list Ptr; /* Handle Preset Return Code */ if (cfe_evs_api_return_value[CFE_EVS_SENDEVENTWITHAPPID_PROC] != UTF_CFE_USE_DEFAULT_RETURN_CODE) { return cfe_evs_api_return_value[CFE_EVS_SENDEVENTWITHAPPID_PROC]; } /* Assume the given AppID is legit */ if (Status == CFE_SUCCESS) { /* Copy message to event packet */ va_start(Ptr, Spec); vsnprintf(GTBigBuf, CFE_EVS_MAX_MESSAGE_LENGTH +2, Spec, Ptr); va_end(Ptr); if (strlen(GTBigBuf) > CFE_EVS_MAX_MESSAGE_LENGTH) { UTF_put_text ("Max Event Message Size Exceeded. Permitted %d; Actual %d\n", CFE_EVS_MAX_MESSAGE_LENGTH, strlen(GTBigBuf)); } strncpy(BigBuf,GTBigBuf,CFE_EVS_MAX_MESSAGE_LENGTH); if (EventType == CFE_EVS_DEBUG) UTF_put_text("DEBUG EVENT ID=%d %s\n",EventID, BigBuf); else if (EventType == CFE_EVS_INFORMATION) UTF_put_text("INFO EVENT ID=%d %s\n",EventID, BigBuf); else if (EventType == CFE_EVS_ERROR) UTF_put_text("ERROR EVENT ID=%d %s\n",EventID, BigBuf); else if (EventType == CFE_EVS_CRITICAL) UTF_put_text("CRITICAL EVENT ID=%d %s\n",EventID, BigBuf); else UTF_put_text("Invalid Event Type %d ID=%d %s\n",EventType,EventID, BigBuf); } return Status; } /* End CFE_EVS_SendEventWithAppID */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Test_DumpInEvent(void) { MM_DumpInEventCmd_t CmdMsg; /* Setup the test message header */ CFE_SB_InitMsg(&CmdMsg, MM_CMD_MID, sizeof(MM_DumpInEventCmd_t), TRUE); UTF_put_text("**********************************************\n"); UTF_put_text("* Memory Dump In Event Message Tests *\n"); UTF_put_text("**********************************************\n"); UTF_put_text("\n"); /* ** Test bad symbol name */ UTF_put_text("Test Dump In Event With Bad Symbol Name \n"); UTF_put_text("----------------------------------------\n"); strcpy(CmdMsg.SrcSymAddress.SymName, "BadSymName"); CmdMsg.SrcSymAddress.Offset = 0; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_RAM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test dump size zero */ UTF_put_text("Test Dump In Event With Dump Size Zero \n"); UTF_put_text("---------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = 0; CmdMsg.MemType = MM_RAM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test dump size too large */ UTF_put_text("Test Dump In Event With Dump Size Too Big \n"); UTF_put_text("------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES + 10; CmdMsg.MemType = MM_RAM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test dump with invalid RAM address */ UTF_put_text("Test Dump In Event With Invalid RAM Address \n"); UTF_put_text("--------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_BAD_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_RAM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test dump with invalid EEPROM address */ UTF_put_text("Test Dump In Event With Invalid EEPROM Address \n"); UTF_put_text("-----------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_BAD_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_EEPROM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM32 dump with misaligned address */ UTF_put_text("Test MEM32 Dump In Event With Misaligned Address \n"); UTF_put_text("-------------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR + 3; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM32; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM32 dump with misaligned data size */ UTF_put_text("Test MEM32 Dump In Event With Misaligned Data Size \n"); UTF_put_text("---------------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES - 3; CmdMsg.MemType = MM_MEM32; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM32 dump with invalid address */ UTF_put_text("Test MEM32 Dump In Event With Invalid Address \n"); UTF_put_text("----------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_BAD_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM32; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM16 dump with misaligned address */ UTF_put_text("Test MEM16 Dump In Event With Misaligned Address \n"); UTF_put_text("-------------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR + 3; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM16; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM16 dump with misaligned data size */ UTF_put_text("Test MEM16 Dump In Event With Misaligned Data Size \n"); UTF_put_text("---------------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES - 3; CmdMsg.MemType = MM_MEM16; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM16 dump with invalid address */ UTF_put_text("Test MEM16 Dump In Event With Invalid Address \n"); UTF_put_text("----------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_BAD_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM16; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test MEM8 dump with invalid address */ UTF_put_text("Test MEM8 Dump In Event With Invalid Address \n"); UTF_put_text("---------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_BAD_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM8; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test dump with invalid memory type */ UTF_put_text("Test Dump In Event With Invalid Memory Type \n"); UTF_put_text("--------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = 0xFF; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid RAM dump of maximum size */ UTF_put_text("Test RAM Dump In Event Max Bytes \n"); UTF_put_text("---------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_RAM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid RAM dump less than maximum size */ UTF_put_text("Test RAM Dump In Event Less Than Max Bytes \n"); UTF_put_text("-------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES / 2; CmdMsg.MemType = MM_RAM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid EEPROM dump of maximum size */ UTF_put_text("Test EEPROM Dump In Event Max Bytes \n"); UTF_put_text("------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_EEPROM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_EEPROM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid EEPROM dump less than maximum size */ UTF_put_text("Test EEPROM Dump In Event Less Than Max Bytes \n"); UTF_put_text("----------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_EEPROM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES / 2; CmdMsg.MemType = MM_EEPROM; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid MEM32 dump of maximum size */ UTF_put_text("Test MEM32 Dump In Event Max Bytes \n"); UTF_put_text("-----------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM32; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid MEM32 dump less than maximum size */ UTF_put_text("Test MEM32 Dump In Event Less Than Max Bytes \n"); UTF_put_text("---------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES / 2; CmdMsg.MemType = MM_MEM32; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid MEM16 dump of maximum size */ UTF_put_text("Test MEM16 Dump In Event Max Bytes \n"); UTF_put_text("-----------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM16; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid MEM16 dump less than maximum size */ UTF_put_text("Test MEM16 Dump In Event Less Than Max Bytes \n"); UTF_put_text("---------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES / 2; CmdMsg.MemType = MM_MEM16; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid MEM8 dump of maximum size */ UTF_put_text("Test MEM8 Dump In Event Max Bytes \n"); UTF_put_text("----------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES; CmdMsg.MemType = MM_MEM8; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid MEM8 dump less than maximum size */ UTF_put_text("Test MEM8 Dump In Event Less Than Max Bytes \n"); UTF_put_text("--------------------------------------------\n"); CmdMsg.SrcSymAddress.SymName[0] = '\0'; CmdMsg.SrcSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_DUMP_INEVENT_BYTES / 2; CmdMsg.MemType = MM_MEM8; MM_DumpInEventCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); } /* end Test_DumpInEvent */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int main(void) { char AppName[10]; UTF_SymbolTable_t UTF_Symbol; strcpy(AppName, "MM"); /* ** Set up to read in script */ UTF_add_input_file(MM_CMD_PIPE, "mm_utf_cmds.in"); MM_AppData.CmdPipe = MM_CMD_PIPE; /* Hook for application code */ /* ** Set up output file and HK packet handler */ UTF_set_output_filename("mm_utf_test.out"); UTF_set_packet_handler(MM_HK_TLM_MID, (utf_packet_handler)PrintHKPacket); /* ** Set up simulated memory for loads and dumps */ UTF_add_sim_address(SIM_RAM_MEM_ADDR, SIM_RAM_MEM_SIZE, "MM_RAM_ADDRESS_SPACE"); UTF_add_sim_address(SIM_EEPROM_MEM_ADDR, SIM_EEPROM_MEM_SIZE, "MM_EEPROM_ADDRESS_SPACE"); /* ** Add these ranges to the OSAL memory table so the CFE_PSP_MemValidateRange ** routine won't barf on them. We set these ranges much bigger than we're ** going to need so we can test bounds checking in MM and not ** CFE_PSP_MemValidateRange. */ CFE_PSP_MemRangeSet(0, CFE_PSP_MEM_RAM, SIM_RAM_MEM_ADDR, (MM_MAX_LOAD_FILE_DATA_RAM * 2), CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_ATTR_READWRITE); CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_EEPROM, SIM_EEPROM_MEM_ADDR, (MM_MAX_LOAD_FILE_DATA_EEPROM * 10), CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_ATTR_READWRITE); /* ** Setup the UTF symbol table structures */ UTF_InitSymbolTable(); strcpy(UTF_Symbol.symbolName, "GoodSymName"); UTF_Symbol.symbolAddr = SIM_RAM_MEM_ADDR; UTF_SetSymbolTableEntry(UTF_Symbol); /* ** Initialize time data structures */ UTF_init_sim_time(0.0); UTF_OSAPI_set_function_hook(OS_GETLOCALTIME_HOOK, TimeHook); /* ** Initialize the PSP EEPROM Write Ena/Dis return status */ UTF_PSP_Set_Api_Return_Code(CFE_PSP_EEPROMWRITEENA_PROC, CFE_PSP_SUCCESS); UTF_PSP_Set_Api_Return_Code(CFE_PSP_EEPROMWRITEDIS_PROC, CFE_PSP_SUCCESS); /* ** Register app MM with executive services. */ UTF_ES_InitAppRecords(); UTF_ES_AddAppRecord("MM",0); CFE_ES_RegisterApp(); CFE_EVS_Register(NULL, 0, CFE_EVS_BINARY_FILTER); /* ** Initialize table services data structures, though we ** don't use any tables for these tests */ CFE_ES_CDS_EarlyInit(); CFE_TBL_EarlyInit(); /* ** Add an entry to the volume table */ UTF_add_volume("/", "ram", FS_BASED, FALSE, FALSE, TRUE, "RAM", "/ram", 0); /* ** Add this hook so we can force a software bus read error ** in our command input file that will make the application exit */ UTF_add_special_command("SET_SB_RETURN_CODE", UTF_SCRIPT_SB_Set_Api_Return_Code); UTF_add_special_command("SET_PSP_RETURN_CODE", UTF_SCRIPT_PSP_Set_Api_Return_Code); /* ** Initialize the CRC value for our test data set */ MM_TestDataSetCRC = CFE_ES_CalculateCRC(MM_TestDataSet, sizeof(MM_TestDataSet), 0, CFE_ES_DEFAULT_CRC); /* ** This is a function stub in cfs_utils.c that does nothing, but ** by calling it here we can increase our coverage statistics, so ** why not? */ CFS_LibInit(); /* ** Call test functions that invoke MM code directly */ printf("***UTF MM DRIVER TESTS START***\n\n"); UTF_put_text("\n"); UTF_put_text("***UTF MM DRIVER TESTS START***"); UTF_put_text("\n\n"); Test_Pokes(); Test_Peeks(); Test_LoadWID(); Test_DumpInEvent(); Test_LoadFromFile(); Test_DumpToFile(); Test_Fill(); Test_SymLookup(); Test_SymTblDump(); printf("***UTF MM DRIVER TESTS END***\n\n"); UTF_put_text("\n"); UTF_put_text("***UTF MM DRIVER TESTS END***"); UTF_put_text("\n\n"); /* ** Call Application Main procedure that will test command ** processing through the software bus command pipe via ** the mm_utf_cmds.in command script */ printf("***UTF MM CMD PIPE TESTS START***\n\n"); UTF_put_text("\n"); UTF_put_text("***UTF MM CMD PIPE TESTS START***"); UTF_put_text("\n\n"); MM_AppMain(); printf("***UTF MM CMD PIPE TESTS END***\n\n"); UTF_put_text("\n"); UTF_put_text("***UTF MM CMD PIPE TESTS END***"); UTF_put_text("\n\n"); /* ** These tests force some CFE api error returns ** during MM initialization. This increases ** the gcov coverage metrics for the app startup ** code. */ printf("***UTF MM APP INIT TESTS START***\n\n"); UTF_put_text("\n"); UTF_put_text("***UTF MM APP INIT TESTS START***"); UTF_put_text("\n\n"); UTF_put_text("\n"); UTF_put_text("Test App Init Error conditions \n"); UTF_put_text("-------------------------------\n"); /* ** Set trigger so CFE_EVS_Register returns something ** other than CFE_SUCCESS (0). Then call app main, this ** should make the app init fail. */ UTF_CFE_EVS_Set_Api_Return_Code(CFE_EVS_REGISTER_PROC, 0xc2000003L); MM_AppMain(); /* Go back to "normal" behavior */ UTF_CFE_EVS_Use_Default_Api_Return_Code(CFE_EVS_REGISTER_PROC); /* ** Set trigger so CFE_SB_CreatePipe returns an error code */ UTF_CFE_SB_Set_Api_Return_Code(CFE_SB_CREATEPIPE_PROC, 0xca000004L); MM_AppMain(); UTF_CFE_SB_Use_Default_Api_Return_Code(CFE_SB_CREATEPIPE_PROC); /* ** Set trigger so CFE_SB_Subscribe returns an error code */ UTF_CFE_SB_Set_Api_Return_Code(CFE_SB_SUBSCRIBE_PROC, 0xca000009L); MM_AppMain(); UTF_CFE_SB_Use_Default_Api_Return_Code(CFE_SB_SUBSCRIBE_PROC); /* ** Hook our own custom function to CFE_SB_Subscribe so we can ** trigger an error return on the SECOND call in MM_AppInit */ UTF_SB_set_function_hook(CFE_SB_SUBSCRIBE_HOOK, (void *)&CFE_SB_SubscribeHook); MM_AppMain(); printf("***UTF MM APP INIT TESTS END***\n\n"); UTF_put_text("\n"); UTF_put_text("***UTF MM APP INIT TESTS END***"); UTF_put_text("\n\n"); return 0; } /* end main */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int main(void) { /* ** API function hook handlers */ UTF_SB_set_function_hook(CFE_SB_SUBSCRIBE_HOOK, (void *)&CFE_SB_SubscribeHook); /* ** Set up output file and HK packet handler */ UTF_set_output_filename("fm_utest.out"); UTF_set_packet_handler(FM_HK_TLM_MID, (utf_packet_handler)PrintHKPacket); UTF_set_packet_handler(FM_DIR_LIST_TLM_MID, (utf_packet_handler)PrintListPacket); UTF_set_packet_handler(FM_FILE_INFO_TLM_MID, (utf_packet_handler)PrintInfoPacket); UTF_set_packet_handler(FM_OPEN_FILES_TLM_MID, (utf_packet_handler)PrintOpenPacket); UTF_set_packet_handler(FM_FREE_SPACE_TLM_MID, (utf_packet_handler)PrintFreePacket); /* ** Initialize time data structures */ UTF_init_sim_time(0.0); /* ** Initialize ES application data */ UTF_ES_InitAppRecords(); UTF_ES_AddAppRecord("FM",0); CFE_ES_RegisterApp(); /* ** Initialize CDS and table services data structures */ CFE_ES_CDS_EarlyInit(); CFE_TBL_EarlyInit(); CFE_EVS_Register(NULL, 0, 0); /* * Setup the virtual/physical file system mapping... * * The following local machine directory structure is required: * * ... fm/fsw/unit_test <-- this is the current working directory * ... fm/fsw/unit_test/ram <-- physical location for virtual disk "/ram" */ UTF_add_volume("/", "ram", FS_BASED, FALSE, FALSE, TRUE, "RAM", "/ram", 0); OS_mkdir("/ram/sub",0); OS_mkdir("/ram/sub2",0); OS_mkdir("/ram/sub2/sub22",0); OS_mkdir("/ram/sub3",0); /* ** Run FM application unit tests */ UT_TotalTestCount = 0; UT_TotalFailCount = 0; UTF_put_text("\n*** FM -- Testing fm_app.c ***\n"); Test_app(); UTF_put_text("\n*** FM -- Testing fm_cmds.c ***\n"); Test_cmds(); UTF_put_text("\n*** FM -- Testing fm_cmd_utils.c ***\n"); Test_utils(); UTF_put_text("\n*** FM -- Testing fm_child.c ***\n"); Test_child(); UTF_put_text("\n*** FM -- Testing fm_tbl.c ***\n"); Test_tbl(); UTF_put_text("\n*** FM -- Total test count = %d, total test errors = %d\n\n", UT_TotalTestCount, UT_TotalFailCount); /* ** Remove directories created for these tests... */ OS_rmdir("/ram/sub3"); OS_rmdir("/ram/sub2/sub22"); OS_rmdir("/ram/sub2"); OS_rmdir("/ram/sub"); /* ** Invoke the main loop test now because the program will end ** when the last entry in the SB sim input file is read. */ UTF_CFE_ES_Set_Api_Return_Code(CFE_ES_RUNLOOP_PROC, TRUE); FM_AppMain(); UTF_CFE_ES_Use_Default_Api_Return_Code(CFE_ES_RUNLOOP_PROC); return 0; } /* End of main() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void PrintLocalHKVars (void) { /* Output the LRO MM housekeeping data */ UTF_put_text("MM HOUSEKEEPING DATA:\n"); UTF_put_text(" Command Counter = %d\n", MM_AppData.CmdCounter); UTF_put_text(" Command Error Counter = %d\n", MM_AppData.ErrCounter); switch(MM_AppData.LastAction) { case MM_NOACTION: UTF_put_text(" Last Action = MM_NOACTION\n"); break; case MM_PEEK: UTF_put_text(" Last Action = MM_PEEK\n"); break; case MM_POKE: UTF_put_text(" Last Action = MM_POKE\n"); break; case MM_LOAD_FROM_FILE: UTF_put_text(" Last Action = MM_LOAD_FROM_FILE\n"); break; case MM_LOAD_WID: UTF_put_text(" Last Action = MM_LOAD_WID\n"); break; case MM_DUMP_TO_FILE: UTF_put_text(" Last Action = MM_DUMP_TO_FILE\n"); break; case MM_DUMP_INEVENT: UTF_put_text(" Last Action = MM_DUMP_INEVENT\n"); break; case MM_FILL: UTF_put_text(" Last Action = MM_FILL\n"); break; case MM_SYM_LOOKUP: UTF_put_text(" Last Action = MM_SYM_LOOKUP\n"); break; case MM_SYMTBL_SAVE: UTF_put_text(" Last Action = MM_SYMTBL_SAVE\n"); break; default: UTF_put_text(" Last Action = %d\n", MM_AppData.LastAction); break; } switch(MM_AppData.MemType) { case MM_NOMEMTYPE: UTF_put_text(" Memory Type = MM_NOMEMTYPE\n"); break; case MM_RAM: UTF_put_text(" Memory Type = MM_RAM\n"); break; case MM_EEPROM: UTF_put_text(" Memory Type = MM_EEPROM\n"); break; case MM_MEM8: UTF_put_text(" Memory Type = MM_MEM8\n"); break; case MM_MEM16: UTF_put_text(" Memory Type = MM_MEM16\n"); break; case MM_MEM32: UTF_put_text(" Memory Type = MM_MEM32\n"); break; default: UTF_put_text(" Memory Type = %d\n", MM_AppData.MemType); break; } UTF_put_text(" Address = 0x%08X\n", MM_AppData.Address); UTF_put_text(" Data Value = 0x%08X\n", MM_AppData.DataValue); UTF_put_text(" Bytes Processed = %d\n", MM_AppData.BytesProcessed); UTF_put_text(" File Name = '%s'\n", MM_AppData.FileName); } /* end PrintLocalHKVars */
/* ** Function Prologue ** ** Function Name: CFE_EVS_SendEvent ** ** Purpose: This routine sends an event message, with message ID containing the current ** processor/box and task ID as well as the eventID. ** ** Assumptions and Notes: */ int32 CFE_EVS_SendEvent (uint16 EventID, uint16 EventType, const char *Spec, ... ) { int32 Status = CFE_SUCCESS; char BigBuf[CFE_EVS_MAX_MESSAGE_LENGTH]; char GTBigBuf[CFE_EVS_MAX_MESSAGE_LENGTH + 2]; va_list Ptr; CFE_EVS_Packet_t EVS_Packet; uint32 AppID = 0xFFFFFFFF; /* Handle Preset Return Code */ if (cfe_evs_api_return_value[CFE_EVS_SENDEVENT_PROC] != UTF_CFE_USE_DEFAULT_RETURN_CODE) { return cfe_evs_api_return_value[CFE_EVS_SENDEVENT_PROC]; } /* Get application identifier */ Status = CFE_ES_GetAppID(&AppID); if (Status == CFE_SUCCESS) { if(UTF_AppID_Registered == FALSE) { char warning_text[120]; strcpy (warning_text,"UTF WARNING: CFE_EVS_SendEvent called by application which is not "); strcat(warning_text,"registered for event services.\n"); /* if the application is not registered for event services do not perform event service */ UTF_put_text(warning_text); } /* Obtain task and system information */ /*EVS_Packet.PacketID.SpacecraftID = OS_BSPGetSpacecraftId();*/ CFE_ES_GetAppName(EVS_Packet.PacketID.AppName, AppID, OS_MAX_API_NAME); /* EVS_Packet.PacketID.ProcessorID = OS_BSPGetProcessorId();*/ EVS_Packet.PacketID.EventID = EventID; EVS_Packet.PacketID.EventType = EventType; /* Copy message to event packet if long format is enabled */ if (UTF_Long_Events_Enabled == TRUE) { va_start(Ptr, Spec); vsnprintf(GTBigBuf, CFE_EVS_MAX_MESSAGE_LENGTH +2, Spec, Ptr); va_end(Ptr); if(strlen(GTBigBuf) > CFE_EVS_MAX_MESSAGE_LENGTH) { UTF_put_text ("Max Event Message Size Exceeded. Permitted %d; Actual %d\n", CFE_EVS_MAX_MESSAGE_LENGTH, strlen(GTBigBuf)); } strncpy(BigBuf,GTBigBuf,CFE_EVS_MAX_MESSAGE_LENGTH); if (EventType == CFE_EVS_DEBUG) UTF_put_text("DEBUG EVENT ID=%d %s\n",EventID, BigBuf); else if (EventType == CFE_EVS_INFORMATION) UTF_put_text("INFO EVENT ID=%d %s\n",EventID, BigBuf); else if (EventType == CFE_EVS_ERROR) UTF_put_text("ERROR EVENT ID=%d %s\n",EventID, BigBuf); else if (EventType == CFE_EVS_CRITICAL) UTF_put_text("CRITICAL EVENT ID=%d %s\n",EventID, BigBuf); else UTF_put_text("Invalid Event Type %d ID=%d %s\n",EventType,EventID, BigBuf); } else { /* Send an empty message if short format is enabled */ strcpy(EVS_Packet.Message, "\0"); } return CFE_SUCCESS; } return Status; } /* End CFE_EVS_SendEvent */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int main(void) { /* ** Set up output results text file */ UTF_set_output_filename("ds_utest.out"); /* ** Set up HK packet handler */ UTF_set_packet_handler(DS_HK_TLM_MID, (utf_packet_handler)PrintHKPacket); /* ** Initialize time data structures */ UTF_init_sim_time(0.0); /* ** Initialize ES application data */ UTF_ES_InitAppRecords(); UTF_ES_AddAppRecord("DS",0); CFE_ES_RegisterApp(); /* ** Initialize CDS and table services data structures */ CFE_ES_CDS_EarlyInit(); CFE_TBL_EarlyInit(); /* * Setup the virtual/physical file system mapping... * * The following local machine directory structure is required: * * ... ds/fsw/unit_test <-- this is the current working directory * ... ds/fsw/unit_test/disk/TT <-- physical location for virtual disk "/tt" */ UTF_add_volume("/TT", "disk", FS_BASED, FALSE, FALSE, TRUE, "TT", "/tt", 0); /* ** Delete files created during previous tests */ OS_remove("/tt/app00002000.tlm"); OS_remove("/tt/app1980001000000.hk"); OS_remove("/tt/b_00000000.x"); OS_remove("/tt/b_99999999.x"); /* ** Required setup prior to calling many CFE API functions */ CFE_ES_RegisterApp(); CFE_EVS_Register(NULL, 0, 0); /* ** Run DS application unit tests */ UTF_put_text("\n*** DS -- Testing ds_cmds.c ***\n"); Test_cmds(); UTF_put_text("\n*** DS -- Testing ds_file.c ***\n"); Test_file(); UTF_put_text("\n*** DS -- Testing ds_table.c ***\n"); Test_table(); UTF_put_text("\n*** DS -- Testing ds_app.c ***\n"); Test_app(); UTF_put_text("\n*** DS -- Total test count = %d, total test errors = %d\n\n", UT_TotalTestCount, UT_TotalFailCount); /* ** Invoke the main loop "success" test now because the program ** will end when the last entry in the SB input file is read. */ UTF_CFE_ES_Set_Api_Return_Code(CFE_ES_RUNLOOP_PROC, TRUE); UTF_CFE_TBL_Set_Api_Return_Code (CFE_TBL_GETSTATUS_PROC, CFE_TBL_INFO_UPDATE_PENDING); DS_AppMain(); return 0; } /* End of main() */
int main(void) { int32 MemDwellAppId = 5; char MemDwellAppName[10]; /********************************/ /* Set up input file */ /********************************/ UTF_add_input_file(CFS_MD_CMD_PIPE, "md_unit_test4.in"); MD_AppData.CmdPipe = CFS_MD_CMD_PIPE; /********************************/ /* Set up output file */ /********************************/ UTF_set_output_filename("md_unit_test4.out"); #ifdef UTF_USE_STDOUT UTF_put_text("Std output is being used. \n"); #endif /**************************************************/ /* Initialize Unit Test Framework */ /**************************************************/ /* Initialize the CDS */ UTF_put_text("\n***Initialize UTF ***\n"); CFE_ES_CDS_EarlyInit(); UTF_CFE_Init(); /********************************/ /* Initialize simulation time */ /********************************/ UTF_init_sim_time(1.5); /**************************************************/ /* Add volume to hold loadfiles */ /**************************************************/ #if MD_SIGNATURE_OPTION == 1 UTF_add_volume("/", "ram", FS_BASED, FALSE, FALSE, TRUE, "RAM", "/ram", 0); #else UTF_add_volume("/", "ramnosig", FS_BASED, FALSE, FALSE, TRUE, "RAM", "/ram", 0); #endif /**************************************************/ /* Add tasks to ES's list of tasks, and */ /* register local task with Executive Services. */ /**************************************************/ UTF_put_text("\n***Add tasks to ES list of tasks ***\n"); UTF_ES_InitTaskRecords(); MemDwellAppId = UTF_ES_GetFreeTaskRecord(); if (MemDwellAppId < 0) { UTF_put_text("\n***Error return from UTF_ES_GetFreeTaskRecord***\n"); exit(0); } strcpy(MemDwellAppName,"MD"); UTF_ES_AddAppRecord(MemDwellAppName, MemDwellAppId); UTF_ES_DumpAppRecords(); /**************************************************/ /* Add "Special" Commands */ /**************************************************/ UTF_add_special_command("SET_MEM_RANGE_FALSE", UTF_SetMemRangeError); UTF_add_special_command("SET_MEM_RANGE_VALID", UTF_SetMemRangeValid); UTF_add_special_command("LOAD_TABLE_FROM_GROUND", UTF_SCRIPT_LoadTableFromGround); UTF_add_special_command("DISPLAY_TABLE_REGISTRY", UTF_SCRIPT_DisplayTableRegistry); UTF_add_special_command("ADD_SIM_MEMORY", UTF_AddSimulatedMemory); UTF_add_special_command("SET_SB_RETURN_CODE", UTF_SCRIPT_SB_Set_Api_Return_Code); UTF_add_special_command("USE_DEFAULT_SB_RETURN_CODE", UTF_SCRIPT_SB_Use_Default_Api_Return_Code); UTF_add_special_command("SET_TBL_RETURN_CODE", UTF_SCRIPT_TBL_Set_Api_Return_Code); UTF_add_special_command("USE_DEFAULT_TBL_RETURN_CODE", UTF_SCRIPT_TBL_Use_Default_Api_Return_Code); /**************************************************/ /* Start Memory Dwell application */ /**************************************************/ UTF_put_text("\n*** Start Memory Dwell Main Task ***\n"); MD_AppMain(); /**************************************************/ /* Here we've reached the end of input file processing */ /**************************************************/ /**************************************************/ /* Test Table Services APIs */ /**************************************************/ UTF_CFE_TBL_DisplayTableRegistryContents(); exit(0); }
void Test_table(void) { int32 FilterTableIndex; uint32 uint32Result; boolean BooleanResult; char StringBuffer[4]; uint32 TestCount = 0; uint32 FailCount = 0; /* ** Tests for function DS_TableUpdateCDS()... ** ** (1) Table data ptr = NULL, get address = success */ /* (1) invalid table descriptor text */ UTF_CFE_ES_Set_Api_Return_Code(CFE_ES_COPYTOCDS_PROC, -1); DS_AppData.DataStoreHandle = 1; DS_TableUpdateCDS(); TestCount++; if (DS_AppData.DataStoreHandle != 0) { UTF_put_text("DS_TableUpdateCDS() -- test failed (1)\n"); FailCount++; } UTF_CFE_ES_Use_Default_Api_Return_Code(CFE_ES_COPYTOCDS_PROC); /* ** Initialize packet filter table contents for these tests... ** ** Table entry 0 = not in use (valid) ** Table entry 1 = in use (valid) ** Table entry 2 = in use (invalid) ** Last entry = in use (valid) ** Other entries = not in use (valid) */ memset(&UT_FilterTbl, DS_UNUSED, sizeof(UT_FilterTbl)); UT_FilterTbl.Packet[1].MessageID = DS_CMD_MID; UT_FilterTbl.Packet[2].MessageID = DS_SEND_HK_MID; UT_FilterTbl.Packet[2].Filter[0].FileTableIndex = DS_DEST_FILE_CNT; UT_FilterTbl.Packet[DS_PACKETS_IN_FILTER_TABLE - 1].MessageID = DS_HK_TLM_MID; /* ** Initialize destination file table contents for these tests... ** ** Table entry 0 = not in use (valid) ** Table entry 1 = in use (valid) ** Table entry 2 = in use (invalid) ** Other entries = not in use (valid) */ memset(&UT_DestFileTbl, DS_UNUSED, sizeof(UT_DestFileTbl)); strcpy(UT_DestFileTbl.File[1].Pathname, "ok"); strcpy(UT_DestFileTbl.File[1].Basename, "ok"); strcpy(UT_DestFileTbl.File[1].Extension, "ok"); UT_DestFileTbl.File[1].FileNameType = DS_BY_COUNT; UT_DestFileTbl.File[1].EnableState = DS_ENABLED; UT_DestFileTbl.File[1].MaxFileSize = DS_FILE_MIN_SIZE_LIMIT; UT_DestFileTbl.File[1].MaxFileAge = DS_FILE_MIN_AGE_LIMIT; UT_DestFileTbl.File[1].SequenceCount = DS_MAX_SEQUENCE_COUNT; strcpy(UT_DestFileTbl.File[2].Pathname, "ok"); /* ** Tests for function DS_TableInit()... ** ** (1) failure to register Destination File Table ** (2) failure to register Packet Filter Table ** (3) failure to load Destination File Table ** (4) failure to load Packet Filter Table ** ** then calls DS_TableManageDestFile() ** then calls DS_TableManageFilter() */ /* Turn on dummy proc that will fake the fail - pass - fail */ UTF_TBL_set_function_hook(CFE_TBL_REGISTER_HOOK, (void *)&CFE_TBL_RegisterHook); /* (1) CFE_TBL_Register (file table) will fail */ DS_TableInit(); /* (2) CFE_TBL_Register (file table) will succeed, (filter table) will fail */ DS_TableInit(); /* Turn off dummy proc that faked the fail - pass - fail */ UTF_TBL_set_function_hook(CFE_TBL_REGISTER_HOOK, NULL); DS_AppData.DestFileTblPtr = (DS_DestFileTable_t *) &UT_DestFileTbl; DS_AppData.FilterTblPtr = (DS_FilterTable_t *) &UT_FilterTbl; UTF_CFE_TBL_Set_Api_Return_Code (CFE_TBL_REGISTER_PROC, CFE_TBL_INFO_RECOVERED_TBL); DS_TableInit(); /* DS_AppData.DestFileTblPtr = (DS_DestFileTable_t *) &UT_DestFileTbl; DS_AppData.FilterTblPtr = (DS_FilterTable_t *) &UT_FilterTbl; UTF_CFE_TBL_Set_Api_Return_Code (CFE_TBL_GETSTATUS_PROC, CFE_TBL_INFO_DUMP_PENDING); DS_TableInit(); UTF_CFE_TBL_Use_Default_Api_Return_Code(CFE_TBL_GETSTATUS_PROC); */ DS_AppData.DestFileTblPtr = (DS_DestFileTable_t *) &UT_DestFileTbl; DS_AppData.FilterTblPtr = (DS_FilterTable_t *) &UT_FilterTbl; UTF_CFE_TBL_Set_Api_Return_Code (CFE_TBL_GETSTATUS_PROC, CFE_TBL_INFO_VALIDATION_PENDING); DS_TableInit(); UTF_CFE_TBL_Use_Default_Api_Return_Code(CFE_TBL_GETSTATUS_PROC); /* DS_AppData.DestFileTblPtr = (DS_DestFileTable_t *) &UT_DestFileTbl; DS_AppData.FilterTblPtr = (DS_FilterTable_t *) &UT_FilterTbl; UTF_CFE_TBL_Set_Api_Return_Code (CFE_TBL_GETSTATUS_PROC, CFE_TBL_INFO_UPDATE_PENDING); DS_TableInit(); UTF_CFE_TBL_Use_Default_Api_Return_Code(CFE_TBL_GETSTATUS_PROC); */ UTF_CFE_TBL_Use_Default_Api_Return_Code(CFE_TBL_REGISTER_PROC); /* ** Tests for function DS_TableManageDestFile()... ** ** (1) Table data ptr = NULL, get address = success ** (2) Table data ptr = ok, get address = update ** (3) Table data ptr = ok, get address = other */ /* ** Tests for function DS_TableManageFilter()... ** ** (1) Table data ptr = NULL, get address = success ** (2) Table data ptr = NULL, get address = update ** (3) Table data ptr = NULL, get address = other ** (4) Table data ptr = ok, get status = validate ** (5) Table data ptr = ok, get status = update, get address = success ** (6) Table data ptr = ok, get status = update, get address = update ** (7) Table data ptr = ok, get status = update, get address = other ** (8) Table data ptr = ok, get status = other */ /* ** Tests for function DS_TableVerifyDestFile()... ** ** (1) invalid table descriptor text ** (2) mix of good, bad and unused table entries */ /* (1) invalid table descriptor text */ memset(&UT_DestFileTbl.Descriptor, 'A', DS_DESCRIPTOR_BUFSIZE); uint32Result = DS_TableVerifyDestFile(&UT_DestFileTbl); TestCount++; if (uint32Result != DS_TABLE_VERIFY_ERR) { UTF_put_text("DS_TableVerifyDestFile() -- test failed (1)\n"); FailCount++; } /* (2) mix of good, bad and unused table entries */ memset(&UT_DestFileTbl.Descriptor, DS_UNUSED, DS_DESCRIPTOR_BUFSIZE); uint32Result = DS_TableVerifyDestFile(&UT_DestFileTbl); TestCount++; if (uint32Result != DS_TABLE_VERIFY_ERR) { UTF_put_text("DS_TableVerifyDestFile() -- test failed (2)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyDestFileEntry()... ** ** (1) destination file pathname = invalid ** (2) destination file basename = invalid ** (3) destination file extension = invalid ** (4) destination file filename type = invalid ** (5) destination file enable state = invalid ** (6) destination file max size = invalid ** (7) destination file max age = invalid ** (8) destination file sequence count = invalid ** (9) destination file table entry = valid */ /* (1) destination file pathname = invalid */ memset(UT_DestFileTbl.File[5].Pathname, 'A', DS_PATHNAME_BUFSIZE); BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (1)\n"); FailCount++; } /* (2) destination file basename = invalid */ strcpy(UT_DestFileTbl.File[5].Pathname, "ok"); memset(UT_DestFileTbl.File[5].Basename, 'A', DS_BASENAME_BUFSIZE); BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (2)\n"); FailCount++; } /* (3) destination file extension = invalid */ strcpy(UT_DestFileTbl.File[5].Basename, "ok"); memset(UT_DestFileTbl.File[5].Extension, 'A', DS_EXTENSION_BUFSIZE); BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (3)\n"); FailCount++; } /* (4) destination file filename type = invalid */ strcpy(UT_DestFileTbl.File[5].Extension, "ok"); UT_DestFileTbl.File[5].FileNameType = DS_UNUSED; BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (4)\n"); FailCount++; } /* (5) destination file enable state = invalid */ UT_DestFileTbl.File[5].FileNameType = DS_BY_COUNT; UT_DestFileTbl.File[5].EnableState = 99; BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (5)\n"); FailCount++; } /* (6) destination file max size = invalid */ UT_DestFileTbl.File[5].EnableState = DS_ENABLED; UT_DestFileTbl.File[5].MaxFileSize = DS_FILE_MIN_SIZE_LIMIT - 1; BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (6)\n"); FailCount++; } /* (7) destination file max age = invalid */ UT_DestFileTbl.File[5].MaxFileSize = DS_FILE_MIN_SIZE_LIMIT; UT_DestFileTbl.File[5].MaxFileAge = DS_FILE_MIN_AGE_LIMIT - 1; BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (7)\n"); FailCount++; } /* (8) destination file sequence count = invalid */ UT_DestFileTbl.File[5].MaxFileAge = DS_FILE_MIN_AGE_LIMIT; UT_DestFileTbl.File[5].SequenceCount = DS_MAX_SEQUENCE_COUNT + 1; BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (8)\n"); FailCount++; } /* (9) destination file table entry = valid */ UT_DestFileTbl.File[5].SequenceCount = DS_MAX_SEQUENCE_COUNT; BooleanResult = DS_TableVerifyDestFileEntry(&UT_DestFileTbl.File[5], 5, 1); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyDestFileEntry() -- test failed (9)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyFilter()... ** ** (1) invalid table descriptor text ** (2) mix of good, bad and unused table entries */ /* (1) invalid table descriptor text */ memset(&UT_FilterTbl.Descriptor, 'A', DS_DESCRIPTOR_BUFSIZE); uint32Result = DS_TableVerifyFilter(&UT_FilterTbl); TestCount++; if (uint32Result != DS_TABLE_VERIFY_ERR) { UTF_put_text("DS_TableVerifyFilter() -- test failed (1)\n"); FailCount++; } /* (2) mix of good, bad and unused table entries */ memset(&UT_FilterTbl.Descriptor, DS_UNUSED, DS_DESCRIPTOR_BUFSIZE); uint32Result = DS_TableVerifyFilter(&UT_FilterTbl); TestCount++; if (uint32Result != DS_TABLE_VERIFY_ERR) { UTF_put_text("DS_TableVerifyFilter() -- test failed (2)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyFilterEntry()... ** ** (1) packet entry MID = unused ** (2) packet entry in use - filter entry = unused ** (3) packet entry in use - filter entry - file table index = invalid ** (4) packet entry in use - filter entry - filter type = invalid ** (5) packet entry in use - filter entry - filter parms = invalid ** (6) packet entry in use - filter entry = valid */ /* (1) packet entry MID = unused */ memset(&UT_FilterTbl.Packet[10], DS_UNUSED, sizeof(DS_PacketEntry_t)); BooleanResult = DS_TableVerifyFilterEntry(&UT_FilterTbl.Packet[10], 10, 0); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyFilterEntry() -- test failed (1)\n"); FailCount++; } /* (2) packet entry in use - filter entry = unused */ UT_FilterTbl.Packet[10].MessageID = DS_CMD_MID; BooleanResult = DS_TableVerifyFilterEntry(&UT_FilterTbl.Packet[10], 10, 0); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyFilterEntry() -- test failed (2)\n"); FailCount++; } /* (3) packet entry in use - filter entry - file table index = invalid */ UT_FilterTbl.Packet[10].Filter[0].FileTableIndex = DS_DEST_FILE_CNT; BooleanResult = DS_TableVerifyFilterEntry(&UT_FilterTbl.Packet[10], 10, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyFilterEntry() -- test failed (3)\n"); FailCount++; } /* (4) packet entry in use - filter entry - filter type = invalid */ UT_FilterTbl.Packet[10].Filter[0].FileTableIndex = DS_DEST_FILE_CNT - 1; UT_FilterTbl.Packet[10].Filter[0].FilterType = DS_UNUSED; BooleanResult = DS_TableVerifyFilterEntry(&UT_FilterTbl.Packet[10], 10, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyFilterEntry() -- test failed (4)\n"); FailCount++; } /* (5) packet entry in use - filter entry - filter parms = invalid */ UT_FilterTbl.Packet[10].Filter[0].FilterType = DS_BY_COUNT; UT_FilterTbl.Packet[10].Filter[0].Algorithm_N = 1; BooleanResult = DS_TableVerifyFilterEntry(&UT_FilterTbl.Packet[10], 10, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyFilterEntry() -- test failed (5)\n"); FailCount++; } /* (6) packet entry in use - filter entry = valid */ UT_FilterTbl.Packet[10].Filter[0].Algorithm_N = 0; BooleanResult = DS_TableVerifyFilterEntry(&UT_FilterTbl.Packet[10], 10, 0); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyFilterEntry() -- test failed (6)\n"); FailCount++; } /* ** Tests for function DS_TableEntryUnused()... ** ** (1) table entry unused ** (2) table entry in use */ /* (1) table entry unused */ BooleanResult = DS_TableEntryUnused(&UT_FilterTbl.Packet[0], sizeof(DS_PacketEntry_t)); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableEntryUnused() -- test failed (1)\n"); FailCount++; } /* (2) table entry in use */ BooleanResult = DS_TableEntryUnused(&UT_FilterTbl.Packet[1], sizeof(DS_PacketEntry_t)); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableEntryUnused() -- test failed (2)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyFileIndex()... ** ** (1) File Table Index < DS_DEST_FILE_CNT (valid) ** (2) File Table Index = DS_DEST_FILE_CNT (invalid) ** (3) File Table Index > DS_DEST_FILE_CNT (invalid) */ /* (1) File Table Index < DS_DEST_FILE_CNT (valid) */ BooleanResult = DS_TableVerifyFileIndex(DS_DEST_FILE_CNT - 1); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyFileIndex() -- test failed (1)\n"); FailCount++; } /* (2) File Table Index = DS_DEST_FILE_CNT (invalid) */ BooleanResult = DS_TableVerifyFileIndex(DS_DEST_FILE_CNT); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyFileIndex() -- test failed (2)\n"); FailCount++; } /* (3) File Table Index > DS_DEST_FILE_CNT (invalid) */ BooleanResult = DS_TableVerifyFileIndex(DS_DEST_FILE_CNT + 1); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyFileIndex() -- test failed (3)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyParms()... ** ** N = pass this many ** X = out of this many ** O = starting at this offset ** ** (1) N is less than X, O is valid ** (2) N is equal to X, O is valid ** (3) N is greater than X, O is valid ** (4) N is valid, O is less than X ** (5) N is valid, O is equal to X ** (6) N is valid, O is greater than X ** (7) N = 0, X = 0, O = 0 (this is valid, it means filter all) */ /* (1) N is less than X, O is valid */ BooleanResult = DS_TableVerifyParms(1, 2, 0); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyParms() -- test failed (1)\n"); FailCount++; } /* (2) N is equal to X, O is valid */ BooleanResult = DS_TableVerifyParms(2, 2, 0); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyParms() -- test failed (2)\n"); FailCount++; } /* (3) N is greater than X, O is valid */ BooleanResult = DS_TableVerifyParms(3, 2, 0); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyParms() -- test failed (3)\n"); FailCount++; } /* (4) N is valid, O is less than X */ BooleanResult = DS_TableVerifyParms(1, 2, 1); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyParms() -- test failed (4)\n"); FailCount++; } /* (5) N is valid, O is equal to X */ BooleanResult = DS_TableVerifyParms(1, 2, 2); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyParms() -- test failed (5)\n"); FailCount++; } /* (6) N is valid, O is greater than X */ BooleanResult = DS_TableVerifyParms(1, 2, 3); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyParms() -- test failed (6)\n"); FailCount++; } /* (7) N = 0, X = 0, O = 0 (this is valid, it means pass none) */ BooleanResult = DS_TableVerifyParms(0, 0, 0); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyParms() -- test failed (7)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyType()... ** ** (1) valid type value (count) ** (2) valid type value (time) ** (3) invalid type value (99) */ /* (1) valid type value (count) */ BooleanResult = DS_TableVerifyType(DS_BY_COUNT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyType() -- test failed (1)\n"); FailCount++; } /* (2) valid type value (time) */ BooleanResult = DS_TableVerifyType(DS_BY_TIME); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyType() -- test failed (2)\n"); FailCount++; } /* (3) invalid type value */ BooleanResult = DS_TableVerifyType(99); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyType() -- test failed (3)\n"); FailCount++; } /* ** Tests for function CFS_VerifyString()... ** ** (1) empty string, string not required ** (2) empty string, string required ** (3) string without terminator ** (4) string with invalid filename chars, char test required ** (5) string with invalid filename chars, char test not required ** (6) string with valid filename chars, char test required */ /* create empty string */ StringBuffer[0] = DS_STRING_TERMINATOR; StringBuffer[1] = DS_STRING_TERMINATOR; StringBuffer[2] = DS_STRING_TERMINATOR; StringBuffer[3] = DS_STRING_TERMINATOR; /* (1) empty string, not required */ BooleanResult = CFS_VerifyString(StringBuffer, 4, DS_STRING_OPTIONAL, DS_DESCRIPTIVE_TEXT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("CFS_VerifyString() -- test failed (1)\n"); FailCount++; } /* (2) empty string, required */ BooleanResult = CFS_VerifyString(StringBuffer, 4, DS_STRING_REQUIRED, DS_DESCRIPTIVE_TEXT); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("CFS_VerifyString() -- test failed (2)\n"); FailCount++; } /* create string without terminator */ StringBuffer[0] = 'A'; StringBuffer[1] = 'B'; StringBuffer[2] = 'C'; StringBuffer[3] = 'D'; /* (3) string without terminator */ BooleanResult = CFS_VerifyString(StringBuffer, 4, DS_STRING_OPTIONAL, DS_DESCRIPTIVE_TEXT); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("CFS_VerifyString() -- test failed (3)\n"); FailCount++; } /* create string with invalid filename characters */ StringBuffer[0] = 'A'; StringBuffer[1] = '$'; StringBuffer[2] = '*'; StringBuffer[3] = DS_STRING_TERMINATOR; /* (4) string with invalid filename chars, char test required */ BooleanResult = CFS_VerifyString(StringBuffer, 4, DS_STRING_OPTIONAL, DS_FILENAME_TEXT); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("CFS_VerifyString() -- test failed (4)\n"); FailCount++; } /* (5) string with invalid filename chars, char test not required */ BooleanResult = CFS_VerifyString(StringBuffer, 4, DS_STRING_OPTIONAL, DS_DESCRIPTIVE_TEXT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("CFS_VerifyString() -- test failed (5)\n"); FailCount++; } /* create string with valid filename characters */ StringBuffer[0] = 'A'; StringBuffer[1] = '/'; StringBuffer[2] = 'B'; StringBuffer[3] = DS_STRING_TERMINATOR; /* (6) string with valid filename chars, char test required */ BooleanResult = CFS_VerifyString(StringBuffer, 4, DS_STRING_OPTIONAL, DS_FILENAME_TEXT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("CFS_VerifyString() -- test failed (6)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyState()... ** ** (1) valid state value (enabled) ** (2) valid state value (disabled) ** (3) invalid state value (99) */ /* (1) valid state value (enabled) */ BooleanResult = DS_TableVerifyState(DS_ENABLED); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyState() -- test failed (1)\n"); FailCount++; } /* (2) valid state value (disabled) */ BooleanResult = DS_TableVerifyState(DS_DISABLED); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyState() -- test failed (2)\n"); FailCount++; } /* (3) invalid state value */ BooleanResult = DS_TableVerifyState(99); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyState() -- test failed (3)\n"); FailCount++; } /* ** Tests for function DS_TableVerifySize()... ** ** (1) valid file size limit ** (2) invalid file size limit */ /* (1) valid file size limit */ BooleanResult = DS_TableVerifySize(DS_FILE_MIN_SIZE_LIMIT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifySize() -- test failed (1)\n"); FailCount++; } /* (2) invalid file size limit */ BooleanResult = DS_TableVerifySize(DS_FILE_MIN_SIZE_LIMIT - 1); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifySize() -- test failed (2)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyAge()... ** ** (1) valid file age limit ** (2) invalid file age limit */ /* (1) valid file age limit */ BooleanResult = DS_TableVerifyAge(DS_FILE_MIN_AGE_LIMIT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyAge() -- test failed (1)\n"); FailCount++; } /* (2) invalid file age limit */ BooleanResult = DS_TableVerifyAge(DS_FILE_MIN_AGE_LIMIT - 1); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyAge() -- test failed (2)\n"); FailCount++; } /* ** Tests for function DS_TableVerifyCount()... ** ** (1) valid sequence count ** (2) invalid sequence count */ /* (1) valid sequence count */ BooleanResult = DS_TableVerifyCount(DS_MAX_SEQUENCE_COUNT); TestCount++; if (BooleanResult == FALSE) { UTF_put_text("DS_TableVerifyCount() -- test failed (1)\n"); FailCount++; } /* (2) invalid sequence count */ BooleanResult = DS_TableVerifyCount(DS_MAX_SEQUENCE_COUNT + 1); TestCount++; if (BooleanResult == TRUE) { UTF_put_text("DS_TableVerifyCount() -- test failed (2)\n"); FailCount++; } /* ** Tests for function DS_TableSubscribe()... ** ** (1) this function has no failure case */ /* (1) this function has no failure case */ DS_TableSubscribe(); TestCount++; /* ** Tests for function DS_TableUnsubscribe()... ** ** (1) this function has no failure case */ /* (1) this function has no failure case */ DS_TableUnsubscribe(); TestCount++; /* ** Tests for function DS_TableFindMsgID()... ** ** (1) find message ID ** (known to be entry (DS_PACKETS_IN_FILTER_TABLE - 1)) */ /* (1) find message ID */ FilterTableIndex = DS_TableFindMsgID(DS_HK_TLM_MID); TestCount++; if (FilterTableIndex != (DS_PACKETS_IN_FILTER_TABLE - 1)) { UTF_put_text("DS_TableFindMsgID() -- test failed (1)\n"); FailCount++; } /* ** Summary for this group of unit tests... */ UTF_put_text("ds_table.c -- test count = %d, test errors = %d\n", TestCount, FailCount); UT_TotalTestCount += TestCount; UT_TotalFailCount += FailCount; return; } /* End of Test_table() */
int32 CFE_TBL_GetAddress_FunctionHook ( void **TblPtr, CFE_TBL_Handle_t TblHandle ) /* To be used before control is turned over to input command file. */ /* Used in concert with CFE_TBL_Register_FunctionHook to set up test cases. */ /* Count 1: invalid table */ /* Count 2: valid table and unexpected return code */ /* Count 3: valid table with enabled field == TRUE */ /* Count 4: valid table and nominal return code */ { static uint32 Count = 0; Count++; static MD_DwellTableLoad_t DwellTbl; static int16 Num1 = 5; int32 RetVal; UTF_put_text("CALL #%d to GetAddress_FunctionHook\n", Count); CFE_PSP_MemSet(&DwellTbl, 0, sizeof(MD_DwellTableLoad_t)); /********************************/ /* Set up Memory */ /********************************/ /* Calling CFE_PSP_MemRangeSet makes calls to CFE_PSP_MemValidateRange for this */ /* range return true. */ RetVal = CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_RAM, (uint32)&Num1, 0x00000002, CFE_PSP_MEM_SIZE_BYTE, CFE_PSP_MEM_ATTR_READ); if (RetVal != OS_SUCCESS) { UTF_put_text ("Error return %d from CFE_PSP_MemRangeSet\n", RetVal); } /* Recover invalid table w/invalid value for enable flag */ /* for dwell tables #1 and #4 */ if (Count == 1) /* Use for first dwell table */ { /* Set TblPtr to point to an invalid table */ DwellTbl.Enabled = 17; /* invalid value */ DwellTbl.Entry[0].Length = 2; DwellTbl.Entry[0].Delay = 1; DwellTbl.Entry[0].DwellAddress.Offset = (uint32)&Num1; strcpy (DwellTbl.Entry[0].DwellAddress.SymName, ""); DwellTbl.Entry[1].Length = 0; DwellTbl.Entry[1].Delay = 0; DwellTbl.Entry[1].DwellAddress.Offset = 0; /* strcpy (DwellTbl.Entry[1].DwellAddress.SymName, ""); */ DwellTbl.Entry[1].DwellAddress.SymName[0]='\0'; /* */ *TblPtr = (void *)&DwellTbl; return (CFE_TBL_INFO_UPDATED); } else if (Count == 3) { DwellTbl.Enabled = 1; DwellTbl.Entry[0].Length = 2; DwellTbl.Entry[0].Delay = 1; DwellTbl.Entry[0].DwellAddress.Offset = (uint32)&Num1; strcpy (DwellTbl.Entry[0].DwellAddress.SymName, ""); DwellTbl.Entry[1].Length = 0; DwellTbl.Entry[1].Delay = 0; DwellTbl.Entry[1].DwellAddress.Offset = 0; /* strcpy (DwellTbl.Entry[1].DwellAddress.SymName, ""); */ DwellTbl.Entry[1].DwellAddress.SymName[0]='\0'; /* */ *TblPtr = (void *)&DwellTbl; return (CFE_TBL_INFO_UPDATED); } else if (Count == 2) { *TblPtr = (void *)0; return (CFE_TBL_ERR_NO_ACCESS); } /* Recover valid tables */ else /* this will cover 4th call on initialization, as well as any */ /* for any updates. */ { /* Set TblPtr to point to a valid table */ DwellTbl.Enabled = MD_DWELL_STREAM_DISABLED; DwellTbl.Entry[0].Length = 2; DwellTbl.Entry[0].Delay = 1; DwellTbl.Entry[0].DwellAddress.Offset = (uint32)&Num1; strcpy (DwellTbl.Entry[0].DwellAddress.SymName, ""); DwellTbl.Entry[1].Length = 0; DwellTbl.Entry[1].Delay = 0; DwellTbl.Entry[1].DwellAddress.Offset = 0; strcpy (DwellTbl.Entry[1].DwellAddress.SymName, ""); /* */ *TblPtr = (void *)&DwellTbl; return (CFE_TBL_INFO_UPDATED); } }
void CFE_PSP_Panic(int32 ErrorCode) { UTF_put_text("CFE_PSP_Panic Called with error code = 0x%08X. Exiting.\n",(unsigned int)ErrorCode); UTF_put_text("The cFE could not start.\n"); UTF_exit(); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Test_SymTblDump(void) { MM_SymTblToFileCmd_t DumpSymTblCmdMsg; /* Setup the test message header */ CFE_SB_InitMsg(&DumpSymTblCmdMsg, MM_CMD_MID, sizeof(MM_SymTblToFileCmd_t), TRUE); UTF_put_text("***************************\n"); UTF_put_text("* Symbol Table Dump Tests *\n"); UTF_put_text("***************************\n"); UTF_put_text("\n"); /* ** Test empty file name */ UTF_put_text("Test symbol dump with empty file name \n"); UTF_put_text("--------------------------------------\n"); DumpSymTblCmdMsg.FileName[0] = '\0'; MM_SymTblToFileCmd((CFE_SB_MsgPtr_t)&DumpSymTblCmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test invalid file name */ UTF_put_text("Test symbol dump with invalid file name \n"); UTF_put_text("--------------------------------------\n"); strcpy(DumpSymTblCmdMsg.FileName, "BadFile*Name"); MM_SymTblToFileCmd((CFE_SB_MsgPtr_t)&DumpSymTblCmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test good file name but OS table dump failure */ UTF_put_text("Test symbol dump with good filename but bad OS return \n"); UTF_put_text("------------------------------------------------------\n"); UTF_SetOSSymbolTableDumpStatus(OS_ERROR); strcpy(DumpSymTblCmdMsg.FileName, "IrrelevantFileName"); MM_SymTblToFileCmd((CFE_SB_MsgPtr_t)&DumpSymTblCmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test good file name but OS table dump failure */ UTF_put_text("Test symbol dump with good filename but bad OS file \n"); UTF_put_text("----------------------------------------------------\n"); UTF_SetOSSymbolTableDumpStatus(OS_ERR_FILE); strcpy(DumpSymTblCmdMsg.FileName, "IrrelevantFileName"); MM_SymTblToFileCmd((CFE_SB_MsgPtr_t)&DumpSymTblCmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test good file name and success from OS */ UTF_put_text("Test symbol dump with good filename and successful return\n"); UTF_put_text("---------------------------------------------------------\n"); UTF_SetOSSymbolTableDumpStatus(OS_SUCCESS); strcpy(DumpSymTblCmdMsg.FileName, "GoodFileName"); MM_SymTblToFileCmd((CFE_SB_MsgPtr_t)&DumpSymTblCmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); } /* end Test_SymTblDump */
void TT_AppInit(void) { void *TblPointer; int32 Status; /* ** Initialize app command execution counters... */ TT4_AppData.CmdCount = 0; TT4_AppData.ErrCount = 0; TT4_AppData.HkPacket.UpdateCount = 0; /* ** Initialize app configuration data... */ strcpy(TT4_AppData.PipeName, "TT_CMD_PIPE"); TT4_AppData.PipeDepth = 12; TT4_AppData.LimitHK = 2; TT4_AppData.LimitCmd = 4; /* ** Initialize event filter table... */ TT4_AppData.EventFilters[0].EventID = TT_INIT_INF_EID; TT4_AppData.EventFilters[0].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[1].EventID = TT_NOOP_INF_EID; TT4_AppData.EventFilters[1].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[2].EventID = TT_RESET_INF_EID; TT4_AppData.EventFilters[2].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[3].EventID = TT_MID_ERR_EID; TT4_AppData.EventFilters[3].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[4].EventID = TT_CC1_ERR_EID; TT4_AppData.EventFilters[4].Mask = CFE_EVS_NO_FILTER; TT4_AppData.EventFilters[5].EventID = TT_LEN_ERR_EID; TT4_AppData.EventFilters[5].Mask = CFE_EVS_NO_FILTER; /* ** Register event filter table... */ CFE_EVS_Register(TT4_AppData.EventFilters, TT_EVT_COUNT, CFE_EVS_BINARY_FILTER); /* ** Initialize housekeeping packet (clear user data area)... */ CFE_SB_InitMsg(&TT4_AppData.HkPacket, CFE_TT_HK_TLM_MID, sizeof(TT_HkPacket_t), TRUE); /* ** Create Software Bus message pipe... */ CFE_SB_CreatePipe(&TT4_AppData.CmdPipe, TT4_AppData.PipeDepth, TT4_AppData.PipeName); /* ** Subscribe to Housekeeping request commands... */ CFE_SB_Subscribe(CFE_TT_SEND_HK_MID,TT4_AppData.CmdPipe); /* ** Subscribe to TT ground command packets... */ CFE_SB_Subscribe(CFE_TT_CMD_MID,TT4_AppData.CmdPipe); /* ** Register & Initialize Table... */ Status = CFE_TBL_Register(&TT4_AppData.TblHandle, "FourNumbers", 4, /* size of table in bytes*/ CFE_TBL_OPT_DBL_BUFFER | CFE_TBL_OPT_LOAD_DUMP, &TT_TableValidationCallbackFunc); /* NULL); */ UTF_put_text("CFE_TBL_Register returned %lx\n", Status); Status = CFE_TBL_Load(TT4_AppData.TblHandle, CFE_TBL_SRC_FILE, "/ram/tt_table_values0.dat"); UTF_put_text("CFE_TBL_Load returned %lx\n", Status); Status = CFE_TBL_GetAddress(&TblPointer,TT4_AppData.TblHandle); UTF_put_text("CFE_TBL_GetAddress returned %lx\n", Status); UTF_put_text("The initial values are:%d %d %d %d\n", *(int8*)TblPointer,*(int8*)(TblPointer+1), *(int8*)(TblPointer+2),*(int8*)(TblPointer+3)); Status = CFE_TBL_ReleaseAddress(TT4_AppData.TblHandle); UTF_put_text("CFE_TBL_ReleaseAddress returned %lx\n", Status); /* ** Application startup event message... */ CFE_EVS_SendEvent(TT_INIT_INF_EID, CFE_EVS_INFORMATION, "TT: Application Initialized"); return; } /* End of TT_AppInit() */
int main(void) { int32 MemDwellAppId = 5; char MemDwellAppName[10]; /********************************/ /* Set up input file */ /********************************/ UTF_add_input_file(CFS_MD_CMD_PIPE, "md_unit_test3.in"); MD_AppData.CmdPipe = CFS_MD_CMD_PIPE; /********************************/ /* Set up output file */ /********************************/ UTF_set_output_filename("md_unit_test3.out"); #ifdef UTF_USE_STDOUT UTF_put_text("Std output is being used. \n"); #endif /**************************************************/ /* Initialize Unit Test Framework */ /**************************************************/ /* Initialize the CDS */ UTF_put_text("\n***Initialize UTF ***\n"); CFE_ES_CDS_EarlyInit(); UTF_CFE_Init(); /********************************/ /* Initialize simulation time */ /********************************/ UTF_init_sim_time(1000.00); /**************************************************/ /* Add tasks to ES's list of tasks, and */ /* register local task with Executive Services. */ /**************************************************/ UTF_put_text("\n***Add tasks to ES list of tasks ***\n"); UTF_ES_InitTaskRecords(); MemDwellAppId = UTF_ES_GetFreeTaskRecord(); if (MemDwellAppId < 0) { UTF_put_text("\n***Error return from UTF_ES_GetFreeTaskRecord***\n"); exit(0); } strcpy(MemDwellAppName,"MD_APP"); UTF_ES_AddAppRecord(MemDwellAppName, MemDwellAppId); UTF_ES_DumpAppRecords(); /* UTF_put_text("\n***Register local task with ES***\n"); */ /* CFE_ES_RegisterApp(); */ /* Register local task with ES */ /**************************************************/ /* Add "Special" Commands */ /**************************************************/ UTF_add_special_command("SET_MEM_RANGE_FALSE", UTF_SetMemRangeError); UTF_add_special_command("SET_MEM_RANGE_VALID", UTF_SetMemRangeValid); UTF_add_special_command("DISPLAY_TABLE_REGISTRY", UTF_SCRIPT_DisplayTableRegistry); UTF_add_special_command("ADD_SIM_MEMORY", UTF_AddSimulatedMemory); UTF_add_special_command("SET_SB_RETURN_CODE", UTF_SCRIPT_SB_Set_Api_Return_Code); UTF_add_special_command("USE_DEFAULT_SB_RETURN_CODE", UTF_SCRIPT_SB_Use_Default_Api_Return_Code); UTF_add_special_command("SET_TBL_RETURN_CODE", UTF_SCRIPT_TBL_Set_Api_Return_Code); UTF_add_special_command("USE_DEFAULT_TBL_RETURN_CODE", UTF_SCRIPT_TBL_Use_Default_Api_Return_Code); /**************************************************/ /* Start Memory Dwell application */ /**************************************************/ UTF_TBL_set_function_hook(CFE_TBL_REGISTER_HOOK, (void *) &CFE_TBL_Register_FunctionHook); UTF_TBL_set_function_hook(CFE_TBL_GETADDRESS_HOOK, (void *) &CFE_TBL_GetAddress_FunctionHook); /**************************************************/ /* Start Memory Dwell application */ /**************************************************/ UTF_put_text("\n*** Start Memory Dwell Main Task ***\n"); MD_AppMain(); /**************************************************/ /* Here we've reached the end of input file processing */ /**************************************************/ /********************************************************/ /* Simulate pipe read error from Software Bus Services. */ /********************************************************/ UTF_CFE_ES_Set_Api_Return_Code(CFE_ES_RUNLOOP_PROC, TRUE ); ; UTF_ES_InitTaskRecords(); UTF_ES_DumpAppRecords(); ; MemDwellAppId = UTF_ES_GetFreeTaskRecord(); if (MemDwellAppId < 0) { UTF_put_text("\n***Error return from UTF_ES_GetFreeTaskRecord***\n"); exit(0); } ; strcpy(MemDwellAppName,"MD_APP"); ;UTF_ES_AddAppRecord(MemDwellAppName, (uint32)MemDwellAppId); UTF_put_text("\n* * * * * * * * * * * * * * * * * * * * * * \n"); /**************************************************/ /* Test Table Services APIs */ /**************************************************/ UTF_CFE_TBL_DisplayTableRegistryContents(); exit(0); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void Test_LoadWID(void) { MM_LoadMemWIDCmd_t CmdMsg; uint32 LocalCrc; /* Setup the test message header */ CFE_SB_InitMsg(&CmdMsg, MM_CMD_MID, sizeof(MM_LoadMemWIDCmd_t), TRUE); /* ** Setup the load data array in the command message with the ** maximum amount of data allowed. */ memcpy(CmdMsg.DataArray, MM_TestDataSet, MM_MAX_UNINTERRUPTABLE_DATA); /* Compute the CRC value */ LocalCrc = CFE_ES_CalculateCRC(MM_TestDataSet, MM_MAX_UNINTERRUPTABLE_DATA, 0, CFE_ES_DEFAULT_CRC); UTF_put_text("**********************************************\n"); UTF_put_text("* Memory Load With Interrupts Disabled Tests *\n"); UTF_put_text("**********************************************\n"); UTF_put_text("\n"); /* ** Test bad symbol name */ UTF_put_text("Test Load WID With Bad Symbol Name \n"); UTF_put_text("-----------------------------------\n"); strcpy(CmdMsg.DestSymAddress.SymName, "BadSymName"); CmdMsg.DestSymAddress.Offset = 0; CmdMsg.NumOfBytes = MM_MAX_UNINTERRUPTABLE_DATA; CmdMsg.Crc = LocalCrc; MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test bad address */ UTF_put_text("Test Load WID With Bad Address \n"); UTF_put_text("-------------------------------\n"); CmdMsg.DestSymAddress.SymName[0] = '\0'; CmdMsg.DestSymAddress.Offset = SIM_BAD_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_UNINTERRUPTABLE_DATA; CmdMsg.Crc = LocalCrc; MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test bad CRC value */ UTF_put_text("Test Load WID With Bad CRC value \n"); UTF_put_text("---------------------------------\n"); CmdMsg.DestSymAddress.SymName[0] = '\0'; CmdMsg.DestSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_UNINTERRUPTABLE_DATA; CmdMsg.Crc = LocalCrc ^ 0xF0F0F0F0; MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test data size that exceeds configuration limits */ UTF_put_text("Test Load WID That Exceeds Configuration Limits \n"); UTF_put_text("------------------------------------------------\n"); CmdMsg.DestSymAddress.SymName[0] = '\0'; CmdMsg.DestSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = 0xFF; CmdMsg.Crc = LocalCrc; MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test zero byte load */ UTF_put_text("Test Load WID With Zero Data Specified \n"); UTF_put_text("---------------------------------------\n"); CmdMsg.DestSymAddress.SymName[0] = '\0'; CmdMsg.DestSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = 0; CmdMsg.Crc = 0; MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid load of maximum size */ UTF_put_text("Test Valid Load WID of Maximum Size \n"); UTF_put_text("------------------------------------\n"); CmdMsg.DestSymAddress.SymName[0] = '\0'; CmdMsg.DestSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = MM_MAX_UNINTERRUPTABLE_DATA; CmdMsg.Crc = LocalCrc; MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); /* ** Test valid load less than maximum size */ UTF_put_text("Test Valid Load WID Less Than Maximum Size \n"); UTF_put_text("-------------------------------------------\n"); CmdMsg.DestSymAddress.SymName[0] = '\0'; CmdMsg.DestSymAddress.Offset = SIM_RAM_MEM_ADDR; CmdMsg.NumOfBytes = 100; CmdMsg.Crc = CFE_ES_CalculateCRC(MM_TestDataSet, 100, 0, CFE_ES_DEFAULT_CRC); MM_LoadMemWIDCmd((CFE_SB_MsgPtr_t)&CmdMsg); PrintLocalHKVars(); UTF_put_text("\n"); } /* end Test_LoadWID */