Esempio n. 1
0
    def setUp(self):
        softm = SoftwareManager()

        pkgs = ['gcc', 'make']
        if distro.detect().name in ['SuSE', 'Ubuntu', 'debian']:
            pkgs.extend(['libpfm4'])
        else:
            pkgs.extend(['libpfm'])

        for pkg in pkgs:
            if not softm.check_installed(pkg) and not softm.install(pkg):
                self.cancel("%s is needed for the test to be run" % pkg)
        test_type = self.params.get('type', default='upstream')

        if test_type == 'upstream':
            tarball = self.fetch_asset(
                'https://netix.dl.sourceforge.net/project/perfmon2/'
                'libpfm4/libpfm-4.9.0.tar.gz', expire='1d')
            archive.extract(tarball, self.teststmpdir)
            version = os.path.basename(tarball.split('.tar.')[0])
            self.path = os.path.join(self.teststmpdir, version)
        elif test_type == 'distro':
            sourcedir = os.path.join(self.teststmpdir, 'libpfm-distro')
            if not os.path.exists(sourcedir):
                os.makedirs(sourcedir)
            if distro.detect().name == 'Ubuntu':
                self.path = softm.get_source('libpfm4', sourcedir)
            else:
                self.path = softm.get_source('libpfm', sourcedir)

        os.chdir(self.path)
        build.make(self.path)
Esempio n. 2
0
    def setUp(self):
        softm = SoftwareManager()

        pkgs = ['gcc', 'make']
        if distro.detect().name in ['SuSE', 'Ubuntu']:
            pkgs.extend(['libpfm4'])
        else:
            pkgs.extend(['libpfm'])

        for pkg in pkgs:
            if not softm.check_installed(pkg) and not softm.install(pkg):
                self.cancel("%s is needed for the test to be run" % pkg)
        test_type = self.params.get('type', default='upstream')

        if test_type == 'upstream':
            tarball = self.fetch_asset(
                'https://netix.dl.sourceforge.net/project/perfmon2/'
                'libpfm4/libpfm-4.9.0.tar.gz', expire='1d')
            archive.extract(tarball, self.teststmpdir)
            version = os.path.basename(tarball.split('.tar.')[0])
            self.path = os.path.join(self.teststmpdir, version)
        elif test_type == 'distro':
            sourcedir = os.path.join(self.teststmpdir, 'libpfm-distro')
            if not os.path.exists(sourcedir):
                os.makedirs(sourcedir)
            if distro.detect().name == 'Ubuntu':
                self.path = softm.get_source('libpfm4', sourcedir)
            else:
                self.path = softm.get_source('libpfm', sourcedir)

        os.chdir(self.path)
        build.make(self.path)
Esempio n. 3
0
    def setUp(self):
        smm = SoftwareManager()
        self.failures = []

        dist = distro.detect()
        deps = ['gcc', 'make']
        if dist.name == 'Ubuntu':
            deps.extend(['g++'])
        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif dist.name in ['SuSE', 'rhel', 'fedora', 'centos', 'redhat']:
            deps.extend(['gcc-c++'])
        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel('%s is needed for the test to be run' % package)
        run_type = self.params.get('type', default='upstream')
        if run_type == "upstream":
            url = self.params.get('url', default="ftp://sourceware.org/pub/"
                                  "valgrind/valgrind-3.13.0.tar.bz2")
            tarball = self.fetch_asset(url)
            archive.extract(tarball, self.workdir)
            version = os.path.basename(tarball.split('.tar.')[0])
            self.sourcedir = os.path.join(self.workdir, version)
        elif run_type == "distro":
            self.sourcedir = os.path.join(self.workdir, 'valgrind-distro')
            if not os.path.exists(self.sourcedir):
                os.makedirs(self.sourcedir)
            self.sourcedir = smm.get_source('valgrind', self.sourcedir)
        os.chdir(self.sourcedir)
        process.run('./configure', ignore_status=True, sudo=True)
Esempio n. 4
0
 def setUp(self):
     sm = SoftwareManager()
     dist = distro.detect()
     packages = ['gcc', 'dejagnu', 'flex', 'bison', 'texinfo']
     if dist.name == 'Ubuntu':
         packages.extend(['g++', 'binutils-dev'])
     # FIXME: "redhat" as the distro name for RHEL is deprecated
     # on Avocado versions >= 50.0.  This is a temporary compatibility
     # enabler for older runners, but should be removed soon
     elif dist.name in ['SuSE', 'rhel', 'fedora', 'redhat']:
         packages.extend(['gcc-c++', 'binutils-devel', 'texi2html'])
     else:
         self.fail('no packages list for your distro.')
     for package in packages:
         if not sm.check_installed(package) and not sm.install(package):
             self.error("Fail to install %s required for this test." %
                        package)
     test_type = self.params.get('type', default='upstream')
     if test_type == 'upstream':
         gdb_version = self.params.get('gdb_version', default='7.10')
         tarball = self.fetch_asset(
             "http://ftp.gnu.org/gnu/gdb/gdb-%s.tar.gz" % gdb_version)
         archive.extract(tarball, self.workdir)
         sourcedir = os.path.join(
             self.workdir, os.path.basename(tarball.split('.tar')[0]))
     elif test_type == 'distro':
         sourcedir = os.path.join(self.workdir, 'gdb-distro')
         if not os.path.exists(sourcedir):
             os.makedirs(sourcedir)
         sourcedir = sm.get_source("gdb", sourcedir)
     os.chdir(sourcedir)
     process.run('./configure', ignore_status=True, sudo=True)
     build.make(sourcedir)
