1193323Sed# $NetBSD: t_ifconf.sh,v 1.4 2019/05/13 17:55:08 bad Exp $ 2193323Sed# 3193323Sed# Copyright (c) 2014 The NetBSD Foundation, Inc. 4193323Sed# All rights reserved. 5193323Sed# 6193323Sed# Redistribution and use in source and binary forms, with or without 7193323Sed# modification, are permitted provided that the following conditions 8193323Sed# are met: 9193323Sed# 1. Redistributions of source code must retain the above copyright 10193323Sed# notice, this list of conditions and the following disclaimer. 11193323Sed# 2. Redistributions in binary form must reproduce the above copyright 12193323Sed# notice, this list of conditions and the following disclaimer in the 13193323Sed# documentation and/or other materials provided with the distribution. 14193323Sed# 15193323Sed# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16193323Sed# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17193323Sed# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18193323Sed# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19212904Sdim# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20218893Sdim# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21193323Sed# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22193323Sed# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23193323Sed# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24193323Sed# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25193323Sed# POSSIBILITY OF SUCH DAMAGE. 26193323Sed# 27193323Sed 28193323SedRUMP_SERVER1=unix://./r1 29193323Sed 30193323SedRUMP_FLAGS=\ 31193323Sed"-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" 32193323Sed 33193323Sedatf_test_case basic cleanup 34193323Sedbasic_head() 35198090Srdivacky{ 36193323Sed 37193323Sed atf_set "descr" "basic ifconf (SIOCGIFCONF) test" 38193323Sed atf_set "require.progs" "rump_server" 39193323Sed} 40193323Sed 41193323Sedbasic_body() 42193323Sed{ 43193323Sed local ifconf="$(atf_get_srcdir)/ifconf" 44193323Sed 45193323Sed atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1} 46193323Sed 47193323Sed export RUMP_SERVER=${RUMP_SERVER1} 48193323Sed export LD_PRELOAD=/usr/lib/librumphijack.so 49193323Sed 50193323Sed # lo0 (127.0.0.1 and link local) 51193323Sed atf_check -s exit:0 -o match:'^2$' "$ifconf" total 52193323Sed atf_check -s exit:0 -o match:'lo0' "$ifconf" list 53193323Sed 54193323Sed # Add shmif0 (no address) 55193323Sed atf_check -s exit:0 rump.ifconfig shmif0 create 56193323Sed atf_check -s exit:0 -o match:'^3$' "$ifconf" total 57193323Sed atf_check -s exit:0 -o match:'shmif0' "$ifconf" list 58193323Sed 59193323Sed # Add shmif1 (no address) 60193323Sed atf_check -s exit:0 rump.ifconfig shmif1 create 61193323Sed atf_check -s exit:0 -o match:'^4$' "$ifconf" total 62193323Sed atf_check -s exit:0 -o match:'shmif1' "$ifconf" list 63193323Sed 64193323Sed # Add an address to shmif0 65193323Sed atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 66193323Sed atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24 67193323Sed atf_check -s exit:0 -o match:'^5$' "$ifconf" total 68193323Sed 69193323Sed # Vary the number of requesting interfaces 70193323Sed atf_check -s exit:0 -o match:1 -x "$ifconf list 1 | wc -l" 71193323Sed atf_check -s exit:0 -o match:2 -x "$ifconf list 2 | wc -l" 72193323Sed atf_check -s exit:0 -o match:3 -x "$ifconf list 3 | wc -l" 73193323Sed atf_check -s exit:0 -o match:4 -x "$ifconf list 4 | wc -l" 74193323Sed atf_check -s exit:0 -o match:5 -x "$ifconf list 5 | wc -l" 75193323Sed atf_check -s exit:0 -o match:5 -x "$ifconf list 6 | wc -l" 76193323Sed 77193323Sed # Check if removing an interface is reflected 78193323Sed atf_check -s exit:0 rump.ifconfig shmif0 destroy 79193323Sed atf_check -s exit:0 -o match:'^3$' "$ifconf" total 80193323Sed atf_check -s exit:0 -o not-match:'shmif0' "$ifconf" list 81193323Sed atf_check -s exit:0 -o match:1 -x "$ifconf list 1 | wc -l" 82193323Sed atf_check -s exit:0 -o match:2 -x "$ifconf list 2 | wc -l" 83193323Sed atf_check -s exit:0 -o match:3 -x "$ifconf list 3 | wc -l" 84193323Sed atf_check -s exit:0 -o match:3 -x "$ifconf list 4 | wc -l" 85193323Sed 86193323Sed unset LD_PRELOAD 87193323Sed unset RUMP_SERVER 88193323Sed} 89193323Sed 90193323Sedbasic_cleanup() 91193323Sed{ 92193323Sed 93193323Sed RUMP_SERVER=${RUMP_SERVER1} rump.halt 94212904Sdim} 95193323Sed 96193323Sedatf_init_test_cases() 97193323Sed{ 98193323Sed 99193323Sed atf_add_test_case basic 100193323Sed} 101193323Sed