Esempio n. 1
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)
Esempio n. 2
0
 def help(self):
     print('%s: [options] [args]' % (self.command_name))
     print('RTEMS Tools Project, %s' % (version.string()))
     print('Options and arguments:')
     opts = list(self.long_opts_help.keys())
     if self.optargs:
         opts += self.optargs.keys()
     indent = self._help_indent()
     for o in sorted(opts):
         if o in self.long_opts_help:
             h = self.long_opts_help[o]
         elif self.optargs:
             h = self.optargs[o]
         else:
             raise error.general('invalid help data: %s' %(o))
         print('%-*s : %s' % (indent, o, h))
     raise error.exit()
Esempio n. 3
0
 def load_config(self, bootloader, config):
     self.config.load(config)
     #
     # Check the config file has the basic data and structure.
     #
     bootloaders = self.config.comma_list('default', 'bootloaders')
     for bl in bootloaders:
         if not self.config.has_section(bl):
             raise error.general(
                 'boot config: missing bootloader section: %s' % (bl))
         for b in self.config.comma_list(bl, 'boards'):
             if not self.config.has_section(b):
                 raise error.general(
                     'boot config: missing board section: %s' % (b))
     #
     # Is the bootloader valid?
     #
     if bootloader is not None and bootloader not in bootloaders:
         raise error.general('boot config: unknown bootloader: %s' %
                             (bootloader))
     self.macros['bootloader'] = str(bootloader)
     self.macros['version_str'] = version.string()
     self.macros['version'] = str(version.version())
     self.macros['revision'] = str(version.revision())
     if version.released():
         self.macros['released'] = '1'
     #
     # Map the config to macros. The [default] section is global. The
     # remaining sections are added as macro maps so the specalised
     # bootloaders can enable reading from a macro map to provide specific
     # values for a specific config such as a board.
     #
     for s in self.config.get_sections():
         if s != 'default':
             self.macros.set_write_map(s, add=True)
         for i in self.config.get_items(s):
             self.macros[i[0]] = i[1]
         self.macros.unset_write_map()
     self.macros.set_read_map('global')
     if bootloader is not None:
         self.macros.set_read_map(bootloader)
Esempio n. 4
0
def run(args):
    try:
        _opts = load(args=args, defaults=defaults_mc)
        log.notice('RTEMS Test - 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, file=sys.stderr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr, file=sys.stderr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        log.notice('abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Esempio n. 5
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)
Esempio n. 6
0
def run(args=sys.argv, command_path=None):
    '''Run a TFTP server session.'''
    # pylint: disable=dangerous-default-value
    # pylint: disable=unused-argument
    # pylint: disable=too-many-branches
    # pylint: disable=too-many-statements
    ecode = 0
    notice = None
    server = None
    # pylint: disable=bare-except
    try:
        description = 'A TFTP Server that supports a read only TFTP session.'

        nice_cwd = os.path.relpath(os.getcwd())
        if len(nice_cwd) > len(os.path.abspath(nice_cwd)):
            nice_cwd = os.path.abspath(nice_cwd)

        argsp = argparse.ArgumentParser(prog='rtems-tftp-server',
                                        description=description)
        argsp.add_argument('-l',
                           '--log',
                           help='log file.',
                           type=str,
                           default=None)
        argsp.add_argument('-v',
                           '--trace',
                           help='enable trace logging for debugging.',
                           action='store_true',
                           default=False)
        argsp.add_argument('--trace-packets',
                           help='enable trace logging of packets.',
                           action='store_true',
                           default=False)
        argsp.add_argument('--show-backtrace',
                           help='show the exception backtrace.',
                           action='store_true',
                           default=False)
        argsp.add_argument(
            '-B',
            '--bind',
            help='address to bind the server too (default: %(default)s).',
            type=str,
            default='all')
        argsp.add_argument(
            '-P',
            '--port',
            help='port to bind the server too (default: %(default)s).',
            type=int,
            default='69')
        argsp.add_argument('-t', '--timeout',
                           help = 'timeout in seconds, client can override ' \
                           '(default: %(default)s).',
                           type = int, default = '10')
        argsp.add_argument(
            '-b',
            '--base',
            help='base path, not checked (default: %(default)s).',
            type=str,
            default=nice_cwd)
        argsp.add_argument(
            '-F',
            '--force-file',
            help='force the file to be downloaded overriding the client.',
            type=str,
            default=None)
        argsp.add_argument('-s', '--sessions',
                           help = 'number of TFTP sessions to run before exiting ' \
                           '(default: forever.',
                           type = int, default = None)

        argopts = argsp.parse_args(args[1:])

        load_log(argopts.log)
        log.notice('RTEMS Tools - TFTP Server, %s' % (version.string()))
        log.output(log.info(args))
        log.tracing = argopts.trace

        server = tftp_server(argopts.bind, argopts.port, argopts.timeout,
                             argopts.base, argopts.force_file,
                             argopts.sessions)
        server.enable_notices()
        if argopts.trace_packets:
            server.trace_packets()
        if argopts.show_backtrace:
            server.except_is_raise()

        try:
            server.start()
            server.run()
        finally:
            server.stop()

    except error.general as gerr:
        notice = str(gerr)
        ecode = 1
    except error.internal as ierr:
        notice = str(ierr)
        ecode = 1
    except error.exit:
        pass
    except KeyboardInterrupt:
        notice = 'abort: user terminated'
        ecode = 1
    except SystemExit:
        pass
    except:
        notice = 'abort: unknown error'
        ecode = 1
    if server is not None:
        del server
    if notice is not None:
        log.stderr(notice)
    sys.exit(ecode)