Esempio n. 5
0
    def setUp(self):
        """
        Build strace

        Source:
        http://github.com/strace/strace.git
        """

        smm = SoftwareManager()
        for package in ['make', 'gcc', 'autoconf', 'automake']:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel(' %s is needed for the test to be run' % package)

        run_type = self.params.get("type", default="distro")
        if run_type == "upstream":
            source = self.params.get('url',
                                     default="https://github.com/"
                                     "strace/strace.git")
            git.get_repo(source,
                         destination_dir=os.path.join(self.workdir, 'strace'))
            self.src_st = os.path.join(self.workdir, "strace")
            os.chdir(self.src_st)
            process.run('./bootstrap', ignore_status=True, sudo=True)
        elif run_type == "distro":
            self.src_st = os.path.join(self.workdir, "strace-distro")
            if not os.path.exists(self.src_st):
                self.src_st = smm.get_source("strace", self.src_st)
            os.chdir(self.src_st)

        process.run('./configure', ignore_status=True, sudo=True)
        build.make(self.src_st)
    def setUp(self):
        smm = SoftwareManager()
        self.failures = []

        dist = distro.detect()
        deps = ['gcc', 'make']
        if dist.name in ['Ubuntu', 'debian']:
            deps.extend(['g++'])
        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif dist.name in ['SuSE', 'rhel', 'fedora', 'centos', 'redhat']:
            deps.extend(['gcc-c++'])
        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel('%s is needed for the test to be run' % package)
        run_type = self.params.get('type', default='upstream')
        if run_type == "upstream":
            url = "ftp://sourceware.org/pub/valgrind/"
            version = self.params.get('version', default="3.18.1")
            url = '%s/valgrind-%s.tar.bz2' % (url, version)
            tarball = self.fetch_asset(url)
            archive.extract(tarball, self.workdir)
            version = os.path.basename(tarball.split('.tar.')[0])
            self.sourcedir = os.path.join(self.workdir, version)
        elif run_type == "distro":
            self.sourcedir = os.path.join(self.workdir, 'valgrind-distro')
            if not os.path.exists(self.sourcedir):
                os.makedirs(self.sourcedir)
            self.sourcedir = smm.get_source('valgrind', self.sourcedir)
        os.chdir(self.sourcedir)
        process.run('./configure', ignore_status=True, sudo=True)
Esempio n. 7
0
 def setUp(self):
     sm = SoftwareManager()
     deps = ['gcc', 'make', 'gawk']
     self.build_dir = self.params.get('build_dir',
                                      default=data_dir.get_tmp_dir())
     for package in deps:
         if not sm.check_installed(package) and not sm.install(package):
             self.cancel('%s is needed for the test to be run' % package)
     run_type = self.params.get('type', default='upstream')
     if run_type == "upstream":
         url = 'https://github.com/bminor/glibc/archive/master.zip'
         tarball = self.fetch_asset("glibc.zip",
                                    locations=[url],
                                    expire='7d')
         archive.extract(tarball, self.workdir)
         glibc_dir = os.path.join(self.workdir, "glibc-master")
     elif run_type == "distro":
         glibc_dir = os.path.join(self.workdir, "glibc-distro")
         if not os.path.exists(glibc_dir):
             os.makedirs(glibc_dir)
         glibc_dir = sm.get_source("glibc", glibc_dir)
     os.chdir(self.build_dir)
     process.run('%s/configure --prefix=%s' %
                 (glibc_dir, self.params.get("prefix", default="/usr")),
                 ignore_status=True,
                 sudo=True)
     build.make(self.build_dir)
