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 <joe.lawrence@redhat.com>
This commit is contained in:
Joe Lawrence 2020-07-30 14:11:36 -04:00
parent d76110ed24
commit de1d0c6e08
1 changed files with 15 additions and 4 deletions

View File

@ -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 # shellcheck disable=SC1091
source /etc/os-release source /etc/os-release
if [[ "${ID}" == "rhel" && "${VERSION_ID%%.*}" == "7" && "${VERSION_ID##*.}" -le "6" ]]; then if [[ "${ID}" == "rhel" && "${VERSION_ID%%.*}" == "7" && "${VERSION_ID##*.}" -le "6" ]]; then
@ -313,8 +325,7 @@ build_combined_module
unload_all unload_all
echo "clearing printk buffer" save_dmesg
sudo dmesg -C
if [ "${DYNDEBUG_ENABLED}" == "1" ]; then if [ "${DYNDEBUG_ENABLED}" == "1" ]; then
prev_dyndebug=$(grep klp_try_switch_task "${DYNDEBUG_CONTROL}" | awk '{print $3;}') 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 echo "func klp_try_switch_task ${prev_dyndebug}" >"${DYNDEBUG_CONTROL}" 2>/dev/null
fi fi
if dmesg | grep -q "Call Trace"; then if new_dmesg | grep -q "Call Trace"; then
dmesg > dmesg.log new_dmesg > dmesg.log
error "kernel error detected in printk buffer" error "kernel error detected in printk buffer"
fi fi