changeset 22145:f8723d47b785

lib-imap-client: Fix test-imapc-client unit test to work on OSX connect() to port 0 fails in it, so for the "connect failure" test first open a random free listener port and then close it. Hopefully nothing else reopens it in the mean time.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 30 May 2017 10:37:24 +0300
parents ca4bf2b2392b
children 88d2ad3f2463
files src/lib-imap-client/test-imapc-client.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap-client/test-imapc-client.c	Wed May 31 00:07:46 2017 +0300
+++ b/src/lib-imap-client/test-imapc-client.c	Tue May 30 10:37:24 2017 +0300
@@ -127,9 +127,10 @@
 	i_zero(&server);
 	server.pid = (pid_t)-1;
 	server.fd = -1;
-	server.fd_listen = server_test == NULL ? -1 :
-		test_open_server_fd(&server.port);
+	server.fd_listen = test_open_server_fd(&server.port);
 	client_set_copy.port = server.port;
+	if (server_test == NULL)
+		i_close_fd(&server.fd_listen);
 
 	if (mkdir(client_set->temp_path_prefix, 0700) < 0 && errno != EEXIST)
 		i_fatal("mkdir(%s) failed: %m", client_set->temp_path_prefix);