summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIoana Ciornei <ioana.ciornei@nxp.com>2026-04-07 13:20:58 +0300
committerJakub Kicinski <kuba@kernel.org>2026-04-09 05:26:44 +0300
commitfff75dba7992d8f63d4df8796baf8114015842cc (patch)
tree00593c5bd017877442bafacc3705806fd109b850
parent686a7587bd0be9407f5ea748edf3d8bb00e5bc72 (diff)
downloadlinux-fff75dba7992d8f63d4df8796baf8114015842cc.tar.xz
selftests: forwarding: lib: rewrite processing of command line arguments
The piece of code which processes the command line arguments and populates NETIFS based on them is really unobvious. Rewrite it so that the intention is clear and the code is easy to follow. Suggested-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Petr Machata <petrm@nvidia.com> Link: https://patch.msgid.link/20260407102058.867279-1-ioana.ciornei@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--tools/testing/selftests/net/forwarding/lib.sh21
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index d8cc4c64148d..d2bdbff68075 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -467,17 +467,18 @@ if [ "${DRIVER_TEST_CONFORMANT}" = "yes" ]; then
TARGETS[$remote_netif]="$REMOTE_TYPE:$REMOTE_ARGS"
else
count=0
+ # Prime NETIFS from the command line, but retain if none given.
+ if [[ $# -gt 0 ]]; then
+ unset NETIFS
+ declare -A NETIFS
- while [[ $# -gt 0 ]]; do
- if [[ "$count" -eq "0" ]]; then
- unset NETIFS
- declare -A NETIFS
- fi
- count=$((count + 1))
- NETIFS[p$count]="$1"
- TARGETS[$1]="local:"
- shift
- done
+ while [[ $# -gt 0 ]]; do
+ count=$((count + 1))
+ NETIFS[p$count]="$1"
+ TARGETS[$1]="local:"
+ shift
+ done
+ fi
fi
##############################################################################