diff options
| author | gson <gson@NetBSD.org> | 2013-04-12 14:21:52 +0000 |
|---|---|---|
| committer | gson <gson@NetBSD.org> | 2013-04-12 14:21:52 +0000 |
| commit | 5e5e39083e050cc0804dce535f359a92adbe2373 (patch) | |
| tree | aeafe0e456c0eafd7b9ad6ca5ddbdf4872d7ec5c /tests/lib/libpthread/t_condwait.c | |
| parent | cf2292387b7a0bf9027216db2ec4b1fa75fa770b (diff) | |
Make cond_wait_mono and cond_wait_real tests accept a wait time in the
range of 90% to 250% of nominal, to allow the test to pass under qemu
which has a known issue where timing can be off by a factor of two.
Diffstat (limited to 'tests/lib/libpthread/t_condwait.c')
| -rw-r--r-- | tests/lib/libpthread/t_condwait.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/lib/libpthread/t_condwait.c b/tests/lib/libpthread/t_condwait.c index 1663963eb32..7c77387f7f1 100644 --- a/tests/lib/libpthread/t_condwait.c +++ b/tests/lib/libpthread/t_condwait.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_condwait.c,v 1.2 2013/03/29 02:32:38 christos Exp $ */ +/* $NetBSD: t_condwait.c,v 1.3 2013/04/12 14:21:52 gson Exp $ */ /* * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_condwait.c,v 1.2 2013/03/29 02:32:38 christos Exp $"); +__RCSID("$NetBSD: t_condwait.c,v 1.3 2013/04/12 14:21:52 gson Exp $"); #include <errno.h> #include <pthread.h> @@ -46,6 +46,7 @@ static void * run(void *param) { struct timespec ts, to, te; + double to_seconds; clockid_t clck; pthread_condattr_t attr; pthread_cond_t cond; @@ -74,13 +75,16 @@ run(void *param) /* Timeout */ ATF_REQUIRE_EQ(clock_gettime(clck, &te), 0); timespecsub(&te, &to, &to); + to_seconds = to.tv_sec + 1e-9 * to.tv_nsec; if (debug) { printf("timeout: %lld.%09ld sec\n", (long long)te.tv_sec, te.tv_nsec); printf("elapsed: %lld.%09ld sec\n", (long long)to.tv_sec, to.tv_nsec); } - ATF_REQUIRE_EQ(to.tv_sec, WAITTIME); + ATF_REQUIRE(to_seconds >= WAITTIME * 0.9); + /* Use a loose upper limit because of qemu timing bugs */ + ATF_REQUIRE(to_seconds < WAITTIME * 2.5); break; default: ATF_REQUIRE_MSG(0, "pthread_cond_timedwait: %s", strerror(ret)); |
