Run mcast tests on rump kernels

The tests on anita qemus failed due to that the host network environment
didn't meet the tests.

The change makes the tests independent from host environments
and the tests will pass on any environments including anita qemus.

Discussed on tech-kern and tech-net.
This commit is contained in:
ozaki-r 2015-05-26 00:42:07 +00:00
parent bfadfbecbf
commit 8a6480b1eb
6 changed files with 130 additions and 16 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.113 2015/05/01 14:17:56 christos Exp $
# $NetBSD: mi,v 1.114 2015/05/26 00:42:07 ozaki-r Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib
@ -2174,7 +2174,7 @@
./usr/libdata/debug/usr/tests/net/if/t_compat.debug tests-net-debug debug,atf,rump
./usr/libdata/debug/usr/tests/net/if_loop/t_pr.debug tests-net-debug debug,atf,rump
./usr/libdata/debug/usr/tests/net/in_cksum/in_cksum.debug tests-net-debug debug,atf
./usr/libdata/debug/usr/tests/net/mcast/t_mcast.debug tests-net-debug debug,atf
./usr/libdata/debug/usr/tests/net/mcast/mcast.debug tests-net-debug debug,atf,rump
./usr/libdata/debug/usr/tests/net/net/t_pktinfo.debug tests-net-debug debug,atf
./usr/libdata/debug/usr/tests/net/net/t_raw.debug tests-net-debug debug,atf,rump
./usr/libdata/debug/usr/tests/net/net/t_tcp.debug tests-net-debug debug,atf

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.622 2015/05/18 06:27:04 ozaki-r Exp $
# $NetBSD: mi,v 1.623 2015/05/26 00:42:07 ozaki-r Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -3151,9 +3151,10 @@
./usr/tests/net/in_cksum/t_in_cksum tests-net-tests atf
./usr/tests/net/in_cksum/in_cksum tests-net-tests atf
./usr/tests/net/mcast tests-net-tests
./usr/tests/net/mcast/Atffile tests-net-tests atf
./usr/tests/net/mcast/Kyuafile tests-net-tests atf,kyua
./usr/tests/net/mcast/t_mcast tests-net-tests atf
./usr/tests/net/mcast/Atffile tests-net-tests atf,rump
./usr/tests/net/mcast/Kyuafile tests-net-tests atf,rump,kyua
./usr/tests/net/mcast/mcast tests-net-tests atf,rump
./usr/tests/net/mcast/t_mcast tests-net-tests atf,rump
./usr/tests/net/mpls tests-net-tests
./usr/tests/net/mpls/Atffile tests-net-tests atf,rump
./usr/tests/net/mpls/Kyuafile tests-net-tests atf,rump,kyua

View File

@ -1,13 +1,13 @@
# $NetBSD: Makefile,v 1.21 2015/05/20 17:39:04 christos Exp $
# $NetBSD: Makefile,v 1.22 2015/05/26 00:42:07 ozaki-r Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/net
TESTS_SUBDIRS= fdpass in_cksum mcast net sys
TESTS_SUBDIRS= fdpass in_cksum net sys
.if (${MKRUMP} != "no")
TESTS_SUBDIRS+= bpf bpfilter carp icmp if if_bridge if_loop mpls npf
TESTS_SUBDIRS+= route
TESTS_SUBDIRS+= bpf bpfilter carp icmp if if_bridge if_loop mcast
TESTS_SUBDIRS+= mpls npf route
.if (${MKSLJIT} != "no")
TESTS_SUBDIRS+= bpfjit
.endif

View File

@ -1,10 +1,14 @@
# $NetBSD: Makefile,v 1.1 2014/10/11 23:04:42 christos Exp $
# $NetBSD: Makefile,v 1.2 2015/05/26 00:42:07 ozaki-r Exp $
#
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/net/mcast
TESTS_C= t_mcast
TESTS_SH= t_mcast
PROGS= mcast
MAN.mcast= # empty
BINDIR.mcast= ${TESTSDIR}
.include <bsd.test.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_mcast.c,v 1.16 2015/05/25 07:17:17 ozaki-r Exp $ */
/* $NetBSD: mcast.c,v 1.1 2015/05/26 00:42:07 ozaki-r Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
#ifdef __RCSID
__RCSID("$NetBSD: t_mcast.c,v 1.16 2015/05/25 07:17:17 ozaki-r Exp $");
__RCSID("$NetBSD: mcast.c,v 1.1 2015/05/26 00:42:07 ozaki-r Exp $");
#else
extern const char *__progname;
#define getprogname() __progname
@ -55,7 +55,7 @@ extern const char *__progname;
#include <poll.h>
#include <stdbool.h>
#ifndef TEST
#ifdef ATF
#include <atf-c.h>
#define ERRX(ev, msg, ...) ATF_REQUIRE_MSG(0, msg, __VA_ARGS__)
@ -341,7 +341,7 @@ run(const char *host, const char *port, size_t n, bool conn, bool bug)
}
}
#ifdef TEST
#ifndef ATF
int
main(int argc, char *argv[])
{

109
tests/net/mcast/t_mcast.sh Normal file
View File

@ -0,0 +1,109 @@
# $NetBSD: t_mcast.sh,v 1.1 2015/05/26 00:42:07 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
netserver="rump_server -lrumpnet -lrumpnet_net"
netserver="$netserver -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif"
export RUMP_SERVER=unix://commsock
DEBUG=false
run_test()
{
local name="$1"
local opts="$2"
local mcast="$(atf_get_srcdir)/mcast"
atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep -q tentative"
# A route to the mcast address is required to join the mcast group
atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
atf_check -s exit:0 -o ignore rump.route add -inet6 default fc00::1
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -nr
export LD_PRELOAD=/usr/lib/librumphijack.so
#$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel
if $DEBUG; then
atf_check -s exit:0 -o ignore $mcast -d ${opts}
else
atf_check -s exit:0 $mcast ${opts}
fi
#$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel
unset LD_PRELOAD
}
add_test()
{
local name=$1
local opts="$2"
local desc="$3"
atf_test_case "mcast_${name}" cleanup
eval "mcast_${name}_head() { \
atf_set \"descr\" \"${desc}\"; \
atf_set \"require.progs\" \"rump_server\"; \
}; \
mcast_${name}_body() { \
run_test \"${name}\" \"${opts}\"; \
}; \
mcast_${name}_cleanup() { \
${DEBUG} && /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null | \
/usr/sbin/tcpdump -n -e -r -; \
env RUMP_SERVER=unix://commsock rump.halt; \
}"
atf_add_test_case "mcast_${name}"
}
atf_init_test_cases()
{
add_test conninet4 "-c -4" \
"Checks connected multicast for ipv4"
add_test connmappedinet4 "-c -m -4" \
"Checks connected multicast for mapped ipv4"
add_test connmappedbuginet4 "-c -m -b -4" \
"Checks connected multicast for mapped ipv4 using the v4 ioctls"
add_test conninet6 "-c -6" \
"Checks connected multicast for ipv6"
add_test unconninet4 "-4" \
"Checks unconnected multicast for ipv4"
add_test unconnmappedinet4 "-m -4" \
"Checks unconnected multicast for mapped ipv4"
add_test unconnmappedbuginet4 "-m -b -4" \
"Checks unconnected multicast for mapped ipv4 using the v4 ioctls"
add_test unconninet6 "-6" \
"Checks unconnected multicast for ipv6"
}