Exemple #1
0
 def load(self, symbol_set_config_file, path_to_builddir):
     scf = open(symbol_set_config_file, 'r')
     for line in scf:
         try:
             if line.strip().startswith("symbolset"):
                 self.symbol_sets.append(symbol_set("", []))
             else:
                 splitted = line.split('=')
                 if (len(splitted) == 2):
                     key = splitted[0].strip()
                     value = splitted[1].strip()
                     if key == 'name':
                         self.symbol_sets[-1].name = value
                     elif key == 'lib':
                         lib = os.path.join(path_to_builddir, value)
                         log.stderr(lib + "\n")
                         self.symbol_sets[-1].libs.append(lib)
                     else:
                         log.stderr("Invalid key : " + key +
                                    " in symbol set configuration file " +
                                    symbol_set_config_file)
                 else:
                     self._log_invalid_format()
         except:
             self._log_invalid_format()
     scf.close()
Exemple #2
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("-----------------------------------------------")
Exemple #3
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("-----------------------------------------------")
Exemple #4
0
def load(args, optargs = None,
         command_path = None,
         defaults = '%s' % (defaults_mc)):
    #
    # The path to this command if not supplied by the upper layers.
    #
    if command_path is None:
        command_path = path.dirname(args[0])
        if len(command_path) == 0:
            command_path = '.'
    #
    # Check if there is a defaults.mc file under the command path. If so this is
    # the tester being run from within the git repo. If not found assume the tools
    # have been installed and the defaults is in the install prefix.
    #
    if path.exists(path.join(command_path, defaults_mc)):
        rtdir = command_path
    else:
        rtdir = '%{_prefix}/share/rtems/tester'
    defaults = '%s/%s' % (rtdir, defaults_mc)
    #
    # The command line contains the base defaults object all build objects copy
    # and modify by loading a configuration.
    #
    log.stderr('rtdir: ')
    print 'rtdir: ' + rtdir + '\n'
    opts = command_line(args,
                        optargs,
                        macros.macros(name = defaults, rtdir = rtdir),
                        command_path)
    options.load(opts)
    return opts
Exemple #5
0
 def _process_data(self, results, directive, info, data):
     new_data = []
     for l in results[1]:
         if l.startswith('%error'):
             l = self._expand(l)
             raise error.general('config error: %s' % (l[7:]))
         elif l.startswith('%warning'):
             l = self._expand(l)
             log.stderr('warning: %s' % (l[9:]))
             log.warning(l[9:])
         if not directive:
             l = self._expand(l)
             ls = self.tags.split(l, 1)
             log.trace('config: %s: _tag: %s %s' % (self.init_name, l, ls))
             if len(ls) > 1:
                 info = ls[0].lower()
                 if info[-1] == ':':
                     info = info[:-1]
                 info_data = ls[1].strip()
             else:
                 info_data = ls[0].strip()
             if info is not None:
                 self._info_append(info, info_data)
             else:
                 log.warning("invalid format: '%s'" % (info_data[:-1]))
         else:
             log.trace('config: %s: _data: %s %s' % (self.init_name, l, new_data))
             new_data.append(l)
     return (directive, info, data + new_data)
Exemple #6
0
 def _error(self, msg):
     err = 'error: %s' % (self._name_line_msg(msg))
     log.stderr(err)
     log.output(err)
     self.in_error = True
     if not self.opts.dry_run():
         log.stderr('warning: switched to dry run due to errors')
         self.opts.set_dry_run()
Exemple #7
0
 def _log_invalid_format(self):
     log.stderr("Invalid symbol configuration file")
     log.stderr(''' Configuration file format:
             symbolset:
                name=SYMBOLSET_NAME
                lib=PATH_TO_LIBRARY_1
                lib=PATH_TO_LIBRARY_2
             symbolset:
                 name=SYMBOLSET_NAME_N
                 lib=PATH_TO_LIBRARY        ''')
Exemple #8
0
 def _log_invalid_format(self):
     log.stderr("Invalid symbol configuration file")
     log.stderr(''' _configuration file format:
             symbolset:
                name=SYMBOLSET_NAME
                lib=PATH_TO_LIBRARY_1
                lib=PATH_TO_LIBRARY_2
             symbolset:
                 name=SYMBOLSET_NAME_N
                 lib=PATH_TO_LIBRARY        ''')