Esempio n. 7
0
def run(args=sys.argv, command_path=None):
    ec = 0
    notice = None
    builder = None
    try:
        description = 'Provide one path to a u-boot build or provide two '
        description += 'paths to the built the first and second stage loaders, '
        description += 'for example a first stage loader is \'MLO\' and a second '
        description += '\'u-boot.img\'. If converting a kernel only provide the '
        description += 'executable\'s path.'

        argsp = argparse.ArgumentParser(prog='rtems-boot-image',
                                        description=description)
        argsp.add_argument('-l',
                           '--log',
                           help='log file (default: %(default)s).',
                           type=str,
                           default=log_default())
        argsp.add_argument('-v',
                           '--trace',
                           help='enable trace logging for debugging.',
                           action='store_true')
        argsp.add_argument(
            '-s',
            '--image-size',
            help='image size in mega-bytes (default: %(default)s).',
            type=str,
            action=valid_si,
            default='64m')
        argsp.add_argument(
            '-F',
            '--fs-format',
            help='root file system format (default: %(default)s).',
            type=str,
            action=valid_format,
            default='fat16')
        argsp.add_argument('-S', '--fs-size',
                           help = 'root file system size in SI units ' + \
                                  '(default: %(default)s).',
                           type = str, action = valid_si, default = 'auto')
        argsp.add_argument('-A', '--fs-align',
                           help = 'root file system alignment in SI units ' + \
                                  '(default: %(default)s).',
                           type = str, action = valid_si, default = '1m')
        argsp.add_argument('-k',
                           '--kernel',
                           help='install the kernel (default: %(default)r).',
                           type=str,
                           action=valid_file,
                           default=None)
        argsp.add_argument(
            '-d',
            '--fdt',
            help='Flat device tree source/blob (default: %(default)r).',
            type=str,
            action=valid_file,
            default=None)
        argsp.add_argument('-f',
                           '--file',
                           help='install the file (default: None).',
                           type=str,
                           action=valid_file,
                           default=[])
        argsp.add_argument('--net-boot',
                           help = 'configure a network boot using TFTP ' + \
                                  '(default: %(default)r).',
                           action = 'store_true')
        argsp.add_argument(
            '--net-boot-dhcp',
            help='network boot using dhcp (default: %(default)r).',
            action='store_true',
            default=False)
        argsp.add_argument(
            '--net-boot-ip',
            help='network boot IP address (default: %(default)r).',
            type=str,
            action=valid_ip,
            default=None)
        argsp.add_argument('--net-boot-server',
                           help = 'network boot server IP address ' + \
                                  '(default: %(default)r).',
                           type = str, action = valid_ip, default = None)
        argsp.add_argument('--net-boot-file',
                           help='network boot file (default: %(default)r).',
                           type=str,
                           default='rtems.img')
        argsp.add_argument(
            '--net-boot-fdt',
            help='network boot load a fdt file (default: %(default)r).',
            type=str,
            default=None)
        argsp.add_argument('-U', '--custom-uenv',
                           help = 'install the custom uEnv.txt file ' + \
                                  '(default: %(default)r).',
                           type = str, action = valid_file, default = None)
        argsp.add_argument('-b',
                           '--board',
                           help='name of the board (default: %(default)r).',
                           type=str,
                           default='list')
        argsp.add_argument('--convert-kernel',
                           help = 'convert a kernel to a bootoader image ' + \
                                  '(default: %(default)r).',
                           action = 'store_true', default = False)
        argsp.add_argument(
            '--build',
            help='set the build directory (default: %(default)r).',
            type=str,
            default='ribuild')
        argsp.add_argument(
            '--no-clean',
            help='do not clean when finished (default: %(default)r).',
            action='store_false',
            default=True)
        argsp.add_argument('-o',
                           '--output',
                           help='image output file name',
                           type=str,
                           action=valid_file_if_exists,
                           required=True)
        argsp.add_argument(
            'paths',
            help='files or paths, the number and type sets the mode.',
            nargs='+',
            action=valid_paths)

        argopts = argsp.parse_args(args[1:])

        load_log(argopts.log)
        log.notice('RTEMS Tools - Boot Image, %s' % (version.string()))
        log.output(log.info(args))
        log.tracing = argopts.trace

        if argopts.net_boot_dhcp or \
           argopts.net_boot_ip is not None:
            if argopts.convert_kernel:
                raise error.general(
                    'net boot options not valid with kernel convert.')
            if argopts.custom_uenv is not None:
                raise error.general(
                    'cannot set custom uenv and net boot options.')

        host.load()

        log.output('Platform: %s' % (host.name))

        if argopts.board == 'list':
            loader = bootloader(command_path)
            boards = loader.list_boards()
            log.notice(' Board list: bootloaders (%d)' % (len(boards)))
            for bl in sorted(boards):
                log.notice('  %s: %d' % (bl, len(boards[bl])))
                for b in boards[bl]:
                    log.notice('   ' + b)
            raise error.exit()

        loader = uboot_bootloader(command_path, argopts.build,
                                  argopts.convert_kernel, argopts.paths,
                                  argopts.board)

        loader.check_mandatory_configs()

        if loader.convert_kernel:
            if argopts.kernel is not None:
                raise error.general(
                    'kernel convert does not use the kernel option.')
            if len(argopts.paths) != 1:
                raise error.general('kernel convert take a single path.')
            argopts.kernel = argopts.paths[0]
        else:
            loader.clean = argopts.no_clean

        loader['build'] = argopts.build
        loader['board'] = argopts.board
        loader['output'] = argopts.output
        loader['image_size'] = argopts.image_size
        loader['fs_format'] = argopts.fs_format
        loader['fs_size'] = argopts.fs_size
        loader['fs_align'] = argopts.fs_align
        loader['kernel'] = argopts.kernel
        loader['fdt'] = argopts.fdt
        loader['files'] = ','.join(argopts.file)
        loader['net_dhcp'] = argopts.net_boot_dhcp
        loader['net_ip'] = argopts.net_boot_ip
        loader['net_server_ip'] = argopts.net_boot_server
        loader['net_exe'] = argopts.net_boot_file
        loader['net_fdt'] = argopts.net_boot_fdt
        loader['uenv_txt'] = argopts.custom_uenv

        loader.log()

        if not loader.convert_kernel:
            if loader['fs_size'] == 'auto':
                loader['fs_size'] = \
                    str(_si_size(loader['image_size']) - _si_size(loader['fs_align']))
            elif _si_size(loader['image_size']) < \
                 _si_size(loader['fs_align']) + _si_size(loader['fs_size']):
                raise error.general(
                    'filesystem partition size larger than image size.')

        if host.name not in builders:
            err = 'no builder; platform not supported: %s' % (host.name)
            raise error.general(err)

        builder = builders[host.name](loader)

        if not loader.check_exes() or not builder.check_exes():
            raise error.general('command(s) not found; please fix.')

        builder.build()

    except error.general as gerr:
        notice = str(gerr)
        ec = 1
    except error.internal as ierr:
        notice = str(ierr)
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        notice = 'abort: user terminated'
        ec = 1
    except:
        raise
        notice = 'abort: unknown error'
        ec = 1
    if builder is not None:
        del builder
    if notice is not None:
        log.stderr(notice)
    sys.exit(ec)
