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
This commit is contained in:
parent
ed9ffd2f09
commit
e48c002fa4
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user