Esempio n. 8
0
 def setUp(self):
     sm = SoftwareManager()
     dist = distro.detect()
     packages = ['gcc', 'dejagnu', 'flex', 'bison', 'texinfo']
     if dist.name == 'Ubuntu':
         packages.extend(['g++', 'binutils-dev'])
     # FIXME: "redhat" as the distro name for RHEL is deprecated
     # on Avocado versions >= 50.0.  This is a temporary compatibility
     # enabler for older runners, but should be removed soon
     elif dist.name in ['SuSE', 'rhel', 'fedora', 'redhat']:
         packages.extend(['gcc-c++', 'binutils-devel', 'texi2html'])
     else:
         self.fail('no packages list for your distro.')
     for package in packages:
         if not sm.check_installed(package) and not sm.install(package):
             self.error("Fail to install %s required for this test." %
                        package)
     test_type = self.params.get('type', default='upstream')
     if test_type == 'upstream':
         gdb_version = self.params.get('gdb_version', default='7.10')
         tarball = self.fetch_asset(
             "http://ftp.gnu.org/gnu/gdb/gdb-%s.tar.gz" % gdb_version)
         archive.extract(tarball, self.workdir)
         sourcedir = os.path.join(
             self.workdir, os.path.basename(tarball.split('.tar')[0]))
     elif test_type == 'distro':
         sourcedir = os.path.join(self.workdir, 'gdb-distro')
         if not os.path.exists(sourcedir):
             os.makedirs(sourcedir)
         sourcedir = sm.get_source("gdb", sourcedir)
     os.chdir(sourcedir)
     process.run('./configure', ignore_status=True, sudo=True)
     build.make(sourcedir)
Esempio n. 9
0
    def setUp(self):
        """
        Install  all the required dependencies
        Building source tarball requires packages specific to os
        that needs to be installed, if not installed test will stop.
        """

        smm = SoftwareManager()
        dist = distro.detect()
        dist_name = dist.name.lower()

        packages = ['gcc', 'wget', 'autoconf', 'automake',
                    'dejagnu', 'binutils', 'patch']

        if dist_name == 'suse':
            packages.extend(['libdw-devel', 'libelf-devel', 'git-core',
                             'elfutils', 'binutils-devel', 'libtool', 'gcc-c++'])

        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif dist_name in ("rhel", "fedora", "redhat"):
            packages.extend(['elfutils-devel', 'elfutils-libelf-devel', 'git',
                             'elfutils-libelf', 'elfutils-libs', 'libtool-ltdl'])

        elif dist_name == 'ubuntu':
            packages.extend(['elfutils', 'libelf-dev', 'libtool', 'git',
                             'libelf1', 'librpmbuild3', 'binutils-dev'])
        else:
            self.cancel("Unsupported OS!")

        for package in packages:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel("Fail to install %s required for this test." %
                            package)
        run_type = self.params.get("type", default="upstream")
        if run_type == "upstream":
            source = self.params.get('url', default="git://git.debian.org/git/"
                                     "collab-maint/ltrace.git")
            git.get_repo(source, destination_dir=os.path.join(
                self.srcdir, 'ltrace'))

            self.src_lt = os.path.join(self.srcdir, "ltrace")
            os.chdir(self.src_lt)
            process.run('patch -p1 < %s' %
                        os.path.join(self.datadir, 'ltrace.patch'), shell=True)
        elif run_type == "distro":
            self.src_lt = os.path.join(self.srcdir, "ltrace-distro")
            if not os.path.exists(self.src_lt):
                self.src_lt = smm.get_source("ltrace", self.src_lt)
            os.chdir(self.src_lt)

        process.run('./autogen.sh')
        process.run('./configure')
        build.make(self.src_lt)
Esempio n. 10
0
    def setUp(self):
        '''
        Install the pre-requisites packages and download kernel source
        '''
        self.testdir = "tools/testing/selftests/ftrace"
        smg = SoftwareManager()
        self.version = self.params.get('type', default='upstream')
        detected_distro = distro.detect()

        if self.version == 'distro':
            # Make sure kernel source repo is configured
            if detected_distro.name in ['rhel', 'centos']:
                self.buldir = smg.get_source("kernel", self.workdir)
                self.buldir = os.path.join(self.buldir,
                                           os.listdir(self.buldir)[0])
            elif 'SuSE' in detected_distro.name:
                if not smg.check_installed("kernel-source") and not\
                        smg.install("kernel-source"):
                    self.cancel(
                        "Failed to install kernel-source for this test.")
                if not os.path.exists("/usr/src/linux"):
                    self.cancel("kernel source missing after install")
                self.buldir = "/usr/src/linux"
        else:
            location = self.params.get('location',
                                       default='https://github.c'
                                       'om/torvalds/linux/archive/master.zip')
            self.output = "linux-master"

            match = next((ext for ext in [".zip", ".tar"] if ext in location),
                         None)
            if match:
                tarball = self.fetch_asset("kselftest%s" % match,
                                           locations=[location],
                                           expire='1d')
                archive.extract(tarball, self.workdir)
            else:
                git.get_repo(location, destination_dir=self.workdir)
            self.buldir = os.path.join(self.workdir, self.output)
        os.chdir(os.path.join(self.buldir, self.testdir))
