[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aP-hpxMgB5tN7KJ3@horms.kernel.org>
Date: Mon, 27 Oct 2025 16:45:27 +0000
From: Simon Horman <horms@...nel.org>
To: Bobby Eshleman <bobbyeshleman@...il.com>
Cc: Stefano Garzarella <sgarzare@...hat.com>, Shuah Khan <shuah@...nel.org>,
Jakub Kicinski <kuba@...nel.org>, virtualization@...ts.linux.dev,
netdev@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bobby Eshleman <bobbyeshleman@...a.com>
Subject: Re: [PATCH net-next 01/12] selftests/vsock: improve logging in
vmtest.sh
On Wed, Oct 22, 2025 at 06:00:05PM -0700, Bobby Eshleman wrote:
> From: Bobby Eshleman <bobbyeshleman@...a.com>
>
> Improve usability of logging functions. Remove the test name prefix from
> logging functions so that logging calls can be made deeper into the call
> stack without passing down the test name or setting some global. Teach
> log function to accept a LOG_PREFIX variable to avoid unnecessary
> argument shifting.
>
> Remove log_setup() and instead use log_host(). The host/guest prefixes
> are useful to show whether a failure happened on the guest or host side,
> but "setup" doesn't really give additional useful information. Since all
> log_setup() calls happen on the host, lets just use log_host() instead.
>
> Signed-off-by: Bobby Eshleman <bobbyeshleman@...a.com>
...
> log() {
> - local prefix="$1"
> + local redirect
> + local prefix
>
> - shift
> - local redirect=
> if [[ ${VERBOSE} -eq 0 ]]; then
> redirect=/dev/null
> else
> redirect=/dev/stdout
> fi
>
> + prefix="${LOG_PREFIX:-}"
> +
> if [[ "$#" -eq 0 ]]; then
> - __log_stdin | tee -a "${LOG}" > ${redirect}
> + if [[ -n "${prefix}" ]]; then
> + cat | awk -v prefix="${prefix}" '{printf "%s: %s\n", prefix, $0}'
FIWIIW, I would drop cat from this line.
> + else
> + cat
> + fi
> else
> - __log_args "$@" | tee -a "${LOG}" > ${redirect}
> - fi
> -}
> -
> -log_setup() {
> - log "setup" "$@"
> + if [[ -n "${prefix}" ]]; then
> + echo "${prefix}: " "$@"
> + else
> + echo "$@"
> + fi
> + fi | tee -a "${LOG}" > ${redirect}
> }
>
> log_host() {
> - local testname=$1
> -
> - shift
> - log "test:${testname}:host" "$@"
> + LOG_PREFIX=host log $@
shellcheck suggests keeping the quoting of $@.
This seems reasonable to me. Although in practice I don't think
it will change the behaviour of this script.
> }
> log_host
> log_guest() {
> - local testname=$1
> -
> - shift
> - log "test:${testname}:guest" "$@"
> + LOG_PREFIX=guest log $@
shellcheck also points out that log_guest is never passed
arguments, so $@ can be dropped. If you prefer to keep
it then, as per log_host, it seems reasonable for it to be quoted.
> }
...
Powered by blists - more mailing lists