git: 9f192dd79cce - stable/12 - netbsd-tests: Fix the libc stat_socket test
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 21 Jan 2022 00:55:25 UTC
The branch stable/12 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=9f192dd79cce2ea53a1cdc3ab64ea204a2fb9d84
commit 9f192dd79cce2ea53a1cdc3ab64ea204a2fb9d84
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-01-14 20:00:01 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-01-21 00:53:44 +0000
netbsd-tests: Fix the libc stat_socket test
The test tries to connect a socket to a closed port at 127.0.0.1. It
sets O_NONBLOCK on the socket first and expects to get EINPROGRESS from
connect(2), but this is not guaranteed, ECONNREFUSED is possible.
Handle both cases, and re-enable the test.
PR: 240621
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 95c75073d3d1ca9dcae41784453172f199bb2c0f)
---
contrib/netbsd-tests/lib/libc/sys/t_stat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_stat.c b/contrib/netbsd-tests/lib/libc/sys/t_stat.c
index 9d0136dae50b..029ff8452d94 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_stat.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_stat.c
@@ -350,14 +350,14 @@ ATF_TC_BODY(stat_socket, tc)
errno = 0;
- ATF_REQUIRE_ERRNO(EINPROGRESS,
- connect(fd, (struct sockaddr *)&addr,
- sizeof(struct sockaddr_in)) == -1);
+ ATF_REQUIRE(connect(fd, (struct sockaddr *)&addr,
+ sizeof(struct sockaddr_in)) == -1);
+ ATF_REQUIRE(errno == EINPROGRESS || errno == ECONNREFUSED);
errno = 0;
if (fstat(fd, &st) != 0 || errno != 0)
- atf_tc_fail("fstat(2) failed for a EINPROGRESS socket");
+ atf_tc_fail("fstat(2) failed for a socket");
(void)close(fd);
}