From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ido Schimmel Subject: [PATCH net-next 02/18] selftests: forwarding: lib: Support NUM_NETIFS of 0 Date: Mon, 19 Nov 2018 16:11:08 +0000 Message-ID: <20181119161006.5405-3-idosch@mellanox.com> References: <20181119161006.5405-1-idosch@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "davem@davemloft.net" , "shuah@kernel.org" , Jiri Pirko , Petr Machata , "roopa@cumulusnetworks.com" , mlxsw , Ido Schimmel To: "netdev@vger.kernel.org" , "linux-kselftest@vger.kernel.org" Return-path: Received: from mail-eopbgr140072.outbound.protection.outlook.com ([40.107.14.72]:6759 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729922AbeKTCfW (ORCPT ); Mon, 19 Nov 2018 21:35:22 -0500 In-Reply-To: <20181119161006.5405-1-idosch@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: From: Petr Machata So far the case of NUM_NETIFS of 0 has not been interesting. However if one wishes to reuse the lib.sh routines in a setup of a separate namespace, being able to import like this is handy. Therefore replace the {1..$NUM_NETIFS} references, which cause iteration over 1 and 0, with an explicit for loop like we do in setup_wait() and tc_offload_check(), so that for NUM_NETIFS of 0 no iteration is done. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/= selftests/net/forwarding/lib.sh index 85d253546684..bb0e9fdf893e 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -104,7 +104,7 @@ create_netif_veth() { local i =20 - for i in $(eval echo {1..$NUM_NETIFS}); do + for ((i =3D 1; i <=3D NUM_NETIFS; ++i)); do local j=3D$((i+1)) =20 ip link show dev ${NETIFS[p$i]} &> /dev/null @@ -135,7 +135,7 @@ if [[ "$NETIF_CREATE" =3D "yes" ]]; then create_netif fi =20 -for i in $(eval echo {1..$NUM_NETIFS}); do +for ((i =3D 1; i <=3D NUM_NETIFS; ++i)); do ip link show dev ${NETIFS[p$i]} &> /dev/null if [[ $? -ne 0 ]]; then echo "SKIP: could not find all required interfaces" --=20 2.19.1