Esempio n. 8
0
def run(args, 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',
            '--user-config':
            'Path to your local user configuration INI file',
            '--report-path':
            'Report output base path (file extension will be added)',
            '--report-format':
            'Formats in which to report test results in addition to txt: json',
            '--log-mode':
            'Reporting modes, failures (default),all,none',
            '--list-bsps':
            'List the supported BSPs',
            '--debug-trace':
            'Debug trace based on specific flags (console,gdb,output,cov)',
            '--filter':
            'Glob that executables must match to run (default: ' +
            default_exefilter + ')',
            '--stacktrace':
            'Dump a stack trace on a user termination (^C)',
            '--coverage':
            'Perform coverage analysis of test executables.'
        }
        mailer.append_options(optargs)
        opts = options.load(args, optargs=optargs, command_path=command_path)
        mail = None
        output = None
        if opts.find_arg('--mail'):
            mail = mailer.mail(opts)
            # Request these now to generate any errors.
            from_addr = mail.from_address()
            smtp_host = mail.smtp_host()
            to_addr = opts.find_arg('--mail-to')
            if to_addr:
                to_addr = to_addr[1]
            else:
                to_addr = '*****@*****.**'
            output = log_capture()
        report_location = opts.find_arg('--report-path')
        if report_location is not None:
            report_location = report_location[1]

        report_formats = opts.find_arg('--report-format')
        if report_formats is not None:
            if len(report_formats) != 2:
                raise error.general('invalid RTEMS report formats option')
            report_formats = report_formats[1].split(',')
            check_report_formats(report_formats, report_location)
        else:
            report_formats = []
        log.notice('RTEMS Testing - Tester, %s' % (version.string()))
        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()
        log.output('Host: ' + host.label(mode='all'))
        executables = find_executables(opts.params(), exe_filter)
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            if len(debug_trace) != 1:
                debug_trace = debug_trace[1]
            else:
                raise error.general(
                    'no debug flags, can be: console,gdb,output,cov')
        else:
            debug_trace = ''
        opts.defaults['exe_trace'] = debug_trace
        job_trace = 'jobs' in debug_trace.split(',')
        rtems_tools = opts.find_arg('--rtems-tools')
        if rtems_tools is not None:
            if len(rtems_tools) != 2:
                raise error.general('invalid RTEMS tools option')
            rtems_tools = rtems_tools[1]
        bsp = opts.find_arg('--rtems-bsp')
        if bsp is None or len(bsp) != 2:
            raise error.general('RTEMS BSP not provided or an invalid option')
        bsp = config.load(bsp[1], opts)
        bsp_config = opts.defaults.expand(opts.defaults['tester'])
        coverage_enabled = opts.find_arg('--coverage')
        if coverage_enabled:
            cov_trace = 'cov' in debug_trace.split(',')
            if len(coverage_enabled) == 2:
                coverage_runner = coverage.coverage_run(
                    opts.defaults,
                    executables,
                    rtems_tools,
                    symbol_set=coverage_enabled[1],
                    trace=cov_trace)
            else:
                coverage_runner = coverage.coverage_run(opts.defaults,
                                                        executables,
                                                        rtems_tools,
                                                        trace=cov_trace)
        log_mode = opts.find_arg('--log-mode')
        if log_mode:
            if log_mode[1] != 'failures' and \
                    log_mode[1] != 'all' and \
                    log_mode[1] != 'none':
                raise error.general('invalid report mode')
            log_mode = log_mode[1]
        else:
            log_mode = 'failures'
        if len(executables) == 0:
            raise error.general('no executables supplied')
        start_time = datetime.datetime.now()
        total = len(executables)
        reports = report.report(total)
        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, log_mode, reporting,
                                                finished, job_trace)
        finished_time = datetime.datetime.now()
        reporting = report_finished(reports, log_mode, reporting, finished,
                                    job_trace)
        if reporting < total:
            log.warning('finished jobs does match: %d' % (reporting))
            report_finished(reports, log_mode, -1, finished, job_trace)
        reports.summary()
        end_time = datetime.datetime.now()
        average_time = 'Average test time: %s' % (str(
            (end_time - start_time) / total))
        total_time = 'Testing time     : %s' % (str(end_time - start_time))
        log.notice(average_time)
        log.notice(total_time)
        for report_format in report_formats:
            report_formatters[report_format](
                args, reports, start_time, end_time, total,
                '.'.join([report_location, report_format]))

        if mail is not None and output is not None:
            m_arch = opts.defaults.expand('%{arch}')
            m_bsp = opts.defaults.expand('%{bsp}')
            build = ' %s:' % (reports.get_config('build', not_found=''))
            subject = '[rtems-test] %s/%s:%s %s' % (
                m_arch, m_bsp, build, reports.score_card('short'))
            np = 'Not present in test'
            ver = reports.get_config('version', not_found=np)
            build = reports.get_config('build', not_found=np)
            tools = reports.get_config('tools', not_found=np)
            body = [
                total_time, average_time, '', 'Host', '====',
                host.label(mode='all'), '', 'Configuration', '=============',
                'Version: %s' % (ver),
                'Build  : %s' % (build),
                'Tools  : %s' % (tools), '', 'Summary', '=======', '',
                reports.score_card(), '',
                reports.failures(), 'Log', '===', ''
            ] + output.get()
            mail.send(to_addr, subject, os.linesep.join(body))
        if coverage_enabled:
            coverage_runner.run()

    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)
