summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libpthread
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-01-13 08:46:46 +0000
committerngie <ngie@FreeBSD.org>2017-01-13 08:46:46 +0000
commit0121c546456826420083135a793921f0b10eb0fb (patch)
tree7bbc8d51c45cac9872c02a253b64874d5bdb15e5 /contrib/netbsd-tests/lib/libpthread
parent2018c33abf77cea7a3171ed6a617730825aee00e (diff)
downloadFreeBSD-src-0121c546456826420083135a793921f0b10eb0fb.zip
FreeBSD-src-0121c546456826420083135a793921f0b10eb0fb.tar.gz
MFC r311265,r311274:
r311265: fpu: ensure calls to pthread_create succeed and test sched_yield to make sure it returns 0 sched_yield tests for values returning 0 of type int and sched_yield is of type long, so the test is a mismatch CID: 1254953, 1254954, 1254965, 1254966 r311274: run: ensure pthread_condattr_{init,setclock} is successful CID: 1268631, 1268633
Diffstat (limited to 'contrib/netbsd-tests/lib/libpthread')
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_condwait.c7
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_fpu.c23
2 files changed, 30 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libpthread/t_condwait.c b/contrib/netbsd-tests/lib/libpthread/t_condwait.c
index 17bbb89..99793d0 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_condwait.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_condwait.c
@@ -42,6 +42,8 @@ __RCSID("$NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $");
#ifdef __FreeBSD__
#include <sys/time.h>
+
+#include "h_common.h"
#endif
#define WAITTIME 2 /* Timeout wait secound */
@@ -60,8 +62,13 @@ 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);
diff --git a/contrib/netbsd-tests/lib/libpthread/t_fpu.c b/contrib/netbsd-tests/lib/libpthread/t_fpu.c
index 4047b1f..6a385d9 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_fpu.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_fpu.c
@@ -58,6 +58,11 @@ __RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $");
#include <atf-c.h>
+#ifdef __FreeBSD__
+#include <errno.h>
+#include <string.h>
+#endif
+
#include "h_common.h"
#define N_RECURSE 10
@@ -77,14 +82,24 @@ 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;
}
@@ -114,7 +129,11 @@ 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 */
}
@@ -134,7 +153,11 @@ 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");
OpenPOWER on IntegriCloud