Esempio n. 11
0
 def setUp(self):
     sm = SoftwareManager()
     deps = ['gcc', 'make', 'gawk']
     self.build_dir = self.params.get('build_dir',
                                      default=data_dir.get_tmp_dir())
     for package in deps:
         if not sm.check_installed(package) and not sm.install(package):
             self.error(package + ' is needed for the test to be run')
     run_type = self.params.get('type', default='upstream')
     if run_type == "upstream":
         url = 'https://github.com/bminor/glibc/archive/master.zip'
         tarball = self.fetch_asset("glibc.zip", locations=[url], expire='7d')
         archive.extract(tarball, self.srcdir)
         glibc_dir = os.path.join(self.srcdir, "glibc-master")
     elif run_type == "distro":
         glibc_dir = os.path.join(self.srcdir, "glibc-distro")
         if not os.path.exists(glibc_dir):
             os.makedirs(glibc_dir)
         glibc_dir = sm.get_source("glibc", glibc_dir)
     os.chdir(self.build_dir)
     process.run(glibc_dir + '/configure --prefix=%s' % self.build_dir,
                 ignore_status=True, sudo=True)
     build.make(self.build_dir)
Esempio n. 12
0
    def setUp(self):

        softm = SoftwareManager()

        for package in ['gcc', 'make']:
            if not softm.check_installed(package) and not softm.install(package):
                self.cancel("%s is needed for the test to be run" % package)
        test_type = self.params.get('type', default='upstream')

        if test_type == 'upstream':
            git.get_repo('https://github.com/arm-hpc/papi.git',
                         destination_dir=self.teststmpdir)
            self.path = os.path.join(self.teststmpdir, 'src')
        elif test_type == 'distro':
            sourcedir = os.path.join(self.teststmpdir, 'papi-distro')
            if not os.path.exists(sourcedir):
                os.makedirs(sourcedir)
            self.path = softm.get_source("papi", sourcedir)
            self.path = os.path.join(self.path, 'src')

        os.chdir(self.path)
        process.run('./configure', shell=True)
        build.make(self.path)
Esempio n. 13
0
    def setUp(self):

        softm = SoftwareManager()

        for package in ['gcc', 'make']:
            if not softm.check_installed(package) and not softm.install(
                    package):
                self.cancel("%s is needed for the test to be run" % package)
        test_type = self.params.get('type', default='upstream')

        if test_type == 'upstream':
            git.get_repo('https://github.com/arm-hpc/papi.git',
                         destination_dir=self.teststmpdir)
            self.path = os.path.join(self.teststmpdir, 'src')
        elif test_type == 'distro':
            sourcedir = os.path.join(self.teststmpdir, 'papi-distro')
            if not os.path.exists(sourcedir):
                os.makedirs(sourcedir)
            self.path = softm.get_source("papi", sourcedir)
            self.path = os.path.join(self.path, 'src')

        os.chdir(self.path)
        process.run('./configure', shell=True)
        build.make(self.path)
