-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rh_kselftests_vm: kernel selftests execution in guest
Creates a new test case that executes the kernel selftests inside the VM through the RPM that has been previously downloaded and installed. Could be expanded with more tests in the future. Signed-off-by: mcasquer <[email protected]>
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- rh_kselftests_vm: | ||
only RHEL | ||
type = rh_kselftests_vm | ||
virt_test_type = qemu | ||
kernel_path = "/tmp/kernel" | ||
kselftests_path = "/usr/libexec/kselftests" | ||
variants: | ||
- mm: | ||
s390x: | ||
kvm_module_parameters = 'hpage=1' | ||
setup_hugepages = yes | ||
tests_execution_cmd = "cd ${kselftests_path}/mm && sh run_vmtests.sh -t hugetlb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from avocado.core import exceptions | ||
|
||
from virttest import error_context | ||
|
||
|
||
@error_context.context_aware | ||
def run(test, params, env): | ||
""" | ||
rh_kselftests_vm test | ||
1) Download the current kernel selftests RPM | ||
2) Install the RPM | ||
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", "/tmp/kernel") | ||
tests_execution_cmd = params.get("tests_execution_cmd") | ||
|
||
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-*") | ||
|
||
error_context.base_context("Execute the selftests", test.log.info) | ||
s, o = session.cmd_status_output(tests_execution_cmd, 180) | ||
|
||
# Exit code for skipped selftests is 4, raise a warning until is fixed | ||
if s == 4: | ||
raise exceptions.TestWarn("Some selftest(s) have been skipped") | ||
elif s != 0: | ||
test.fail("Error during selftests execution: %s" % o) | ||
|
||
test.log.info("The selftests results: %s" % o) | ||
error_context.context("Cleaning kernel files", test.log.debug) | ||
session.cmd("rm -rf %s" % kernel_path) |