Skip to content

Commit

Permalink
Check errno on startup in timerfd__{reset_to_very_long,unmodified_err…
Browse files Browse the repository at this point in the history
…no} (#53)

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 authored Dec 7, 2024
1 parent 081c91c commit d10de5f
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 @@ -952,6 +952,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 @@ -963,6 +964,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 @@ -989,6 +991,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 d10de5f

Please sign in to comment.