From de1d0c6e08e6c781f59f327e6ddfa9e603585ed0 Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Thu, 30 Jul 2020 14:11:36 -0400 Subject: [PATCH] kpatch-test: don't clear dmesg during test The kpatch-test script clears the kernel log buffer to distinguish between old and new dmesg entries. Wiping out the old buffer may surprise some users, but isn't too hard to avoid: - save the last dmesg line - run the tests - filter out old dmesg lines until after finding the saved entry - if no saved entry is found, the buffer most likely overflowed - inform the user to increase the log size Signed-off-by: Joe Lawrence --- test/integration/kpatch-test | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/integration/kpatch-test b/test/integration/kpatch-test index c47c5c2..4359b46 100755 --- a/test/integration/kpatch-test +++ b/test/integration/kpatch-test @@ -296,6 +296,18 @@ run_combined_test() { } +# save existing dmesg so we can detect new content +save_dmesg() { + SAVED_DMESG="$(dmesg | tail -n1)" +} + +# new dmesg entries since our saved entry +new_dmesg() { + if ! dmesg | awk -v last="$SAVED_DMESG" 'p; $0 == last{p=1} END {exit !p}'; then + error "dmesg overflow, try increasing kernel log buffer size" + fi +} + # shellcheck disable=SC1091 source /etc/os-release if [[ "${ID}" == "rhel" && "${VERSION_ID%%.*}" == "7" && "${VERSION_ID##*.}" -le "6" ]]; then @@ -313,8 +325,7 @@ build_combined_module unload_all -echo "clearing printk buffer" -sudo dmesg -C +save_dmesg if [ "${DYNDEBUG_ENABLED}" == "1" ]; then prev_dyndebug=$(grep klp_try_switch_task "${DYNDEBUG_CONTROL}" | awk '{print $3;}') @@ -345,8 +356,8 @@ if [ "${DYNDEBUG_ENABLED}" == "1" ]; then echo "func klp_try_switch_task ${prev_dyndebug}" >"${DYNDEBUG_CONTROL}" 2>/dev/null fi -if dmesg | grep -q "Call Trace"; then - dmesg > dmesg.log +if new_dmesg | grep -q "Call Trace"; then + new_dmesg > dmesg.log error "kernel error detected in printk buffer" fi