@@ -97,7 +97,7 @@ start_test()
9797 }
9898
9999 # func_exit_handler() is in hijack.sh
100- trap ' func_exit_handler $?' EXIT
100+ trap ' func_exit_handler $?' EXIT SIGTERM
101101
102102 if test -z " $MAX_WAIT_FW_LOADING " ; then
103103 local _pltf; _pltf=$( " $SCRIPT_HOME /tools/sof-dump-status.py" -p)
@@ -125,6 +125,7 @@ start_test()
125125 die " FW is not loaded for $MAX_WAIT_FW_LOADING "
126126 fi
127127 }
128+ func_kmsg_collect
128129
129130 export SOF_TEST_TOP_PID=" $$ "
130131 local prefix; prefix=" ktime=$( ktime) sof-test PID=${SOF_TEST_TOP_PID} "
@@ -198,6 +199,26 @@ stop_test()
198199}
199200
200201
202+ finish_kmsg_collection ()
203+ {
204+ if [[ -n " $DMESG_PID " ]]; then
205+ kill " $DMESG_PID " 2> /dev/null
206+ wait " $DMESG_PID " 2> /dev/null
207+ unset KERNEL_CHECKPOINT
208+ fi
209+
210+ local journalctl_logs=" $LOG_ROOT /dmesg.txt"
211+ if test -s " ${journalctl_logs} " ; then
212+ wcLog=$( wc -l " ${journalctl_logs} " )
213+ dlogi " nlines=$wcLog "
214+ else
215+ dlogw " Empty ${journalctl_logs} "
216+ fi
217+ # Make sure the logs are written on disk just in case of DUT power reset.
218+ sync
219+ }
220+
221+
201222ktime ()
202223{
203224 # Keep it coarse because of various delays.
@@ -408,6 +429,24 @@ func_mtrace_collect()
408429 sudo bash -c " ${mtraceCmd[*]} &" >& " $clogfile "
409430}
410431
432+ func_kmsg_collect () {
433+ local journalctl_logs=" $LOG_ROOT /dmesg.txt"
434+
435+ if [[ " $KERNEL_CHECKPOINT " =~ ^[0-9]{10} ]]; then
436+ dlogi " Saving kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs} "
437+ journalctl_cmd --since=@" $KERNEL_CHECKPOINT " -f >> " ${journalctl_logs} " &
438+ elif [[ " $KERNEL_CHECKPOINT " == " disabled" ]]; then
439+ dlogi " Saving all kernel messages"
440+ journalctl_cmd -f >> " ${journalctl_logs} " &
441+ else
442+ dloge ' Kernel check point "KERNEL_CHECKPOINT" is not properly set'
443+ dloge " KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT "
444+ test " $exit_status " -ne 0 || exit_status=1
445+ return
446+ fi
447+ DMESG_PID=$!
448+ }
449+
411450func_lib_log_post_process ()
412451{
413452 # SyS-T log output a Zephyr feature, no need postprocess
0 commit comments