From 9a9a33398db6cf89ff0f203423a28e4589b90949 Mon Sep 17 00:00:00 2001 From: vangyzen Date: Mon, 5 Aug 2019 22:59:35 +0000 Subject: [PATCH] Relax time constraint in pthread_cond_timedwait unit test pthread_cond_timedwait() should wait _at least_ until the timeout, but it might appear to wait longer due to system activity and scheduling. The test ignored fractional seconds when comparing the actual and expected timeouts, so it allowed anywhere between zero and one extra second of wait time. Zero is a bit unreasonable. Compare fractional seconds so we always allow up to one extra second. Reviewed by: ngie MFC after: 1 week Sponsored by: Dell EMC Isilon --- contrib/netbsd-tests/lib/libpthread/t_condwait.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/contrib/netbsd-tests/lib/libpthread/t_condwait.c b/contrib/netbsd-tests/lib/libpthread/t_condwait.c index 58b4a8bc155..37aadb52292 100644 --- a/contrib/netbsd-tests/lib/libpthread/t_condwait.c +++ b/contrib/netbsd-tests/lib/libpthread/t_condwait.c @@ -51,6 +51,9 @@ static void * run(void *param) { struct timespec ts, to, te; +#ifdef __FreeBSD__ + struct timespec tw; +#endif clockid_t clck; pthread_condattr_t attr; pthread_cond_t cond; @@ -91,7 +94,15 @@ run(void *param) /* Loose upper limit because of qemu timing bugs */ ATF_REQUIRE(to_seconds < WAITTIME * 2.5); } else { +#ifdef __FreeBSD__ + tw.tv_sec = WAITTIME; + tw.tv_nsec = 0; + ATF_REQUIRE(timespeccmp(&to, &tw, >=)); + tw.tv_sec++; + ATF_REQUIRE(timespeccmp(&to, &tw, <=)); +#else ATF_REQUIRE_EQ(to.tv_sec, WAITTIME); +#endif } break; default: -- 2.45.0