@@ -83,6 +83,9 @@ minvalue() { printf '%d' $(( "$1" < "$2" ? "$1" : "$2" )); }
8383#
8484start_test ()
8585{
86+ setup_kernel_check_point
87+ func_kmsg_collect
88+
8689 if [ " $SOF_TEST_PIPEWIRE " == true ]; then
8790 func_lib_enable_pipewire
8891 fi
@@ -97,7 +100,7 @@ start_test()
97100 }
98101
99102 # func_exit_handler() is in hijack.sh
100- trap ' func_exit_handler $?' EXIT
103+ trap ' func_exit_handler $?' EXIT SIGTERM
101104
102105 if test -z " $MAX_WAIT_FW_LOADING " ; then
103106 local _pltf; _pltf=$( " $SCRIPT_HOME /tools/sof-dump-status.py" -p)
@@ -157,7 +160,6 @@ start_test()
157160 local start_msg=" $prefix : starting"
158161 dlogi " $start_msg "
159162 logger -p user.info " $start_msg "
160-
161163}
162164
163165# See high-level description in start_test header above
@@ -198,6 +200,24 @@ stop_test()
198200}
199201
200202
203+ finish_kmsg_collection ()
204+ {
205+ dlogi " Finishing dmesg collection"
206+ kill -TERM " $KMSG_PID "
207+ wait " $KMSG_PID "
208+
209+ local journalctl_logs=" $LOG_ROOT /dmesg.txt"
210+ if test -s " ${journalctl_logs} " ; then
211+ wcLog=$( wc -l " ${journalctl_logs} " )
212+ dlogi " nlines=$wcLog "
213+ else
214+ dlogw " Empty ${journalctl_logs} "
215+ fi
216+ # Make sure the logs are written on disk just in case of DUT power reset.
217+ sync
218+ }
219+
220+
201221ktime ()
202222{
203223 # Keep it coarse because of various delays.
@@ -276,7 +296,9 @@ setup_kernel_check_point()
276296 # appear in the next one, see comments in config.sh. Add 3 extra
277297 # second to account for our own, sof-test delays after PASS/FAIL
278298 # decision: time spent collecting logs etc.
279- if [ -z " $KERNEL_CHECKPOINT " ]; then
299+ if [[ " $KERNEL_CHECKPOINT " == " disabled" ]]; then
300+ dlogi " KERNEL_CHECKPOINT already set as DISABLED"
301+ elif [ -z " $KERNEL_CHECKPOINT " ]; then
280302 KERNEL_CHECKPOINT=$(( $(date +% s) - SOF_TEST_INTERVAL - 3 ))
281303 else
282304 # Not the first time we are called so this is a test
@@ -408,6 +430,22 @@ func_mtrace_collect()
408430 sudo bash -c " ${mtraceCmd[*]} &" >& " $clogfile "
409431}
410432
433+ func_kmsg_collect () {
434+ local journalctl_logs=" $LOG_ROOT /dmesg.txt"
435+
436+ if [[ " $KERNEL_CHECKPOINT " =~ ^[0-9]{10} ]]; then
437+ dlogi " Saving kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs} "
438+ journalctl_cmd --since=@" $KERNEL_CHECKPOINT " -f >> " ${journalctl_logs} " &
439+ elif [[ " $KERNEL_CHECKPOINT " == " disabled" ]]; then
440+ dlogi " KERNEL_CHECKPOINT set as DISABLED, saving all kernel messages"
441+ journalctl_cmd -f >> " ${journalctl_logs} " &
442+ else
443+ dlogi " KERNEL_CHECKPOINT is not properly set, saving all kernel messages"
444+ journalctl_cmd -f >> " ${journalctl_logs} " &
445+ fi
446+ KMSG_PID=$!
447+ }
448+
411449func_lib_log_post_process ()
412450{
413451 # SyS-T log output a Zephyr feature, no need postprocess
0 commit comments