Esempio n. 14
0
    def setUp(self):
        """
        Install  all the required dependencies
        Building source tarball requires packages specific to os
        that needs to be installed, if not installed test will stop.
        """

        smm = SoftwareManager()
        dist = distro.detect()
        dist_name = dist.name.lower()

        packages = [
            'gcc', 'wget', 'autoconf', 'automake', 'dejagnu', 'binutils',
            'patch'
        ]

        if dist_name == 'suse':
            packages.extend([
                'libdw-devel', 'libelf-devel', 'git-core', 'elfutils',
                'binutils-devel', 'libtool', 'gcc-c++'
            ])

        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif dist_name in ("rhel", "fedora", "redhat"):
            packages.extend([
                'elfutils-devel', 'elfutils-libelf-devel', 'git',
                'elfutils-libelf', 'elfutils-libs', 'libtool-ltdl'
            ])

        elif dist_name == 'ubuntu':
            packages.extend([
                'elfutils', 'libelf-dev', 'libtool', 'git', 'libelf1',
                'librpmbuild3', 'binutils-dev'
            ])
        else:
            self.cancel("Unsupported OS!")

        for package in packages:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel("Fail to install %s required for this test." %
                            package)
        run_type = self.params.get("type", default="upstream")
        if run_type == "upstream":
            source = self.params.get('url',
                                     default="git://git.debian.org/git/"
                                     "collab-maint/ltrace.git")
            git.get_repo(source,
                         destination_dir=os.path.join(self.workdir, 'ltrace'))

            self.src_lt = os.path.join(self.workdir, "ltrace")
            os.chdir(self.src_lt)
            process.run('patch -p1 < %s' % self.get_data('ltrace.patch'),
                        shell=True)
        elif run_type == "distro":
            self.src_lt = os.path.join(self.workdir, "ltrace-distro")
            if not os.path.exists(self.src_lt):
                self.src_lt = smm.get_source("ltrace", self.src_lt)
            os.chdir(self.src_lt)

        process.run('./autogen.sh')
        process.run('./configure')
        build.make(self.src_lt)
    def setUp(self):
        """
        Resolve the packages dependencies and download the source.
        """
        smg = SoftwareManager()
        self.comp = self.params.get('comp', default='')
        self.run_type = self.params.get('type', default='upstream')
        if self.comp:
            self.comp = '-C %s' % self.comp
        detected_distro = distro.detect()
        deps = ['gcc', 'make', 'automake', 'autoconf', 'rsync']

        if 'Ubuntu' in detected_distro.name:
            deps.extend(['libpopt0', 'libc6', 'libc6-dev', 'libcap-dev',
                         'libpopt-dev', 'libcap-ng0', 'libcap-ng-dev',
                         'libnuma-dev', 'libfuse-dev', 'elfutils', 'libelf1'])
        elif 'SuSE' in detected_distro.name:
            deps.extend(['glibc', 'glibc-devel', 'popt-devel', 'sudo',
                         'libcap2', 'libcap-devel', 'libcap-ng-devel',
                         'fuse', 'fuse-devel', 'glibc-devel-static'])
        elif detected_distro.name in ['centos', 'fedora', 'rhel']:
            deps.extend(['popt', 'glibc', 'glibc-devel', 'glibc-static',
                         'libcap-ng', 'libcap', 'libcap-devel', 'fuse-devel',
                         'libcap-ng-devel', 'popt-devel'])

        for package in deps:
            if not smg.check_installed(package) and not smg.install(package):
                self.cancel(
                    "Fail to install %s required for this test." % (package))

        if self.run_type == 'upstream':
            location = self.params.get('location', default='https://github.c'
                                       'om/torvalds/linux/archive/master.zip')
            tarball = self.fetch_asset("kselftest.zip", locations=[location],
                                       expire='1d')
            archive.extract(tarball, self.workdir)
            self.buldir = os.path.join(self.workdir, 'linux-master')
        else:
            # Make sure kernel source repo is configured
            if detected_distro.name in ['centos', 'fedora', 'rhel']:
                src_name = 'kernel'
                if detected_distro.name == 'rhel':
                    # Check for "el*a" where ALT always ends with 'a'
                    if platform.uname()[2].split(".")[-2].endswith('a'):
                        self.log.info('Using ALT as kernel source')
                        src_name = 'kernel-alt'
                self.buldir = smg.get_source(src_name, self.workdir)
                self.buldir = os.path.join(
                    self.buldir, os.listdir(self.buldir)[0])
            elif 'Ubuntu' in detected_distro.name:
                self.buldir = smg.get_source('linux', self.workdir)
            elif 'SuSE' in detected_distro.name:
                smg._source_install('kernel-default')
                smg.get_source('kernel-source', self.workdir)
                packages = '/usr/src/packages/'
                os.chdir(os.path.join(packages, 'SOURCES'))
                process.system('./mkspec', ignore_status=True)
                shutil.copy(os.path.join(packages, 'SOURCES/kernel'
                                                   '-default.spec'),
                            os.path.join(packages, 'SPECS/kernel'
                                                   '-default.spec'))
                self.buldir = smg.prepare_source(os.path.join(
                    packages, 'SPECS/kernel'
                              '-default.spec'), dest_path=self.teststmpdir)
                for l_dir in glob.glob(os.path.join(self.buldir, 'linux*')):
                    if os.path.isdir(l_dir) and 'Makefile' in os.listdir(l_dir):
                        self.buldir = os.path.join(
                            self.buldir, os.listdir(self.buldir)[0])

        self.sourcedir = os.path.join(self.buldir, self.testdir)
        if build.make(self.sourcedir):
            self.fail("Compilation failed, Please check the build logs !!")
