Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net Move route check functions to net_common.sh
details: https://anonhg.NetBSD.org/src/rev/eb5c75006496
branches: trunk
changeset: 349110:eb5c75006496
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Nov 24 09:05:16 2016 +0000
description:
Move route check functions to net_common.sh
diffstat:
tests/net/icmp/t_icmp_redirect.sh | 53 ++++++---------------------
tests/net/net/t_ipaddress.sh | 68 +++++++++---------------------------
tests/net/net_common.sh | 40 ++++++++++++++++++++-
tests/net/route/Makefile | 8 +++-
tests/net/route/t_flags.sh | 73 ++++++++++++--------------------------
tests/net/route/t_flags6.sh | 59 ++++++++----------------------
6 files changed, 114 insertions(+), 187 deletions(-)
diffs (truncated from 710 to 300 lines):
diff -r f25d537a1079 -r eb5c75006496 tests/net/icmp/t_icmp_redirect.sh
--- a/tests/net/icmp/t_icmp_redirect.sh Thu Nov 24 09:03:53 2016 +0000
+++ b/tests/net/icmp/t_icmp_redirect.sh Thu Nov 24 09:05:16 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_icmp_redirect.sh,v 1.4 2016/11/07 05:25:36 ozaki-r Exp $
+# $NetBSD: t_icmp_redirect.sh,v 1.5 2016/11/24 09:05:16 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -111,33 +111,6 @@
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()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
icmp_redirect_timeout_body()
{
@@ -159,7 +132,7 @@
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
@@ -167,20 +140,20 @@
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
atf_check -s exit:0 sleep $((REDIRECT_TIMEOUT + 2))
# The dynamic entry should be expired and removed
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
export RUMP_SERVER=$SOCK_PEER
$DEBUG && rump.netstat -rn -f inet
@@ -249,7 +222,7 @@
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
@@ -257,7 +230,7 @@
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
### ICMP redirects are NOT sent by the peer ###
@@ -274,7 +247,7 @@
$DEBUG && rump.netstat -rn -f inet
# A direct route shouldn't be created
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
### ICMP redirects are sent by the peer ###
@@ -291,8 +264,8 @@
$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
@@ -301,7 +274,7 @@
# cleanup
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route delete 10.0.2.1
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
### ICMP redirects are NOT sent by the peer (again) ###
@@ -318,7 +291,7 @@
$DEBUG && rump.netstat -rn -f inet
# A direct route shouldn't be created
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
teardown_gw
diff -r f25d537a1079 -r eb5c75006496 tests/net/net/t_ipaddress.sh
--- a/tests/net/net/t_ipaddress.sh Thu Nov 24 09:03:53 2016 +0000
+++ b/tests/net/net/t_ipaddress.sh Thu Nov 24 09:05:16 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipaddress.sh,v 1.6 2016/11/24 07:32:19 ozaki-r Exp $
+# $NetBSD: t_ipaddress.sh,v 1.7 2016/11/24 09:05:17 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -32,24 +32,6 @@
DEBUG=${DEBUG:-false}
-check_entry()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local word=$2
-
- atf_check -s exit:0 -o match:"$word" -e ignore -x \
- "rump.netstat -rn | grep ^'$ip'"
-}
-
-check_entry_fail()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn | grep ^'$ip'"
-}
-
test_same_address()
{
local ip=10.0.0.1
@@ -66,20 +48,16 @@
$DEBUG && rump.netstat -nr -f inet
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net UC
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
$DEBUG && rump.netstat -nr -f inet
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
# Assign the same address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
@@ -87,20 +65,16 @@
$DEBUG && rump.netstat -nr -f inet
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net UC
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
$DEBUG && rump.netstat -nr -f inet
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
}
test_same_address6()
@@ -119,20 +93,16 @@
$DEBUG && rump.netstat -nr -f inet6
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net UC
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
$DEBUG && rump.netstat -nr -f inet6
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
# Assign the same address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
@@ -140,20 +110,16 @@
$DEBUG && rump.netstat -nr -f inet6
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net UC
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
$DEBUG && rump.netstat -nr -f inet6
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
}
test_auto_linklocal()
diff -r f25d537a1079 -r eb5c75006496 tests/net/net_common.sh
--- a/tests/net/net_common.sh Thu Nov 24 09:03:53 2016 +0000
+++ b/tests/net/net_common.sh Thu Nov 24 09:05:16 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: net_common.sh,v 1.2 2016/11/24 09:03:53 ozaki-r Exp $
+# $NetBSD: net_common.sh,v 1.3 2016/11/24 09:05:16 ozaki-r Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -47,3 +47,41 @@
cat ./.__diff
}
+check_route()
+{
+ local target=$1
+ local gw=$2
+ local flags=${3:-\.\+}
+ local ifname=${4:-\.\+}
+
+ target=$(echo $target |sed 's/\./\\./g')
+ if [ "$gw" = "" ]; then
+ gw=".+"
+ else
+ gw=$(echo $gw |sed 's/\./\\./g')
+ fi
+
+ atf_check -s exit:0 -e ignore \
+ -o match:"^$target +$gw +$flags +- +- +.+ +$ifname" \
+ rump.netstat -rn
+}
+
+check_route_flags()
Home |
Main Index |
Thread Index |
Old Index