Exemplo n.º 1
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))
Exemplo n.º 2
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))
Exemplo n.º 3
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")
Exemplo n.º 4
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()
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 def __init__(self, index, total, report, executable, rtems_tools, bsp,
              bsp_config, opts):
     self.index = index
     self.total = total
     self.report = report
     self.bsp = bsp
     self.bsp_config = bsp_config
     self.opts = copy.copy(opts)
     self.opts.defaults['test_index'] = str(index)
     self.opts.defaults['test_total'] = str(total)
     self.opts.defaults['bsp'] = bsp
     self.opts.defaults['bsp_arch'] = '%%{%s_arch}' % (bsp)
     self.opts.defaults['bsp_opts'] = '%%{%s_opts}' % (bsp)
     if not path.isfile(executable):
         raise error.general('cannot find executable: %s' % (executable))
     self.opts.defaults['test_executable'] = executable
     self.opts.defaults['test_executable_name'] = path.basename(executable)
     if rtems_tools:
         rtems_tools_bin = path.join(self.opts.defaults.expand(rtems_tools),
                                     'bin')
         if not path.isdir(rtems_tools_bin):
             raise error.general('cannot find RTEMS tools path: %s' %
                                 (rtems_tools_bin))
         self.opts.defaults['rtems_tools'] = rtems_tools_bin
     self.config = config.file(self.report, self.bsp_config, self.opts)
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
Exemplo n.º 8
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)
Exemplo n.º 9
0
 def fdt_convert(self, image, fdt):
     dst = path.join(path.abspath(self['build']), path.basename(fdt))
     self['fdt_build'] = dst
     log.output('Copy (into build): %s -> %s' % (fdt, dst))
     image.clean_path(dst)
     path.copy(fdt, dst)
     return self['fdt_image'].replace('@FDT@', dst)
Exemplo n.º 10
0
 def log(self, name, mode):
     status_fails = [
         'failed', 'timeout', 'invalid', 'wrong-version', 'wrong-build',
         'wrong-tools'
     ]
     if mode != 'none':
         self.lock.acquire()
         if name not in self.results:
             self.lock.release()
             raise error.general('test report missing: %s' % (name))
         exe = path.basename(self.results[name]['exe'])
         result = self.results[name]['result']
         time = self.results[name]['end'] - self.results[name]['start']
         failed = result in status_fails
         result = 'Result: %-10s Time: %s %s' % (result, str(time), exe)
         if mode != 'none':
             header = self.results[name]['header']
         if mode == 'all' or failed:
             output = self.results[name]['output']
         else:
             output = None
         self.lock.release()
         if header:
             log.output(header)
         if output:
             log.output(result)
             log.output(output)
Exemplo n.º 11
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)
Exemplo n.º 12
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)
Exemplo n.º 13
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()
Exemplo n.º 14
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
Exemplo n.º 15
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))
Exemplo n.º 16
0
 def end(self, name, output):
     start = False
     end = False
     timeout = False
     prefixed_output = []
     for line in output:
         if line[0] == ']':
             if line[1].startswith('*** '):
                 if line[1][4:].startswith('END OF '):
                     end = True
                 if line[1][4:].startswith('TIMEOUT TIMEOUT'):
                     timeout = True
                 else:
                     start = True
         prefixed_output += [line[0] + ' ' + line[1]]
     self.lock.acquire()
     if name not in self.results:
         self.lock.release()
         raise error.general('test report missing: %s' % (name))
     if self.results[name]['end'] is not None:
         self.lock.release()
         raise error.general('test already finished: %s' % (name))
     self.results[name]['end'] = datetime.datetime.now()
     if start and end:
         status = 'passed'
         self.passed += 1
     elif timeout:
         status = 'timeout'
         self.timeouts += 1
     elif start:
         if not end:
             status = 'failed'
             self.failed += 1
     else:
         if self.invalid_tests and path.basename(
                 name) in self.invalid_tests:
             status = 'passed'
             self.passed += 1
         else:
             status = 'invalid'
             self.invalids += 1
     self.results[name]['result'] = status
     self.results[name]['output'] = prefixed_output
     if self.name_max_len < len(path.basename(name)):
         self.name_max_len = len(path.basename(name))
     self.lock.release()
