From: Yang Tse Date: Wed, 26 Oct 2011 16:46:32 +0000 (+0200) Subject: multi tests: OOM handling fixes - commit 629d2e34 follow-up X-Git-Tag: upstream/7.37.1~3546 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51e5a2bf3fc4b555e118ecede183d7e3d8e4fb88;p=platform%2Fupstream%2Fcurl.git multi tests: OOM handling fixes - commit 629d2e34 follow-up --- diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 21d1487..a47f1de 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -136,6 +136,8 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd, if(res) return res; + /* At this point, L is guaranteed to be greater or equal than -1. */ + if(L != -1) { T.tv_sec = L/1000; T.tv_usec = (L%1000)*1000; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 81c435d..34b8c9f 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -95,6 +95,7 @@ extern int unitfail; #define TEST_ERR_USAGE 118 #define TEST_ERR_FOPEN 117 #define TEST_ERR_FSTAT 116 +#define TEST_ERR_BAD_TIMEOUT 115 /* ** Macros for test source code readability/maintainability. @@ -301,14 +302,20 @@ extern int unitfail; /* ---------------------------------------------------------------- */ -#define exe_multi_timeout(A,B,Y,Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_timeout((A),(B))) != CURLM_OK) { \ - fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ - res = (int)ec; \ - } \ +#define exe_multi_timeout(A,B,Y,Z) do { \ + CURLMcode ec; \ + if((ec = curl_multi_timeout((A),(B))) != CURLM_OK) { \ + fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ + res = (int)ec; \ + } \ + else if(*((B)) < -1L) { \ + fprintf(stderr, "%s:%d curl_multi_timeout() succeeded, " \ + "but returned invalid timeout value (%ld)\n", \ + (Y), (Z), (long)*((B))); \ + res = TEST_ERR_BAD_TIMEOUT; \ + } \ } WHILE_FALSE #define res_multi_timeout(A,B) \