예제 #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;
}
예제 #2
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);
}
예제 #3
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);
}
예제 #4
0
파일: utf_test_mm.c 프로젝트: kingzappo/cfe
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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 */