Exemplo n.º 17
0
 def end(self, name, output):
     start = False
     end = False
     timeout = False
     prefixed_output = []
     for line in output:
         if line[0] == ']':
             if line[1].startswith('*** '):
                 if line[1][4:].startswith('END OF '):
                     end = True
                 if line[1][4:].startswith('TIMEOUT TIMEOUT'):
                     timeout = True
                 else:
                     start = True
         prefixed_output += [line[0] + ' ' + line[1]]
     self.lock.acquire()
     if name not in self.results:
         self.lock.release()
         raise error.general('test report missing: %s' % (name))
     if self.results[name]['end'] is not None:
         self.lock.release()
         raise error.general('test already finished: %s' % (name))
     self.results[name]['end'] = datetime.datetime.now()
     if start and end:
         status = 'passed'
         self.passed += 1
     elif timeout:
         status = 'timeout'
         self.timeouts += 1
     elif start:
         if not end:
             status = 'failed'
             self.failed += 1
     else:
         if self.invalid_tests and path.basename(name) in self.invalid_tests:
             status = 'passed'
             self.passed += 1
         else:
             status = 'invalid'
             self.invalids += 1
     self.results[name]['result'] = status
     self.results[name]['output'] = prefixed_output
     if self.name_max_len < len(path.basename(name)):
         self.name_max_len = len(path.basename(name))
     self.lock.release()
Exemplo n.º 18
0
 def kernel_convert(self, image, kernel):
     dst = path.join(path.abspath(self['build']), path.basename(kernel))
     self['kernel_build'] = dst
     log.output('Copy (into build): %s -> %s' % (kernel, dst))
     image.clean_path(dst)
     path.copy(kernel, dst)
     cmds = self.filter_text(self.comma_split(self['kernel_converter']))
     for cmd in cmds:
         _command(cmd, self['build'])
     return self['kernel_image'].replace('@KERNEL@', dst)
Exemplo n.º 19
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
Exemplo n.º 20
0
 def filter_text(self, lines):
     out = []
     for line in lines:
         if '@KERNEL@' in line:
             line = line.replace('@KERNEL@', path.basename(self['kernel']))
         if '@KERNEL_IMAGE@' in line:
             line = line.replace('@KERNEL_IMAGE@', self.kernel_image())
         if '@FDT@' in line:
             line = line.replace('@FDT@', path.basename(self['fdt']))
         if '@FDT_IMAGE@' in line:
             line = line.replace('@FDT_IMAGE@', self.fdt_image())
         if '@NET_SERVER_IP@' in line and self['net_server_ip'] is not None:
             line = line.replace('@NET_SERVER_IP@', self['net_server_ip'])
         if '@NET_IP@' in line and self['net_ip'] is not None:
             line = line.replace('@NET_IP@', self['net_ip'])
         if '@NET_BOOTEXE@' in line and self['net_exe'] is not None:
             line = line.replace('@NET_BOOTEXE@', self['net_exe'])
         if '@NET_BOOTFDT@' in line and self['net_fdt'] is not None:
             line = line.replace('@NET_BOOTFDT@', self['net_fdt'])
         out += [line]
     return out
Exemplo n.º 21
0
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))
Exemplo n.º 22
0
 def log(self, name, mode):
     if mode != 'none':
         self.lock.acquire()
         if name not in self.results:
             self.lock.release()
             raise error.general('test report missing: %s' % (name))
         exe = path.basename(self.results[name]['exe'])
         result = self.results[name]['result']
         time = self.results[name]['end'] - self.results[name]['start']
         if mode != 'none':
             header = self.results[name]['header']
         if mode == 'all' or result != 'passed':
             output = self.results[name]['output']
         else:
             output = None
         self.lock.release()
         if header:
             log.output(header)
         if output:
             log.output(output)
             log.output('Result: %-10s Time: %s %s' % (result, str(time), exe))
