def load(self, name): # # Load all the files. # self.ini = {'base': path.dirname(name), 'files': []} includes = [name] still_loading = True while still_loading: still_loading = False for include in includes: if not path.exists(include): rebased_inc = path.join(self.ini['base'], path.basename(include)) if not path.exists(rebased_inc): e = 'config: cannot find configuration: %s' % (include) raise error.general(e) include = rebased_inc if include not in self.ini['files']: try: self.config.read(include) except configparser.ParsingError as ce: raise error.general('config: %s' % (ce)) still_loading = True self.ini['files'] += [include] includes = [] if still_loading: for section in self.config.sections(): includes += self.comma_list(section, 'include', err=False)
def configuration_path(prog=None): '''Return the path the configuration data path for RTEMS. The path is relative to the installed executable. Mangage the installed package and the in source tree when running from within the rtems-tools repo. Note: 1. This code assumes the executable is wrapped and not using 'env'. 2. Ok to directly call os.path. ''' if prog is None: if len(sys.argv) == 1: exec_name = sys.argv[0] else: exec_name = sys.argv[1] else: exec_name = prog exec_name = os.path.abspath(exec_name) for top in [ os.path.dirname(os.path.dirname(exec_name)), os.path.dirname(exec_name) ]: config_path = path.join(top, 'share', 'rtems', 'config') if path.exists(config_path): break config_path = path.join(top, 'config') if path.exists(config_path): break config_path = None return config_path
def run(self, setName, covoarConfigFile, symbolFile): covoarResultDir = path.join(self.baseResultDir, setName) if (not path.exists(covoarResultDir)): path.mkdir(covoarResultDir) if (not path.exists(symbolFile)): log.stderr("Symbol set file: " + symbolFile + " doesn't exists! Covoar can not be run!") log.stderr("Skipping " + setName) return command = "covoar -C" + covoarConfigFile + " -S " + symbolFile + " -O " + covoarResultDir + " " + path.join(self.tracesDir, "*.exe") log.notice("Running covoar for " + setName, stdout_only=True) log.notice(command, stdout_only=True) executor = execute.execute(verbose=True, output=output_handler) exit_code = executor.shell(command, cwd=os.getcwd()) shutil.copy2(path.join(self.covoarSrcDir, 'table.js'), path.join(covoarResultDir, 'table.js')) shutil.copy2(path.join(self.covoarSrcDir, 'covoar.css'), path.join(covoarResultDir, 'covoar.css')) log.notice("Coverage run for " + setName + " finished ") status = "success" if (exit_code[0] != 0): status = "failure. Error code: " + str(exit_code[0]) log.notice("Coverage run for " + setName + " finished " + status) log.notice("-----------------------------------------------")
def run(self, set_name, symbol_file): covoar_result_dir = path.join(self.base_result_dir, set_name) if not path.exists(covoar_result_dir): path.mkdir(covoar_result_dir) if not path.exists(symbol_file): raise error.general('coverage: no symbol set file: %s' % (symbol_file)) exe = self._find_covoar() command = exe + ' -O ' + covoar_result_dir + \ ' -p ' + self.project_name + \ ' ' + self.executables + ' ' command += self.covoar_cmd log.notice() log.notice('Running coverage analysis: %s (%s)' % (set_name, covoar_result_dir)) start_time = datetime.datetime.now() executor = execute.execute(verbose=self.trace, output=self.output_handler) exit_code = executor.shell(command, cwd=os.getcwd()) if exit_code[0] != 0: raise error.general('coverage: covoar failure:: %d' % (exit_code[0])) end_time = datetime.datetime.now() log.notice('Coverage time: %s' % (str(end_time - start_time)))
def __init__(self, config, version, prefix, tools, rtems, build_dir, options): self.config = config self.build_dir = build_dir self.rtems_version = version self.prefix = prefix self.tools = tools self.rtems = rtems self.options = options self.counts = {'h': 0, 'exes': 0, 'objs': 0, 'libs': 0} self.results = results( rtems, { 'groups': ['Shared', 'BSP', 'Network', 'Tests', 'LibCPU', 'CPU Kit'], 'exclude': '.*Makefile.*', 'CPU Kit': '.*cpukit/.*', 'Network': '.*libnetworking/.*|.*librpc/.*', 'Tests': '.*testsuites/.*', 'BSP': '.*libbsp/.*', 'LibCPU': '.*libcpu/.*', 'Shared': '.*shared/.*' }) if not path.exists(path.join(rtems, 'configure')) or \ not path.exists(path.join(rtems, 'Makefile.in')) or \ not path.exists(path.join(rtems, 'cpukit')): raise error.general('RTEMS source path does not look like RTEMS')
def post_process(self): # Handle the log first. log.default = log.log(self.logfiles()) if self.trace(): log.tracing = True if self.quiet(): log.quiet = True # Handle the jobs for make if '_ncpus' not in self.defaults: raise error.general('host number of CPUs not set') ncpus = self.jobs(self.defaults['_ncpus']) if ncpus > 1: self.defaults['_smp_mflags'] = '-j %d' % (ncpus) else: self.defaults['_smp_mflags'] = self.defaults['nil'] # Load user macro files um = self.user_macros() if um: checked = path.exists(um) if False in checked: raise error.general('macro file not found: %s' % (um[checked.index(False)])) for m in um: self.defaults.load(m) # Check if the user has a private set of macros to load if 'RSB_MACROS' in os.environ: if path.exists(os.environ['RSB_MACROS']): self.defaults.load(os.environ['RSB_MACROS']) if 'HOME' in os.environ: rsb_macros = path.join(os.environ['HOME'], '.rsb_macros') if path.exists(rsb_macros): self.defaults.load(rsb_macros)
def run(self, set_name, covoar_config_file, symbol_file, gcnos_file): covoar_result_dir = path.join(self.base_result_dir, set_name) if (not path.exists(covoar_result_dir)): path.mkdir(covoar_result_dir) if (not path.exists(symbol_file)): log.stderr("Symbol set file: " + symbol_file + " doesn't exists! Covoar can not be run!") log.stderr("Skipping " + set_name) return command = "covoar -v -C" + covoar_config_file + " -S " + symbol_file + " -O " + covoar_result_dir + " " + path.join( self.traces_dir, "*.exe") if (path.exists(gcnos_file)): command = command + " -g " + gcnos_file log.notice("Running covoar for " + set_name, stdout_only=True) log.notice(command, stdout_only=True) executor = execute.execute(verbose=True, output=output_handler) exit_code = executor.shell(command, cwd=os.getcwd()) shutil.copy2(path.join(self.covoar_src_dir, 'table.js'), path.join(covoar_result_dir, 'table.js')) shutil.copy2(path.join(self.covoar_src_dir, 'covoar.css'), path.join(covoar_result_dir, 'covoar.css')) log.notice("Coverage run for " + set_name + " finished ") status = "success" if (exit_code[0] != 0): status = "failure. Error code: " + str(exit_code[0]) log.notice("Coverage run for " + set_name + " finished " + status) log.notice("-----------------------------------------------")
def _check_frist_second_stages(self): if not self.convert_kernel: if self['first_stage'] is not None and \ not path.exists(self['first_stage']): err = 'u-boot: first stage loader not found: %s' % \ (self['first_stage']) raise error.general(err) if self['second_stage'] is not None and \ not path.exists(self['second_stage']): err = 'u-boot: second stage loader not found: %s' % \ (self['second_stage']) raise error.general(err)
def load(bsp, opts): mandatory = ['bsp', 'arch', 'tester'] cfg = configuration.configuration() path_ = opts.defaults.expand('%%{_configdir}/bsps/%s.ini' % (bsp)) ini_name = path.basename(path_) for p in path.dirname(path_).split(':'): if path.exists(path.join(p, ini_name)): cfg.load(path.join(p, ini_name)) if not cfg.has_section(bsp): raise error.general('bsp section not found in ini: [%s]' % (bsp)) item_names = cfg.get_item_names(bsp, err=False) for m in mandatory: if m not in item_names: raise error.general( 'mandatory item not found in bsp section: %s' % (m)) opts.defaults.set_write_map(bsp, add=True) for i in cfg.get_items(bsp, flatten=False): opts.defaults[i[0]] = i[1] if not opts.defaults.set_read_map(bsp): raise error.general('cannot set BSP read map: %s' % (bsp)) # Get a copy of the required fields we need requires = cfg.comma_list(bsp, 'requires', err=False) del cfg user_config = opts.find_arg('--user-config') if user_config is not None: user_config = path.expanduser(user_config[1]) if not path.exists(user_config): raise error.general( 'cannot find user configuration file: %s' % (user_config)) else: if 'HOME' in os.environ: user_config = path.join(os.environ['HOME'], '.rtemstesterrc') if user_config: if path.exists(user_config): cfg = configuration.configuration() cfg.load(user_config) if cfg.has_section(bsp): for i in cfg.get_items(bsp, flatten=False): opts.defaults[i[0]] = i[1] # Check for the required values. for r in requires: if opts.defaults.get(r) is None: raise error.general('user value missing, BSP %s requires \'%s\': missing: %s' % \ (bsp, ', '.join(requires), r)) return opts.defaults['bsp'] raise error.general('cannot find bsp configuration file: %s.ini' % (bsp))
def run(self): if self.executables == None: log.stderr("ERROR: Executables for coverage analysis unspecified!") raise Exception('Executable for coverage analysis unspecified') if self.config_map == None: log.stderr("ERROR: Configuration map for coverage analysis unspecified!") raise Exception("ERROR: Configuration map for coverage analysis unspecified!") covoarConfigFile = path.join(self.tracesDir, 'config') self.writeCovoarConfig(covoarConfigFile) if(not path.exists(covoarConfigFile)): log.stderr("Covoar configuration file: " + path.abspath(covoarConfigFile) + " doesn't exists! Covoar can not be run! "); return -1 self._linkExecutables() symbolConfig = symbolsConfiguration() symbolConfig.load(self.symbolConfigPath) for sset in symbolConfig.symbolSets: if sset.isValid(): symbolSetFile = path.join(self.tracesDir, sset.name + ".symcfg") sset.writeSetFile(symbolSetFile) self.symbolSets.append(sset.name) covoar_run = covoar(self.testDir, self.symbolConfigPath, self.tracesDir, path.join(self.rtdir, 'covoar')) covoar_run.run(sset.name, covoarConfigFile, symbolSetFile) else: log.stderr("Invalid symbol set " + sset.name + ". Skipping covoar run.") self._generateReports(); self._cleanup(); self._summarize();
def load(args, optargs=None, command_path=None, defaults='%s' % (defaults_mc)): # # The path to this command if not supplied by the upper layers. # if command_path is None: command_path = path.dirname(args[0]) if len(command_path) == 0: command_path = '.' # # Check if there is a defaults.mc file under the command path. If so this is # the tester being run from within the git repo. If not found assume the tools # have been installed and the defaults is in the install prefix. # if path.exists(path.join(command_path, defaults_mc)): rtdir = command_path else: rtdir = '%{_prefix}/share/rtems/tester' defaults = '%s/%s' % (rtdir, defaults_mc) # # The command line contains the base defaults object all build objects copy # and modify by loading a configuration. # opts = command_line(args, optargs, macros.macros(name=defaults, rtdir=rtdir), command_path) options.load(opts) return opts
def open(self): def _readthread(me, x): line = '' while me.running: time.sleep(0.05) try: data = me.tty.read() except IOError as ioe: if ioe.errno == errno.EAGAIN: continue raise except: raise for c in data: if len(c) == 0: continue if c != chr(0): line += c if c == '\n': me.output(line) line = '' if stty and path.exists(self.dev): self.tty = stty.tty(self.dev) else: self.tty = telnet.tty(self.dev) self.tty.set(self.setup) self.tty.on() self.read_thread = threading.Thread(target=_readthread, name='tty[%s]' % (self.dev), args=(self, 0)) self.read_thread.daemon = True self.running = True self.read_thread.start()
def load(self, name): if not path.exists(name): raise error.general('config: cannot read configuration: %s' % (name)) self.name = name self.config.read(name) archs = [] self.profiles['profiles'] = self._comma_list('profiles', 'profiles', error = False) if len(self.profiles['profiles']) == 0: self.profiles['profiles'] = ['tier_%d' % (t) for t in range(1,4)] for p in self.profiles['profiles']: profile = {} profile['name'] = p profile['archs'] = self._comma_list(profile['name'], 'archs') archs += profile['archs'] for arch in profile['archs']: bsps = 'bsps_%s' % (arch) profile[bsps] = self._comma_list(profile['name'], bsps) self.profiles[profile['name']] = profile for a in set(archs): arch = {} arch['excludes'] = self._comma_list(a, 'excludes', error = False) arch['bsps'] = self._comma_list(a, 'bsps', error = False) for b in arch['bsps']: arch[b] = {} arch[b]['bspopts'] = self._comma_list(a, 'bspopts_%s' % (b), error = False) arch[b]['config'] = self._comma_list(a, 'config_%s' % (b), error = False) self.archs[a] = arch builds = {} builds['default'] = self._get_item('builds', 'default').split() builds['variations'] = self._comma_list('builds', 'variations') builds['var_options'] = {} for v in builds['variations']: builds['var_options'][v] = self._get_item('builds', v).split() self.builds = builds
def status(self): _status = {} if path.exists(self.path): ec, output = self._run(['status']) if ec == 0: state = 'none' for l in output.split('\n'): if l.startswith('# '): l = l[2:] if l.startswith('On branch '): _status['branch'] = l[len('On branch '):] elif l.startswith('Changes to be committed:'): state = 'staged' elif l.startswith('Changes not staged for commit:'): state = 'unstaged' elif l.startswith('Untracked files:'): state = 'untracked' elif l.startswith('HEAD detached'): state = 'detached' elif state != 'none' and len(l.strip()) != 0: if l[0].isspace(): l = l.strip() if l[0] != '(': if state not in _status: _status[state] = [] l = l[1:] if ':' in l: l = l.split(':')[1] _status[state] += [l.strip()] return _status
def parse(self): if not path.exists(self.summary_file_path): log.output('coverage: summary file %s does not exist!' % (self.summary_file_path)) self.is_failure = True with open(self.summary_file_path, 'r') as summary_file: self.bytes_analyzed = self._get_next_with_colon(summary_file) self.bytes_not_executed = self._get_next_with_colon(summary_file) self.percentage_executed = self._get_next_with_colon(summary_file) self.percentage_not_executed = self._get_next_with_colon( summary_file) self.ranges_uncovered = self._get_next_with_colon(summary_file) self.branches_total = self._get_next_with_colon(summary_file) self.branches_uncovered = self._get_next_with_colon(summary_file) self.branches_always_taken = self._get_next_without_colon( summary_file) self.branches_never_taken = self._get_next_without_colon( summary_file) if len(self.branches_uncovered) > 0 and len(self.branches_total) > 0: self.percentage_branches_covered = \ 1.0 - (float(self.branches_uncovered) / float(self.branches_total)) else: self.percentage_branches_covered = 0.0 return
def parse(self): if (not path.exists(self.summary_file_path)): log.warning("_summary file " + self.summary_file_path + " does not exist!") self.is_failure = True return summary_file = open(self.summary_file_path, 'r') self.bytes_analyzed = self._get_value_from_next_line_with_colon( summary_file) self.bytes_not_executed = self._get_value_from_next_line_with_colon( summary_file) self.percentage_executed = self._get_value_from_next_line_with_colon( summary_file) self.percentage_not_executed = self._get_value_from_next_line_with_colon( summary_file) self.ranges_uncovered = self._get_value_from_next_line_with_colon( summary_file) self.branches_total = self._get_value_from_next_line_with_colon( summary_file) self.branches_uncovered = self._get_value_from_next_line_with_colon( summary_file) self.branches_always_taken = self._get_value_from_next_line_without_colon( summary_file) self.branches_never_taken = self._get_value_from_next_line_without_colon( summary_file) summary_file.close() if not self.branches_uncovered == '' and not self.branches_total == '': self.percentage_branches_covered = 1 - float( self.branches_uncovered) / float(self.branches_total) else: self.percentage_branches_covered = 0.0 return
def load(args, optargs=None, command_path=None, defaults="%s" % (defaults_mc)): # # The path to this command if not supplied by the upper layers. # if command_path is None: command_path = path.dirname(args[0]) if len(command_path) == 0: command_path = "." # # Check if there is a defaults.mc file under the command path. If so this is # the tester being run from within the git repo. If not found assume the tools # have been installed and the defaults is in the install prefix. # if path.exists(path.join(command_path, defaults_mc)): rtdir = command_path else: rtdir = "%{_prefix}/share/rtems/tester" defaults = "%s/%s" % (rtdir, defaults_mc) # # The command line contains the base defaults object all build objects copy # and modify by loading a configuration. # opts = command_line(args, optargs, macros.macros(name=defaults, rtdir=rtdir), command_path) options.load(opts) return opts
def __init__(self, macros_, executables, prefix, symbol_set=None, trace=False): ''' Constructor ''' self.trace = trace self.macros = macros_ self.build_dir = self.macros['_cwd'] self.explanations_txt = self.macros.expand( self.macros['cov_explanations']) self.test_dir = path.join(self.build_dir, self.macros['bsp'] + '-coverage') if not path.exists(self.test_dir): path.mkdir(self.test_dir) self.rtdir = path.abspath(self.macros['_rtdir']) self.rtscripts = self.macros.expand(self.macros['_rtscripts']) self.coverage_config_path = path.join(self.rtscripts, 'coverage') self.symbol_config_path = path.join(self.coverage_config_path, 'symbol-sets.ini') self.symbol_select_path = path.join( self.coverage_config_path, self.macros['bsp'] + '-symbols.ini') self.executables = executables self.symbol_sets = [] self.no_clean = int(self.macros['_no_clean']) self.report_format = self.macros['cov_report_format'] self.symbol_set = symbol_set self.target = self.macros['target'] self.bsp_name = self.macros['bsp'].split('-')[0] self.prefix = prefix
def __init__(self, dev): if host.is_windows: raise error.general('termios not support on host') self.dev = dev self.default_attr = None self.fd = None self.if_on = False if host.is_windows: raise error.general('TTY consoles not supported on Windows.') if not path.exists(dev): raise error.general('dev not found: %s' % (dev)) try: self.fd = open(dev, 'rw') except IOError as ioe: raise error.general('opening tty dev: %s: %s' % (dev, ioe)) except: raise error.general('opening tty dev: %s: unknown' % (dev)) try: self.default_attr = termios.tcgetattr(self.fd) except: close(self.fd) raise error.general('cannot get termios attrs: %s' % (dev)) try: fcntl.fcntl(self.fd, fcntl.F_SETFL, fcntl.fcntl(self.fd, fcntl.F_GETFL) | os.O_NONBLOCK) except: close(self.fd) raise error.general('cannot make tty non-blocking: %s' % (dev)) self.attr = self.default_attr
def _cleanup(self): if not self.no_clean: log.notice('***Cleaning tempfiles***') path.removeall(self.traces_dir) for exe in self.executables: trace_file = exe + '.cov' if path.exists(trace_file): os.remove(trace_file)
def __init__(self, config, version, prefix, tools, rtems, build_dir, options): self.config = config self.build_dir = build_dir self.rtems_version = version self.prefix = prefix self.tools = tools self.rtems = rtems self.options = options self.errors = {'configure': 0, 'build': 0, 'tests': 0} self.counts = {'h': 0, 'exes': 0, 'objs': 0, 'libs': 0} self.warnings = warnings_counter(rtems) self.results = results() if not path.exists(path.join(rtems, 'configure')) or \ not path.exists(path.join(rtems, 'Makefile.in')) or \ not path.exists(path.join(rtems, 'cpukit')): raise error.general('RTEMS source path does not look like RTEMS')
def load(self, name, variation): if not path.exists(name): raise error.general('config: cannot read configuration: %s' % (name)) self.name = name try: self.config.read(name) except configparser.ParsingError as ce: raise error.general('config: %s' % (ce)) archs = [] self.profiles['profiles'] = self._comma_list('profiles', 'profiles', error=False) if len(self.profiles['profiles']) == 0: self.profiles['profiles'] = ['tier_%d' % (t) for t in range(1, 4)] for p in self.profiles['profiles']: profile = {} profile['name'] = p profile['archs'] = self._comma_list(profile['name'], 'archs') archs += profile['archs'] for arch in profile['archs']: bsps = 'bsps_%s' % (arch) profile[bsps] = self._comma_list(profile['name'], bsps) self.profiles[profile['name']] = profile for a in set(archs): arch = {} arch['excludes'] = {} for exclude in self._comma_list(a, 'exclude', error=False): arch['excludes'][exclude] = ['all'] for i in self._get_items(a, False): if i[0].startswith('exclude_'): exclude = i[0][len('exclude_'):] if exclude not in arch['excludes']: arch['excludes'][exclude] = [] arch['excludes'][exclude] += sorted( set([b.strip() for b in i[1].split(',')])) arch['bsps'] = self._comma_list(a, 'bsps', error=False) for b in arch['bsps']: arch[b] = {} arch[b]['bspopts'] = self._comma_list(a, 'bspopts_%s' % (b), error=False) self.archs[a] = arch builds = {} builds['default'] = self._get_item('builds', 'default').split() builds['variations'] = self._comma_list('builds', 'variations') if variation is None: variation = builds['default'] builds['variation'] = variation builds['base'] = self._get_item('builds', 'standard').split() builds['variations'] = self._comma_list('builds', variation) builds['var_options'] = {} for v in builds['variations']: if v == 'base': builds['var_options'][v] = self._get_item('builds', v).split() else: builds['var_options'][v] = [] self.builds = builds
def _cleanup(self): if not self.no_clean: if self.trace: log.output('Coverage cleaning tempfiles') for exe in self.executables: trace_file = exe + '.cov' if path.exists(trace_file): os.remove(trace_file) os.remove(self.symbol_select_path)
def run_jobs(self, jobs): if path.exists(self.build_dir) and not self.options['no-clean']: log.notice('Cleaning: %s' % (self.build_dir)) path.removeall(self.build_dir) self.start = _now() self.end = _now() self.duration = self.end - self.start self.average = self.duration env_path = os.environ['PATH'] os.environ['PATH'] = path.host(path.join(self.tools, 'bin')) + \ os.pathsep + os.environ['PATH'] job_count, build_job_count = jobs_option_parse(self.options['jobs']) builds = self._create_build_jobs(jobs, build_job_count) active_jobs = [] self.jobs_completed = 0 try: while len(builds) > 0 or len(active_jobs) > 0: new_jobs = job_count - len(active_jobs) if new_jobs > 0: active_jobs += builds[:new_jobs] builds = builds[new_jobs:] finished_jobs = [] for job in active_jobs: state = job.current_state() if state == 'ready': job.run() elif state != 'running': finished_jobs += [job] for job in finished_jobs: self._update_file_counts(job.get_file_counts()) job.log_output() job.clean() active_jobs.remove(job) self.jobs_completed += 1 if self.options['dry-run']: time.sleep(0) else: time.sleep(0.100) except: for job in active_jobs: try: job.kill() except: pass raise self.end = _now() os.environ['PATH'] = env_path self.duration = self.end - self.start if self.jobs_completed == 0: self.jobs_completed = 1 self._finished() self.average = self.duration / self.jobs_completed log.notice('Average BSP Build Time: %s' % (str(self.average))) log.notice('Total Time %s' % (str(self.duration)))
def __init__(self, config, version, prefix, tools, rtems, build_dir, options): self.config = config self.build_dir = build_dir self.rtems_version = version self.prefix = prefix self.tools = tools self.rtems = rtems self.options = options self.errors = { 'configure': 0, 'build': 0, 'tests': 0 } self.counts = { 'h' : 0, 'exes' : 0, 'objs' : 0, 'libs' : 0 } self.warnings = warnings_counter(rtems) if not path.exists(path.join(rtems, 'configure')) or \ not path.exists(path.join(rtems, 'Makefile.in')) or \ not path.exists(path.join(rtems, 'cpukit')): raise error.general('RTEMS source path does not look like RTEMS')
def isValid(self): if len(self.name) == 0: log.stderr("Invalid symbol set. Symbol set must have name! ") return False if len(self.libs) == 0: log.stderr("Invalid symbol set. Symbol set must have specified libraries!") return False for lib in self.libs: if not path.exists(lib): log.stderr("Invalid library path: " + lib) return False return True
def user_macros(self): # # Return something even if it does not exist. # if self.opts['macros'] is None: return None um = [] configs = self.defaults.expand('%{_configdir}').split(':') for m in self.opts['macros'].split(','): if path.exists(m): um += [m] else: # Get the expanded config macros then check them. cm = path.expand(m, configs) ccm = path.exists(cm) if True in ccm: # Pick the first found um += [cm[ccm.index(True)]] else: um += [m] return um if len(um) else None
def load(self, name, variation): if not path.exists(name): raise error.general('config: cannot read configuration: %s' % (name)) self.name = name try: self.config.read(name) except configparser.ParsingError as ce: raise error.general('config: %s' % (ce)) archs = [] self.profiles['profiles'] = self._comma_list('profiles', 'profiles', error = False) if len(self.profiles['profiles']) == 0: self.profiles['profiles'] = ['tier_%d' % (t) for t in range(1,4)] for p in self.profiles['profiles']: profile = {} profile['name'] = p profile['archs'] = self._comma_list(profile['name'], 'archs') archs += profile['archs'] for arch in profile['archs']: bsps = 'bsps_%s' % (arch) profile[bsps] = self._comma_list(profile['name'], bsps) self.profiles[profile['name']] = profile for a in set(archs): arch = {} arch['excludes'] = {} for exclude in self._comma_list(a, 'exclude', error = False): arch['excludes'][exclude] = ['all'] for i in self._get_items(a, False): if i[0].startswith('exclude_'): exclude = i[0][len('exclude_'):] if exclude not in arch['excludes']: arch['excludes'][exclude] = [] arch['excludes'][exclude] += sorted(set([b.strip() for b in i[1].split(',')])) arch['bsps'] = self._comma_list(a, 'bsps', error = False) for b in arch['bsps']: arch[b] = {} arch[b]['bspopts'] = self._comma_list(a, 'bspopts_%s' % (b), error = False) self.archs[a] = arch builds = {} builds['default'] = self._get_item('builds', 'default').split() builds['variations'] = self._comma_list('builds', 'variations') if variation is None: variation = builds['default'] builds['variation'] = variation builds['base'] = self._get_item('builds', 'standard').split() builds['variations'] = self._comma_list('builds', variation) builds['var_options'] = {} for v in builds['variations']: if v == 'base': builds['var_options'][v] = self._get_item('builds', v).split() else: builds['var_options'][v] = [] self.builds = builds
def _run(self, args, check=False): e = execute.capture_execution() if path.exists(self.path): cwd = self.path else: cwd = None cmd = [self.git] + args log.trace('cmd: (%s) %s' % (str(cwd), ' '.join(cmd))) exit_code, proc, output = e.spawn(cmd, cwd=path.host(cwd)) log.trace(output) if check: self._git_exit_code(exit_code, cmd, output) return exit_code, output
def run(self, set_name, symbol_file): covoar_result_dir = path.join(self.base_result_dir, set_name) if (not path.exists(covoar_result_dir)): path.mkdir(covoar_result_dir) if (not path.exists(symbol_file)): raise error.general( 'symbol set file: coverage/%s.symcfg was not created for covoar, skipping %s' % (symbol_file, set_name)) command = ('covoar -S ' + symbol_file + ' -O ' + covoar_result_dir + ' -f' + self.simulator_format + ' -T' + self.target_arch + ' -E' + self.explanations_txt + ' -c' + self.coverage_extension + ' -e' + self.executable_extension + ' -p' + self.project_name + ' ' + self.executables) log.notice('Running covoar for %s' % (set_name)) executor = execute.execute(verbose=True, output=self.output_handler) exit_code = executor.shell(command, cwd=os.getcwd()) if (exit_code[0] != 0): raise error.general('covoar failure exit code: %d' % (exit_code[0])) log.notice('Coverage run for %s finished successfully.' % (set_name)) log.notice('-----------------------------------------------')
def is_valid(self): if len(self.name) == 0: raise error.general('symbol set has no name in symbol_sets.cfg') if len(self.libs) == 0: raise error.general( 'symbol set contains no libraries to analyse in symbol_sets.cfg' ) for lib in self.libs: if not path.exists(lib): log.notice('Invalid library path: %s in symbol_sets.cfg' % (lib)) return False return True
def cleanup(self): log.notice('Cleaning up') for m in self.unmount_paths: log.output('unmount: %s' % (m)) self.unmount(m) for i in self.detach_images: log.output('detach: %s' % (i)) self.image_detach(i) if self.loader.clean: for r in self.remove_paths: if path.exists(r): log.output('remove: %s' % (r)) path.removeall(r)
def is_valid(self): if len(self.name) == 0: log.stderr("Invalid symbol set. Symbol set must have name! ") return False if len(self.libs) == 0: log.stderr( "Invalid symbol set. Symbol set must have specified libraries!" ) return False for lib in self.libs: if not path.exists(lib): log.stderr("Invalid library path: " + lib) return False return True
def __init__(self, dev): if options.host_windows: raise error.general('termios not support on host') self.dev = dev self.default_attr = None self.fd = None self.if_on = False if options.host_windows: raise error.general('TTY consoles not supported on Windows.') if not path.exists(dev): raise error.general('dev not found: %s' % (dev)) try: self.fd = open(dev, 'rw') except IOError, ioe: raise error.general('opening tty dev: %s: %s' % (dev, ioe))
def __call__(self, parser, namespace, value, option_string=None): current = getattr(namespace, self.dest) if not isinstance(current, list) and current is not None: raise argparse.ArgumentError( self, ' already provided: %s, have %s' % (value, current)) if path.exists(value): if not path.isfile(value): raise argparse.ArgumentError( self, 'is not a valid file: %s' % (value)) if not path.isreadable(value): raise argparse.ArgumentError(self, 'is not readable: %s' % (value)) if current is not None: value = current + [value] setattr(namespace, self.dest, value)
def create_path(self, where, recreate=True, cleanup=True): if path.exists(where): log.output('remove: %s' % (where)) path.removeall(where) try: log.output('make: %s' % (where)) path.mkdir(where) except: raise error.general('cannot create build path: %s' % (where)) if not path.isreadable(where): raise error.general('build path is not readable: %s' % (where)) if not path.iswritable(where): raise error.general('build path is not writeable: %s' % (where)) if cleanup: self.remove_paths += [where]
def load(self, name): names = self.expand(name).split(':') for n in names: log.trace('opening: %s' % (n)) if path.exists(n): try: mc = open(path.host(n), 'r') macros = self.parse(mc) mc.close() self.files += [n] return except IOError as err: pass raise error.general('opening macro file: %s' % \ (path.host(self.expand(name))))
def add_dir_name(self): for symbol_set in self.symbol_sets: symbol_set_dir = path.join(self.build_dir, self.bsp + '-coverage', symbol_set) html_files = path.listdir(symbol_set_dir) for html_file in html_files: html_file = path.join(symbol_set_dir, html_file) if path.exists(html_file) and 'html' in html_file: with open(html_file, 'r') as f: file_data = f.read() text = file_data[file_data.find('<div class="heading-title">')\ +len('<div class="heading-title">') \ : file_data.find('</div')] file_data = file_data.replace(text, text + '<br>' + symbol_set) with open(html_file, 'w') as f: f.write(file_data)
def parse(self): if(not path.exists(self.summaryFilePath)): log.warning("Summary file " + self.summaryFilePath + " does not exist!") self.isFailure = True return summaryFile = open(self.summaryFilePath,'r') self.bytes_analyzed = self._getValueFromNextLineWithColon(summaryFile) self.bytes_notExecuted = self._getValueFromNextLineWithColon(summaryFile) self.percentage_executed = self._getValueFromNextLineWithColon(summaryFile) self.percentage_notExecuted = self._getValueFromNextLineWithColon(summaryFile) self.ranges_uncovered = self._getValueFromNextLineWithColon(summaryFile) self.branches_total = self._getValueFromNextLineWithColon(summaryFile) self.branches_uncovered = self._getValueFromNextLineWithColon(summaryFile) self.branches_alwaysTaken = self._getValueFromNextLineWithoutColon(summaryFile) self.branches_neverTaken = self._getValueFromNextLineWithoutColon(summaryFile) summaryFile.close() self.percentage_branchesCovered = 1 - float(self.branches_uncovered) / float(self.branches_total) return
def run_args(args): b = None ec = 0 try: # # On Windows MSYS2 prepends a path to itself to the environment # path. This means the RTEMS specific automake is not found and which # breaks the bootstrap. We need to remove the prepended path. Also # remove any ACLOCAL paths from the environment. # if os.name == 'nt': cspath = os.environ['PATH'].split(os.pathsep) if 'msys' in cspath[0] and cspath[0].endswith('bin'): os.environ['PATH'] = os.pathsep.join(cspath[1:]) top = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) prefix = '/opt/rtems/%s' % (rtems_version()) tools = prefix build_dir = 'bsp-builds' logf = 'bsp-build-%s.txt' % (datetime.datetime.now().strftime('%Y%m%d-%H%M%S')) config_file = path.join(top, 'share', 'rtems', 'tester', 'rtems', 'rtems-bsps.ini') if not path.exists(config_file): config_file = path.join(top, 'tester', 'rtems', 'rtems-bsps.ini') argsp = argparse.ArgumentParser() argsp.add_argument('--prefix', help = 'Prefix to build the BSP.', type = str) argsp.add_argument('--rtems-tools', help = 'The RTEMS tools directory.', type = str) argsp.add_argument('--rtems', help = 'The RTEMS source tree.', type = str) argsp.add_argument('--build-path', help = 'Path to build in.', type = str) argsp.add_argument('--log', help = 'Log file.', type = str) argsp.add_argument('--stop-on-error', help = 'Stop on an error.', action = 'store_true') argsp.add_argument('--no-clean', help = 'Do not clean the build output.', action = 'store_true') argsp.add_argument('--profiles', help = 'Build the listed profiles.', type = str, default = 'tier-1') argsp.add_argument('--build', help = 'Build variation.', type = str) argsp.add_argument('--arch', help = 'Build the specific architecture.', type = str) argsp.add_argument('--bsp', help = 'Build the specific BSP.', type = str) argsp.add_argument('--dry-run', help = 'Do not run the actual builds.', action = 'store_true') opts = argsp.parse_args(args[1:]) if opts.log is not None: logf = opts.log log.default = log.log([logf]) log.notice('RTEMS Tools Project - RTEMS Kernel BSP Builder, %s' % (version.str())) if opts.rtems is None: raise error.general('No RTEMS source provided on the command line') if opts.prefix is not None: prefix = path.shell(opts.prefix) if opts.rtems_tools is not None: tools = path.shell(opts.rtems_tools) if opts.build_path is not None: build_dir = path.shell(opts.build_path) if opts.bsp is not None and opts.arch is None: raise error.general('BSP provided but no architecture') config = configuration() config.load(config_file, opts.build) options = { 'stop-on-error' : opts.stop_on_error, 'no-clean' : opts.no_clean, 'dry-run' : opts.dry_run, 'jobs' : 8 } b = build(config, rtems_version(), prefix, tools, path.shell(opts.rtems), build_dir, options) if opts.arch is not None: if opts.bsp is not None: b.build_arch_bsp(opts.arch, opts.bsp) else: b.build_arch(opts.arch) else: for profile in opts.profiles.split(','): b.build_profile(profile.strip()) except error.general as gerr: print(gerr) print('BSP Build FAILED', file = sys.stderr) ec = 1 except error.internal as ierr: print(ierr) print('BSP Build FAILED', file = sys.stderr) ec = 1 except error.exit as eerr: pass except KeyboardInterrupt: log.notice('abort: user terminated') ec = 1 if b is not None: b.results.report() sys.exit(ec)
def _arch_bsp_dir_clean(self, arch, bsp): if path.exists(self._path(arch, bsp)): path.removeall(self._path(arch, bsp))
def _arch_bsp_dir_make(self, arch, bsp): if not path.exists(self._path(arch, bsp)): path.mkdir(self._path(arch, bsp))
def prepareEnvironment(self): if(path.exists(self.tracesDir)): path.removeall(self.tracesDir) path.mkdir(self.tracesDir) log.notice("Coverage environment prepared", stdout_only = True)