Example #1
0
    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("-----------------------------------------------")
Example #2
0
def run():
    import sys
    try:
        #
        # Run where defaults.mc is located
        #
        long_opts = {
            # key              macro        handler   param  defs   init
            '--file'  :      ('_file',      'path',   True,  None,  False)
        }
        opts = options.command_line(base_path = '.',
                                    argv = sys.argv,
                                    long_opts = long_opts)
        options.load(opts)
        s = file(opts.defaults['_file'], opts)
        s.load(opts.defaults['_file'])
        print(s)
        del s
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Example #3
0
def report_finished(reports, report_mode, reporting, finished, job_trace):
    processing = True
    while processing:
        processing = False
        reported = []
        for tst in finished:
            if tst not in reported and \
                    (reporting < 0 or tst.index == reporting):
                if job_trace:
                    log.notice('}} %*d: %s: %s (%d)' % (len(str(tst.total)), tst.index,
                                                        path.basename(tst.executable),
                                                        'reporting',
                                                        reporting))
                processing = True
                reports.log(tst.executable, report_mode)
                reported += [tst]
                reporting += 1
        finished[:] = [t for t in finished if t not in reported]
        if len(reported):
            del reported[:]
            if job_trace:
                print('}} threading:', threading.active_count())
                for t in threading.enumerate():
                    print('}} ', t.name)
    return reporting
Example #4
0
 def install(self, src, dst):
     src_base = path.basename(src)
     log.notice('Install: %s' % (src_base))
     asrc = path.abspath(src)
     adst = path.join(path.abspath(dst), src_base)
     log.output('Copy: %s -> %s' % (asrc, adst))
     path.copy(asrc, adst)
Example #5
0
def _job_trace(tst, msg, total, exe, active, reporting):
    s = ''
    for a in active:
        s += ' %d:%s' % (a.index, path.basename(a.executable))
    log.notice('}} %*d: %s: %s (%d %d %d%s)' %
               (len(str(tst.total)), tst.index, path.basename(
                   tst.executable), msg, reporting, total, exe, s))
Example #6
0
 def install_configuration(self, image, mountpoint):
     uenv_txt = self['uenv_txt']
     if uenv_txt is not None:
         log.output('Uenv txt: %s' % (uenv_txt))
         image.install(path.abspath(uenv_txt), mountpoint)
     else:
         template = None
         if self['net_dhcp'] or self['net_ip'] is not None:
             if self['net_dhcp']:
                 template = 'uenv_net_dhcp'
             else:
                 template = 'uenv_net_static'
             if self['net_server_ip']:
                 template += '_sip'
             if self['net_fdt']:
                 template += '_net_fdt'
         else:
             if self['kernel'] is not None:
                 template = 'uenv_exe'
             elif self['fdt'] is not None:
                 template = 'uenv'
             if self['fdt'] is not None:
                 template += '_fdt'
         if template is not None:
             log.notice('Uenv template: %s' % (template))
             uenv_start = self.comma_split(self['uenv_start'])
             uenv_body = self.comma_split(self[template])
             uenv_end = self.comma_split(self['uenv_end'])
             uenv = uenv_start + uenv_body + uenv_end
             image.install_text(self.filter_text(uenv),
                                path.join(mountpoint, self['boot_config']))
Example #7
0
 def _generate_reports(self, symbol_sets):
     log.notice('Coverage generating reports')
     if self.report_format == 'html':
         report = report_gen_html(symbol_sets, self.build_dir, self.rtdir,
                                  self.macros['bsp'])
         report.generate()
         report.add_covoar_css()
Example #8
0
 def _generate_reports(self):
     log.notice('Generating reports')
     if self.report_format == 'html':
         report = report_gen_html(self.symbol_sets, self.target_dir,
                                  self.rtdir)
         report.generate()
         report.add_covoar_src_path()
Example #9
0
    def _linkExecutables(self):
        log.notice("Linking executables to " + self.tracesDir)

        for exe in self.executables:
            dst = path.join(self.tracesDir, path.basename(exe))
            os.link(exe, dst)
        log.notice("Symlinks made")
Example #10
0
    def start(self, index, total, name, executable, bsp_arch, bsp):
        header = '[%*d/%*d] p:%-*d f:%-*d t:%-*d i:%-*d | %s/%s: %s' % \
                 (len(str(total)), index,
                  len(str(total)), total,
                  len(str(total)), self.passed,
                  len(str(total)), self.failed,
                  len(str(total)), self.timeouts,
                  len(str(total)), self.invalids,
                  bsp_arch,
                  bsp,
                  path.basename(executable))
        self.lock.acquire()
        if name in self.results:
            self.lock.release()
            raise error.general('duplicate test: %s' % (name))
        self.results[name] = { 'index': index,
                               'bsp': bsp,
                               'bsp_arch': bsp_arch,
                               'exe': executable,
                               'start': datetime.datetime.now(),
                               'end': None,
                               'result': None,
                               'output': None,
                               'header': header }

        self.lock.release()
        log.notice(header, stdout_only = True)