Exemplo n.º 23
0
 def __init__(self, index, total, report, executable, rtems_tools, bsp, bsp_config, opts):
     self.index = index
     self.total = total
     self.report = report
     self.bsp = bsp
     self.bsp_config = bsp_config
     self.opts = copy.copy(opts)
     self.opts.defaults['test_index'] = str(index)
     self.opts.defaults['test_total'] = str(total)
     self.opts.defaults['bsp'] = bsp
     self.opts.defaults['bsp_arch'] = '%%{%s_arch}' % (bsp)
     self.opts.defaults['bsp_opts'] = '%%{%s_opts}' % (bsp)
     if not path.isfile(executable):
         raise error.general('cannot find executable: %s' % (executable))
     self.opts.defaults['test_executable'] = executable
     self.opts.defaults['test_executable_name'] = path.basename(executable)
     if rtems_tools:
         rtems_tools_bin = path.join(self.opts.defaults.expand(rtems_tools), 'bin')
         if not path.isdir(rtems_tools_bin):
             raise error.general('cannot find RTEMS tools path: %s' % (rtems_tools_bin))
         self.opts.defaults['rtems_tools'] = rtems_tools_bin
     self.config = config.file(self.report, self.bsp_config, self.opts)
Exemplo n.º 24
0
 def log(self, name, mode):
     if mode != 'none':
         self.lock.acquire()
         if name not in self.results:
             self.lock.release()
             raise error.general('test report missing: %s' % (name))
         exe = path.basename(self.results[name]['exe'])
         result = self.results[name]['result']
         time = self.results[name]['end'] - self.results[name]['start']
         if mode != 'none':
             header = self.results[name]['header']
         if mode == 'all' or result != 'passed':
             output = self.results[name]['output']
         else:
             output = None
         self.lock.release()
         if header:
             log.output(header)
         if output:
             log.output(output)
             log.output('Result: %-10s Time: %s %s' %
                        (result, str(time), exe))
Exemplo n.º 25
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)
Exemplo n.º 26
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
Exemplo n.º 27
0
 def fdt_image(self):
     return self['fdt_image'].replace('@FDT@', path.basename(self['fdt']))
