Remove building with NOCRYPTO option
[minix.git] / tests / net / ndp / t_ndp.sh
blob5ede5e340e30cf2173cd6752dd6325ea968e6ea4
1 # $NetBSD: t_ndp.sh,v 1.6 2015/08/18 00:58:35 ozaki-r Exp $
3 # Copyright (c) 2015 The NetBSD Foundation, Inc.
4 # All rights reserved.
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.
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.
28 inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
29 inetserver="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif"
30 HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
32 SOCKSRC=unix://commsock1
33 SOCKDST=unix://commsock2
34 IP6SRC=fc00::1
35 IP6DST=fc00::2
37 DEBUG=true
38 TIMEOUT=1
40 atf_test_case cache_expiration cleanup
41 atf_test_case command cleanup
42 atf_test_case cache_overwriting cleanup
44 cache_expiration_head()
46 atf_set "descr" "Tests for NDP cache expiration"
47 atf_set "require.progs" "rump_server"
50 command_head()
52 atf_set "descr" "Tests for commands of ndp(8)"
53 atf_set "require.progs" "rump_server"
56 cache_overwriting_head()
58 atf_set "descr" "Tests for behavior of overwriting NDP caches"
59 atf_set "require.progs" "rump_server"
62 setup_dst_server()
64 export RUMP_SERVER=$SOCKDST
65 atf_check -s exit:0 rump.ifconfig shmif0 create
66 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
67 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6DST
68 atf_check -s exit:0 rump.ifconfig shmif0 up
69 atf_check -s exit:0 rump.ifconfig -w 10
71 $DEBUG && rump.ifconfig shmif0
72 $DEBUG && rump.ndp -n -a
75 setup_src_server()
77 $DEBUG && ulimit -c unlimited
78 export RUMP_SERVER=$SOCKSRC
80 # Setup an interface
81 atf_check -s exit:0 rump.ifconfig shmif0 create
82 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
83 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6SRC
84 atf_check -s exit:0 rump.ifconfig shmif0 up
85 atf_check -s exit:0 rump.ifconfig -w 10
87 # Sanity check
88 $DEBUG && rump.ifconfig shmif0
89 $DEBUG && rump.ndp -n -a
90 atf_check -s exit:0 -o ignore rump.ndp -n $IP6SRC
91 atf_check -s not-exit:0 -o ignore -e ignore rump.ndp -n $IP6DST
94 get_timeout()
96 local timeout=$(env RUMP_SERVER=$SOCKSRC rump.ndp -n $IP6DST |grep $IP6DST|awk '{print $4;}')
97 timeout=${timeout%s}
98 echo $timeout
101 cache_expiration_body()
103 atf_check -s exit:0 ${inetserver} $SOCKSRC
104 atf_check -s exit:0 ${inetserver} $SOCKDST
106 setup_dst_server
107 setup_src_server
110 # Check if a cache is expired expectedly
112 export RUMP_SERVER=$SOCKSRC
113 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST
115 $DEBUG && rump.ndp -n -a
116 atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6SRC
117 # Should be cached
118 atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n $IP6DST
120 timeout=$(get_timeout $IP6DST)
122 atf_check -s exit:0 sleep $(($timeout + 1))
124 $DEBUG && rump.ndp -n -a
125 atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6SRC
126 # Expired but remains until GC sweaps it (1 day)
127 atf_check -s exit:0 -o match:'(1d0h0m|23h59m)' rump.ndp -n $IP6DST
130 ifdown_dst_server()
132 export RUMP_SERVER=$SOCKDST
133 atf_check -s exit:0 rump.ifconfig shmif0 down
134 export RUMP_SERVER=$SOCKSRC
137 command_body()
139 atf_check -s exit:0 ${inetserver} $SOCKSRC
140 atf_check -s exit:0 ${inetserver} $SOCKDST
142 setup_dst_server
143 setup_src_server
145 export RUMP_SERVER=$SOCKSRC
147 # Add and delete a static entry
148 $DEBUG && rump.ndp -n -a
149 atf_check -s exit:0 -o ignore rump.ndp -s fc00::10 b2:a0:20:00:00:10
150 $DEBUG && rump.ndp -n -a
151 atf_check -s exit:0 -o match:'permanent' rump.ndp -n fc00::10
152 atf_check -s exit:0 -o match:'deleted' rump.ndp -d fc00::10
153 $DEBUG && rump.ndp -n -a
154 atf_check -s not-exit:0 -o ignore -e ignore rump.ndp -n fc00::10
156 # Add multiple entries via a file (XXX not implemented)
157 #cat - > ./list <<-EOF
158 #fc00::11 b2:a0:20:00:00:11
159 #fc00::12 b2:a0:20:00:00:12
160 #fc00::13 b2:a0:20:00:00:13
161 #fc00::14 b2:a0:20:00:00:14
162 #fc00::15 b2:a0:20:00:00:15
163 #EOF
164 #$DEBUG && rump.ndp -n -a
165 #atf_check -s exit:0 -o ignore rump.ndp -f ./list
166 #$DEBUG && rump.ndp -n -a
168 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST
169 atf_check -s exit:0 -o ignore rump.ndp -s fc00::11 b2:a0:20:00:00:11
170 atf_check -s exit:0 -o ignore rump.ndp -s fc00::12 b2:a0:20:00:00:12
172 atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n $IP6DST
173 atf_check -s exit:0 -o match:'permanent' rump.ndp -n fc00::11
174 atf_check -s exit:0 -o match:'permanent' rump.ndp -n fc00::12
176 # Test ndp -a
177 atf_check -s exit:0 -o match:'fc00::11' rump.ndp -n -a
178 atf_check -s exit:0 -o match:'fc00::12' rump.ndp -n -a
180 # Ensure no packet upsets the src server
181 ifdown_dst_server
183 # Flush all entries (-c)
184 $DEBUG && rump.ndp -n -a
185 atf_check -s exit:0 -o ignore rump.ndp -c
186 atf_check -s not-exit:0 -o ignore -e ignore rump.ndp -n $IP6DST
187 # Only the static caches are not deleted
188 atf_check -s exit:0 -o ignore -e ignore rump.ndp -n fc00::11
189 atf_check -s exit:0 -o ignore -e ignore rump.ndp -n fc00::12
191 # Test temp option (XXX it doesn't work; expire time isn't set)
192 $DEBUG && rump.ndp -n -a
193 #atf_check -s exit:0 -o ignore rump.ndp -s fc00::10 b2:a0:20:00:00:10 temp
194 rump.ndp -s fc00::10 b2:a0:20:00:00:10 temp
195 $DEBUG && rump.ndp -n -a
196 #atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n fc00::10
198 return 0
201 cache_overwriting_body()
203 atf_check -s exit:0 ${inetserver} $SOCKSRC
204 atf_check -s exit:0 ${inetserver} $SOCKDST
206 setup_dst_server
207 setup_src_server
209 export RUMP_SERVER=$SOCKSRC
211 # Cannot overwrite a permanent cache
212 atf_check -s not-exit:0 -e ignore rump.ndp -s $IP6SRC b2:a0:20:00:00:ff
213 $DEBUG && rump.ndp -n -a
215 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST
216 $DEBUG && rump.ndp -n -a
217 # Can overwrite a dynamic cache
218 atf_check -s exit:0 -o ignore rump.ndp -s $IP6DST b2:a0:20:00:00:00
219 $DEBUG && rump.ndp -n -a
220 atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6DST
222 # Test temp option (XXX it doesn't work; expire time isn't set)
223 #atf_check -s exit:0 -o ignore rump.ndp -s fc00::10 b2:a0:20:00:00:10 temp
224 #$DEBUG && rump.ndp -n -a
225 #atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n fc00::10
226 # Cannot overwrite a temp cache
227 #atf_check -s not-exit:0 -e ignore rump.ndp -s fc00::10 b2:a0:20:00:00:ff
228 #$DEBUG && rump.ndp -n -a
230 return 0
233 cleanup()
235 env RUMP_SERVER=$SOCKSRC rump.halt
236 env RUMP_SERVER=$SOCKDST rump.halt
239 dump_src()
241 export RUMP_SERVER=$SOCKSRC
242 rump.netstat -nr
243 rump.ndp -n -a
244 rump.ifconfig
245 $HIJACKING dmesg
248 dump_dst()
250 export RUMP_SERVER=$SOCKDST
251 rump.netstat -nr
252 rump.ndp -n -a
253 rump.ifconfig
254 $HIJACKING dmesg
257 dump()
259 dump_src
260 dump_dst
261 shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
262 $DEBUG && gdb -ex bt /usr/bin/rump_server rump_server.core
263 $DEBUG && gdb -ex bt /usr/sbin/rump.ndp rump.ndp.core
266 cache_expiration_cleanup()
268 $DEBUG && dump
269 cleanup
272 command_cleanup()
274 $DEBUG && dump
275 cleanup
278 cache_overwriting_cleanup()
280 $DEBUG && dump
281 cleanup
284 atf_init_test_cases()
286 atf_add_test_case cache_expiration
287 atf_add_test_case command
288 atf_add_test_case cache_overwriting