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
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);

}
Beispiel #3
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 */