Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add basic if_gif tests to ATF.



details:   https://anonhg.NetBSD.org/src/rev/46d90fb4d81d
branches:  trunk
changeset: 341406:46d90fb4d81d
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Thu Nov 05 00:02:59 2015 +0000

description:
add basic if_gif tests to ATF.

diffstat:

 distrib/sets/lists/tests/mi |    6 +-
 etc/mtree/NetBSD.dist.tests |    3 +-
 tests/net/Makefile          |    6 +-
 tests/net/if_gif/Makefile   |   10 +
 tests/net/if_gif/t_gif.sh   |  494 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 514 insertions(+), 5 deletions(-)

diffs (truncated from 569 to 300 lines):

diff -r 212026ef7783 -r 46d90fb4d81d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Nov 04 23:57:05 2015 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Nov 05 00:02:59 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.650 2015/10/14 16:33:42 christos Exp $
+# $NetBSD: mi,v 1.651 2015/11/05 00:02:59 knakahara Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3154,6 +3154,10 @@
 ./usr/tests/net/if_bridge/Atffile              tests-net-tests         atf,rump
 ./usr/tests/net/if_bridge/Kyuafile             tests-net-tests         atf,rump,kyua
 ./usr/tests/net/if_bridge/t_bridge             tests-net-tests         atf,rump
+./usr/tests/net/if_gif                         tests-net-tests         compattestfile,atf
+./usr/tests/net/if_gif/Atffile                 tests-net-tests         atf,rump
+./usr/tests/net/if_gif/Kyuafile                        tests-net-tests         atf,rump,kyua
+./usr/tests/net/if_gif/t_gif                   tests-net-tests         atf,rump
 ./usr/tests/net/if_loop                                tests-net-tests         compattestfile,atf
 ./usr/tests/net/if_loop/Atffile                        tests-net-tests         atf,rump
 ./usr/tests/net/if_loop/Kyuafile               tests-net-tests         atf,rump,kyua
diff -r 212026ef7783 -r 46d90fb4d81d etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests       Wed Nov 04 23:57:05 2015 +0000
+++ b/etc/mtree/NetBSD.dist.tests       Thu Nov 05 00:02:59 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.tests,v 1.120 2015/09/24 16:02:39 christos Exp $
+#      $NetBSD: NetBSD.dist.tests,v 1.121 2015/11/05 00:02:59 knakahara Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -318,6 +318,7 @@
 ./usr/tests/net/icmp
 ./usr/tests/net/if
 ./usr/tests/net/if_bridge
+./usr/tests/net/if_gif
 ./usr/tests/net/if_loop
 ./usr/tests/net/in_cksum
 ./usr/tests/net/mcast
diff -r 212026ef7783 -r 46d90fb4d81d tests/net/Makefile
--- a/tests/net/Makefile        Wed Nov 04 23:57:05 2015 +0000
+++ b/tests/net/Makefile        Thu Nov 05 00:02:59 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.25 2015/08/03 09:54:20 ozaki-r Exp $
+# $NetBSD: Makefile,v 1.26 2015/11/05 00:02:59 knakahara Exp $
 
 .include <bsd.own.mk>
 
@@ -6,8 +6,8 @@
 
 TESTS_SUBDIRS=         fdpass in_cksum net sys
 .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
-TESTS_SUBDIRS+=                arp bpf bpfilter carp icmp if if_bridge if_loop mcast
-TESTS_SUBDIRS+=                mpls ndp npf route
+TESTS_SUBDIRS+=                arp bpf bpfilter carp icmp if if_bridge if_gif if_loop
+TESTS_SUBDIRS+=                mcast mpls ndp npf route
 .if (${MKSLJIT} != "no")
 TESTS_SUBDIRS+=                bpfjit
 .endif
