t_ipv6_lifetime.sh revision 313535
1# $NetBSD: t_ipv6_lifetime.sh,v 1.6 2016/11/25 08:51:17 ozaki-r Exp $ 2# 3# Copyright (c) 2015 The NetBSD Foundation, 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 28SOCK=unix://sock 29BUS=./bus 30 31DEBUG=${DEBUG:-false} 32 33deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]" 34 35atf_test_case basic cleanup 36 37basic_head() 38{ 39 atf_set "descr" "Tests for IPv6 address lifetime" 40 atf_set "require.progs" "rump_server" 41} 42 43basic_body() 44{ 45 local time=5 46 local bonus=2 47 local ip="fc00::1" 48 49 rump_server_start $SOCK netinet6 50 rump_server_add_iface $SOCK shmif0 $BUS 51 52 export RUMP_SERVER=$SOCK 53 54 atf_check -s exit:0 rump.ifconfig shmif0 up 55 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 62 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 73 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 77 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 88 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 92 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 99 100 if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1 101 then 102 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete 103 atf_skip "unreliable under qemu, skip until PR kern/43997 fixed" 104 fi 105 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 114 115 rump_server_destroy_ifaces 116} 117 118basic_cleanup() 119{ 120 $DEBUG && dump 121 cleanup 122} 123 124atf_init_test_cases() 125{ 126 atf_add_test_case basic 127} 128