Skip to content
Merged
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
66 changes: 56 additions & 10 deletions test-case/check-sof-logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@

set -e

TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
source "${TOPDIR}"/case-lib/lib.sh

func_opt_parse_option "$@"

setup_kernel_check_point

# check sof-logger location
type -a sof-logger ||
die "sof-logger Not Installed!"
Expand Down Expand Up @@ -98,6 +97,12 @@ run_loggers()
return $etrace_exit
}


dma_nudge()
{
sudo timeout -k 5 2 "$loggerBin" -l "${ldcFile}" -F info=pga -t
}

# Dumps all logs before exiting
print_logs_exit()
{
Expand All @@ -111,20 +116,42 @@ print_logs_exit()

local bname
for ftype in data etrace error etrace_stderr; do
printf '\n\n'
printf '\n'
bname="logger.$ftype.txt"
dlogi "Log file $bname BEG::"
cat "$LOG_ROOT/$bname" || true # we already checked these
dlogi "::END log file $bname"
printf '\n'
done
test -z "$errmsg" || dloge "$errmsg"
exit "$exit_code"
}

reload_drivers()
{
"${TOPDIR}"/tools/kmod/sof_remove.sh

setup_kernel_check_point

"${TOPDIR}"/tools/kmod/sof_insert.sh

# The DSP may unfortunately need multiple retries to boot, see
# https://github.com/thesofproject/sof/issues/3395
dlogi "Waiting a few seconds for the DSP to fully boot and then suspend"
for i in $(seq 1 5); do
if sudo test -e /sys/kernel/debug/sof/etrace; then break; fi
sleep 1
done
# Now give enough time to go to D3 suspend
sleep 4
}

main()
{
reload_drivers

run_loggers ||
print_logs_exit 1 "Reading etrace failed, run_loggers returned $?"
print_logs_exit 1 "Reading (e)trace failed, run_loggers returned $?"

local f

Expand All @@ -138,8 +165,12 @@ main()
logger."$f".txt > "$stderr_file"
done

# Simulates a stuck DMA to test the code below
# sed -i -e '2,$ d' "$LOG_ROOT/logger.data.txt"

# Search for the log header, should be something like this:
# TIMESTAMP DELTA C# COMPONENT LOCATION CONTENT
# then for the 'FW ABI' banner
for f in etrace data; do
local tracef="$LOG_ROOT/logger.$f.txt"
test -e "$tracef" || die "$tracef" not found
Expand All @@ -148,14 +179,29 @@ main()
print_logs_exit 1 "Log header not found in ${data_file}"

# See initial message SOF PR #3281 / SOF commit 67a0a69
grep -q 'dma-trace.c.*FW ABI.*tag.*hash' "$tracef" ||
grep -q 'dma-trace.c.*FW ABI.*tag.*hash' "$tracef" || {

# Workaround for DMA trace bug
# https://github.com/thesofproject/sof/issues/4333
if [ "$f" = data ]; then
dloge "Empty or stuck DMA trace? Let's try to nudge it."
dloge ' vv Workaround for SOF issue 4333 vv'
local second_chance="$LOG_ROOT/logger.dma_trace_bug_4333.txt"
dma_nudge | tee "$second_chance"
printf '\n'
dloge ' ^^ End of workaround nudge for 4333 ^^ '
printf '\n'

if head "$second_chance" |
grep -q 'dma-trace.c.*FW ABI.*tag.*hash'; then
continue # and don't report failure 4333
fi
fi

print_logs_exit 1 "Initial FW ABI banner not found in ${data_file}"
}
done

# This is a bit redundant with the previous test but does not hurt.
tail -n +2 "${data_file}" | grep -q '[^[:blank:]]' ||
print_logs_exit 1 "Nothing but the first line in DMA trace ${data_file}"

# Show all outputs even when everything went OK
print_logs_exit 0
}
Expand Down