From bef1c573153bc6c619302372e09325111a7faba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sat, 2 Nov 2019 14:56:57 +0100 Subject: [PATCH] Allow a single FD to be "leaked" in the TCP connect leak test. On macOS, the kqueue mechanism appears to create an internal FD that wrongly triggers the leak condition. --- tests/issue-115-connect-fail-leak.d | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/issue-115-connect-fail-leak.d b/tests/issue-115-connect-fail-leak.d index 9af3afc..95afedb 100644 --- a/tests/issue-115-connect-fail-leak.d +++ b/tests/issue-115-connect-fail-leak.d @@ -19,15 +19,19 @@ void main() auto initial = determineSocketCount(); + foreach (i; 0 .. 3) + test(); + + assert(determineSocketCount() <= initial + 1, "Sockets leaked!"); +} + +void test() +{ TCPConnection conn; try { conn = connectTCP("127.0.0.1", 16565); - logError("Connection: %s", conn); - conn.close(); assert(false, "Didn't expect TCP connection on port 16565 to succeed"); } catch (Exception) { } - - assert(determineSocketCount() == initial, "Sockets leaked!"); } size_t determineSocketCount()