1 # $NetBSD: t_ipv6_lifetime.sh,v 1.6 2016/11/25 08:51:17 ozaki-r 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.
33 deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]"
35 atf_test_case basic cleanup
39 atf_set "descr" "Tests for IPv6 address lifetime"
40 atf_set "require.progs" "rump_server"
49 rump_server_start $SOCK netinet6
50 rump_server_add_iface $SOCK shmif0 $BUS
52 export RUMP_SERVER=$SOCK
54 atf_check -s exit:0 rump.ifconfig shmif0 up
56 # A normal IP address doesn't contain preferred/valid lifetime
57 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip
58 $DEBUG && rump.ifconfig -L shmif0
59 atf_check -s exit:0 -o not-match:'pltime' rump.ifconfig -L shmif0
60 atf_check -s exit:0 -o not-match:'vltime' rump.ifconfig -L shmif0
61 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
63 # Setting only a preferred lifetime
64 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip pltime $time
65 $DEBUG && rump.ifconfig -L shmif0
66 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
67 atf_check -s exit:0 -o match:'vltime infty' rump.ifconfig -L shmif0
68 atf_check -s exit:0 sleep $(($time + $bonus))
69 $DEBUG && rump.ifconfig -L shmif0
70 # Should remain but marked as deprecated
71 atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0
72 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
74 # Setting only a valid lifetime (invalid)
75 atf_check -s not-exit:0 -e match:'Invalid argument' \
76 rump.ifconfig shmif0 inet6 $ip vltime $time
78 # Setting both preferred and valid lifetimes (same value)
79 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
80 pltime $time vltime $time
81 $DEBUG && rump.ifconfig -L shmif0
82 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
83 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
84 atf_check -s exit:0 sleep $(($time + $bonus))
85 $DEBUG && rump.ifconfig -L shmif0
86 # Shouldn't remain anymore
87 atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
89 # Setting both preferred and valid lifetimes (pltime > vltime)
90 atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \
91 shmif0 inet6 $ip pltime $(($time * 2)) vltime $time
93 # Setting both preferred and valid lifetimes (pltime < vltime)
94 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
95 pltime $time vltime $((time * 2))
96 $DEBUG && rump.ifconfig -L shmif0
97 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
98 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
100 if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
102 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
103 atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
106 atf_check -s exit:0 sleep $(($time + $bonus))
107 $DEBUG && rump.ifconfig -L shmif0
108 # Should remain but marked as deprecated
109 atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0
110 atf_check -s exit:0 sleep $(($time + $bonus))
111 $DEBUG && rump.ifconfig -L shmif0
112 # Shouldn't remain anymore
113 atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
115 rump_server_destroy_ifaces
124 atf_init_test_cases()
126 atf_add_test_case basic