diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-06-15 10:49:27 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-06-15 10:49:27 -0600 |
commit | 26ac732b006795448eee5be2f4513ece875032b6 (patch) | |
tree | 63163d9658f0784f9bb1e4de09d96ac1cef38394 | |
parent | 595e4db1bae4fbe4bb97460f9180694535e045af (diff) | |
download | liburing-26ac732b006795448eee5be2f4513ece875032b6.tar.gz liburing-26ac732b006795448eee5be2f4513ece875032b6.tar.bz2 |
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 <axboe@kernel.dk>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | test/runtests.sh | 54 |
3 files changed, 52 insertions, 5 deletions
@@ -88,6 +88,7 @@ /test/timeout /test/timeout-overflow /test/config.local +/test/*.dmesg config-host.h config-host.mak @@ -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 |