Esempio n. 16
0
class Binutils(Test):
    """
    This testcase make use of testsuite provided by the
    source package, performs functional test for all binary tools
    source file is downloaded and compiled.
    """

    def check_install(self, package):
        """
        Appends package to `self._needed_deps` when not able to install it
        """
        if (not self._sm.check_installed(package) and
                not self._sm.install(package)):
            self.cancel('Please install %s for the test to run' % self.package)

    def setUp(self):
        # Check for basic utilities
        self._sm = SoftwareManager()

        # Install required tools and resolve dependencies
        needed_deps = ['make', 'gcc', 'dejagnu',
                       'elfutils', 'autoconf', 'automake']
        dist = distro.detect()
        if dist.name.lower() == 'ubuntu':
            needed_deps.extend(['build-essential'])
        for pkg in needed_deps:
            self.check_install(pkg)
        run_type = self.params.get("type", default="upstream")
        # Extract - binutils
        # Source: https://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.bz2
        if run_type == "upstream":
            version = self.params.get('binutils_version', default='2.27')
            locations = [
                "https://www.mirrorservice.org/sites/sourceware.org"
                "/pub/binutils/releases/binutils-%s.tar.bz2" % version]
            tarball = self.fetch_asset("binutils-%s.tar.bz2" % version,
                                       locations=locations)
            archive.extract(tarball, self.workdir)
            self.sourcedir = os.path.join(
                self.workdir, os.path.basename(tarball.split('.tar.')[0]))
        elif run_type == "distro":
            self.sourcedir = os.path.join(self.workdir, "binutils-distro")
            if not os.path.exists(self.sourcedir):
                self.sourcedir = self._sm.get_source("binutils", self.sourcedir)

        # Compile the binutils
        os.chdir(self.sourcedir)
        process.run('./configure')
        build.make(self.sourcedir)

    def test(self):
        """
        Runs the binutils `make check`
        """
        ret = build.make(self.sourcedir, extra_args='check', ignore_status=True)

        errors = 0
        for root, _, filenames in os.walk(self.sourcedir):
            for filename in fnmatch.filter(filenames, '*.log'):
                filename = os.path.join(root, filename)
                logfile = filename[:-4] + ".log"
                shutil.copy(logfile, self.logdir)
                with open(logfile) as result:
                    for line in result.readlines():
                        if line.startswith('FAIL'):
                            errors += 1
                            self.log.error(line)
        if errors:
            self.fail("%s test(s) failed, check the log for details." % errors)
        elif ret:
            self.fail("'make check' finished with %s, but no FAIL lines were "
                      "found." % ret)
    def setUp(self):
        """
        Resolve the packages dependencies and download the source.
        """
        smg = SoftwareManager()
        self.comp = self.params.get('comp', default='')
        self.run_type = self.params.get('type', default='upstream')
        if self.comp:
            self.comp = '-C %s' % self.comp
        detected_distro = distro.detect()
        deps = ['gcc', 'make', 'automake', 'autoconf', 'rsync']

        if detected_distro.name in ['Ubuntu', 'debian']:
            deps.extend([
                'libpopt0', 'libc6', 'libc6-dev', 'libcap-dev', 'libpopt-dev',
                'libcap-ng0', 'libcap-ng-dev', 'libnuma-dev', 'libfuse-dev',
                'elfutils', 'libelf1', 'libhugetlbfs-dev'
            ])
        elif 'SuSE' in detected_distro.name:
            deps.extend([
                'glibc', 'glibc-devel', 'popt-devel', 'sudo', 'libcap2',
                'libcap-devel', 'libcap-ng-devel', 'fuse', 'fuse-devel',
                'glibc-devel-static'
            ])
            if detected_distro.version >= 15:
                deps.extend(['libhugetlbfs-devel'])
            else:
                deps.extend(['libhugetlbfs-libhugetlb-devel'])
        elif detected_distro.name in ['centos', 'fedora', 'rhel']:
            deps.extend([
                'popt', 'glibc', 'glibc-devel', 'glibc-static', 'libcap-ng',
                'libcap', 'libcap-devel', 'fuse-devel', 'libcap-ng-devel',
                'popt-devel', 'libhugetlbfs-devel'
            ])

        for package in deps:
            if not smg.check_installed(package) and not smg.install(package):
                self.cancel("Fail to install %s required for this test." %
                            (package))

        if self.run_type == 'upstream':
            location = self.params.get('location',
                                       default='https://github.c'
                                       'om/torvalds/linux/archive/master.zip')
            path = ''
            match = next((ext for ext in [".zip", ".tar"] if ext in location),
                         None)
            if match:
                tarball = self.fetch_asset("kselftest%s" % match,
                                           locations=[location],
                                           expire='1d')
                archive.extract(tarball, self.workdir)
                path = glob.glob(os.path.join(self.workdir, "linux*"))
            else:
                git.get_repo(location, destination_dir=self.workdir)
                path = glob.glob(self.workdir)
            for l_dir in path:
                if os.path.isdir(l_dir) and 'Makefile' in os.listdir(l_dir):
                    self.buldir = os.path.join(self.workdir, l_dir)
                    break
        else:
            # Make sure kernel source repo is configured
            if detected_distro.name in ['centos', 'fedora', 'rhel']:
                src_name = 'kernel'
                if detected_distro.name == 'rhel':
                    # Check for "el*a" where ALT always ends with 'a'
                    if platform.uname()[2].split(".")[-2].endswith('a'):
                        self.log.info('Using ALT as kernel source')
                        src_name = 'kernel-alt'
                self.buldir = smg.get_source(src_name, self.workdir)
                self.buldir = os.path.join(self.buldir,
                                           os.listdir(self.buldir)[0])
            elif detected_distro.name in ['Ubuntu', 'debian']:
                self.buldir = smg.get_source('linux', self.workdir)
            elif 'SuSE' in detected_distro.name:
                if not smg.check_installed("kernel-source") and not\
                        smg.install("kernel-source"):
                    self.cancel(
                        "Failed to install kernel-source for this test.")
                if not os.path.exists("/usr/src/linux"):
                    self.cancel("kernel source missing after install")
                self.buldir = "/usr/src/linux"

        self.sourcedir = os.path.join(self.buldir, self.testdir)
        if build.make(self.sourcedir):
            self.fail("Compilation failed, Please check the build logs !!")
