Home | History | Annotate | Line # | Download | only in inpcb
t_inpcb_bind.sh revision 1.1
      1  1.1  ozaki #	$NetBSD: t_inpcb_bind.sh,v 1.1 2022/11/17 08:40:23 ozaki-r Exp $
      2  1.1  ozaki #
      3  1.1  ozaki # Copyright (c) 2022 Internet Initiative Japan 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 SOCK=unix://inpcb_bind
     29  1.1  ozaki BUS=./bus
     30  1.1  ozaki 
     31  1.1  ozaki DEBUG=${DEBUG:-false}
     32  1.1  ozaki NAME="inpcb_bind"
     33  1.1  ozaki 
     34  1.1  ozaki test_inpcb_bind_ipv4()
     35  1.1  ozaki {
     36  1.1  ozaki 	local addr="10.0.0.10"
     37  1.1  ozaki 	local port=23000
     38  1.1  ozaki 	local prog="$(atf_get_srcdir)/inpcb_bind"
     39  1.1  ozaki 
     40  1.1  ozaki 	rump_server_start $SOCK
     41  1.1  ozaki 	rump_server_add_iface $SOCK shmif0 $BUS
     42  1.1  ozaki 
     43  1.1  ozaki 	export RUMP_SERVER=$SOCK
     44  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 $addr/24
     45  1.1  ozaki 	atf_check -s exit:0 -o ignore $HIJACKING $prog $addr $port
     46  1.1  ozaki 	atf_check -s exit:0 -o ignore $HIJACKING $prog 224.0.2.1 $port $addr
     47  1.1  ozaki }
     48  1.1  ozaki 
     49  1.1  ozaki test_inpcb_bind_ipv6()
     50  1.1  ozaki {
     51  1.1  ozaki 	local addr="fc00::10"
     52  1.1  ozaki 	local port=23000
     53  1.1  ozaki 	local prog="$(atf_get_srcdir)/inpcb_bind"
     54  1.1  ozaki 
     55  1.1  ozaki 	rump_server_start $SOCK netinet6
     56  1.1  ozaki 	rump_server_add_iface $SOCK shmif0 $BUS
     57  1.1  ozaki 
     58  1.1  ozaki 	export RUMP_SERVER=$SOCK
     59  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $addr/64
     60  1.1  ozaki 	atf_check -s exit:0 -o ignore $HIJACKING $prog $addr $port
     61  1.1  ozaki 	atf_check -s exit:0 -o ignore $HIJACKING $prog ff1e::123 $port $addr
     62  1.1  ozaki }
     63  1.1  ozaki 
     64  1.1  ozaki add_test()
     65  1.1  ozaki {
     66  1.1  ozaki 	local name="${NAME}_$1"
     67  1.1  ozaki 	local desc="$2"
     68  1.1  ozaki 
     69  1.1  ozaki 	atf_test_case "${name}" cleanup
     70  1.1  ozaki 	eval "${name}_head() {
     71  1.1  ozaki 			atf_set descr \"${desc}\"
     72  1.1  ozaki 			atf_set require.progs rump_server
     73  1.1  ozaki 		}
     74  1.1  ozaki 	    ${name}_body() {
     75  1.1  ozaki 			test_${name}
     76  1.1  ozaki 		}
     77  1.1  ozaki 	    ${name}_cleanup() {
     78  1.1  ozaki 			\$DEBUG && dump
     79  1.1  ozaki 			cleanup
     80  1.1  ozaki 		}"
     81  1.1  ozaki 	atf_add_test_case "${name}"
     82  1.1  ozaki }
     83  1.1  ozaki 
     84  1.1  ozaki atf_init_test_cases()
     85  1.1  ozaki {
     86  1.1  ozaki 
     87  1.1  ozaki 	add_test ipv4	"tests for inpcb_bind (ipv4)"
     88  1.1  ozaki 	add_test ipv6	"tests for inpcb_bind (ipv6)"
     89  1.1  ozaki }
     90