コード例 #1
0
    def run(self, args):
        fail = False
        view = output.View(app_args=args)
        view.notify(event='message',
                    msg='Probing your system for test requirements')
        try:
            process.find_command('7za')
            view.notify(event='minor', msg='7zip present')
        except process.CmdNotFoundError:
            view.notify(event='warning',
                        msg=("7za not installed. You may "
                             "install 'p7zip' (or the "
                             "equivalent on your distro) to "
                             "fix the problem"))
            fail = True

        jeos_sha1_url = 'https://lmr.fedorapeople.org/jeos/SHA1SUM_JEOS20'
        try:
            view.notify(event='minor',
                        msg=('Verifying expected SHA1 '
                             'sum from %s' % jeos_sha1_url))
            sha1_file = urllib2.urlopen(jeos_sha1_url)
            sha1_contents = sha1_file.read()
            sha1 = sha1_contents.split(" ")[0]
            view.notify(event='minor', msg='Expected SHA1 sum: %s' % sha1)
        except Exception, e:
            view.notify(event='error',
                        msg='Failed to get SHA1 from file: %s' % e)
            fail = True
コード例 #2
0
ファイル: software_manager.py プロジェクト: eduardok/avocado
    def get_package_management(self):
        """
        Determine the supported package management systems present on the
        system. If more than one package management system installed, try
        to find the best supported system.
        """
        list_supported = []
        for high_level_pm in SUPPORTED_PACKAGE_MANAGERS:
            try:
                process.find_command(high_level_pm)
                list_supported.append(high_level_pm)
            except process.CmdNotFoundError:
                pass

        pm_supported = None
        if len(list_supported) == 0:
            pm_supported = None
        if len(list_supported) == 1:
            pm_supported = list_supported[0]
        elif len(list_supported) > 1:
            if ('apt-get' in list_supported
                    and self.distro in ('debian', 'ubuntu')):
                pm_supported = 'apt-get'
            elif ('yum' in list_supported
                  and self.distro in ('redhat', 'fedora')):
                pm_supported = 'yum'
            else:
                pm_supported = list_supported[0]

        return pm_supported
コード例 #3
0
ファイル: software_manager.py プロジェクト: cheliu/avocado
    def get_package_management(self):
        """
        Determine the supported package management systems present on the
        system. If more than one package management system installed, try
        to find the best supported system.
        """
        list_supported = []
        for high_level_pm in SUPPORTED_PACKAGE_MANAGERS:
            try:
                process.find_command(high_level_pm)
                list_supported.append(high_level_pm)
            except process.CmdNotFoundError:
                pass

        pm_supported = None
        if len(list_supported) == 0:
            pm_supported = None
        if len(list_supported) == 1:
            pm_supported = list_supported[0]
        elif len(list_supported) > 1:
            if ('apt-get' in list_supported and
                    self.distro in ('debian', 'ubuntu')):
                pm_supported = 'apt-get'
            elif ('yum' in list_supported and
                  self.distro in ('redhat', 'fedora')):
                pm_supported = 'yum'
            else:
                pm_supported = list_supported[0]

        return pm_supported
コード例 #4
0
ファイル: gdb.py プロジェクト: cheliu/avocado
    def configure(self, parser):
        self.parser = parser
        gdb_grp = self.parser.runner.add_argument_group('GNU Debugger support')
        gdb_grp.add_argument('--gdb-run-bin', action='append',
                             default=[], metavar='BINARY_PATH',
                             help=('Set a breakpoint on a given binary to be '
                                   'run inside the GNU debugger. Format should '
                                   'be "<binary>[:breakpoint]". Breakpoint '
                                   'defaults to "main"'))

        gdb_grp.add_argument('--gdb-prerun-commands', action='append',
                             default=[], metavar='BINARY_PATH:COMMANDS_PATH',
                             help=('After loading a binary in binary in GDB, '
                                   'but before actually running it, execute '
                                   'the given GDB commands in the given file.'
                                   'BINARY_PATH is optional and if ommited '
                                   'will apply to all binaries'))

        gdb_grp.add_argument('--gdb-enable-core', action='store_true',
                             default=False,
                             help=('Automatically generate a core dump when the'
                                   ' inferior process received a fatal signal '
                                   'such as SIGSEGV or SIGABRT'))

        default_gdb_path = '/usr/bin/gdb'
        try:
            system_gdb_path = process.find_command('gdb')
        except process.CmdNotFoundError:
            system_gdb_path = default_gdb_path
        gdb_grp.add_argument('--gdb-path',
                             default=system_gdb_path, metavar='PATH',
                             help=('Path to the GDB executable, should you '
                                   'need to use a custom GDB version. Defaults '
                                   'to "%(default)s"'))

        default_gdbserver_path = '/usr/bin/gdbserver'
        try:
            system_gdbserver_path = process.find_command('gdbserver')
        except process.CmdNotFoundError:
            system_gdbserver_path = default_gdbserver_path
        gdb_grp.add_argument('--gdbserver-path',
                             default=system_gdbserver_path, metavar='PATH',
                             help=('Path to the gdbserver executable, should you '
                                   'need to use a custom version. Defaults '
                                   'to "%(default)s"'))

        self.configured = True
