1# $NetBSD: t_ifconfig.sh,v 1.3 2015/09/15 09:51:01 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 28RUMP_SERVER1=unix://./r1 29 30RUMP_FLAGS=\ 31"-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif" 32 33atf_test_case create_destroy cleanup 34create_destroy_head() 35{ 36 37 atf_set "descr" "tests of ifconfig create and destroy" 38 atf_set "require.progs" "rump_server" 39} 40 41create_destroy_body() 42{ 43 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1} 44 45 export RUMP_SERVER=${RUMP_SERVER1} 46 47 # Create and destroy (no address) 48 atf_check -s exit:0 rump.ifconfig shmif0 create 49 atf_check -s exit:0 rump.ifconfig shmif0 destroy 50 51 # Create and destroy (with an IPv4 address) 52 atf_check -s exit:0 rump.ifconfig shmif0 create 53 atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 54 atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24 55 atf_check -s exit:0 rump.ifconfig shmif0 up 56 atf_check -s exit:0 rump.ifconfig shmif0 destroy 57 58 # Create and destroy (with an IPv6 address) 59 atf_check -s exit:0 rump.ifconfig shmif0 create 60 atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 61 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 62 atf_check -s exit:0 rump.ifconfig shmif0 up 63 atf_check -s exit:0 rump.ifconfig shmif0 destroy 64 65 unset RUMP_SERVER 66} 67 68create_destroy_cleanup() 69{ 70 71 RUMP_SERVER=${RUMP_SERVER1} rump.halt 72} 73 74atf_test_case options cleanup 75options_head() 76{ 77 78 atf_set "descr" "tests of ifconfig options" 79 atf_set "require.progs" "rump_server" 80} 81 82options_body() 83{ 84 85 export RUMP_SERVER=${RUMP_SERVER1} 86 atf_check -s exit:0 rump_server $RUMP_FLAGS $RUMP_SERVER1 87 88 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create 89 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr bus1 90 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet 10.0.0.1/24 91 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::1/64 92 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 93 atf_check -s exit:0 -o ignore rump.ifconfig -w 10 94 $DEBUG && rump.ifconfig shmif0 95 96 # ifconfig [-N] interface address_family 97 # -N resolves hostnames 98 atf_check -s exit:0 -o match:'inet 127.0.0.1' rump.ifconfig lo0 inet 99 atf_check -s exit:0 -o match:'inet localhost' rump.ifconfig -N lo0 inet 100 atf_check -s exit:0 -o match:'inet6 ::1' rump.ifconfig lo0 inet6 101 atf_check -s exit:0 -o match:'inet6 localhost' rump.ifconfig -N lo0 inet6 102 atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig lo0 atalk 103 atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig -N lo0 atalk 104 atf_check -s exit:0 -o ignore rump.ifconfig lo0 link 105 atf_check -s exit:0 -o ignore rump.ifconfig -N lo0 link 106 107 # ifconfig [-hLmNvz] interface 108 # -h -v shows statistics in human readable format 109 atf_check -s exit:0 -o ignore rump.ifconfig -h -v lo0 110 # -L shows IPv6 lifetime 111 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::2 \ 112 pltime 100 113 $DEBUG && rump.ifconfig -L shmif0 114 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0 115 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0 116 # -m shows all of the supported media (not supported in shmif) 117 $DEBUG && rump.ifconfig -m shmif0 118 atf_check -s exit:0 -o ignore rump.ifconfig -m shmif0 119 atf_check -s exit:0 -o match:'localhost' rump.ifconfig -N lo0 120 atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0 121 atf_check -s exit:0 -o ignore rump.ping -c 1 localhost 122 # -z clears and shows statistics at that point 123 atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -z lo0 124 atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0 125 126 # ifconfig -a [-bdhLNmsuvz] 127 # -a shows all interfaces in the system 128 $DEBUG && rump.ifconfig -a 129 atf_check -s exit:0 -o match:'shmif0' -o match:'lo0' rump.ifconfig -a 130 # -a -b shows only broadcast interfaces 131 atf_check -s exit:0 -o match:'shmif0' -o not-match:'lo0' rump.ifconfig -a -b 132 # -a -d shows only down interfaces 133 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down 134 atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -d 135 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 136 atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -d 137 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -a -L 138 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -a -L 139 atf_check -s exit:0 -o match:'localhost' rump.ifconfig -a -N 140 atf_check -s exit:0 -o ignore rump.ifconfig -a -m 141 # -a -s shows only interfaces connected to a network 142 # (shmif is always connected) 143 $DEBUG && rump.ifconfig -a -s 144 atf_check -s exit:0 -o ignore rump.ifconfig -a -s 145 # -a -u shows only up interfaces 146 atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -u 147 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down 148 atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -u 149 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 150 atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v 151 atf_check -s exit:0 -o ignore rump.ping -c 1 localhost 152 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down 153 atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -a -z 154 atf_check -s exit:0 -o not-match:'2 packets' rump.ifconfig -a -v 155 atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v 156 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 157 158 # ifconfig -l [-bdsu] 159 # -l shows only inteface names 160 atf_check -s exit:0 -o match:'lo0 shmif0' rump.ifconfig -l 161 atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -b 162 atf_check -s exit:0 -o ignore rump.ifconfig -l -d 163 atf_check -s exit:0 -o match:'lo0 shmif0' rump.ifconfig -l -s 164 atf_check -s exit:0 -o match:'lo0 shmif0' rump.ifconfig -l -u 165 166 # ifconfig -s interface 167 # -s interface exists with 0 / 1 if connected / disconnected 168 atf_check -s exit:0 -o empty rump.ifconfig -s lo0 169 atf_check -s exit:0 -o empty rump.ifconfig -s shmif0 170 171 # ifconfig -C 172 # -C shows all of the interface cloners available on the system 173 atf_check -s exit:0 -o match:'shmif lo carp' rump.ifconfig -C 174 175 unset RUMP_SERVER 176} 177 178options_cleanup() 179{ 180 181 env RUMP_SERVER=${RUMP_SERVER1} rump.halt 182} 183 184atf_init_test_cases() 185{ 186 187 atf_add_test_case create_destroy 188 atf_add_test_case options 189} 190