]> 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)
committerGitLab <gitlab@git.dovecot.net>
Sun, 4 Jun 2017 16:29:49 +0000 (19:29 +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 0e66fe612097e0b5d3c4d806be66fb50ef1577c7..69bd865c84c8348d20c1841ae5f0d7ab630811c5 100644 (file)
@@ -128,9 +128,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);