int main(void) { char AppName[10]; strcpy(AppName, "TT"); /********************************/ /* Set up to read in script */ /********************************/ UTF_add_input_file(CFE_TT_CMD_PIPE, "ttscript1.in"); TT_AppData.CmdPipe = CFE_TT_CMD_PIPE; /* Hook for application code */ UTF_add_special_command("LOAD_TABLE_FROM_GROUND", UTF_SCRIPT_LoadTableFromGround); /********************************/ /* Set up output file */ /********************************/ UTF_set_output_filename("test_tbl_api2.ActualOutput"); UTF_set_packet_handler(CFE_TT_HK_TLM_MID, print_housekeeping); UTF_add_volume("/", "ram", FS_BASED, FALSE, FALSE, TRUE, "RAM", "/ram", 0); /**************************************************/ /* Initialize time data structures */ /**************************************************/ UTF_init_sim_time(0.0); UTF_OSAPI_set_function_hook(OS_GETLOCALTIME_HOOK, time_hook); /**************************************************/ /* Call utility to register task TT with */ /* Executive Services. */ /**************************************************/ UTF_ES_InitAppRecords(); UTF_ES_AddAppRecord("TT",0); CFE_ES_RegisterApp(); /* Create Input Files */ Create_Input_File0(); Create_Input_File1(); Create_Input_File2(); Create_Input_File3(); /**************************************************/ /* Initialize Table Services data structures */ /**************************************************/ /* Initialize the CDS */ CFE_ES_CDS_EarlyInit(); CFE_TBL_EarlyInit(); /********************************/ /* Call Main procedure for table owner application*/ /********************************/ TT_AppMain(); return 0; }
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); }
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; }
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); }
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); }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 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() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 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) { 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 */