From 20a4555d66949a37247da278357464a9d8314ee2 Mon Sep 17 00:00:00 2001 From: mcasquer Date: Tue, 23 Jul 2024 09:36:43 +0200 Subject: [PATCH] vm_hugetlb_selftests: hugetlb kernel selftests execution in guest Creates a new test case that executes the hugetlb selftests from the kernel selftests package that has been previously downloaded and extracted, to ensure the correct behavior of this feature at the VM level. Signed-off-by: mcasquer --- qemu/tests/cfg/vm_hugetlb_selftests.cfg | 8 +++++ qemu/tests/vm_hugetlb_selftests.py | 44 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 qemu/tests/cfg/vm_hugetlb_selftests.cfg create mode 100644 qemu/tests/vm_hugetlb_selftests.py diff --git a/qemu/tests/cfg/vm_hugetlb_selftests.cfg b/qemu/tests/cfg/vm_hugetlb_selftests.cfg new file mode 100644 index 0000000000..0164005fc2 --- /dev/null +++ b/qemu/tests/cfg/vm_hugetlb_selftests.cfg @@ -0,0 +1,8 @@ +- vm_hugetlb_selftests: + only Linux + only x86_64 + type = vm_hugetlb_selftests + virt_test_type = qemu + setup_hugepages = yes + kernel_path = "/home/kernel" + depends_pkgs = rsync libcap-devel numactl-devel glibc-devel diff --git a/qemu/tests/vm_hugetlb_selftests.py b/qemu/tests/vm_hugetlb_selftests.py new file mode 100644 index 0000000000..515ae6a431 --- /dev/null +++ b/qemu/tests/vm_hugetlb_selftests.py @@ -0,0 +1,44 @@ +from virttest import error_context +from virttest import utils_package + + +@error_context.context_aware +def run(test, params, env): + """ + vm_hugetlb_selftests test + 1) Download the current kernel selftests RPM + 2) Extract the RPM files + 3) Execute the hugetlb 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.objects("depends_pkgs") + 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") + error_context.base_context("The kernel version: %s" % kernel_version, test.log.info) + + error_context.context("Download the kernel source 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("Extract the RPM files", test.log.debug) + session.cmd("rpm2cpio kernel-*.rpm | cpio -div") + session.cmd("cd usr/libexec/kselftests/mm") + + error_context.base_context("Execute the hugetlb selftests", test.log.info) + s, o = session.cmd_status_output("sh run_vmtests.sh -t hugetlb", 180) + if s != 0: + test.fail("Error during hugetlb selftests execution: %s" % o) + + error_context.context("The hugeltb tests results: %s" % o, test.log.debug)