Module Name: src Committed By: ozaki-r Date: Fri Mar 4 02:44:45 UTC 2016
Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net: Makefile Added Files: src/tests/net/if_tap: Makefile t_tap.sh Log Message: Add tests for tap(4) To generate a diff of this commit: cvs rdiff -u -r1.663 -r1.664 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.124 -r1.125 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.26 -r1.27 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/if_tap/Makefile \ src/tests/net/if_tap/t_tap.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.663 src/distrib/sets/lists/tests/mi:1.664 --- src/distrib/sets/lists/tests/mi:1.663 Tue Feb 23 16:21:55 2016 +++ src/distrib/sets/lists/tests/mi Fri Mar 4 02:44:45 2016 @@ -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 Index: src/etc/mtree/NetBSD.dist.tests diff -u src/etc/mtree/NetBSD.dist.tests:1.124 src/etc/mtree/NetBSD.dist.tests:1.125 --- src/etc/mtree/NetBSD.dist.tests:1.124 Tue Jan 5 17:22:38 2016 +++ src/etc/mtree/NetBSD.dist.tests Fri Mar 4 02:44:45 2016 @@ -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 Index: src/tests/net/Makefile diff -u src/tests/net/Makefile:1.26 src/tests/net/Makefile:1.27 --- src/tests/net/Makefile:1.26 Thu Nov 5 00:02:59 2015 +++ src/tests/net/Makefile Fri Mar 4 02:44:45 2016 @@ -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 @@ TESTSDIR= ${TESTSBASE}/net 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 Added files: Index: src/tests/net/if_tap/Makefile diff -u /dev/null src/tests/net/if_tap/Makefile:1.1 --- /dev/null Fri Mar 4 02:44:45 2016 +++ src/tests/net/if_tap/Makefile Fri Mar 4 02:44:45 2016 @@ -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> Index: src/tests/net/if_tap/t_tap.sh diff -u /dev/null src/tests/net/if_tap/t_tap.sh:1.1 --- /dev/null Fri Mar 4 02:44:45 2016 +++ src/tests/net/if_tap/t_tap.sh Fri Mar 4 02:44:45 2016 @@ -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 +}