From ead6ab2ef765ec8c917ba8f5424d72a6624b0b20 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 17:29:25 +0000 Subject: Abort test if it seems that it would have run forever. This is just to prevent test hanging and actually is an indication that there's a condition that is not being properly handled at some point in the library. Loop counter limits might need to be further increased on false positives. --- tests/libtest/lib525.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tests/libtest/lib525.c') diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 9dcddaecf..b5b522de1 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -24,6 +24,8 @@ int test(char *URL) int running; char done=FALSE; CURLM *m; + int loop1 = 40; + int loop2 = 20; if (!arg2) { fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); @@ -82,22 +84,23 @@ int test(char *URL) res = (int)curl_multi_add_handle(m, curl); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = (int)curl_multi_perform(m, &running); if (running <= 0) { done = TRUE; break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -125,6 +128,12 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + res = 77; + } + #ifdef LIB529 /* test 529 */ curl_multi_remove_handle(m, curl); -- cgit v1.2.3