Example #1
0
void
ModuleTestListenerLoaderImpl::
load( const StringList& searchingPaths
    , TestResultReporter* resultReporter
    , TestSuiteResultReporter* suiteResultReporter
    , TestCaseResultReporter* caseResultReporter)
{
   loader->load(searchingPaths, getListenerSharedObjectName(name));

   typedef TestListener* (*TestListenerCreater) \
                  ( TestResultReporter* \
						, TestSuiteResultReporter* \
						, TestCaseResultReporter* \
						, int, char**);

   TestListenerCreater create = (TestListenerCreater) \
       loader->findSymbol(getCreaterSymbolName(name));

   listener = create( resultReporter 
                    , suiteResultReporter
                    , caseResultReporter
                    , args.first
                    , args.second);
   if(listener == 0)
   {
      throw Error("Cannot create listener");
   }
}
Example #2
0
void
ModuleTestListenerLoaderImpl::destroyListener()
{
   typedef void (*TestListenerDestroy)(TestListener*);
   TestListenerDestroy destroy = 0;

   __TESTNGPPST_TRY
   {
      destroy =  (TestListenerDestroy) \
         loader->findSymbol(getDestroySymbolName(name));

      destroy(listener);
   }
   __TESTNGPPST_CATCH_ALL
   {
      delete listener;
   }
   __TESTNGPPST_FINALLY
   {
      listener = 0;
      loader->unload();
   }
   __TESTNGPPST_DONE

}
Example #3
0
void AppFalcon::compileTLTable()
{
   ModuleLoader ml;
   // the load path is not relevant, as we load by file name or stream
   // apply options
   ml.compileTemplate( m_options.parse_ftd );
   ml.saveModules( false );
   ml.alwaysRecomp( true );

   // will throw Error* on failure
   Module* mod = loadInput( ml );

   // try to open the oputput stream.
   Stream* out = 0;
   try
   {
       String ioEncoding = getIoEncoding();
       out = AddSystemEOL(
            TranscoderFactory ( ioEncoding == "" ? "C" : ioEncoding,
                  openOutputStream ( "temp.ftt" ), true ) );
      // Ok, we have the output stream.
      if ( ! mod->saveTableTemplate( out, ioEncoding == "" ? "C" : ioEncoding ) )
         throw String( "can't write on output stream." );
   }
   catch( ... )
   {
      delete out;
      mod->decref();
      throw;
   }

   delete out;
   mod->decref();
}
Example #4
0
RangeSensor::RangeSensor(const QString &port, const trikKernel::Configurer &configurer, ModuleLoader &moduleLoader
		, const trikHal::HardwareAbstractionInterface &hardwareAbstraction)
	: mState("Range Sensor on " + port)
{
	if (!moduleLoader.load(configurer.attributeByPort(port, "module"))
			|| !moduleLoader.load(configurer.attributeByDevice("rangeSensor", "commonModule")))
	{
		QLOG_ERROR() << "Module loading failed";
		mState.fail();
		return;
	}

	mMinValue = ConfigurerHelper::configureInt(configurer, mState, port, "minValue");
	mMaxValue = ConfigurerHelper::configureInt(configurer, mState, port, "maxValue");

	mSensorWorker.reset(new RangeSensorWorker(configurer.attributeByPort(port, "eventFile"), mState
			, hardwareAbstraction));

	if (!mState.isFailed()) {
		mSensorWorker->moveToThread(&mWorkerThread);

		connect(mSensorWorker.data(), SIGNAL(newData(int, int, trikKernel::TimeVal))
				, this, SIGNAL(newData(int, int, trikKernel::TimeVal)));

		QLOG_INFO() << "Starting RangeSensor worker thread" << &mWorkerThread;

		mWorkerThread.start();
	}
Example #5
0
void MemChecker::start()
{
    if (!needMemCheck())
    {
        return;
    }

    ModuleLoader *loader = testcase->getLoader();

    typedef void (*start_t)(mem_checker::Reporter *, mem_checker::Reporter *);
    start_t starter = (start_t)loader->findSymbol("startMemChecker");

    TestFixture *fixture = testcase->getFixture();

    info = mem_checker::createReporter(InfoReporter(fixture));
    failure = mem_checker::createReporter(FailureReporter(fixture)); // Note: Reporter is new in runner.exe, and used in .dll. is this ok?
    starter(info, failure);
}
Example #6
0
void MemChecker::verify()
{
    if (!needMemCheck())
    {
        return;
    }

    ModuleLoader *loader = testcase->getLoader();

    typedef void (*verify_t)(void);
    verify_t verifier = (verify_t)loader->findSymbol("verifyMemChecker");
    verifier();

    //delete info;  // Note: this will cause linux run exception
    //delete failure;
    //info = 0;
    //failure = 0;
}
RangeSensor::RangeSensor(QString const &port, trikKernel::Configurer const &configurer, ModuleLoader &moduleLoader)
{
	if (!moduleLoader.load(configurer.attributeByPort(port, "module"))
			|| !moduleLoader.load(configurer.attributeByDevice("rangeSensor", "commonModule")))
	{
		QLOG_ERROR() << "Module loading failed";
		mState.fail();
		return;
	}

	mSensorWorker.reset(new RangeSensorWorker(configurer.attributeByPort(port, "eventFile"), mState));

	if (!mState.isFailed()) {
		mSensorWorker->moveToThread(&mWorkerThread);

		connect(mSensorWorker.data(), SIGNAL(newData(int, int)), this, SIGNAL(newData(int, int)));

		mWorkerThread.start();
	}
Example #8
0
void AppFalcon::generateAssembly()
{
   ModuleLoader ml;
   // the load path is not relevant, as we load by file name or stream
   // apply options
   ml.compileTemplate( m_options.parse_ftd );
   ml.saveModules( false );
   ml.alwaysRecomp( true );

   // will throw Error* on failure
   Module* mod = loadInput( ml );

   // try to open the oputput stream.
   Stream* out = 0;

   try
   {
      String ioEncoding = getIoEncoding();
      out = AddSystemEOL(
         TranscoderFactory ( ioEncoding == "" ? "C" : ioEncoding,
            openOutputStream( "fas" ), true ) );

      // Ok, we have the output stream.
      GenHAsm gasm(out);
      gasm.generatePrologue( mod );
      gasm.generate( ml.compiler().sourceTree() );
      if ( ! out->good() )
         throw String( "can't write on output stream." );
   }
   catch( const String & )
   {
      delete out;
      mod->decref();
      throw;
   }

   delete out;
   mod->decref();
}
Example #9
0
void AppFalcon::buildModule()
{
   ModuleLoader ml;
   // the load path is not relevant, as we load by file name or stream
   // apply options
   ml.compileTemplate( m_options.parse_ftd );
   ml.saveModules( false );
   ml.alwaysRecomp( true );

   // will throw Error* on failure
   Module* mod = loadInput( ml );

   // try to open the oputput stream.
   Stream* out = 0;

   try
   {
      // binary
      out = openOutputStream ( "fam" );

      // Ok, we have the output stream.
      GenCode gcode(mod);
      gcode.generate( ml.compiler().sourceTree() );
      if ( ! mod->save( out ) )
         throw String( "can't write on output stream." );
   }
   catch( const String & )
   {
      delete out;
      mod->decref();
      throw;
   }

   delete out;
   mod->decref();
}
Example #10
0
    // we have enough information.
    if (m_progressObserver) {
        m_progressObserver->initialize(Tr::tr("Resolving project for configuration %1")
                .arg(TopLevelProject::deriveId(parameters.finalBuildConfigurationTree())), 1);
        cancelationTimer.setSingleShot(false);
        QObject::connect(&cancelationTimer, &QTimer::timeout, [this]() {
            QBS_ASSERT(m_progressObserver, return);
            if (m_progressObserver->canceled())
                m_engine->cancel();
        });
        cancelationTimer.start(1000);
    }

    const FileTime resolveTime = FileTime::currentTime();
    Evaluator evaluator(m_engine, m_logger);
    ModuleLoader moduleLoader(&evaluator, m_logger);
    moduleLoader.setProgressObserver(m_progressObserver);
    moduleLoader.setSearchPaths(m_searchPaths);
    moduleLoader.setOldProjectProbes(m_oldProjectProbes);
    moduleLoader.setOldProductProbes(m_oldProductProbes);
    const ModuleLoaderResult loadResult = moduleLoader.load(parameters);
    ProjectResolver resolver(&evaluator, loadResult, parameters, m_logger);
    resolver.setProgressObserver(m_progressObserver);
    const TopLevelProjectPtr project = resolver.resolve();
    project->lastResolveTime = resolveTime;

    // E.g. if the top-level project is disabled.
    if (m_progressObserver)
        m_progressObserver->setFinished();

    return project;
Example #11
0
void AppFalcon::runModule()
{
   ModuleLoader ml;
   prepareLoader( ml );

   // Create the runtime using the given module loader.
   Runtime runtime( &ml );

   // now that we have the main module, inject other requested modules
   ListElement *pliter = m_options.preloaded.begin();
   while ( pliter != 0 )
   {
      Module *module = ml.loadName ( * ( ( String * ) pliter->data() ) );
      runtime.addModule( module );

      // abandon our reference to the injected module
      module->decref();

      pliter = pliter->next();
   }

   // then add the main module
   Module* mainMod = loadInput(ml);
   runtime.addModule( mainMod );

   // abandon our reference to the main module
   mainMod->decref();

   //===========================================
   // Prepare the virtual machine
   //
   VMachineWrapper vmachine;

   //redirect the VM streams to ours.
   // The machine takes ownership of the streams, so they won't be useable anymore
   // after the machine destruction.
   readyStreams();
   vmachine->stdIn( m_stdIn );
   vmachine->stdOut( m_stdOut );
   vmachine->stdErr( m_stdErr );
   // I have given real process streams to the vm
   vmachine->hasProcessStreams( true );

   // push the core module
   // we know we're not launching the core module.
   vmachine->launchAtLink( false );
   Module* core = core_module_init();
   #ifdef NDEBUG
      vmachine->link ( core );
   #else
      LiveModule *res = vmachine->link ( core );
      fassert ( res != 0 ); // should not fail
   #endif
   core->decref();

   // prepare environment
   Item *item_args = vmachine->findGlobalItem ( "args" );
   fassert ( item_args != 0 );
   CoreArray *args = new CoreArray ( m_argc - m_script_pos );

   String ioEncoding = getIoEncoding();
   for ( int ap = m_script_pos; ap < m_argc; ap ++ )
   {
      CoreString *cs = new CoreString;
      if ( ! TranscodeFromString ( m_argv[ap], ioEncoding, *cs ) )
      {
         cs->bufferize ( m_argv[ap] );
      }

      args->append ( cs );
   }

   item_args->setArray ( args );

   Item *script_name = vmachine->findGlobalItem ( "scriptName" );
   fassert ( script_name != 0 );
   *script_name = new CoreString ( mainMod->name() );

   Item *script_path = vmachine->findGlobalItem ( "scriptPath" );
   fassert ( script_path != 0 );
   *script_path = new CoreString ( mainMod->path() );

   // Link the runtime in the VM.
   // We'll be running the modules as we link them in.
   vmachine->launchAtLink( true );
   if ( vmachine->link( &runtime ) )
   {
      vmachine->launch();

      if ( vmachine->regA().isInteger() )
         exitval( ( int32 ) vmachine->regA().asInteger() );
   }
}
Example #12
0
void AppFalcon::prepareLoader( ModuleLoader &ml )
{
   // 1. Ready the module loader
   ModuleLoader *modLoader = &ml;
   ml.setSearchPath( getLoadPath() );

   // adds also the input path.
   if ( m_options.input != "" && m_options.input != "-" )
   {
      URI in_uri( m_options.input );
      in_uri.pathElement().setFilename("");
      // empty path? -- add current directory (may be removed from defaults)
      if ( in_uri.get() == "" )
         modLoader->addSearchPath ( "." );
      else
         modLoader->addSearchPath ( in_uri.get() );
   }

   // set the module preferred language; ok also if default ("") is used
   modLoader->setLanguage ( m_options.module_language );
   applyDirectives( modLoader->compiler() );
   applyConstants( modLoader->compiler() );

   // save the main module also if compile only option is set
   modLoader->saveModules ( m_options.save_modules );
   modLoader->compileInMemory ( m_options.comp_memory );
   modLoader->alwaysRecomp ( m_options.force_recomp );
   modLoader->sourceEncoding ( getSrcEncoding() );
   // normally, save is not mandatory, unless we compile them our own
   // should be the default, but we reset it.
   modLoader->saveMandatory ( false );

   // should we forcefully consider input as ftd?
   modLoader->compileTemplate ( m_options.parse_ftd );

   Engine::setSearchPath( modLoader->getSearchPath() );
}
Example #13
0
int main( int argc, char *argv[] )
{
   // Install a void ctrl-c handler (let ctrl-c to kill this app)
   Sys::_dummy_ctrl_c_handler();

   Falcon::Engine::AutoInit autoInit;


   int script_pos = argc;
   char *input_file = 0;
   FileStream *bincode_stream;

   stdOut = stdOutputStream();
   stdErr = stdErrorStream();
   stdIn = stdInputStream();

   // option decoding
   for ( int i = 1; i < argc; i++ )
   {
      char *op = argv[i];

      if (op[0] == '-' )
      {
         switch ( op[1] )
         {
            case 'e':
               if ( op[2] == 0 && i < argc + 1) {
                  io_encoding = argv[++i];
               }
               else {
                  io_encoding = op + 2;
               }
            break;

            case 'h': usage(); return 0;

            case 'L':
               if ( op[2] == 0 && i < argc + 1)
                  load_path = argv[++i];
               else
                  load_path = op + 2; break;
            break;

            case 'P':
               ignore_defpath = true;
               break;

            case 'l':
               if ( op[2] == 0 && i + 1 < argc )
                  module_language = argv[++i];
               else
                  module_language = op + 2;
            break;

            case 'p':
               if ( op[2] == 0 && i < argc + 1)
                  preloaded.pushBack( argv[++i] );
               else
                  preloaded.pushBack( op + 2 );
            break;


            case 'v': version(); return 0;

            default:
               stdOut->writeString( "falrun: unrecognized option '" );
               stdOut->writeString( op );
               stdOut->writeString( "'.\n\n" );
               usage();
               return 1;
         }
      }
      else {
         input_file = op;
         script_pos = i+1;
         break;
      }
   }

   // eventually change the encodings.
   io_encoding = get_io_encoding();

   if ( io_encoding != "" )
   {
      Transcoder *trans = TranscoderFactory( io_encoding, 0, true );
      if ( trans == 0 )
      {
         stdOut->writeString( "Fatal: unrecognized encoding '" + io_encoding + "'.\n\n" );
         return 1;
      }
      delete stdIn ;
      delete stdOut;
      delete stdErr;

      trans->setUnderlying( new StdInStream );

      stdIn = AddSystemEOL( trans, true );
      stdOut = AddSystemEOL( TranscoderFactory( io_encoding, new StdOutStream, true ), true );
      stdErr = AddSystemEOL( TranscoderFactory( io_encoding, new StdErrStream, true ), true );
   }

   if ( input_file == 0 ) {
      stdOut->writeString( "falrun: missing script name.\n" );
      usage();
      return 1;
   }

   bincode_stream = new FileStream;
   bincode_stream->open( input_file );

   if ( ! bincode_stream->good() )
   {
      stdOut->writeString( "falrun: Can't open file " );
      stdOut->writeString( input_file );
      stdOut->writeString( "\n" );
      stdOut->flush();
      return 1;
   }


   String module_name;
   String source_path;
   findModuleName( input_file, module_name );
   findModulepath( input_file, source_path );

   //-----------------------------------------
   // execute the script.
   //

   if ( source_path != "" )
      source_path += ";";

   try
   {
      ModuleLoader *modloader = new ModuleLoader( source_path + get_load_path() );
      Engine::setSearchPath( modloader->getSearchPath() );

      // set the module preferred language; ok also if default ("") is used
      modloader->setLanguage( module_language );

      Module *core = core_module_init();

      Module *main_mod = modloader->loadModule( bincode_stream );

      VMachine *vmachine = new VMachine(false);
      // change default machine streams.
      vmachine->stdIn( stdIn );
      vmachine->stdOut( stdOut );
      vmachine->stdErr( stdErr );
      vmachine->init();

      vmachine->link( core );
      core->decref();
      Runtime *runtime = new Runtime( modloader );

      // preload required modules

      ListElement *pliter = preloaded.begin();
      while( pliter != 0 )
      {
         Module *module = modloader->loadName( * ((String *) pliter->data()) );
         runtime->addModule( module );
         pliter = pliter->next();
      }

      Item *item_args = vmachine->findGlobalItem( "args" );
      fassert( item_args != 0 );
      CoreArray *args = new CoreArray( argc - script_pos );
      for ( int ap = script_pos; ap < argc; ap ++ ) {
         args->append( new CoreString( argv[ap] ) );
      }
      item_args->setArray( args );

      Item *script_name = vmachine->findGlobalItem( "scriptName" );
      fassert( script_name != 0 );
      script_name->setString( new CoreString( module_name ) );

      // the runtime will try to load the references.
      runtime->addModule( main_mod );

      if( vmachine->link( runtime ) )
      {
         vmachine->launch();

         if ( vmachine->regA().type() == FLC_ITEM_INT )
            return (int32) vmachine->regA().asInteger();

         return 0;
      }

      vmachine->finalize();
   }
   catch ( Error *err )
   {
      String temp;
      err->toString( temp );
      stdErr->writeString( "falcon: FATAL - Program terminated with error.\n" );
      stdErr->writeString( temp + "\n" );
      err->decref();
      return 1;
   }


   return 255;
}