1 # $NetBSD: t_ipv6_lifetime.sh,v 1.2 2016/08/10 21:33:52 kre Exp $
3 # Copyright (c) 2015 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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 INET6SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev"
29 INET6SERVER="$INET6SERVER -lrumpnet_netinet6 -lrumpnet_shmif"
36 atf_test_case basic cleanup
40 atf_set "descr" "Tests for IPv6 address lifetime"
41 atf_set "require.progs" "rump_server"
50 atf_check -s exit:0 ${INET6SERVER} $SOCK
51 export RUMP_SERVER=$SOCK
53 atf_check -s exit:0 rump.ifconfig shmif0 create
54 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
55 atf_check -s exit:0 rump.ifconfig shmif0 up
57 # A normal IP address doesn't contain preferred/valid lifetime
58 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip
59 $DEBUG && rump.ifconfig -L shmif0
60 atf_check -s exit:0 -o not-match:'pltime' rump.ifconfig -L shmif0
61 atf_check -s exit:0 -o not-match:'vltime' rump.ifconfig -L shmif0
62 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
64 # Setting only a preferred lifetime
65 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip pltime $time
66 $DEBUG && rump.ifconfig -L shmif0
67 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
68 atf_check -s exit:0 -o match:'vltime infty' rump.ifconfig -L shmif0
69 atf_check -s exit:0 sleep $(($time + $bonus))
70 $DEBUG && rump.ifconfig -L shmif0
71 # Should remain but marked as deprecated
72 atf_check -s exit:0 -o match:'deprecated' rump.ifconfig -L shmif0
73 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
75 # Setting only a valid lifetime (invalid)
76 atf_check -s not-exit:0 -e match:'Invalid argument' \
77 rump.ifconfig shmif0 inet6 $ip vltime $time
79 # Setting both preferred and valid lifetimes (same value)
80 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
81 pltime $time vltime $time
82 $DEBUG && rump.ifconfig -L shmif0
83 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
84 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
85 atf_check -s exit:0 sleep $(($time + $bonus))
86 $DEBUG && rump.ifconfig -L shmif0
87 # Shouldn't remain anymore
88 atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
90 # Setting both preferred and valid lifetimes (pltime < vltime)
91 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
92 pltime $time vltime $((time * 2))
93 $DEBUG && rump.ifconfig -L shmif0
94 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
95 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
96 atf_check -s exit:0 sleep $(($time + $bonus))
97 $DEBUG && rump.ifconfig -L shmif0
98 # Should remain but marked as deprecated
99 atf_check -s exit:0 -o match:'deprecated' rump.ifconfig -L shmif0
100 atf_check -s exit:0 sleep $(($time + $bonus))
101 $DEBUG && rump.ifconfig -L shmif0
102 # Shouldn't remain anymore
103 atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
105 # Setting both preferred and valid lifetimes (pltime > vltime)
106 atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \
107 shmif0 inet6 $ip pltime $(($time * 2)) vltime $time
114 env RUMP_SERVER=$SOCK rump.halt
119 env RUMP_SERVER=$SOCK rump.ifconfig
120 env RUMP_SERVER=$SOCK rump.netstat -nr
121 shmif_dumpbus -p - $BUS 2>/dev/null| tcpdump -n -e -r -
130 atf_init_test_cases()
132 atf_add_test_case basic