Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions case-lib/hijack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,23 @@ function func_exit_handler()
func_lib_start_log_collect 1
sleep 1s
}
local loggerBin; loggerBin=$(basename "$SOFLOGGER")
sudo pkill -9 "$loggerBin" 2>/dev/null || {

local loggerBin wcLog; loggerBin=$(basename "$SOFLOGGER")
# INT doesn't print any "Killed" message in non-interactive mode
sudo pkill -INT "$loggerBin" || {
dloge "sof-logger was already dead"
exit_status=1
}
sleep 1s
if pgrep "$loggerBin"; then
dloge "$loggerBin resisted pkill -INT, using -KILL"
sudo pkill -KILL "$loggerBin"
exit_status=2
fi
# logfile is set in a different file: lib.sh
# shellcheck disable=SC2154
wcLog=$(wc -l "$logfile")
dlogi "nlines=$wcLog"
fi
# when case ends, store kernel log
# /var/log/kern.log format:
Expand Down
26 changes: 20 additions & 6 deletions case-lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,39 @@ func_lib_start_log_collect()
return 1
}

local loggerBin="" logfile="" logopt="-t"
[[ "$SOFLOGGER" ]] && loggerBin=$SOFLOGGER || loggerBin=$(command -v sof-logger)
local logopt="-t"

if [ -z "$SOFLOGGER" ]; then
SOFLOGGER=$(command -v sof-logger) || {
dlogw 'No sof-logger found in PATH'
return 1
}
fi

test -x "$SOFLOGGER" || {
dlogw "$SOFLOGGER not found or not executable"
return 2
}

if [ "X$is_etrace" == "X0" ];then
logfile=$LOG_ROOT/slogger.txt
else
logfile=$LOG_ROOT/etrace.txt
logopt=""
fi
[[ ! "$loggerBin" ]] && return
SOFLOGGER=$loggerBin

if func_hijack_setup_sudo_level ;then
# shellcheck disable=SC2034 # external script will use it
SOF_LOG_COLLECT=1
else
>&2 dlogw "without sudo permission to run $SOFLOGGER command"
return
return 3
fi

sudo "$loggerBin $logopt -l $ldcFile -o $logfile" 2>/dev/null &
local loggerCmd="$SOFLOGGER $logopt -l $ldcFile -o $logfile"
dlogi "Starting $loggerCmd"
# Cleaned up by func_exit_handler() in hijack.sh
sudo "$loggerCmd" &
}

func_lib_check_sudo()
Expand Down