Esempio n. 18
0
    def setUp(self):
        """
        Resolve the packages dependencies and download the source.
        """
        smg = SoftwareManager()
        self.comp = self.params.get('comp', default='')
        run_type = self.params.get('type', default='upstream')
        if self.comp:
            self.comp = '-C %s' % self.comp
        detected_distro = distro.detect()
        deps = ['gcc', 'make', 'automake', 'autoconf']

        if 'Ubuntu' in detected_distro.name:
            deps.extend(['libpopt0', 'libc6', 'libc6-dev', 'libcap-dev',
                         'libpopt-dev', 'libcap-ng0', 'libcap-ng-dev',
                         'libnuma-dev', 'libfuse-dev', 'elfutils', 'libelf1'])
        elif 'SuSE' in detected_distro.name:
            deps.extend(['popt', 'glibc', 'glibc-devel', 'popt-devel', 'sudo',
                         'libcap2', 'libcap-devel', 'libcap-ng-devel',
                         'fuse', 'fuse-devel', 'glibc-devel-static'])
        # FIXME: "redhat" as the distro name for RHEL is deprecated
        # on Avocado versions >= 50.0.  This is a temporary compatibility
        # enabler for older runners, but should be removed soon
        elif detected_distro.name in ['centos', 'fedora', 'rhel', 'redhat']:
            deps.extend(['popt', 'glibc', 'glibc-devel', 'glibc-static',
                         'libcap-ng', 'libcap', 'libcap-devel', 'fuse-devel',
                         'libcap-ng-devel'])

        for package in deps:
            if not smg.check_installed(package) and not smg.install(package):
                self.cancel(
                    "Fail to install %s required for this test." % (package))

        if run_type == 'upstream':
            location = ["https://github.com/torvalds/linux/archive/master.zip"]
            tarball = self.fetch_asset("kselftest.zip", locations=location,
                                       expire='1d')
            archive.extract(tarball, self.workdir)
            self.buldir = os.path.join(self.workdir, 'linux-master')
        else:
            # Make sure kernel source repo is configured
            if detected_distro.name in ['centos', 'fedora', 'rhel']:
                self.buldir = smg.get_source('kernel', self.workdir)
                self.buldir = os.path.join(
                    self.buldir, os.listdir(self.buldir)[0])
            elif 'Ubuntu' in detected_distro.name:
                self.buldir = smg.get_source('linux', self.workdir)
            elif 'SuSE' in detected_distro.name:
                smg.get_source('kernel-source', self.workdir)
                packages = '/usr/src/packages/'
                os.chdir(os.path.join(packages, 'SOURCES'))
                process.system('./mkspec', ignore_status=True)
                shutil.copy(os.path.join(packages, 'SOURCES/kernel'
                                                   '-default.spec'),
                            os.path.join(packages, 'SPECS/kernel'
                                                   '-default.spec'))
                self.buldir = smg.prepare_source(os.path.join(
                    packages, 'SPECS/kernel'
                              '-default.spec'), dest_path=self.teststmpdir)
                for l_dir in glob.glob(os.path.join(self.buldir, 'linux*')):
                    if os.path.isdir(l_dir) and 'Makefile' in os.listdir(l_dir):
                        self.buldir = os.path.join(
                            self.buldir, os.listdir(self.buldir)[0])

        self.sourcedir = os.path.join(self.buldir, self.testdir)
        result = build.run_make(self.sourcedir)
        for line in str(result).splitlines():
            if 'ERROR' in line:
                self.fail("Compilation failed, Please check the build logs !!")