Exemplo n.º 28
0
 def end(self, name, output, output_prefix):
     start = False
     end = False
     state = None
     version = None
     build = None
     tools = None
     timeout = False
     prefixed_output = []
     for line in output:
         if line[0] == output_prefix:
             if line[1].startswith('*** '):
                 banner = line[1][4:]
                 if banner.startswith('BEGIN OF '):
                     start = True
                 elif line[1][4:].startswith('END OF '):
                     end = True
                 elif banner.startswith('TIMEOUT TIMEOUT'):
                     timeout = True
                 elif banner.startswith('TEST VERSION:'):
                     version = banner[13:].strip()
                 elif banner.startswith('TEST STATE:'):
                     state = banner[11:].strip()
                 elif banner.startswith('TEST BUILD:'):
                     build = ','.join(banner[11:].strip().split(' '))
                 elif banner.startswith('TEST TOOLS:'):
                     tools = banner[11:].strip()
         prefixed_output += [line[0] + ' ' + line[1]]
     self.lock.acquire()
     try:
         if name not in self.results:
             raise error.general('test report missing: %s' % (name))
         if self.results[name]['end'] is not None:
             raise error.general('test already finished: %s' % (name))
         self.results[name]['end'] = datetime.datetime.now()
         if state is not None and state not in [
                 'BENCHMARK', 'EXPECTED_FAIL', 'INDETERMINATE', 'USER_INPUT'
         ]:
             if version:
                 if 'version' not in self.config:
                     self.config['version'] = version
                 else:
                     if version != self.config['version']:
                         state = 'WRONG-VERSION'
             if build:
                 if 'build' not in self.config:
                     self.config['build'] = build
                 else:
                     if build != self.config['build']:
                         state = 'WRONG-BUILD'
             if tools:
                 if 'tools' not in self.config:
                     self.config['tools'] = tools
                 else:
                     if tools != self.config['tools']:
                         state = 'WRONG-TOOLS'
         if state is None or state == 'EXPECTED-PASS':
             if start and end:
                 if state is None or state == 'EXPECTED-PASS':
                     status = 'passed'
                     self.passed += 1
             elif timeout:
                 status = 'timeout'
                 self.timeouts += 1
             elif start:
                 if not end:
                     status = 'failed'
                     self.failed += 1
             else:
                 exe_name = path.basename(name).split('.')[0]
                 if exe_name in test_fail_excludes:
                     status = 'passed'
                     self.passed += 1
                 else:
                     status = 'invalid'
                     self.invalids += 1
         else:
             if state == 'EXPECTED_FAIL':
                 if start and end:
                     status = 'passed'
                     self.passed += 1
                 else:
                     status = 'expected-fail'
                     self.expected_fail += 1
             elif state == 'USER_INPUT':
                 status = 'user-input'
                 self.user_input += 1
             elif state == 'INDETERMINATE':
                 if start and end:
                     status = 'passed'
                     self.passed += 1
                 else:
                     status = 'indeterminate'
                     self.indeterminate += 1
             elif state == 'BENCHMARK':
                 status = 'benchmark'
                 self.benchmark += 1
             elif state == 'WRONG-VERSION':
                 status = 'wrong-version'
                 self.wrong_version += 1
             elif state == 'WRONG-BUILD':
                 status = 'wrong-build'
                 self.wrong_build += 1
             elif state == 'WRONG-TOOLS':
                 status = 'wrong-tools'
                 self.wrong_tools += 1
             else:
                 raise error.general('invalid test state: %s: %s' %
                                     (name, state))
         self.results[name]['result'] = status
         self.results[name]['output'] = prefixed_output
         if self.name_max_len < len(path.basename(name)):
             self.name_max_len = len(path.basename(name))
     finally:
         self.lock.release()
     return status
Exemplo n.º 29
0
 def end(self, name, output):
     start = False
     end = False
     state = None
     timeout = False
     prefixed_output = []
     for line in output:
         if line[0] == ']':
             if line[1].startswith('*** '):
                 if line[1][4:].startswith('END OF '):
                     end = True
                 if line[1][4:].startswith('TEST STATE:'):
                     state = line[1][15:].strip()
                 if line[1][4:].startswith('TIMEOUT TIMEOUT'):
                     timeout = True
                 else:
                     start = True
         prefixed_output += [line[0] + ' ' + line[1]]
     self.lock.acquire()
     if name not in self.results:
         self.lock.release()
         raise error.general('test report missing: %s' % (name))
     if self.results[name]['end'] is not None:
         self.lock.release()
         raise error.general('test already finished: %s' % (name))
     self.results[name]['end'] = datetime.datetime.now()
     if state is None:
         if start and end:
             if state is None:
                 status = 'passed'
                 self.passed += 1
         elif timeout:
             status = 'timeout'
             self.timeouts += 1
         elif start:
             if not end:
                 status = 'failed'
                 self.failed += 1
         else:
             status = 'invalid'
             self.invalids += 1
     else:
         if state == 'EXPECTED_FAIL':
             if start and end:
                 status = 'passed'
                 self.passed += 1
             else:
                 status = 'expected-fail'
                 self.expected_fail += 1
         elif state == 'USER_INPUT':
             status = 'user-input'
             self.user_input += 1
         elif state == 'INDETERMINATE':
             if start and end:
                 status = 'passed'
                 self.passed += 1
             else:
                 status = 'indeterminate'
                 self.indeterminate += 1
         elif state == 'BENCHMARK':
             status = 'benchmark'
             self.benchmark += 1
         else:
             raise error.general('invalid test state: %s: %s' %
                                 (name, state))
     self.results[name]['result'] = status
     self.results[name]['output'] = prefixed_output
     if self.name_max_len < len(path.basename(name)):
         self.name_max_len = len(path.basename(name))
     self.lock.release()
