Ejemplo n.º 1
0
	bool TestManager::RunTest(const char* path)
	{
		bool ok;
		TestParser testParser;
		Test *test = testParser.ParseTest(path);
		if (test != NULL)
		{
			// making log directory within tests directory:
			string testDirectory(path);
			testDirectory = testDirectory.substr(0, testDirectory.rfind(PATH_SEPARATOR) + 1);
			testDirectory.append(LOGS_DIRECTORY);
#ifdef _WIN32
			_mkdir(testDirectory.c_str());
#else
			mkdir(testDirectory.c_str(), S_IRWXU);
#endif

			// setting log file name:
			tstring fileName(LOG4CPLUS_TEXT(path));
			fileName.append(LOG4CPLUS_TEXT(".log"));
			size_t lastSeparatorIndex = fileName.rfind(PATH_SEPARATOR);
			fileName.insert(lastSeparatorIndex, 1, PATH_SEPARATOR);
			fileName.insert(lastSeparatorIndex + 1, LOGS_DIRECTORY);

			// configuring logger:
			PropertyConfigurator baseConfig(TESTER_LOG_CONFIG);
			helpers::Properties baseProperties = baseConfig.getProperties();
			helpers::Properties* properties = new helpers::Properties();
			vector<tstring> propertyNames = baseProperties.propertyNames();
			for (vector<string>::iterator it = propertyNames.begin(); it != propertyNames.end(); it++)
			{
				tstring key("log4cplus.");
				key.append(it->c_str());
				properties->setProperty(key, baseProperties.getProperty(it->c_str()));
			}

			properties->setProperty(LOG4CPLUS_TEXT("log4cplus.appender.RaccoonTestFileAppender.File"), fileName);

			Logger logger = Logger::getInstance(TESTER_LOGGER_NAME);
			SharedAppenderPtrList list = logger.getAllAppenders();
			PropertyConfigurator config(*properties);
			config.configure();
			for (SharedAppenderPtrList::iterator it = list.begin(); it != list.end(); it++)
			{
				logger.addAppender(*it);
			}

			LOG4CPLUS_INFO(logger, "Testing " << path << "...");
			ok = RunTest(*test);
			delete test;
			delete properties;
			logger.removeAppender(FILE_APPENDER_NAME);
		}
		else
		{
			ok = false;
		}

		return ok;
	}
Ejemplo n.º 2
0
int
main (int argc, char *argv[])
{
  int failureCount = 0;
  int i;

  GNUNET_log_setup ("test_fs_directory",
#if VERBOSE
                    "DEBUG",
#else
                    "WARNING",
#endif
                    NULL);
  for (i = 17; i < 1000; i *= 2)
    failureCount += testDirectory (i);
  if (failureCount != 0)
    return 1;
  return 0;
}
Ejemplo n.º 3
0
int main( int argc, char ** argv )
{
	QApplication::setColorSpec( QApplication::CustomColor );

    QApplication a( argc, argv );
	a.setApplicationVersion( APP_VERSION );

    QSplashScreen* splash = new QSplashScreen;
    splash->setPixmap( QPixmap(":/icons/tonatiuhsplash.png") );
    splash->show();

    Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;

    splash->showMessage(QObject::tr("Loading libraries..."), topRight, Qt::black);


    QApplication::addLibraryPath( QApplication::applicationDirPath()
	        + QDir::separator() + "marble" );

	SoQt::init( (QWidget *) NULL );

	//MFVec2::initClass();
	UserMField::initClass();
	UserSField::initClass();
	TSceneKit::initClass();
	TMaterial::initClass();
	TDefaultMaterial::initClass();
	TSeparatorKit::initClass();
	TShape::initClass();
	TCube::initClass();
	TLightShape::initClass();
	TShapeKit::initClass();
	TAnalyzerKit::initClass();
	TAnalyzerResultKit::initClass();
	TAnalyzerParameter::initClass();
	TAnalyzerResult::initClass();
	TAnalyzerLevel::initClass();
	TSquare::initClass();
	TLightKit::initClass();
	TSunShape::initClass();
	TDefaultSunShape::initClass();
	TTracker::initClass();
	TTrackerForAiming::initClass();
	TDefaultTracker::initClass();
	TSceneTracker::initClass();
	GraphicRootTracker::initClass();
	TTransmissivity::initClass();
	TDefaultTransmissivity::initClass();


	splash->showMessage( QObject::tr("Setting up the main window..."), topRight, Qt::black );


	QDir pluginsDirectory( qApp->applicationDirPath() );
	pluginsDirectory.cd( "plugins" );
	PluginManager pluginManager;
	pluginManager.LoadAvailablePlugins( pluginsDirectory );

    int exit;
   	if( argc > 1 )
   	{
   		QString tonatiuhFile = argv[1];

    	QFileInfo fileInfo( tonatiuhFile );
    	if( fileInfo.completeSuffix() == QLatin1String( "tnhs") )
    	{

    		QString fileName( argv[1] );
    		QFileInfo fileInfo( fileName );

    		QDir testDirectory( fileInfo.absolutePath() );
    		testDirectory.cd( "." );

    		QScriptEngine* interpreter = new QScriptEngine;
    		qScriptRegisterSequenceMetaType<QVector<QVariant> >(interpreter);


    		MainWindow* mw = new MainWindow( QLatin1String("") );
    		mw->SetPluginManager( &pluginManager );
    		QScriptValue tonatiuh = interpreter->newQObject( mw );
    		interpreter->globalObject().setProperty( "tonatiuh", tonatiuh );


    		QFile scriptFile( fileName );
    		if( !scriptFile.open( QIODevice::ReadOnly) )
    		{
    			QString errorMessage = QString( "Cannot open file %1." ).arg( fileName );
    			std::cerr<<errorMessage.toStdString()<<std::endl;
    		}


    		QTextStream in( &scriptFile );
    		QString program = in.readAll();
    		scriptFile.close();


    		QScriptSyntaxCheckResult checkResult = interpreter->checkSyntax( program );
    		if( checkResult.state() != QScriptSyntaxCheckResult::Valid )
    		{
    			QString errorMessage = QString( "Script Syntaxis Error.\n"
    					"Line: %1. %2" ).arg( QString::number( checkResult.errorLineNumber() ), checkResult.errorMessage () );
    			std::cerr<<errorMessage.toStdString()<<std::endl;
    			return -1;
    		}

    		QScriptValue result = interpreter->evaluate( program );
    		if( result.isError () )
    		{
    			QScriptValue lineNumber = result.property( "lineNumber");

    			QString errorMessage = QString( "Script Execution Error.\nLine %1. %2" ).arg( QString::number( lineNumber.toNumber() ), result.toString() );
    			std::cerr<<errorMessage.toStdString()<<std::endl;
    			return -1;

    		}

       		delete mw;
       		delete interpreter;
    		exit = 0;
    	}
    	else
    	{

    		MainWindow* mw = new MainWindow( tonatiuhFile );
    		mw->SetPluginManager( &pluginManager );


       		mw->show();
       	    splash->finish( mw );
       	    delete splash;
    	    exit = a.exec();
       		delete mw;
    	}
   	}
   	else
   	{
   		MainWindow* mw = new MainWindow("");
		mw->SetPluginManager( &pluginManager );
   		mw->show();
   	    splash->finish( mw );
   	    delete splash;
	    exit = a.exec();
   		delete mw;

   	}

	return exit;
}