Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libpthread Make cond_wait_mono and cond_wait_real ...
details: https://anonhg.NetBSD.org/src/rev/5181a1a62ef2
branches: trunk
changeset: 786041:5181a1a62ef2
user: gson <gson%NetBSD.org@localhost>
date: Fri Apr 12 14:21:52 2013 +0000
description:
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:
tests/lib/libpthread/t_condwait.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (44 lines):
diff -r f5a4bd15c6df -r 5181a1a62ef2 tests/lib/libpthread/t_condwait.c
--- a/tests/lib/libpthread/t_condwait.c Fri Apr 12 12:30:18 2013 +0000
+++ b/tests/lib/libpthread/t_condwait.c Fri Apr 12 14:21:52 2013 +0000
@@ -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 @@
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 @@
/* 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));
Home |
Main Index |
Thread Index |
Old Index