Skip to content

Commit b7d2f35

Browse files
committed
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 b7d2f35

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

case-lib/hijack.sh

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

1313
dlogi "Starting func_exit_handler($exit_status)"
1414

15+
if [[ -n "$DMESG_PID" ]]; then
16+
kill "$DMESG_PID" 2>/dev/null
17+
wait "$DMESG_PID" 2>/dev/null
18+
unset KERNEL_CHECKPOINT
19+
fi
20+
1521
func_lib_check_and_disable_pipewire
1622

1723
# call trace
@@ -134,32 +140,6 @@ function func_exit_handler()
134140
storage_checks || exit_status=1
135141
fi
136142

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-
163143
# get ps command result as list
164144
local -a cmd_lst
165145
# $$ as current script pid

case-lib/lib.sh

Lines changed: 20 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_dmesg_collect
128129

129130
export SOF_TEST_TOP_PID="$$"
130131
local prefix; prefix="ktime=$(ktime) sof-test PID=${SOF_TEST_TOP_PID}"
@@ -408,6 +409,24 @@ func_mtrace_collect()
408409
sudo bash -c "${mtraceCmd[*]} &" >& "$clogfile"
409410
}
410411

412+
func_dmesg_collect() {
413+
local journalctl_logs="$LOG_ROOT/dmesg.txt"
414+
415+
if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
416+
dlogi "Saving kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
417+
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" -f >> "${journalctl_logs}" &
418+
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
419+
dlogi "Saving all kernel messages"
420+
journalctl_cmd -f >> "${journalctl_logs}" &
421+
else
422+
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
423+
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
424+
test "$exit_status" -ne 0 || exit_status=1
425+
return
426+
fi
427+
DMESG_PID=$!
428+
}
429+
411430
func_lib_log_post_process()
412431
{
413432
# SyS-T log output a Zephyr feature, no need postprocess

0 commit comments

Comments
 (0)