2 # $NetBSD: t_bridge.sh,v 1.1 2014/09/18 15:13:27 ozaki-r Exp $
4 # Copyright (c) 2014 The NetBSD Foundation, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
29 inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_bridge -lrumpnet_shmif"
30 inet6server="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_bridge -lrumpnet_shmif"
32 SOCK1=unix://commsock1
33 SOCK2=unix://commsock2
34 SOCK3=unix://commsock3
40 atf_test_case basic cleanup
41 atf_test_case basic6 cleanup
45 atf_set "descr" "Does simple if_bridge tests"
46 atf_set "require.progs" "rump_server"
51 atf_set "descr" "Does simple if_bridge tests (IPv6)"
52 atf_set "require.progs" "rump_server"
62 export RUMP_SERVER=${sock}
63 atf_check -s exit:0 rump.ifconfig shmif0 create
64 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus}
65 if [ $mode = "ipv6" ]; then
66 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
68 atf_check -s exit:0 rump.ifconfig shmif0 inet ${addr} netmask 0xffffff00
71 atf_check -s exit:0 rump.ifconfig shmif0 up
82 export RUMP_SERVER=${sock}
83 atf_check -s exit:0 -o match:shmif0 rump.ifconfig
84 if [ $mode = "ipv6" ]; then
85 export LD_PRELOAD=/usr/lib/librumphijack.so
86 atf_check -s exit:0 -o ignore ping6 -n -c 1 ${addr}
89 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 ${addr}
97 export RUMP_SERVER=${sock}
98 rump.ifconfig -v shmif0
103 test_endpoint $SOCK1 $IP1 bus1 ipv4
104 test_endpoint $SOCK3 $IP2 bus2 ipv4
106 export RUMP_SERVER=$SOCK2
107 atf_check -s exit:0 -o match:shmif0 rump.ifconfig
108 atf_check -s exit:0 -o match:shmif1 rump.ifconfig
113 test_endpoint $SOCK1 $IP61 bus1 ipv6
114 test_endpoint $SOCK3 $IP62 bus2 ipv6
116 export RUMP_SERVER=$SOCK2
117 atf_check -s exit:0 -o match:shmif0 rump.ifconfig
118 atf_check -s exit:0 -o match:shmif1 rump.ifconfig
121 setup_bridge_server()
123 export RUMP_SERVER=$SOCK2
124 atf_check -s exit:0 rump.ifconfig shmif0 create
125 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
126 atf_check -s exit:0 rump.ifconfig shmif0 up
128 atf_check -s exit:0 rump.ifconfig shmif1 create
129 atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2
130 atf_check -s exit:0 rump.ifconfig shmif1 up
135 atf_check -s exit:0 ${inetserver} $SOCK1
136 atf_check -s exit:0 ${inetserver} $SOCK2
137 atf_check -s exit:0 ${inetserver} $SOCK3
139 setup_endpoint $SOCK1 $IP1 bus1 ipv4
140 setup_endpoint $SOCK3 $IP2 bus2 ipv4
146 atf_check -s exit:0 ${inet6server} $SOCK1
147 atf_check -s exit:0 ${inet6server} $SOCK2
148 atf_check -s exit:0 ${inet6server} $SOCK3
150 setup_endpoint $SOCK1 $IP61 bus1 ipv6
151 setup_endpoint $SOCK3 $IP62 bus2 ipv6
157 export RUMP_SERVER=$SOCK2
158 atf_check -s exit:0 rump.ifconfig bridge0 create
159 atf_check -s exit:0 rump.ifconfig bridge0 up
161 export LD_PRELOAD=/usr/lib/librumphijack.so
162 atf_check -s exit:0 /sbin/brconfig bridge0 add shmif0
163 atf_check -s exit:0 /sbin/brconfig bridge0 add shmif1
164 /sbin/brconfig bridge0
172 export RUMP_SERVER=$SOCK2
173 export LD_PRELOAD=/usr/lib/librumphijack.so
174 /sbin/brconfig bridge0
175 atf_check -s exit:0 /sbin/brconfig bridge0 delete shmif0
176 atf_check -s exit:0 /sbin/brconfig bridge0 delete shmif1
177 /sbin/brconfig bridge0
185 export RUMP_SERVER=$SOCK2
186 export LD_PRELOAD=/usr/lib/librumphijack.so
187 atf_check -s exit:0 -o match:shmif0 /sbin/brconfig bridge0
188 atf_check -s exit:0 -o match:shmif1 /sbin/brconfig bridge0
189 /sbin/brconfig bridge0
195 env RUMP_SERVER=$SOCK1 rump.halt
196 env RUMP_SERVER=$SOCK2 rump.halt
197 env RUMP_SERVER=$SOCK3 rump.halt
202 /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
203 /usr/bin/shmif_dumpbus -p - bus2 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
208 export RUMP_SERVER=$SOCK1
209 rump.ifconfig shmif0 down
210 rump.ifconfig shmif0 up
211 export RUMP_SERVER=$SOCK3
212 rump.ifconfig shmif0 down
213 rump.ifconfig shmif0 up
218 export RUMP_SERVER=$SOCK1
219 atf_check -s not-exit:0 -o ignore rump.ping -q -n -w 1 -c 1 $IP2
220 export RUMP_SERVER=$SOCK3
221 atf_check -s not-exit:0 -o ignore rump.ping -q -n -w 1 -c 1 $IP1
226 export RUMP_SERVER=$SOCK1
227 rump.ifconfig -v shmif0
228 atf_check -s exit:0 -o ignore rump.ping -q -n -w 1 -c 1 $IP2
229 rump.ifconfig -v shmif0
231 export RUMP_SERVER=$SOCK3
232 rump.ifconfig -v shmif0
233 atf_check -s exit:0 -o ignore rump.ping -q -n -w 1 -c 1 $IP1
234 rump.ifconfig -v shmif0
239 export LD_PRELOAD=/usr/lib/librumphijack.so
240 export RUMP_SERVER=$SOCK1
241 atf_check -s not-exit:0 -o ignore ping6 -q -n -c 1 $IP62
242 export RUMP_SERVER=$SOCK3
243 atf_check -s not-exit:0 -o ignore ping6 -q -n -c 1 $IP61
249 export RUMP_SERVER=$SOCK1
250 rump.ifconfig -v shmif0
251 export LD_PRELOAD=/usr/lib/librumphijack.so
252 atf_check -s exit:0 -o ignore ping6 -q -n -c 1 $IP62
254 rump.ifconfig -v shmif0
256 export RUMP_SERVER=$SOCK3
257 rump.ifconfig -v shmif0
258 export LD_PRELOAD=/usr/lib/librumphijack.so
259 atf_check -s exit:0 -o ignore ping6 -q -n -c 1 $IP61
261 rump.ifconfig -v shmif0
283 # TODO: enable once ping6 implements timeout feature
292 # TODO: enable once ping6 implements timeout feature
308 atf_init_test_cases()
310 atf_add_test_case basic
311 atf_add_test_case basic6