]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: Adjust test timeouts based on valgrind runtime presence
authorMarco Bettini <marco.bettini@open-xchange.com>
Fri, 18 Feb 2022 15:26:29 +0000 (16:26 +0100)
committerMarco Bettini <marco.bettini@open-xchange.com>
Mon, 28 Feb 2022 13:45:36 +0000 (13:45 +0000)
configure.ac
src/lib-smtp/test-smtp-payload.c
src/lib-smtp/test-smtp-server-errors.c
src/lib-test/test-common.h

index 93f864044406bdb64c52eddcdcc1f9185a480458..7d9e96516cae1c39f499d7bee7471d7b8da6cb04 100644 (file)
@@ -337,6 +337,8 @@ AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
               malloc_usable_size glob fallocate posix_fadvise \
               getpeereid getpeerucred inotify_init timegm)
 
+AC_CHECK_HEADERS([valgrind/valgrind.h])
+
 DOVECOT_SOCKPEERCRED
 DOVECOT_CLOCK_GETTIME
 
index 7363736cc4197a8a042f9fff28babafe40ee7800..0ad87733fc8f2d53066fe92f8550cc91e2045917 100644 (file)
 #include <unistd.h>
 #include <dirent.h>
 
-#define CLIENT_PROGRESS_TIMEOUT     60
-#define SERVER_KILL_TIMEOUT_SECS    20
-#define MAX_PARALLEL_PENDING        200
+#define VALGRIND_TIMEOUT_MULTIPLIER (ON_VALGRIND ? 5 : 1)
+
+#define CLIENT_PROGRESS_TIMEOUT_MSECS (60 * VALGRIND_TIMEOUT_MULTIPLIER * 1000)
+#define SERVER_KILL_TIMEOUT_SECS      (20 * VALGRIND_TIMEOUT_MULTIPLIER)
+#define MAX_PARALLEL_PENDING          200
 
 static bool debug = FALSE;
 static bool small_socket_buffers = FALSE;
@@ -812,7 +814,7 @@ test_client(enum smtp_protocol protocol,
 
        if (!small_socket_buffers) {
                to_client_progress = timeout_add(
-                       CLIENT_PROGRESS_TIMEOUT*1000,
+                       CLIENT_PROGRESS_TIMEOUT_MSECS,
                        test_client_progress_timeout, NULL);
        }
 
@@ -963,8 +965,7 @@ test_run_scenarios(
        smtp_server_set.protocol = protocol;
        smtp_server_set.capabilities = capabilities;
        smtp_server_set.hostname = "localhost";
-       smtp_server_set.max_client_idle_time_msecs =
-               CLIENT_PROGRESS_TIMEOUT*1000;
+       smtp_server_set.max_client_idle_time_msecs = CLIENT_PROGRESS_TIMEOUT_MSECS;
        smtp_server_set.max_pipelined_commands = 1;
        smtp_server_set.auth_optional = TRUE;
        smtp_server_set.ssl = &ssl_server_set;
@@ -974,8 +975,8 @@ test_run_scenarios(
        i_zero(&smtp_client_set);
        smtp_client_set.my_hostname = "localhost";
        smtp_client_set.temp_path_prefix = "/tmp";
-       smtp_client_set.command_timeout_msecs = CLIENT_PROGRESS_TIMEOUT*1000;
-       smtp_client_set.connect_timeout_msecs = CLIENT_PROGRESS_TIMEOUT*1000;
+       smtp_client_set.command_timeout_msecs = CLIENT_PROGRESS_TIMEOUT_MSECS;
+       smtp_client_set.connect_timeout_msecs = CLIENT_PROGRESS_TIMEOUT_MSECS;
        smtp_client_set.ssl = &ssl_client_set;
        smtp_client_set.debug = debug;
 
index a28c037dd7b137b791d7116cd86a26058b1b8357..b944a3968dadca6367d82341f730b33fae98b18e 100644 (file)
 
 #include <unistd.h>
 
-#define SERVER_MAX_TIMEOUT_MSECS 10*1000
-#define CLIENT_KILL_TIMEOUT_SECS 20
+#define VALGRIND_TIMEOUT_MULTIPLIER (ON_VALGRIND ? 5 : 1)
+
+#define SERVER_MAX_TIMEOUT_MSECS (10 * VALGRIND_TIMEOUT_MULTIPLIER * 1000)
+#define CLIENT_KILL_TIMEOUT_SECS (20 * VALGRIND_TIMEOUT_MULTIPLIER)
 
 static void main_deinit(void);
 
index f845c0d58537e1bde1d7a9476fb42384eb922c4d..305586448a5785003b6b5fc5fd6ebf142eaeb925 100644 (file)
@@ -1,6 +1,13 @@
 #ifndef TEST_COMMON_H
 #define TEST_COMMON_H
 
+#ifdef HAVE_VALGRIND_VALGRIND_H
+#  include <valgrind/valgrind.h>
+#  define ON_VALGRIND ((bool) RUNNING_ON_VALGRIND)
+#else
+#  define ON_VALGRIND FALSE
+#endif
+
 struct istream *test_istream_create(const char *data);
 struct istream *test_istream_create_data(const void *data, size_t size);
 void test_istream_set_size(struct istream *input, uoff_t size);