Example #11
0
    def parse(self):
        if (not path.exists(self.summary_file_path)):
            log.notice('summary file %s does not exist!' %
                       (self.summary_file_path))
            self.is_failure = True
            return

        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 - (float(self.branches_uncovered) / float(self.branches_total))
        else:
            self.percentage_branches_covered = 0.0
        return
Example #12
0
    def start(self, index, total, name, executable, bsp_arch, bsp):
        header = '[%*d/%*d] p:%-*d f:%-*d t:%-*d i:%-*d | %s/%s: %s' % \
                 (len(str(total)), index,
                  len(str(total)), total,
                  len(str(total)), self.passed,
                  len(str(total)), self.failed,
                  len(str(total)), self.timeouts,
                  len(str(total)), self.invalids,
                  bsp_arch,
                  bsp,
                  path.basename(executable))
        self.lock.acquire()
        if name in self.results:
            self.lock.release()
            raise error.general('duplicate test: %s' % (name))
        self.results[name] = {
            'index': index,
            'bsp': bsp,
            'bsp_arch': bsp_arch,
            'exe': executable,
            'start': datetime.datetime.now(),
            'end': None,
            'result': None,
            'output': None,
            'header': header
        }

        self.lock.release()
        log.notice(header, stdout_only=True)
Example #13
0
    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("-----------------------------------------------")
Example #14
0
def list(opts):
    path_ = opts.defaults.expand('%%{_configdir}/bsps/*.ini')
    bsps = path.collect_files(path_)
    log.notice(' BSP List:')
    for bsp in bsps:
        log.notice('  %s' % (path.basename(bsp[:-4])))
    raise error.exit()
Example #15
0
def run(args):
    try:
        long_opts = {
            # key              macro         handler   param  defs   init
            '--test-path'  : ('_test_path',  'path',   True,  None,  False),
            '--test-jobs'  : ('_test_jobs',  'jobs',   True,  'max', True),
            '--test-bool'  : ('_test_bool',  'bool',   False, '0',   True)
        }
        opts = command_line(base_path = '.',
                            argv = args,
                            optargs = None,
                            defaults = macros.macros(),
                            long_opts = long_opts,
                            command_path = '.')
        load(opts)
        log.notice('RTEMS Tools Project - Defaults, v%s' % (version.string()))
        opts.log_info()
        log.notice('Options:')
        log.notice(str(opts))
        log.notice('Defaults:')
        log.notice(str(opts.defaults))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        _notice(opts, 'abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Example #16
0
def list_bsps(opts):
    path_ = opts.defaults.expand('%%{_configdir}/bsps/*.mc')
    bsps = path.collect_files(path_)
    log.notice(' BSP List:')
    for bsp in bsps:
        log.notice('  %s' % (path.basename(bsp[:-3])))
    raise error.exit()
def report_finished(reports, report_mode, reporting, finished, job_trace):
    processing = True
    while processing:
        processing = False
        reported = []
        for tst in finished:
            if tst not in reported and \
                    (reporting < 0 or tst.index == reporting):
                if job_trace:
                    log.notice('}} %*d: %s: %s (%d)' % (len(str(tst.total)), tst.index,
                                                        path.basename(tst.executable),
                                                        'reporting',
                                                        reporting))
                processing = True
                reports.log(tst.executable, report_mode)
                reported += [tst]
                reporting += 1
        finished[:] = [t for t in finished if t not in reported]
        if len(reported):
            del reported[:]
            if job_trace:
                print('}} threading:', threading.active_count())
                for t in threading.enumerate():
                    print('}} ', t.name)
    return reporting
Example #18
0
def _job_trace(tst, msg, total, exe, active, reporting):
    s = ''
    for a in active:
        s += ' %d:%s' % (a.index, path.basename(a.executable))
    log.notice('}} %*d: %s: %s (%d %d %d%s)' % (len(str(tst.total)), tst.index,
                                                path.basename(tst.executable),
                                                msg,
                                                reporting, total, exe, s))
Example #19
0
 def install_text(self, text, dst):
     dst_base = path.basename(dst)
     log.notice('Install: %s' % (dst_base))
     adst = path.abspath(dst)
     log.output('Copy: text[%d] -> %s' % (len(text), adst))
     log.output([' ] ' + l for l in text])
     with open(adst, "w") as o:
         o.write(os.linesep.join(text))
Example #20
0
 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)
Example #21
0
def _check_dir(_opts, macro, value, constraint, silent=False):
    if constraint != 'none' and not path.isdir(value):
        if constraint == 'required':
            if not silent:
                log.notice('error: dir: not found: (%s) %s' % (macro, value))
            return False
        if not silent and _opts.warn_all():
            log.notice('warning: dir: not found: (%s) %s' % (macro, value))
    return True
