Example #1
0
/****************************************************************************
Desc:
****************************************************************************/
int main( 
	int				argc,
	char ** 			argv)
{
	RCODE				rc = FERR_OK;
	IFlmTest *		pTest = NULL;
	unsigned int	i = 1;
	ArgList *		pArgs = NULL;
	TEST_INFO		testInfo;
	
	if( RC_BAD( rc = FlmStartup()))
	{
		goto Exit;
	}
	
	if( (pArgs = f_new ArgList) == NULL)
	{
		rc = RC_SET( FERR_MEM);
		goto Exit;
	}
	
#ifdef FLM_NLM
	f_conInit( 0, 0, "FLAIM Unit Test");
#endif	

	if( argc > 1)
	{
		if( (f_strcmp( argv[1], "--help") == 0) || 
			 (f_strcmp( argv[1], "-h") == 0))
		{
			printHelp();
			goto Exit;
		}
	}

	pArgs->expandArgs( argv, argc);

	while( i < pArgs->getNumEntries())
	{
		if( (*pArgs)[i][0] != '-')
		{
			goto Exit;
		}
				
		if( ((*pArgs)[i][1] == 'l') || ((*pArgs)[i][1] == 'L'))
		{
			testInfo.bLog = true;
			f_strcpy( testInfo.pszLogfile, &((*pArgs)[i][2]));
		}
		else if( ((*pArgs)[i][1] == 'd') || ((*pArgs)[i][1] == 'D'))
		{
			testInfo.bDisplay = true;
		}
		else if( ((*pArgs)[i][1] == 'c') || ((*pArgs)[i][1] == 'C'))
		{
			f_strcpy( testInfo.pszConfig, &((*pArgs)[i][2]));
		}
		else if( ((*pArgs)[i][1] == 'b') || ((*pArgs)[i][1] == 'B'))
		{
			f_strcpy( testInfo.pszBuild, &((*pArgs)[i][2]));
		}
		else if( ((*pArgs)[i][1] == 'u') || ((*pArgs)[i][1] == 'U'))
		{
			f_strcpy( testInfo.pszUser, &((*pArgs)[i][2]));
		}
		else
		{
			f_conPrintf( "\nInvalid parameter");
			printHelp();
			goto Exit;
		}
		
		i++;
	}

	f_conPrintf( "Running %s\n", argv[0]);

	if( RC_BAD( rc = getTest( &pTest)))
	{
		f_conPrintf( "ERROR: Unable to create test instance\n");
		goto Exit;
	}

	if( pTest->init( testInfo.bLog, testInfo.pszLogfile, testInfo.bDisplay,
		testInfo.pszConfig, testInfo.pszEnvironment,
		testInfo.pszBuild, testInfo.pszUser) != 0)
	{
		f_conPrintf( "\nTest initialization failed");
		goto Exit;
	}

	if( RC_BAD( rc = pTest->execute()))
	{
		goto Exit;
	}
	
Exit:

	if( pTest)
	{
		pTest->Release();
	}
	
	if( pArgs)
	{
		pArgs->Release();
	}
	
#ifdef FLM_NLM
	f_conPrintf( "\nPress any key to exit ... ");
	f_conGetKey();
#endif

#ifdef FLM_NLM
	f_conExit();
#endif
	FlmShutdown();

	return( (int)rc);
}