|
Petr Šabata |
f5bf49 |
#!/usr/bin/env sh
|
|
Petr Šabata |
f5bf49 |
BOOT_ARG="test_boot_count"
|
|
Petr Šabata |
f5bf49 |
_YELLOW='\033[1;33m'
|
|
Petr Šabata |
f5bf49 |
_GREEN='\033[0;32m'
|
|
Petr Šabata |
f5bf49 |
_RED='\033[0;31m'
|
|
Petr Šabata |
f5bf49 |
_NC='\033[0m' # No Color
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ -n "$(cat /proc/cmdline | grep "\bno_test\b")" ]; then
|
|
Petr Šabata |
f5bf49 |
exit 0
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
get_test_boot_count() {
|
|
Petr Šabata |
f5bf49 |
local boot_count=$(cat /proc/cmdline | sed -n "s/.*$BOOT_ARG=\([0-9]*\).*/\1/p")
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ -z "$boot_count" ]; then
|
|
Petr Šabata |
f5bf49 |
boot_count=1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $boot_count
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_output() {
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
sync
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_passed() {
|
|
Petr Šabata |
f5bf49 |
echo -e "${_GREEN}TEST PASSED${_NC}" > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo -e "${_GREEN}kexec-kdump-test: TEST PASSED${_NC}" > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
sync
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
shutdown -h 0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
exit 0
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_failed() {
|
|
Petr Šabata |
f5bf49 |
echo -e "${_RED}TEST FAILED${_NC}" > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo -e "${_RED}kexec-kdump-test: TEST FAILED${_NC}" > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
sync
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
shutdown -h 0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
exit 1
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_abort() {
|
|
Petr Šabata |
f5bf49 |
echo -e "${_YELLOW}TEST ABORTED${_NC}" > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo -e "${_YELLOW}kexec-kdump-test: TEST ABORTED${_NC}" > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS1
|
|
Petr Šabata |
f5bf49 |
echo $@ > /dev/ttyS0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
sync
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
shutdown -h 0
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
exit 2
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
has_valid_vmcore_dir() {
|
|
Petr Šabata |
f5bf49 |
local path=$1
|
|
Petr Šabata |
f5bf49 |
local vmcore_dir=$path/$(ls -1 $path | tail -n 1)
|
|
Petr Šabata |
f5bf49 |
local vmcore="<invalid>"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Checking with `crash` is slow and consume a lot of memory/disk,
|
|
Petr Šabata |
f5bf49 |
# just do a sanity check by check if log are available.
|
|
Petr Šabata |
f5bf49 |
if [ -e $vmcore_dir/vmcore ]; then
|
|
Petr Šabata |
f5bf49 |
vmcore=$vmcore_dir/vmcore
|
|
Petr Šabata |
f5bf49 |
makedumpfile --dump-dmesg $vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1
|
|
Petr Šabata |
f5bf49 |
elif [ -e $vmcore_dir/vmcore.flat ]; then
|
|
Petr Šabata |
f5bf49 |
vmcore=$vmcore_dir/vmcore.flat
|
|
Petr Šabata |
f5bf49 |
makedumpfile -R $vmcore_dir/vmcore < $vmcore || return 1
|
|
Petr Šabata |
f5bf49 |
makedumpfile --dump-dmesg $vmcore_dir/vmcore $vmcore_dir/vmcore-dmesg.txt.2 || return 1
|
|
Petr Šabata |
f5bf49 |
rm $vmcore_dir/vmcore
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if diff $vmcore_dir/vmcore-dmesg.txt.2 $vmcore_dir/vmcore-dmesg.txt; then
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_output "Found a valid vmcore in \"$vmcore_dir\""
|
|
Petr Šabata |
f5bf49 |
test_output "VMCORE: $vmcore"
|
|
Petr Šabata |
f5bf49 |
test_output "KERNEL VERSION: $(rpm -q kernel-core)"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
return 0
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
BOOT_COUNT=$(get_test_boot_count)
|
|
Petr Šabata |
f5bf49 |
test_output "Kexec-Kdump-Test Boot #$BOOT_COUNT"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo 'fedora' | passwd --stdin root
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_output "Updating kernel cmdline"
|
|
Petr Šabata |
f5bf49 |
grubby --update-kernel ALL --args $BOOT_ARG=$(expr $BOOT_COUNT + 1) && sync
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_output "Executing test hook"
|
|
Petr Šabata |
f5bf49 |
source /kexec-kdump-test/test.sh
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
on_test;
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
test_output "Test exited, system hang for inspect"
|