From: Stephan Bosch Date: Thu, 14 Feb 2019 22:20:13 +0000 (+0100) Subject: master: test-auth-client - Add progress timeout. X-Git-Tag: 2.3.9~828 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbd53af22a84d35fa7ad6301719c3e9523a3349f;p=thirdparty%2Fdovecot%2Fcore.git master: test-auth-client - Add progress timeout. --- diff --git a/src/master/test-auth-client.c b/src/master/test-auth-client.c index 240e116e3a..c61bd76f1b 100644 --- a/src/master/test-auth-client.c +++ b/src/master/test-auth-client.c @@ -28,6 +28,7 @@ #include #define TEST_SOCKET "./auth-client-test" +#define CLIENT_PROGRESS_TIMEOUT 30 /* * Types @@ -685,6 +686,8 @@ static void (*const test_functions[])(void) = { * Test client */ +struct timeout *to_client_progress = NULL; + static void test_client_deinit(void) { } @@ -710,6 +713,9 @@ test_client_auth_callback(struct auth_client_request *request, string_t *resp_b64; const char *errormsg = NULL; + if (to_client_progress != NULL) + timeout_reset(to_client_progress); + switch (status) { case AUTH_REQUEST_STATUS_ABORT: errormsg = "Abort"; @@ -751,6 +757,9 @@ test_client_auth_connected(struct auth_client *client ATTR_UNUSED, { struct login_request *login_req = context; + if (to_client_progress != NULL) + timeout_reset(to_client_progress); + if (login_req->status == 0 && !connected) { i_assert(login_req->error == NULL); login_req->error = i_strdup("Connection failed"); @@ -759,6 +768,15 @@ test_client_auth_connected(struct auth_client *client ATTR_UNUSED, io_loop_stop(login_req->ioloop); } +static void +test_client_progress_timeout(void *context ATTR_UNUSED) +{ + /* Terminate test due to lack of progress */ + test_assert(FALSE); + timeout_remove(&to_client_progress); + io_loop_stop(current_ioloop); +} + static int test_client_auth_simple(const char *mech, const char *username, const char *password, const char **error_r) @@ -810,6 +828,9 @@ test_client_auth_simple(const char *mech, const char *username, login_req.username = username; login_req.password = password; + to_client_progress = timeout_add(CLIENT_PROGRESS_TIMEOUT*1000, + test_client_progress_timeout, NULL); + auth_client = auth_client_init(TEST_SOCKET, 2234, debug); auth_client_set_connect_timeout(auth_client, 1000); auth_client_connect(auth_client); @@ -835,6 +856,7 @@ test_client_auth_simple(const char *mech, const char *username, *error_r = t_strdup(login_req.error); auth_client_deinit(&auth_client); + timeout_remove(&to_client_progress); io_loop_destroy(&ioloop); i_free(login_req.error);