1*0a6a1f1dSLionel Sambuc# $NetBSD: t_ifconf.sh,v 1.1 2014/12/08 04:23:03 ozaki-r Exp $ 2*0a6a1f1dSLionel Sambuc# 3*0a6a1f1dSLionel Sambuc# Copyright (c) 2014 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_shmif" 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambucatf_test_case basic cleanup 34*0a6a1f1dSLionel Sambucbasic_head() 35*0a6a1f1dSLionel Sambuc{ 36*0a6a1f1dSLionel Sambuc 37*0a6a1f1dSLionel Sambuc atf_set "descr" "basic ifconf (SIOCGIFCONF) test" 38*0a6a1f1dSLionel Sambuc atf_set "require.progs" "rump_server" 39*0a6a1f1dSLionel Sambuc} 40*0a6a1f1dSLionel Sambuc 41*0a6a1f1dSLionel Sambucbasic_body() 42*0a6a1f1dSLionel Sambuc{ 43*0a6a1f1dSLionel Sambuc local ifconf="$(atf_get_srcdir)/ifconf" 44*0a6a1f1dSLionel Sambuc 45*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1} 46*0a6a1f1dSLionel Sambuc 47*0a6a1f1dSLionel Sambuc export RUMP_SERVER=${RUMP_SERVER1} 48*0a6a1f1dSLionel Sambuc export LD_PRELOAD=/usr/lib/librumphijack.so 49*0a6a1f1dSLionel Sambuc 50*0a6a1f1dSLionel Sambuc # lo0 (127.0.0.1 and link local) 51*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'^2$' "$ifconf" total 52*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'lo0' "$ifconf" list 53*0a6a1f1dSLionel Sambuc 54*0a6a1f1dSLionel Sambuc # Add shmif0 (no address) 55*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 56*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'^3$' "$ifconf" total 57*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif0' "$ifconf" list 58*0a6a1f1dSLionel Sambuc 59*0a6a1f1dSLionel Sambuc # Add shmif1 (no address) 60*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif1 create 61*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'^4$' "$ifconf" total 62*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'shmif1' "$ifconf" list 63*0a6a1f1dSLionel Sambuc 64*0a6a1f1dSLionel Sambuc # Add an address to shmif0 65*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 66*0a6a1f1dSLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24 67*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o match:'^5$' "$ifconf" total 68*0a6a1f1dSLionel Sambuc 69*0a6a1f1dSLionel Sambuc # Get only first two entries (lo0's) 70*0a6a1f1dSLionel Sambuc atf_check -s exit:0 -o not-match:'shmif' "$ifconf" list 2 71*0a6a1f1dSLionel Sambuc 72*0a6a1f1dSLionel Sambuc unset LD_PRELOAD 73*0a6a1f1dSLionel Sambuc unset RUMP_SERVER 74*0a6a1f1dSLionel Sambuc} 75*0a6a1f1dSLionel Sambuc 76*0a6a1f1dSLionel Sambucbasic_cleanup() 77*0a6a1f1dSLionel Sambuc{ 78*0a6a1f1dSLionel Sambuc 79*0a6a1f1dSLionel Sambuc RUMP_SERVER=${RUMP_SERVER1} rump.halt 80*0a6a1f1dSLionel Sambuc} 81*0a6a1f1dSLionel Sambuc 82*0a6a1f1dSLionel Sambucatf_init_test_cases() 83*0a6a1f1dSLionel Sambuc{ 84*0a6a1f1dSLionel Sambuc 85*0a6a1f1dSLionel Sambuc atf_add_test_case basic 86*0a6a1f1dSLionel Sambuc} 87