コード例 #5
0
ファイル: output.py プロジェクト: cheliu/avocado
    def __init__(self):
        try:
            paginator = "%s -FRSX" % process.find_command('less')
        except process.CmdNotFoundError:
            paginator = None

        paginator = os.environ.get('PAGER', paginator)

        if paginator is None:
            self.pipe = sys.stdout
        else:
            self.pipe = os.popen(paginator, 'w')
コード例 #6
0
ファイル: software_manager.py プロジェクト: eduardok/avocado
    def provides(self, path):
        """
        Return a list of packages that provide [path].

        :param path: File path.
        """
        try:
            command = process.find_command('apt-file')
        except ValueError:
            self.install('apt-file')
            command = process.find_command('apt-file')

        cache_update_cmd = command + ' update'
        try:
            process.system(cache_update_cmd, ignore_status=True)
        except exceptions.CmdError:
            log.error("Apt file cache update failed")
        fu_cmd = command + ' search ' + path
        try:
            provides = process.system_output(fu_cmd).split('\n')
            list_provides = []
            for line in provides:
                if line:
                    try:
                        line = line.split(':')
                        package = line[0].strip()
                        lpath = line[1].strip()
                        if lpath == path and package not in list_provides:
                            list_provides.append(package)
                    except IndexError:
                        pass
            if len(list_provides) > 1:
                log.warning('More than one package found, '
                            'opting by the first result')
            if list_provides:
                log.info("Package %s provides %s", list_provides[0], path)
                return list_provides[0]
            return None
        except exceptions.CmdError:
            return None
コード例 #7
0
ファイル: software_manager.py プロジェクト: cheliu/avocado
    def provides(self, path):
        """
        Return a list of packages that provide [path].

        :param path: File path.
        """
        try:
            command = process.find_command('apt-file')
        except ValueError:
            self.install('apt-file')
            command = process.find_command('apt-file')

        cache_update_cmd = command + ' update'
        try:
            process.system(cache_update_cmd, ignore_status=True)
        except exceptions.CmdError:
            log.error("Apt file cache update failed")
        fu_cmd = command + ' search ' + path
        try:
            provides = process.system_output(fu_cmd).split('\n')
            list_provides = []
            for line in provides:
                if line:
                    try:
                        line = line.split(':')
                        package = line[0].strip()
                        lpath = line[1].strip()
                        if lpath == path and package not in list_provides:
                            list_provides.append(package)
                    except IndexError:
                        pass
            if len(list_provides) > 1:
                log.warning('More than one package found, '
                            'opting by the first result')
            if list_provides:
                log.info("Package %s provides %s", list_provides[0], path)
                return list_provides[0]
            return None
        except exceptions.CmdError:
            return None
コード例 #8
0
ファイル: output.py プロジェクト: eduardok/avocado
def get_paginator():
    """
    Get a pipe. If we can't do that, return stdout.

    The paginator is 'less'. The paginator is a useful feature inspired in
    programs such as git, since it lets you scroll up and down large buffers
    of text, increasing the program's usability.
    """
    try:
        less_cmd = process.find_command('less')
        return os.popen('%s -FRSX' % less_cmd, 'w')
    except process.CmdNotFoundError:
        return sys.stdout
