diff --git a/qemu/tests/cfg/rh_kselftests_vm.cfg b/qemu/tests/cfg/rh_kselftests_vm.cfg new file mode 100644 index 0000000000..ff5ffc7741 --- /dev/null +++ b/qemu/tests/cfg/rh_kselftests_vm.cfg @@ -0,0 +1,11 @@ +- rh_kselftests_vm: + only RHEL + type = rh_kselftests_vm + virt_test_type = qemu + kernel_path = "/home/kernel" + variants: + - mm: + no s390x + setup_hugepages = yes + depends_pkgs = rsync libcap-devel numactl-devel glibc-devel + tests_execution_cmd = "cd mm && sh run_vmtests.sh -t hugetlb" diff --git a/qemu/tests/rh_kselftests_vm.py b/qemu/tests/rh_kselftests_vm.py new file mode 100644 index 0000000000..7db4bef4a5 --- /dev/null +++ b/qemu/tests/rh_kselftests_vm.py @@ -0,0 +1,45 @@ +from virttest import error_context +from virttest import utils_package + + +@error_context.context_aware +def run(test, params, env): + """ + rh_kselftests_vm test + 1) Download the current kernel selftests RPM + 2) Extract the RPM files + 3) Execute the kernel selftests + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment + """ + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + session = vm.wait_for_login() + kernel_path = params.get("kernel_path", "/home/kernel") + pkgs = params.get("depends_pkgs").split() + tests_execution_cmd = params.get("tests_execution_cmd") + if not utils_package.package_install(pkgs, session): + test.cancel("Install dependency packages failed") + + session.cmd("mkdir -p %s" % kernel_path) + kernel_version = session.cmd_output("uname -r").strip().split("+")[0] + error_context.base_context("The kernel version: %s" % kernel_version, test.log.info) + + error_context.context("Download the kernel selftests RPM", test.log.debug) + session.cmd("cd %s" % kernel_path) + session.cmd( + "brew download-build --rpm kernel-selftests-internal-%s.rpm" % kernel_version, + 180, + ) + + error_context.context("Install the RPM", test.log.debug) + session.cmd("dnf install -y ./kernel-*") + session.cmd("cd /usr/libexec/kselftests") + + error_context.base_context("Execute the selftests", test.log.info) + s, o = session.cmd_status_output(tests_execution_cmd, 180) + if s != 0: + test.fail("Error during selftests execution: %s" % o) + + test.log.info("The selftests results: %s" % o)