selftests: pstore: skip when no backend is registered
PATCH 1/2 selftests: pstore: skip when no backend is registered
An unregistered pstore backend reads back "(null)", and every later check fails. This also contradicts the pstore_crash_test documentation.
pstore_crash_test has carried the comment
# exit if pstore backend is not registered
Fix by skipping an unregistered backend in common_tests.
Signed-off-by Eva Kurchatova <[email protected]>
--- tools/testing/selftests/pstore/common_tests | 17 ++++++++++++----- .../selftests/pstore/pstore_post_reboot_tests | 3 --- 2 files changed, 12 insertions(+), 8 deletions(-)
tools/testing/selftests/pstore/common_tests +12 -5
@@ -55,6 +55,8 @@ operate_files() { # tested value, files, operation # Parameters TEST_STRING_PATTERN="Testing pstore: uuid=" +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 UUID=`cat /proc/sys/kernel/random/uuid` TOP_DIR=`absdir $0` LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`_${UUID}/
@@ -74,10 +76,15 @@ prlog "=== Pstore unit tests (`basename $0`) ===" prlog "UUID="$UUID prlog -n "Checking pstore backend is registered ... " -backend=`cat /sys/module/pstore/parameters/backend` -show_result $? +# No file at all where pstore is not loaded, "(null)" where none registered +backend=`cat /sys/module/pstore/parameters/backend 2>/dev/null` +if [ -z "$backend" ] || [ "$backend" = "(null)" ]; then + prlog "SKIP" + prlog -e "\tbackend=${backend:-<none>}" + prlog -e "\tcmdline=`cat /proc/cmdline`" + prlog "pstore backend is not registered, skipping" + exit $ksft_skip +fi +prlog "ok" prlog -e "\tbackend=${backend}" prlog -e "\tcmdline=`cat /proc/cmdline`" -if [ $rc -ne 0 ]; then - exit 1 -fi
tools/testing/selftests/pstore/pstore_post_reboot_tests +0 -3
@@ -7,9 +7,6 @@ # Written by Hiraku Toyooka <[email protected]> # -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 - . ./common_tests if [ -e $REBOOT_FLAG ]; then
Signature · 1 line
2.55.0
PATCH 2/2 selftests: pstore: skip the frontends the kernel does not have
The console and pmsg frontends are separate options from the backend:CONFIG_PSTORE_CONSOLE and CONFIG_PSTORE_PMSG can both be off on a kernel that registers one. pstore_tests checks for both regardless and fails where they are absent.
Report them as skips instead.
Signed-off-by Eva Kurchatova <[email protected]>
--- tools/testing/selftests/pstore/pstore_tests | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
tools/testing/selftests/pstore/pstore_tests +12 -6
@@ -9,13 +9,20 @@ . ./common_tests +# The frontends are separate options, a backend does not bring them in prlog -n "Checking pstore console is registered ... " -dmesg | grep -Eq "console \[(pstore|${backend})" -show_result $? +if dmesg | grep -Eq "console \[(pstore|${backend})"; then + show_result 0 +else + prlog "SKIP (no pstore console, needs CONFIG_PSTORE_CONSOLE)" +fi prlog -n "Checking /dev/pmsg0 exists ... " -test -e /dev/pmsg0 -show_result $? +if [ -e /dev/pmsg0 ]; then + show_result 0 +else + prlog "SKIP (no /dev/pmsg0, needs CONFIG_PSTORE_PMSG)" +fi prlog -n "Writing unique string to /dev/pmsg0 ... " if [ -e "/dev/pmsg0" ]; then
@@ -23,8 +30,7 @@ if [ -e "/dev/pmsg0" ]; then show_result $? echo "$UUID" > $TOP_DIR/uuid else - prlog "FAIL" - rc=1 + prlog "SKIP (no /dev/pmsg0)" fi exit $rc
Signature · 1 line
2.55.0