test: fix socket unit test to use non-blocking accepted sockets

SCK_AcceptConnection() always returns a non-blocking socket. Clear the
O_NONBLOCK flag in the socket unit test, which relies on blocking, to
avoid failures.

Reported-by: Matthias Andree <matthias.andree@gmx.de>
This commit is contained in:
Miroslav Lichvar
2025-08-28 09:33:34 +02:00
parent 9e8541e3c4
commit 120bf44989

View File

@@ -191,6 +191,7 @@ test_unit(void)
s3 = SCK_AcceptConnection(s1, &sa2); s3 = SCK_AcceptConnection(s1, &sa2);
TEST_CHECK(UTI_CompareIPs(&sa1.ip_addr, &sa2.ip_addr, NULL) == 0); TEST_CHECK(UTI_CompareIPs(&sa1.ip_addr, &sa2.ip_addr, NULL) == 0);
fcntl(s3, F_SETFL, fcntl(s3, F_GETFL) & ~O_NONBLOCK);
send_and_recv(SCK_ADDR_IP, 1, 1, s3, s2); send_and_recv(SCK_ADDR_IP, 1, 1, s3, s2);
SCK_ShutdownConnection(s2); SCK_ShutdownConnection(s2);
@@ -227,6 +228,7 @@ test_unit(void)
s3 = SCK_AcceptConnection(s1, &sa2); s3 = SCK_AcceptConnection(s1, &sa2);
TEST_CHECK(sa2.ip_addr.family == IPADDR_UNSPEC); TEST_CHECK(sa2.ip_addr.family == IPADDR_UNSPEC);
fcntl(s3, F_SETFL, fcntl(s3, F_GETFL) & ~O_NONBLOCK);
send_and_recv(SCK_ADDR_UNIX, 1, i % 2, s3, s2); send_and_recv(SCK_ADDR_UNIX, 1, i % 2, s3, s2);
if (i % 4) if (i % 4)