1# $NetBSD: t_mcast.sh,v 1.1 2015/05/26 00:42:07 ozaki-r Exp $ 2# 3# Copyright (c) 2015 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26# 27 28netserver="rump_server -lrumpnet -lrumpnet_net" 29netserver="$netserver -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif" 30export RUMP_SERVER=unix://commsock 31 32DEBUG=false 33 34run_test() 35{ 36 local name="$1" 37 local opts="$2" 38 local mcast="$(atf_get_srcdir)/mcast" 39 40 atf_check -s exit:0 ${netserver} ${RUMP_SERVER} 41 atf_check -s exit:0 rump.ifconfig shmif0 create 42 atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 43 atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24 44 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64 45 atf_check -s exit:0 rump.ifconfig shmif0 up 46 47 atf_check -s exit:0 rump.ifconfig -w 10 48 atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep -q tentative" 49 50 # A route to the mcast address is required to join the mcast group 51 atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1 52 atf_check -s exit:0 -o ignore rump.route add -inet6 default fc00::1 53 54 $DEBUG && rump.ifconfig 55 $DEBUG && rump.netstat -nr 56 57 export LD_PRELOAD=/usr/lib/librumphijack.so 58 #$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel 59 if $DEBUG; then 60 atf_check -s exit:0 -o ignore $mcast -d ${opts} 61 else 62 atf_check -s exit:0 $mcast ${opts} 63 fi 64 #$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel 65 unset LD_PRELOAD 66} 67 68add_test() 69{ 70 local name=$1 71 local opts="$2" 72 local desc="$3" 73 74 atf_test_case "mcast_${name}" cleanup 75 eval "mcast_${name}_head() { \ 76 atf_set \"descr\" \"${desc}\"; \ 77 atf_set \"require.progs\" \"rump_server\"; \ 78 }; \ 79 mcast_${name}_body() { \ 80 run_test \"${name}\" \"${opts}\"; \ 81 }; \ 82 mcast_${name}_cleanup() { \ 83 ${DEBUG} && /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null | \ 84 /usr/sbin/tcpdump -n -e -r -; \ 85 env RUMP_SERVER=unix://commsock rump.halt; \ 86 }" 87 atf_add_test_case "mcast_${name}" 88} 89 90atf_init_test_cases() 91{ 92 93 add_test conninet4 "-c -4" \ 94 "Checks connected multicast for ipv4" 95 add_test connmappedinet4 "-c -m -4" \ 96 "Checks connected multicast for mapped ipv4" 97 add_test connmappedbuginet4 "-c -m -b -4" \ 98 "Checks connected multicast for mapped ipv4 using the v4 ioctls" 99 add_test conninet6 "-c -6" \ 100 "Checks connected multicast for ipv6" 101 add_test unconninet4 "-4" \ 102 "Checks unconnected multicast for ipv4" 103 add_test unconnmappedinet4 "-m -4" \ 104 "Checks unconnected multicast for mapped ipv4" 105 add_test unconnmappedbuginet4 "-m -b -4" \ 106 "Checks unconnected multicast for mapped ipv4 using the v4 ioctls" 107 add_test unconninet6 "-6" \ 108 "Checks unconnected multicast for ipv6" 109} 110