Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add tests for a gateway not on the local subnet
details: https://anonhg.NetBSD.org/src/rev/e7244a3e40f0
branches: trunk
changeset: 343301:e7244a3e40f0
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Jan 29 04:15:46 2016 +0000
description:
Add tests for a gateway not on the local subnet
The tests are derived from the example at
http://www.netbsd.org/docs/network/#nonsubnetgateway ,
which has come up in PR 50717.
diffstat:
distrib/sets/lists/tests/mi | 3 +-
tests/net/route/Makefile | 4 +-
tests/net/route/t_route.sh | 103 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+), 3 deletions(-)
diffs (140 lines):
diff -r 8755f65c26ee -r e7244a3e40f0 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Fri Jan 29 02:40:22 2016 +0000
+++ b/distrib/sets/lists/tests/mi Fri Jan 29 04:15:46 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.660 2016/01/25 03:14:29 jnemeth Exp $
+# $NetBSD: mi,v 1.661 2016/01/29 04:15:46 ozaki-r Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -3221,6 +3221,7 @@
./usr/tests/net/route/Kyuafile tests-net-tests atf,rump,kyua
./usr/tests/net/route/t_change tests-net-tests atf,rump
./usr/tests/net/route/t_flags tests-net-tests atf,rump
+./usr/tests/net/route/t_route tests-net-tests atf,rump
./usr/tests/net/sys tests-net-tests compattestfile,atf
./usr/tests/net/sys/Atffile tests-net-tests compattestfile,atf
./usr/tests/net/sys/Kyuafile tests-net-tests compattestfile,atf,kyua
diff -r 8755f65c26ee -r e7244a3e40f0 tests/net/route/Makefile
--- a/tests/net/route/Makefile Fri Jan 29 02:40:22 2016 +0000
+++ b/tests/net/route/Makefile Fri Jan 29 04:15:46 2016 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.2 2015/05/18 06:27:04 ozaki-r Exp $
+# $NetBSD: Makefile,v 1.3 2016/01/29 04:15:46 ozaki-r Exp $
#
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/net/route
-TESTS_SH= t_change t_flags
+TESTS_SH= t_change t_flags t_route
.include <bsd.test.mk>
diff -r 8755f65c26ee -r e7244a3e40f0 tests/net/route/t_route.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/route/t_route.sh Fri Jan 29 04:15:46 2016 +0000
@@ -0,0 +1,103 @@
+# $NetBSD: t_route.sh,v 1.1 2016/01/29 04:15:46 ozaki-r Exp $
+#
+# Copyright (c) 2016 Internet Initiative Japan Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+RUMP_LIBS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
+SOCK_CLIENT=unix://commsock1
+SOCK_GW=unix://commsock2
+BUS=bus1
+
+DEBUG=false
+TIMEOUT=1
+PING_OPTS="-n -c 1 -w $TIMEOUT"
+
+atf_test_case non_subnet_gateway cleanup
+non_subnet_gateway_head()
+{
+
+ atf_set "descr" "tests of a gateway not on the local subnet"
+ atf_set "require.progs" "rump_server"
+}
+
+non_subnet_gateway_body()
+{
+
+ atf_check -s exit:0 rump_server ${RUMP_LIBS} ${SOCK_CLIENT}
+ atf_check -s exit:0 rump_server ${RUMP_LIBS} ${SOCK_GW}
+
+ export RUMP_SERVER=${SOCK_GW}
+
+ atf_check -s exit:0 rump.ifconfig shmif0 create
+ atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
+ atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+
+ # The gateway knows the client
+ atf_check -s exit:0 -o match:'add net 10.0.0.1: gateway shmif0' \
+ rump.route add -net 10.0.0.1/32 -link -cloning -iface shmif0
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ export RUMP_SERVER=${SOCK_CLIENT}
+
+ atf_check -s exit:0 rump.ifconfig shmif0 create
+ atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
+ atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.1/32
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ # Don't know a route to the gateway yet
+ atf_check -s not-exit:0 -o match:'100.0% packet loss' \
+ -e match:'No route to host' rump.ping $PING_OPTS 192.168.0.1
+
+ # Teach a route to the gateway
+ atf_check -s exit:0 -o match:'add net 192.168.0.1: gateway shmif0' \
+ rump.route add -net 192.168.0.1/32 -link -cloning -iface shmif0
+ atf_check -s exit:0 -o match:'add net default: gateway 192.168.0.1' \
+ rump.route add default -ifa 10.0.0.1 192.168.0.1
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ # Be reachable to the gateway
+ atf_check -s exit:0 -o ignore rump.ping $PING_OPTS 192.168.0.1
+
+ unset RUMP_SERVER
+}
+
+non_subnet_gateway_cleanup()
+{
+
+ $DEBUG && shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r -
+ env RUMP_SERVER=$SOCK_CLIENT rump.halt
+ env RUMP_SERVER=$SOCK_GW rump.halt
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case non_subnet_gateway
+}
Home |
Main Index |
Thread Index |
Old Index