def __init__(self, config, tree): self.config = config super(Runner, self).__init__(self.config, tree) systemConfig = self.config.args.config if systemConfig is not None: self.system_tree = plptree.get_configs_from_env( self.config.args.configDef, systemConfig) else: self.system_tree = plptree.get_configs_from_file( self.config.args.configFile)[0]
def run(self): self.config.addOption("--help", dest="showHelp", action="store_true", help="show this help message and exit") self.config.addOption( "--platform", dest="platform", default=None, choices=list(self.platforms.keys()), help="specify the platform. Default: %(default)s.") self.config.addOption( "--prop", dest="props", action="append", help="specify a property to be given to the platform", metavar="PATH") self.config.addOption( "--dir", dest="dir", default=os.getcwd(), help= "specify the test directory containing the binaries and from which the execution must be launched.", metavar="PATH") self.config.addOption( "--launcher", dest="launcher", default=os.path.join(os.environ['PULP_SDK_HOME'], 'bin', 'launcher'), help="specify the launcher command to be executed", metavar="CMD") self.config.addOption("--commands", dest="showCommands", action="store_true", default=False, help="show the available commands.") self.parser.add_argument('command', metavar='commands', type=str, nargs='*', help='a command to be executed') self.parser.add_argument("--chip", dest="chip", default=None, help="Specify target chip") self.config.addOption( "--dev", dest="dev", action="store_true", default=False, help="activate development mode (more advanced options)") self.config.addOption("--no-warnings", dest="warnings", action="store_false", default=True, help='deactivate warnings') self.config.addOption("--config", dest="config", default=None, help='specify the system configuration') self.config.addOption("--reentrant", dest="reentrant", action="store_true", help='This script was called was pulp-run') self.config.addOption("--config-file", dest="configFile", default=None, help='specify the system configuration file') self.config.addOption("--config-opt", dest="configOpt", default=[], action="append", help='specify configuration option') if self.config.getOption('dev'): self.config.addOption("--py-stack", dest="pyStack", action="store_true", default=False, help="activate Python tracestack") props = self.config.getOption('props') if props != None: for rawProp in props: prop = rawProp.split(':') self.config.setProperty(propertyName=prop[1], value=prop[2], path=prop[0]) testPath = os.path.abspath(self.config.getOption('dir')) try: os.makedirs(testPath) except: pass os.chdir(testPath) systemConfig = self.config.getOption('config') if systemConfig != None: self.system_tree = plptree.get_configs_from_env( self.config.args.configDef, systemConfig) else: self.system_tree = plptree.get_configs_from_file( self.config.getOption('configFile'))[0] self.pyStack = self.system_tree.get_bool('runner/py-stack') # First get the json configuration config_path = self.config.getOption('configFile') chip = self.config.getOption('chip') if chip is not None: config_path = os.path.join( os.path.dirname(os.path.dirname(sys.argv[0])), 'configs', 'systems', '%s.json' % chip) elif config_path is None: raise Exception('A chip or a config file must be specified') config = js.import_config_from_file(config_path) platform = self.config.getOption('platform') if platform is not None: config.set('platform', platform) self.system_tree = plptree.get_config_tree_from_dict(config.get_dict()) platform_name = config.get('**/platform').get() if platform_name == 'gvsoc' and self.system_tree.get('pulp_chip') in [ 'pulp', 'pulpissimo', 'oprecompkw', 'oprecompkw_sfloat', 'oprecompkw_sfloat_sa', 'multino', 'oprecompkw_sa', 'bigpulp', 'bigpulp-z-7045', 'wolfe' ]: platform_name = 'vp' try: module = imp.load_source('module', self.platforms[platform_name]) platform = module.Runner(self.config, config) for module in self.modules: platform.addParser(module(self.config, self.system_tree)) retval = platform.handleCommands() return retval except Exception as e: if self.pyStack: raise else: print(e) return -1
def __init__(self, tools_path=None): self.configs = plptree.get_configs_from_env(path=tools_path)
def __load_system_configs(self, configs): self.configs = plptree.get_configs_from_env(configs, [], self.tools_path)