Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function func_exit_handler()

dlogi "Starting func_exit_handler($exit_status)"

finish_kmsg_collection

func_lib_check_and_disable_pipewire

# call trace
Expand Down Expand Up @@ -134,32 +136,6 @@ function func_exit_handler()
storage_checks || exit_status=1
fi

local journalctl_logs="$LOG_ROOT/dmesg.txt"
if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
# Do not collect the entire duration of the test but only the
# last iteration.
dlogi "Save kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
dlogi "Save all kernel messages to ${journalctl_logs}"
journalctl_cmd > "${journalctl_logs}"
else
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
test "$exit_status" -ne 0 || exit_status=1
fi
if test -s "${journalctl_logs}"; then
wcLog=$(wc -l "${journalctl_logs}")
dlogi "nlines=$wcLog"
else
dlogw "Empty ${journalctl_logs}"
fi
# Make sure the logs are written on disk just in case of DUT power reset.
sync

# After log collected, KERNEL_CHECKPOINT will not be used any more
unset KERNEL_CHECKPOINT

# get ps command result as list
local -a cmd_lst
# $$ as current script pid
Expand Down
41 changes: 40 additions & 1 deletion case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ start_test()
}

# func_exit_handler() is in hijack.sh
trap 'func_exit_handler $?' EXIT
trap 'func_exit_handler $?' EXIT SIGTERM

if test -z "$MAX_WAIT_FW_LOADING"; then
local _pltf; _pltf=$("$SCRIPT_HOME/tools/sof-dump-status.py" -p)
Expand Down Expand Up @@ -125,6 +125,7 @@ start_test()
die "FW is not loaded for $MAX_WAIT_FW_LOADING"
fi
}
func_kmsg_collect

export SOF_TEST_TOP_PID="$$"
local prefix; prefix="ktime=$(ktime) sof-test PID=${SOF_TEST_TOP_PID}"
Expand Down Expand Up @@ -198,6 +199,26 @@ stop_test()
}


finish_kmsg_collection()
{
if [[ -n "$DMESG_PID" ]]; then
kill "$DMESG_PID" 2>/dev/null
wait "$DMESG_PID" 2>/dev/null
unset KERNEL_CHECKPOINT
fi

local journalctl_logs="$LOG_ROOT/dmesg.txt"
if test -s "${journalctl_logs}"; then
wcLog=$(wc -l "${journalctl_logs}")
dlogi "nlines=$wcLog"
else
dlogw "Empty ${journalctl_logs}"
fi
# Make sure the logs are written on disk just in case of DUT power reset.
sync
}


ktime()
{
# Keep it coarse because of various delays.
Expand Down Expand Up @@ -408,6 +429,24 @@ func_mtrace_collect()
sudo bash -c "${mtraceCmd[*]} &" >& "$clogfile"
}

func_kmsg_collect() {
local journalctl_logs="$LOG_ROOT/dmesg.txt"

if [[ "$KERNEL_CHECKPOINT" =~ ^[0-9]{10} ]]; then
dlogi "Saving kernel messages since ${KERNEL_CHECKPOINT} to ${journalctl_logs}"
journalctl_cmd --since=@"$KERNEL_CHECKPOINT" -f >> "${journalctl_logs}" &
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
dlogi "Saving all kernel messages"
journalctl_cmd -f >> "${journalctl_logs}" &
else
dloge 'Kernel check point "KERNEL_CHECKPOINT" is not properly set'
dloge "KERNEL_CHECKPOINT=$KERNEL_CHECKPOINT"
test "$exit_status" -ne 0 || exit_status=1
return
fi
DMESG_PID=$!
}

func_lib_log_post_process()
{
# SyS-T log output a Zephyr feature, no need postprocess
Expand Down