Netdev List
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Ido Schimmel <idosch@nvidia.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, edumazet@google.com, donald.hunter@gmail.com,
	petrm@nvidia.com, razor@blackwall.org, daniel@iogearbox.net
Subject: Re: [PATCH net-next 2/2] selftests: net: Add a selftest for externally validated neighbor entries
Date: Sat, 14 Jun 2025 18:11:30 +0100	[thread overview]
Message-ID: <20250614171130.GA861417@horms.kernel.org> (raw)
In-Reply-To: <20250611141551.462569-3-idosch@nvidia.com>

On Wed, Jun 11, 2025 at 05:15:51PM +0300, Ido Schimmel wrote:
> Add test cases for externally validated neighbor entries, testing both
> IPv4 and IPv6. Name the file "test_neigh.sh" so that it could be
> possibly extended in the future with more neighbor test cases.
> 
> Example output:
> 
>  # ./test_neigh.sh
>  TEST: IPv4 "extern_valid" flag: Add entry                           [ OK ]
>  TEST: IPv4 "extern_valid" flag: Add with an invalid state           [ OK ]
>  TEST: IPv4 "extern_valid" flag: Add with "use" flag                 [ OK ]
>  TEST: IPv4 "extern_valid" flag: Replace entry                       [ OK ]
>  TEST: IPv4 "extern_valid" flag: Replace entry with "managed" flag   [ OK ]
>  TEST: IPv4 "extern_valid" flag: Replace with an invalid state       [ OK ]
>  TEST: IPv4 "extern_valid" flag: Transition to "reachable" state     [ OK ]
>  TEST: IPv4 "extern_valid" flag: Transition back to "stale" state    [ OK ]
>  TEST: IPv4 "extern_valid" flag: Forced garbage collection           [ OK ]
>  TEST: IPv4 "extern_valid" flag: Periodic garbage collection         [ OK ]
>  TEST: IPv6 "extern_valid" flag: Add entry                           [ OK ]
>  TEST: IPv6 "extern_valid" flag: Add with an invalid state           [ OK ]
>  TEST: IPv6 "extern_valid" flag: Add with "use" flag                 [ OK ]
>  TEST: IPv6 "extern_valid" flag: Replace entry                       [ OK ]
>  TEST: IPv6 "extern_valid" flag: Replace entry with "managed" flag   [ OK ]
>  TEST: IPv6 "extern_valid" flag: Replace with an invalid state       [ OK ]
>  TEST: IPv6 "extern_valid" flag: Transition to "reachable" state     [ OK ]
>  TEST: IPv6 "extern_valid" flag: Transition back to "stale" state    [ OK ]
>  TEST: IPv6 "extern_valid" flag: Forced garbage collection           [ OK ]
>  TEST: IPv6 "extern_valid" flag: Periodic garbage collection         [ OK ]
> 
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>

...

> diff --git a/tools/testing/selftests/net/test_neigh.sh b/tools/testing/selftests/net/test_neigh.sh

...

> +################################################################################
> +# Utilities
> +
> +run_cmd()
> +{
> +	local cmd="$1"
> +	local out
> +	local stderr="2>/dev/null"
> +
> +	if [ "$VERBOSE" = "1" ]; then
> +		printf "COMMAND: $cmd\n"
> +		stderr=
> +	fi

Hi Ido,

shellcheck was recently added to NIPA and it warns about the above as follows.
Could you consider addressing this?

In tools/testing/selftests/net/test_neigh.sh line 21:
 		printf "COMMAND: $cmd\n"
                        ^---------------^ SC2059 (info): Don't use variables in the printf format string. Use printf '..%s..' "$foo".

> +
> +	out=$(eval $cmd $stderr)
> +	rc=$?
> +	if [ "$VERBOSE" -eq 1 ] && [ -n "$out" ]; then
> +		echo "    $out"
> +	fi
> +
> +	return $rc
> +}

...

> +################################################################################
> +# Main
> +
> +while getopts ":t:pvh" opt; do
> +	case $opt in
> +		t) TESTS=$OPTARG;;
> +		p) PAUSE_ON_FAIL=yes;;
> +		v) VERBOSE=$(($VERBOSE + 1));;
> +		h) usage; exit 0;;
> +		*) usage; exit 1;;
> +	esac
> +done

Likewise, shellcheck has the following to say about the above.

In tools/testing/selftests/net/test_neigh.sh line 318:
		v) VERBOSE=$(($VERBOSE + 1));;
                              ^------^ SC2004 (style): $/${} is unnecessary on arithmetic variables.

> +
> +require_command jq
> +
> +ip neigh help 2>&1 | grep -q "extern_valid"
> +if [ $? -ne 0 ]; then
> +   echo "SKIP: iproute2 ip too old, missing \"extern_valid\" support"
> +   exit $ksft_skip
> +fi
> +
> +trap exit_cleanup_all EXIT
> +
> +for t in $TESTS
> +do
> +	setup; $t; cleanup_all_ns;
> +done
> -- 
> 2.49.0
> 

-- 
pw-bot: cr

      parent reply	other threads:[~2025-06-14 17:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 14:15 [PATCH net-next 0/2] Add support for externally validated neighbor entries Ido Schimmel
2025-06-11 14:15 ` [PATCH net-next 1/2] neighbor: Add NTF_EXT_VALIDATED flag for externally validated entries Ido Schimmel
2025-06-12 10:26   ` Nikolay Aleksandrov
2025-06-13  8:23   ` Daniel Borkmann
2025-06-17 14:09     ` Ido Schimmel
2025-06-17 14:21       ` Daniel Borkmann
2025-06-14 17:13   ` Simon Horman
2025-06-11 14:15 ` [PATCH net-next 2/2] selftests: net: Add a selftest for externally validated neighbor entries Ido Schimmel
2025-06-12 10:26   ` Nikolay Aleksandrov
2025-06-14 17:11   ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250614171130.GA861417@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=razor@blackwall.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox