Skip to content

Commit

Permalink
Check errno on startup in timerfd__{reset_to_very_long,unmodified_errno}
Browse files Browse the repository at this point in the history
Due to a bug in CheriBSD, errno was set non-zero when starting this test,
but without these checks the test confusingly failed in the later check
which made me think something was wrong in timerfd_create. Check errno on
startup to make this more obvious.

See CTSRD-CHERI/cheribsd#1424
  • Loading branch information
arichardson committed Sep 3, 2023
1 parent c8ef343 commit ecac389
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/timerfd-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ ATF_TC_BODY_FD_LEAKCHECK(timerfd__short_evfilt_timer_timeout, tc)
ATF_TC_WITHOUT_HEAD(timerfd__unmodified_errno);
ATF_TC_BODY_FD_LEAKCHECK(timerfd__unmodified_errno, tc)
{
ATF_REQUIRE(errno == 0);
int timerfd = timerfd_create(CLOCK_MONOTONIC, /**/
TFD_CLOEXEC | TFD_NONBLOCK);
ATF_REQUIRE(timerfd >= 0);
Expand All @@ -954,6 +955,7 @@ ATF_TC_BODY_FD_LEAKCHECK(timerfd__unmodified_errno, tc)
.it_value.tv_nsec = 100000000,
},
NULL) == 0);
ATF_REQUIRE(errno == 0);
(void)wait_for_timerfd(timerfd);
ATF_REQUIRE(errno == 0);

Expand All @@ -980,6 +982,7 @@ ATF_TC_BODY_FD_LEAKCHECK(timerfd__unmodified_errno, tc)
ATF_TC_WITHOUT_HEAD(timerfd__reset_to_very_long);
ATF_TC_BODY_FD_LEAKCHECK(timerfd__reset_to_very_long, tc)
{
ATF_REQUIRE(errno == 0);
int timerfd = timerfd_create(CLOCK_MONOTONIC, /**/
TFD_CLOEXEC | TFD_NONBLOCK);
ATF_REQUIRE(timerfd >= 0);
Expand Down

0 comments on commit ecac389

Please sign in to comment.