From patchwork Thu Jan 28 19:29:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 75608 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o0SJTFVS024017 for ; Thu, 28 Jan 2010 19:29:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753807Ab0A1T3L (ORCPT ); Thu, 28 Jan 2010 14:29:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753641Ab0A1T3L (ORCPT ); Thu, 28 Jan 2010 14:29:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23698 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240Ab0A1T3K (ORCPT ); Thu, 28 Jan 2010 14:29:10 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0SJT6vf029573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Jan 2010 14:29:09 -0500 Received: from localhost.localdomain (vpn-8-85.rdu.redhat.com [10.11.8.85]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0SJT3Ni030083; Thu, 28 Jan 2010 14:29:04 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Improvements and cleanups to build subtest Date: Thu, 28 Jan 2010 17:29:01 -0200 Message-Id: <1264706941-7502-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 28 Jan 2010 19:29:15 +0000 (UTC) diff --git a/client/tests/kvm/tests/build.py b/client/tests/kvm/tests/build.py index f5f67ad..2e05a56 100644 --- a/client/tests/kvm/tests/build.py +++ b/client/tests/kvm/tests/build.py @@ -181,7 +181,7 @@ class KojiInstaller: logging.info("Both tag and build parameters provided, ignoring tag " "parameter...") if self.tag and not self.build: - self.build = self.__get_build() + self.build = self._get_build() if not self.tag and not self.build: raise error.TestError("Koji install selected but neither koji_tag " "nor koji_build parameters provided. Please " @@ -201,7 +201,7 @@ class KojiInstaller: self.test_bindir = test.bindir - def __get_build(self): + def _get_build(self): """ Get the source package build name, according to the appropriate tag. """ @@ -212,10 +212,14 @@ class KojiInstaller: for line in latest_raw: if line.startswith(self.src_pkg): build_name = line.split()[0] + + if not build_name: + raise error.TestError("There are no packages built for tag: %s" % + self.tag) return build_name - def __clean_previous_installs(self): + def _clean_previous_installs(self): """ Remove all rpms previously installed. """ @@ -227,7 +231,7 @@ class KojiInstaller: utils.system("yum remove -y %s" % removable_packages) - def __get_packages(self): + def _get_packages(self): """ Downloads the entire build for the specific build name. It's inefficient, but it saves the need of having an NFS share set. @@ -241,7 +245,7 @@ class KojiInstaller: utils.system(download_cmd) - def __install_packages(self): + def _install_packages(self): """ Install all relevant packages from the build that was just downloaded. """ @@ -261,7 +265,7 @@ class KojiInstaller: utils.system("yum install --nogpgcheck -y %s" % installable_packages) - def __check_installed_binaries(self): + def _check_installed_binaries(self): """ Make sure the relevant binaries installed actually come from the build that was installed. @@ -278,10 +282,10 @@ class KojiInstaller: def install(self): - self.__clean_previous_installs() - self.__get_packages() - self.__install_packages() - self.__check_installed_binaries() + self._clean_previous_installs() + self._get_packages() + self._install_packages() + self._check_installed_binaries() create_symlinks(test_bindir=self.test_bindir, bin_list=self.qemu_bin_paths) if self.load_modules: @@ -375,7 +379,7 @@ class SourceDirInstaller: self.configure_options = check_configure_options(configure_script) - def __build(self): + def _build(self): make_jobs = utils.count_cpus() os.chdir(self.srcdir) # For testing purposes, it's better to build qemu binaries with @@ -389,7 +393,7 @@ class SourceDirInstaller: utils.system(step) - def __install(self): + def _install(self): os.chdir(self.srcdir) logging.info("Installing KVM userspace") if self.repo_type == 1: @@ -399,16 +403,16 @@ class SourceDirInstaller: create_symlinks(self.test_bindir, self.prefix) - def __load_modules(self): + def _load_modules(self): load_kvm_modules(module_dir=self.srcdir, extra_modules=self.extra_modules) def install(self): - self.__build() - self.__install() + self._build() + self._install() if self.load_modules: - self.__load_modules() + self._load_modules() class GitInstaller: @@ -462,25 +466,24 @@ class GitInstaller: user_tag = params.get("user_tag", "HEAD") kmod_tag = params.get("kmod_tag", "HEAD") - if not kernel_repo: - message = "KVM git repository path not specified" - logging.error(message) - raise error.TestError(message) if not user_repo: message = "KVM user git repository path not specified" logging.error(message) raise error.TestError(message) - kernel_srcdir = os.path.join(srcdir, "kvm") - kvm_utils.get_git_branch(kernel_repo, kernel_branch, kernel_srcdir, - kernel_tag, kernel_lbranch) - self.kernel_srcdir = kernel_srcdir - userspace_srcdir = os.path.join(srcdir, "kvm_userspace") kvm_utils.get_git_branch(user_repo, user_branch, userspace_srcdir, user_tag, user_lbranch) self.userspace_srcdir = userspace_srcdir + if kernel_repo: + kernel_srcdir = os.path.join(srcdir, "kvm") + kvm_utils.get_git_branch(kernel_repo, kernel_branch, kernel_srcdir, + kernel_tag, kernel_lbranch) + self.kernel_srcdir = kernel_srcdir + else: + self.kernel_srcdir = None + if kmod_repo: kmod_srcdir = os.path.join (srcdir, "kvm_kmod") kvm_utils.get_git_branch(kmod_repo, kmod_branch, kmod_srcdir, @@ -493,69 +496,71 @@ class GitInstaller: self.configure_options = check_configure_options(configure_script) - def __build(self): - # Number of concurrent build tasks + def _build(self): make_jobs = utils.count_cpus() + cfg = './configure' + self.modules_build_succeed = False if self.kmod_srcdir: logging.info('Building KVM modules') os.chdir(self.kmod_srcdir) - utils.system('./configure') - utils.system('make clean') - utils.system('make sync LINUX=%s' % self.kernel_srcdir) - utils.system('make -j %s' % make_jobs) - - logging.info('Building KVM userspace code') - os.chdir(self.userspace_srcdir) - cfg = './configure --prefix=%s' % self.prefix - if "--disable-strip" in self.configure_options: - cfg += ' --disable-strip' - if self.extra_configure_options: - cfg = ' %s' % self.extra_configure_options - utils.system(cfg) - utils.system('make clean') - utils.system('make -j %s' % make_jobs) - else: + module_build_steps = [cfg, + 'make clean', + 'make sync LINUX=%s' % self.kernel_srcdir, + 'make'] + elif self.kernel_srcdir: logging.info('Building KVM modules') os.chdir(self.userspace_srcdir) - cfg = './configure --kerneldir=%s' % self.host_kernel_srcdir - utils.system(cfg) - utils.system('make clean') - utils.system('make -j %s -C kernel LINUX=%s sync' % - (make_jobs, self.kernel_srcdir)) - - logging.info('Building KVM userspace code') - # This build method (no kvm-kmod) requires that we execute - # configure again, but now let's use the full command line. - cfg += ' --prefix=%s' % self.prefix - if "--disable-strip" in self.configure_options: - cfg += ' --disable-strip' - if self.extra_configure_options: - cfg += ' %s' % self.extra_configure_options - steps = [cfg, 'make -j %s' % make_jobs] - for step in steps: - utils.system(step) - - - def __install(self): + cfg += ' --kerneldir=%s' % self.host_kernel_srcdir + module_build_steps = [cfg, + 'make clean', + 'make -C kernel LINUX=%s sync' % self.kernel_srcdir] + else: + module_build_steps = [] + + try: + if module_build_steps: + for step in module_build_steps: + utils.run(step) + self.modules_build_succeed = True + except error.CmdError, e: + logging.error("KVM modules build failed to build: %s" % e) + + logging.info('Building KVM userspace code') + os.chdir(self.userspace_srcdir) + cfg += ' --prefix=%s' % self.prefix + if "--disable-strip" in self.configure_options: + cfg += ' --disable-strip' + if self.extra_configure_options: + cfg += ' %s' % self.extra_configure_options + utils.system(cfg) + utils.system('make clean') + utils.system('make -j %s' % make_jobs) + + + def _install(self): os.chdir(self.userspace_srcdir) utils.system('make install') create_symlinks(self.test_bindir, self.prefix) - def __load_modules(self): - if self.kmod_srcdir: + def _load_modules(self): + if self.kmod_srcdir and self.modules_build_succeed: load_kvm_modules(module_dir=self.kmod_srcdir, extra_modules=self.extra_modules) - else: + elif self.kernel_srcdir and self.modules_build_succeed: load_kvm_modules(module_dir=self.userspace_srcdir, extra_modules=self.extra_modules) + else: + logging.info("Loading stock KVM modules") + load_kvm_modules(load_stock=True, + extra_modules=self.extra_modules) def install(self): - self.__build() - self.__install() + self._build() + self._install() if self.load_modules: - self.__load_modules() + self._load_modules() def run_build(test, params, env):