Use the autotest step engine to conveniently install a host kernel, be it an rpm kernel or a git build. Even though this is standard autotest functionality for quite a while, we haven't integrated it properly so far. Now people testing KVM will have a clean, programatic way to test host kernels. Want to install the kernel from an rpm? Just put it on the control file something like: host_kernel_install = 'rpm' host_kernel_rpm_url = 'http://kojipkgs.fedoraproject.org/packages/kernel/2.6.36/0.32.rc6.git2.fc15/x86_64/kernel-2.6.36-0.32.rc6.git2.fc15.x86_64.rpm' Want to install the kernel from kvm.git, master branch? Just put it on the control file: host_kernel_git_repo = 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git' host_kernel_git_branch = 'master' host_kernel_config = 'http://your-server.com/config' You can also specify commits and a list of patches to apply in the kernel before it is built. This change moves the bulk of the KVM test code to a function step_test, and the host kernel install is the implementation of the function step_init(). The interesting variables for the user are defined right at the top of the control file, and, by default no attempt to build/install the host kernel will be made. Changes from v1: - Now that some autotest bugs were worked up (patchset pending review and apply), this patch was remastered and the method job.bootloader.boot_once() was replaced with testkernel.boot(), which works now. Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx> --- client/tests/kvm/control | 88 +++++++++++++++++++++++++++++++++------------ 1 files changed, 64 insertions(+), 24 deletions(-) diff --git a/client/tests/kvm/control b/client/tests/kvm/control index 63bbe5d..b9e2646 100644 --- a/client/tests/kvm/control +++ b/client/tests/kvm/control @@ -21,43 +21,83 @@ For online docs, please refer to http://www.linux-kvm.org/page/KVM-Autotest """ import sys, os, logging +# set English environment (command output might be localized, need to be safe) +os.environ['LANG'] = 'en_US.UTF-8' # Add the KVM tests dir to the python path kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') sys.path.append(kvm_test_dir) # Now we can import modules inside the KVM tests dir import kvm_utils, kvm_config -# set English environment (command output might be localized, need to be safe) -os.environ['LANG'] = 'en_US.UTF-8' +# Choose the host kernel install mode 'rpm' or 'git' +# If you don't want to install a kernel, keep the below 'default' +host_kernel_install = 'default' +# URL for the kernel package +host_kernel_rpm_url = 'http://kojipkgs.fedoraproject.org/packages/kernel/2.6.36/0.32.rc6.git2.fc15/x86_64/kernel-2.6.36-0.32.rc6.git2.fc15.x86_64.rpm' +# Git repo URL and other git repo relevant data +host_kernel_git_repo = 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git' +host_kernel_git_branch = 'master' +host_kernel_git_commit = '' +# If you want to apply patches to your tree, make sure you populate the list +# below with the urls of the patches. +host_kernel_patch_list = [] +# URL for the kernel config file (git build method) +host_kernel_config = 'http://your-server.com/config' + + +def step_init(): + job.next_step([step_test]) + if host_kernel_install == 'rpm': + logging.info('Chose to install host kernel through rpm, proceeding') + dst = os.path.join("/tmp", os.path.basename(host_kernel_rpm_url)) + k = utils.get_file(host_kernel_rpm_url, dst) + host_kernel = job.kernel(k) + host_kernel.install(install_vmlinux=False) + host_kernel.boot() + elif host_kernel_install == 'git': + logging.info('Chose to install host kernel through git, proceeding') + repodir = os.path.join("/tmp", 'kernel_src') + r = kvm_utils.get_git_branch(host_kernel_git_repo, + host_kernel_git_branch, + repodir, + host_kernel_git_commit) + host_kernel = job.kernel(r) + if host_kernel_patch_list: + host_kernel.patch(host_kernel_patch_list) + host_kernel.config(host_kernel_config) + host_kernel.build() + host_kernel.install() + host_kernel.boot() + else: + logging.info('Chose %s, using the current kernel for the host', + host_kernel_install) -str = """ + +def step_test(): + str = """ # This string will be parsed after build.cfg. Make any desired changes to the # build configuration here. For example: #release_tag = 84 -""" -build_cfg = kvm_config.config() -# As the base test config is quite large, in order to save memory, we use the -# fork_and_parse() method, that creates another parser process and destroys it -# at the end of the parsing, so the memory spent can be given back to the OS. -build_cfg_path = os.path.join(kvm_test_dir, "build.cfg") -build_cfg.fork_and_parse(build_cfg_path, str) -if not kvm_utils.run_tests(build_cfg.get_generator(), job): - logging.error("KVM build step failed, exiting.") - sys.exit(1) - -str = """ + """ + build_cfg = kvm_config.config() + build_cfg_path = os.path.join(kvm_test_dir, "build.cfg") + build_cfg.fork_and_parse(build_cfg_path, str) + if not kvm_utils.run_tests(build_cfg.get_generator(), job): + logging.error("KVM build step failed, exiting.") + sys.exit(1) + + str = """ # This string will be parsed after tests.cfg. Make any desired changes to the # test configuration here. For example: #display = sdl #install|setup: timeout_multiplier = 3 -""" -tests_cfg = kvm_config.config() -tests_cfg_path = os.path.join(kvm_test_dir, "tests.cfg") -tests_cfg.fork_and_parse(tests_cfg_path, str) - -# Run the tests -kvm_utils.run_tests(tests_cfg.get_generator(), job) + """ + tests_cfg = kvm_config.config() + tests_cfg_path = os.path.join(kvm_test_dir, "tests.cfg") + tests_cfg.fork_and_parse(tests_cfg_path, str) -# Generate a nice HTML report inside the job's results dir -kvm_utils.create_report(kvm_test_dir, job.resultdir) + # Run the tests + kvm_utils.run_tests(tests_cfg.get_generator(), job) + # Generate a nice HTML report inside the job's results dir + kvm_utils.create_report(kvm_test_dir, job.resultdir) -- 1.7.2.3 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html