]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-client: Fix test-imapc-client unit test to work on OSX
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 30 May 2017 07:37:24 +0000 (10:37 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 12 Jun 2017 07:16:11 +0000 (10:16 +0300)
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.

src/lib-imap-client/test-imapc-client.c

index bf925214235e5f82a7ec67feb523f127c74eaf8b..164d6412a2a605b98f3e0b8e12556fa3bc0f9804 100644 (file)
@@ -127,9 +127,10 @@ static void test_run_client_server(
        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);