selftest: add more detailed log and fix a test failure issue

Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kairui Song 2020-11-18 17:15:37 +08:00
parent 13ac244630
commit 616d359c5e
2 changed files with 13 additions and 5 deletions

View File

@ -73,25 +73,33 @@ has_valid_vmcore_dir() {
local vmcore_dir=$path/$(ls -1 $path | tail -n 1)
local vmcore="<invalid>"
test_output "Found a vmcore dir \"$vmcore_dir\":"
# Checking with `crash` is slow and consume a lot of memory/disk,
# just do a sanity check by check if log are available.
if [ -e $vmcore_dir/vmcore ]; then
vmcore=$vmcore_dir/vmcore
makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1
makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || {
test_output "Failed to retrive dmesg from vmcore!"
return 1
}
elif [ -e $vmcore_dir/vmcore.flat ]; then
vmcore=$vmcore_dir/vmcore.flat
makedumpfile -R $vmcore_dir/vmcore < $vmcore || return 1
makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1
makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || {
test_output "Failed to retrive dmesg from vmcore!"
return 1
}
rm $vmcore_dir/vmcore
else
test_output "The vmcore dir is empty!"
return 1
fi
if diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then
if ! diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then
test_output "Dmesg retrived from vmcore is different from dump version!"
return 1
fi
test_output "Found a valid vmcore in \"$vmcore_dir\""
test_output "VMCORE: $vmcore"
test_output "KERNEL VERSION: $(rpm -q kernel-core)"

View File

@ -22,7 +22,7 @@ EOF
if has_valid_vmcore_dir /var/crash; then
test_passed
else
test_failed
test_failed "Vmcore missing"
fi
shutdown -h 0