def execute(self, args): self.validate_args(args) self.logger.info("Connecting to device...") ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) # Setup config self.config = RunConfiguration(ext_loader) for filepath in settings.get_config_paths(): self.config.load_config(filepath) self.config.set_agenda(Agenda()) self.config.finalize() context = LightContext(self.config) # Setup device self.device = ext_loader.get_device(settings.device, **settings.device_config) self.device.validate() self.device.dynamic_modules = [] self.device.connect() self.device.initialize(context) host_binary = context.resolver.get( Executable(NO_ONE, self.device.abi, 'revent')) self.target_binary = self.device.install_executable(host_binary) self.run(args)
def execute(self, agenda, selectors=None): # NOQA """ Execute the run specified by an agenda. Optionally, selectors may be used to only selecute a subset of the specified agenda. Params:: :agenda: an ``Agenda`` instance to be executed. :selectors: A dict mapping selector name to the coresponding values. **Selectors** Currently, the following seectors are supported: ids The value must be a sequence of workload specfication IDs to be executed. Note that if sections are specified inthe agenda, the workload specifacation ID will be a combination of the section and workload IDs. """ signal.connect(self._error_signalled_callback, signal.ERROR_LOGGED) signal.connect(self._warning_signalled_callback, signal.WARNING_LOGGED) self.logger.info('Initializing') self.ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) self.logger.debug('Loading run configuration.') self.config = RunConfiguration(self.ext_loader) for filepath in settings.get_config_paths(): self.config.load_config(filepath) self.config.set_agenda(agenda, selectors) self.config.finalize() config_outfile = os.path.join(settings.meta_directory, 'run_config.json') with open(config_outfile, 'w') as wfh: self.config.serialize(wfh) self.logger.debug('Initialising device configuration.') if not self.config.device: raise ConfigError('Make sure a device is specified in the config.') self.device = self.ext_loader.get_device(self.config.device, **self.config.device_config) self.device.validate() self.context = ExecutionContext(self.device, self.config) self.logger.debug('Loading resource discoverers.') self.context.initialize() self.context.resolver.load() self.context.add_artifact('run_config', config_outfile, 'meta') self.logger.debug('Installing instrumentation') for name, params in self.config.instrumentation.iteritems(): instrument = self.ext_loader.get_instrument( name, self.device, **params) instrumentation.install(instrument) instrumentation.validate() self.logger.debug('Installing result processors') result_manager = ResultManager() for name, params in self.config.result_processors.iteritems(): processor = self.ext_loader.get_result_processor(name, **params) result_manager.install(processor) result_manager.validate() self.logger.debug('Loading workload specs') for workload_spec in self.config.workload_specs: workload_spec.load(self.device, self.ext_loader) workload_spec.workload.init_resources(self.context) workload_spec.workload.validate() if self.config.flashing_config: if not self.device.flasher: msg = 'flashing_config specified for {} device that does not support flashing.' raise ConfigError(msg.format(self.device.name)) self.logger.debug('Flashing the device') self.device.flasher.flash(self.device) self.logger.info('Running workloads') runner = self._get_runner(result_manager) runner.init_queue(self.config.workload_specs) runner.run() self.execute_postamble()
def setUp(self): self.config = RunConfiguration(MockExtensionLoader()) self.config.load_config({'device': 'MockDevice'})