From f947a506d1d124b275b26fda94e0a996a1b068e2 Mon Sep 17 00:00:00 2001 From: Emilia Kurdybelska Date: Fri, 6 Mar 2026 10:33:26 +0100 Subject: [PATCH] Revert "hijack.sh: exit_handler: collect dmesg throughout the whole test" This reverts commit c341de8b060e6845301e4b03c39f71e8aac6d477. --- case-lib/hijack.sh | 28 ++++++++++++++++++++++++++-- case-lib/lib.sh | 41 +---------------------------------------- 2 files changed, 27 insertions(+), 42 deletions(-) diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index f1d1b8a7..6f14e954 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -12,8 +12,6 @@ function func_exit_handler() dlogi "Starting func_exit_handler($exit_status)" - finish_kmsg_collection - func_lib_check_and_disable_pipewire # call trace @@ -136,6 +134,32 @@ function func_exit_handler() storage_checks || exit_status=1 fi + local journalctl_logs="$LOG_ROOT/dmesg.txt" + if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then + # Do not collect the entire duration of the test but only the + # last iteration. + dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}" + journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}" + elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then + dlogi "Save all kernel messages to ${journalctl_logs}" + journalctl_cmd > "${journalctl_logs}" + else + dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set' + dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT" + test "$exit_status" -ne 0 || exit_status=1 + fi + if test -s "${journalctl_logs}"; then + wcLog=$(wc -l "${journalctl_logs}") + dlogi "nlines=$wcLog" + else + dlogw "Empty ${journalctl_logs}" + fi + # Make sure the logs are written on disk just in case of DUT power reset. + sync + + # After log collected, KERNEL_CHECKPOINT will not be used any more + unset KERNEL_CHECKPOINT + # get ps command result as list local -a cmd_lst # $$ as current script pid diff --git a/case-lib/lib.sh b/case-lib/lib.sh index d1ce1cef..15d122ba 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -97,7 +97,7 @@ start_test() } # func_exit_handler() is in hijack.sh - trap 'func_exit_handler $?' EXIT SIGTERM + trap 'func_exit_handler $?' EXIT if test -z "$MAX_WAIT_FW_LOADING"; then local _pltf; _pltf=$("$SCRIPT_HOME/tools/sof-dump-status.py" -p) @@ -125,7 +125,6 @@ start_test() die "FW is not loaded for $MAX_WAIT_FW_LOADING" fi } - func_kmsg_collect export SOF_TEST_TOP_PID="$$" local prefix; prefix="ktime=$(ktime) sof-test PID=${SOF_TEST_TOP_PID}" @@ -199,26 +198,6 @@ stop_test() } -finish_kmsg_collection() -{ - if [[ -n "$DMESG_PID" ]]; then - kill "$DMESG_PID" 2>/dev/null - wait "$DMESG_PID" 2>/dev/null - unset KERNEL_CHECKPOINT - fi - - local journalctl_logs="$LOG_ROOT/dmesg.txt" - if test -s "${journalctl_logs}"; then - wcLog=$(wc -l "${journalctl_logs}") - dlogi "nlines=$wcLog" - else - dlogw "Empty ${journalctl_logs}" - fi - # Make sure the logs are written on disk just in case of DUT power reset. - sync -} - - ktime() { # Keep it coarse because of various delays. @@ -429,24 +408,6 @@ func_mtrace_collect() sudo bash -c "${mtraceCmd[*]} &" >& "$clogfile" } -func_kmsg_collect() { - local journalctl_logs="$LOG_ROOT/dmesg.txt" - - if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then - dlogi "Saving kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}" - journalctl_cmd --since=@"$KERNEL_CHECKPOINT" -f >> "${journalctl_logs}" & - elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then - dlogi "Saving all kernel messages" - journalctl_cmd -f >> "${journalctl_logs}" & - else - dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set' - dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT" - test "$exit_status" -ne 0 || exit_status=1 - return - fi - DMESG_PID=$! -} - func_lib_log_post_process() { # SyS-T log output a Zephyr feature, no need postprocess