Exemplo n.º 30
0
 def show_state(results, state, max_len):
     for name in results:
         if results[name]['result'] == state:
             log.output(' %s' % (path.basename(name)))
Exemplo n.º 31
0
 def run(self):
     self.thread = threading.Thread(target = self.runner,
                                    name = 'test[%s]' % path.basename(self.executable))
     self.thread.start()
Exemplo n.º 32
0
 def run(self):
     name = 'test[%s]' % path.basename(self.executable)
     self.thread = threading.Thread(target=self.runner, name=name)
     self.thread.start()
Exemplo n.º 33
0
 def show_state(results, state, max_len):
     for name in results:
         if results[name]['result'] == state:
             log.output(' %s' % (path.basename(name)))
Exemplo n.º 34
0
 def kernel_image(self):
     return self['kernel_image'].replace('@KERNEL@',
                                         path.basename(self['kernel']))
Exemplo n.º 35
0
 def show_state(results, state, max_len):
     l = []
     for name in results:
         if results[name]['result'] == state:
             l += [' %s' % (path.basename(name))]
     return l
Exemplo n.º 36
0
    def load(self, name):

        def common_end(left, right):
            end = ''
            while len(left) and len(right):
                if left[-1] != right[-1]:
                    return end
                end = left[-1] + end
                left = left[:-1]
                right = right[:-1]
            return end

        if self.load_depth == 0:
            self.in_error = False
            self.lc = 0
            self.name = name
            self.conditionals = {}

        self.load_depth += 1

        save_name = self.name
        save_lc = self.lc

        self.name = name
        self.lc = 0

        #
        # Locate the config file. Expand any macros then add the
        # extension. Check if the file exists, therefore directly
        # referenced. If not see if the file contains ':' or the path
        # separator. If it does split the path else use the standard config dir
        # path in the defaults.
        #
        exname = self.expand(name)

        #
        # Macro could add an extension.
        #
        if exname.endswith('.cfg'):
            configname = exname
        else:
            configname = '%s.cfg' % (exname)
            name = '%s.cfg' % (name)

        if ':' in configname:
            cfgname = path.basename(configname)
        else:
            cfgname = common_end(configname, name)

        if not path.exists(configname):
            if ':' in configname:
                configdirs = path.dirname(configname).split(':')
            else:
                configdirs = self.define('_configdir').split(':')
            for cp in configdirs:
                configname = path.join(path.abspath(cp), cfgname)
                if path.exists(configname):
                    break
                configname = None
            if configname is None:
                raise error.general('no config file found: %s' % (cfgname))

        try:
            log.trace('config: %s: _open: %s' % (self.init_name, path.host(configname)))
            config = open(path.host(configname), 'r')
        except IOError as err:
            raise error.general('error opening config file: %s' % (path.host(configname)))
        self.configpath += [configname]

        self._includes += [configname]

        try:
            dir = None
            info = None
            data = []
            while True:
                r = self._parse(config, dir, info)
                if r[0] == 'control':
                    if r[1] == '%end':
                        break
                    log.warning("unexpected '%s'" % (r[1]))
                elif r[0] == 'directive':
                    if r[1] == '%include':
                        self.load(r[2][0])
                        continue
                    dir, info, data = self._process_directive(r, dir, info, data)
                elif r[0] == 'data':
                    dir, info, data = self._process_data(r, dir, info, data)
                else:
                    self._error("%d: invalid parse state: '%s" % (self.lc, r[0]))
            if dir is not None:
                self._directive_extend(dir, data)
        except:
            config.close()
            raise

        config.close()

        self.name = save_name
        self.lc = save_lc

        self.load_depth -= 1
