svn commit: r312294 - in vendor/NetBSD/tests/dist: lib/libc/ssp lib/libc/sys lib/libpthread net/carp
Ngie Cooper
ngie at FreeBSD.org
Mon Jan 16 17:25:51 UTC 2017
Author: ngie
Date: Mon Jan 16 17:25:48 2017
New Revision: 312294
URL: https://svnweb.freebsd.org/changeset/base/312294
Log:
Sync from NetBSD again to pick up more test fixes/enhancements pushed upstream
Added:
vendor/NetBSD/tests/dist/net/carp/t_basic.sh (contents, props changed)
Deleted:
vendor/NetBSD/tests/dist/net/carp/t_basic.c
Modified:
vendor/NetBSD/tests/dist/lib/libc/ssp/h_memset.c
vendor/NetBSD/tests/dist/lib/libc/ssp/h_read.c
vendor/NetBSD/tests/dist/lib/libc/sys/t_mmap.c
vendor/NetBSD/tests/dist/lib/libc/sys/t_timer_create.c
vendor/NetBSD/tests/dist/lib/libpthread/t_condwait.c
vendor/NetBSD/tests/dist/lib/libpthread/t_detach.c
vendor/NetBSD/tests/dist/lib/libpthread/t_fork.c
vendor/NetBSD/tests/dist/lib/libpthread/t_fpu.c
vendor/NetBSD/tests/dist/lib/libpthread/t_mutex.c
vendor/NetBSD/tests/dist/lib/libpthread/t_sem.c
vendor/NetBSD/tests/dist/lib/libpthread/t_swapcontext.c
Modified: vendor/NetBSD/tests/dist/lib/libc/ssp/h_memset.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libc/ssp/h_memset.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libc/ssp/h_memset.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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() */
}
Modified: vendor/NetBSD/tests/dist/lib/libc/ssp/h_read.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libc/ssp/h_read.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libc/ssp/h_read.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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);
}
Modified: vendor/NetBSD/tests/dist/lib/libc/sys/t_mmap.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libc/sys/t_mmap.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libc/sys/t_mmap.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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/0
#include <string.h>
#include <unistd.h>
#include <paths.h>
-#include <machine/disklabel.h>
static long page = 0;
static char path[] = "mmap";
Modified: vendor/NetBSD/tests/dist/lib/libc/sys/t_timer_create.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libc/sys/t_timer_create.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libc/sys/t_timer_create.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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;
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_condwait.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_condwait.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_condwait.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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 201
#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);
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_detach.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_detach.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_detach.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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);
}
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_fork.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_fork.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_fork.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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 at 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);
}
}
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_fpu.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_fpu.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_fpu.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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/
* <is at 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");
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_mutex.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_mutex.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_mutex.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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);
}
}
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_sem.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_sem.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_sem.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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>
Modified: vendor/NetBSD/tests/dist/lib/libpthread/t_swapcontext.c
==============================================================================
--- vendor/NetBSD/tests/dist/lib/libpthread/t_swapcontext.c Mon Jan 16 16:58:12 2017 (r312293)
+++ vendor/NetBSD/tests/dist/lib/libpthread/t_swapcontext.c Mon Jan 16 17:25:48 2017 (r312294)
@@ -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));
}
Added: vendor/NetBSD/tests/dist/net/carp/t_basic.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ vendor/NetBSD/tests/dist/net/carp/t_basic.sh Mon Jan 16 17:25:48 2017 (r312294)
@@ -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
+}
More information about the svn-src-vendor
mailing list