Esempio n. 9
0
def title():
    return 'RTEMS Tools Project - RTEMS Kernel BSP Builder, %s' % (
        version.string())
Esempio n. 10
0
def run(args=sys.argv, command_path=None):
    ec = 0
    notice = None
    proxy = None
    try:
        description = 'Proxy TFTP sessions from the host running this proxy'
        description += 'to hosts and ports defined in the configuration file. '
        description += 'The tool lets you create a farm of hardware and to run '
        description += 'more than one TFTP test session on a host or multiple '
        description += 'hosts at once. This proxy service is not considered secure'
        description += 'and is for use in a secure environment.'

        argsp = argparse.ArgumentParser(prog='rtems-tftp-proxy',
                                        description=description)
        argsp.add_argument('-l',
                           '--log',
                           help='log file.',
                           type=str,
                           default=None)
        argsp.add_argument('-v',
                           '--trace',
                           help='enable trace logging for debugging.',
                           action='store_true',
                           default=False)
        argsp.add_argument('-c',
                           '--config',
                           help='proxy configuation (default: %(default)s).',
                           type=str,
                           default=None)
        argsp.add_argument(
            '-B',
            '--bind',
            help='address to bind the proxy too (default: %(default)s).',
            type=str,
            default='all')
        argsp.add_argument(
            '-P',
            '--port',
            help='port to bind the proxy too(default: %(default)s).',
            type=int,
            default='69')

        argopts = argsp.parse_args(args[1:])

        load_log(argopts.log)
        log.notice('RTEMS Tools - TFTP Proxy, %s' % (version.string()))
        log.output(log.info(args))
        log.tracing = argopts.trace

        if argopts.config is None:
            raise error.general('no config file, see -h')

        proxy = proxy_server(argopts.config, argopts.bind, argopts.port)

        try:
            proxy.start()
            proxy.run()
        except:
            proxy.stop()
            raise

    except error.general as gerr:
        notice = str(gerr)
        ec = 1
    except error.internal as ierr:
        notice = str(ierr)
        ec = 1
    except error.exit as eerr:
        pass
    except KeyboardInterrupt:
        notice = 'abort: user terminated'
        ec = 1
    except:
        raise
        notice = 'abort: unknown error'
        ec = 1
    if proxy is not None:
        del proxy
    if notice is not None:
        log.stderr(notice)
    sys.exit(ec)
