/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 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 UTF_SCRIPT_SB_Use_Default_Api_Return_Code(int argc,char *argv[]) { int32 Index; /* Check for correct number of arguments */ if (argc != 2) { UTF_error("UTF Error: Read %d args w/script cmd UTF_SCRIPT_SB_Set_Api_Return_Code. Expected 1.\n", argc -1 ); UTF_exit(); } /* Extract argument values */ Index = UTF_arg2dbl(argv[1]); /* Call function to set API return code */ UTF_CFE_SB_Set_Api_Return_Code(Index, UTF_CFE_USE_DEFAULT_RETURN_CODE); return; }
void UTF_SCRIPT_SB_Set_Api_Return_Code(int argc,char *argv[]) { int32 Index; int32 Code; /* Check for correct number of arguments */ if (argc != 3) { UTF_error("UTF Error: Read %d args w/script cmd UTF_SCRIPT_SB_Set_Api_Return_Code. Expected 2.\n", argc -1 ); UTF_exit(); } /* Extract argument values */ Index = UTF_arg2dbl(argv[1]); Code = UTF_arg2uint(argv[2]); /* Call function to set API return code */ UTF_CFE_SB_Set_Api_Return_Code(Index, Code); return; }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 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 */