Skip to content

Commit

Permalink
selftests: forwarding: lib.sh: Validate NETIFS
Browse files Browse the repository at this point in the history
The variable should contain at least NUM_NETIFS interfaces, stored
as keys named "p$i", for i in `seq $NUM_NETIFS`.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Benjamin Poirier <bpoirier@nvidia.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Petr Machata authored and Paolo Abeni committed Apr 16, 2024
1 parent a4022a3 commit 2291752
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ if [[ "$REQUIRE_MTOOLS" = "yes" ]]; then
require_command mreceive
fi

if [[ ! -v NUM_NETIFS ]]; then
echo "SKIP: importer does not define \"NUM_NETIFS\""
exit $ksft_skip
fi

##############################################################################
# Command line options handling

Expand All @@ -296,6 +291,23 @@ done
##############################################################################
# Network interfaces configuration

if [[ ! -v NUM_NETIFS ]]; then
echo "SKIP: importer does not define \"NUM_NETIFS\""
exit $ksft_skip
fi

if (( NUM_NETIFS > ${#NETIFS[@]} )); then
echo "SKIP: Importer requires $NUM_NETIFS NETIFS, but only ${#NETIFS[@]} are defined (${NETIFS[@]})"
exit $ksft_skip
fi

for i in $(seq ${#NETIFS[@]}); do
if [[ ! ${NETIFS[p$i]} ]]; then
echo "SKIP: NETIFS[p$i] not given"
exit $ksft_skip
fi
done

create_netif_veth()
{
local i
Expand Down

0 comments on commit 2291752

Please sign in to comment.