Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libpthread PR lib/54440: adapt the FreeBSD change ...
details: https://anonhg.NetBSD.org/src/rev/56b354c493f5
branches: trunk
changeset: 964636:56b354c493f5
user: martin <martin%NetBSD.org@localhost>
date: Sat Aug 10 07:36:15 2019 +0000
description:
PR lib/54440: adapt the FreeBSD change to this test and calculate time
differences more exact, allowing between 0 and 1 s delay between the
expected wakeup and the actual event happening.
Also convert the QEMU special case code to the same scheme, but for now
disable it (with XXX mark) and see if the proper timing limits fix that
case too.
If not, we will re-enable the QEMU special case.
diffstat:
tests/lib/libpthread/t_condwait.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diffs (57 lines):
diff -r 92caa1facf70 -r 56b354c493f5 tests/lib/libpthread/t_condwait.c
--- a/tests/lib/libpthread/t_condwait.c Sat Aug 10 07:08:11 2019 +0000
+++ b/tests/lib/libpthread/t_condwait.c Sat Aug 10 07:36:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_condwait.c,v 1.6 2019/07/09 16:24:01 maya Exp $ */
+/* $NetBSD: t_condwait.c,v 1.7 2019/08/10 07:36:15 martin 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.6 2019/07/09 16:24:01 maya Exp $");
+__RCSID("$NetBSD: t_condwait.c,v 1.7 2019/08/10 07:36:15 martin Exp $");
#include <sys/time.h>
#include <errno.h>
@@ -50,7 +50,7 @@
static void *
run(void *param)
{
- struct timespec ts, to, te;
+ struct timespec ts, to, te, twmin, twmax;
clockid_t clck;
pthread_condattr_t attr;
pthread_cond_t cond;
@@ -85,14 +85,23 @@
printf("elapsed: %lld.%09ld sec\n",
(long long)to.tv_sec, to.tv_nsec);
}
- if (isQEMU()) {
- double to_seconds = to.tv_sec + 1e-9 * to.tv_nsec;
- ATF_REQUIRE(to_seconds >= WAITTIME * 0.9);
- /* Loose upper limit because of qemu timing bugs */
- ATF_REQUIRE(to_seconds < WAITTIME * 2.5);
+ twmin.tv_sec = WAITTIME;
+ twmin.tv_nsec = 0;
+ if (0 /* XXX */ && isQEMU()) {
+ struct timespec td, t;
+ td.tv_sec = 0;
+ td.tv_nsec = 900000000;
+ t = twmin;
+ timespecsub(&t, &td, &twmin);
+ td.tv_sec = 2;
+ td.tv_nsec = 500000000;
+ timespecadd(&t, &td, &twmax);
} else {
- ATF_REQUIRE_EQ(to.tv_sec, WAITTIME);
+ twmax = twmin;
+ twmax.tv_sec++;
}
+ ATF_REQUIRE(timespeccmp(&to, &twmin, >=));
+ ATF_REQUIRE(timespeccmp(&to, &twmax, <=));
break;
default:
ATF_REQUIRE_MSG(0, "pthread_cond_timedwait: %s", strerror(ret));
Home |
Main Index |
Thread Index |
Old Index