1*0a6a1f1dSLionel Sambuc# $NetBSD: t_ifconfig.sh,v 1.3 2015/09/15 09:51:01 ozaki-r Exp $ 2*0a6a1f1dSLionel Sambuc# 3*0a6a1f1dSLionel Sambuc# Copyright (c) 2015 The NetBSD Foundation, Inc. 4*0a6a1f1dSLionel Sambuc# All rights reserved. 5*0a6a1f1dSLionel Sambuc# 6*0a6a1f1dSLionel Sambuc# Redistribution and use in source and binary forms, with or without 7*0a6a1f1dSLionel Sambuc# modification, are permitted provided that the following conditions 8*0a6a1f1dSLionel Sambuc# are met: 9*0a6a1f1dSLionel Sambuc# 1. Redistributions of source code must retain the above copyright 10*0a6a1f1dSLionel Sambuc# notice, this list of conditions and the following disclaimer. 11*0a6a1f1dSLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 12*0a6a1f1dSLionel Sambuc# notice, this list of conditions and the following disclaimer in the 13*0a6a1f1dSLionel Sambuc# documentation and/or other materials provided with the distribution. 14*0a6a1f1dSLionel Sambuc# 15*0a6a1f1dSLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16*0a6a1f1dSLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17*0a6a1f1dSLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18*0a6a1f1dSLionel Sambuc# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19*0a6a1f1dSLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20*0a6a1f1dSLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21*0a6a1f1dSLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22*0a6a1f1dSLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23*0a6a1f1dSLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24*0a6a1f1dSLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25*0a6a1f1dSLionel Sambuc# POSSIBILITY OF SUCH DAMAGE. 26*0a6a1f1dSLionel Sambuc# 27*0a6a1f1dSLionel Sambuc 28*0a6a1f1dSLionel SambucRUMP_SERVER1=unix://./r1 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel SambucRUMP_FLAGS=\ 31*0a6a1f1dSLionel Sambuc"-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif" 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambucatf_test_case create_destroy cleanup 34*0a6a1f1dSLionel Sambuccreate_destroy_head() 35*0a6a1f1dSLionel Sambuc{ 36*0a6a1f1dSLionel Sambuc 37*0a6a1f1dSLionel Sambuc atf_set "descr" "tests of ifconfig create and destroy" 38*0a6a1f1dSLionel Sambuc atf_set "require.progs" "rump_server" 39*0a6a1f1dSLionel Sambuc} 40*0a6a1f1dSLionel Sambuc 41*0a6a1f1dSLionel Sambuccreate_destroy_body() 42*0a6a1f1dSLionel Sambuc{ 43*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1} 44*0a6a1f1dSLionel Sambuc 45*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 46*0a6a1f1dSLionel Sambuc 47*0a6a1f1dSLionel Sambuc # Create and destroy (no address) 48*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 49*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 destroy 50*0a6a1f1dSLionel Sambuc 51*0a6a1f1dSLionel Sambuc # Create and destroy (with an IPv4 address) 52*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 53*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 54*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24 55*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 up 56*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 destroy 57*0a6a1f1dSLionel Sambuc 58*0a6a1f1dSLionel Sambuc # Create and destroy (with an IPv6 address) 59*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 60*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 61*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 62*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 up 63*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 destroy 64*0a6a1f1dSLionel Sambuc 65*0a6a1f1dSLionel Sambuc unset RUMP_SERVER 66*0a6a1f1dSLionel Sambuc} 67*0a6a1f1dSLionel Sambuc 68*0a6a1f1dSLionel Sambuccreate_destroy_cleanup() 69*0a6a1f1dSLionel Sambuc{ 70*0a6a1f1dSLionel Sambuc 71*0a6a1f1dSLionel Sambuc RUMP_SERVER=${RUMP_SERVER1} rump.halt 72*0a6a1f1dSLionel Sambuc} 73*0a6a1f1dSLionel Sambuc 74*0a6a1f1dSLionel Sambucatf_test_case options cleanup 75*0a6a1f1dSLionel Sambucoptions_head() 76*0a6a1f1dSLionel Sambuc{ 77*0a6a1f1dSLionel Sambuc 78*0a6a1f1dSLionel Sambuc atf_set "descr" "tests of ifconfig options" 79*0a6a1f1dSLionel Sambuc atf_set "require.progs" "rump_server" 80*0a6a1f1dSLionel Sambuc} 81*0a6a1f1dSLionel Sambuc 82*0a6a1f1dSLionel Sambucoptions_body() 83*0a6a1f1dSLionel Sambuc{ 84*0a6a1f1dSLionel Sambuc 85*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 86*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server $RUMP_FLAGS $RUMP_SERVER1 87*0a6a1f1dSLionel Sambuc 88*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create 89*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr bus1 90*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet 10.0.0.1/24 91*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::1/64 92*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 93*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -w 10 94*0a6a1f1dSLionel Sambuc $DEBUG && rump.ifconfig shmif0 95*0a6a1f1dSLionel Sambuc 96*0a6a1f1dSLionel Sambuc # ifconfig [-N] interface address_family 97*0a6a1f1dSLionel Sambuc # -N resolves hostnames 98*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'inet 127.0.0.1' rump.ifconfig lo0 inet 99*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'inet localhost' rump.ifconfig -N lo0 inet 100*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'inet6 ::1' rump.ifconfig lo0 inet6 101*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'inet6 localhost' rump.ifconfig -N lo0 inet6 102*0a6a1f1dSLionel Sambuc atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig lo0 atalk 103*0a6a1f1dSLionel Sambuc atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig -N lo0 atalk 104*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig lo0 link 105*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -N lo0 link 106*0a6a1f1dSLionel Sambuc 107*0a6a1f1dSLionel Sambuc # ifconfig [-hLmNvz] interface 108*0a6a1f1dSLionel Sambuc # -h -v shows statistics in human readable format 109*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -h -v lo0 110*0a6a1f1dSLionel Sambuc # -L shows IPv6 lifetime 111*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::2 \ 112*0a6a1f1dSLionel Sambuc pltime 100 113*0a6a1f1dSLionel Sambuc $DEBUG && rump.ifconfig -L shmif0 114*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0 115*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0 116*0a6a1f1dSLionel Sambuc # -m shows all of the supported media (not supported in shmif) 117*0a6a1f1dSLionel Sambuc $DEBUG && rump.ifconfig -m shmif0 118*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -m shmif0 119*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'localhost' rump.ifconfig -N lo0 120*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0 121*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ping -c 1 localhost 122*0a6a1f1dSLionel Sambuc # -z clears and shows statistics at that point 123*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -z lo0 124*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0 125*0a6a1f1dSLionel Sambuc 126*0a6a1f1dSLionel Sambuc # ifconfig -a [-bdhLNmsuvz] 127*0a6a1f1dSLionel Sambuc # -a shows all interfaces in the system 128*0a6a1f1dSLionel Sambuc $DEBUG && rump.ifconfig -a 129*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif0' -o match:'lo0' rump.ifconfig -a 130*0a6a1f1dSLionel Sambuc # -a -b shows only broadcast interfaces 131*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif0' -o not-match:'lo0' rump.ifconfig -a -b 132*0a6a1f1dSLionel Sambuc # -a -d shows only down interfaces 133*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down 134*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -d 135*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 136*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -d 137*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'pltime' rump.ifconfig -a -L 138*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'vltime' rump.ifconfig -a -L 139*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'localhost' rump.ifconfig -a -N 140*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -a -m 141*0a6a1f1dSLionel Sambuc # -a -s shows only interfaces connected to a network 142*0a6a1f1dSLionel Sambuc # (shmif is always connected) 143*0a6a1f1dSLionel Sambuc $DEBUG && rump.ifconfig -a -s 144*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -a -s 145*0a6a1f1dSLionel Sambuc # -a -u shows only up interfaces 146*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -u 147*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down 148*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -u 149*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 150*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v 151*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ping -c 1 localhost 152*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down 153*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -a -z 154*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o not-match:'2 packets' rump.ifconfig -a -v 155*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v 156*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up 157*0a6a1f1dSLionel Sambuc 158*0a6a1f1dSLionel Sambuc # ifconfig -l [-bdsu] 159*0a6a1f1dSLionel Sambuc # -l shows only inteface names 160*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'lo0 shmif0' rump.ifconfig -l 161*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -b 162*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o ignore rump.ifconfig -l -d 163*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'lo0 shmif0' rump.ifconfig -l -s 164*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'lo0 shmif0' rump.ifconfig -l -u 165*0a6a1f1dSLionel Sambuc 166*0a6a1f1dSLionel Sambuc # ifconfig -s interface 167*0a6a1f1dSLionel Sambuc # -s interface exists with 0 / 1 if connected / disconnected 168*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o empty rump.ifconfig -s lo0 169*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o empty rump.ifconfig -s shmif0 170*0a6a1f1dSLionel Sambuc 171*0a6a1f1dSLionel Sambuc # ifconfig -C 172*0a6a1f1dSLionel Sambuc # -C shows all of the interface cloners available on the system 173*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif lo carp' rump.ifconfig -C 174*0a6a1f1dSLionel Sambuc 175*0a6a1f1dSLionel Sambuc unset RUMP_SERVER 176*0a6a1f1dSLionel Sambuc} 177*0a6a1f1dSLionel Sambuc 178*0a6a1f1dSLionel Sambucoptions_cleanup() 179*0a6a1f1dSLionel Sambuc{ 180*0a6a1f1dSLionel Sambuc 181*0a6a1f1dSLionel Sambuc env RUMP_SERVER=${RUMP_SERVER1} rump.halt 182*0a6a1f1dSLionel Sambuc} 183*0a6a1f1dSLionel Sambuc 184*0a6a1f1dSLionel Sambucatf_init_test_cases() 185*0a6a1f1dSLionel Sambuc{ 186*0a6a1f1dSLionel Sambuc 187*0a6a1f1dSLionel Sambuc atf_add_test_case create_destroy 188*0a6a1f1dSLionel Sambuc atf_add_test_case options 189*0a6a1f1dSLionel Sambuc} 190