selftests: mlxsw: Use busywait helper in blackhole routes test
authorDanielle Ratson <danieller@mellanox.com>
Thu, 27 Feb 2020 07:50:11 +0000 (08:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Feb 2020 19:10:14 +0000 (11:10 -0800)
Blackhole routes test uses offload indication checks.

Use busywait helper and wait until the routes offload indication is set or
fail if it reaches timeout.

Signed-off-by: Danielle Ratson <danieller@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/mlxsw/blackhole_routes.sh
tools/testing/selftests/net/forwarding/lib.sh

index 5ba5bef44d5b17989dbc6ba22c081c33cce4421c..bdffe698e1d17289f4f59da282ec9cbb420115e4 100755 (executable)
@@ -45,6 +45,7 @@ ALL_TESTS="
        blackhole_ipv6
 "
 NUM_NETIFS=4
+: ${TIMEOUT:=20000} # ms
 source $lib_dir/tc_common.sh
 source $lib_dir/lib.sh
 
@@ -123,7 +124,7 @@ blackhole_ipv4()
                skip_hw dst_ip 198.51.100.1 src_ip 192.0.2.1 ip_proto icmp \
                action pass
 
-       ip -4 route show 198.51.100.0/30 | grep -q offload
+       busywait "$TIMEOUT" wait_for_offload ip -4 route show 198.51.100.0/30
        check_err $? "route not marked as offloaded when should"
 
        ping_do $h1 198.51.100.1
@@ -147,7 +148,7 @@ blackhole_ipv6()
                skip_hw dst_ip 2001:db8:2::1 src_ip 2001:db8:1::1 \
                ip_proto icmpv6 action pass
 
-       ip -6 route show 2001:db8:2::/120 | grep -q offload
+       busywait "$TIMEOUT" wait_for_offload ip -6 route show 2001:db8:2::/120
        check_err $? "route not marked as offloaded when should"
 
        ping6_do $h1 2001:db8:2::1
index aff3178edf6d94cb6d2f4c008bcc80e2842b6193..5ea33c72f46829b7d496ed8450eb715176dba3d7 100644 (file)
@@ -248,6 +248,11 @@ busywait()
        done
 }
 
+wait_for_offload()
+{
+       "$@" | grep -q offload
+}
+
 until_counter_is()
 {
        local value=$1; shift