Example #22
0
 def build(self):
     for arch in self.config.archs():
         self.build_arch(arch)
     log.notice('^ Profile Time %s' % (str(end - start)))
     log.notice('+  warnings:%d  exes:%d  objs:%d  libs:%d' % \
                (self.warnings.get(), self.counts['exes'],
                 self.counts['objs'], self.counts['libs']))
     log.output('Profile Warnings:')
     log.output(self.warnings.report())
Example #23
0
 def build(self):
     for arch in self.config.archs():
         self.build_arch(arch)
     log.notice('^ Profile Time %s' % (str(end - start)))
     log.notice('+  warnings:%d  exes:%d  objs:%d  libs:%d' % \
                (self.warnings.get(), self.counts['exes'],
                 self.counts['objs'], self.counts['libs']))
     log.output('Profile Warnings:')
     log.output(self.warnings.report())
Example #24
0
    def _link_executables(self):
        log.notice("Linking executables to " + self.traces_dir)

        for exe in self.executables:
            dst = path.join(self.traces_dir, path.basename(exe))
            try:
                os.link(exe, dst)
            except OSError, e:
                log.stderr("creating hardlink from " + path.abspath(exe) +
                           " to " + dst + " failed!")
                raise
Example #25
0
def run(args):
    try:
        _opts = load(args=args, defaults=defaults_mc)
        log.notice("RTEMS Test - Defaults, v%s" % (version.str()))
        _opts.log_info()
        log.notice("Options:")
        log.notice(str(_opts))
        log.notice("Defaults:")
        log.notice(str(_opts.defaults))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Example #26
0
def _check_exes(exes):
    ok = True
    first = True
    for exe in exes:
        log.output('check exe: %s' % (exe))
        if not check.check_exe(None, exe):
            if first:
                log.notice('Host executable(s) not found:')
                first = False
            log.notice(' %s' % (exe))
            ok = False
    return ok
Example #27
0
def run(args):
    try:
        _opts = load(args = args, defaults = 'rtems/testing/defaults.mc')
        log.notice('RTEMS Test - Defaults, v%s' % (version.str()))
        _opts.log_info()
        log.notice('Options:')
        log.notice(str(_opts))
        log.notice('Defaults:')
        log.notice(str(_opts.defaults))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Example #28
0
 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)
Example #29
0
 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
Example #30
0
 def report(self):
     self.lock.acquire()
     log_lock.acquire()
     passes = self.pass_count()
     fails = self.fail_count()
     log.notice('Passes: %d   Failures: %d' % (passes, fails))
     log.output()
     log.output('Build Report')
     log.output('   Passes: %d   Failures: %d' % (passes, fails))
     log.output(' Failures:')
     if fails == 0:
         log.output('  None')
     else:
         max_col = self._max_col('fails')
         for build in self.errors['fails']:
             arch, bsp, build_config = arch_bsp_build_parse(build)
             arch_bsp = self._arch_bsp(arch, bsp)
             for f in self.errors['fails'][build]:
                 config_cmd = f[2]
                 config_at = config_cmd.find('configure')
                 if config_at != -1:
                     config_cmd = config_cmd[config_at:]
                 log.output(' %*s:' % (max_col + 2, arch_bsp))
                 s1 = ' ' * 6
                 log.output(wrap([s1, config_cmd], lineend='\\', width=75))
                 if f[3] is not None:
                     s1 = ' ' * len(s1)
                     for msg in f[3]:
                         log.output(wrap([s1, msg], lineend='\\'))
     log.output(' Passes:')
     if passes == 0:
         log.output('  None')
     else:
         max_col = self._max_col('passes')
         for build in self.errors['passes']:
             arch, bsp, build_config = arch_bsp_build_parse(build)
             arch_bsp = self._arch_bsp(arch, bsp)
             for f in self.errors['passes'][build]:
                 config_cmd = f[1]
                 config_at = config_cmd.find('configure')
                 if config_at != -1:
                     config_cmd = config_cmd[config_at:]
                 log.output(' %s (%5d):' % (arch_bsp, f[2]))
                 log.output(
                     wrap([' ' * 6, config_cmd], lineend='\\', width=75))
     log_lock.release()
     self.lock.release()
Example #31
0
 def start(self):
     log.notice('Proxy: %s:%i' % (self.host, self.port))
     if self.host == 'all':
         host = ''
     else:
         host = self.host
     try:
         self.server = udp_server((host, self.port), udp_handler)
     except Exception as e:
         raise error.general('proxy create: %s' % (e))
     self.server.proxy = self
     self._lock()
     try:
         self.server_thread = threading.Thread(
             target=self.server.serve_forever)
         self.server_thread.daemon = True
         self.server_thread.start()
     finally:
         self._unlock()