Exemple #9
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
Exemple #10
0
    def run(self):
        if self.executables == None:
            log.stderr("ERROR: Executables for coverage analysis unspecified!")
            raise Exception('Executable for coverage analysis unspecified')
        if self.config_map == None:
            log.stderr("ERROR: Configuration map for coverage analysis unspecified!")
            raise Exception("ERROR: Configuration map for coverage analysis unspecified!")

        covoarConfigFile = path.join(self.tracesDir, 'config')
        self.writeCovoarConfig(covoarConfigFile)
        if(not path.exists(covoarConfigFile)):
            log.stderr("Covoar configuration file: " + path.abspath(covoarConfigFile) + " doesn't exists! Covoar can not be run! ");
            return -1

        self._linkExecutables()

        symbolConfig = symbolsConfiguration()
        symbolConfig.load(self.symbolConfigPath)

        for sset in symbolConfig.symbolSets:
            if sset.isValid():
                symbolSetFile = path.join(self.tracesDir, sset.name + ".symcfg")
                sset.writeSetFile(symbolSetFile)
                self.symbolSets.append(sset.name)

                covoar_run = covoar(self.testDir, self.symbolConfigPath, self.tracesDir, path.join(self.rtdir, 'covoar'))
                covoar_run.run(sset.name, covoarConfigFile, symbolSetFile)
            else:
                log.stderr("Invalid symbol set " + sset.name + ". Skipping covoar run.")

        self._generateReports();
        self._cleanup();
        self._summarize();
Exemple #11
0
 def load(self, symbolSetConfigFile):
     scf = open(symbolSetConfigFile, 'r')
     for line in scf:
         try:
             if line.strip().startswith("symbolset"):
                 self.symbolSets.append(symbolSet("",[]))
             else:
                 splitted = line.split('=')
                 if(len(splitted) == 2):
                     key = splitted[0].strip()
                     value = splitted[1].strip()
                     if key == 'name':
                         self.symbolSets[-1].name = value
                     elif key == 'lib':
                         self.symbolSets[-1].libs.append(value)
                     else:
                         log.stderr("Invalid key : " + key + " in symbol set configuration file " + symbolSetConfigFile)
                 else:
                     self._log_invalid_format()
         except:
             self._log_invalid_format()
     scf.close()
Exemple #12
0
    def run(self):
        if self.executables == None:
            log.stderr(
                "ERROR: _executables for coverage analysis unspecified!")
            raise Exception('Executable for coverage analysis unspecified')
        if self.config_map == None:
            log.stderr(
                "ERROR: _configuration map for coverage analysis unspecified!")
            raise Exception(
                "ERROR: _configuration map for coverage analysis unspecified!")

        covoar_config_file = path.join(self.traces_dir, 'config')
        self.write_covoar_config(covoar_config_file)
        if (not path.exists(covoar_config_file)):
            log.stderr("Covoar configuration file: " +
                       path.abspath(covoar_config_file) +
                       " doesn't exists! Covoar can not be run! ")
            return -1

        self._link_executables()

        symbol_config = symbols_configuration()
        symbol_config.load(self.symbol_config_path, self.path_to_builddir)
        gcnos_file = path.join(self.traces_dir, "rtems.gcnos")
        gcnos().create_gcnos_file(self.gcnos_file_path, gcnos_file,
                                  self.path_to_builddir)

        for sset in 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)

                covoar_run = covoar(self.test_dir, self.symbol_config_path,
                                    self.traces_dir,
                                    path.join(self.rtdir, 'covoar'))
                covoar_run.run(sset.name, covoar_config_file, symbol_set_file,
                               gcnos_file)
            else:
                log.stderr("Invalid symbol set " + sset.name +
                           ". Skipping covoar run.")

        self._generate_reports()
        self._cleanup()
        self._summarize()
Exemple #13
0
 def isValid(self):
     if len(self.name) == 0:
         log.stderr("Invalid symbol set. Symbol set must have name! ")
         return False
     if len(self.libs) == 0:
         log.stderr("Invalid symbol set. Symbol set must have specified libraries!")
         return False
     for lib in self.libs:
         if not path.exists(lib):
             log.stderr("Invalid library path: " + lib)
             return False
     return True
Exemple #14
0
 def is_valid(self):
     if len(self.name) == 0:
         log.stderr("Invalid symbol set. Symbol set must have name! ")
         return False
     if len(self.libs) == 0:
         log.stderr(
             "Invalid symbol set. Symbol set must have specified libraries!"
         )
         return False
     for lib in self.libs:
         if not path.exists(lib):
             log.stderr("Invalid library path: " + lib)
             return False
     return True
Exemple #15
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)
Exemple #16
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)
Exemple #17
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)