svn commit: r312295 - in projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests: lib/libc/ssp lib/libc/sys lib/libpthread net/carp
Ngie Cooper
ngie at FreeBSD.org
Mon Jan 16 17:43:46 UTC 2017
Author: ngie
Date: Mon Jan 16 17:43:43 2017
New Revision: 312295
URL: https://svnweb.freebsd.org/changeset/base/312295
Log:
Merge ^/vendor/NetBSD/tests/dist at r312294
This includes a number of accepted upstream fixes, as well as
a reimplementation of the net/carp/... testcase (which is
currently unused).
Added:
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.sh
- copied unchanged from r312294, vendor/NetBSD/tests/dist/net/carp/t_basic.sh
Deleted:
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.c
Modified:
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_read.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_condwait.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_detach.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fork.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fpu.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_mutex.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_sem.c
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
Directory Properties:
projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/ (props changed)
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_memset.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_memset.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,9 +41,5 @@ main(int argc, char *argv[])
char b[10];
size_t len = atoi(argv[1]);
(void)memset(b, 0, len);
-#ifdef __FreeBSD__
return b[0]; /* keeps optimizer from zapping the call to memset() */
-#else
- return 0;
-#endif
}
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_read.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_read.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/ssp/h_read.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,17 +29,15 @@
#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>
-#ifdef __FreeBSD__
-#include <fcntl.h>
-#include <paths.h>
-
int
main(int argc, char *argv[])
{
@@ -54,14 +52,3 @@ main(int argc, char *argv[])
(void)printf("%s\n", b);
return (0);
}
-#else
-int
-main(int argc, char *argv[])
-{
- char b[MAXPATHLEN];
- size_t len = atoi(argv[1]);
-
- (void)printf("%s\n", b);
- return 0;
-}
-#endif
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,11 +74,8 @@ __RCSID("$NetBSD: t_mmap.c,v 1.11 2017/0
#include <string.h>
#include <unistd.h>
#include <paths.h>
-#ifdef __NetBSD__
-#include <machine/disklabel.h>
-#else
+#ifdef __FreeBSD__
#include <stdint.h>
-#include <sys/disklabel.h>
#endif
static long page = 0;
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,11 +38,7 @@ static timer_t t;
static bool fail = true;
static void
-#ifdef __FreeBSD__
timer_signal_handler(int signo, siginfo_t *si, void *osi __unused)
-#else
-timer_signal_handler(int signo, siginfo_t *si, void *osi)
-#endif
{
timer_t *tp;
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_condwait.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_condwait.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_condwait.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,11 +41,7 @@ __RCSID("$NetBSD: t_condwait.c,v 1.4 201
#include "isqemu.h"
-#ifdef __FreeBSD__
-#include <sys/time.h>
-
#include "h_common.h"
-#endif
#define WAITTIME 2 /* Timeout wait secound */
@@ -62,13 +59,8 @@ run(void *param)
clck = *(clockid_t *)param;
-#ifdef __FreeBSD__
PTHREAD_REQUIRE(pthread_condattr_init(&attr));
PTHREAD_REQUIRE(pthread_condattr_setclock(&attr, clck));
-#else
- pthread_condattr_init(&attr);
- pthread_condattr_setclock(&attr, clck); /* MONOTONIC or MONOTONIC */
-#endif
pthread_cond_init(&cond, &attr);
ATF_REQUIRE_EQ((ret = pthread_mutex_lock(&m)), 0);
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_detach.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_detach.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_detach.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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>
@@ -47,9 +48,7 @@ static void *func(void *);
static void *
func(void *arg)
{
-#ifdef __FreeBSD__
sleep(2);
-#endif
return NULL;
}
@@ -79,25 +78,17 @@ ATF_TC_BODY(pthread_detach, tc)
*/
PTHREAD_REQUIRE(pthread_detach(t));
-#ifdef __FreeBSD__
sleep(1);
-#endif
rv = pthread_join(t, NULL);
ATF_REQUIRE(rv == EINVAL);
-#ifdef __FreeBSD__
sleep(3);
-#endif
/*
* As usual, ESRCH should follow if
* we try to detach an invalid thread.
*/
-#ifdef __NetBSD__
- rv = pthread_cancel(NULL);
-#else
rv = pthread_cancel(t);
-#endif
ATF_REQUIRE(rv == ESRCH);
}
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fork.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fork.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fork.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,11 +61,7 @@ print_pid(void *arg)
thread_survived = 1;
if (parent != getpid()) {
-#ifdef __FreeBSD__
_exit(1);
-#else
- exit(1);
-#endif
}
return NULL;
}
@@ -99,11 +95,7 @@ ATF_TC_BODY(fork, tc)
ATF_REQUIRE_EQ_MSG(WEXITSTATUS(status), 0, "thread survived in child");
} else {
sleep(5);
-#ifdef __FreeBSD__
_exit(thread_survived ? 1 : 0);
-#else
- exit(thread_survived ? 1 : 0);
-#endif
}
}
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fpu.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fpu.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_fpu.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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>
@@ -82,24 +84,16 @@ stir(void *p)
for (;;) {
x = sin ((y = cos (x + y + .4)) - (z = cos (x + z + .6)));
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(sched_yield() == 0,
"sched_yield failed: %s", strerror(errno));
-#else
- PTHREAD_REQUIRE(sched_yield());
-#endif
}
}
static double
mul3(double x, double y, double z)
{
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(sched_yield() == 0,
"sched_yield failed: %s", strerror(errno));
-#else
- PTHREAD_REQUIRE(sched_yield());
-#endif
return x * y * z;
}
@@ -129,11 +123,7 @@ bar(void *p)
static void
recurse(void) {
pthread_t s2;
-#ifdef __FreeBSD__
PTHREAD_REQUIRE(pthread_create(&s2, 0, bar, 0));
-#else
- pthread_create(&s2, 0, bar, 0);
-#endif
sleep(20); /* XXX must be long enough for our slowest machine */
}
@@ -153,11 +143,7 @@ ATF_TC_BODY(fpu, tc)
PTHREAD_REQUIRE(pthread_mutex_init(&recursion_depth_lock, 0));
-#ifdef __FreeBSD__
PTHREAD_REQUIRE(pthread_create(&s5, 0, stir, stirseed));
-#else
- pthread_create(&s5, 0, stir, stirseed);
-#endif
recurse();
atf_tc_fail("exiting from main");
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_mutex.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_mutex.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_mutex.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,12 +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 $");
-#ifdef __FreeBSD__
#include <sys/time.h> /* For timespecadd */
#include <inttypes.h> /* For UINT16_MAX */
-#endif
#include <pthread.h>
#include <stdio.h>
#include <string.h>
@@ -594,20 +592,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;
-#ifdef __FreeBSD__
int protocol;
PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr,
&protocol));
printf("priority: %d\nprotocol: %d\n", i, protocol);
-#endif
PTHREAD_REQUIRE(pthread_mutexattr_setprioceiling(&mattr, i));
PTHREAD_REQUIRE(pthread_mutexattr_getprioceiling(&mattr,
&prioceiling));
-#ifdef __FreeBSD__
printf("prioceiling: %d\n", prioceiling);
-#endif
ATF_REQUIRE_EQ(i, prioceiling);
}
}
Modified: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_sem.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_sem.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_sem.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
==============================================================================
--- projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c Mon Jan 16 17:25:48 2017 (r312294)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c Mon Jan 16 17:43:43 2017 (r312295)
@@ -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,15 +28,13 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD");
-#ifdef __FreeBSD__
#include <sys/types.h>
#include <errno.h>
-#include <string.h>
-#endif
#include <pthread.h>
-#include <ucontext.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ucontext.h>
#include <atf-c.h>
@@ -82,12 +80,8 @@ threadfunc(void *arg)
oself = (void *)pthread_self();
printf("before swapcontext self = %p\n", oself);
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(swapcontext(&octx, &nctx) != -1, "swapcontext failed: %s",
strerror(errno));
-#else
- PTHREAD_REQUIRE(swapcontext(&octx, &nctx));
-#endif
/* NOTREACHED */
return NULL;
@@ -118,12 +112,8 @@ ATF_TC_BODY(swapcontext1, tc)
printf("Testing if swapcontext() alters pthread_self()\n");
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s",
strerror(errno));
-#else
- PTHREAD_REQUIRE(getcontext(&nctx));
-#endif
PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL));
PTHREAD_REQUIRE(pthread_join(thread, NULL));
}
Copied: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.sh (from r312294, vendor/NetBSD/tests/dist/net/carp/t_basic.sh)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/net/carp/t_basic.sh Mon Jan 16 17:43:43 2017 (r312295, copy of r312294, vendor/NetBSD/tests/dist/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
+}
More information about the svn-src-projects
mailing list