Example #32
0
 def handle(self):
     client_ip = self.client_address[0]
     client_port = self.client_address[1]
     client = '%s:%i' % (client_ip, client_port)
     session = tftp_session()
     finished = session.data(client_ip, client_port, self.request[0])
     if not finished:
         timeout = session.get_timeout(self.server.proxy.session_timeout, 1)
         host = self.server.proxy.get_host(client_ip)
         if host is not None:
             session_count = self.server.proxy.get_session_count()
             log.notice(' ] %6d: session: %s -> %s: start' %
                        (session_count, client, host))
             host_ip, host_server_port = host_port_split(host)
             host_port = host_server_port
             sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
             sock.settimeout(timeout)
             log.trace(
                 '  > ' +
                 session.decode(client_ip, client_port, self.request[0]))
             sock.sendto(self.request[0], (host_ip, host_port))
             while not finished:
                 try:
                     data, address = sock.recvfrom(16 * 1024)
                 except socket.error as se:
                     log.notice(' ] session: %s -> %s: error: %s' %
                                (client, host, se))
                     return
                 except socket.gaierror as se:
                     log.notice(' ] session: %s -> %s: error: %s' %
                                (client, host, se))
                     return
                 except:
                     return
                 finished = session.data(address[0], address[1], data)
                 if address[0] == host_ip:
                     if host_port == host_server_port:
                         host_port = address[1]
                     if address[1] == host_port:
                         log.trace(
                             '  < ' +
                             session.decode(address[0], address[1], data))
                         sock.sendto(data, (client_ip, client_port))
                 elif address[0] == client_ip and address[1] == client_port:
                     log.trace('  > ' +
                               session.decode(address[0], address[1], data))
                     sock.sendto(data, (host_ip, host_port))
             log.notice(' ] %6d: session: %s -> %s: end' %
                        (session_count, client, host))
         else:
             mac = getmac.get_mac_address(ip=client_ip)
             log.trace(' . request: host not found: %s (%s)' %
                       (client, mac))
Example #33
0
 def report(self):
     log.notice('* Passes: %d   Failures: %d' %
                (len(self.passes), len(self.fails)))
     log.output()
     log.output('Build Report')
     log.output('   Passes: %d   Failures: %d' %
                (len(self.passes), len(self.fails)))
     log.output(' Failures:')
     if len(self.fails) == 0:
         log.output('None')
     else:
         max_col = 0
         for f in self.fails:
             arch_bsp = self._arch_bsp(f[0], f[1])
             if len(arch_bsp) > max_col:
                 max_col = len(arch_bsp)
         for f in self.fails:
             config_cmd = f[2]
             config_at = config_cmd.find('configure')
             if config_at != -1:
                 config_cmd = config_cmd[config_at:]
             log.output(' %*s:  %s' % (max_col + 2,
                                       self._arch_bsp(f[0], f[1]),
                                       config_cmd))
     log.output(' Passes:')
     if len(self.passes) == 0:
         log.output('None')
     else:
         max_col = 0
         for f in self.passes:
             arch_bsp = self._arch_bsp(f[0], f[1])
             if len(arch_bsp) > max_col:
                 max_col = len(arch_bsp)
         for f in self.passes:
             config_cmd = f[2]
             config_at = config_cmd.find('configure')
             if config_at != -1:
                 config_cmd = config_cmd[config_at:]
             log.output(' %*s:  %5d  %s' % (max_col + 2,
                                            self._arch_bsp(f[0], f[1]),
                                            f[3],
                                            config_cmd))
Example #34
0
 def report(self):
     log.notice('* Passes: %d   Failures: %d' %
                (len(self.passes), len(self.fails)))
     log.output()
     log.output('Build Report')
     log.output('   Passes: %d   Failures: %d' %
                (len(self.passes), len(self.fails)))
     log.output(' Failures:')
     if len(self.fails) == 0:
         log.output('None')
     else:
         max_col = 0
         for f in self.fails:
             arch_bsp = self._arch_bsp(f[0], f[1])
             if len(arch_bsp) > max_col:
                 max_col = len(arch_bsp)
         for f in self.fails:
             config_cmd = f[2]
             config_at = config_cmd.find('configure')
             if config_at != -1:
                 config_cmd = config_cmd[config_at:]
             log.output(
                 ' %*s:  %s' %
                 (max_col + 2, self._arch_bsp(f[0], f[1]), config_cmd))
     log.output(' Passes:')
     if len(self.passes) == 0:
         log.output('None')
     else:
         max_col = 0
         for f in self.passes:
             arch_bsp = self._arch_bsp(f[0], f[1])
             if len(arch_bsp) > max_col:
                 max_col = len(arch_bsp)
         for f in self.passes:
             config_cmd = f[2]
             config_at = config_cmd.find('configure')
             if config_at != -1:
                 config_cmd = config_cmd[config_at:]
             log.output(
                 ' %*s:  %5d  %s' % (max_col + 2, self._arch_bsp(
                     f[0], f[1]), f[3], config_cmd))
