]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: test-http-client-errors - Don't rely on sleeps
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 10 Dec 2020 08:44:42 +0000 (10:44 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 1 Jul 2021 07:22:34 +0000 (07:22 +0000)
Use the notification signal API instead. Also it's only one test (group)
that needs to do this.

src/lib-http/test-http-client-errors.c

index 462c9c45e79a464122aa9c108d9258e5e6427e1d..9cb2401d325544d04dafc171204caa0b271551c1 100644 (file)
@@ -376,6 +376,8 @@ static void
 test_server_connection_refused(unsigned int index ATTR_UNUSED)
 {
        i_close_fd(&fd_listen);
+
+       test_subprocess_notify_signal_send_parent();
 }
 
 /* client */
@@ -415,6 +417,9 @@ test_client_connection_refused(const struct http_client_settings *client_set)
        struct http_client_request *hreq;
        struct _connection_refused *ctx;
 
+       /* wait for the server side to close the socket */
+       test_subprocess_notify_signal_wait(10000);
+
        ctx = i_new(struct _connection_refused, 1);
        ctx->count = 2;
 
@@ -3816,8 +3821,6 @@ test_run_client(const struct http_client_settings *client_set,
        if (debug)
                i_debug("PID=%s", my_pid);
 
-       i_sleep_msecs(100); /* wait a little for server setup */
-
        ioloop = io_loop_create();
        test_client_run(client_test, client_set);
        io_loop_destroy(&ioloop);
@@ -3835,6 +3838,7 @@ test_run_client_server(const struct http_client_settings *client_set,
 {
        unsigned int i;
 
+       test_subprocess_notify_signal_reset();
        test_server_init = NULL;
        test_server_deinit = NULL;
        test_server_input = NULL;