From 26ac732b006795448eee5be2f4513ece875032b6 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 15 Jun 2020 10:49:27 -0600 Subject: test/runtests.sh: add dmesg check Lifted this from blktests, basically it just checks for known patterns of kernel complaints. If we trigger one while running a test, we fail the test case. Signed-off-by: Jens Axboe --- .gitignore | 1 + Makefile | 2 +- test/runtests.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fee76e8..48964d1 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,7 @@ /test/timeout /test/timeout-overflow /test/config.local +/test/*.dmesg config-host.h config-host.mak diff --git a/Makefile b/Makefile index 05d5879..948e004 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ install-tests: @$(MAKE) -C test install prefix=$(DESTDIR)$(prefix) datadir=$(DESTDIR)$(datadir) clean: - @rm -f config-host.mak config-host.h cscope.out $(NAME).pc + @rm -f config-host.mak config-host.h cscope.out $(NAME).pc test/*.dmesg @$(MAKE) -C src clean @$(MAKE) -C test clean @$(MAKE) -C examples clean diff --git a/test/runtests.sh b/test/runtests.sh index f2fbe5d..d2e9f73 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -7,9 +7,9 @@ TIMEOUT=30 FAILED="" MAYBE_FAILED="" -do_kmsg="yes" +do_kmsg="1" if ! [ $(id -u) = 0 ]; then - do_kmsg="no" + do_kmsg="0" fi TEST_DIR=$(dirname $0) @@ -24,13 +24,51 @@ if [ -f "$TEST_DIR/config.local" ]; then done fi +_check_dmesg() +{ + local dmesg_marker="$1" + local seqres="$2.seqres" + + if [[ $do_kmsg -eq 0 ]]; then + return 0 + fi + + dmesg | bash -c "$DMESG_FILTER" | grep -A 9999 "$dmesg_marker" >"${seqres}.dmesg" + grep -q -e "kernel BUG at" \ + -e "WARNING:" \ + -e "BUG:" \ + -e "Oops:" \ + -e "possible recursive locking detected" \ + -e "Internal error" \ + -e "INFO: suspicious RCU usage" \ + -e "INFO: possible circular locking dependency detected" \ + -e "general protection fault:" \ + -e "blktests failure" \ + "${seqres}.dmesg" + # shellcheck disable=SC2181 + if [[ $? -eq 0 ]]; then + return 1 + else + rm -f "${seqres}.dmesg" + return 0 + fi +} + run_test() { T="$1" D="$2" - if [ "$do_kmsg" = "yes" ]; then - echo Running test $T $D | tee /dev/kmsg + DMESG_FILTER="cat" + + if [ "$do_kmsg" -eq 1 ]; then + if [ -z "$D" ]; then + local dmesg_marker="Running test $T:" + else + local dmesg_marker="Running test $T $D:" + fi + echo $dmesg_marker | tee /dev/kmsg else + local dmesg_marker="" echo Running test $T $D fi timeout --preserve-status -s INT $TIMEOUT ./$T $D @@ -45,6 +83,14 @@ run_test() FAILED="$FAILED <$T $D>" fi RET=1 + elif ! _check_dmesg "$dmesg_marker" "$T"; then + echo "Test $T failed dmesg check" + if [ -z "$D" ]; then + FAILED="$FAILED <$T>" + else + FAILED="$FAILED <$T $D>" + fi + RET=1 elif [ ! -z "$D" ]; then sleep .1 ps aux | grep "\[io_wq_manager\]" > /dev/null -- cgit v1.2.3