-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rh_kselftests_vm: kernel selftests execution in guest #4114
rh_kselftests_vm: kernel selftests execution in guest #4114
Conversation
f024df5
to
fb7b441
Compare
|
@zhenyzha @MiriamDeng @fbq815 @zhencliu @YongxueHong please could you review this PR? Thanks ! |
@zhenyzha @MiriamDeng @fbq815 @zhencliu @YongxueHong this is a kindly reminder, please could you review this PR? Thanks ! |
@mcasquer Could you provide the test results of rhel.10? I have not been able to compile successfully on 10 recently. |
Indeed, good catch ! |
4aeb981
to
f76de3b
Compare
f76de3b
to
370b56e
Compare
Hi @mcasquer , I have a quick look with the kernel CKI testing for the mm part, any code change with the following trigger source will trigger the test automatically,
hugetlb was covered with: I would like to double confirm does this meet your requirements, or it is must to check it in a qemu-kvm based VM os which is the purpose of this patch ? |
@yanan-fu the idea is to execute those tests inside a VM backed by hugepages, my understanding is the kernel team is not covering this scenario so that's why we need the test case |
370b56e
to
061d464
Compare
Hi @mcasquer , I am curious do we need to cover different page size? Or the page size is a part of test matrix? |
@zhencliu not really, at least for x86_64 the 2MB hugepages are fine |
edc0751
to
68c1f57
Compare
@YongxueHong @zhencliu could you review again this PR? Thanks! |
9d7799f
to
083e5ca
Compare
083e5ca
to
20a4555
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the test result above, LGTM
ac5e452
to
7906012
Compare
qemu/tests/rh_kselftests_vm.py
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be in the finally
section of the try
block, which means even if the test case fails or not, we should clean the downloaded rpm(and also uninstall it?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use clone_master = yes
to skip the cleanup step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulYuuu done !
I just saw the version now. Is there any blocker to give up it now ? Just some code structure change. |
qemu/tests/rh_kselftests_vm.py
Outdated
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think it is a issue need be fixed in kernel selftests, but it is intentional.
From my checking with the source code, if there is a skip case after a fail case, the return value is 4. It is wrong(Not the scope of this PR but the kselftest).
Suggest to use whitelist for the know test can be skipped, and parse the output of the test to make a final decision of the test case result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfu but then how will the user know that there are skipped tests? If we set the skipped as passed it's possible the user won't be aware, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are talking about exitcode in this thread.
run_test() {
if test_selected ${CATEGORY}; then
# On memory constrainted systems some tests can fail to allocate hugepages.
# perform some cleanup before the test for a higher success rate.
if [ ${CATEGORY} == "thp" ] | [ ${CATEGORY} == "hugetlb" ]; then
echo 3 > /proc/sys/vm/drop_caches
sleep 2
echo 1 > /proc/sys/vm/compact_memory
sleep 2
fi
local test=$(pretty_name "$*")
local title="running $*"
local sep=$(echo -n "$title" | tr "[:graph:][:space:]" -)
printf "%s\n%s\n%s\n" "$sep" "$title" "$sep" | tap_prefix
("$@" 2>&1) | tap_prefix
local ret=${PIPESTATUS[0]}
count_total=$(( count_total + 1 ))
if [ $ret -eq 0 ]; then
count_pass=$(( count_pass + 1 ))
echo "[PASS]" | tap_prefix
echo "ok ${count_total} ${test}" | tap_output
elif [ $ret -eq $ksft_skip ]; then
count_skip=$(( count_skip + 1 ))
echo "[SKIP]" | tap_prefix
echo "ok ${count_total} ${test} # SKIP" | tap_output
exitcode=$ksft_skip
else
count_fail=$(( count_fail + 1 ))
echo "[FAIL]" | tap_prefix
echo "not ok ${count_total} ${test} # exit=$ret" | tap_output
exitcode=1
fi
fi # test_selected
}
In the loop,
1: PASS | 1: SKIP | 1: FAIL | |
---|---|---|---|
2: PASS | 0 | 4 | 1 |
2: SKIP | 4 | 4 | 4 |
2: FAIL | 1 | 1 | 1 |
Scenarios that we need to agree on are SKIP --> FAIL(exit 1)
and FAIL --> SKIP(exit 4)
. I think FAIL --> SKIP(exit 4)
must return 1 but this needs to be changed at Linux source code, for now, I don't think we have good solution to handle it. A workaround is to check the output and collect count of [PASS]
[SKIP]
[FAIL]
rather than check the exit code. Keep if s == 4:
in this version is in order to safely raise a warning if we will have new test cases for mm in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfu but then how will the user know that there are skipped tests? If we set the skipped as passed it's possible the user won't be aware, right?
Any skip but case not in whitelist should fail this auto case. Checking the output is needed.
- Use exitcode is incorrect if there are skip case but after a fail one
- If the skip case is in whitelist, i prefer to mark test case status to PASS instead of WARN as it is a known issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the whitelist approach
hi @yanan-fu , time is limited, as we talked before, tests_execution_cmd is OK for the current testing, and we may have to enhance it when we need to do some pre-test work or the execution is different from mm test, so what about keeping the current code, and make the change once we have to |
okay, then let's focus on the result parser now, cc @mcasquer |
7906012
to
c399ddc
Compare
Results in x86_64
Results in s390x (now marked as passed)
|
qemu/tests/cfg/rh_kselftests_vm.cfg
Outdated
kvm_module_parameters = 'hpage=1' | ||
setup_hugepages = yes | ||
tests_execution_cmd = "cd ${kselftests_path}/mm && sh run_vmtests.sh -t hugetlb" | ||
whitelist = "hugetlb_fault_after_madv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move into s390x:
as skip this case for s390x only if i remember it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done !
qemu/tests/rh_kselftests_vm.py
Outdated
session = vm.wait_for_login() | ||
kernel_path = params.get("kernel_path", "/tmp/kernel") | ||
tests_execution_cmd = params.get("tests_execution_cmd") | ||
whitelist = params.get("whitelist").split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align with the comment above, now, only s390x have the known skip case, so:
whitelist = params.get("whitelist", "").split()
or whitelist = params.objects("whitelist")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done !
qemu/tests/rh_kselftests_vm.py
Outdated
skipped_tests = True if "[SKIP]" in o else False | ||
test.log.debug("Skipped tests: %r" % skipped_tests) | ||
for test_name in whitelist: | ||
if skipped_tests and test_name in o: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_name is always in the o
, no matter the status is pass, skip or fail.
You need to parser the output and get the skiped case name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done !
cc64e54
to
b851155
Compare
Results in x86_64
Results in s390x
|
qemu/tests/rh_kselftests_vm.py
Outdated
if len(skipped_list) == num_skipped_tests: | ||
return True | ||
elif len(skipped_list) < num_skipped_tests: | ||
raise exceptions.TestWarn("Some skipped test(s) are not in the whitelist") | ||
if s != 0: | ||
test.fail("Error during selftests execution: %s" % o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM, except here.
If we have 3 test cases, 1 PASS 1 SKIP 1 FAIL
, the skip one is on the whitelist, the current logic still returns True, but PASS + SKIP != 3
.
I think the summary like SUMMARY: PASS=9 SKIP=1 FAIL=0
can help to detect how to handle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulYuuu
Updated, failed cases are considered first, then skipped so nothing should be missed now
b851155
to
ae60572
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yanan-fu I am okay with this version, how about you?
qemu/tests/rh_kselftests_vm.py
Outdated
test.log.info("The selftests results: %s" % o) | ||
|
||
summary = re.findall(r"\# SUMMARY.+", o) | ||
num_failed_tests = int(re.findall(r"FAIL\=\d", str(summary))[0].split('=')[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num_failed_tests = int(re.findall(r"FAIL\=\d", str(summary))[0].split('=')[1]) | |
num_failed_tests = int(re.findall(r"FAIL\=\d+", str(summary))[0].split('=')[1]) |
To assume count may more than 10, same for skipped test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
qemu/tests/rh_kselftests_vm.py
Outdated
test.log.debug("Number of failed tests: %d" % num_failed_tests) | ||
|
||
if num_failed_tests != 0: | ||
test.fail("Error during selftests execution: %s" % o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already log output above, let's simplify the error message, the current one is too long for the test status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
qemu/tests/rh_kselftests_vm.py
Outdated
|
||
summary = re.findall(r"\# SUMMARY.+", o) | ||
num_failed_tests = int(re.findall(r"FAIL\=\d", str(summary))[0].split('=')[1]) | ||
test.log.debug("Number of failed tests: %d" % num_failed_tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test.log.debug("Number of failed tests: %d" % num_failed_tests) | |
test.log.debug("Number of failed tests: %d", num_failed_tests) |
A bit suggestion, logging module will help to format it with this during call, can refer to the logging doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
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]>
ae60572
to
981ba5d
Compare
Results in x86_64
Results in s390x
|
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]
ID: 2637