#include "testutil.h"
#include "memdebug.h"
-#undef TEST_HANG_TIMEOUT
-#define TEST_HANG_TIMEOUT 30 * 1000
-
static CURLcode test_lib1501(char *URL)
{
+ static const long HANG_TIMEOUT = 30 * 1000;
/* 500 milliseconds allowed. An extreme number but lets be really
conservative to allow old and slow machines to run this test too */
static const int MAX_BLOCKED_TIME_MS = 500;
multi_perform(mhandle, &still_running);
- abort_on_test_timeout();
+ abort_on_test_timeout_custom(HANG_TIMEOUT);
while(still_running) {
struct timeval timeout;
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
- abort_on_test_timeout();
+ abort_on_test_timeout_custom(HANG_TIMEOUT);
curl_mfprintf(stderr, "ping\n");
before = tutil_tvnow();
multi_perform(mhandle, &still_running);
- abort_on_test_timeout();
+ abort_on_test_timeout_custom(HANG_TIMEOUT);
after = tutil_tvnow();
e = tutil_tvdiff(after, before);
tv_test_start = tutil_tvnow(); \
} while(0)
-#define exe_test_timedout(Y,Z) do { \
+#define TEST_HANG_TIMEOUT 60 * 1000 /* global default */
+
+#define exe_test_timedout(T,Y,Z) do { \
long timediff = tutil_tvdiff(tutil_tvnow(), tv_test_start); \
- if(timediff > (TEST_HANG_TIMEOUT)) { \
+ if(timediff > (T)) { \
curl_mfprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
"that it would have run forever (%ld ms > %ld ms)\n", \
(Y), (Z), timediff, (long) (TEST_HANG_TIMEOUT)); \
} while(0)
#define res_test_timedout() \
- exe_test_timedout((__FILE__), (__LINE__))
+ exe_test_timedout(TEST_HANG_TIMEOUT, (__FILE__), (__LINE__))
+
+#define res_test_timedout_custom(T) \
+ exe_test_timedout((T), (__FILE__), (__LINE__))
-#define chk_test_timedout(Y, Z) do { \
- exe_test_timedout(Y, Z); \
- if(res) \
- goto test_cleanup; \
+#define chk_test_timedout(T, Y, Z) do { \
+ exe_test_timedout(T, Y, Z); \
+ if(res) \
+ goto test_cleanup; \
} while(0)
#define abort_on_test_timeout() \
- chk_test_timedout((__FILE__), (__LINE__))
+ chk_test_timedout(TEST_HANG_TIMEOUT, (__FILE__), (__LINE__))
+
+#define abort_on_test_timeout_custom(T) \
+ chk_test_timedout((T), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */
return CURLE_UNSUPPORTED_PROTOCOL; \
}
-/* global default */
-#define NUM_HANDLES 4
+#define NUM_HANDLES 4 /* global default */
/* ---------------------------------------------------------------- */
#endif /* HEADER_CURL_TEST_H */
-
-/* Set default that each test may override */
-#undef TEST_HANG_TIMEOUT
-#define TEST_HANG_TIMEOUT 60 * 1000