1313680Sngie# $NetBSD: t_mcast.sh,v 1.4 2016/11/25 08:51:16 ozaki-r Exp $ 2303980Sngie# 3303980Sngie# Copyright (c) 2015 The NetBSD Foundation, Inc. 4303980Sngie# All rights reserved. 5303980Sngie# 6303980Sngie# Redistribution and use in source and binary forms, with or without 7303980Sngie# modification, are permitted provided that the following conditions 8303980Sngie# are met: 9303980Sngie# 1. Redistributions of source code must retain the above copyright 10303980Sngie# notice, this list of conditions and the following disclaimer. 11303980Sngie# 2. Redistributions in binary form must reproduce the above copyright 12303980Sngie# notice, this list of conditions and the following disclaimer in the 13303980Sngie# documentation and/or other materials provided with the distribution. 14303980Sngie# 15303980Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16303980Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17303980Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18303980Sngie# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19303980Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20303980Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21303980Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22303980Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23303980Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24303980Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25303980Sngie# POSSIBILITY OF SUCH DAMAGE. 26303980Sngie# 27303980Sngie 28303980Sngieexport RUMP_SERVER=unix://commsock 29303980Sngie 30313680SngieDEBUG=${DEBUG:-false} 31303980Sngie 32303980Sngierun_test() 33303980Sngie{ 34303980Sngie local name="$1" 35303980Sngie local opts="$2" 36303980Sngie local mcast="$(atf_get_srcdir)/mcast" 37303980Sngie 38313680Sngie rump_server_start $RUMP_SERVER netinet6 39313680Sngie rump_server_add_iface $RUMP_SERVER shmif0 bus1 40303980Sngie atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24 41303980Sngie atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64 42303980Sngie atf_check -s exit:0 rump.ifconfig shmif0 up 43303980Sngie 44303980Sngie atf_check -s exit:0 rump.ifconfig -w 10 45303980Sngie atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep -q tentative" 46303980Sngie 47303980Sngie # A route to the mcast address is required to join the mcast group 48303980Sngie atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1 49303980Sngie atf_check -s exit:0 -o ignore rump.route add -inet6 default fc00::1 50303980Sngie 51303980Sngie $DEBUG && rump.ifconfig 52303980Sngie $DEBUG && rump.netstat -nr 53303980Sngie 54303980Sngie export LD_PRELOAD=/usr/lib/librumphijack.so 55303980Sngie #$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel 56303980Sngie if $DEBUG; then 57303980Sngie atf_check -s exit:0 -o ignore $mcast -d ${opts} 58303980Sngie else 59303980Sngie atf_check -s exit:0 $mcast ${opts} 60303980Sngie fi 61303980Sngie #$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel 62303980Sngie unset LD_PRELOAD 63303980Sngie} 64303980Sngie 65303980Sngieadd_test() 66303980Sngie{ 67303980Sngie local name=$1 68303980Sngie local opts="$2" 69303980Sngie local desc="$3" 70303980Sngie 71303980Sngie atf_test_case "mcast_${name}" cleanup 72303980Sngie eval "mcast_${name}_head() { \ 73303980Sngie atf_set \"descr\" \"${desc}\"; \ 74303980Sngie atf_set \"require.progs\" \"rump_server\"; \ 75303980Sngie }; \ 76303980Sngie mcast_${name}_body() { \ 77303980Sngie run_test \"${name}\" \"${opts}\"; \ 78313680Sngie rump_server_destroy_ifaces; \ 79303980Sngie }; \ 80303980Sngie mcast_${name}_cleanup() { \ 81313680Sngie ${DEBUG} && dump; \ 82313680Sngie cleanup; \ 83303980Sngie }" 84303980Sngie atf_add_test_case "mcast_${name}" 85303980Sngie} 86303980Sngie 87303980Sngieatf_init_test_cases() 88303980Sngie{ 89303980Sngie 90303980Sngie add_test conninet4 "-c -4" \ 91303980Sngie "Checks connected multicast for ipv4" 92303980Sngie add_test connmappedinet4 "-c -m -4" \ 93303980Sngie "Checks connected multicast for mapped ipv4" 94303980Sngie add_test connmappedbuginet4 "-c -m -b -4" \ 95303980Sngie "Checks connected multicast for mapped ipv4 using the v4 ioctls" 96303980Sngie add_test conninet6 "-c -6" \ 97303980Sngie "Checks connected multicast for ipv6" 98303980Sngie add_test unconninet4 "-4" \ 99303980Sngie "Checks unconnected multicast for ipv4" 100303980Sngie add_test unconnmappedinet4 "-m -4" \ 101303980Sngie "Checks unconnected multicast for mapped ipv4" 102303980Sngie add_test unconnmappedbuginet4 "-m -b -4" \ 103303980Sngie "Checks unconnected multicast for mapped ipv4 using the v4 ioctls" 104303980Sngie add_test unconninet6 "-6" \ 105303980Sngie "Checks unconnected multicast for ipv6" 106303980Sngie} 107