From 69a99734360caf30908a7f400205e4e7f44d81f3 Mon Sep 17 00:00:00 2001 From: Keqiao Zhang Date: Fri, 22 Jul 2022 14:09:07 +0800 Subject: [PATCH 1/3] lib.sh: add a new logging tool casvtool.py support cavstool.py is a Zephyr native logging tool, this tool will be used to dump the etrace from the shared memory. Signed-off-by: Keqiao Zhang --- case-lib/lib.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 2a663d1d..7373ad9f 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -293,6 +293,25 @@ find_ldc_file() printf '%s' "$ldcFile" } +func_cavstool_etrace_collect() +{ + local clogopt="--log-only --verbose" + local clogfile=$LOG_ROOT/etrace.txt + + if [ -z "$CAVSTOOL" ]; then + CAVSTOOL=$(command -v cavstool.py) || { + dlogw 'No cavstool.py found in PATH' + return 1 + } + fi + + local cavstoolCmd=("$CAVSTOOL" "$clogopt") + dlogi "Starting ${cavstoolCmd[*]}" + # Cleaned up by func_exit_handler() in hijack.sh + # shellcheck disable=SC2024 + sudo "${cavstoolCmd[@]}" >& "$clogfile" & +} + SOF_LOG_COLLECT=0 # This function starts a logger in the background using '&' # From 383747e282021757b8808f918197389328faaabb Mon Sep 17 00:00:00 2001 From: Keqiao Zhang Date: Fri, 22 Jul 2022 14:05:56 +0800 Subject: [PATCH 2/3] lib.sh: switch to use cavstool to dump the etrace we will use the Zephyr logging tool to dump the etrace form the shared memory for all Zephyr platforms. Signed-off-by: Keqiao Zhang --- case-lib/lib.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 7373ad9f..d36ce9d7 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -353,7 +353,18 @@ func_lib_start_log_collect() if [ "X$is_etrace" == "X0" ];then logfile=$LOG_ROOT/slogger.txt + + # start cavstool in the background to collect the etrace. + # Since cavstool can follow a ring buffer in etrace, so it should be + # started at the start of the test and we would not miss any Zephyr logs. + # FIXME (new) sof SOF bug #6039 + is_zephyr && func_cavstool_etrace_collect else + # cavstool starts at the beginning of the test, we don't need to start + # it again. We only need to start sof-logger to collect the etrace logs + # only for the non-zephyr platforms at the end of a test. + is_zephyr && return 0 + logfile=$LOG_ROOT/etrace.txt logopt="" fi From d11a6b513326aa84d4ac59cfd160759c72bfe41c Mon Sep 17 00:00:00 2001 From: Keqiao Zhang Date: Fri, 22 Jul 2022 14:10:32 +0800 Subject: [PATCH 3/3] hijack.sh: kill the cavstool.py after the test we need to kill the cavstool.py process after the test to prevent the conflicts between each case. Signed-off-by: Keqiao Zhang --- case-lib/hijack.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index 7e4eb348..d9d12773 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -55,8 +55,17 @@ function func_exit_handler() logfile="$logfile" local loggerBin wcLog; loggerBin=$(basename "$SOFLOGGER") - # We need this to avoid the confusion of a "Terminated" message + local cavstoolBin=cavstool.py + + # We need this dlogi to avoid the confusion of a "Terminated" message # without context. + if is_zephyr; then + dlogi "pkill -TERM -f $cavstoolBin" + sudo pkill -TERM -f "$cavstoolBin" || { + dloge "cavstool.py was already dead" + exit_status=1 + } + fi dlogi "pkill -TERM $loggerBin" sudo pkill -TERM "$loggerBin" || { dloge "sof-logger was already dead" @@ -76,11 +85,16 @@ function func_exit_handler() fi } sleep 1s - if pgrep "$loggerBin"; then - dloge "$loggerBin resisted pkill -TERM, using -KILL" - sudo pkill -KILL "$loggerBin" - exit_status=1 - fi + + local logtool + for logtool in "$cavstoolBin" "$loggerBin" + do + if pgrep -f "$logtool"; then + dloge "$logtool resisted pkill -TERM, using -KILL" + sudo pkill -KILL -f "$logtool" + exit_status=1 + fi + done if test -e "$logfile"; then