Date: Wed, 2 Mar 2022 21:57:24 GMT From: Eric van Gyzen <vangyzen@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: b49682bb0658 - stable/13 - sem_clockwait_np test: fix usage of ATF API Message-ID: <202203022157.222LvOko065191@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=b49682bb0658bbccaef2547c4fac2b58756acdc2 commit b49682bb0658bbccaef2547c4fac2b58756acdc2 Author: Eric van Gyzen <vangyzen@FreeBSD.org> AuthorDate: 2021-10-01 11:25:48 +0000 Commit: Eric van Gyzen <vangyzen@FreeBSD.org> CommitDate: 2022-03-02 21:56:30 +0000 sem_clockwait_np test: fix usage of ATF API ATF_REQUIRE_ERRNO requires the given errno iff the given expression is true. These test cases used it incorrectly, potentially allowing sem_clockwait_np to succeed when it was expected to fail. Use separate ATF calls to require failure and the expected errno. MFC after: 1 week Sponsored by: Dell EMC Isilon (cherry picked from commit 35e4527e88d3843cccf2f15a32b1fa041a01d693) --- contrib/netbsd-tests/lib/librt/t_sem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/netbsd-tests/lib/librt/t_sem.c b/contrib/netbsd-tests/lib/librt/t_sem.c index 3156b11e9bf3..1c4290c0b3fb 100644 --- a/contrib/netbsd-tests/lib/librt/t_sem.c +++ b/contrib/netbsd-tests/lib/librt/t_sem.c @@ -366,8 +366,9 @@ ATF_TC_BODY(clockwait_absolute_intr_remaining, tc) ATF_REQUIRE_MSG(clock_gettime(CLOCK_MONOTONIC, &ts) == 0, "%s", strerror(errno)); timespec_add_ms(&ts, 100); - ATF_REQUIRE_ERRNO(EINTR, sem_clockwait_np(&sem, CLOCK_MONOTONIC, + ATF_REQUIRE_EQ(-1, sem_clockwait_np(&sem, CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &remain)); + ATF_REQUIRE_ERRNO(EINTR, 1); ATF_REQUIRE_MSG(got_sigalrm, "did not get SIGALRM"); ATF_REQUIRE_MSG(remain.tv_sec == 42 && remain.tv_nsec == 1000*1000*1000, "an absolute clockwait modified the remaining time on EINTR"); @@ -397,8 +398,9 @@ ATF_TC_BODY(clockwait_relative_intr_remaining, tc) "%s", strerror(errno)); ts.tv_sec = 0; ts.tv_nsec = 100*1000*1000; - ATF_REQUIRE_ERRNO(EINTR, sem_clockwait_np(&sem, CLOCK_MONOTONIC, 0, &ts, + ATF_REQUIRE_EQ(-1, sem_clockwait_np(&sem, CLOCK_MONOTONIC, 0, &ts, &remain)); + ATF_REQUIRE_ERRNO(EINTR, 1); ATF_REQUIRE_MSG(got_sigalrm, "did not get SIGALRM"); ATF_REQUIRE_MSG(remain.tv_sec == 0 && (remain.tv_nsec >= 25*1000*1000 || machine_is_virtual()) &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203022157.222LvOko065191>