]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: test-master-login-auth - Split off test_run_server/client() from test_run_cli...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sat, 11 Apr 2020 11:51:49 +0000 (13:51 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 25 May 2020 17:38:24 +0000 (19:38 +0200)
src/master/test-master-login-auth.c

index 025380fd94860490305bccfc5ae676289456a57d..4ea8e77fa38248816c71b1d7071029e73b475e50 100644 (file)
@@ -893,6 +893,36 @@ static void test_server_kill_forced(void)
        }
 }
 
+static void test_run_server(test_server_init_t *server_test)
+{
+       i_set_failure_prefix("SERVER: ");
+
+       if (debug)
+               i_debug("PID=%s", my_pid);
+
+       ioloop = io_loop_create();
+       server_test();
+       io_loop_destroy(&ioloop);
+
+       i_close_fd(&fd_listen);
+}
+
+static void test_run_client(test_client_init_t *client_test)
+{
+       i_set_failure_prefix("CLIENT: ");
+
+       if (debug)
+               i_debug("PID=%s", my_pid);
+
+       i_sleep_intr_msecs(100); /* wait a little for server setup */
+
+       ioloop = io_loop_create();
+       if (client_test())
+               io_loop_run(ioloop);
+       test_client_deinit();
+       io_loop_destroy(&ioloop);
+}
+
 static void
 test_run_client_server(test_client_init_t *client_test,
                       test_server_init_t *server_test)
@@ -914,15 +944,10 @@ test_run_client_server(test_client_init_t *client_test,
                                io_loop_destroy(&ioloop);
                        }
                        lib_signals_deinit();
+
                        /* child: server */
-                       i_set_failure_prefix("SERVER: ");
-                       if (debug)
-                               i_debug("PID=%s", my_pid);
-                       ioloop = io_loop_create();
-                       server_test();
-                       io_loop_destroy(&ioloop);
-                       if (fd_listen != -1)
-                               i_close_fd(&fd_listen);
+                       test_run_server(server_test);
+
                        /* wait for it to be killed; this way, valgrind will not
                           object to this process going away inelegantly. */
                        i_sleep_intr_secs(60);
@@ -935,17 +960,7 @@ test_run_client_server(test_client_init_t *client_test,
        }
 
        /* parent: client */
-       i_set_failure_prefix("CLIENT: ");
-       if (debug)
-               i_debug("PID=%s", my_pid);
-
-       i_sleep_intr_msecs(100); /* wait a little for server setup */
-
-       ioloop = io_loop_create();
-       if (client_test())
-               io_loop_run(ioloop);
-       test_client_deinit();
-       io_loop_destroy(&ioloop);
+       test_run_client(client_test);
 
        i_unset_failure_prefix();
        test_server_kill_forced();