]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: fix socket unit test to use non-blocking accepted sockets master
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 28 Aug 2025 07:33:34 +0000 (09:33 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 28 Aug 2025 07:39:26 +0000 (09:39 +0200)
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>
test/unit/socket.c

index 8630f382e46abb6f17a7ab9f216bdce21e351522..e3db0742886838989c4fae9e39e8dc85dd3bac9c 100644 (file)
@@ -191,6 +191,7 @@ test_unit(void)
         s3 = SCK_AcceptConnection(s1, &sa2);
         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);
 
         SCK_ShutdownConnection(s2);
@@ -227,6 +228,7 @@ test_unit(void)
     s3 = SCK_AcceptConnection(s1, &sa2);
     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);
 
     if (i % 4)