Example #35
0
 def prepare_environment(self):
     symbol_set_files = []
     if (path.exists(self.traces_dir)):
         path.removeall(self.traces_dir)
     path.mkdir(self.traces_dir)
     if self.config_map is None:
         raise error.general(
             'no coverage configuration map specified in %s config file' %
             {bsp})
     self.symbol_config.load(self.symbol_config_path, self.path_to_builddir)
     for sset in self.symbol_config.symbol_sets:
         if sset.is_valid():
             symbol_set_file = (path.join(self.traces_dir,
                                          sset.name + '.symcfg'))
             sset.write_set_file(symbol_set_file)
             self.symbol_sets.append(sset.name)
         else:
             log.notice(
                 'Invalid symbol set %s in symbol_sets.cfg. skipping covoar run.'
                 % (sset.name))
     log.notice('Coverage environment prepared')
Example #36
0
    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)))
Example #37
0
def run(args):
    import sys
    try:
        _opts = options.command_line(argv=args)
        options.load(_opts)
        log.notice('RTEMS Toolkit - Check, v%s' % (version.string()))
        if host_setup(_opts):
            print('Environment is ok')
        else:
            print('Environment is not correctly set up')
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Example #38
0
 def summary(self):
     def show_state(results, state, max_len):
         for name in results:
             if results[name]['result'] == state:
                 log.output(' %s' % (path.basename(name)))
     log.output()
     log.notice('Passed:   %*d' % (self.total_len, self.passed))
     log.notice('Failed:   %*d' % (self.total_len, self.failed))
     log.notice('Timeouts: %*d' % (self.total_len, self.timeouts))
     log.notice('Invalid:  %*d' % (self.total_len, self.invalids))
     log.output('----------%s' % ('-' * self.total_len))
     log.notice('Total:    %*d' % (self.total_len, self.total))
     log.output()
     if self.failed:
         log.output('Failures:')
         show_state(self.results, 'failed', self.name_max_len)
     if self.timeouts:
         log.output('Timeouts:')
         show_state(self.results, 'timeout', self.name_max_len)
     if self.invalids:
         log.output('Invalid:')
         show_state(self.results, 'invalid', self.name_max_len)
Example #39
0
    def start(self, index, total, name, executable, bsp_arch, bsp,
              show_header):
        header = '[%*d/%*d] p:%-*d f:%-*d u:%-*d e:%-*d I:%-*d B:%-*d ' \
                 't:%-*d L:%-*d i:%-*d W:%-*d | %s/%s: %s' % \
                 (len(str(total)), index,
                  len(str(total)), total,
                  len(str(total)), self.passed,
                  len(str(total)), self.failed,
                  len(str(total)), self.user_input,
                  len(str(total)), self.expected_fail,
                  len(str(total)), self.indeterminate,
                  len(str(total)), self.benchmark,
                  len(str(total)), self.timeouts,
                  len(str(total)), self.test_too_long,
                  len(str(total)), self.invalids,
                  len(str(total)), self.wrong_version + self.wrong_build + self.wrong_tools,
                  bsp_arch,
                  bsp,
                  path.basename(name))
        self.lock.acquire()
        if name in self.results:
            self.lock.release()
            raise error.general('duplicate test: %s' % (name))
        self.results[name] = {
            'index': index,
            'bsp': bsp,
            'bsp_arch': bsp_arch,
            'exe': name,
            'start': datetime.datetime.now(),
            'end': None,
            'result': None,
            'output': None,
            'header': header
        }

        self.lock.release()
        if show_header:
            log.notice(header, stdout_only=True)
Example #40
0
    def summary(self):
        def show_state(results, state, max_len):
            for name in results:
                if results[name]['result'] == state:
                    log.output(' %s' % (path.basename(name)))

        log.output()
        log.notice('Passed:   %*d' % (self.total_len, self.passed))
        log.notice('Failed:   %*d' % (self.total_len, self.failed))
        log.notice('Timeouts: %*d' % (self.total_len, self.timeouts))
        log.notice('Invalid:  %*d' % (self.total_len, self.invalids))
        log.output('----------%s' % ('-' * self.total_len))
        log.notice('Total:    %*d' % (self.total_len, self.total))
        log.output()
        if self.failed:
            log.output('Failures:')
            show_state(self.results, 'failed', self.name_max_len)
        if self.timeouts:
            log.output('Timeouts:')
            show_state(self.results, 'timeout', self.name_max_len)
        if self.invalids:
            log.output('Invalid:')
            show_state(self.results, 'invalid', self.name_max_len)
Example #41
0
def _check_exe(_opts, macro, value, constraint, silent=False):

    if len(value) == 0 or constraint == 'none':
        return True

    orig_value = value

    if path.isabspath(value):
        if path.isfile(value):
            return True
        if os.name == 'nt':
            if path.isfile('%s.exe' % (value)):
                return True
        value = path.basename(value)
        absexe = True
    else:
        absexe = False

    paths = os.environ['PATH'].split(os.pathsep)

    if _check_paths(value, paths):
        if absexe:
            if not silent:
                log.notice(
                    'warning: exe: absolute exe found in path: (%s) %s' %
                    (macro, orig_value))
        return True

    if constraint == 'optional':
        if not silent:
            log.trace('warning: exe: optional exe not found: (%s) %s' %
                      (macro, orig_value))
        return True

    if not silent:
        log.notice('error: exe: not found: (%s) %s' % (macro, orig_value))
    return False