Exemplo n.º 37
0
    def __init__(self, base_path = None, argv = None, optargs = None,
                 defaults = None, long_opts = None, long_opts_help = None,
                 command_path = '', log_default = None):

        if argv is None:
            return

        global basepath

        if long_opts == None:
            long_opts = {}

        basepath = base_path

        if log_default is not None and type(log_default) is not list:
            raise error.general('log default is not a list')
        self.log_default = log_default

        if defaults is None:
            defaults = macros.macros()

        self.long_opts = {
            # key                 macro                handler            param  defs       init
            '--jobs'           : ('_jobs',             self._lo_jobs,     True,  'default', True),
            '--log'            : ('_logfile',          self._lo_string,   True,  None,      False),
            '--macros'         : ('_macros',           self._lo_string,   True,  None,      False),
            '--force'          : ('_force',            self._lo_bool,     False, '0',       True),
            '--quiet'          : ('_quiet',            self._lo_bool,     False, '0',       True),
            '--trace'          : ('_trace',            self._lo_bool,     False, '0',       True),
            '--dry-run'        : ('_dry_run',          self._lo_bool,     False, '0',       True),
            '--warn-all'       : ('_warn_all',         self._lo_bool,     False, '0',       True),
            '--no-clean'       : ('_no_clean',         self._lo_bool,     False, '0',       True),
            '--keep-going'     : ('_keep_going',       self._lo_bool,     False, '0',       True),
            '--always-clean'   : ('_always_clean',     self._lo_bool,     False, '0',       True),
            '--no-install'     : ('_no_install',       self._lo_bool,     False, '0',       True),
            '--help'           : (None,                self._lo_help,     False, None,      False)
        }
        self.long_opts_help = {
            '--force':                      'Force the build to proceed',
            '--quiet':                      'Quiet output (not used)',
            '--trace':                      'Trace the execution',
            '--dry-run':                    'Do everything but actually run the build',
            '--warn-all':                   'Generate warnings',
            '--no-clean':                   'Do not clean up the build tree',
            '--always-clean':               'Always clean the build tree, even with an error',
            '--keep-going':                 'Do not stop on an error.',
            '--jobs=[0..n,none,half,full]': 'Run with specified number of jobs, default: num CPUs.',
            '--macros file[,file]':         'Macro format files to load after the defaults',
            '--log file':                   'Log file where all build output is written to',
        }
        self.opts = { 'params' : [] }
        self.command_path = command_path
        self.command_name = path.basename(argv[0])
        self.argv = argv
        self.args = argv[1:]
        self.optargs = optargs
        self.defaults = defaults
        for lo in self.long_opts:
            self.opts[lo[2:]] = self.long_opts[lo][3]
            if self.long_opts[lo][4]:
                self.defaults[self.long_opts[lo][0]] = ('none', 'none', self.long_opts[lo][3])
        for lo in long_opts:
            if lo in self.long_opts:
                raise error.general('suplicate option: %s' % (lo))
            self.opts[lo[2:]] = long_opts[lo][3]
            if long_opts[lo][4]:
                self.defaults[long_opts[lo][0]] = ('none', 'none', long_opts[lo][3])
            if long_opts[lo][1] == 'int':
                handler = self._lo_int
            elif long_opts[lo][1] == 'string':
                handler = self._lo_string
            elif long_opts[lo][1] == 'path':
                handler = self._lo_path
            elif long_opts[lo][1] == 'jobs':
                handler = self._lo_jobs
            elif long_opts[lo][1] == 'bool':
                handler = self._lo_bool
            elif long_opts[lo][1] == 'triplet':
                handler = self._lo_triplets
            else:
                raise error.general('invalid option handler: %s: %s' % (lo, long_opts[lo][1]))
            self.long_opts[lo] = (long_opts[lo][0], handler, long_opts[lo][2],
                                   long_opts[lo][3], long_opts[lo][4])
            if long_opts_help is not None:
                if lo not in long_opts_help:
                    raise error.general('no help for option: %s' % (lo))
                self.long_opts_help[lo] = long_opts_help[lo]
Exemplo n.º 38
0
 def _name_line_msg(self,  msg):
     return '%s:%d: %s' % (path.basename(self.init_name), self.lc,  msg)