summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-01-16 17:25:48 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-01-16 17:25:48 +0000
commit03c41ac965df56079c04c1750c684b942e27c59a (patch)
tree95238c07f579c78188d230f8759f0d0345b0f6ae
parent181439425f0bb490970e4e7022295f139d9988ad (diff)
downloadsrc-test2-03c41ac965df56079c04c1750c684b942e27c59a.tar.gz
src-test2-03c41ac965df56079c04c1750c684b942e27c59a.zip
Sync from NetBSD again to pick up more test fixes/enhancements pushed upstream
Notes
Notes: svn path=/vendor/NetBSD/tests/dist/; revision=312294
-rw-r--r--lib/libc/ssp/h_memset.c6
-rw-r--r--lib/libc/ssp/h_read.c15
-rw-r--r--lib/libc/sys/t_mmap.c6
-rw-r--r--lib/libc/sys/t_timer_create.c4
-rw-r--r--lib/libpthread/t_condwait.c11
-rw-r--r--lib/libpthread/t_detach.c13
-rw-r--r--lib/libpthread/t_fork.c8
-rw-r--r--lib/libpthread/t_fpu.c16
-rw-r--r--lib/libpthread/t_mutex.c13
-rw-r--r--lib/libpthread/t_sem.c5
-rw-r--r--lib/libpthread/t_swapcontext.c13
-rw-r--r--net/carp/t_basic.c221
-rwxr-xr-xnet/carp/t_basic.sh165
13 files changed, 237 insertions, 259 deletions
diff --git a/lib/libc/ssp/h_memset.c b/lib/libc/ssp/h_memset.c
index 65ed5f2ee7d2..f1acbbd4e311 100644
--- a/lib/libc/ssp/h_memset.c
+++ b/lib/libc/ssp/h_memset.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $");
#include <stdio.h>
#include <string.h>
@@ -41,5 +41,5 @@ main(int argc, char *argv[])
char b[10];
size_t len = atoi(argv[1]);
(void)memset(b, 0, len);
- return 0;
+ return b[0]; /* keeps optimizer from zapping the call to memset() */
}
diff --git a/lib/libc/ssp/h_read.c b/lib/libc/ssp/h_read.c
index 5240af291eb7..046ac62199b8 100644
--- a/lib/libc/ssp/h_read.c
+++ b/lib/libc/ssp/h_read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,9 +29,11 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $");
#include <sys/param.h>
+#include <fcntl.h>
+#include <paths.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -40,8 +42,13 @@ int
main(int argc, char *argv[])
{
char b[MAXPATHLEN];
+ int fd, n;
size_t len = atoi(argv[1]);
- (void)read(0, b, len);
+
+ if ((fd = open(_PATH_DEVZERO, O_RDONLY)) == -1)
+ abort();
+ if ((n = read(fd, b, len)) == -1)
+ abort();
(void)printf("%s\n", b);
- return 0;
+ return (0);
}
diff --git a/lib/libc/sys/t_mmap.c b/lib/libc/sys/t_mmap.c
index 3dc1e7f92fe3..f01ed76315b5 100644
--- a/lib/libc/sys/t_mmap.c
+++ b/lib/libc/sys/t_mmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.11 2017/01/13 20:43:11 christos Exp $ */
+/* $NetBSD: t_mmap.c,v 1.12 2017/01/16 16:31:05 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,9 +55,10 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mmap.c,v 1.11 2017/01/13 20:43:11 christos Exp $");
+__RCSID("$NetBSD: t_mmap.c,v 1.12 2017/01/16 16:31:05 christos Exp $");
#include <sys/param.h>
+#include <sys/disklabel.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -73,7 +74,6 @@ __RCSID("$NetBSD: t_mmap.c,v 1.11 2017/01/13 20:43:11 christos Exp $");
#include <string.h>
#include <unistd.h>
#include <paths.h>
-#include <machine/disklabel.h>
static long page = 0;
static char path[] = "mmap";
diff --git a/lib/libc/sys/t_timer_create.c b/lib/libc/sys/t_timer_create.c
index ce1fb99eb1ad..e8a6acd08efc 100644
--- a/lib/libc/sys/t_timer_create.c
+++ b/lib/libc/sys/t_timer_create.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_timer_create.c,v 1.4 2012/03/18 07:00:52 jruoho Exp $ */
+/* $NetBSD: t_timer_create.c,v 1.5 2017/01/16 16:32:13 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@ static timer_t t;
static bool fail = true;
static void
-timer_signal_handler(int signo, siginfo_t *si, void *osi)
+timer_signal_handler(int signo, siginfo_t *si, void *osi __unused)
{
timer_t *tp;
diff --git a/lib/libpthread/t_condwait.c b/lib/libpthread/t_condwait.c
index 9b79587104cf..58b4a8bc155a 100644
--- a/lib/libpthread/t_condwait.c
+++ b/lib/libpthread/t_condwait.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $ */
+/* $NetBSD: t_condwait.c,v 1.5 2017/01/16 16:29:19 christos Exp $ */
/*
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -26,8 +26,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $");
+__RCSID("$NetBSD: t_condwait.c,v 1.5 2017/01/16 16:29:19 christos Exp $");
+#include <sys/time.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
@@ -40,6 +41,8 @@ __RCSID("$NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $");
#include "isqemu.h"
+#include "h_common.h"
+
#define WAITTIME 2 /* Timeout wait secound */
static const int debug = 1;
@@ -56,8 +59,8 @@ run(void *param)
clck = *(clockid_t *)param;
- pthread_condattr_init(&attr);
- pthread_condattr_setclock(&attr, clck); /* MONOTONIC or MONOTONIC */
+ PTHREAD_REQUIRE(pthread_condattr_init(&attr));
+ PTHREAD_REQUIRE(pthread_condattr_setclock(&attr, clck));
pthread_cond_init(&cond, &attr);
ATF_REQUIRE_EQ((ret = pthread_mutex_lock(&m)), 0);
diff --git a/lib/libpthread/t_detach.c b/lib/libpthread/t_detach.c
index 21db871a70da..b30cb029d578 100644
--- a/lib/libpthread/t_detach.c
+++ b/lib/libpthread/t_detach.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $ */
+/* $NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,10 +29,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $");
+__RCSID("$NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $");
-#include <pthread.h>
#include <errno.h>
+#include <pthread.h>
+#include <time.h>
#include <atf-c.h>
@@ -43,6 +44,7 @@ static void *func(void *);
static void *
func(void *arg)
{
+ sleep(2);
return NULL;
}
@@ -72,14 +74,17 @@ ATF_TC_BODY(pthread_detach, tc)
*/
PTHREAD_REQUIRE(pthread_detach(t));
+ sleep(1);
rv = pthread_join(t, NULL);
ATF_REQUIRE(rv == EINVAL);
+ sleep(3);
+
/*
* As usual, ESRCH should follow if
* we try to detach an invalid thread.
*/
- rv = pthread_cancel(NULL);
+ rv = pthread_cancel(t);
ATF_REQUIRE(rv == ESRCH);
}
diff --git a/lib/libpthread/t_fork.c b/lib/libpthread/t_fork.c
index ab8806d25641..936c7decaecf 100644
--- a/lib/libpthread/t_fork.c
+++ b/lib/libpthread/t_fork.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fork.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */
+/* $NetBSD: t_fork.c,v 1.2 2017/01/16 16:28:27 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_fork.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $");
+__RCSID("$NetBSD: t_fork.c,v 1.2 2017/01/16 16:28:27 christos Exp $");
/*
* Written by Love Hörnquist Åstrand <lha@NetBSD.org>, March 2003.
@@ -61,7 +61,7 @@ print_pid(void *arg)
thread_survived = 1;
if (parent != getpid()) {
- exit(1);
+ _exit(1);
}
return NULL;
}
@@ -95,7 +95,7 @@ ATF_TC_BODY(fork, tc)
ATF_REQUIRE_EQ_MSG(WEXITSTATUS(status), 0, "thread survived in child");
} else {
sleep(5);
- exit(thread_survived ? 1 : 0);
+ _exit(thread_survived ? 1 : 0);
}
}
diff --git a/lib/libpthread/t_fpu.c b/lib/libpthread/t_fpu.c
index 4047b1fa6195..dd47fb8067e7 100644
--- a/lib/libpthread/t_fpu.c
+++ b/lib/libpthread/t_fpu.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $ */
+/* $NetBSD: t_fpu.c,v 1.3 2017/01/16 16:27:43 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $");
+__RCSID("$NetBSD: t_fpu.c,v 1.3 2017/01/16 16:27:43 christos Exp $");
/*
* This is adapted from part of csw/cstest of the MPD implementation by
@@ -49,10 +49,12 @@ __RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $");
* <is@netbsd.org>.
*/
+#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@@ -77,14 +79,16 @@ stir(void *p)
for (;;) {
x = sin ((y = cos (x + y + .4)) - (z = cos (x + z + .6)));
- PTHREAD_REQUIRE(sched_yield());
+ ATF_REQUIRE_MSG(sched_yield() == 0,
+ "sched_yield failed: %s", strerror(errno));
}
}
static double
mul3(double x, double y, double z)
{
- PTHREAD_REQUIRE(sched_yield());
+ ATF_REQUIRE_MSG(sched_yield() == 0,
+ "sched_yield failed: %s", strerror(errno));
return x * y * z;
}
@@ -114,7 +118,7 @@ bar(void *p)
static void
recurse(void) {
pthread_t s2;
- pthread_create(&s2, 0, bar, 0);
+ PTHREAD_REQUIRE(pthread_create(&s2, 0, bar, 0));
sleep(20); /* XXX must be long enough for our slowest machine */
}
@@ -134,7 +138,7 @@ ATF_TC_BODY(fpu, tc)
PTHREAD_REQUIRE(pthread_mutex_init(&recursion_depth_lock, 0));
- pthread_create(&s5, 0, stir, stirseed);
+ PTHREAD_REQUIRE(pthread_create(&s5, 0, stir, stirseed));
recurse();
atf_tc_fail("exiting from main");
diff --git a/lib/libpthread/t_mutex.c b/lib/libpthread/t_mutex.c
index e9ba2fc5754a..b706e462f3db 100644
--- a/lib/libpthread/t_mutex.c
+++ b/lib/libpthread/t_mutex.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $ */
+/* $NetBSD: t_mutex.c,v 1.15 2017/01/16 16:23:41 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,8 +29,10 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $");
+__RCSID("$NetBSD: t_mutex.c,v 1.15 2017/01/16 16:23:41 christos Exp $");
+#include <sys/time.h> /* For timespecadd */
+#include <inttypes.h> /* For UINT16_MAX */
#include <pthread.h>
#include <stdio.h>
#include <string.h>
@@ -570,9 +572,16 @@ ATF_TC_BODY(mutexattr2, tc)
int min_prio = sched_get_priority_min(SCHED_FIFO);
for (int i = min_prio; i <= max_prio; i++) {
int prioceiling;
+ int protocol;
+
+ PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr,
+ &protocol));
+
+ printf("priority: %d\nprotocol: %d\n", i, protocol);
PTHREAD_REQUIRE(pthread_mutexattr_setprioceiling(&mattr, i));
PTHREAD_REQUIRE(pthread_mutexattr_getprioceiling(&mattr,
&prioceiling));
+ printf("prioceiling: %d\n", prioceiling);
ATF_REQUIRE_EQ(i, prioceiling);
}
}
diff --git a/lib/libpthread/t_sem.c b/lib/libpthread/t_sem.c
index a4e03ae9c605..3d15eddab64b 100644
--- a/lib/libpthread/t_sem.c
+++ b/lib/libpthread/t_sem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_sem.c,v 1.9 2017/01/16 16:22:22 christos Exp $ */
/*
* Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -86,8 +86,9 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_sem.c,v 1.9 2017/01/16 16:22:22 christos Exp $");
+#include <sys/time.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
diff --git a/lib/libpthread/t_swapcontext.c b/lib/libpthread/t_swapcontext.c
index 8fd231404542..677c51fc8601 100644
--- a/lib/libpthread/t_swapcontext.c
+++ b/lib/libpthread/t_swapcontext.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_swapcontext.c,v 1.2 2014/08/25 16:31:15 bouyer Exp $ */
+/* $NetBSD: t_swapcontext.c,v 1.3 2017/01/16 16:27:06 christos Exp $ */
/*
* Copyright (c) 2012 Emmanuel Dreyfus. All rights reserved.
@@ -28,10 +28,13 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD");
+#include <sys/types.h>
+#include <errno.h>
#include <pthread.h>
-#include <ucontext.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ucontext.h>
#include <atf-c.h>
@@ -77,7 +80,8 @@ threadfunc(void *arg)
oself = (void *)pthread_self();
printf("before swapcontext self = %p\n", oself);
- PTHREAD_REQUIRE(swapcontext(&octx, &nctx));
+ ATF_REQUIRE_MSG(swapcontext(&octx, &nctx) != -1, "swapcontext failed: %s",
+ strerror(errno));
/* NOTREACHED */
return NULL;
@@ -99,7 +103,8 @@ ATF_TC_BODY(swapcontext1, tc)
printf("Testing if swapcontext() alters pthread_self()\n");
- PTHREAD_REQUIRE(getcontext(&nctx));
+ ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s",
+ strerror(errno));
PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL));
PTHREAD_REQUIRE(pthread_join(thread, NULL));
}
diff --git a/net/carp/t_basic.c b/net/carp/t_basic.c
deleted file mode 100644
index 681b8bb179a7..000000000000
--- a/net/carp/t_basic.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/* $NetBSD: t_basic.c,v 1.6 2017/01/13 21:30:42 christos Exp $ */
-
-/*-
- * Copyright (c) 2010 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.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__RCSID("$NetBSD: t_basic.c,v 1.6 2017/01/13 21:30:42 christos Exp $");
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip_carp.h>
-
-#include <rump/rump.h>
-#include <rump/rump_syscalls.h>
-
-#include <atf-c.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include "../config/netconfig.c"
-#include "h_macros.h"
-
-static bool oknow = false;
-
-static void
-sighnd(int sig)
-{
-
- ATF_REQUIRE_EQ(sig, SIGCHLD);
- if (oknow)
- return;
-
- atf_tc_fail("child died unexpectedly");
-}
-
-ATF_TC(handover);
-ATF_TC_HEAD(handover, tc)
-{
-
- atf_tc_set_md_var(tc, "descr", "check that carp handover works if "
- "the master dies");
-}
-
-#define THEBUS "buuuuuuus,etherbus"
-
-static void
-child(bool master)
-{
- char ifname[IFNAMSIZ];
- struct carpreq cr;
- struct ifreq ifr;
- const char *carpif;
- int s;
-
- /* helps reading carp debug output */
- if (master)
- carpif = "carp0";
- else
- carpif = "carp1";
-
- /*
- * Should use sysctl, bug debug is dabug.
- */
- {
- //extern int rumpns_carp_opts[]; /* XXX */
- //rumpns_carp_opts[CARPCTL_LOG] = 1;
- }
-
-
- rump_init();
-
- memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, carpif, sizeof(ifr.ifr_name));
-
- RL(s = rump_sys_socket(PF_INET, SOCK_DGRAM, 0));
- RL(rump_sys_ioctl(s, SIOCIFCREATE, &ifr));
-
- netcfg_rump_makeshmif(THEBUS, ifname);
-
- if (master)
- netcfg_rump_if(ifname, "10.1.1.1", "255.255.255.0");
- else
- netcfg_rump_if(ifname, "10.1.1.2", "255.255.255.0");
-
- /* configure the carp interface */
- ifr.ifr_data = &cr;
- RL(rump_sys_ioctl(s, SIOCGVH, &ifr));
-
- strlcpy(cr.carpr_carpdev, ifname, sizeof(cr.carpr_carpdev));
- cr.carpr_vhid = 175;
- if (master)
- cr.carpr_advskew = 0;
- else
- cr.carpr_advskew = 200;
- cr.carpr_advbase = 1;
- strcpy((char *)cr.carpr_key, "s3cret");
-
- RL(rump_sys_ioctl(s, SIOCSVH, &ifr));
- netcfg_rump_if(carpif, "10.1.1.100", "255.255.255.0");
-
- /* tassa pause()en enka muuta voi */
- pause();
-}
-
-ATF_TC_BODY(handover, tc)
-{
- char ifname[IFNAMSIZ];
- pid_t mpid, cpid;
- int i, status;
-
- signal(SIGCHLD, sighnd);
-
- /* fork master */
- switch (mpid = fork()) {
- case -1:
- atf_tc_fail_errno("fork failed");
- /*NOTREACHED*/
- case 0:
- child(true);
- /*NOTREACHED*/
- default:
- break;
- }
-
- usleep(500000);
-
- /* fork backup */
- switch (cpid = fork()) {
- case -1:
- kill(mpid, SIGKILL);
- atf_tc_fail_errno("fork failed");
- /*NOTREACHED*/
- case 0:
- child(false);
- /*NOTREACHED*/
- default:
- break;
- }
-
- usleep(500000);
-
- rump_init();
- netcfg_rump_makeshmif(THEBUS, ifname);
- netcfg_rump_if(ifname, "10.1.1.240", "255.255.255.0");
-
- /* check that the primary addresses are up */
- ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.1", 1000), true);
- ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.2", 1000), true);
-
- /* give carp a while to croak */
- sleep(4);
-
- /* check that the shared IP works */
- ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.100", 500), true);
-
- /* KILLING SPREE */
- oknow = true;
- kill(mpid, SIGKILL);
- wait(&status);
- usleep(10000); /* just in case */
- oknow = false;
-
- /* check that primary is now dead */
- ATF_REQUIRE_EQ(netcfg_rump_pingtest("10.1.1.1", 100), false);
-
- /* do it in installments. carp will cluck meanwhile */
- for (i = 0; i < 5; i++) {
- if (netcfg_rump_pingtest("10.1.1.100", 1000) == true)
- break;
- }
- if (i == 5)
- atf_tc_fail("failed to failover");
-
- /* to kill the child */
- oknow = true;
- kill(cpid, SIGKILL);
-
- /* clean & done */
-}
-
-ATF_TP_ADD_TCS(tp)
-{
-
- ATF_TP_ADD_TC(tp, handover);
-
- return atf_no_error();
-}
diff --git a/net/carp/t_basic.sh b/net/carp/t_basic.sh
new file mode 100755
index 000000000000..94ada1cbb6d0
--- /dev/null
+++ b/net/carp/t_basic.sh
@@ -0,0 +1,165 @@
+# $NetBSD: t_basic.sh,v 1.1 2017/01/16 08:18:11 ozaki-r Exp $
+#
+# Copyright (c) 2017 Internet Initiative Japan 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.
+#
+
+SOCK_CLIENT=unix://carp_client
+SOCK_MASTER=unix://carp_master
+SOCK_BACKUP=unix://carp_backup
+BUS=bus_carp
+IP_CLIENT=10.1.1.240
+IP_MASTER=10.1.1.1
+IP_BACKUP=10.1.1.2
+IP_CARP=10.1.1.100
+TIMEOUT=3
+
+atf_test_case carp_handover cleanup
+
+carp_handover_head()
+{
+
+ atf_set "descr" "Tests for CARP handover"
+ atf_set "require.progs" "rump_server"
+}
+
+setup_carp()
+{
+ local sock=$1
+ local master=$2
+ local carpif= ip= advskew=
+
+ if $master; then
+ carpif=carp0
+ ip=$IP_MASTER
+ advskew=0
+ else
+ carpif=carp1
+ ip=$IP_BACKUP
+ advskew=200
+ fi
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.ifconfig $carpif create
+ atf_check -s exit:0 rump.ifconfig shmif0 $ip/24 up
+ atf_check -s exit:0 rump.ifconfig $carpif \
+ vhid 175 advskew $advskew advbase 1 pass s3cret \
+ $IP_CARP netmask 255.255.255.0
+ atf_check -s exit:0 rump.ifconfig -w 10
+}
+
+wait_handover()
+{
+ local i=0
+
+ export RUMP_SERVER=$SOCK_CLIENT
+
+ while [ $i -ne 5 ]; do
+ $DEBUG && echo "Trying ping $IP_CARP"
+ rump.ping -n -w 1 -c 1 $IP_CARP >/dev/null
+ if [ $? = 0 ]; then
+ $DEBUG && echo "Passed ping $IP_CARP"
+ break;
+ fi
+ $DEBUG && echo "Failed ping $IP_CARP"
+ i=$((i + 1))
+ done
+
+ if [ $i -eq 5 ]; then
+ atf_fail "Failed to failover (5 sec)"
+ fi
+}
+
+carp_handover_body()
+{
+
+ rump_server_start $SOCK_CLIENT
+ rump_server_start $SOCK_MASTER
+ rump_server_start $SOCK_BACKUP
+
+ rump_server_add_iface $SOCK_CLIENT shmif0 $BUS
+ rump_server_add_iface $SOCK_MASTER shmif0 $BUS
+ rump_server_add_iface $SOCK_BACKUP shmif0 $BUS
+
+ setup_carp $SOCK_MASTER true
+ setup_carp $SOCK_BACKUP false
+
+ export RUMP_SERVER=$SOCK_CLIENT
+ atf_check -s exit:0 rump.ifconfig shmif0 $IP_CLIENT/24 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ # Check that the primary addresses are up
+ atf_check -s exit:0 -o ignore \
+ rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
+ atf_check -s exit:0 -o ignore \
+ rump.ping -n -w $TIMEOUT -c 1 $IP_BACKUP
+
+ # Give carp a while to croak
+ sleep 4
+
+ # Check state
+ export RUMP_SERVER=$SOCK_MASTER
+ $DEBUG && rump.ifconfig
+ atf_check -s exit:0 -o match:'carp: MASTER carpdev shmif0' \
+ rump.ifconfig carp0
+ export RUMP_SERVER=$SOCK_BACKUP
+ $DEBUG && rump.ifconfig
+ atf_check -s exit:0 -o match:'carp: BACKUP carpdev shmif0' \
+ rump.ifconfig carp1
+ export RUMP_SERVER=$SOCK_CLIENT
+
+ # Check that the shared IP works
+ atf_check -s exit:0 -o ignore \
+ rump.ping -n -w $TIMEOUT -c 1 $IP_CARP
+
+ # KILLING SPREE
+ env RUMP_SERVER=$SOCK_MASTER rump.halt
+ sleep 1
+
+ # Check that primary is now dead
+ atf_check -s not-exit:0 -o ignore \
+ rump.ping -n -w $TIMEOUT -c 1 $IP_MASTER
+
+ # Do it in installments. carp will cluck meanwhile
+ wait_handover
+
+ # Check state
+ export RUMP_SERVER=$SOCK_BACKUP
+ $DEBUG && rump.ifconfig
+ atf_check -s exit:0 -o match:'carp: MASTER carpdev shmif0' \
+ rump.ifconfig carp1
+}
+
+carp_handover_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case carp_handover
+}