Home | History | Annotate | Line # | Download | only in mcast
t_mcast.sh revision 1.1.2.1
      1  1.1.2.1  pgoyette #	$NetBSD: t_mcast.sh,v 1.1.2.1 2017/01/07 08:56:56 pgoyette Exp $
      2      1.1     ozaki #
      3      1.1     ozaki # Copyright (c) 2015 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 export RUMP_SERVER=unix://commsock
     29      1.1     ozaki 
     30  1.1.2.1  pgoyette DEBUG=${DEBUG:-false}
     31      1.1     ozaki 
     32      1.1     ozaki run_test()
     33      1.1     ozaki {
     34      1.1     ozaki 	local name="$1"
     35      1.1     ozaki 	local opts="$2"
     36      1.1     ozaki 	local mcast="$(atf_get_srcdir)/mcast"
     37      1.1     ozaki 
     38  1.1.2.1  pgoyette 	rump_server_start $RUMP_SERVER netinet6
     39  1.1.2.1  pgoyette 	rump_server_add_iface $RUMP_SERVER shmif0 bus1
     40      1.1     ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24
     41      1.1     ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64
     42      1.1     ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 up
     43      1.1     ozaki 
     44      1.1     ozaki 	atf_check -s exit:0 rump.ifconfig -w 10
     45      1.1     ozaki 	atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep -q tentative"
     46      1.1     ozaki 
     47      1.1     ozaki 	# A route to the mcast address is required to join the mcast group
     48      1.1     ozaki 	atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
     49      1.1     ozaki 	atf_check -s exit:0 -o ignore rump.route add -inet6 default fc00::1
     50      1.1     ozaki 
     51      1.1     ozaki 	$DEBUG && rump.ifconfig
     52      1.1     ozaki 	$DEBUG && rump.netstat -nr
     53      1.1     ozaki 
     54      1.1     ozaki 	export LD_PRELOAD=/usr/lib/librumphijack.so
     55      1.1     ozaki 	#$DEBUG && /usr/sbin/ifmcstat  # Not yet run on rump kernel
     56      1.1     ozaki 	if $DEBUG; then
     57      1.1     ozaki 		atf_check -s exit:0 -o ignore $mcast -d ${opts}
     58      1.1     ozaki 	else
     59      1.1     ozaki 		atf_check -s exit:0 $mcast ${opts}
     60      1.1     ozaki 	fi
     61      1.1     ozaki 	#$DEBUG && /usr/sbin/ifmcstat  # Not yet run on rump kernel
     62      1.1     ozaki 	unset LD_PRELOAD
     63      1.1     ozaki }
     64      1.1     ozaki 
     65      1.1     ozaki add_test()
     66      1.1     ozaki {
     67      1.1     ozaki 	local name=$1
     68      1.1     ozaki 	local opts="$2"
     69      1.1     ozaki 	local desc="$3"
     70      1.1     ozaki 
     71      1.1     ozaki 	atf_test_case "mcast_${name}" cleanup
     72      1.1     ozaki 	eval "mcast_${name}_head() { \
     73      1.1     ozaki 			atf_set \"descr\" \"${desc}\"; \
     74      1.1     ozaki 			atf_set \"require.progs\" \"rump_server\"; \
     75      1.1     ozaki 		}; \
     76      1.1     ozaki 	    mcast_${name}_body() { \
     77      1.1     ozaki 			run_test \"${name}\" \"${opts}\"; \
     78  1.1.2.1  pgoyette 			rump_server_destroy_ifaces; \
     79      1.1     ozaki 		}; \
     80      1.1     ozaki 	    mcast_${name}_cleanup() { \
     81  1.1.2.1  pgoyette 			${DEBUG} && dump; \
     82  1.1.2.1  pgoyette 			cleanup; \
     83      1.1     ozaki 		}"
     84      1.1     ozaki 	atf_add_test_case "mcast_${name}"
     85      1.1     ozaki }
     86      1.1     ozaki 
     87      1.1     ozaki atf_init_test_cases()
     88      1.1     ozaki {
     89      1.1     ozaki 
     90      1.1     ozaki 	add_test conninet4            "-c -4" \
     91      1.1     ozaki 	    "Checks connected multicast for ipv4"
     92      1.1     ozaki 	add_test connmappedinet4      "-c -m -4" \
     93      1.1     ozaki 	    "Checks connected multicast for mapped ipv4"
     94      1.1     ozaki 	add_test connmappedbuginet4   "-c -m -b -4" \
     95      1.1     ozaki 	    "Checks connected multicast for mapped ipv4 using the v4 ioctls"
     96      1.1     ozaki 	add_test conninet6            "-c -6" \
     97      1.1     ozaki 	    "Checks connected multicast for ipv6"
     98      1.1     ozaki 	add_test unconninet4          "-4" \
     99      1.1     ozaki 	    "Checks unconnected multicast for ipv4"
    100      1.1     ozaki 	add_test unconnmappedinet4    "-m -4" \
    101      1.1     ozaki 	    "Checks unconnected multicast for mapped ipv4"
    102      1.1     ozaki 	add_test unconnmappedbuginet4 "-m -b -4" \
    103      1.1     ozaki 	    "Checks unconnected multicast for mapped ipv4 using the v4 ioctls"
    104      1.1     ozaki 	add_test unconninet6          "-6" \
    105      1.1     ozaki 	    "Checks unconnected multicast for ipv6"
    106      1.1     ozaki }
    107