selftests: Add ipv4 runtime tests to fcnal-test
authorDavid Ahern <dsahern@gmail.com>
Thu, 1 Aug 2019 18:56:44 +0000 (11:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Aug 2019 17:42:04 +0000 (10:42 -0700)
Add runtime tests where passive (no traffic flowing) and active (with
traffic) sockets are expected to be reset on device deletes.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/fcnal-test.sh

index 48e74d62e0093af970d30896a6844f58e70f9987..b8bdab733ecd6667f25922daecc934434ff83935 100755 (executable)
@@ -1508,6 +1508,188 @@ ipv4_addr_bind()
        ipv4_addr_bind_vrf
 }
 
+################################################################################
+# IPv4 runtime tests
+
+ipv4_rt()
+{
+       local desc="$1"
+       local varg="$2"
+       local with_vrf="yes"
+       local a
+
+       #
+       # server tests
+       #
+       for a in ${NSA_IP} ${VRF_IP}
+       do
+               log_start
+               run_cmd nettest ${varg} -s &
+               sleep 1
+               run_cmd_nsb nettest ${varg} -r ${a} &
+               sleep 3
+               run_cmd ip link del ${VRF}
+               sleep 1
+               log_test_addr ${a} 0 0 "${desc}, global server"
+
+               setup ${with_vrf}
+       done
+
+       for a in ${NSA_IP} ${VRF_IP}
+       do
+               log_start
+               run_cmd nettest ${varg} -s -d ${VRF} &
+               sleep 1
+               run_cmd_nsb nettest ${varg} -r ${a} &
+               sleep 3
+               run_cmd ip link del ${VRF}
+               sleep 1
+               log_test_addr ${a} 0 0 "${desc}, VRF server"
+
+               setup ${with_vrf}
+       done
+
+       a=${NSA_IP}
+       log_start
+       run_cmd nettest ${varg} -s -d ${NSA_DEV} &
+       sleep 1
+       run_cmd_nsb nettest ${varg} -r ${a} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "${desc}, enslaved device server"
+
+       setup ${with_vrf}
+
+       #
+       # client test
+       #
+       log_start
+       run_cmd_nsb nettest ${varg} -s &
+       sleep 1
+       run_cmd nettest ${varg} -d ${VRF} -r ${NSB_IP} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "${desc}, VRF client"
+
+       setup ${with_vrf}
+
+       log_start
+       run_cmd_nsb nettest ${varg} -s &
+       sleep 1
+       run_cmd nettest ${varg} -d ${NSA_DEV} -r ${NSB_IP} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "${desc}, enslaved device client"
+
+       setup ${with_vrf}
+
+       #
+       # local address tests
+       #
+       for a in ${NSA_IP} ${VRF_IP}
+       do
+               log_start
+               run_cmd nettest ${varg} -s &
+               sleep 1
+               run_cmd nettest ${varg} -d ${VRF} -r ${a} &
+               sleep 3
+               run_cmd ip link del ${VRF}
+               sleep 1
+               log_test_addr ${a} 0 0 "${desc}, global server, VRF client, local"
+
+               setup ${with_vrf}
+       done
+
+       for a in ${NSA_IP} ${VRF_IP}
+       do
+               log_start
+               run_cmd nettest ${varg} -d ${VRF} -s &
+               sleep 1
+               run_cmd nettest ${varg} -d ${VRF} -r ${a} &
+               sleep 3
+               run_cmd ip link del ${VRF}
+               sleep 1
+               log_test_addr ${a} 0 0 "${desc}, VRF server and client, local"
+
+               setup ${with_vrf}
+       done
+
+       a=${NSA_IP}
+       log_start
+       run_cmd nettest ${varg} -s &
+       sleep 1
+       run_cmd nettest ${varg} -d ${NSA_DEV} -r ${a} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "${desc}, global server, enslaved device client, local"
+
+       setup ${with_vrf}
+
+       log_start
+       run_cmd nettest ${varg} -d ${VRF} -s &
+       sleep 1
+       run_cmd nettest ${varg} -d ${NSA_DEV} -r ${a} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "${desc}, VRF server, enslaved device client, local"
+
+       setup ${with_vrf}
+
+       log_start
+       run_cmd nettest ${varg} -d ${NSA_DEV} -s &
+       sleep 1
+       run_cmd nettest ${varg} -d ${NSA_DEV} -r ${a} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "${desc}, enslaved device server and client, local"
+}
+
+ipv4_ping_rt()
+{
+       local with_vrf="yes"
+       local a
+
+       for a in ${NSA_IP} ${VRF_IP}
+       do
+               log_start
+               run_cmd_nsb ping -f ${a} &
+               sleep 3
+               run_cmd ip link del ${VRF}
+               sleep 1
+               log_test_addr ${a} 0 0 "Device delete with active traffic - ping in"
+
+               setup ${with_vrf}
+       done
+
+       a=${NSB_IP}
+       log_start
+       run_cmd ping -f -I ${VRF} ${a} &
+       sleep 3
+       run_cmd ip link del ${VRF}
+       sleep 1
+       log_test_addr ${a} 0 0 "Device delete with active traffic - ping out"
+}
+
+ipv4_runtime()
+{
+       log_section "Run time tests - ipv4"
+
+       setup "yes"
+       ipv4_ping_rt
+
+       setup "yes"
+       ipv4_rt "TCP active socket"  "-n -1"
+
+       setup "yes"
+       ipv4_rt "TCP passive socket" "-i"
+}
+
 ################################################################################
 # IPv6
 
@@ -2772,7 +2954,7 @@ EOF
 ################################################################################
 # main
 
-TESTS_IPV4="ipv4_ping ipv4_tcp ipv4_udp ipv4_addr_bind"
+TESTS_IPV4="ipv4_ping ipv4_tcp ipv4_udp ipv4_addr_bind ipv4_runtime"
 TESTS_IPV6="ipv6_ping ipv6_tcp ipv6_udp ipv6_addr_bind"
 PAUSE_ON_FAIL=no
 PAUSE=no
@@ -2815,6 +2997,7 @@ do
        ipv4_tcp|tcp)    ipv4_tcp;;
        ipv4_udp|udp)    ipv4_udp;;
        ipv4_bind|bind)  ipv4_addr_bind;;
+       ipv4_runtime)    ipv4_runtime;;
 
        ipv6_ping|ping6) ipv6_ping;;
        ipv6_tcp|tcp6)   ipv6_tcp;;