Re: [PATCH net-next 02/10] selftests: forwarding: lib.sh: Validate NETIFS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 12, 2024 at 07:03:05PM +0200, Petr Machata wrote:
> 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@xxxxxxxxxx>
> Reviewed-by: Benjamin Poirier <bpoirier@xxxxxxxxxx>
> ---
>  tools/testing/selftests/net/forwarding/lib.sh | 22 ++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 658e4e7bf4b9..3cbbc2fd4d7d 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -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
>  
> @@ -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
> -- 
> 2.43.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@xxxxxxxxx>




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux