Skip to content

Commit a3faf7f

Browse files
committed
test-case/check-sof-logger.sh: Fix logger selection and broaden timeout handling
Two independent fixes: Logger selection when multiple sof-logger binaries exist in PATH: - Move 'loggerBin=$(type -p sof-logger)' before the md5 check so default is always available - Replace die() with dlogw() when different-checksum binaries are found; test can still run with clearly chosen binary - Prefer distro-managed system binary (/usr/bin/sof-logger, then /bin/sof-logger) over locally-built /usr/local copy; log the chosen path at dlogw level - Falls back to the original 'type -p' result if neither system path exists Timeout exit code handling: - Introduce helper timeout_status_ok(): returns 0 for exit codes 124 (standard 'timeout' expiry) and 125 (some wrapper/edge-case paths) - Replace hardcoded 'test -eq 124' checks (DMA logger, mtrace, etrace) with calls to timeout_status_ok(); prevents spurious 'unexpected exit status' failures on systems where timeout returns 125 Signed-off-by: Mateusz Junkier <mateusz.junkier@intel.com>
1 parent 3768bfe commit a3faf7f

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

test-case/check-sof-logger.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,25 @@ md5list()
4141
while read -r; do md5sum "$REPLY"; done
4242
}
4343

44+
loggerBin=$(type -p sof-logger)
45+
4446
# Recent Ubuntu versions symlink the entire /bin -> /usr/bin so we
4547
# cannot just count the number of filenames we found. Count the
4648
# number of different _checksums_ we found in PATH.
47-
if type -a -p sof-logger | md5list | awk '{ print $1 }' |
48-
sort -u | tail -n +2 | grep -q . ; then
49-
dloge "There are different sof-logger in PATH on the system $(hostname)!"
50-
type -a -p sof-logger | md5list
51-
die "Not testing a random sof-logger version"
49+
md5_out=$(type -a -p sof-logger | md5list)
50+
if [ "$(echo "$md5_out" | awk '{ print $1 }' | sort -u | wc -l)" -gt 1 ]; then
51+
dlogw "There are different sof-logger binaries in PATH on the system $(hostname)!"
52+
echo "$md5_out"
53+
54+
# Prefer distro/system binary over /usr/local when versions differ.
55+
if [ -x /usr/bin/sof-logger ]; then
56+
loggerBin=/usr/bin/sof-logger
57+
elif [ -x /bin/sof-logger ]; then
58+
loggerBin=/bin/sof-logger
59+
fi
60+
61+
dlogw "Using selected sof-logger: $loggerBin"
5262
fi
53-
loggerBin=$(type -p sof-logger)
5463
dlogi "Found file: $(md5sum "$loggerBin" | awk '{print $2, $1;}')"
5564

5665
if ! is_firmware_file_zephyr; then
@@ -72,10 +81,13 @@ sof_alsa_card_found()
7281
# - /proc/asound/sofsoundwire/id
7382
# - /proc/asound/sofhdadsp/id
7483
# - https://github.com/thesofproject/sof-test/issues/1243
75-
# Designed to support multiple SOF instances with SOF probes
84+
# Designed to support multiple SOF instances with SOF probes
85+
# shellcheck disable=SC2317 # called indirectly via poll_wait_for
7686
for i in /proc/asound/sof*/id; do
87+
# shellcheck disable=SC2317
7788
if test -e "$i"; then return 0; fi
7889
done
90+
# shellcheck disable=SC2317
7991
return 1
8092
}
8193

@@ -109,6 +121,11 @@ run_loggers()
109121

110122
local etrace_exit
111123

124+
timeout_status_ok()
125+
{
126+
[ "$1" -eq 124 ] || [ "$1" -eq 125 ]
127+
}
128+
112129
# This test is not really supposed to run while the DSP is busy at
113130
# the same time, so $data_file will hopefully not be long.
114131
local collect_secs=3
@@ -182,8 +199,7 @@ run_loggers()
182199
# Sof-logger DMA logging (IPC3 only)
183200

184201
loggerStatus=0; wait "$dmaPID" || loggerStatus=$?
185-
# 124 is the normal timeout exit status
186-
test "$loggerStatus" -eq 124 || {
202+
timeout_status_ok "$loggerStatus" || {
187203
cat "$error_file"
188204
die "timeout sof-logger returned unexpected: $loggerStatus"
189205
}
@@ -196,7 +212,7 @@ run_loggers()
196212
# SOF kernel IPC4 SRAM logging interface (mtrace)
197213

198214
loggerStatus=0; wait "$mtracetoolPID" || loggerStatus=$?
199-
test "$loggerStatus" -eq 124 || {
215+
timeout_status_ok "$loggerStatus" || {
200216
cat "$etrace_file"
201217
cat "$etrace_stderr_file"
202218
die "timeout $mtracetool returned unexpected: $loggerStatus"
@@ -205,7 +221,7 @@ run_loggers()
205221
# SOF kernel IPC3 SRAM logging interface (etrace)
206222

207223
loggerStatus=0; wait "$cavstoolPID" || loggerStatus=$?
208-
test "$loggerStatus" -eq 124 || {
224+
timeout_status_ok "$loggerStatus" || {
209225
cat "$error_file"
210226
die "timeout $cavstool returned unexpected: $loggerStatus"
211227
}

0 commit comments

Comments
 (0)