Example #42
0
 def build_arch(self, arch):
     start = datetime.datetime.now()
     log.output('=' * 70)
     log.notice(']] Architecture: %s' % (arch))
     if not self.confif.arch_present(arch):
         raise error.general('Architecture not found: %s' % (arch))
     for bsp in self._bsps(arch):
         self.build_arch_bsp(arch, bsp)
     log.notice('^ Architecture Time %s' % (str(end - start)))
     log.notice('  warnings:%d  exes:%d  objs:%s  libs:%d' % \
                self.warnings.get(), self.counts['exes'],
                self.counts['objs'], self.counts['libs'])
     log.output('Architecture Warnings:')
     log.output(self.warnings.report())
Example #43
0
 def build_profile(self, profile):
     if not self.config.profile_present(profile):
         raise error.general('BSP not found: %s/%s' % (arch, bsp))
     start = datetime.datetime.now()
     log.notice(']] Profile: %s' % (profile))
     for arch in self.config.profile_archs(profile):
         for bsp in self.config.profile_arch_bsps(profile, arch):
             self.build_arch_bsp(arch, bsp)
     end = datetime.datetime.now()
     log.notice('^ Profile Time %s' % (str(end - start)))
     log.notice('  warnings:%d  exes:%d  objs:%d  libs:%d' % \
                (self.warnings.get(), self.counts['exes'],
                 self.counts['objs'], self.counts['libs']))
     log.output('Profile Warnings:')
     log.output(self.warnings.report())
Example #44
0
                                      rtdir = command_path),
                        command_path)
    options.load(opts)
    return opts

def run(args):
    try:
        _opts = load(args = args, defaults = 'rtems/testing/defaults.mc')
        log.notice('RTEMS Test - Defaults, v%s' % (version.str()))
        _opts.log_info()
        log.notice('Options:')
        log.notice(str(_opts))
        log.notice('Defaults:')
        log.notice(str(_opts.defaults))
    except error.general, gerr:
        print gerr
        sys.exit(1)
    except error.internal, ierr:
        print ierr
        sys.exit(1)
    except error.exit, eerr:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)

if __name__ == '__main__':
    import sys
    run(sys.argv)
Example #45
0
 def build_arch_bsp(self, arch, bsp):
     if not self.config.bsp_present(arch, bsp):
         raise error.general('BSP not found: %s/%s' % (arch, bsp))
     log.output('-' * 70)
     log.notice('] BSP: %s/%s' % (arch, bsp))
     log.notice('. Creating: %s' % (self._path(arch, bsp)))
     self._arch_bsp_dir_clean(arch, bsp)
     self._arch_bsp_dir_make(arch, bsp)
     variations = self._variations(arch, bsp)
     build_set = self._build_set(variations)
     bsp_start = datetime.datetime.now()
     bsp_warnings = warnings_counter(self.rtems)
     env_path = os.environ['PATH']
     os.environ['PATH'] = path.host(path.join(self.tools, 'bin')) + \
                          os.pathsep + os.environ['PATH']
     for bs in sorted(build_set.keys()):
         warnings = warnings_counter(self.rtems)
         start = datetime.datetime.now()
         log.output('- ' * 35)
         log.notice('. Configuring: %s' % (bs))
         try:
             result = '+ Pass'
             bpath = self._build_dir(arch, bsp, bs)
             path.mkdir(bpath)
             config_cmd = self._config_command(build_set[bs], arch, bsp)
             cmd = config_cmd
             e = execute.capture_execution(log = warnings)
             log.output('run: ' + cmd)
             if self.options['dry-run']:
                 exit_code = 0
             else:
                 exit_code, proc, output = e.shell(cmd, cwd = path.host(bpath))
             if exit_code != 0:
                 result = '- FAIL'
                 self.errors['configure'] += 1
                 log.notice('- Configure failed: %s' % (bs))
                 log.output('cmd failed: %s' % (cmd))
                 if self.options['stop-on-error']:
                     raise error.general('Configuring %s failed' % (bs))
             else:
                 log.notice('. Building: %s' % (bs))
                 cmd = 'make'
                 if 'jobs' in self.options:
                     cmd += ' -j %s' % (self.options['jobs'])
                 log.output('run: ' + cmd)
                 if self.options['dry-run']:
                     exit_code = 0
                 else:
                     exit_code, proc, output = e.shell(cmd, cwd = path.host(bpath))
                 if exit_code != 0:
                     result = '- FAIL'
                     self.errors['build'] += 1
                     log.notice('- FAIL: %s: %s' % (bs, self._error_str()))
                     log.output('cmd failed: %s' % (cmd))
                     if self.options['stop-on-error']:
                         raise error.general('Building %s failed' % (bs))
                 files = self._count_files(arch, bsp, bs)
                 log.notice('%s: %s: warnings:%d  exes:%d  objs:%s  libs:%d' % \
                            (result, bs, warnings.get(),
                             files['exes'], files['objs'], files['libs']))
             log.notice('  %s' % (self._error_str()))
             self.results.add(result[0] == '+', arch, bsp, config_cmd, warnings.get())
         finally:
             end = datetime.datetime.now()
             if not self.options['no-clean']:
                 log.notice('. Cleaning: %s' % (self._build_dir(arch, bsp, bs)))
                 path.removeall(self._build_dir(arch, bsp, bs))
         log.notice('^ Time %s' % (str(end - start)))
         log.output('Warnings Report:')
         log.output(warnings.report())
         warnings.accumulate(bsp_warnings)
         warnings.accumulate(self.warnings)
     bsp_end = datetime.datetime.now()
     log.notice('^ BSP Time %s' % (str(bsp_end - bsp_start)))
     log.output('BSP Warnings Report:')
     log.output(bsp_warnings.report())
     os.environ['PATH'] = env_path