コード例 #9
0
ファイル: software_manager.py プロジェクト: eduardok/avocado
 def __init__(self):
     """
     Initializes the base command and the yum package repository.
     """
     super(ZypperBackend, self).__init__()
     self.base_command = process.find_command('zypper') + ' -n'
     z_cmd = self.base_command + ' --version'
     cmd_result = process.run(z_cmd, ignore_status=True, verbose=False)
     out = cmd_result.stdout.strip()
     try:
         ver = re.findall('\d.\d*.\d*', out)[0]
     except IndexError:
         ver = out
     self.pm_version = ver
     log.debug('Zypper version: %s' % self.pm_version)
コード例 #10
0
ファイル: software_manager.py プロジェクト: cheliu/avocado
 def __init__(self):
     """
     Initializes the base command and the yum package repository.
     """
     super(ZypperBackend, self).__init__()
     self.base_command = process.find_command('zypper') + ' -n'
     z_cmd = self.base_command + ' --version'
     cmd_result = process.run(z_cmd, ignore_status=True,
                              verbose=False)
     out = cmd_result.stdout.strip()
     try:
         ver = re.findall('\d.\d*.\d*', out)[0]
     except IndexError:
         ver = out
     self.pm_version = ver
     log.debug('Zypper version: %s' % self.pm_version)
コード例 #11
0
def get_qemu_img_binary(params=None):
    if params is not None:
        params_qemu = params.get('virt.qemu.paths.qemu_img_bin')
        if params_qemu is not None:
            return _validate_path(params_qemu,
                                  'config value virt.qemu.paths.qemu_img_bin')

    env_qemu = os.environ.get('QEMU_IMG')
    if env_qemu is not None:
        return _validate_path(env_qemu, 'env variable $QEMU_IMG')

    try:
        return process.find_command('qemu-img')
    except process.CmdNotFoundError:
        pass

    raise QEMUCmdNotFoundError('qemu-img')
コード例 #12
0
ファイル: software_manager.py プロジェクト: FengYang/avocado
    def __init__(self):
        """
        Initializes the base command and the debian package repository.
        """
        super(AptBackend, self).__init__()
        executable = process.find_command('apt-get')
        self.base_command = executable + ' -y'
        self.repo_file_path = '/etc/apt/sources.list.d/autotest'
        cmd_result = process.run('apt-get -v | head -1',
                                 ignore_status=True,
                                 verbose=False)
        out = cmd_result.stdout.strip()
        try:
            ver = re.findall('\d\S*', out)[0]
        except IndexError:
            ver = out
        self.pm_version = ver

        log.debug('apt-get version: %s' % self.pm_version)
コード例 #13
0
ファイル: software_manager.py プロジェクト: eduardok/avocado
    def __init__(self):
        """
        Initializes the base command and the debian package repository.
        """
        super(AptBackend, self).__init__()
        executable = process.find_command('apt-get')
        self.base_command = executable + ' -y'
        self.repo_file_path = '/etc/apt/sources.list.d/autotest'
        cmd_result = process.run('apt-get -v | head -1',
                                 ignore_status=True,
                                 verbose=False)
        out = cmd_result.stdout.strip()
        try:
            ver = re.findall('\d\S*', out)[0]
        except IndexError:
            ver = out
        self.pm_version = ver

        log.debug('apt-get version: %s' % self.pm_version)
コード例 #14
0
ファイル: software_manager.py プロジェクト: eduardok/avocado
    def __init__(self):
        """
        Initializes the base command and the yum package repository.
        """
        super(YumBackend, self).__init__()
        executable = process.find_command('yum')
        base_arguments = '-y'
        self.base_command = executable + ' ' + base_arguments
        self.repo_file_path = '/etc/yum.repos.d/autotest.repo'
        self.cfgparser = ConfigParser.ConfigParser()
        self.cfgparser.read(self.repo_file_path)
        y_cmd = executable + ' --version | head -1'
        cmd_result = process.run(y_cmd, ignore_status=True, verbose=False)
        out = cmd_result.stdout.strip()
        try:
            ver = re.findall('\d*.\d*.\d*', out)[0]
        except IndexError:
            ver = out
        self.pm_version = ver
        log.debug('Yum version: %s' % self.pm_version)

        self.yum_base = yum.YumBase()
