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