Esempio n. 11
0
def run(args):
    tests = []
    stdtty = tester.rt.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',
            '--user-config': 'Path to your local user configuration INI file',
            '--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 = tester.rt.options.load(args, optargs=optargs)
        log.notice('RTEMS Testing - Run, %s' % (version.string()))
        if opts.find_arg('--list-bsps'):
            tester.rt.bsps.list(opts)
        opts.log_info()
        log.output('Host: ' + host.label(mode='all'))
        debug_trace = opts.find_arg('--debug-trace')
        if debug_trace:
            if len(debug_trace) != 1:
                debug_trace = 'output,' + debug_trace[1]
            else:
                raise error.general(
                    'no debug flags, can be: console,gdb,output')
        else:
            debug_trace = 'output'
        opts.defaults['debug_trace'] = debug_trace
        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 an invalid option')
        bsp = tester.rt.config.load(bsp[1], opts)
        bsp_config = opts.defaults.expand(opts.defaults['tester'])
        executables = find_executables(opts.params())
        if len(executables) != 1:
            raise error.general('one executable required, found %d' %
                                (len(executables)))
        opts.defaults['test_disable_header'] = '1'
        reports = tester.rt.report.report(1)
        start_time = datetime.datetime.now()
        opts.defaults['exe_trace'] = debug_trace
        tst = test(1, 1, reports, executables[0], rtems_tools, bsp, bsp_config,
                   opts)
        tst.run()
        end_time = datetime.datetime.now()
        total_time = 'Run time     : %s' % (str(end_time - start_time))
        log.notice(total_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')
        sys.exit(1)
    finally:
        tester.rt.console.restore(stdtty)
    sys.exit(0)