Skip to content

Commit

Permalink
lib.sh: disable logging with SOF_LOGGING=none env or missing .ldc
Browse files Browse the repository at this point in the history
Some configurations don't support the logger. Others do but do not want
to run it for various reasons.

Supersedes thesofproject#811, see earlier discussions there.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Dec 1, 2021
1 parent 0a464ff commit 1de043b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fake_kern_error()

}

# Prints the .ldc file found on stdout, errors on stderr.
find_ldc_file()
{
local ldcFile
Expand All @@ -87,6 +88,7 @@ find_ldc_file()
# and then on the standard location.
if [ -n "$SOFLDC" ]; then
ldcFile="$SOFLDC"
>&2 dlogi "SOFLDC=${SOFLDC} overriding default locations"
else
local platf; platf=$(sof-dump-status.py -p) || {
>&2 dloge "Failed to query platform with sof-dump-status.py"
Expand All @@ -98,7 +100,7 @@ find_ldc_file()
fi

[[ -e "$ldcFile" ]] || {
>&2 dloge "LDC file $ldcFile not found, check the SOFLDC environment variable or copy your sof-*.ldc to /etc/sof"
>&2 dlogi "LDC file $ldcFile not found"
return 1
}
printf '%s' "$ldcFile"
Expand Down Expand Up @@ -397,7 +399,27 @@ is_zephyr()

logger_disabled()
{
[[ ${OPT_VAL['s']} -eq 0 ]]
local ldcFile
# Some firmware/OS configurations do not support logging.
ldcFile=$(find_ldc_file) || {
dlogi '.ldc dictionary file not found, SOF logs collection disabled'
return 0 # 0 is 'true'
}

# Disable logging when available...
if [ ${OPT_VAL['s']} -eq 0 ]; then
return 0
fi

# ... across all tests at once.
# In the future we should support SOF_LOGGING=etrace (only), see
# sof-test#726
if [ "x$SOF_LOGGING" == 'xnone' ]; then
dlogi 'SOF logs collection globally disabled by SOF_LOGGING=none'
return 0
fi

return 1
}

print_module_params()
Expand Down

0 comments on commit 1de043b

Please sign in to comment.