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