summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/net/route/t_flags.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/net/route/t_flags.sh')
-rwxr-xr-xcontrib/netbsd-tests/net/route/t_flags.sh116
1 files changed, 35 insertions, 81 deletions
diff --git a/contrib/netbsd-tests/net/route/t_flags.sh b/contrib/netbsd-tests/net/route/t_flags.sh
index 26625bb..457e3f5 100755
--- a/contrib/netbsd-tests/net/route/t_flags.sh
+++ b/contrib/netbsd-tests/net/route/t_flags.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_flags.sh,v 1.11 2016/08/10 23:00:39 roy Exp $
+# $NetBSD: t_flags.sh,v 1.15 2016/12/21 02:46:08 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,27 +25,24 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-netserver=\
-"rump_server -lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet \
- -lrumpnet_shmif"
SOCK_LOCAL=unix://commsock1
SOCK_PEER=unix://commsock2
SOCK_GW=unix://commsock3
BUS=bus1
BUS2=bus2
-DEBUG=false
+DEBUG=${DEBUG:-false}
setup_local()
{
- atf_check -s exit:0 ${netserver} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
export RUMP_SERVER=$SOCK_LOCAL
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.2/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -rn -f inet
@@ -54,13 +51,13 @@ setup_local()
setup_peer()
{
- atf_check -s exit:0 ${netserver} ${SOCK_PEER}
+ rump_server_start $SOCK_PEER
+ rump_server_add_iface $SOCK_PEER shmif0 $BUS
export RUMP_SERVER=$SOCK_PEER
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.1/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -rn -f inet
@@ -69,16 +66,14 @@ setup_peer()
setup_gw()
{
- atf_check -s exit:0 ${netserver} ${SOCK_GW}
+ rump_server_start $SOCK_GW
+ rump_server_add_iface $SOCK_GW shmif0 $BUS
+ rump_server_add_iface $SOCK_GW shmif1 $BUS2
export RUMP_SERVER=$SOCK_GW
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.254/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 linkstr ${BUS2}
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 10.0.2.1/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 alias 10.0.2.2/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up
@@ -91,46 +86,13 @@ setup_gw()
$DEBUG && rump.netstat -rn -f inet
}
-teardown_gw()
-{
-
- env RUMP_SERVER=$SOCK_GW rump.halt
-}
-
-check_entry_flags()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2
-
- atf_check -s exit:0 -o match:" $flags " -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
-check_entry_gw()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local gw=$2
-
- atf_check -s exit:0 -o match:" $gw " -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
-check_entry_fail()
-{
- ip=$(echo $1 |sed 's/\./\\./g')
- flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
test_lo()
{
export RUMP_SERVER=$SOCK_LOCAL
# Up, Host, local
- check_entry_flags 127.0.0.1 UHl
+ check_route_flags 127.0.0.1 UHl
}
test_connected()
@@ -139,10 +101,10 @@ test_connected()
export RUMP_SERVER=$SOCK_LOCAL
# Up, Host, LLINFO, local
- check_entry_flags 10.0.0.2 UHl
+ check_route_flags 10.0.0.2 UHl
# Up, Cloning
- check_entry_flags 10.0.0/24 UC
+ check_route_flags 10.0.0/24 UC
}
test_default_gateway()
@@ -154,7 +116,7 @@ test_default_gateway()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
}
test_static()
@@ -167,14 +129,14 @@ test_static()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Static
- check_entry_flags 10.0.1.1 UGHS
+ check_route_flags 10.0.1.1 UGHS
# Static route to network
atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Static
- check_entry_flags 10.0.2/24 UGS
+ check_route_flags 10.0.2/24 UGS
}
test_blackhole()
@@ -193,14 +155,14 @@ test_blackhole()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Blackhole, Static
- check_entry_flags 10.0.0/24 UGBS
+ check_route_flags 10.0.0/24 UGBS
atf_check -s not-exit:0 -o match:'100.0% packet loss' \
rump.ping -n -w 1 -c 1 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Shouldn't be created
- check_entry_fail 10.0.0.1 UH
+ check_route_no_entry 10.0.0.1
}
test_reject()
@@ -215,14 +177,14 @@ test_reject()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Reject, Static
- check_entry_flags 10.0.0/24 UGRS
+ check_route_flags 10.0.0/24 UGRS
atf_check -s not-exit:0 -o ignore -e match:'No route to host' \
rump.ping -n -w 1 -c 1 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Shouldn't be created
- check_entry_fail 10.0.0.1 UH
+ check_route_no_entry 10.0.0.1
# Gateway is lo0 (RTF_GATEWAY)
@@ -234,14 +196,14 @@ test_reject()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Reject, Static
- check_entry_flags 10.0.0/24 UGRS
+ check_route_flags 10.0.0/24 UGRS
atf_check -s not-exit:0 -o ignore -e match:'Network is unreachable' \
rump.ping -n -w 1 -c 1 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Shouldn't be created
- check_entry_fail 10.0.0.1 UH
+ check_route_no_entry 10.0.0.1
# Gateway is lo0 (RTF_HOST)
@@ -253,7 +215,7 @@ test_reject()
$DEBUG && rump.netstat -rn -f inet
# Up, Host, Reject, Static
- check_entry_flags 10.0.0.1 UHRS
+ check_route_flags 10.0.0.1 UHRS
atf_check -s not-exit:0 -o ignore -e match:'No route to host' \
rump.ping -n -w 1 -c 1 10.0.0.1
@@ -278,7 +240,7 @@ test_icmp_redirect()
export RUMP_SERVER=$SOCK_PEER
atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254
# Up, Gateway, Static
- check_entry_flags 10.0.2/24 UGS
+ check_route_flags 10.0.2/24 UGS
#
# Setup the default gateway to the peer, 10.0.0.1
@@ -286,15 +248,15 @@ test_icmp_redirect()
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
# Try ping 10.0.2.1
atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.1
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Dynamic
- check_entry_flags 10.0.2.1 UGHD
- check_entry_gw 10.0.2.1 10.0.0.254
+ check_route_flags 10.0.2.1 UGHD
+ check_route_gw 10.0.2.1 10.0.0.254
export RUMP_SERVER=$SOCK_PEER
$DEBUG && rump.netstat -rn -f inet
@@ -307,18 +269,16 @@ test_icmp_redirect()
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route add 10.0.2.2 10.0.0.1
# Up, Gateway, Host, Static
- check_entry_flags 10.0.2.2 UGHS
- check_entry_gw 10.0.2.2 10.0.0.1
+ check_route_flags 10.0.2.2 UGHS
+ check_route_gw 10.0.2.2 10.0.0.1
# Try ping 10.0.2.2
atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.2
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Modified, Static
- check_entry_flags 10.0.2.2 UGHMS
- check_entry_gw 10.0.2.2 10.0.0.254
-
- teardown_gw
+ check_route_flags 10.0.2.2 UGHMS
+ check_route_gw 10.0.2.2 10.0.0.254
}
test_announce()
@@ -332,19 +292,11 @@ test_announce()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Static, proxy
- check_entry_flags 10.0.0/24 UGSp
+ check_route_flags 10.0.0/24 UGSp
# TODO test its behavior
}
-cleanup()
-{
- $DEBUG && /usr/bin/shmif_dumpbus -p - $BUS 2>/dev/null | \
- /usr/sbin/tcpdump -n -e -r -
- env RUMP_SERVER=$SOCK_LOCAL rump.halt
- env RUMP_SERVER=$SOCK_PEER rump.halt
-}
-
add_test()
{
local name=$1
@@ -359,8 +311,10 @@ add_test()
setup_local; \
setup_peer; \
test_${name}; \
+ rump_server_destroy_ifaces; \
}; \
route_flags_${name}_cleanup() { \
+ $DEBUG && dump; \
cleanup; \
}"
atf_add_test_case "route_flags_${name}"
OpenPOWER on IntegriCloud