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 diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 2a663d1d..d36ce9d7 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 '&' # @@ -334,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