diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2017-01-16 17:25:48 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2017-01-16 17:25:48 +0000 |
commit | 03c41ac965df56079c04c1750c684b942e27c59a (patch) | |
tree | 95238c07f579c78188d230f8759f0d0345b0f6ae /lib/libpthread | |
parent | 181439425f0bb490970e4e7022295f139d9988ad (diff) |
Notes
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/t_condwait.c | 11 | ||||
-rw-r--r-- | lib/libpthread/t_detach.c | 13 | ||||
-rw-r--r-- | lib/libpthread/t_fork.c | 8 | ||||
-rw-r--r-- | lib/libpthread/t_fpu.c | 16 | ||||
-rw-r--r-- | lib/libpthread/t_mutex.c | 13 | ||||
-rw-r--r-- | lib/libpthread/t_sem.c | 5 | ||||
-rw-r--r-- | lib/libpthread/t_swapcontext.c | 13 |
7 files changed, 53 insertions, 26 deletions
diff --git a/lib/libpthread/t_condwait.c b/lib/libpthread/t_condwait.c index 9b79587104cfa..58b4a8bc155aa 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 21db871a70da7..b30cb029d578c 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 ab8806d256411..936c7decaecf1 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 4047b1fa6195a..dd47fb8067e7c 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 e9ba2fc5754a1..b706e462f3dbc 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 a4e03ae9c605b..3d15eddab64b0 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 8fd2314045425..677c51fc8601f 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)); } |