Esempio n. 19
0
    def setUp(self):
        """
        Install all the dependency packages required for building
        source tarball specific to os,if not tests will stop.
        """
        smm = SoftwareManager()
        dist = distro.detect()
        packages = ['gcc', 'dejagnu', 'flex', 'bison', 'sharutils']

        if dist.name in ['Ubuntu', 'debian']:
            packages.extend([
                'libmpfr-dev', 'libgmp-dev', 'libmpc-dev', 'zip', 'libc6-dev',
                'libelf1', 'elfutils', 'autogen'
            ])
            if dist.name == 'Ubuntu':
                packages.extend(['texinfo', 'gnat'])
        elif dist.name.lower() == 'suse':
            packages.extend([
                'glibc-devel-static', 'zlib-devel', 'elfutils', 'libelf-devel',
                'gcc-c++', 'isl-devel', 'gmp-devel', 'glibc-devel',
                'mpfr-devel', 'makeinfo', 'texinfo', 'mpc-devel'
            ])
            if (int(dist.version) == 15 and int(dist.release) > 3):
                packages.remove('isl-devel')
        else:
            packages.extend([
                'glibc-static', 'elfutils-devel', 'texinfo-tex', 'texinfo',
                'elfutils-libelf-devel', 'gmp-devel', 'mpfr-devel',
                'libmpc-devel', 'zlib-devel', 'gettext', 'libgcc', 'libgomp',
                'dblatex', 'doxygen', 'texlive-collection-latex',
                'python3-sphinx', 'systemtap-sdt-devel'
            ])
        if dist.name == 'rhel' and \
           (int(dist.version) == 8 and int(dist.release) >= 6):
            packages.extend([
                'autogen', 'guile', 'guile-devel', 'isl-devel',
                'docbook5-style-xsl'
            ])

        for package in packages:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel("Failed to install %s required for this test." %
                            package)
        run_type = self.params.get('type', default='distro')
        if run_type == "upstream":
            url = 'https://github.com/gcc-mirror/gcc/archive/master.zip'
            tarball = self.fetch_asset('gcc.zip', locations=[url], expire='7d')
            archive.extract(tarball, self.workdir)
            self.sourcedir = os.path.join(self.workdir, 'gcc-master')
        elif run_type == "distro":
            self.sourcedir = os.path.join(self.workdir, 'gcc-distro')
            if not os.path.exists(self.sourcedir):
                os.makedirs(self.sourcedir)
            """
            FIXME. On certain distros I have observed get_source()
            API fails to populate source tree. This can be an
            avocado utils issue. Explicitly fail this testcase
            until it has been root caused.
            """
            if (int(dist.version) == 15 and int(dist.release) > 3):
                self.fail('Test case is broken for this release')
            else:
                self.sourcedir = smm.get_source("gcc", self.sourcedir)
        os.chdir(self.sourcedir)
        process.run('./configure', ignore_status=True, sudo=True)
        build.make(self.sourcedir, ignore_status=True)
Esempio n. 20
0
class Binutils(Test):
    """
    This testcase make use of testsuite provided by the
    source package, performs functional test for all binary tools
    source file is downloaded and compiled.
    """

    def check_install(self, package):
        """
        Appends package to `self._needed_deps` when not able to install it
        """
        if (not self._sm.check_installed(package) and
                not self._sm.install(package)):
            self.cancel('Please install %s for the test to run' % self.package)

    def setUp(self):
        # Check for basic utilities
        self._sm = SoftwareManager()

        # Install required tools and resolve dependencies
        needed_deps = ['make', 'gcc', 'dejagnu',
                       'elfutils', 'autoconf', 'automake']
        dist = distro.detect()
        if dist.name.lower() == 'ubuntu':
            needed_deps.extend(['build-essential'])
        for pkg in needed_deps:
            self.check_install(pkg)
        run_type = self.params.get("type", default="upstream")
        # Extract - binutils
        # Source: https://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.bz2
        if run_type == "upstream":
            version = self.params.get('binutils_version', default='2.27')
            locations = [
                "https://www.mirrorservice.org/sites/sourceware.org"
                "/pub/binutils/releases/binutils-%s.tar.bz2" % version]
            tarball = self.fetch_asset("binutils-%s.tar.bz2" % version,
                                       locations=locations)
            archive.extract(tarball, self.workdir)
            self.sourcedir = os.path.join(
                self.workdir, os.path.basename(tarball.split('.tar.')[0]))
        elif run_type == "distro":
            self.sourcedir = os.path.join(self.workdir, "binutils-distro")
            if not os.path.exists(self.sourcedir):
                self.sourcedir = self._sm.get_source("binutils", self.sourcedir)

        # Compile the binutils
        os.chdir(self.sourcedir)
        process.run('./configure')
        build.make(self.sourcedir)

    def test(self):
        """
        Runs the binutils `make check`
        """
        ret = build.make(self.sourcedir, extra_args='check', ignore_status=True)

        errors = 0
        for root, _, filenames in os.walk(self.sourcedir):
            for filename in fnmatch.filter(filenames, '*.log'):
                filename = os.path.join(root, filename)
                logfile = filename[:-4] + ".log"
                shutil.copy(logfile, self.logdir)
                with open(logfile) as result:
                    for line in result.readlines():
                        if line.startswith('FAIL'):
                            errors += 1
                            self.log.error(line)
        if errors:
            self.fail("%s test(s) failed, check the log for details." % errors)
        elif ret:
            self.fail("'make check' finished with %s, but no FAIL lines were "
                      "found." % ret)