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 95c75073d3)
This commit is contained in:
Mark Johnston committed 2022-01-20 19:53:44 -05:00
1 parent 6d1a563281
commit 9f192dd79c
1 file changed
+4 -4
+4 -4
View File
@@ -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);
}