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 Jun 19, 2022
1 parent 86d269e commit 090f859
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 @@ -900,6 +900,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 @@ -911,6 +912,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 @@ -937,6 +939,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 090f859

Please sign in to comment.