diff --git a/case-lib/hijack.sh b/case-lib/hijack.sh index 02f7e016..22c19e99 100644 --- a/case-lib/hijack.sh +++ b/case-lib/hijack.sh @@ -8,6 +8,8 @@ function func_exit_handler() { local exit_status=${1:-0} + dlogi "Starting func_exit_handler($exit_status)" + # call trace if [ "$exit_status" -ne 0 ] ; then dloge "Starting ${FUNCNAME[0]}(), exit status=$exit_status, FUNCNAME stack:" @@ -86,22 +88,6 @@ function func_exit_handler() exit_status=1 fi - if test -e "$logfile"; then - - wcLog=$(wc -l "$logfile") # show both line count and filename - dlogi "nlines=$wcLog" - - local nlines; nlines=$(wc -l < "$logfile") # line count only - # The first line is the sof-logger header - if [ "$nlines" -le 1 ]; then - dloge "Empty logger trace" - exit_status=1 - fi - else - dloge "Log file not found: $logfile" - exit_status=1 - fi - fi if [ "$SOF_LOGGING" != 'none' ] && is_ipc4 && is_firmware_file_zephyr; then @@ -113,6 +99,24 @@ function func_exit_handler() } fi + # Check $logfile when there is one + if [ -n "$logfile" ]; then + if test -e "$logfile"; then + wcLog=$(wc -l "$logfile") # show both line count and filename + dlogi "nlines=$wcLog" + + local nlines; nlines=$(wc -l < "$logfile") # line count only + # The first line is the sof-logger banner + if [ "$nlines" -le 1 ]; then + dloge "Empty logfile" + exit_status=1 + fi + else + dloge "Log file not found: $logfile" + exit_status=1 + fi + fi + stop_test || exit_status=1 if [ "$ENABLE_STORAGE_CHECKS" = '1' ]; then diff --git a/case-lib/lib.sh b/case-lib/lib.sh index f07107a2..23314248 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -321,7 +321,7 @@ find_ldc_file() func_mtrace_collect() { - local clogfile=$LOG_ROOT/mtrace.txt + local clogfile="$1" if [ -z "$MTRACE" ]; then MTRACE=$(command -v mtrace-reader.py) || { @@ -330,8 +330,8 @@ func_mtrace_collect() } fi - local mtraceCmd="$MTRACE" - dlogi "Starting ${mtraceCmd[*]}" + local mtraceCmd=("$MTRACE") + dlogi "Starting ${mtraceCmd[*]} >& $clogfile &" # Cleaned up by func_exit_handler() in hijack.sh # shellcheck disable=SC2024 sudo "${mtraceCmd[@]}" >& "$clogfile" & @@ -358,7 +358,7 @@ func_sof_logger_collect() # The logger does not like empty '' arguments and $logopt can be # shellcheck disable=SC2206 local loggerCmd=("$SOFLOGGER" $logopt -l "$ldcFile") - dlogi "Starting ${loggerCmd[*]}" + dlogi "Starting ${loggerCmd[*]} > $logfile &" # Cleaned up by func_exit_handler() in hijack.sh # shellcheck disable=SC2024 sudo "${loggerCmd[@]}" > "$logfile" & @@ -398,7 +398,8 @@ func_lib_start_log_collect() if [ "X$is_etrace" == "X0" ]; then if is_ipc4 && is_firmware_file_zephyr; then - func_mtrace_collect + logfile="$LOG_ROOT"/mtrace.txt + func_mtrace_collect "$logfile" else log_file=$LOG_ROOT/slogger.txt log_opt="-t" @@ -416,7 +417,7 @@ func_lib_start_log_collect() } -check_error_in_file() +check_error_in_fw_logfile() { local platf; platf=$(sof-dump-status.py -p) diff --git a/test-case/check-sof-logger.sh b/test-case/check-sof-logger.sh index d341c849..aacad43d 100755 --- a/test-case/check-sof-logger.sh +++ b/test-case/check-sof-logger.sh @@ -328,7 +328,7 @@ main() for f in "${stdout_files[@]}"; do local tracef="$LOG_ROOT/logger.$f.txt" - check_error_in_file "$tracef" || { + check_error_in_fw_logfile "$tracef" || { OK=false; printf '\n' } done