Skip to content
Merged
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
25 changes: 25 additions & 0 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,31 @@ 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}"
kernel_logger_cmd --since=@"$KERNEL_CHECKPOINT" > "${journalctl_logs}"
elif [[ "$KERNEL_CHECKPOINT" == "disabled" ]]; then
dlogi "Save all kernel messages to ${journalctl_logs}"
kernel_logger_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
27 changes: 19 additions & 8 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ storage_checks()

setup_kernel_check_point()
{
sudo true
# Make the check point $SOF_TEST_INTERVAL second(s) earlier to avoid
# log loss. Note this may lead to an error caused by one test
# appear in the next one, see comments in config.sh. Add 3 extra
Expand Down Expand Up @@ -1140,10 +1141,20 @@ is_sof_used()
}

# a wrapper to journalctl with required style
journalctl_cmd()
kernel_logger_cmd()
{
sudo journalctl -k -q --no-pager --utc --output=short-monotonic \
--no-hostname "$@"
if command -v journalctl >/dev/null 2>&1; then
sudo journalctl -k -q --no-pager --utc --output=short-monotonic --no-hostname "$@"
else
local mapped_args=()
local arg

for arg in "$@"; do
mapped_args+=("${arg/--priority/--level}")
done

sudo dmesg -k --nopager "${mapped_args[@]}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is dropping the important --since argument: exactly why dmesg is unsuitable for testing.

  2. Other obvious reason why is: unknown ring buffer size and losing logs at very verbose levels.

Embedded systems like Yocto aside, "systemd-free" distros have /var/log/something that should have been used instead of dmesg. It would have avoided at least issue 2.

At least it does not seem to affect systems that do have journalctl....

fi
}

# Force the exit handler to collect all the logs since boot time instead
Expand All @@ -1157,7 +1168,7 @@ disable_kernel_check_point()
# shellcheck disable=SC2120
sof_firmware_boot_complete()
{
journalctl_cmd "$@" | grep -i 'sof.*firmware[[:blank:]]*boot[[:blank:]]*complete'
kernel_logger_cmd "$@" | grep -i 'sof.*firmware[[:blank:]]*boot[[:blank:]]*complete'
}

# If the firmware is loaded then you probably want to use the newer
Expand Down Expand Up @@ -1246,7 +1257,7 @@ fw_relfilepath()
fw_relfilepath_from_klogs()
{
local rel_filepath
rel_filepath=$(journalctl -k |
rel_filepath=$(kernel_logger_cmd |
awk '/sof.*[[:blank:]]request_firmware[[:blank:]]/ {
sub(/^.*request_firmware/,""); last_loaded_file=$1
}
Expand Down Expand Up @@ -1354,11 +1365,11 @@ grep_firmware_info_in_logs()
{
# dump the version info and ABI info
# "head -n" makes this compatible with set -e.
journalctl_cmd "$@" | grep "Firmware info" -A1 | head -n 12
kernel_logger_cmd "$@" | grep "Firmware info" -A1 | head -n 12
# For dumping the firmware information when DUT runs IPC4 mode
journalctl_cmd "$@" | grep "firmware version" -A1 | head -n 12
kernel_logger_cmd "$@" | grep "firmware version" -A1 | head -n 12
# dump the debug info
journalctl_cmd "$@" | grep "Firmware debug build" -A3 | head -n 12
kernel_logger_cmd "$@" | grep "Firmware debug build" -A3 | head -n 12
}

# check if NTP Synchronized, if so return 0 otherwise return 1
Expand Down
4 changes: 2 additions & 2 deletions test-case/verify-sof-firmware-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ disable_kernel_check_point

start_test

cmd="journalctl_cmd"
cmd="kernel_logger_cmd"

dlogi "Checking SOF Firmware load info in kernel log"
if sof_firmware_boot_complete; then
Expand All @@ -42,7 +42,7 @@ else # failed, show some logs

printf ' ------\n Check journalctl status: \n ---- \n'
systemctl --no-pager status systemd-journald* || true
journalctl_cmd --lines 50 || true
kernel_logger_cmd --lines 50 || true

die "Cannot find any 'sof boot complete' message in logs since boot time"
fi
4 changes: 2 additions & 2 deletions tools/sof-kernel-log-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ fi

# confirm begin_timestamp is in UNIX timestamp format, otherwise search full log
if [[ $begin_timestamp =~ ^[0-9]{10} ]]; then
cmd="journalctl_cmd --since=@$begin_timestamp"
cmd="kernel_logger_cmd --since=@$begin_timestamp"
else
die "Invalid begin_timestamp $1 argument: $begin_timestamp"
fi
Expand All @@ -469,7 +469,7 @@ declare -p cmd
if err=$($cmd --priority=err |
grep -v -E -e "$ignore_str" "${sof_local_extra_kernel_ignores[@]}"); then

type journalctl_cmd
type kernel_logger_cmd
echo "$(date -u '+%Y-%m-%d %T %Z')" "[ERROR]" "Caught kernel log error"
echo "===========================>>"
echo "$err"
Expand Down
Loading