diff -r 212026ef7783 -r 46d90fb4d81d tests/net/if_gif/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/if_gif/Makefile Thu Nov 05 00:02:59 2015 +0000
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2015/11/05 00:02:59 knakahara Exp $
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/net/if_gif
+
+TESTS_SH=      t_gif
+
+.include <bsd.test.mk>
diff -r 212026ef7783 -r 46d90fb4d81d tests/net/if_gif/t_gif.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/if_gif/t_gif.sh Thu Nov 05 00:02:59 2015 +0000
@@ -0,0 +1,494 @@
+#! /usr/bin/atf-sh
+#      $NetBSD: t_gif.sh,v 1.1 2015/11/05 00:02:59 knakahara Exp $
+#
+# Copyright (c) 2015 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.
+#
+
+server="rump_server -v -lrumpnet -lrumpnet_net -lrumpnet_netinet \
+                   -lrumpnet_netinet6 -lrumpnet_shmif -lrumpnet_gif"
+
+SOCK1=unix://commsock1 # for ROUTER1
+SOCK2=unix://commsock2 # for ROUTER2
+ROUTER1_LANIP=192.168.1.1
+ROUTER1_LANNET=192.168.1.0/24
+ROUTER1_WANIP=10.0.0.1
+ROUTER1_GIFIP=172.16.1.1
+ROUTER2_LANIP=192.168.2.1
+ROUTER2_LANNET=192.168.2.0/24
+ROUTER2_WANIP=10.0.0.2
+ROUTER2_GIFIP=172.16.2.1
+
+ROUTER1_LANIP6=fc00:1::1
+ROUTER1_LANNET6=fc00:1::/64
+ROUTER1_WANIP6=fc00::1
+ROUTER1_GIFIP6=fc00:3::1
+ROUTER2_LANIP6=fc00:2::1
+ROUTER2_LANNET6=fc00:2::/64
+ROUTER2_WANIP6=fc00::2
+ROUTER2_GIFIP6=fc00:4::1
+
+TIMEOUT=5
+
+atf_test_case basicv4overv4 cleanup
+atf_test_case basicv4overv6 cleanup
+atf_test_case basicv6overv4 cleanup
+atf_test_case basicv6overv6 cleanup
+
+basicv4overv4_head()
+{
+       atf_set "descr" "Does IPv4 over IPv4 if_gif tests"
+       atf_set "require.progs" "rump_server"
+}
+
+basicv4overv6_head()
+{
+       atf_set "descr" "Does IPv4 over IPv6 if_gif tests"
+       atf_set "require.progs" "rump_server"
+}
+
+basicv6overv4_head()
+{
+       atf_set "descr" "Does IPv6 over IPv4 if_gif tests"
+       atf_set "require.progs" "rump_server"
+}
+
+basicv6overv6_head()
+{
+       atf_set "descr" "Does IPv6 over IPv6 if_gif tests"
+       atf_set "require.progs" "rump_server"
+}
+
+setup_router()
+{
+       sock=${1}
+       lan=${2}
+       lan_mode=${3}
+       wan=${4}
+       wan_mode=${5}
+
+       export RUMP_SERVER=${sock}
+       atf_check -s exit:0 rump.ifconfig shmif0 create
+       atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus0
+       if [ ${lan_mode} = "ipv6" ]; then
+               atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${lan}
+       else
+               atf_check -s exit:0 rump.ifconfig shmif0 inet ${lan} netmask 0xffffff00
+       fi
+       atf_check -s exit:0 rump.ifconfig shmif0 up
+       rump.ifconfig shmif0
+
+       atf_check -s exit:0 rump.ifconfig shmif1 create
+       atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus1
+       if [ ${wan_mode} = "ipv6" ]; then
+               atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${wan}
+       else
+               atf_check -s exit:0 rump.ifconfig shmif1 inet ${wan} netmask 0xff000000
+       fi
+       atf_check -s exit:0 rump.ifconfig shmif1 up
+       rump.ifconfig shmif1
+}
+
+test_router()
+{
+       sock=${1}
+       lan=${2}
+       lan_mode=${3}
+       wan=${4}
+       wan_mode=${5}
+
+       export RUMP_SERVER=${sock}
+       atf_check -s exit:0 -o match:shmif0 rump.ifconfig
+       if [ ${lan_mode} = "ipv6" ]; then
+               atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${lan}
+       else
+               atf_check -s exit:0 -o ignore rump.ping -n -c 1 -w $TIMEOUT ${lan}
+       fi
+
+       atf_check -s exit:0 -o match:shmif1 rump.ifconfig
+       if [ ${wan_mode} = "ipv6" ]; then
+               atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${wan}
+       else
+               atf_check -s exit:0 -o ignore rump.ping -n -c 1 -w $TIMEOUT ${wan}
+       fi
+}
+
+setup()
+{
+       inner=${1}
+       outer=${2}
+
+       atf_check -s exit:0 ${server} $SOCK1
+       atf_check -s exit:0 ${server} $SOCK2
+
+       router1_lan=""
+       router1_lan_mode=""
+       router2_lan=""
+       router2_lan_mode=""
+       if [ ${inner} = "ipv6" ]; then
+               router1_lan=$ROUTER1_LANIP6
+               router1_lan_mode="ipv6"
+               router2_lan=$ROUTER2_LANIP6
+               router2_lan_mode="ipv6"
+       else
+               router1_lan=$ROUTER1_LANIP
+               router1_lan_mode="ipv4"
+               router2_lan=$ROUTER2_LANIP
+               router2_lan_mode="ipv4"
+       fi
+
+       if [ ${outer} = "ipv6" ]; then
+               setup_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
+                       $ROUTER1_WANIP6 ipv6
+               setup_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
+                       $ROUTER2_WANIP6 ipv6
+       else
+               setup_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
+                       $ROUTER1_WANIP ipv4
+               setup_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
+                       $ROUTER2_WANIP ipv4
+       fi
+}
+
+test_setup()
+{
+       inner=${1}
+       outer=${2}
+
+       router1_lan=""
+       router1_lan_mode=""
+       router2_lan=""
+       router2_lan_mode=""
+       if [ ${inner} = "ipv6" ]; then
+               router1_lan=$ROUTER1_LANIP6
+               router1_lan_mode="ipv6"
+               router2_lan=$ROUTER2_LANIP6
+               router2_lan_mode="ipv6"
+       else
+               router1_lan=$ROUTER1_LANIP
+               router1_lan_mode="ipv4"
+               router2_lan=$ROUTER2_LANIP
+               router2_lan_mode="ipv4"
+       fi
+       if [ ${outer} = "ipv6" ]; then
+               test_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
+                       $ROUTER1_WANIP6 ipv6
+               test_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
+                       $ROUTER2_WANIP6 ipv6
+       else
+               test_router $SOCK1 ${router1_lan} ${router1_lan_mode} \
+                       $ROUTER1_WANIP ipv4
+               test_router $SOCK2 ${router2_lan} ${router2_lan_mode} \
+                       $ROUTER2_WANIP ipv4
+       fi
+}
+
+setup_if_gif()
+{
+       sock=${1}
+       addr=${2}
+       remote=${3}
+       inner=${4}
+       src=${5}
+       dst=${6}
+       peernet=${7}
+
+       export RUMP_SERVER=${sock}
+       atf_check -s exit:0 rump.ifconfig gif0 create
+       atf_check -s exit:0 rump.ifconfig gif0 tunnel ${src} ${dst}
+       if [ ${inner} = "ipv6" ]; then
+               atf_check -s exit:0 rump.ifconfig gif0 inet6 ${addr}/128 ${remote}
+               atf_check -s exit:0 -o ignore rump.route add -inet6 ${peernet} ${addr}
+       else
+               atf_check -s exit:0 rump.ifconfig gif0 inet ${addr}/32 ${remote}
+               atf_check -s exit:0 -o ignore rump.route add -inet ${peernet} ${addr}



Home | Main Index | Thread Index | Old Index