コード例 #15
0
ファイル: software_manager.py プロジェクト: cheliu/avocado
    def __init__(self):
        """
        Initializes the base command and the yum package repository.
        """
        super(YumBackend, self).__init__()
        executable = process.find_command('yum')
        base_arguments = '-y'
        self.base_command = executable + ' ' + base_arguments
        self.repo_file_path = '/etc/yum.repos.d/avocado-managed.repo'
        self.cfgparser = ConfigParser.ConfigParser()
        self.cfgparser.read(self.repo_file_path)
        y_cmd = executable + ' --version | head -1'
        cmd_result = process.run(y_cmd, ignore_status=True,
                                 verbose=False, shell=True)
        out = cmd_result.stdout.strip()
        try:
            ver = re.findall('\d*.\d*.\d*', out)[0]
        except IndexError:
            ver = out
        self.pm_version = ver
        log.debug('Yum version: %s' % self.pm_version)

        self.yum_base = yum.YumBase()
コード例 #16
0
def get_qemu_dst_binary(params=None):
    """
    Find an alternate QEMU binary to transfer state to.

    This is for use in migration tests.
    """
    if params is not None:
        params_qemu = params.get('virt.qemu.paths.qemu_dst_bin')
        if params_qemu is not None:
            return _validate_path(params_qemu,
                                  'config value virt.qemu.paths.qemu_dst_bin')

    env_qemu = os.environ.get('QEMU_DST')
    if env_qemu is not None:
        return _validate_path(env_qemu, 'env variable $QEMU')

    for c in _QEMU_CANDIDATE_NAMES:
        try:
            return process.find_command(c)
        except process.CmdNotFoundError:
            pass

    raise QEMUCmdNotFoundError('qemu alternate destination')
コード例 #17
0
def get_qemu_binary(params=None):
    """
    Find a QEMU binary.

    First, look in the test params, then in the env variable $QEMU and
    then, if nothing found, look in the system $PATH.
    """
    if params is not None:
        params_qemu = params.get('virt.qemu.paths.qemu_bin')
        if params_qemu is not None:
            return _validate_path(params_qemu,
                                  'config value virt.qemu.paths.qemu_bin')

    env_qemu = os.environ.get('QEMU')
    if env_qemu is not None:
        return _validate_path(env_qemu, 'env variable $QEMU')

    for c in _QEMU_CANDIDATE_NAMES:
        try:
            return process.find_command(c)
        except process.CmdNotFoundError:
            pass

    raise QEMUCmdNotFoundError('qemu')
コード例 #18
0
ファイル: conf.py プロジェクト: cheliu/avocado
# -*- coding: utf-8 -*-

import sys
import os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
root_path = os.path.abspath(os.path.join("..", ".."))
sys.path.insert(0, root_path)

import avocado.version
from avocado.utils import process

# Auto generate API documentation
_sphinx_apidoc = process.find_command('sphinx-apidoc')
_output_dir = os.path.join(root_path, 'docs', 'source', 'api')
_api_dir = os.path.join(root_path, 'avocado')
process.run("%s -o %s %s" % (_sphinx_apidoc, _output_dir, _api_dir))

extensions = ['sphinx.ext.autodoc',
              'sphinx.ext.intersphinx',
              'sphinx.ext.todo',
              'sphinx.ext.coverage']

master_doc = 'index'
project = u'Avocado'
copyright = u'2014, Red Hat'

version = avocado.version.VERSION
release = avocado.version.VERSION
コード例 #19
0
ファイル: conf.py プロジェクト: eduardok/avocado
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
root_path = os.path.abspath(os.path.join("..", ".."))
sys.path.insert(0, root_path)

# Auto generate API documentation
from avocado.utils import process
_sphinx_apidoc = process.find_command('sphinx-apidoc')
_output_dir = os.path.join(root_path, 'docs', 'source', 'api')
_api_dir = os.path.join(root_path, 'avocado')
process.run("%s -o %s %s" % (_sphinx_apidoc, _output_dir, _api_dir))

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
    'sphinx.ext.coverage'
]
コード例 #20
0
ファイル: software_manager.py プロジェクト: cheliu/avocado
 def __init__(self):
     self.lowlevel_base_cmd = process.find_command('dpkg')
コード例 #21
0
ファイル: software_manager.py プロジェクト: eduardok/avocado
 def __init__(self):
     self.lowlevel_base_cmd = process.find_command('dpkg')