Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add tests for tap(4)
details: https://anonhg.NetBSD.org/src/rev/b2e198d21d36
branches: trunk
changeset: 343920:b2e198d21d36
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Mar 04 02:44:45 2016 +0000
description:
Add tests for tap(4)
diffstat:
distrib/sets/lists/tests/mi | 6 +-
etc/mtree/NetBSD.dist.tests | 3 +-
tests/net/Makefile | 4 +-
tests/net/if_tap/Makefile | 10 ++
tests/net/if_tap/t_tap.sh | 198 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 217 insertions(+), 4 deletions(-)
diffs (271 lines):
diff -r 3f50d6d88d02 -r b2e198d21d36 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Thu Mar 03 21:38:55 2016 +0000
+++ b/distrib/sets/lists/tests/mi Fri Mar 04 02:44:45 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.663 2016/02/23 16:21:55 christos Exp $
+# $NetBSD: mi,v 1.664 2016/03/04 02:44:45 ozaki-r Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -3176,6 +3176,10 @@
./usr/tests/net/if_loop/Atffile tests-net-tests atf,rump
./usr/tests/net/if_loop/Kyuafile tests-net-tests atf,rump,kyua
./usr/tests/net/if_loop/t_pr tests-net-tests atf,rump
+./usr/tests/net/if_tap tests-net-tests compattestfile,atf
+./usr/tests/net/if_tap/Atffile tests-net-tests atf,rump
+./usr/tests/net/if_tap/Kyuafile tests-net-tests atf,rump,kyua
+./usr/tests/net/if_tap/t_tap tests-net-tests atf,rump
./usr/tests/net/in_cksum tests-net-tests compattestfile,atf
./usr/tests/net/in_cksum/Atffile tests-net-tests compattestfile,atf
./usr/tests/net/in_cksum/Kyuafile tests-net-tests compattestfile,atf,kyua
diff -r 3f50d6d88d02 -r b2e198d21d36 etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests Thu Mar 03 21:38:55 2016 +0000
+++ b/etc/mtree/NetBSD.dist.tests Fri Mar 04 02:44:45 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.dist.tests,v 1.124 2016/01/05 17:22:38 jakllsch Exp $
+# $NetBSD: NetBSD.dist.tests,v 1.125 2016/03/04 02:44:45 ozaki-r Exp $
./usr/libdata/debug/usr/tests
./usr/libdata/debug/usr/tests/atf
@@ -324,6 +324,7 @@
./usr/tests/net/if_bridge
./usr/tests/net/if_gif
./usr/tests/net/if_loop
+./usr/tests/net/if_tap
./usr/tests/net/in_cksum
./usr/tests/net/mcast
./usr/tests/net/mpls
diff -r 3f50d6d88d02 -r b2e198d21d36 tests/net/Makefile
--- a/tests/net/Makefile Thu Mar 03 21:38:55 2016 +0000
+++ b/tests/net/Makefile Fri Mar 04 02:44:45 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.26 2015/11/05 00:02:59 knakahara Exp $
+# $NetBSD: Makefile,v 1.27 2016/03/04 02:44:45 ozaki-r Exp $
.include <bsd.own.mk>
@@ -7,7 +7,7 @@
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_gif if_loop
-TESTS_SUBDIRS+= mcast mpls ndp npf route
+TESTS_SUBDIRS+= if_tap mcast mpls ndp npf route
.if (${MKSLJIT} != "no")
TESTS_SUBDIRS+= bpfjit
.endif
diff -r 3f50d6d88d02 -r b2e198d21d36 tests/net/if_tap/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/if_tap/Makefile Fri Mar 04 02:44:45 2016 +0000
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2016/03/04 02:44:45 ozaki-r Exp $
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/net/if_tap
+
+TESTS_SH= t_tap
+
+.include <bsd.test.mk>
diff -r 3f50d6d88d02 -r b2e198d21d36 tests/net/if_tap/t_tap.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/if_tap/t_tap.sh Fri Mar 04 02:44:45 2016 +0000
@@ -0,0 +1,198 @@
+# $NetBSD: t_tap.sh,v 1.1 2016/03/04 02:44:45 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_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6"
+RUMP_FLAGS="$RUMP_FLAGS -lrumpnet_shmif -lrumpdev -lrumpnet_tap -lrumpnet_bridge"
+HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
+
+SOCK_LOCAL=unix://commsock1
+SOCK_REMOTE=unix://commsock2
+BUS=bus1
+IP4_LOCAL=10.0.0.1
+IP4_TAP=10.0.0.2
+IP4_REMOTE=10.0.0.3
+IP6_LOCAL=fc00::1
+IP6_TAP=fc00::2
+IP6_REMOTE=fc00::3
+
+DEBUG=false
+TIMEOUT=1
+
+atf_test_case create_destroy cleanup
+create_destroy_head()
+{
+
+ atf_set "descr" "tests of creation and deletion of tap interface"
+ atf_set "require.progs" "rump_server"
+}
+
+create_destroy_body()
+{
+
+ atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
+
+ export RUMP_SERVER=${SOCK_LOCAL}
+
+ # Create and destroy (no address)
+ atf_check -s exit:0 rump.ifconfig tap0 create
+ atf_check -s exit:0 rump.ifconfig tap0 destroy
+
+ # Create and destroy (with an IPv4 address)
+ atf_check -s exit:0 rump.ifconfig tap0 create
+ atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
+ atf_check -s exit:0 rump.ifconfig tap0 up
+ atf_check -s exit:0 rump.ifconfig tap0 destroy
+
+ # Create and destroy (with an IPv6 address)
+ atf_check -s exit:0 rump.ifconfig tap0 create
+ atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
+ atf_check -s exit:0 rump.ifconfig tap0 up
+ atf_check -s exit:0 rump.ifconfig tap0 destroy
+}
+
+create_destroy_cleanup()
+{
+
+ RUMP_SERVER=${SOCK_LOCAL} rump.halt
+}
+
+atf_test_case stand_alone cleanup
+create_destroy_head()
+{
+
+ atf_set "descr" "tests of alone tap interface"
+ atf_set "require.progs" "rump_server"
+}
+
+stand_alone_body()
+{
+ atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
+ atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE}
+
+ export RUMP_SERVER=${SOCK_LOCAL}
+
+ 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 $IP4_LOCAL
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig tap0 create
+ atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
+ atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
+ atf_check -s exit:0 rump.ifconfig tap0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ export RUMP_SERVER=${SOCK_REMOTE}
+
+ 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 $IP4_REMOTE
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL
+ # Cannot reach to an alone tap
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ rump.ping -n -w $TIMEOUT -c 1 $IP4_TAP
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
+ # Cannot reach to an alone tap
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP
+}
+
+stand_alone_cleanup()
+{
+
+ RUMP_SERVER=${SOCK_LOCAL} rump.halt
+ RUMP_SERVER=${SOCK_REMOTE} rump.halt
+}
+
+atf_test_case bridged cleanup
+bridged_head()
+{
+
+ atf_set "descr" "tests of alone tap interface"
+ atf_set "require.progs" "rump_server"
+}
+
+bridged_body()
+{
+ atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
+ atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE}
+
+ export RUMP_SERVER=${SOCK_LOCAL}
+
+ 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 $IP4_LOCAL
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig tap0 create
+ atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
+ atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
+ atf_check -s exit:0 rump.ifconfig tap0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ atf_check -s exit:0 rump.ifconfig bridge0 create
+ atf_check -s exit:0 rump.ifconfig bridge0 up
+ export LD_PRELOAD=/usr/lib/librumphijack.so
+ atf_check -s exit:0 brconfig bridge0 add shmif0
+ atf_check -s exit:0 brconfig bridge0 add tap0
+ unset LD_PRELOAD
+
+ export RUMP_SERVER=${SOCK_REMOTE}
+
+ 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 $IP4_REMOTE
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL
+ atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_TAP
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
+ atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP
+}
+
+bridged_cleanup()
+{
+
+ RUMP_SERVER=${SOCK_LOCAL} rump.halt
+ RUMP_SERVER=${SOCK_REMOTE} rump.halt
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case create_destroy
+ atf_add_test_case stand_alone
+ atf_add_test_case bridged
+}
Home |
Main Index |
Thread Index |
Old Index