Beispiel #1
0
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;
}
Beispiel #2
0
/******************************************************************************
**  Function: UTF_CFE_Init
**  Purpose:
**    Perform all standard initializations for the UTF. 
*/
int32 UTF_CFE_Init(void)
{
	/* Call CFE_ES_RegisterApp before CFE_TBL_EarlyInit to prevent warning */
	/* messages.  CFE_ES_RegisterApp can be called again later in application */
	/* and causes no problem in the UTF environment.                          */
	CFE_ES_RegisterApp();
	
	/* Initialize data structure which will be used by Table Services.    */
	CFE_TBL_EarlyInit ();
	
	/* Initialize data structure which will be used by Executive Services.    */
	UTF_ES_InitAppRecords();
	
	return CFE_SUCCESS;
	
}
Beispiel #3
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() */
Beispiel #4
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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() */
Beispiel #5
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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 */