t_tap.sh revision 1.2
1# $NetBSD: t_tap.sh,v 1.2 2016/06/21 05:04:16 ozaki-r Exp $ 2# 3# Copyright (c) 2016 Internet Initiative Japan Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26# 27 28RUMP_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6" 29RUMP_FLAGS="$RUMP_FLAGS -lrumpnet_shmif -lrumpdev -lrumpnet_tap -lrumpnet_bridge" 30HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" 31 32SOCK_LOCAL=unix://commsock1 33SOCK_REMOTE=unix://commsock2 34BUS=bus1 35IP4_LOCAL=10.0.0.1 36IP4_TAP=10.0.0.2 37IP4_REMOTE=10.0.0.3 38IP6_LOCAL=fc00::1 39IP6_TAP=fc00::2 40IP6_REMOTE=fc00::3 41 42DEBUG=false 43TIMEOUT=1 44 45atf_test_case tap_create_destroy cleanup 46tap_create_destroy_head() 47{ 48 49 atf_set "descr" "tests of creation and deletion of tap interface" 50 atf_set "require.progs" "rump_server" 51} 52 53tap_create_destroy_body() 54{ 55 56 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} 57 58 export RUMP_SERVER=${SOCK_LOCAL} 59 60 # Create and destroy (no address) 61 atf_check -s exit:0 rump.ifconfig tap0 create 62 atf_check -s exit:0 rump.ifconfig tap0 destroy 63 64 # Create and destroy (with an IPv4 address) 65 atf_check -s exit:0 rump.ifconfig tap0 create 66 atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP 67 atf_check -s exit:0 rump.ifconfig tap0 up 68 atf_check -s exit:0 rump.ifconfig tap0 destroy 69 70 # Create and destroy (with an IPv6 address) 71 atf_check -s exit:0 rump.ifconfig tap0 create 72 atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP 73 atf_check -s exit:0 rump.ifconfig tap0 up 74 atf_check -s exit:0 rump.ifconfig tap0 destroy 75} 76 77tap_create_destroy_cleanup() 78{ 79 80 RUMP_SERVER=${SOCK_LOCAL} rump.halt 81} 82 83atf_test_case tap_stand_alone cleanup 84tap_create_destroy_head() 85{ 86 87 atf_set "descr" "tests of alone tap interface" 88 atf_set "require.progs" "rump_server" 89} 90 91tap_stand_alone_body() 92{ 93 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} 94 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE} 95 96 export RUMP_SERVER=${SOCK_LOCAL} 97 98 atf_check -s exit:0 rump.ifconfig shmif0 create 99 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS 100 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL 101 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL 102 atf_check -s exit:0 rump.ifconfig shmif0 up 103 atf_check -s exit:0 rump.ifconfig tap0 create 104 atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP 105 atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP 106 atf_check -s exit:0 rump.ifconfig tap0 up 107 atf_check -s exit:0 rump.ifconfig -w 10 108 109 export RUMP_SERVER=${SOCK_REMOTE} 110 111 atf_check -s exit:0 rump.ifconfig shmif0 create 112 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS 113 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE 114 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE 115 atf_check -s exit:0 rump.ifconfig shmif0 up 116 atf_check -s exit:0 rump.ifconfig -w 10 117 118 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL 119 # Cannot reach to an alone tap 120 atf_check -s not-exit:0 -o ignore -e ignore \ 121 rump.ping -n -w $TIMEOUT -c 1 $IP4_TAP 122 123 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL 124 # Cannot reach to an alone tap 125 atf_check -s not-exit:0 -o ignore -e ignore \ 126 rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP 127} 128 129tap_stand_alone_cleanup() 130{ 131 132 RUMP_SERVER=${SOCK_LOCAL} rump.halt 133 RUMP_SERVER=${SOCK_REMOTE} rump.halt 134} 135 136atf_test_case tap_bridged cleanup 137tap_bridged_head() 138{ 139 140 atf_set "descr" "tests of alone tap interface" 141 atf_set "require.progs" "rump_server" 142} 143 144tap_bridged_body() 145{ 146 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} 147 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE} 148 149 export RUMP_SERVER=${SOCK_LOCAL} 150 151 atf_check -s exit:0 rump.ifconfig shmif0 create 152 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS 153 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL 154 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL 155 atf_check -s exit:0 rump.ifconfig shmif0 up 156 atf_check -s exit:0 rump.ifconfig tap0 create 157 atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP 158 atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP 159 atf_check -s exit:0 rump.ifconfig tap0 up 160 atf_check -s exit:0 rump.ifconfig -w 10 161 162 atf_check -s exit:0 rump.ifconfig bridge0 create 163 atf_check -s exit:0 rump.ifconfig bridge0 up 164 export LD_PRELOAD=/usr/lib/librumphijack.so 165 atf_check -s exit:0 brconfig bridge0 add shmif0 166 atf_check -s exit:0 brconfig bridge0 add tap0 167 unset LD_PRELOAD 168 169 export RUMP_SERVER=${SOCK_REMOTE} 170 171 atf_check -s exit:0 rump.ifconfig shmif0 create 172 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS 173 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE 174 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE 175 atf_check -s exit:0 rump.ifconfig shmif0 up 176 atf_check -s exit:0 rump.ifconfig -w 10 177 178 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL 179 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_TAP 180 181 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL 182 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP 183} 184 185tap_bridged_cleanup() 186{ 187 188 RUMP_SERVER=${SOCK_LOCAL} rump.halt 189 RUMP_SERVER=${SOCK_REMOTE} rump.halt 190} 191 192atf_init_test_cases() 193{ 194 195 atf_add_test_case tap_create_destroy 196 atf_add_test_case tap_stand_alone 197 atf_add_test_case tap_bridged 198} 199