Skip to content

Commit

Permalink
macos: more timing test fixes for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jiixyj committed Jul 11, 2022
1 parent 56f35ed commit 605be8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/timerfd-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ ATF_TC_BODY_FD_LEAKCHECK(timerfd__simple_periodic_timer, tc)

ATF_REQUIRE(read(timerfd, &timeouts, sizeof(timeouts)) ==
(ssize_t)sizeof(timeouts));
ATF_REQUIRE(timeouts >= 2);
#ifndef ALLOW_TIMER_SLACK
ATF_REQUIRE(timeouts == 2);
#endif

ATF_REQUIRE(close(timerfd) == 0);
}
Expand Down Expand Up @@ -238,12 +241,18 @@ ATF_TC_BODY_FD_LEAKCHECK(timerfd__reset_periodic_timer, tc)
ATF_REQUIRE(timerfd_settime(timerfd, 0, &time, NULL) == 0);

uint64_t timeouts = wait_for_timerfd(timerfd);
ATF_REQUIRE(timeouts >= 1);
#ifndef ALLOW_TIMER_SLACK
ATF_REQUIRE(timeouts == 1);
#endif

ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, &e) == 0);
timespecsub(&e, &b, &e);
ATF_REQUIRE((e.tv_sec == 0 && e.tv_nsec >= 150000000) || e.tv_sec > 0);
#ifndef ALLOW_TIMER_SLACK
ATF_REQUIRE(e.tv_sec == 0 && e.tv_nsec >= 150000000 &&
e.tv_nsec < 150000000 + TIMER_SLACK * 2);
#endif

ATF_REQUIRE(close(timerfd) == 0);
}
Expand Down

0 comments on commit 605be8c

Please sign in to comment.