Home | History | Annotate | Line # | Download | only in if
      1 # $NetBSD: t_ifconfig.sh,v 1.22 2021/08/17 22:00:33 andvar 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 
     28 RUMP_SERVER1=unix://./r1
     29 RUMP_SERVER2=unix://./r2
     30 
     31 RUMP_FLAGS=\
     32 "-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif"
     33 RUMP_FLAGS="${RUMP_FLAGS}"
     34 
     35 TIMEOUT=3
     36 
     37 anycast="[Aa][Nn][Yy][Cc][Aa][Ss][Tt]"
     38 deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]"
     39 
     40 atf_test_case ifconfig_create_destroy cleanup
     41 ifconfig_create_destroy_head()
     42 {
     43 
     44 	atf_set "descr" "tests of ifconfig create and destroy"
     45 	atf_set "require.progs" "rump_server"
     46 }
     47 
     48 ifconfig_create_destroy_body()
     49 {
     50 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
     51 
     52 	export RUMP_SERVER=${RUMP_SERVER1}
     53 
     54 	# Create and destroy (no address)
     55 	atf_check -s exit:0 rump.ifconfig shmif0 create
     56 	atf_check -s exit:0 rump.ifconfig shmif0 destroy
     57 
     58 	# Create and destroy (with an IPv4 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 192.168.0.1/24
     62 	atf_check -s exit:0 rump.ifconfig shmif0 up
     63 	atf_check -s exit:0 rump.ifconfig shmif0 destroy
     64 
     65 	# Create and destroy (with an IPv6 address)
     66 	atf_check -s exit:0 rump.ifconfig shmif0 create
     67 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus
     68 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1
     69 	atf_check -s exit:0 rump.ifconfig shmif0 up
     70 	atf_check -s exit:0 rump.ifconfig shmif0 destroy
     71 
     72 	# Check if ifconfig (ioctl) works after a failure of ifconfig destroy
     73 	atf_check -s exit:0 -o ignore rump.ifconfig lo0
     74 	atf_check -s not-exit:0 -e ignore rump.ifconfig lo0 destroy
     75 	atf_check -s exit:0 -o ignore rump.ifconfig lo0
     76 
     77 	unset RUMP_SERVER
     78 }
     79 
     80 ifconfig_create_destroy_cleanup()
     81 {
     82 
     83 	RUMP_SERVER=${RUMP_SERVER1} rump.halt
     84 }
     85 
     86 atf_test_case ifconfig_options cleanup
     87 ifconfig_options_head()
     88 {
     89 
     90 	atf_set "descr" "tests of ifconfig options"
     91 	atf_set "require.progs" "rump_server"
     92 }
     93 
     94 ifconfig_options_body()
     95 {
     96 
     97 	export RUMP_SERVER=${RUMP_SERVER1}
     98 	atf_check -s exit:0 rump_server $RUMP_FLAGS $RUMP_SERVER1
     99 
    100 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
    101 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr bus1
    102 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet 10.0.0.1/24
    103 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::1/64
    104 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
    105 	atf_check -s exit:0 -o ignore rump.ifconfig -w 10
    106 	$DEBUG && rump.ifconfig shmif0
    107 
    108 	# ifconfig [-N] interface address_family
    109 	#   -N resolves hostnames
    110 	atf_check -s exit:0 -o match:'inet 127.0.0.1' rump.ifconfig lo0 inet
    111 	atf_check -s exit:0 -o match:'inet localhost' rump.ifconfig -N lo0 inet
    112 	atf_check -s exit:0 -o match:'inet6 ::1' rump.ifconfig lo0 inet6
    113 	atf_check -s exit:0 -o match:'inet6 localhost' rump.ifconfig -N lo0 inet6
    114 	atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig lo0 atalk
    115 	atf_check -s not-exit:0 -e match:'not supported' rump.ifconfig -N lo0 atalk
    116 	atf_check -s exit:0 -o ignore rump.ifconfig lo0 link
    117 	atf_check -s exit:0 -o ignore rump.ifconfig -N lo0 link
    118 
    119 	# ifconfig [-hLmNvz] interface
    120 	#   -h -v shows statistics in human readable format
    121 	atf_check -s exit:0 -o ignore rump.ifconfig -h -v lo0
    122 	#   -L shows IPv6 lifetime
    123 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 fc00::2 \
    124 	    pltime 100
    125 	$DEBUG && rump.ifconfig -L shmif0
    126 	atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
    127 	atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
    128 	#   -m shows all of the supported media (not supported in shmif)
    129 	$DEBUG && rump.ifconfig -m shmif0
    130 	atf_check -s exit:0 -o ignore rump.ifconfig -m shmif0
    131 	atf_check -s exit:0 -o match:'localhost' rump.ifconfig -N lo0
    132 	atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0
    133 	atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT localhost
    134 	#   -z clears and shows statistics at that point
    135 	atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -z lo0
    136 	atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -v lo0
    137 
    138 	# ifconfig -a [-bdhLNmsuvz]
    139 	#   -a shows all interfaces in the system
    140 	$DEBUG && rump.ifconfig -a
    141 	atf_check -s exit:0 -o match:'shmif0' -o match:'lo0' rump.ifconfig -a
    142 	#   -a -b shows only broadcast interfaces
    143 	atf_check -s exit:0 -o match:'shmif0' -o not-match:'lo0' rump.ifconfig -a -b
    144 	#   -a -d shows only down interfaces
    145 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down
    146 	atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -d
    147 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
    148 	atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -d
    149 	atf_check -s exit:0 -o match:'pltime' rump.ifconfig -a -L
    150 	atf_check -s exit:0 -o match:'vltime' rump.ifconfig -a -L
    151 	atf_check -s exit:0 -o match:'localhost' rump.ifconfig -a -N
    152 	atf_check -s exit:0 -o ignore rump.ifconfig -a -m
    153 	#   -a -s shows only interfaces connected to a network
    154 	#   (shmif is always connected)
    155 	$DEBUG && rump.ifconfig -a -s
    156 	atf_check -s exit:0 -o ignore rump.ifconfig -a -s
    157 	#   -a -u shows only up interfaces
    158 	atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -a -u
    159 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down
    160 	atf_check -s exit:0 -o not-match:'shmif0' rump.ifconfig -a -u
    161 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
    162 	atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v
    163 	atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT localhost
    164 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down
    165 	atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -a -z
    166 	atf_check -s exit:0 -o not-match:'2 packets' rump.ifconfig -a -v
    167 	atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v
    168 	atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
    169 
    170 	# ifconfig -l [-bdsu]
    171 	#   -l shows only interface names
    172 	atf_check -s exit:0 -o match:'lo0' rump.ifconfig -l
    173 	atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l
    174 	atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -b
    175 	atf_check -s exit:0 -o not-match:'lo0' rump.ifconfig -l -b
    176 	atf_check -s exit:0 -o ignore rump.ifconfig -l -d
    177 	atf_check -s exit:0 -o match:'lo0' rump.ifconfig -l -s
    178 	atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -s
    179 	atf_check -s exit:0 -o match:'lo0' rump.ifconfig -l -u
    180 	atf_check -s exit:0 -o match:'shmif0' rump.ifconfig -l -u
    181 
    182 	# ifconfig -s interface
    183 	#   -s interface exists with 0 / 1 if connected / disconnected
    184 	atf_check -s exit:0 -o empty rump.ifconfig -s lo0
    185 	atf_check -s exit:0 -o empty rump.ifconfig -s shmif0
    186 
    187 	# ifconfig -C
    188 	#   -C shows all of the interface cloners available on the system
    189 	atf_check -s exit:0 -o match:'shmif carp lo' rump.ifconfig -C
    190 
    191 	unset RUMP_SERVER
    192 }
    193 
    194 ifconfig_options_cleanup()
    195 {
    196 
    197 	env RUMP_SERVER=${RUMP_SERVER1} rump.halt
    198 }
    199 
    200 
    201 atf_test_case ifconfig_parameters cleanup
    202 ifconfig_parameters_head()
    203 {
    204 	atf_set "descr" "tests of interface parameters"
    205 	atf_set "require.progs" "rump_server"
    206 }
    207 
    208 ifconfig_parameters_body()
    209 {
    210 	local interval=
    211 
    212 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
    213 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2}
    214 
    215 	export RUMP_SERVER=${RUMP_SERVER1}
    216 	atf_check -s exit:0 rump.ifconfig shmif0 create
    217 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus
    218 	atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24
    219 	atf_check -s exit:0 rump.ifconfig shmif0 up
    220 	unset RUMP_SERVER
    221 
    222 	export RUMP_SERVER=${RUMP_SERVER2}
    223 	atf_check -s exit:0 rump.ifconfig shmif0 create
    224 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus
    225 	atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.2/24
    226 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.0.3/24 alias
    227 	atf_check -s exit:0 rump.ifconfig shmif0 up
    228 	unset RUMP_SERVER
    229 
    230 	export RUMP_SERVER=${RUMP_SERVER1}
    231 
    232 	# active
    233 	atf_check -s exit:0 rump.ifconfig shmif0 link b2:a0:75:00:00:01 active
    234 	atf_check -s exit:0 -o match:'address:.b2:a0:75:00:00:01' \
    235 	    rump.ifconfig shmif0
    236 	# down, up
    237 	atf_check -s exit:0 rump.ifconfig shmif0 down
    238 	atf_check -s not-exit:0 -o ignore -e ignore rump.ping -c 1 \
    239 	    -w $TIMEOUT -n 192.168.0.2
    240 	atf_check -s exit:0 rump.ifconfig shmif0 up
    241 	atf_check -s exit:0 rump.ifconfig -w 10
    242 	atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT -n 192.168.0.2
    243 
    244 	# alias
    245 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 alias
    246 	atf_check -s exit:0 -o match:'192.168.1.1/24' rump.ifconfig shmif0
    247 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 -alias
    248 	atf_check -s exit:0 -o not-match:'192.168.1.1/24' rump.ifconfig shmif0
    249 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1
    250 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2
    251 	atf_check -s exit:0 -o match:'fc00::1' rump.ifconfig shmif0 inet6
    252 	atf_check -s exit:0 -o match:'fc00::2' rump.ifconfig shmif0 inet6
    253 
    254 	# delete
    255 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1 alias
    256 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1 delete
    257 	atf_check -s exit:0 -o not-match:'192.168.1.1' rump.ifconfig shmif0 inet
    258 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.0.1 delete
    259 	atf_check -s exit:0 -o not-match:'192.168.0.1' rump.ifconfig shmif0 inet
    260 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 delete
    261 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 delete
    262 	atf_check -s exit:0 -o not-match:'fc00::1' rump.ifconfig shmif0 inet6
    263 	atf_check -s exit:0 -o not-match:'fc00::2' rump.ifconfig shmif0 inet6
    264 	# can delete inactive link
    265 	atf_check -s exit:0 rump.ifconfig shmif0 link b2:a0:75:00:00:02
    266 	atf_check -s exit:0 rump.ifconfig shmif0 link b2:a0:75:00:00:02 delete
    267 	# cannot delete active link
    268 	atf_check -s not-exit:0 -e match:'SIOCDLIFADDR: Device busy' \
    269 	    rump.ifconfig shmif0 link b2:a0:75:00:00:01 delete
    270 
    271 	atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.0.1/24
    272 
    273 	# arp
    274 	atf_check -s exit:0 rump.ifconfig shmif0 -arp
    275 	atf_check -s not-exit:0 -o ignore -e ignore \
    276 	    rump.ping -c 1 -w $TIMEOUT -n 192.168.0.3
    277 	atf_check -s exit:0 -o not-match:'192.168.0.3' rump.arp -an
    278 	# The entry shouldn't appear in the routing table anymore
    279 	atf_check -s exit:0 -o not-match:'192.168.0.3' rump.netstat -nr
    280 
    281 	# netmask
    282 	atf_check -s exit:0 rump.ifconfig shmif0 inet 172.16.0.1 netmask 255.255.255.0 alias
    283 	atf_check -s exit:0 -o match:'172.16.0/24' rump.netstat -rn -f inet
    284 	atf_check -s exit:0 rump.ifconfig shmif0 inet 172.16.0.1 delete
    285 
    286 	# broadcast (does it not work?)
    287 	atf_check -s exit:0 rump.ifconfig shmif0 inet 172.16.0.1 \
    288 	    broadcast 255.255.255.255 alias
    289 	atf_check -s exit:0 -o match:'broadcast 255.255.255.255' \
    290 	    rump.ifconfig shmif0 inet
    291 
    292 	# metric (external only)
    293 	atf_check -s exit:0 rump.ifconfig shmif0 metric 10
    294 	atf_check -s exit:0 rump.ifconfig shmif0 metric 0
    295 
    296 	# prefixlen
    297 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 prefixlen 70
    298 	atf_check -s exit:0 -o match:'fc00::/70' rump.netstat -rn -f inet6
    299 
    300 	# anycast
    301 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 anycast
    302 	atf_check -s exit:0 -o match:"fc00::2.+$anycast" rump.ifconfig shmif0 inet6
    303 
    304 	# deprecated
    305 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 deprecated
    306 	# Not deprecated immediately. Need to wait nd6_timer that does it is scheduled.
    307 	interval=$(sysctl -n net.inet6.icmp6.nd6_prune)
    308 	atf_check -s exit:0 sleep $((interval + 1))
    309 	atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
    310 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 -deprecated
    311 	atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
    312 
    313 	# pltime
    314 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 pltime 3
    315 	atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
    316 	atf_check -s exit:0 sleep 5
    317 	atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
    318 
    319 	# eui64
    320 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00:1::0 eui64
    321 	atf_check -s exit:0 -o match:'fc00:1::' rump.ifconfig shmif0 inet6
    322 
    323 	unset RUMP_SERVER
    324 }
    325 
    326 ifconfig_parameters_cleanup()
    327 {
    328 	env RUMP_SERVER=${RUMP_SERVER1} rump.halt
    329 	env RUMP_SERVER=${RUMP_SERVER2} rump.halt
    330 }
    331 
    332 ifconfig_up_down_common()
    333 {
    334 	local family=$1
    335 	local ip=$2
    336 
    337 	if [ $family = inet6 ]; then
    338 		rump_server_start $RUMP_SERVER1 netinet6
    339 	else
    340 		rump_server_start $RUMP_SERVER1
    341 	fi
    342 	rump_server_add_iface $RUMP_SERVER1 shmif0 bus1
    343 
    344 	export RUMP_SERVER=$RUMP_SERVER1
    345 	rump.ifconfig shmif0
    346 
    347 	# Set the same number of trials to make the following test
    348 	# work for both IPv4 and IPv6
    349 	if [ $family = inet6 ]; then
    350 		atf_check -s exit:0 -o ignore \
    351 		    rump.sysctl -w net.inet6.ip6.dad_count=5
    352 	else
    353 		atf_check -s exit:0 -o ignore \
    354 		    rump.sysctl -w net.inet.ip.dad_count=5
    355 	fi
    356 
    357 	#
    358 	# Assign an address and up the interface at once
    359 	#
    360 	atf_check -s exit:0 rump.ifconfig shmif0 $family $ip/24 up
    361 	# UP
    362 	atf_check -s exit:0 \
    363 	    -o match:'shmif0.*UP.*RUNNING' rump.ifconfig shmif0
    364 	# The address is TENTATIVE
    365 	atf_check -s exit:0 \
    366 	    -o match:"$ip.*TENTATIVE" rump.ifconfig shmif0
    367 	# Waiting for DAD completion
    368 	atf_check -s exit:0 rump.ifconfig -w 10
    369 	# The address left TENTATIVE
    370 	atf_check -s exit:0 \
    371 	    -o not-match:"$ip.*TENTATIVE" rump.ifconfig shmif0
    372 
    373 	#
    374 	# ifconfig down
    375 	#
    376 	atf_check -s exit:0 rump.ifconfig shmif0 down
    377 	atf_check -s exit:0 \
    378 	    -o not-match:'shmif0.*UP.*RUNNING' rump.ifconfig shmif0
    379 	# The address becomes DETATCHED
    380 	atf_check -s exit:0 \
    381 	    -o match:"$ip.*DETACHED" rump.ifconfig shmif0
    382 	# ifconfig up
    383 	atf_check -s exit:0 rump.ifconfig shmif0 up
    384 	# The address becomes TENTATIVE
    385 	atf_check -s exit:0 \
    386 	    -o match:"$ip.*TENTATIVE" rump.ifconfig shmif0
    387 	# Waiting for DAD completion
    388 	atf_check -s exit:0 rump.ifconfig -w 10
    389 	# The address left TENTATIVE
    390 	atf_check -s exit:0 \
    391 	    -o not-match:"$ip.*TENTATIVE" rump.ifconfig shmif0
    392 
    393 	# Clean up
    394 	atf_check -s exit:0 rump.ifconfig shmif0 $family $ip delete
    395 
    396 	#
    397 	# Assign an address
    398 	#
    399 	atf_check -s exit:0 rump.ifconfig shmif0 $family $ip/24
    400 	# UP automatically
    401 	atf_check -s exit:0 \
    402 	    -o match:'shmif0.*UP.*RUNNING' rump.ifconfig shmif0
    403 	# Need some delay
    404 	sleep 1
    405 	# The IP becomes TENTATIVE
    406 	atf_check -s exit:0 \
    407 	    -o match:"$ip.*TENTATIVE" rump.ifconfig shmif0
    408 	# Waiting for DAD completion
    409 	atf_check -s exit:0 rump.ifconfig -w 10
    410 	# The address left TENTATIVE
    411 	atf_check -s exit:0 \
    412 	    -o not-match:"$ip.*TENTATIVE" rump.ifconfig shmif0
    413 
    414 	rump_server_destroy_ifaces
    415 }
    416 
    417 atf_test_case ifconfig_up_down_ipv4 cleanup
    418 ifconfig_up_down_ipv4_head()
    419 {
    420 	atf_set "descr" "tests of interface up/down (IPv4)"
    421 	atf_set "require.progs" "rump_server"
    422 }
    423 
    424 ifconfig_up_down_ipv4_body()
    425 {
    426 
    427 	ifconfig_up_down_common inet 10.0.0.1
    428 }
    429 
    430 ifconfig_up_down_ipv4_cleanup()
    431 {
    432 
    433 	$DEBUG && dump
    434 	cleanup
    435 }
    436 
    437 atf_test_case ifconfig_up_down_ipv6 cleanup
    438 ifconfig_up_down_ipv6_head()
    439 {
    440 	atf_set "descr" "tests of interface up/down (IPv6)"
    441 	atf_set "require.progs" "rump_server"
    442 }
    443 
    444 ifconfig_up_down_ipv6_body()
    445 {
    446 
    447 	ifconfig_up_down_common inet6 fc00::1
    448 }
    449 
    450 ifconfig_up_down_ipv6_cleanup()
    451 {
    452 
    453 	$DEBUG && dump
    454 	cleanup
    455 }
    456 
    457 atf_test_case ifconfig_number cleanup
    458 ifconfig_number_head()
    459 {
    460 	atf_set "descr" "tests of passing a number (if_index) to ifconfig"
    461 	atf_set "require.progs" "rump_server"
    462 }
    463 
    464 ifconfig_number_body()
    465 {
    466 
    467 	rump_server_start $RUMP_SERVER1
    468 	rump_server_add_iface $RUMP_SERVER1 shmif0 bus1
    469 
    470 	export RUMP_SERVER=$RUMP_SERVER1
    471 	atf_check -s not-exit:0 -e match:'Device not configured' rump.ifconfig 0
    472 	atf_check -s exit:0 rump.ifconfig 1 # lo0
    473 	atf_check -s exit:0 rump.ifconfig 2 # shmif0
    474 	atf_check -s not-exit:0 -e match:'Device not configured' rump.ifconfig 3
    475 
    476 	rump_server_destroy_ifaces
    477 }
    478 
    479 ifconfig_number_cleanup()
    480 {
    481 
    482 	$DEBUG && dump
    483 	cleanup
    484 }
    485 
    486 atf_test_case ifconfig_description cleanup
    487 ifconfig_description_head()
    488 {
    489 	atf_set "descr" "tests of setting and unsetting interface description"
    490 	atf_set "require.progs" "rump_server"
    491 }
    492 
    493 ifconfig_description_body()
    494 {
    495 
    496 	rump_server_start $RUMP_SERVER1
    497 
    498 	export RUMP_SERVER=$RUMP_SERVER1
    499 	for descr in description descr; do
    500 		atf_check -s exit:0 rump.ifconfig lo0 $descr DESCRIPTION-TEST
    501 		atf_check -s exit:0 -o match:"DESCRIPTION-TEST" rump.ifconfig lo0
    502 		atf_check -s exit:0 rump.ifconfig lo0 $descr DESCRIPTION-TEST-MODIFIED
    503 		atf_check -s exit:0 -o match:"DESCRIPTION-TEST-MODIFIED" rump.ifconfig lo0
    504 		atf_check -s exit:0 rump.ifconfig lo0 -$descr
    505 		atf_check -s exit:0 -o not-match:'DESCRIPTION-TEST-MODIFIED' rump.ifconfig lo0
    506 
    507 		atf_check -s exit:0 rump.ifconfig lo0 $descr `printf "%063d" 0`	
    508 		atf_check -s not-exit:0 -e match:"description too long" rump.ifconfig lo0 $descr `printf "%064d" 0`
    509 		atf_check -s exit:0 rump.ifconfig lo0 $descr ""
    510 	done
    511 }
    512 
    513 ifconfig_description_cleanup()
    514 {
    515 
    516 	$DEBUG && dump
    517 	cleanup
    518 }
    519 
    520 atf_init_test_cases()
    521 {
    522 
    523 	atf_add_test_case ifconfig_create_destroy
    524 	atf_add_test_case ifconfig_options
    525 	atf_add_test_case ifconfig_parameters
    526 	atf_add_test_case ifconfig_up_down_ipv4
    527 	atf_add_test_case ifconfig_up_down_ipv6
    528 	atf_add_test_case ifconfig_number
    529 	atf_add_test_case ifconfig_description
    530 }
    531