Home | History | Annotate | Line # | Download | only in if
      1  1.4    bad # $NetBSD: t_ifconf.sh,v 1.4 2019/05/13 17:55:08 bad Exp $
      2  1.1  ozaki #
      3  1.1  ozaki # Copyright (c) 2014 The NetBSD Foundation, Inc.
      4  1.1  ozaki # All rights reserved.
      5  1.1  ozaki #
      6  1.1  ozaki # Redistribution and use in source and binary forms, with or without
      7  1.1  ozaki # modification, are permitted provided that the following conditions
      8  1.1  ozaki # are met:
      9  1.1  ozaki # 1. Redistributions of source code must retain the above copyright
     10  1.1  ozaki #    notice, this list of conditions and the following disclaimer.
     11  1.1  ozaki # 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  ozaki #    notice, this list of conditions and the following disclaimer in the
     13  1.1  ozaki #    documentation and/or other materials provided with the distribution.
     14  1.1  ozaki #
     15  1.1  ozaki # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  ozaki # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  ozaki # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  ozaki # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  ozaki # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  ozaki # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  ozaki # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  ozaki # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  ozaki # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  ozaki # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  ozaki # POSSIBILITY OF SUCH DAMAGE.
     26  1.1  ozaki #
     27  1.1  ozaki 
     28  1.1  ozaki RUMP_SERVER1=unix://./r1
     29  1.1  ozaki 
     30  1.1  ozaki RUMP_FLAGS=\
     31  1.4    bad "-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
     32  1.1  ozaki 
     33  1.1  ozaki atf_test_case basic cleanup
     34  1.1  ozaki basic_head()
     35  1.1  ozaki {
     36  1.1  ozaki 
     37  1.1  ozaki 	atf_set "descr" "basic ifconf (SIOCGIFCONF) test"
     38  1.1  ozaki 	atf_set "require.progs" "rump_server"
     39  1.1  ozaki }
     40  1.1  ozaki 
     41  1.1  ozaki basic_body()
     42  1.1  ozaki {
     43  1.1  ozaki 	local ifconf="$(atf_get_srcdir)/ifconf"
     44  1.1  ozaki 
     45  1.1  ozaki 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
     46  1.1  ozaki 
     47  1.1  ozaki 	export RUMP_SERVER=${RUMP_SERVER1}
     48  1.1  ozaki 	export LD_PRELOAD=/usr/lib/librumphijack.so
     49  1.1  ozaki 
     50  1.1  ozaki 	# lo0 (127.0.0.1 and link local)
     51  1.1  ozaki 	atf_check -s exit:0 -o match:'^2$' "$ifconf" total
     52  1.1  ozaki 	atf_check -s exit:0 -o match:'lo0' "$ifconf" list
     53  1.1  ozaki 
     54  1.1  ozaki 	# Add shmif0 (no address)
     55  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 create
     56  1.1  ozaki 	atf_check -s exit:0 -o match:'^3$' "$ifconf" total
     57  1.1  ozaki 	atf_check -s exit:0 -o match:'shmif0' "$ifconf" list
     58  1.1  ozaki 
     59  1.1  ozaki 	# Add shmif1 (no address)
     60  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 create
     61  1.1  ozaki 	atf_check -s exit:0 -o match:'^4$' "$ifconf" total
     62  1.1  ozaki 	atf_check -s exit:0 -o match:'shmif1' "$ifconf" list
     63  1.1  ozaki 
     64  1.1  ozaki 	# Add an address to shmif0
     65  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus
     66  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1/24
     67  1.1  ozaki 	atf_check -s exit:0 -o match:'^5$' "$ifconf" total
     68  1.1  ozaki 
     69  1.2  ozaki 	# Vary the number of requesting interfaces
     70  1.2  ozaki 	atf_check -s exit:0 -o match:1 -x "$ifconf list 1 | wc -l"
     71  1.2  ozaki 	atf_check -s exit:0 -o match:2 -x "$ifconf list 2 | wc -l"
     72  1.2  ozaki 	atf_check -s exit:0 -o match:3 -x "$ifconf list 3 | wc -l"
     73  1.2  ozaki 	atf_check -s exit:0 -o match:4 -x "$ifconf list 4 | wc -l"
     74  1.2  ozaki 	atf_check -s exit:0 -o match:5 -x "$ifconf list 5 | wc -l"
     75  1.2  ozaki 	atf_check -s exit:0 -o match:5 -x "$ifconf list 6 | wc -l"
     76  1.2  ozaki 
     77  1.2  ozaki 	# Check if removing an interface is reflected
     78  1.2  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 destroy
     79  1.2  ozaki 	atf_check -s exit:0 -o match:'^3$' "$ifconf" total
     80  1.2  ozaki 	atf_check -s exit:0 -o not-match:'shmif0' "$ifconf" list
     81  1.2  ozaki 	atf_check -s exit:0 -o match:1 -x "$ifconf list 1 | wc -l"
     82  1.2  ozaki 	atf_check -s exit:0 -o match:2 -x "$ifconf list 2 | wc -l"
     83  1.2  ozaki 	atf_check -s exit:0 -o match:3 -x "$ifconf list 3 | wc -l"
     84  1.2  ozaki 	atf_check -s exit:0 -o match:3 -x "$ifconf list 4 | wc -l"
     85  1.1  ozaki 
     86  1.1  ozaki 	unset LD_PRELOAD
     87  1.1  ozaki 	unset RUMP_SERVER
     88  1.1  ozaki }
     89  1.1  ozaki 
     90  1.1  ozaki basic_cleanup()
     91  1.1  ozaki {
     92  1.1  ozaki 
     93  1.1  ozaki 	RUMP_SERVER=${RUMP_SERVER1} rump.halt
     94  1.1  ozaki }
     95  1.1  ozaki 
     96  1.1  ozaki atf_init_test_cases()
     97  1.1  ozaki {
     98  1.1  ozaki 
     99  1.1  ozaki 	atf_add_test_case basic
    100  1.1  ozaki }
    101