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