Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/mcast Add tests that destroy an interface while th...
details: https://anonhg.NetBSD.org/src/rev/b9125976713e
branches: trunk
changeset: 351825:b9125976713e
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue Feb 28 09:23:23 2017 +0000
description:
Add tests that destroy an interface while the mcast program is running
diffstat:
tests/net/mcast/mcast.c | 15 ++++++--
tests/net/mcast/t_mcast.sh | 81 ++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 82 insertions(+), 14 deletions(-)
diffs (179 lines):
diff -r 2fe668dcddab -r b9125976713e tests/net/mcast/mcast.c
--- a/tests/net/mcast/mcast.c Tue Feb 28 04:47:41 2017 +0000
+++ b/tests/net/mcast/mcast.c Tue Feb 28 09:23:23 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcast.c,v 1.3 2015/05/28 10:19:17 ozaki-r Exp $ */
+/* $NetBSD: mcast.c,v 1.4 2017/02/28 09:23:23 ozaki-r Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
#ifdef __RCSID
-__RCSID("$NetBSD: mcast.c,v 1.3 2015/05/28 10:19:17 ozaki-r Exp $");
+__RCSID("$NetBSD: mcast.c,v 1.4 2017/02/28 09:23:23 ozaki-r Exp $");
#else
extern const char *__progname;
#define getprogname() __progname
@@ -73,6 +73,7 @@
#endif
static int debug;
+static int nsleep;
#define TOTAL 10
#define PORT_V4MAPPED "6666"
@@ -338,6 +339,8 @@
seq, msg.seq);
}
+ if (nsleep)
+ sleep(nsleep);
/* Tell I'm finished */
synchronize(fd, false);
}
@@ -417,7 +420,7 @@
n = TOTAL;
bug = conn = false;
- while ((c = getopt(argc, argv, "46bcdmn:")) != -1)
+ while ((c = getopt(argc, argv, "46bcdmn:s:")) != -1)
switch (c) {
case '4':
host = HOST_V4;
@@ -443,8 +446,12 @@
case 'n':
n = atoi(optarg);
break;
+ case 's':
+ nsleep = atoi(optarg);
+ break;
default:
- fprintf(stderr, "Usage: %s [-cdm46] [-n <tot>]",
+ fprintf(stderr, "Usage: %s [-cdm46] [-n <tot>]"
+ " [-s <sleep>]",
getprogname());
return 1;
}
diff -r 2fe668dcddab -r b9125976713e tests/net/mcast/t_mcast.sh
--- a/tests/net/mcast/t_mcast.sh Tue Feb 28 04:47:41 2017 +0000
+++ b/tests/net/mcast/t_mcast.sh Tue Feb 28 09:23:23 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_mcast.sh,v 1.4 2016/11/25 08:51:16 ozaki-r Exp $
+# $NetBSD: t_mcast.sh,v 1.5 2017/02/28 09:23:23 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -62,15 +62,61 @@
unset LD_PRELOAD
}
+run_test_destroyif()
+{
+ local name="$1"
+ local opts="$2"
+ local mcast="$(atf_get_srcdir)/mcast"
+ local sleep=3
+
+ rump_server_start $RUMP_SERVER netinet6
+ rump_server_add_iface $RUMP_SERVER shmif0 bus1
+ export RUMP_SERVER=$RUMP_SERVER
+ 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
+ $mcast -d ${opts} -s $sleep &
+ else
+ $mcast ${opts} -s $sleep &
+ fi
+ #$DEBUG && /usr/sbin/ifmcstat # Not yet run on rump kernel
+ unset LD_PRELOAD
+
+ # Give a chance to setup mcast
+ sleep 1
+
+ # Try to destroy an interface that the mcast program is running on
+ atf_check -s exit:0 rump.ifconfig shmif0 destroy
+
+ wait
+ atf_check -s exit:0 -o ignore rump.ifconfig
+}
+
add_test()
{
local name=$1
local opts="$2"
local desc="$3"
+ local fulldesc=
+ fulldesc="Checks $desc"
atf_test_case "mcast_${name}" cleanup
eval "mcast_${name}_head() { \
- atf_set \"descr\" \"${desc}\"; \
+ atf_set \"descr\" \"${fulldesc}\"; \
atf_set \"require.progs\" \"rump_server\"; \
}; \
mcast_${name}_body() { \
@@ -82,25 +128,40 @@
cleanup; \
}"
atf_add_test_case "mcast_${name}"
+
+ fulldesc="Destroying interface while testing ${desc}"
+ atf_test_case "mcast_destroyif_${name}" cleanup
+ eval "mcast_destroyif_${name}_head() { \
+ atf_set \"descr\" \"${fulldesc}\"; \
+ atf_set \"require.progs\" \"rump_server\"; \
+ }; \
+ mcast_destroyif_${name}_body() { \
+ run_test_destroyif \"${name}\" \"${opts}\"; \
+ }; \
+ mcast_destroyif_${name}_cleanup() { \
+ ${DEBUG} && dump; \
+ cleanup; \
+ }"
+ atf_add_test_case "mcast_destroyif_${name}"
}
atf_init_test_cases()
{
add_test conninet4 "-c -4" \
- "Checks connected multicast for ipv4"
+ "connected multicast for ipv4"
add_test connmappedinet4 "-c -m -4" \
- "Checks connected multicast for mapped ipv4"
+ "connected multicast for mapped ipv4"
add_test connmappedbuginet4 "-c -m -b -4" \
- "Checks connected multicast for mapped ipv4 using the v4 ioctls"
+ "connected multicast for mapped ipv4 using the v4 ioctls"
add_test conninet6 "-c -6" \
- "Checks connected multicast for ipv6"
+ "connected multicast for ipv6"
add_test unconninet4 "-4" \
- "Checks unconnected multicast for ipv4"
+ "unconnected multicast for ipv4"
add_test unconnmappedinet4 "-m -4" \
- "Checks unconnected multicast for mapped ipv4"
+ "unconnected multicast for mapped ipv4"
add_test unconnmappedbuginet4 "-m -b -4" \
- "Checks unconnected multicast for mapped ipv4 using the v4 ioctls"
+ "unconnected multicast for mapped ipv4 using the v4 ioctls"
add_test unconninet6 "-6" \
- "Checks unconnected multicast for ipv6"
+ "unconnected multicast for ipv6"
}
Home |
Main Index |
Thread Index |
Old Index