From ecac3891c9b7b862bb7bff4dc424df8b04e7053a Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sun, 19 Jun 2022 15:44:02 +0000 Subject: [PATCH] Check errno on startup in timerfd__{reset_to_very_long,unmodified_errno} 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 https://github.com/CTSRD-CHERI/cheribsd/issues/1424 --- test/timerfd-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/timerfd-test.c b/test/timerfd-test.c index dad90aa..6392136 100644 --- a/test/timerfd-test.c +++ b/test/timerfd-test.c @@ -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); @@ -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); @@ -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);