Skip to content

Commit c341de8

Browse files
ekurdybxmajunkier
authored andcommitted
hijack.sh: exit_handler: collect dmesg throughout the whole test
Start collecting dmesg logs in the beggining of the test and run collection in the background. Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
1 parent fca480c commit c341de8

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

case-lib/hijack.sh

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ function func_exit_handler()
1212

1313
dlogi "Starting func_exit_handler($exit_status)"
1414

15+
finish_kmsg_collection
16+
1517
func_lib_check_and_disable_pipewire
1618

1719
# call trace
@@ -134,32 +136,6 @@ function func_exit_handler()
134136
storage_checks || exit_status=1
135137
fi
136138

137-
local journalctl_logs="$LOG_ROOT/dmesg.txt"
138-
if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
139-
# Do not collect the entire duration of the test but only the
140-
# last iteration.
141-
dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
142-
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
143-
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
144-
dlogi "Save all kernel messages to ${journalctl_logs}"
145-
journalctl_cmd > "${journalctl_logs}"
146-
else
147-
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
148-
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
149-
test "$exit_status" -ne 0 || exit_status=1
150-
fi
151-
if test -s "${journalctl_logs}"; then
152-
wcLog=$(wc -l "${journalctl_logs}")
153-
dlogi "nlines=$wcLog"
154-
else
155-
dlogw "Empty ${journalctl_logs}"
156-
fi
157-
# Make sure the logs are written on disk just in case of DUT power reset.
158-
sync
159-
160-
# After log collected, KERNEL_CHECKPOINT will not be used any more
161-
unset KERNEL_CHECKPOINT
162-
163139
# get ps command result as list
164140
local -a cmd_lst
165141
# $$ as current script pid

case-lib/lib.sh

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
201222
ktime()
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+
411450
func_lib_log_post_process()
412451
{
413452
# SyS-T log output a Zephyr feature, no need postprocess

0 commit comments

Comments
 (0)