@@ -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,23 @@ stop_test()
198200}
199201
200202
203+ finish_kmsg_collection ()
204+ {
205+ dlogi " Finishing dmesg collection"
206+ sudo pkill -9 journalctl
207+
208+ local journalctl_logs=" $LOG_ROOT /dmesg.txt"
209+ if test -s " ${journalctl_logs} " ; then
210+ wcLog=$( wc -l " ${journalctl_logs} " )
211+ dlogi " nlines=$wcLog "
212+ else
213+ dlogw " Empty ${journalctl_logs} "
214+ fi
215+ # Make sure the logs are written on disk just in case of DUT power reset.
216+ sync
217+ }
218+
219+
201220ktime ()
202221{
203222 # Keep it coarse because of various delays.
@@ -276,7 +295,9 @@ setup_kernel_check_point()
276295 # appear in the next one, see comments in config.sh. Add 3 extra
277296 # second to account for our own, sof-test delays after PASS/FAIL
278297 # decision: time spent collecting logs etc.
279- if [ -z " $KERNEL_CHECKPOINT " ]; then
298+ if [[ " $KERNEL_CHECKPOINT " == " disabled" ]]; then
299+ dlogi " KERNEL_CHECKPOINT already set as DISABLED"
300+ elif [ -z " $KERNEL_CHECKPOINT " ]; then
280301 KERNEL_CHECKPOINT=$(( $(date +% s) - SOF_TEST_INTERVAL - 3 ))
281302 else
282303 # Not the first time we are called so this is a test
@@ -408,6 +429,21 @@ 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 " KERNEL_CHECKPOINT set as DISABLED, saving all kernel messages"
440+ journalctl_cmd -f >> " ${journalctl_logs} " &
441+ else
442+ dlogi " KERNEL_CHECKPOINT is not properly set, saving all kernel messages"
443+ journalctl_cmd -f >> " ${journalctl_logs} " &
444+ fi
445+ }
446+
411447func_lib_log_post_process ()
412448{
413449 # SyS-T log output a Zephyr feature, no need postprocess
0 commit comments