Example #46
0
 def prepareEnvironment(self):
     if(path.exists(self.tracesDir)):
         path.removeall(self.tracesDir)
     path.mkdir(self.tracesDir)
     log.notice("Coverage environment prepared", stdout_only = True)
Example #47
0
def run(command_path = None):
    import sys
    stdtty = console.save()
    opts = None
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--report-mode': 'Reporting modes, failures (default),all,none',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)' }
        opts = options.load(sys.argv,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            list_bsps(opts)
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            rtems_tools = rtems_tools[1]
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None:
            raise error.general('no RTEMS BSP provided')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general('BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])
        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params())
        if len(executables) == 0:
            raise error.general('no executbles supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests([l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        tests = []
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports,
                               executables[exe],
                               rtems_tools, bsp, bsp_config,
                               opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create',
                               total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead',
                                   total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports,
                                                report_mode,
                                                reporting,
                                                finished,
                                                job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode,
                                    reporting, finished, job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Testing time: %s' % (str(end_time - start_time)))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Example #48
0
def run(command_path = None):
    import sys
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--report-mode': 'Reporting modes, failures (default),all,none',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--filter':      'Glob that executables must match to run (default: ' +
                              default_exefilter + ')',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)',
                    '--rtems-builddir': 'The path to the build directory ( including e.g. /b-leon2/ )'}
        opts = options.load(sys.argv,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        exe_filter = opts.find_arg('--filter')
        if exe_filter:
            exe_filter = exe_filter[1]
        else:
            exe_filter = default_exefilter
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            bla = '%{_prefix}'
            print "prefixx: " + bla
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        else:
            rtems_tools = '%{_prefix}'
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or invalid option')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general('BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])

        path_to_builddir= opts.find_arg('--rtems-builddir')
        if not path_to_builddir:
            raise error.general("Path to build directory not provided")

        coverage_enabled = opts.coverage()
        if coverage_enabled:
            import coverage
            from rtemstoolkit import check
            log.notice("Coverage analysis requested")
            opts.defaults.load('%%{_configdir}/coverage.mc')
            if not check.check_exe('__covoar', opts.defaults['__covoar']):
                raise error.general("Covoar not found!")

            coverage = coverage.coverage_run(opts.defaults, path_to_builddir[1])
            coverage.prepareEnvironment();

        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params(), exe_filter, path_to_builddir[1])
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests([l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports,
                               executables[exe],
                               rtems_tools, bsp, bsp_config,
                               opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create',
                               total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead',
                                   total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports,
                                                report_mode,
                                                reporting,
                                                finished,
                                                job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode,
                                    reporting, finished, job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Average test time: %s' % (str((end_time - start_time) / total)))
        log.notice('Testing time     : %s' % (str(end_time - start_time)))

        if coverage_enabled:
            coverage.config_map = opts.defaults.macros['coverage']
            coverage.executables = executables
            print [c for c in coverage.config_map]
            print [e for e in executables]
Example #49
0
 def _summarize(self):
     log.notice("Coverage analysis finished. You can find results in " + self.targetDir)
Example #50
0
def output_handler(text):
    log.notice(text, stdout_only = False)
Example #51
0
    return opts


def run(args):
    try:
        _opts = load(args=args, defaults=defaults_mc)
        log.notice("RTEMS Test - Defaults, v%s" % (version.str()))
        _opts.log_info()
        log.notice("Options:")
        log.notice(str(_opts))
        log.notice("Defaults:")
        log.notice(str(_opts.defaults))
    except error.general, gerr:
        print gerr
        sys.exit(1)
    except error.internal, ierr:
        print ierr
        sys.exit(1)
    except error.exit, eerr:
        pass
    except KeyboardInterrupt:
        log.notice("abort: user terminated")
        sys.exit(1)
    sys.exit(0)


if __name__ == "__main__":
    import sys

    run(sys.argv)
Example #52
0
def run(args):
    try:
        _opts = load(args = args, defaults = defaults_mc)
        log.notice('RTEMS Test - Defaults, v%s' % (version.str()))
        _opts.log_info()
        log.notice('Options:')
        log.notice(str(_opts))
        log.notice('Defaults:')
        log.notice(str(_opts.defaults))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Example #53
0
 def _cleanup(self):
     log.notice("Cleaning workspace up")
     path.removeall(self.tracesDir)
Example #54
0
def run(command_path = None):
    import sys
    tests = []
    stdtty = console.save()
    opts = None
    default_exefilter = '*.exe'
    try:
        optargs = { '--rtems-tools': 'The path to the RTEMS tools',
                    '--rtems-bsp':   'The RTEMS BSP to run the test on',
                    '--report-mode': 'Reporting modes, failures (default),all,none',
                    '--list-bsps':   'List the supported BSPs',
                    '--debug-trace': 'Debug trace based on specific flags',
                    '--filter':      'Glob that executables must match to run (default: ' +
                              default_exefilter + ')',
                    '--stacktrace':  'Dump a stack trace on a user termination (^C)' }
        opts = options.load(sys.argv,
                            optargs = optargs,
                            command_path = command_path)
        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
        if opts.find_arg('--list-bsps'):
            bsps.list(opts)
        exe_filter = opts.find_arg('--filter')
        if exe_filter:
            exe_filter = exe_filter[1]
        else:
            exe_filter = default_exefilter
        opts.log_info()
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            debug_trace = debug_trace[1]
        else:
            debug_trace = ''
        opts.defaults['debug_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools:
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        else:
            rtems_tools = '%{_prefix}'
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or invalid option')
        opts.defaults.load('%%{_configdir}/bsps/%s.mc' % (bsp[1]))
        bsp = opts.defaults.get('%{bsp}')
        if not bsp:
            raise error.general('BSP definition (%{bsp}) not found in the global map')
        bsp = bsp[2]
        if not opts.defaults.set_read_map(bsp):
            raise error.general('no BSP map found')
        bsp_script = opts.defaults.get(bsp)
        if not bsp_script:
            raise error.general('BSP script not found: %s' % (bsp))
        bsp_config = opts.defaults.expand(opts.defaults[bsp])
        report_mode = opts.find_arg('--report-mode')
        if report_mode:
            if report_mode[1] != 'failures' and \
                    report_mode[1] != 'all' and \
                    report_mode[1] != 'none':
                raise error.general('invalid report mode')
            report_mode = report_mode[1]
        else:
            report_mode = 'failures'
        executables = find_executables(opts.params(), exe_filter)
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        invalid_tests = opts.defaults['invalid_tests']
        if invalid_tests:
            reports.set_invalid_tests([l.strip() for l in invalid_tests.splitlines()])
        reporting = 1
        jobs = int(opts.jobs(opts.defaults['_ncpus']))
        exe = 0
        finished = []
        if jobs > len(executables):
            jobs = len(executables)
        while exe < total or len(tests) > 0:
            if exe < total and len(tests) < jobs:
                tst = test_run(exe + 1, total, reports,
                               executables[exe],
                               rtems_tools, bsp, bsp_config,
                               opts)
                exe += 1
                tests += [tst]
                if job_trace:
                    _job_trace(tst, 'create',
                               total, exe, tests, reporting)
                tst.run()
            else:
                dead = [t for t in tests if not t.is_alive()]
                tests[:] = [t for t in tests if t not in dead]
                for tst in dead:
                    if job_trace:
                        _job_trace(tst, 'dead',
                                   total, exe, tests, reporting)
                    finished += [tst]
                    tst.reraise()
                del dead
                if len(tests) >= jobs or exe >= total:
                    time.sleep(0.250)
                if len(finished):
                    reporting = report_finished(reports,
                                                report_mode,
                                                reporting,
                                                finished,
                                                job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, report_mode,
                                    reporting, finished, job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, report_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        log.notice('Average test time: %s' % (str((end_time - start_time) / total)))
        log.notice('Testing time     : %s' % (str(end_time - start_time)))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        sys.exit(2)
    except KeyboardInterrupt:
        if opts is not None and opts.find_arg('--stacktrace'):
            print('}} dumping:', threading.active_count())
            for t in threading.enumerate():
                print('}} ', t.name)
            print(stacktraces.trace())
        log.notice('abort: user terminated')
        killall(tests)
        sys.exit(1)
    finally:
        console.restore(stdtty)
    sys.exit(0)
Example #55
0
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)
Example #56
0
 def _generateReports(self):
     log.notice("Generating reports")
     report = reportGen(self.symbolSets, self.targetDir)
     report.generate()