From: Viktor Szakats Date: Tue, 27 May 2025 19:20:36 +0000 (+0200) Subject: tests: drop mk-bundle exceptions X-Git-Tag: curl-8_15_0~301 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6897aeb10561b55c6659866fc0518dd67422f267;p=thirdparty%2Fcurl.git tests: drop mk-bundle exceptions Using a mixture of techniques to avoid symbols collisions: - reduce scope. - add `t*_` / `T*_` prefix. - move shared functions to `testutil.c`. (`suburl()`, `rlim2str()`) - clone re-used lib*.c sources. (lib587, lib645) - include shared symbols just once in re-used `lib*.c` sources. (using `LIB*_C` guards.) - drop re-used `lib*.c` sources where they were identical or unused. - make macros global. - #undef macros before use. What remain is the entry functions `test`, and `unit_setup`, `unit_stop` in unit tests. Also: - fix formatting and other minor things along the way. - add `const` where possible. - sync some symbol names between tests. - drop `mk-bundle-hints.sh` that's no longer necessary. Closes #17468 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 2c8b1b30d2..3315090e2c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -62,7 +62,6 @@ EXTRA_DIST = \ http2-server.pl \ http3-server.pl \ memanalyze.pl \ - mk-bundle-hints.sh \ mk-bundle.pl \ negtelnetserver.py \ nghttpx.conf \ diff --git a/tests/data/test1596 b/tests/data/test1596 index 8b94cd12fa..5778e76b78 100644 --- a/tests/data/test1596 +++ b/tests/data/test1596 @@ -28,7 +28,7 @@ http HTTP Retry-After header parsing using a date -lib%TESTNUMBER +lib1594 http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index d130d5158d..293b0f0970 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -63,8 +63,8 @@ LIBTESTPROGS = libauthretry libntlmconnect libprereq \ lib1540 lib1541 lib1542 lib1543 lib1545 \ lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \ lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 lib1571 \ - lib1576 lib1578 \ - lib1591 lib1592 lib1593 lib1594 lib1596 lib1597 lib1598 \ + lib1576 \ + lib1591 lib1592 lib1593 lib1594 lib1597 lib1598 \ \ lib1662 \ \ @@ -107,7 +107,8 @@ lib504_LDADD = $(TESTUTIL_LIBS) lib505_SOURCES = lib505.c $(SUPPORTFILES) $(MULTIBYTE) -lib506_SOURCES = lib506.c $(SUPPORTFILES) +lib506_SOURCES = lib506.c $(SUPPORTFILES) $(TESTUTIL) +lib506_LDADD = $(TESTUTIL_LIBS) lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib507_LDADD = $(TESTUTIL_LIBS) @@ -132,7 +133,8 @@ lib516_SOURCES = lib516.c $(SUPPORTFILES) lib517_SOURCES = lib517.c $(SUPPORTFILES) -lib518_SOURCES = lib518.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE) +lib518_SOURCES = lib518.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE) +lib518_LDADD = $(TESTUTIL_LIBS) lib519_SOURCES = lib519.c $(SUPPORTFILES) @@ -171,7 +173,8 @@ lib533_LDADD = $(TESTUTIL_LIBS) lib536_SOURCES = lib536.c $(SUPPORTFILES) -lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE) +lib537_SOURCES = lib537.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE) +lib537_LDADD = $(TESTUTIL_LIBS) lib539_SOURCES = lib539.c $(SUPPORTFILES) @@ -228,15 +231,20 @@ lib566_SOURCES = lib566.c $(SUPPORTFILES) $(MULTIBYTE) lib567_SOURCES = lib567.c $(SUPPORTFILES) -lib568_SOURCES = lib568.c $(SUPPORTFILES) $(MULTIBYTE) +lib568_SOURCES = lib568.c $(SUPPORTFILES) $(TESTUTIL) $(MULTIBYTE) +lib568_LDADD = $(TESTUTIL_LIBS) -lib569_SOURCES = lib569.c $(SUPPORTFILES) $(MULTIBYTE) +lib569_SOURCES = lib569.c $(SUPPORTFILES) $(TESTUTIL) $(MULTIBYTE) +lib569_LDADD = $(TESTUTIL_LIBS) -lib570_SOURCES = lib570.c $(SUPPORTFILES) +lib570_SOURCES = lib570.c $(SUPPORTFILES) $(TESTUTIL) +lib570_LDADD = $(TESTUTIL_LIBS) -lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE) +lib571_SOURCES = lib571.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE) +lib571_LDADD = $(TESTUTIL_LIBS) -lib572_SOURCES = lib572.c $(SUPPORTFILES) $(MULTIBYTE) +lib572_SOURCES = lib572.c $(SUPPORTFILES) $(TESTUTIL) $(MULTIBYTE) +lib572_LDADD = $(TESTUTIL_LIBS) lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE) lib573_LDADD = $(TESTUTIL_LIBS) @@ -266,8 +274,7 @@ lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 lib586_SOURCES = lib586.c $(SUPPORTFILES) -lib587_SOURCES = lib554.c $(SUPPORTFILES) -lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 +lib587_SOURCES = lib587.c $(SUPPORTFILES) lib589_SOURCES = lib589.c $(SUPPORTFILES) @@ -285,8 +292,7 @@ lib599_SOURCES = lib599.c $(SUPPORTFILES) $(MULTIBYTE) lib643_SOURCES = lib643.c $(SUPPORTFILES) -lib645_SOURCES = lib643.c $(SUPPORTFILES) -lib645_CPPFLAGS = $(AM_CPPFLAGS) -DLIB645 +lib645_SOURCES = lib645.c $(SUPPORTFILES) lib650_SOURCES = lib650.c $(SUPPORTFILES) @@ -538,9 +544,6 @@ lib1571_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1571 lib1576_SOURCES = lib1576.c $(SUPPORTFILES) -lib1578_SOURCES = lib1576.c $(SUPPORTFILES) -lib1578_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1578 - lib1591_SOURCES = lib1591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1591_LDADD = $(TESTUTIL_LIBS) @@ -553,10 +556,6 @@ lib1593_LDADD = $(TESTUTIL_LIBS) lib1594_SOURCES = lib1594.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1594_LDADD = $(TESTUTIL_LIBS) -lib1596_SOURCES = lib1594.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib1596_LDADD = $(TESTUTIL_LIBS) -lib1596_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1596 - lib1597_SOURCES = lib1597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1597_LDADD = $(TESTUTIL_LIBS) diff --git a/tests/libtest/lib1485.c b/tests/libtest/lib1485.c index 71678563f2..c980dfb75c 100644 --- a/tests/libtest/lib1485.c +++ b/tests/libtest/lib1485.c @@ -27,7 +27,7 @@ #include "warnless.h" #include "memdebug.h" -struct transfer_status { +struct t1485_transfer_status { CURL *easy; curl_off_t out_len; size_t hd_line; @@ -35,10 +35,10 @@ struct transfer_status { int http_status; }; -static size_t header_callback(char *ptr, size_t size, size_t nmemb, - void *userp) +static size_t t1485_header_callback(char *ptr, size_t size, size_t nmemb, + void *userp) { - struct transfer_status *st = (struct transfer_status *)userp; + struct t1485_transfer_status *st = (struct t1485_transfer_status *)userp; const char *hd = ptr; size_t len = size * nmemb; CURLcode result; @@ -78,9 +78,9 @@ static size_t header_callback(char *ptr, size_t size, size_t nmemb, return len; } -static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1485_write_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct transfer_status *st = (struct transfer_status *)userp; + struct t1485_transfer_status *st = (struct t1485_transfer_status *)userp; size_t len = size * nmemb; fwrite(ptr, size, nmemb, stdout); st->out_len += (curl_off_t)len; @@ -91,7 +91,7 @@ CURLcode test(char *URL) { CURL *curls = NULL; CURLcode res = CURLE_OK; - struct transfer_status st; + struct t1485_transfer_status st; start_test_timing(); @@ -103,9 +103,9 @@ CURLcode test(char *URL) st.easy = curls; /* to allow callbacks access */ easy_setopt(curls, CURLOPT_URL, URL); - easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback); + easy_setopt(curls, CURLOPT_WRITEFUNCTION, t1485_write_cb); easy_setopt(curls, CURLOPT_WRITEDATA, &st); - easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback); + easy_setopt(curls, CURLOPT_HEADERFUNCTION, t1485_header_callback); easy_setopt(curls, CURLOPT_HEADERDATA, &st); easy_setopt(curls, CURLOPT_NOPROGRESS, 1L); diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c index b5944ef313..f72b2dd720 100644 --- a/tests/libtest/lib1500.c +++ b/tests/libtest/lib1500.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *curls = NULL; diff --git a/tests/libtest/lib1501.c b/tests/libtest/lib1501.c index 2194127ed5..0644b83748 100644 --- a/tests/libtest/lib1501.c +++ b/tests/libtest/lib1501.c @@ -29,6 +29,7 @@ #include "warnless.h" #include "memdebug.h" +#undef TEST_HANG_TIMEOUT #define TEST_HANG_TIMEOUT 30 * 1000 /* 500 milliseconds allowed. An extreme number but lets be really conservative diff --git a/tests/libtest/lib1502.c b/tests/libtest/lib1502.c index cb7a8c2ae6..b4f56407f5 100644 --- a/tests/libtest/lib1502.c +++ b/tests/libtest/lib1502.c @@ -37,8 +37,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *easy = NULL; diff --git a/tests/libtest/lib1506.c b/tests/libtest/lib1506.c index d7e4cb0d62..0a4507a211 100644 --- a/tests/libtest/lib1506.c +++ b/tests/libtest/lib1506.c @@ -27,10 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -#define NUM_HANDLES 4 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1507.c b/tests/libtest/lib1507.c index 7525ec5342..f2f25f057a 100644 --- a/tests/libtest/lib1507.c +++ b/tests/libtest/lib1507.c @@ -38,7 +38,7 @@ #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1507_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { (void)ptr; (void)size; @@ -73,7 +73,7 @@ CURLcode test(char *URL) curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD); #endif curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, t1507_read_cb); curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM); curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib1510.c b/tests/libtest/lib1510.c index d039b7b0e3..ec4c0baba3 100644 --- a/tests/libtest/lib1510.c +++ b/tests/libtest/lib1510.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - #define NUM_URLS 4 CURLcode test(char *URL) @@ -73,7 +71,7 @@ CURLcode test(char *URL) easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L); - /* get NUM_HANDLES easy handles */ + /* get NUM_URLS easy handles */ for(i = 0; i < NUM_URLS; i++) { /* specify target */ curl_msnprintf(target_url, sizeof(target_url), diff --git a/tests/libtest/lib1512.c b/tests/libtest/lib1512.c index 02b2e8cac5..763694837d 100644 --- a/tests/libtest/lib1512.c +++ b/tests/libtest/lib1512.c @@ -32,6 +32,7 @@ #include "memdebug.h" +#undef NUM_HANDLES #define NUM_HANDLES 2 CURLcode test(char *URL) diff --git a/tests/libtest/lib1514.c b/tests/libtest/lib1514.c index 6b4e18bac0..9596fb7685 100644 --- a/tests/libtest/lib1514.c +++ b/tests/libtest/lib1514.c @@ -30,16 +30,16 @@ #include "memdebug.h" -static char testdata[]="dummy"; - -struct WriteThis { +#ifndef LIB1514_C +#define LIB1514_C +struct t1514_WriteThis { char *readptr; size_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1514_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t1514_WriteThis *pooh = (struct t1514_WriteThis *)userp; if(size*nmemb < 1) return 0; @@ -53,13 +53,17 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) return 0; /* no more data left to deliver */ } +#endif CURLcode test(char *URL) { CURL *curl; CURLcode result = CURLE_OK; CURLcode res = CURLE_OK; - struct WriteThis pooh = { testdata, sizeof(testdata)-1 }; + + static char testdata[] = "dummy"; + + struct t1514_WriteThis pooh = { testdata, sizeof(testdata)-1 }; global_init(CURL_GLOBAL_ALL); @@ -68,7 +72,7 @@ CURLcode test(char *URL) easy_setopt(curl, CURLOPT_URL, URL); easy_setopt(curl, CURLOPT_POST, 1L); /* Purposely omit to set CURLOPT_POSTFIELDSIZE */ - easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + easy_setopt(curl, CURLOPT_READFUNCTION, t1514_read_cb); easy_setopt(curl, CURLOPT_READDATA, &pooh); #ifdef LIB1539 /* speak HTTP 1.0 - no chunked! */ diff --git a/tests/libtest/lib1515.c b/tests/libtest/lib1515.c index 6c07c7901b..fda322e604 100644 --- a/tests/libtest/lib1515.c +++ b/tests/libtest/lib1515.c @@ -34,8 +34,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - #define DNS_TIMEOUT 1L static CURLcode do_one_request(CURLM *m, char *URL, char *resolve) diff --git a/tests/libtest/lib1517.c b/tests/libtest/lib1517.c index 3ae6c03c4d..7d9e39dc1d 100644 --- a/tests/libtest/lib1517.c +++ b/tests/libtest/lib1517.c @@ -25,16 +25,14 @@ #include "memdebug.h" -static char testdata[]="this is what we post to the silly web server\n"; - -struct WriteThis { - char *readptr; +struct t1517_WriteThis { + const char *readptr; size_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1517_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t1517_WriteThis *pooh = (struct t1517_WriteThis *)userp; size_t tocopy = size * nmemb; /* Wait one second before return POST data * @@ -55,10 +53,13 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) CURLcode test(char *URL) { + static const char testdata[] = + "this is what we post to the silly web server\n"; + CURL *curl; CURLcode res = CURLE_OK; - struct WriteThis pooh; + struct t1517_WriteThis pooh; if(!strcmp(URL, "check")) { #if (defined(_WIN32) || defined(__CYGWIN__)) @@ -96,7 +97,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1517_read_cb); /* pointer to pass to our read function */ test_setopt(curl, CURLOPT_READDATA, &pooh); diff --git a/tests/libtest/lib1518.c b/tests/libtest/lib1518.c index 928462e0a0..2278d1f4c0 100644 --- a/tests/libtest/lib1518.c +++ b/tests/libtest/lib1518.c @@ -27,8 +27,10 @@ /* Test inspired by github issue 3340 */ -static size_t writecb(char *buffer, size_t size, size_t nitems, - void *outstream) +#ifndef LIB1518_C +#define LIB1518_C +static size_t t1518_write_cb(char *buffer, size_t size, size_t nitems, + void *outstream) { (void)buffer; (void)size; @@ -36,6 +38,7 @@ static size_t writecb(char *buffer, size_t size, size_t nitems, (void)outstream; return 0; } +#endif CURLcode test(char *URL) { @@ -83,7 +86,7 @@ CURLcode test(char *URL) curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &curlRedirectCount); curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effectiveUrl); curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectUrl); - test_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); + test_setopt(curl, CURLOPT_WRITEFUNCTION, t1518_write_cb); curl_mprintf("res %d\n" "status %ld\n" diff --git a/tests/libtest/lib1520.c b/tests/libtest/lib1520.c index f9070945ca..9eb2840228 100644 --- a/tests/libtest/lib1520.c +++ b/tests/libtest/lib1520.c @@ -31,26 +31,26 @@ #define TO "" #define FROM "" -static const char *payload_text[] = { - "From: different\r\n", - "To: another\r\n", - "\r\n", - "\r\n", - ".\r\n", - ".\r\n", - "\r\n", - ".\r\n", - "\r\n", - "body", - NULL -}; - struct upload_status { int lines_read; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1520_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { + static const char *payload_text[] = { + "From: different\r\n", + "To: another\r\n", + "\r\n", + "\r\n", + ".\r\n", + ".\r\n", + "\r\n", + ".\r\n", + "\r\n", + "body", + NULL + }; + struct upload_status *upload_ctx = (struct upload_status *)userp; const char *data; @@ -97,7 +97,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1520_read_cb); test_setopt(curl, CURLOPT_READDATA, &upload_ctx); test_setopt(curl, CURLOPT_MAIL_FROM, FROM); test_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list); diff --git a/tests/libtest/lib1522.c b/tests/libtest/lib1522.c index 1c0d945293..6d3b8d5ea9 100644 --- a/tests/libtest/lib1522.c +++ b/tests/libtest/lib1522.c @@ -30,8 +30,6 @@ #include "warnless.h" #include "memdebug.h" -static char g_Data[40 * 1024]; /* POST 40KB */ - static int sockopt_callback(void *clientp, curl_socket_t curlfd, curlsocktype purpose) { @@ -51,6 +49,8 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd, CURLcode test(char *URL) { + static char g_Data[40 * 1024]; /* POST 40KB */ + CURLcode code = TEST_ERR_MAJOR_BAD; CURLcode res; struct curl_slist *pHeaderList = NULL; diff --git a/tests/libtest/lib1523.c b/tests/libtest/lib1523.c index 80e01aea6d..e26db4d1ef 100644 --- a/tests/libtest/lib1523.c +++ b/tests/libtest/lib1523.c @@ -40,7 +40,7 @@ static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c, return 0; } -static size_t write_cb(char *d, size_t n, size_t l, void *p) +static size_t t1523_write_cb(char *d, size_t n, size_t l, void *p) { /* take care of the data here, ignored in this example */ (void)d; @@ -63,7 +63,7 @@ CURLcode test(char *URL) curl_global_init(CURL_GLOBAL_ALL); hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_URL, URL); - curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_cb); + curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, t1523_write_cb); curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, buffer); curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(hnd, CURLOPT_XFERINFOFUNCTION, dload_progress_cb); diff --git a/tests/libtest/lib1525.c b/tests/libtest/lib1525.c index 481384320f..7802293a5c 100644 --- a/tests/libtest/lib1525.c +++ b/tests/libtest/lib1525.c @@ -32,20 +32,19 @@ #include "memdebug.h" -static char testdata[] = "Hello Cloud!\n"; +static const char t1525_testdata[] = "Hello Cloud!\n"; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(testdata)) { - return strlen(testdata); + if(amount < strlen(t1525_testdata)) { + return strlen(t1525_testdata); } (void)stream; - memcpy(ptr, testdata, strlen(testdata)); - return strlen(testdata); + memcpy(ptr, t1525_testdata, strlen(t1525_testdata)); + return strlen(t1525_testdata); } - CURLcode test(char *URL) { CURL *curl = NULL; @@ -82,9 +81,9 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTP); test_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1525_read_cb); test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1525_testdata)); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib1526.c b/tests/libtest/lib1526.c index cf6ca1e429..487b2818fd 100644 --- a/tests/libtest/lib1526.c +++ b/tests/libtest/lib1526.c @@ -31,17 +31,17 @@ #include "memdebug.h" -static char testdata[] = "Hello Cloud!\n"; +static const char t1526_testdata[] = "Hello Cloud!\n"; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(testdata)) { - return strlen(testdata); + if(amount < strlen(t1526_testdata)) { + return strlen(t1526_testdata); } (void)stream; - memcpy(ptr, testdata, strlen(testdata)); - return strlen(testdata); + memcpy(ptr, t1526_testdata, strlen(t1526_testdata)); + return strlen(t1526_testdata); } CURLcode test(char *URL) @@ -85,9 +85,9 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTP); test_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1526_read_cb); test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1526_testdata)); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib1527.c b/tests/libtest/lib1527.c index aa5aa286ab..cc7151058a 100644 --- a/tests/libtest/lib1527.c +++ b/tests/libtest/lib1527.c @@ -31,20 +31,19 @@ #include "memdebug.h" -static char testdata[] = "Hello Cloud!\n"; +static const char t1527_testdata[] = "Hello Cloud!\n"; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(testdata)) { - return strlen(testdata); + if(amount < strlen(t1527_testdata)) { + return strlen(t1527_testdata); } (void)stream; - memcpy(ptr, testdata, strlen(testdata)); - return strlen(testdata); + memcpy(ptr, t1527_testdata, strlen(t1527_testdata)); + return strlen(t1527_testdata); } - CURLcode test(char *URL) { CURL *curl = NULL; @@ -83,9 +82,9 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_HTTP); test_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1527_read_cb); test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata)); + test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1527_testdata)); test_setopt(curl, CURLOPT_HEADEROPT, (long)CURLHEADER_UNIFIED); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib1531.c b/tests/libtest/lib1531.c index 1155296fcc..a33b9c4093 100644 --- a/tests/libtest/lib1531.c +++ b/tests/libtest/lib1531.c @@ -28,13 +28,11 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -static char const testData[] = ".abc\0xyz"; -static curl_off_t const testDataSize = sizeof(testData) - 1; - CURLcode test(char *URL) { + static char const testData[] = ".abc\0xyz"; + static curl_off_t const testDataSize = sizeof(testData) - 1; + CURL *easy; CURLM *multi_handle; int still_running; /* keep number of running handles */ diff --git a/tests/libtest/lib1533.c b/tests/libtest/lib1533.c index 68fdb2b6d2..620405f04c 100644 --- a/tests/libtest/lib1533.c +++ b/tests/libtest/lib1533.c @@ -40,7 +40,6 @@ struct cb_data { size_t remaining_bytes; }; - static void reset_data(struct cb_data *data, CURL *curl) { data->easy_handle = curl; @@ -49,11 +48,9 @@ static void reset_data(struct cb_data *data, CURL *curl) data->remaining_bytes = 3; } - -static size_t read_callback(char *ptr, size_t size, size_t nitems, - void *userdata) +static size_t t1533_read_cb(char *ptr, size_t size, size_t nitems, void *userp) { - struct cb_data *data = (struct cb_data *)userdata; + struct cb_data *data = (struct cb_data *)userp; /* wait until the server has sent all response headers */ if(data->response_received) { @@ -75,11 +72,9 @@ static size_t read_callback(char *ptr, size_t size, size_t nitems, } } - -static size_t write_callback(char *ptr, size_t size, size_t nmemb, - void *userdata) +static size_t t1533_write_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct cb_data *data = (struct cb_data *)userdata; + struct cb_data *data = (struct cb_data *)userp; size_t totalsize = nmemb * size; /* unused parameter */ @@ -97,7 +92,6 @@ static size_t write_callback(char *ptr, size_t size, size_t nmemb, return totalsize; } - static CURLcode perform_and_check_connections(CURL *curl, const char *description, long expected_connections) @@ -155,9 +149,9 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)data.remaining_bytes); test_setopt(curl, CURLOPT_VERBOSE, 1L); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1533_read_cb); test_setopt(curl, CURLOPT_READDATA, &data); - test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + test_setopt(curl, CURLOPT_WRITEFUNCTION, t1533_write_cb); test_setopt(curl, CURLOPT_WRITEDATA, &data); result = perform_and_check_connections(curl, diff --git a/tests/libtest/lib1540.c b/tests/libtest/lib1540.c index aad97d2af2..35e905c1d9 100644 --- a/tests/libtest/lib1540.c +++ b/tests/libtest/lib1540.c @@ -28,7 +28,7 @@ #include "warnless.h" #include "memdebug.h" -struct transfer_status { +struct t1540_transfer_status { CURL *easy; int halted; int counter; /* count write callback invokes */ @@ -41,7 +41,7 @@ static int please_continue(void *userp, curl_off_t ultotal, curl_off_t ulnow) { - struct transfer_status *st = (struct transfer_status *)userp; + struct t1540_transfer_status *st = (struct t1540_transfer_status *)userp; (void)dltotal; (void)dlnow; (void)ultotal; @@ -57,8 +57,8 @@ static int please_continue(void *userp, return 0; /* go on */ } -static size_t header_callback(char *ptr, size_t size, size_t nmemb, - void *userp) +static size_t t1540_header_callback(char *ptr, size_t size, size_t nmemb, + void *userp) { size_t len = size * nmemb; (void)userp; @@ -66,9 +66,9 @@ static size_t header_callback(char *ptr, size_t size, size_t nmemb, return len; } -static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1540_write_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct transfer_status *st = (struct transfer_status *)userp; + struct t1540_transfer_status *st = (struct t1540_transfer_status *)userp; size_t len = size * nmemb; st->counter++; if(st->counter > 1) { @@ -87,7 +87,7 @@ CURLcode test(char *URL) { CURL *curls = NULL; CURLcode res = CURLE_OK; - struct transfer_status st; + struct t1540_transfer_status st; start_test_timing(); @@ -99,9 +99,9 @@ CURLcode test(char *URL) st.easy = curls; /* to allow callbacks access */ easy_setopt(curls, CURLOPT_URL, URL); - easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback); + easy_setopt(curls, CURLOPT_WRITEFUNCTION, t1540_write_cb); easy_setopt(curls, CURLOPT_WRITEDATA, &st); - easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback); + easy_setopt(curls, CURLOPT_HEADERFUNCTION, t1540_header_callback); easy_setopt(curls, CURLOPT_HEADERDATA, &st); easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, please_continue); diff --git a/tests/libtest/lib1541.c b/tests/libtest/lib1541.c index d09e0e66e7..a228da2867 100644 --- a/tests/libtest/lib1541.c +++ b/tests/libtest/lib1541.c @@ -27,7 +27,7 @@ #include "warnless.h" #include "memdebug.h" -struct transfer_status { +struct t1541_transfer_status { CURL *easy; int hd_count; int bd_count; @@ -36,7 +36,7 @@ struct transfer_status { #define KN(a) a, #a -static int geterr(const char *name, CURLcode val, int lineno) +static int t1541_geterr(const char *name, CURLcode val, int lineno) { curl_mprintf("CURLINFO_%s returned %d, \"%s\" on line %d\n", name, val, curl_easy_strerror(val), lineno); @@ -59,7 +59,7 @@ static void check_time(CURL *easy, int key, const char *name, curl_off_t tval; CURLcode res = curl_easy_getinfo(easy, (CURLINFO)key, &tval); if(res) { - geterr(name, res, __LINE__); + t1541_geterr(name, res, __LINE__); } else report_time(name, where, tval, tval > 0); @@ -71,16 +71,16 @@ static void check_time0(CURL *easy, int key, const char *name, curl_off_t tval; CURLcode res = curl_easy_getinfo(easy, (CURLINFO)key, &tval); if(res) { - geterr(name, res, __LINE__); + t1541_geterr(name, res, __LINE__); } else report_time(name, where, tval, !tval); } -static size_t header_callback(char *ptr, size_t size, size_t nmemb, - void *userp) +static size_t t1541_header_callback(char *ptr, size_t size, size_t nmemb, + void *userp) { - struct transfer_status *st = (struct transfer_status *)userp; + struct t1541_transfer_status *st = (struct t1541_transfer_status *)userp; size_t len = size * nmemb; (void)ptr; @@ -100,9 +100,9 @@ static size_t header_callback(char *ptr, size_t size, size_t nmemb, return len; } -static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1541_write_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct transfer_status *st = (struct transfer_status *)userp; + struct t1541_transfer_status *st = (struct t1541_transfer_status *)userp; (void)ptr; (void)st; @@ -114,7 +114,7 @@ CURLcode test(char *URL) { CURL *curls = NULL; CURLcode res = CURLE_OK; - struct transfer_status st; + struct t1541_transfer_status st; start_test_timing(); @@ -126,9 +126,9 @@ CURLcode test(char *URL) st.easy = curls; /* to allow callbacks access */ easy_setopt(curls, CURLOPT_URL, URL); - easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback); + easy_setopt(curls, CURLOPT_WRITEFUNCTION, t1541_write_cb); easy_setopt(curls, CURLOPT_WRITEDATA, &st); - easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback); + easy_setopt(curls, CURLOPT_HEADERFUNCTION, t1541_header_callback); easy_setopt(curls, CURLOPT_HEADERDATA, &st); easy_setopt(curls, CURLOPT_NOPROGRESS, 0L); diff --git a/tests/libtest/lib1552.c b/tests/libtest/lib1552.c index b61f162ed9..eef9703886 100644 --- a/tests/libtest/lib1552.c +++ b/tests/libtest/lib1552.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *curls = NULL; diff --git a/tests/libtest/lib1553.c b/tests/libtest/lib1553.c index a1c04314ee..e20f18831f 100644 --- a/tests/libtest/lib1553.c +++ b/tests/libtest/lib1553.c @@ -28,11 +28,9 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -static int xferinfo(void *p, - curl_off_t dltotal, curl_off_t dlnow, - curl_off_t ultotal, curl_off_t ulnow) +static int t1553_xferinfo(void *p, + curl_off_t dltotal, curl_off_t dlnow, + curl_off_t ultotal, curl_off_t ulnow) { (void)p; (void)dlnow; @@ -72,7 +70,7 @@ CURLcode test(char *URL) easy_setopt(curls, CURLOPT_VERBOSE, 1L); easy_setopt(curls, CURLOPT_MIMEPOST, mime); easy_setopt(curls, CURLOPT_USERPWD, "u:s"); - easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, xferinfo); + easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, t1553_xferinfo); easy_setopt(curls, CURLOPT_NOPROGRESS, 1L); libtest_debug_config.nohex = 1; diff --git a/tests/libtest/lib1554.c b/tests/libtest/lib1554.c index 4fc408f609..b33d03d9c0 100644 --- a/tests/libtest/lib1554.c +++ b/tests/libtest/lib1554.c @@ -36,8 +36,8 @@ static const char *ldata_names[] = { "NULL", }; -static void test_lock(CURL *handle, curl_lock_data data, - curl_lock_access laccess, void *useptr) +static void t1554_test_lock(CURL *handle, curl_lock_data data, + curl_lock_access laccess, void *useptr) { (void)handle; (void)data; @@ -46,7 +46,7 @@ static void test_lock(CURL *handle, curl_lock_data data, curl_mprintf("-> Mutex lock %s\n", ldata_names[data]); } -static void test_unlock(CURL *handle, curl_lock_data data, void *useptr) +static void t1554_test_unlock(CURL *handle, curl_lock_data data, void *useptr) { (void)handle; (void)data; @@ -70,8 +70,8 @@ CURLcode test(char *URL) } curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); - curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock); - curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock); + curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t1554_test_lock); + curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t1554_test_unlock); /* Loop the transfer and cleanup the handle properly every lap. This will still reuse connections since the pool is in the shared object! */ diff --git a/tests/libtest/lib1555.c b/tests/libtest/lib1555.c index eda2328a33..f66b89c89e 100644 --- a/tests/libtest/lib1555.c +++ b/tests/libtest/lib1555.c @@ -29,7 +29,7 @@ #include "memdebug.h" -static CURL *curl; +static CURL *t1555_curl; static int progressCallback(void *arg, double dltotal, @@ -45,9 +45,9 @@ static int progressCallback(void *arg, (void)dlnow; (void)ultotal; (void)ulnow; - res = curl_easy_recv(curl, buffer, 256, &n); + res = curl_easy_recv(t1555_curl, buffer, 256, &n); curl_mprintf("curl_easy_recv returned %d\n", res); - res = curl_easy_send(curl, buffer, n, &n); + res = curl_easy_send(t1555_curl, buffer, n, &n); curl_mprintf("curl_easy_send returned %d\n", res); return 1; @@ -59,22 +59,22 @@ CURLcode test(char *URL) global_init(CURL_GLOBAL_ALL); - easy_init(curl); + easy_init(t1555_curl); - easy_setopt(curl, CURLOPT_URL, URL); - easy_setopt(curl, CURLOPT_TIMEOUT, (long)7); - easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); - easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback); - easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL); - easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0); + easy_setopt(t1555_curl, CURLOPT_URL, URL); + easy_setopt(t1555_curl, CURLOPT_TIMEOUT, (long)7); + easy_setopt(t1555_curl, CURLOPT_NOSIGNAL, (long)1); + easy_setopt(t1555_curl, CURLOPT_PROGRESSFUNCTION, progressCallback); + easy_setopt(t1555_curl, CURLOPT_PROGRESSDATA, NULL); + easy_setopt(t1555_curl, CURLOPT_NOPROGRESS, (long)0); - res = curl_easy_perform(curl); + res = curl_easy_perform(t1555_curl); test_cleanup: /* undocumented cleanup sequence - type UA */ - curl_easy_cleanup(curl); + curl_easy_cleanup(t1555_curl); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index a0b9baa1bf..af75b89ea8 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -1906,7 +1906,7 @@ static int huge(void) int i; CURLU *urlp = curl_url(); CURLUcode rc; - CURLUPart part[]= { + CURLUPart part[] = { CURLUPART_SCHEME, CURLUPART_USER, CURLUPART_PASSWORD, diff --git a/tests/libtest/lib1564.c b/tests/libtest/lib1564.c index 83c774df70..08a76d74f7 100644 --- a/tests/libtest/lib1564.c +++ b/tests/libtest/lib1564.c @@ -27,7 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 #define WAKEUP_NUM 10 CURLcode test(char *URL) diff --git a/tests/libtest/lib1565.c b/tests/libtest/lib1565.c index d83add8959..992a3dead5 100644 --- a/tests/libtest/lib1565.c +++ b/tests/libtest/lib1565.c @@ -31,19 +31,18 @@ #include #include -#define TEST_HANG_TIMEOUT 60 * 1000 #define CONN_NUM 3 #define TIME_BETWEEN_START_SECS 2 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static CURL *pending_handles[CONN_NUM]; static int pending_num = 0; -static CURLcode test_failure = CURLE_OK; +static CURLcode t1565_test_failure = CURLE_OK; static CURLM *testmulti = NULL; static const char *url; -static void *run_thread(void *ptr) +static void *t1565_run_thread(void *ptr) { CURL *easy = NULL; CURLcode res = CURLE_OK; @@ -61,7 +60,7 @@ static void *run_thread(void *ptr) pthread_mutex_lock(&lock); - if(test_failure) { + if(t1565_test_failure) { pthread_mutex_unlock(&lock); goto test_cleanup; } @@ -81,8 +80,8 @@ test_cleanup: pthread_mutex_lock(&lock); - if(!test_failure) - test_failure = res; + if(!t1565_test_failure) + t1565_test_failure = res; pthread_mutex_unlock(&lock); @@ -111,7 +110,7 @@ CURLcode test(char *URL) url = URL; - result = pthread_create(&tid, NULL, run_thread, NULL); + result = pthread_create(&tid, NULL, t1565_run_thread, NULL); if(!result) tid_valid = true; else { @@ -185,8 +184,8 @@ CURLcode test(char *URL) test_cleanup: pthread_mutex_lock(&lock); - if(!test_failure) - test_failure = res; + if(!t1565_test_failure) + t1565_test_failure = res; pthread_mutex_unlock(&lock); if(tid_valid) @@ -199,7 +198,7 @@ test_cleanup: curl_easy_cleanup(started_handles[i]); curl_global_cleanup(); - return test_failure; + return t1565_test_failure; } #else /* without pthread, this test doesn't work */ diff --git a/tests/libtest/lib1576.c b/tests/libtest/lib1576.c index 279d6fbc97..98a7a6c7b1 100644 --- a/tests/libtest/lib1576.c +++ b/tests/libtest/lib1576.c @@ -25,20 +25,20 @@ #include "memdebug.h" -static char testdata[] = "request indicates that the client, which made"; +static char t1576_testdata[] = "request indicates that the client, which made"; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t1576_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { - size_t amount = nmemb * size; /* Total bytes curl wants */ - if(amount < strlen(testdata)) { - return strlen(testdata); + size_t amount = nmemb * size; /* Total bytes curl wants */ + if(amount < strlen(t1576_testdata)) { + return strlen(t1576_testdata); } (void)stream; - memcpy(ptr, testdata, strlen(testdata)); - return strlen(testdata); + memcpy(ptr, t1576_testdata, strlen(t1576_testdata)); + return strlen(t1576_testdata); } -static int seek_callback(void *ptr, curl_off_t offset, int origin) +static int t1576_seek_callback(void *ptr, curl_off_t offset, int origin) { (void)ptr; (void)offset; @@ -70,9 +70,9 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); - test_setopt(curl, CURLOPT_SEEKFUNCTION, seek_callback); - test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata)); + test_setopt(curl, CURLOPT_READFUNCTION, t1576_read_cb); + test_setopt(curl, CURLOPT_SEEKFUNCTION, t1576_seek_callback); + test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1576_testdata)); test_setopt(curl, CURLOPT_CUSTOMREQUEST, "CURL"); if(testno == 1578) { diff --git a/tests/libtest/lib1591.c b/tests/libtest/lib1591.c index 7d1c012698..ae341aae59 100644 --- a/tests/libtest/lib1591.c +++ b/tests/libtest/lib1591.c @@ -31,18 +31,19 @@ #include #include "memdebug.h" -static char testdata[] = "Hello Cloud!\r\n"; static size_t consumed = 0; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t1591_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { - size_t amount = nmemb * size; /* Total bytes curl wants */ + static const char testdata[] = "Hello Cloud!\r\n"; + + size_t amount = nmemb * size; /* Total bytes curl wants */ if(consumed == strlen(testdata)) { return 0; } - if(amount > strlen(testdata)-consumed) { + if(amount > strlen(testdata) - consumed) { amount = strlen(testdata); } @@ -55,7 +56,7 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) /* * carefully not leak memory on OOM */ -static int trailers_callback(struct curl_slist **list, void *userdata) +static int t1591_trailers_callback(struct curl_slist **list, void *userdata) { struct curl_slist *nlist = NULL; struct curl_slist *nlist2 = NULL; @@ -102,8 +103,8 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_HTTPHEADER, hhl); test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); - test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1591_read_cb); + test_setopt(curl, CURLOPT_TRAILERFUNCTION, t1591_trailers_callback); test_setopt(curl, CURLOPT_TRAILERDATA, NULL); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib1592.c b/tests/libtest/lib1592.c index 99f088d661..efb4254070 100644 --- a/tests/libtest/lib1592.c +++ b/tests/libtest/lib1592.c @@ -32,9 +32,9 @@ /* We're willing to wait a very generous two seconds for the removal. This is as low as we can go while still easily supporting SIGALRM timing for the non-threaded blocking resolver. It doesn't matter that much because when - the test passes, we never wait this long. We set it much higher to avoid - issues when running on overloaded CI machines. */ -#define TEST_HANG_TIMEOUT 60 * 1000 + the test passes, we never wait this long. We set it much higher via + the default TEST_HANG_TIMEOUT to avoid issues when running on overloaded + CI machines. */ #include "test.h" #include "testutil.h" diff --git a/tests/libtest/lib1598.c b/tests/libtest/lib1598.c index e2a3cfeb0a..aba94129c9 100644 --- a/tests/libtest/lib1598.c +++ b/tests/libtest/lib1598.c @@ -34,7 +34,7 @@ /* * carefully not leak memory on OOM */ -static int trailers_callback(struct curl_slist **list, void *userdata) +static int t1598_trailers_callback(struct curl_slist **list, void *userdata) { struct curl_slist *nlist = NULL; struct curl_slist *nlist2 = NULL; @@ -52,10 +52,10 @@ static int trailers_callback(struct curl_slist **list, void *userdata) } } -static const char *post_data = "xxx=yyy&aaa=bbbbb"; - CURLcode test(char *URL) { + static const char *post_data = "xxx=yyy&aaa=bbbbb"; + CURL *curl = NULL; CURLcode res = CURLE_FAILED_INIT; /* http and proxy header list */ @@ -89,7 +89,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_HTTPHEADER, hhl); test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(post_data)); test_setopt(curl, CURLOPT_POSTFIELDS, post_data); - test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback); + test_setopt(curl, CURLOPT_TRAILERFUNCTION, t1598_trailers_callback); test_setopt(curl, CURLOPT_TRAILERDATA, NULL); test_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib1662.c b/tests/libtest/lib1662.c index 1e9e2b0617..6d70de4035 100644 --- a/tests/libtest/lib1662.c +++ b/tests/libtest/lib1662.c @@ -23,15 +23,15 @@ ***************************************************************************/ #include "test.h" -static char testdata[]="mooaaa"; - -struct WriteThis { +struct t1662_WriteThis { size_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t1662_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + static const char testdata[] = "mooaaa"; + + struct t1662_WriteThis *pooh = (struct t1662_WriteThis *)userp; size_t len = strlen(testdata); if(size*nmemb < len) @@ -46,14 +46,13 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) return 0; /* no more data left to deliver */ } - CURLcode test(char *URL) { CURLcode res = CURLE_OK; CURL *hnd; curl_mime *mime1; curl_mimepart *part1; - struct WriteThis pooh = { 1 }; + struct t1662_WriteThis pooh = { 1 }; mime1 = NULL; @@ -67,7 +66,7 @@ CURLcode test(char *URL) mime1 = curl_mime_init(hnd); if(mime1) { part1 = curl_mime_addpart(mime1); - curl_mime_data_cb(part1, -1, read_callback, NULL, NULL, &pooh); + curl_mime_data_cb(part1, -1, t1662_read_cb, NULL, NULL, &pooh); curl_mime_filename(part1, "poetry.txt"); curl_mime_name(part1, "content"); curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1); diff --git a/tests/libtest/lib1901.c b/tests/libtest/lib1901.c index 6d5f3d4aa0..0ae6bc5ded 100644 --- a/tests/libtest/lib1901.c +++ b/tests/libtest/lib1901.c @@ -27,19 +27,15 @@ #include "warnless.h" #include "memdebug.h" - - -static const char *chunks[]={ - "one", - "two", - "three", - "four", - NULL -}; - - -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t1901_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { + static const char *chunks[] = { + "one", + "two", + "three", + "four", + NULL + }; static int ix = 0; (void)size; (void)nmemb; @@ -67,7 +63,7 @@ CURLcode test(char *URL) ignores it */ easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 4L); easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); - easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + easy_setopt(curl, CURLOPT_READFUNCTION, t1901_read_cb); easy_setopt(curl, CURLOPT_POST, 1L); easy_setopt(curl, CURLOPT_VERBOSE, 1L); easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); diff --git a/tests/libtest/lib1911.c b/tests/libtest/lib1911.c index 6dd4dcb1b0..3621040ec8 100644 --- a/tests/libtest/lib1911.c +++ b/tests/libtest/lib1911.c @@ -31,10 +31,10 @@ define not publicly exposed so we set our own */ #define MAX_INPUT_LENGTH 8000000 -static char testbuf[MAX_INPUT_LENGTH + 2]; - CURLcode test(char *URL) { + static char testbuf[MAX_INPUT_LENGTH + 2]; + const struct curl_easyoption *o; CURL *easy; int error = 0; diff --git a/tests/libtest/lib1915.c b/tests/libtest/lib1915.c index 02c225a323..4fd0354059 100644 --- a/tests/libtest/lib1915.c +++ b/tests/libtest/lib1915.c @@ -28,25 +28,6 @@ #include "warnless.h" #include "memdebug.h" -struct entry { - const char *name; - const char *exp; -}; - -static const struct entry preload_hosts[] = { -#if (SIZEOF_TIME_T < 5) - { "1.example.com", "20370320 01:02:03" }, - { "2.example.com", "20370320 03:02:01" }, - { "3.example.com", "20370319 01:02:03" }, -#else - { "1.example.com", "25250320 01:02:03" }, - { "2.example.com", "25250320 03:02:01" }, - { "3.example.com", "25250319 01:02:03" }, -#endif - { "4.example.com", "" }, - { NULL, NULL } /* end of list marker */ -}; - struct state { int index; }; @@ -55,6 +36,25 @@ struct state { static CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *e, void *userp) { + struct entry { + const char *name; + const char *exp; + }; + + static const struct entry preload_hosts[] = { +#if (SIZEOF_TIME_T < 5) + { "1.example.com", "20370320 01:02:03" }, + { "2.example.com", "20370320 03:02:01" }, + { "3.example.com", "20370319 01:02:03" }, +#else + { "1.example.com", "25250320 01:02:03" }, + { "2.example.com", "25250320 03:02:01" }, + { "3.example.com", "25250319 01:02:03" }, +#endif + { "4.example.com", "" }, + { NULL, NULL } /* end of list marker */ + }; + const char *host; const char *expire; struct state *s = (struct state *)userp; diff --git a/tests/libtest/lib1940.c b/tests/libtest/lib1940.c index c90a3e0a53..60b14f02a5 100644 --- a/tests/libtest/lib1940.c +++ b/tests/libtest/lib1940.c @@ -26,33 +26,38 @@ #include "memdebug.h" -static const char *testdata[]={ - "daTE", - "Server", - "content-type", - "content-length", - "location", - "set-cookie", - "silly-thing", - "fold", - "blank", - "Blank2", - NULL -}; +#ifndef LIB1940_C +#define LIB1940_C -#ifdef LIB1946 -#define HEADER_REQUEST 0 -#else -#define HEADER_REQUEST -1 -#endif +static size_t t1940_write_cb(char *data, size_t n, size_t l, void *userp) +{ + /* take care of the data here, ignored in this example */ + (void)data; + (void)userp; + return n*l; +} -static void showem(CURL *easy, unsigned int type) +static void t1940_showem(CURL *easy, int header_request, unsigned int type) { + static const char *testdata[] = { + "daTE", + "Server", + "content-type", + "content-length", + "location", + "set-cookie", + "silly-thing", + "fold", + "blank", + "Blank2", + NULL + }; + int i; struct curl_header *header; for(i = 0; testdata[i]; i++) { - if(CURLHE_OK == curl_easy_header(easy, testdata[i], 0, type, - HEADER_REQUEST, &header)) { + if(CURLHE_OK == curl_easy_header(easy, testdata[i], 0, + type, header_request, &header)) { if(header->amount > 1) { /* more than one, iterate over them */ size_t index = 0; @@ -63,8 +68,8 @@ static void showem(CURL *easy, unsigned int type) if(++index == amount) break; - if(CURLHE_OK != curl_easy_header(easy, testdata[i], index, type, - HEADER_REQUEST, &header)) + if(CURLHE_OK != curl_easy_header(easy, testdata[i], index, + type, header_request, &header)) break; } while(1); } @@ -75,26 +80,27 @@ static void showem(CURL *easy, unsigned int type) } } } +#endif -static size_t write_cb(char *data, size_t n, size_t l, void *userp) -{ - /* take care of the data here, ignored in this example */ - (void)data; - (void)userp; - return n*l; -} CURLcode test(char *URL) { CURL *easy = NULL; CURLcode res = CURLE_OK; + int header_request; +#ifdef LIB1946 + header_request = 0; +#else + header_request = -1; +#endif + global_init(CURL_GLOBAL_DEFAULT); easy_init(easy); easy_setopt(easy, CURLOPT_URL, URL); easy_setopt(easy, CURLOPT_VERBOSE, 1L); easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L); /* ignores any content */ - easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb); + easy_setopt(easy, CURLOPT_WRITEFUNCTION, t1940_write_cb); /* if there's a proxy set, use it */ if(libtest_arg2 && *libtest_arg2) { @@ -105,13 +111,13 @@ CURLcode test(char *URL) if(res) goto test_cleanup; - showem(easy, CURLH_HEADER); + t1940_showem(easy, header_request, CURLH_HEADER); if(libtest_arg2 && *libtest_arg2) { /* now show connect headers only */ - showem(easy, CURLH_CONNECT); + t1940_showem(easy, header_request, CURLH_CONNECT); } - showem(easy, CURLH_1XX); - showem(easy, CURLH_TRAILER); + t1940_showem(easy, header_request, CURLH_1XX); + t1940_showem(easy, header_request, CURLH_TRAILER); test_cleanup: curl_easy_cleanup(easy); diff --git a/tests/libtest/lib1945.c b/tests/libtest/lib1945.c index 5a4361fbd1..8bb87a28d7 100644 --- a/tests/libtest/lib1945.c +++ b/tests/libtest/lib1945.c @@ -26,7 +26,7 @@ #include "memdebug.h" -static void showem(CURL *easy, unsigned int type) +static void t1945_showem(CURL *easy, unsigned int type) { struct curl_header *header = NULL; struct curl_header *prev = NULL; @@ -39,7 +39,7 @@ static void showem(CURL *easy, unsigned int type) } } -static size_t write_cb(char *data, size_t n, size_t l, void *userp) +static size_t t1945_write_cb(char *data, size_t n, size_t l, void *userp) { /* take care of the data here, ignored in this example */ (void)data; @@ -58,7 +58,7 @@ CURLcode test(char *URL) curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L); curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L); /* ignores any content */ - curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb); + curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, t1945_write_cb); /* if there's a proxy set, use it */ if(libtest_arg2 && *libtest_arg2) { @@ -69,7 +69,7 @@ CURLcode test(char *URL) if(res) { curl_mprintf("badness: %d\n", res); } - showem(easy, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX); + t1945_showem(easy, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX); test_cleanup: curl_easy_cleanup(easy); diff --git a/tests/libtest/lib1947.c b/tests/libtest/lib1947.c index 3288939fca..9d9559a142 100644 --- a/tests/libtest/lib1947.c +++ b/tests/libtest/lib1947.c @@ -26,7 +26,7 @@ #include "memdebug.h" -static size_t writecb(char *data, size_t n, size_t l, void *userp) +static size_t t1947_write_cb(char *data, size_t n, size_t l, void *userp) { /* ignore the data */ (void)data; @@ -47,7 +47,7 @@ CURLcode test(char *URL) /* perform a request that involves redirection */ easy_setopt(curl, CURLOPT_URL, URL); - easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); + easy_setopt(curl, CURLOPT_WRITEFUNCTION, t1947_write_cb); easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); res = curl_easy_perform(curl); if(res) { diff --git a/tests/libtest/lib1971.c b/tests/libtest/lib1971.c index c36a0c2bc6..4bbdc207ae 100644 --- a/tests/libtest/lib1971.c +++ b/tests/libtest/lib1971.c @@ -25,13 +25,12 @@ #include "memdebug.h" -static size_t read_callback(char *buffer, size_t size, size_t nitems, - void *userdata) +static size_t t1971_read_cb(char *ptr, size_t size, size_t nitems, void *userp) { - (void)buffer; /* unused */ + (void)ptr; /* unused */ (void)size; /* unused */ (void)nitems; /* unused */ - (void)userdata; /* unused */ + (void)userp; /* unused */ return 0; } @@ -55,7 +54,7 @@ CURLcode test(char *URL) } test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1971_read_cb); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3"); test_setopt(curl, CURLOPT_USERPWD, "xxx"); diff --git a/tests/libtest/lib1975.c b/tests/libtest/lib1975.c index b9fdc84786..ade53bc477 100644 --- a/tests/libtest/lib1975.c +++ b/tests/libtest/lib1975.c @@ -25,13 +25,12 @@ #include "memdebug.h" -static size_t read_callback(char *buffer, size_t size, size_t nitems, - void *userdata) +static size_t t1975_read_cb(char *ptr, size_t size, size_t nitems, void *userp) { - (void)buffer; /* unused */ + (void)ptr; /* unused */ (void)size; /* unused */ (void)nitems; /* unused */ - (void)userdata; /* unused */ + (void)userp; /* unused */ return 0; } @@ -55,7 +54,7 @@ CURLcode test(char *URL) } test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t1975_read_cb); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3"); test_setopt(curl, CURLOPT_USERPWD, "xxx"); diff --git a/tests/libtest/lib2301.c b/tests/libtest/lib2301.c index 8a370928a3..8603f31414 100644 --- a/tests/libtest/lib2301.c +++ b/tests/libtest/lib2301.c @@ -27,7 +27,7 @@ #ifndef CURL_DISABLE_WEBSOCKETS #if 0 -static CURLcode send_ping(CURL *curl, const char *send_payload) +static CURLcode t2301_send_ping(CURL *curl, const char *send_payload) { size_t sent; CURLcode result = @@ -38,7 +38,7 @@ static CURLcode send_ping(CURL *curl, const char *send_payload) return result; } -static CURLcode recv_pong(CURL *curl, const char *expected_payload) +static CURLcode t2301_recv_pong(CURL *curl, const char *expected_payload) { size_t rlen; unsigned int rflags; @@ -67,7 +67,7 @@ static CURLcode recv_pong(CURL *curl, const char *expected_payload) } /* just close the connection */ -static void websocket_close(CURL *curl) +static void t2301_websocket_close(CURL *curl) { size_t sent; CURLcode result = @@ -76,23 +76,23 @@ static void websocket_close(CURL *curl) "ws: curl_ws_send returned %d, sent %d\n", result, (int)sent); } -static void websocket(CURL *curl) +static void t2301_websocket(CURL *curl) { int i = 0; curl_mfprintf(stderr, "ws: websocket() starts\n"); do { - if(send_ping(curl, "foobar")) + if(t2301_send_ping(curl, "foobar")) return; - if(recv_pong(curl, "foobar")) + if(t2301_recv_pong(curl, "foobar")) return; sleep(2); } while(i++ < 10); - websocket_close(curl); + t2301_websocket_close(curl); } #endif -static size_t writecb(char *b, size_t size, size_t nitems, void *p) +static size_t t2301_write_cb(char *b, size_t size, size_t nitems, void *p) { CURL *easy = p; unsigned char *buffer = (unsigned char *)b; @@ -135,13 +135,13 @@ CURLcode test(char *URL) curl_easy_setopt(curl, CURLOPT_USERAGENT, "webbie-sox/3"); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, t2301_write_cb); curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl); res = curl_easy_perform(curl); curl_mfprintf(stderr, "curl_easy_perform() returned %d\n", res); #if 0 if(res == CURLE_OK) - websocket(curl); + t2301_websocket(curl); #endif /* always cleanup */ curl_easy_cleanup(curl); diff --git a/tests/libtest/lib2302.c b/tests/libtest/lib2302.c index 1207a3a9af..010e3b0911 100644 --- a/tests/libtest/lib2302.c +++ b/tests/libtest/lib2302.c @@ -78,7 +78,7 @@ static size_t add_data(struct ws_data *wd, const char *buf, size_t blen, } -static size_t writecb(char *buffer, size_t size, size_t nitems, void *p) +static size_t t2302_write_cb(char *buffer, size_t size, size_t nitems, void *p) { struct ws_data *ws_data = p; size_t incoming = nitems; @@ -112,7 +112,7 @@ CURLcode test(char *URL) /* use the callback style */ curl_easy_setopt(curl, CURLOPT_USERAGENT, "webbie-sox/3"); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, t2302_write_cb); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ws_data); res = curl_easy_perform(curl); curl_mfprintf(stderr, "curl_easy_perform() returned %d\n", res); diff --git a/tests/libtest/lib2304.c b/tests/libtest/lib2304.c index 74053538bf..9c2828ca84 100644 --- a/tests/libtest/lib2304.c +++ b/tests/libtest/lib2304.c @@ -26,7 +26,7 @@ #ifndef CURL_DISABLE_WEBSOCKETS -static CURLcode send_ping(CURL *curl, const char *send_payload) +static CURLcode t2304_send_ping(CURL *curl, const char *send_payload) { size_t sent; CURLcode result = @@ -38,7 +38,7 @@ static CURLcode send_ping(CURL *curl, const char *send_payload) return result; } -static CURLcode recv_pong(CURL *curl, const char *expected_payload) +static CURLcode t2304_recv_pong(CURL *curl, const char *expected_payload) { size_t rlen; const struct curl_ws_frame *meta; @@ -82,7 +82,7 @@ static CURLcode recv_any(CURL *curl) } /* just close the connection */ -static void websocket_close(CURL *curl) +static void t2304_websocket_close(CURL *curl) { size_t sent; CURLcode result = @@ -91,23 +91,23 @@ static void websocket_close(CURL *curl) "ws: curl_ws_send returned %d, sent %u\n", result, (int)sent); } -static void websocket(CURL *curl) +static void t2304_websocket(CURL *curl) { int i = 0; curl_mfprintf(stderr, "ws: websocket() starts\n"); do { recv_any(curl); curl_mfprintf(stderr, "Send ping\n"); - if(send_ping(curl, "foobar")) + if(t2304_send_ping(curl, "foobar")) return; curl_mfprintf(stderr, "Receive pong\n"); - if(recv_pong(curl, "foobar")) { + if(t2304_recv_pong(curl, "foobar")) { curl_mprintf("Connection closed\n"); return; } sleep(2); } while(i++ < 10); - websocket_close(curl); + t2304_websocket_close(curl); } CURLcode test(char *URL) @@ -128,7 +128,7 @@ CURLcode test(char *URL) res = curl_easy_perform(curl); curl_mfprintf(stderr, "curl_easy_perform() returned %d\n", res); if(res == CURLE_OK) - websocket(curl); + t2304_websocket(curl); /* always cleanup */ curl_easy_cleanup(curl); diff --git a/tests/libtest/lib2402.c b/tests/libtest/lib2402.c index 9e3e8fba79..808b966290 100644 --- a/tests/libtest/lib2402.c +++ b/tests/libtest/lib2402.c @@ -27,10 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -#define NUM_HANDLES 4 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib2404.c b/tests/libtest/lib2404.c index c4d8e5df58..5876f76675 100644 --- a/tests/libtest/lib2404.c +++ b/tests/libtest/lib2404.c @@ -27,10 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -#define NUM_HANDLES 4 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib2502.c b/tests/libtest/lib2502.c index 8979d19b05..99cb8ed37a 100644 --- a/tests/libtest/lib2502.c +++ b/tests/libtest/lib2502.c @@ -28,10 +28,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -#define NUM_HANDLES 4 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib3026.c b/tests/libtest/lib3026.c index a94b1a271d..28580e9956 100644 --- a/tests/libtest/lib3026.c +++ b/tests/libtest/lib3026.c @@ -30,10 +30,10 @@ #ifdef _WIN32 #if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE) -static DWORD WINAPI run_thread(LPVOID ptr) +static DWORD WINAPI t3026_run_thread(LPVOID ptr) #else #include -static unsigned int WINAPI run_thread(void *ptr) +static unsigned int WINAPI t3026_run_thread(void *ptr) #endif { CURLcode *result = ptr; @@ -71,9 +71,9 @@ CURLcode test(char *URL) curl_win_thread_handle_t th; results[i] = CURL_LAST; /* initialize with invalid value */ #if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE) - th = CreateThread(NULL, 0, run_thread, &results[i], 0, NULL); + th = CreateThread(NULL, 0, t3026_run_thread, &results[i], 0, NULL); #else - th = _beginthreadex(NULL, 0, run_thread, &results[i], 0, NULL); + th = _beginthreadex(NULL, 0, t3026_run_thread, &results[i], 0, NULL); #endif if(!th) { curl_mfprintf(stderr, "%s:%d Couldn't create thread, errno %lu\n", @@ -104,7 +104,7 @@ cleanup: #include #include -static void *run_thread(void *ptr) +static void *t3026_run_thread(void *ptr) { CURLcode *result = ptr; @@ -135,7 +135,7 @@ CURLcode test(char *URL) for(i = 0; i < tid_count; i++) { int res; results[i] = CURL_LAST; /* initialize with invalid value */ - res = pthread_create(&tids[i], NULL, run_thread, &results[i]); + res = pthread_create(&tids[i], NULL, t3026_run_thread, &results[i]); if(res) { curl_mfprintf(stderr, "%s:%d Couldn't create thread, errno %d\n", __FILE__, __LINE__, res); diff --git a/tests/libtest/lib3105.c b/tests/libtest/lib3105.c index c41a59a1b6..c8a1a78f06 100644 --- a/tests/libtest/lib3105.c +++ b/tests/libtest/lib3105.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *curls = NULL; diff --git a/tests/libtest/lib3207.c b/tests/libtest/lib3207.c index 5baec357d1..294c8e6240 100644 --- a/tests/libtest/lib3207.c +++ b/tests/libtest/lib3207.c @@ -126,8 +126,8 @@ test_cleanup: #if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) -static void test_lock(CURL *handle, curl_lock_data data, - curl_lock_access laccess, void *useptr) +static void t3207_test_lock(CURL *handle, curl_lock_data data, + curl_lock_access laccess, void *useptr) { curl_mutex_t *mutexes = (curl_mutex_t*) useptr; (void)handle; @@ -135,7 +135,7 @@ static void test_lock(CURL *handle, curl_lock_data data, Curl_mutex_acquire(&mutexes[data]); } -static void test_unlock(CURL *handle, curl_lock_data data, void *useptr) +static void t3207_test_unlock(CURL *handle, curl_lock_data data, void *useptr) { curl_mutex_t *mutexes = (curl_mutex_t*) useptr; (void)handle; @@ -150,8 +150,8 @@ static void execute(CURLSH *share, struct Ctx *ctx) for(i = 0; i < CURL_LOCK_DATA_LAST - 1; i++) { Curl_mutex_init(&mutexes[i]); } - curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock); - curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock); + curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t3207_test_lock); + curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t3207_test_unlock); curl_share_setopt(share, CURLSHOPT_USERDATA, (void *)mutexes); curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); diff --git a/tests/libtest/lib3208.c b/tests/libtest/lib3208.c index ce3a4cbe9c..846e8fcf9b 100644 --- a/tests/libtest/lib3208.c +++ b/tests/libtest/lib3208.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 1a9222edc8..e7623e5aaa 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -54,8 +54,6 @@ static void setupcallbacks(CURL *curl) testcounter = 0; } -#else -#define setupcallbacks(x) Curl_nop_stmt #endif @@ -89,7 +87,9 @@ CURLcode test(char *URL) if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp")) test_setopt(curl, CURLOPT_FTPPORT, "-"); +#ifdef LIB585 setupcallbacks(curl); +#endif res = curl_easy_perform(curl); @@ -181,5 +181,3 @@ test_cleanup: return res; } - -#undef setupcallbacks diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 44ad6f6790..0a0208294d 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index cac2a755cb..4356f5aad4 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* * Source code in here hugely as reported in bug report 651460 by * Christopher R. Palmer. diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 93d38a0b24..989fa4dcf7 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* * Source code in here hugely as reported in bug report 651464 by * Christopher R. Palmer. diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 8680c6ec6d..89a5ccb5ab 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -22,19 +22,20 @@ * ***************************************************************************/ #include "test.h" + +#include "testutil.h" #include "memdebug.h" -static const char * const HOSTHEADER = "Host: www.host.foo.com"; #define JAR libtest_arg2 #define THREADS 2 /* struct containing data of a thread */ -struct Tdata { +struct t506_Tdata { CURLSH *share; char *url; }; -struct userdata { +struct t506_userdata { const char *text; int counter; }; @@ -42,11 +43,11 @@ struct userdata { static int locks[3]; /* lock callback */ -static void test_lock(CURL *handle, curl_lock_data data, - curl_lock_access laccess, void *useptr) +static void t506_test_lock(CURL *handle, curl_lock_data data, + curl_lock_access laccess, void *useptr) { const char *what; - struct userdata *user = (struct userdata *)useptr; + struct t506_userdata *user = (struct t506_userdata *)useptr; int locknum; (void)handle; @@ -82,10 +83,10 @@ static void test_lock(CURL *handle, curl_lock_data data, } /* unlock callback */ -static void test_unlock(CURL *handle, curl_lock_data data, void *useptr) +static void t506_test_unlock(CURL *handle, curl_lock_data data, void *useptr) { const char *what; - struct userdata *user = (struct userdata *)useptr; + struct t506_userdata *user = (struct t506_userdata *)useptr; int locknum; (void)handle; switch(data) { @@ -117,21 +118,19 @@ static void test_unlock(CURL *handle, curl_lock_data data, void *useptr) user->counter++; } - /* build host entry */ static struct curl_slist *sethost(struct curl_slist *headers) { (void)headers; - return curl_slist_append(NULL, HOSTHEADER); + return curl_slist_append(NULL, "Host: www.host.foo.com"); } - /* the dummy thread function */ -static void *test_fire(void *ptr) +static void *t506_test_fire(void *ptr) { CURLcode code; struct curl_slist *headers; - struct Tdata *tdata = (struct Tdata*)ptr; + struct t506_Tdata *tdata = (struct t506_Tdata*)ptr; CURL *curl; curl = curl_easy_init(); @@ -163,14 +162,6 @@ static void *test_fire(void *ptr) return NULL; } - -/* build request url */ -static char *suburl(const char *base, int i) -{ - return curl_maprintf("%s%.4d", base, i); -} - - /* test function */ CURLcode test(char *URL) { @@ -178,14 +169,14 @@ CURLcode test(char *URL) CURLSHcode scode = CURLSHE_OK; CURLcode code = CURLE_OK; char *url = NULL; - struct Tdata tdata; + struct t506_Tdata tdata; CURL *curl; CURLSH *share; struct curl_slist *headers = NULL; struct curl_slist *cookies = NULL; struct curl_slist *next_cookie = NULL; int i; - struct userdata user; + struct t506_userdata user; user.text = "Pigs in space"; user.counter = 0; @@ -207,11 +198,11 @@ CURLcode test(char *URL) if(CURLSHE_OK == scode) { curl_mprintf("CURLSHOPT_LOCKFUNC\n"); - scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock); + scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t506_test_lock); } if(CURLSHE_OK == scode) { curl_mprintf("CURLSHOPT_UNLOCKFUNC\n"); - scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock); + scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t506_test_unlock); } if(CURLSHE_OK == scode) { curl_mprintf("CURLSHOPT_USERDATA\n"); @@ -265,12 +256,12 @@ CURLcode test(char *URL) for(i = 1; i <= THREADS; i++) { /* set thread data */ - tdata.url = suburl(URL, i); /* must be curl_free()d */ + tdata.url = tutil_suburl(URL, i); /* must be curl_free()d */ tdata.share = share; /* simulate thread, direct call of "thread" function */ curl_mprintf("*** run %d\n",i); - test_fire(&tdata); + t506_test_fire(&tdata); curl_free(tdata.url); } @@ -286,7 +277,7 @@ CURLcode test(char *URL) return TEST_ERR_MAJOR_BAD; } - url = suburl(URL, i); + url = tutil_suburl(URL, i); headers = sethost(NULL); test_setopt(curl, CURLOPT_HTTPHEADER, headers); test_setopt(curl, CURLOPT_URL, url); @@ -313,7 +304,7 @@ CURLcode test(char *URL) curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - url = suburl(URL, i); + url = tutil_suburl(URL, i); headers = sethost(NULL); test_setopt(curl, CURLOPT_HTTPHEADER, headers); test_setopt(curl, CURLOPT_URL, url); diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index f86ee79b92..53b554d194 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *curls = NULL; diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 8480cd7d14..968125c28d 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -25,16 +25,14 @@ #include "memdebug.h" -static char testdata[]="this is what we post to the silly web server\n"; - -struct WriteThis { - char *readptr; +struct t508_WriteThis { + const char *readptr; size_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t508_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t508_WriteThis *pooh = (struct t508_WriteThis *)userp; if(size*nmemb < 1) return 0; @@ -51,10 +49,13 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) CURLcode test(char *URL) { + static const char testdata[] = + "this is what we post to the silly web server\n"; + CURL *curl; CURLcode res = CURLE_OK; - struct WriteThis pooh; + struct t508_WriteThis pooh; pooh.readptr = testdata; pooh.sizeleft = strlen(testdata); @@ -81,7 +82,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t508_read_cb); /* pointer to pass to our read function */ test_setopt(curl, CURLOPT_READDATA, &pooh); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 0c7a7d1493..4be925917a 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -25,22 +25,24 @@ #include "memdebug.h" -static const char * const testpost[]={ - "one", - "two", - "three", - "and a final longer crap: four", - NULL -}; - +#ifndef LIB510_C +#define LIB510_C -struct WriteThis { +struct t510_WriteThis { int counter; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t510_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + static const char * const testpost[] = { + "one", + "two", + "three", + "and a final longer crap: four", + NULL + }; + + struct t510_WriteThis *pooh = (struct t510_WriteThis *)userp; const char *data; if(size*nmemb < 1) @@ -60,13 +62,14 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) } return 0; /* no more data left to deliver */ } +#endif CURLcode test(char *URL) { CURL *curl; CURLcode res = CURLE_OK; struct curl_slist *slist = NULL; - struct WriteThis pooh; + struct t510_WriteThis pooh; pooh.counter = 0; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { @@ -96,7 +99,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POST, 1L); /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t510_read_cb); /* pointer to pass to our read function */ test_setopt(curl, CURLOPT_READDATA, &pooh); diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index af40e6ee09..c0153f0247 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -25,7 +25,7 @@ #include "memdebug.h" -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t513_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { (void)ptr; (void)size; @@ -61,7 +61,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L); /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t513_read_cb); /* pointer to pass to our read function */ test_setopt(curl, CURLOPT_READDATA, NULL); diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index d7849f1dcc..32175d00ee 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -25,145 +25,145 @@ #include "memdebug.h" -struct dcheck { - const char *input; - time_t output; -}; +CURLcode test(char *URL) +{ + struct dcheck { + const char *input; + time_t output; + }; -static const struct dcheck dates[] = { - {"Sun, 06 Nov 1994 08:49:37 GMT", 784111777 }, - {"Sunday, 06-Nov-94 08:49:37 GMT", 784111777 }, - {"Sun Nov 6 08:49:37 1994", 784111777 }, - {"Sun Nov 6 8:49:37 1994", 784111777 }, - {"Sun Nov 6 8:9:37 1994", 784109377 }, - {"Sun Nov 6 008:09:37 1994", -1 }, - {"Nov Sun 6 8:9:7 1994", 784109347 }, - {"06 Nov 1994 08:49:37 GMT", 784111777 }, - {"06-Nov-94 08:49:37 GMT", 784111777 }, - {"Nov 6 08:49:37 1994", 784111777 }, - {"06 Nov 1994 08:49:37", 784111777 }, - {"06-Nov-94 08:49:37", 784111777 }, - {"1994 Nov 6 08:49:37", 784111777 }, - {"GMT 08:49:37 06-Nov-94 Sunday", 784111777 }, - {"94 6 Nov 08:49:37", 784111777 }, - {"1994 Nov 6", 784080000 }, - {"06-Nov-94", 784080000 }, - {"Sun Nov 6 94", 784080000 }, - {"1994.Nov.6", 784080000 }, - {"Sun/Nov/6/94/GMT", 784080000 }, - {"Sun, 06 Nov 1994 08:49:37 CET", 784108177 }, - {"06 Nov 1994 08:49:37 EST", 784129777 }, - {"Sun, 06 Nov 1994 08:49:37 UT", 784111777 }, - {"Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 }, - {"Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 }, - {"20040912 15:05:58 -0700", 1095026758 }, - {"20040911 +0200", 1094853600 }, - {"Thu, 01-Jan-1970 00:59:59 GMT", 3599 }, - {"Thu, 01-Jan-1970 01:00:00 GMT", 3600 }, - {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, - {"Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 }, - {"Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 }, - {"Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 }, - {"Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 }, - {"Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 }, - {", 1-Jan-2003 00:00:00 GMT", 1041379200 }, - {"1-Jan-2003 00:00:00 GMT", 1041379200 }, - {"1-Jan-2003 00:00:00 GMT", 1041379200 }, - {"Wed,18-Apr-07 22:50:12 GMT", 1176936612 }, - {"WillyWonka , 18-Apr-07 22:50:12 GMT", -1 }, - {"WillyWonka , 18-Apr-07 22:50:12", -1 }, - {"WillyWonka , 18-apr-07 22:50:12", -1 }, - {"Mon, 18-Apr-1977 22:50:13 GMT", 230251813 }, - {"Mon, 18-Apr-77 22:50:13 GMT", 230251813 }, - {"Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 }, - {"Partyday, 18- April-07 22:50:12", -1 }, - {"Partyday, 18 - Apri-07 22:50:12", -1 }, - {"Wednes, 1-Januar-2003 00:00:00 GMT", -1 }, - {"Sat, 15-Apr-17 21:01:22", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 DST", -1 }, - {"Sat, 15-Apr-17 21:01:22 -0400", 1492304482 }, - {"Sat, 15-Apr-17 21:01:22 (hello there)", -1 }, - {"Sat, 15-Apr-17 21:01:22 11:22:33", -1 }, - {"Sat, 15-Apr-17 ::00 21:01:22", -1 }, - {"Sat, 15-Apr-17 boink:z 21:01:22", -1 }, - {"Sat, 15-Apr-17 91:22:33 21:01:22", -1 }, - {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, - {"22:50:12 Thu Apr 18 2007 GMT", 1176936612 }, - {"Thu 22:50:12 Apr 18 2007 GMT", 1176936612 }, - {"Thu Apr 22:50:12 18 2007 GMT", 1176936612 }, - {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, - {"Thu Apr 18 2007 22:50:12 GMT", 1176936612 }, - {"Thu Apr 18 2007 GMT 22:50:12", 1176936612 }, + static const struct dcheck dates[] = { + {"Sun, 06 Nov 1994 08:49:37 GMT", 784111777 }, + {"Sunday, 06-Nov-94 08:49:37 GMT", 784111777 }, + {"Sun Nov 6 08:49:37 1994", 784111777 }, + {"Sun Nov 6 8:49:37 1994", 784111777 }, + {"Sun Nov 6 8:9:37 1994", 784109377 }, + {"Sun Nov 6 008:09:37 1994", -1 }, + {"Nov Sun 6 8:9:7 1994", 784109347 }, + {"06 Nov 1994 08:49:37 GMT", 784111777 }, + {"06-Nov-94 08:49:37 GMT", 784111777 }, + {"Nov 6 08:49:37 1994", 784111777 }, + {"06 Nov 1994 08:49:37", 784111777 }, + {"06-Nov-94 08:49:37", 784111777 }, + {"1994 Nov 6 08:49:37", 784111777 }, + {"GMT 08:49:37 06-Nov-94 Sunday", 784111777 }, + {"94 6 Nov 08:49:37", 784111777 }, + {"1994 Nov 6", 784080000 }, + {"06-Nov-94", 784080000 }, + {"Sun Nov 6 94", 784080000 }, + {"1994.Nov.6", 784080000 }, + {"Sun/Nov/6/94/GMT", 784080000 }, + {"Sun, 06 Nov 1994 08:49:37 CET", 784108177 }, + {"06 Nov 1994 08:49:37 EST", 784129777 }, + {"Sun, 06 Nov 1994 08:49:37 UT", 784111777 }, + {"Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 }, + {"Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 }, + {"20040912 15:05:58 -0700", 1095026758 }, + {"20040911 +0200", 1094853600 }, + {"Thu, 01-Jan-1970 00:59:59 GMT", 3599 }, + {"Thu, 01-Jan-1970 01:00:00 GMT", 3600 }, + {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, + {"Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 }, + {"Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 }, + {"Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 }, + {"Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 }, + {"Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 }, + {", 1-Jan-2003 00:00:00 GMT", 1041379200 }, + {"1-Jan-2003 00:00:00 GMT", 1041379200 }, + {"1-Jan-2003 00:00:00 GMT", 1041379200 }, + {"Wed,18-Apr-07 22:50:12 GMT", 1176936612 }, + {"WillyWonka , 18-Apr-07 22:50:12 GMT", -1 }, + {"WillyWonka , 18-Apr-07 22:50:12", -1 }, + {"WillyWonka , 18-apr-07 22:50:12", -1 }, + {"Mon, 18-Apr-1977 22:50:13 GMT", 230251813 }, + {"Mon, 18-Apr-77 22:50:13 GMT", 230251813 }, + {"Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 }, + {"Partyday, 18- April-07 22:50:12", -1 }, + {"Partyday, 18 - Apri-07 22:50:12", -1 }, + {"Wednes, 1-Januar-2003 00:00:00 GMT", -1 }, + {"Sat, 15-Apr-17 21:01:22", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 DST", -1 }, + {"Sat, 15-Apr-17 21:01:22 -0400", 1492304482 }, + {"Sat, 15-Apr-17 21:01:22 (hello there)", -1 }, + {"Sat, 15-Apr-17 21:01:22 11:22:33", -1 }, + {"Sat, 15-Apr-17 ::00 21:01:22", -1 }, + {"Sat, 15-Apr-17 boink:z 21:01:22", -1 }, + {"Sat, 15-Apr-17 91:22:33 21:01:22", -1 }, + {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, + {"22:50:12 Thu Apr 18 2007 GMT", 1176936612 }, + {"Thu 22:50:12 Apr 18 2007 GMT", 1176936612 }, + {"Thu Apr 22:50:12 18 2007 GMT", 1176936612 }, + {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, + {"Thu Apr 18 2007 22:50:12 GMT", 1176936612 }, + {"Thu Apr 18 2007 GMT 22:50:12", 1176936612 }, - {"\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, - {"-\"22:50:12 Thu Apr 18 2007 GMT\"", 1176936612 }, - {"*\"Thu 22:50:12 Apr 18 2007 GMT\"", 1176936612 }, - {";\"Thu Apr 22:50:12 18 2007 GMT\"", 1176936612 }, - {".\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, - {"\"Thu Apr 18 2007 22:50:12 GMT\"", 1176936612 }, - {"\"Thu Apr 18 2007 GMT 22:50:12\"", 1176936612 }, + {"\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, + {"-\"22:50:12 Thu Apr 18 2007 GMT\"", 1176936612 }, + {"*\"Thu 22:50:12 Apr 18 2007 GMT\"", 1176936612 }, + {";\"Thu Apr 22:50:12 18 2007 GMT\"", 1176936612 }, + {".\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, + {"\"Thu Apr 18 2007 22:50:12 GMT\"", 1176936612 }, + {"\"Thu Apr 18 2007 GMT 22:50:12\"", 1176936612 }, - {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, - {"15-Sat, Apr-17 21:01:22 GMT", 1492290082 }, - {"15-Sat, Apr 21:01:22 GMT 17", 1492290082 }, - {"15-Sat, Apr 21:01:22 GMT 2017", 1492290082 }, - {"15 Apr 21:01:22 2017", 1492290082 }, - {"15 17 Apr 21:01:22", 1492290082 }, - {"Apr 15 17 21:01:22", 1492290082 }, - {"Apr 15 21:01:22 17", 1492290082 }, - {"2017 April 15 21:01:22", -1 }, - {"15 April 2017 21:01:22", -1 }, - {"98 April 17 21:01:22", -1 }, - {"Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 }, - {"Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 }, - {"Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 }, - {"IAintNoDateFool", -1 }, - {"Thu Apr 18 22:50 2007 GMT", 1176936600 }, - {"20110623 12:34:56", 1308832496 }, - {"20110632 12:34:56", -1 }, - {"20110623 56:34:56", -1 }, - {"20111323 12:34:56", -1 }, - {"20110623 12:34:79", -1 }, - {"Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 }, - {"Wed, 31 Dec 2008 23:59:61 GMT", -1 }, - {"Wed, 31 Dec 2008 24:00:00 GMT", -1 }, - {"Wed, 31 Dec 2008 23:60:59 GMT", -1 }, - {"20110623 12:3", 1308830580 }, - {"20110623 1:3", 1308790980 }, - {"20110623 1:30", 1308792600 }, - {"20110623 12:12:3", 1308831123 }, - {"20110623 01:12:3", 1308791523 }, - {"20110623 01:99:30", -1 }, - {"Thu, 01-Jan-1970 00:00:00 GMT", 0 }, - {"Thu, 31-Dec-1969 23:59:58 GMT", -2 }, - {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */ + {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, + {"15-Sat, Apr-17 21:01:22 GMT", 1492290082 }, + {"15-Sat, Apr 21:01:22 GMT 17", 1492290082 }, + {"15-Sat, Apr 21:01:22 GMT 2017", 1492290082 }, + {"15 Apr 21:01:22 2017", 1492290082 }, + {"15 17 Apr 21:01:22", 1492290082 }, + {"Apr 15 17 21:01:22", 1492290082 }, + {"Apr 15 21:01:22 17", 1492290082 }, + {"2017 April 15 21:01:22", -1 }, + {"15 April 2017 21:01:22", -1 }, + {"98 April 17 21:01:22", -1 }, + {"Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 }, + {"Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 }, + {"Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 }, + {"IAintNoDateFool", -1 }, + {"Thu Apr 18 22:50 2007 GMT", 1176936600 }, + {"20110623 12:34:56", 1308832496 }, + {"20110632 12:34:56", -1 }, + {"20110623 56:34:56", -1 }, + {"20111323 12:34:56", -1 }, + {"20110623 12:34:79", -1 }, + {"Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 }, + {"Wed, 31 Dec 2008 23:59:61 GMT", -1 }, + {"Wed, 31 Dec 2008 24:00:00 GMT", -1 }, + {"Wed, 31 Dec 2008 23:60:59 GMT", -1 }, + {"20110623 12:3", 1308830580 }, + {"20110623 1:3", 1308790980 }, + {"20110623 1:30", 1308792600 }, + {"20110623 12:12:3", 1308831123 }, + {"20110623 01:12:3", 1308791523 }, + {"20110623 01:99:30", -1 }, + {"Thu, 01-Jan-1970 00:00:00 GMT", 0 }, + {"Thu, 31-Dec-1969 23:59:58 GMT", -2 }, + {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */ #if SIZEOF_TIME_T > 4 - {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t) 2362034977 }, - {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 }, + {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t) 2362034977 }, + {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 }, #ifndef HAVE_TIME_T_UNSIGNED #if 0 - /* causes warning on MSVC */ - {"Sun, 06 Nov 1900 08:49:37 GMT", -2182259423 }, + /* causes warning on MSVC */ + {"Sun, 06 Nov 1900 08:49:37 GMT", -2182259423 }, #endif - {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 }, - {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 }, + {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 }, + {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 }, #endif - {"Thu, 01-Jan-1499 00:00:00 GMT", -1 }, + {"Thu, 01-Jan-1499 00:00:00 GMT", -1 }, #else - {"Sun, 06 Nov 2044 08:49:37 GMT", -1 }, + {"Sun, 06 Nov 2044 08:49:37 GMT", -1 }, #endif #ifndef HAVE_TIME_T_UNSIGNED - {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 }, + {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 }, #endif - { NULL, 0 } -}; + { NULL, 0 } + }; -CURLcode test(char *URL) -{ int i; int error = 0; diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 3bc2fa5ed9..f9df1b4b4f 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -23,14 +23,11 @@ ***************************************************************************/ #include "test.h" -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif #ifdef HAVE_FCNTL_H #include #endif -#include +#include "testutil.h" #include "warnless.h" #include "memdebug.h" @@ -38,9 +35,10 @@ #error "this test requires FD_SETSIZE" #endif -#define SAFETY_MARGIN (16) +#define T518_SAFETY_MARGIN (16) + #define NUM_OPEN (FD_SETSIZE + 10) -#define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN) +#define NUM_NEEDED (NUM_OPEN + T518_SAFETY_MARGIN) #if defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" @@ -50,31 +48,31 @@ #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) -static int *testfd = NULL; -static struct rlimit num_open; -static char msgbuff[256]; +static int *t518_testfd = NULL; +static struct rlimit t518_num_open; +static char t518_msgbuff[256]; -static void store_errmsg(const char *msg, int err) +static void t518_store_errmsg(const char *msg, int err) { if(!err) - curl_msnprintf(msgbuff, sizeof(msgbuff), "%s", msg); + curl_msnprintf(t518_msgbuff, sizeof(t518_msgbuff), "%s", msg); else - curl_msnprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, - err, strerror(err)); + curl_msnprintf(t518_msgbuff, sizeof(t518_msgbuff), "%s, errno %d, %s", msg, + err, strerror(err)); } -static void close_file_descriptors(void) +static void t518_close_file_descriptors(void) { - for(num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) - if(testfd[num_open.rlim_cur] > 0) - close(testfd[num_open.rlim_cur]); - free(testfd); - testfd = NULL; + for(t518_num_open.rlim_cur = 0; + t518_num_open.rlim_cur < t518_num_open.rlim_max; + t518_num_open.rlim_cur++) + if(t518_testfd[t518_num_open.rlim_cur] > 0) + close(t518_testfd[t518_num_open.rlim_cur]); + free(t518_testfd); + t518_testfd = NULL; } -static int fopen_works(void) +static int t518_fopen_works(void) { FILE *fpa[3]; int i; @@ -86,8 +84,8 @@ static int fopen_works(void) for(i = 0; i < 3; i++) { fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT); if(!fpa[i]) { - store_errmsg("fopen failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t518_store_errmsg("fopen failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); ret = 0; break; } @@ -99,28 +97,7 @@ static int fopen_works(void) return ret; } -static void rlim2str(char *buf, size_t len, rlim_t val) -{ -#ifdef RLIM_INFINITY - if(val == RLIM_INFINITY) { - curl_msnprintf(buf, len, "INFINITY"); - return; - } -#endif -#ifdef HAVE_LONGLONG - if(sizeof(rlim_t) > sizeof(long)) - curl_msnprintf(buf, len, "%llu", (unsigned long long)val); - else -#endif - { - if(sizeof(rlim_t) < sizeof(long)) - curl_msnprintf(buf, len, "%u", (unsigned int)val); - else - curl_msnprintf(buf, len, "%lu", (unsigned long)val); - } -} - -static int test_rlimit(int keep_open) +static int t518_test_rlimit(int keep_open) { rlim_t nitems, i; int *memchunk = NULL; @@ -132,17 +109,17 @@ static int test_rlimit(int keep_open) /* get initial open file limits */ if(getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t518_store_errmsg("getrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); return -1; } /* show initial open file limits */ - rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); curl_mfprintf(stderr, "initial soft limit: %s\n", strbuff); - rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); curl_mfprintf(stderr, "initial hard limit: %s\n", strbuff); /* show our constants */ @@ -169,9 +146,9 @@ static int test_rlimit(int keep_open) rl.rlim_cur = OPEN_MAX; if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { /* on failure don't abort just issue a warning */ - store_errmsg("setrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); - msgbuff[0] = '\0'; + t518_store_errmsg("setrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); + t518_msgbuff[0] = '\0'; } } #endif @@ -180,25 +157,25 @@ static int test_rlimit(int keep_open) rl.rlim_cur = rl.rlim_max; if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { /* on failure don't abort just issue a warning */ - store_errmsg("setrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); - msgbuff[0] = '\0'; + t518_store_errmsg("setrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); + t518_msgbuff[0] = '\0'; } /* get current open file limits */ if(getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t518_store_errmsg("getrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); return -3; } /* show current open file limits */ - rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); curl_mfprintf(stderr, "current soft limit: %s\n", strbuff); - rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); curl_mfprintf(stderr, "current hard limit: %s\n", strbuff); } /* (rl.rlim_cur != rl.rlim_max) */ @@ -214,23 +191,23 @@ static int test_rlimit(int keep_open) /* * verify that soft limit is higher than NUM_NEEDED, * which is the number of file descriptors we would - * try to open plus SAFETY_MARGIN to not exhaust the + * try to open plus T518_SAFETY_MARGIN to not exhaust the * file descriptor pool */ - num_open.rlim_cur = NUM_NEEDED; + t518_num_open.rlim_cur = NUM_NEEDED; if((rl.rlim_cur > 0) && #ifdef RLIM_INFINITY (rl.rlim_cur != RLIM_INFINITY) && #endif - (rl.rlim_cur <= num_open.rlim_cur)) { - rlim2str(strbuff2, sizeof(strbuff2), rl.rlim_cur); - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + (rl.rlim_cur <= t518_num_open.rlim_cur)) { + tutil_rlim2str(strbuff2, sizeof(strbuff2), rl.rlim_cur); + tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s", - strbuff1, strbuff2); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); + strbuff1, strbuff2); + t518_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); return -4; } @@ -239,7 +216,7 @@ static int test_rlimit(int keep_open) * avoid a low memory condition once the file descriptors are * open. System conditions that could make the test fail should * be addressed in the precheck phase. This chunk of memory shall - * be always free()ed before exiting the test_rlimit() function so + * be always free()ed before exiting the t518_test_rlimit() function so * that it becomes available to the test. */ @@ -248,8 +225,8 @@ static int test_rlimit(int keep_open) if(nitems > 0x7fff) nitems = 0x40000; do { - num_open.rlim_max = sizeof(*memchunk) * nitems; - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + t518_num_open.rlim_max = sizeof(*memchunk) * nitems; + tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max); curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); if(!memchunk) { @@ -258,8 +235,8 @@ static int test_rlimit(int keep_open) } } while(nitems && !memchunk); if(!memchunk) { - store_errmsg("memchunk, malloc() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t518_store_errmsg("memchunk, malloc() failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); return -5; } @@ -272,30 +249,31 @@ static int test_rlimit(int keep_open) /* set the number of file descriptors we will try to open */ - num_open.rlim_max = NUM_OPEN; + t518_num_open.rlim_max = NUM_OPEN; /* verify that we won't overflow size_t in malloc() */ - if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*testfd)) { - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); + if((size_t)(t518_num_open.rlim_max) > ((size_t)-1) / sizeof(*t518_testfd)) { + tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_max); curl_msnprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); + t518_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); free(memchunk); return -6; } /* allocate array for file descriptors */ - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max); curl_mfprintf(stderr, "allocating array for %s file descriptors\n", strbuff); - testfd = malloc(sizeof(*testfd) * (size_t)(num_open.rlim_max)); - if(!testfd) { - store_errmsg("testfd, malloc() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t518_testfd = malloc(sizeof(*t518_testfd) * + (size_t)(t518_num_open.rlim_max)); + if(!t518_testfd) { + t518_store_errmsg("testfd, malloc() failed", errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); free(memchunk); return -7; } @@ -304,70 +282,70 @@ static int test_rlimit(int keep_open) curl_mfprintf(stderr, "initializing testfd array\n"); - for(num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) - testfd[num_open.rlim_cur] = -1; + for(t518_num_open.rlim_cur = 0; + t518_num_open.rlim_cur < t518_num_open.rlim_max; + t518_num_open.rlim_cur++) + t518_testfd[t518_num_open.rlim_cur] = -1; - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max); curl_mfprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ - testfd[0] = open(DEV_NULL, O_RDONLY); - if(testfd[0] < 0) { + t518_testfd[0] = open(DEV_NULL, O_RDONLY); + if(t518_testfd[0] < 0) { curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); - store_errmsg(strbuff, errno); - curl_mfprintf(stderr, "%s\n", msgbuff); - free(testfd); - testfd = NULL; + t518_store_errmsg(strbuff, errno); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); + free(t518_testfd); + t518_testfd = NULL; free(memchunk); return -8; } /* create a bunch of file descriptors */ - for(num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) { + for(t518_num_open.rlim_cur = 1; + t518_num_open.rlim_cur < t518_num_open.rlim_max; + t518_num_open.rlim_cur++) { - testfd[num_open.rlim_cur] = dup(testfd[0]); + t518_testfd[t518_num_open.rlim_cur] = dup(t518_testfd[0]); - if(testfd[num_open.rlim_cur] < 0) { + if(t518_testfd[t518_num_open.rlim_cur] < 0) { - testfd[num_open.rlim_cur] = -1; + t518_testfd[t518_num_open.rlim_cur] = -1; - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); curl_mfprintf(stderr, "%s\n", strbuff); - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); curl_mfprintf(stderr, "%s\n", strbuff); - num_open.rlim_max = NUM_NEEDED; + t518_num_open.rlim_max = NUM_NEEDED; - rlim2str(strbuff2, sizeof(strbuff2), num_open.rlim_max); - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + tutil_rlim2str(strbuff2, sizeof(strbuff2), t518_num_open.rlim_max); + tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s", strbuff2, strbuff1); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); - - for(num_open.rlim_cur = 0; - testfd[num_open.rlim_cur] >= 0; - num_open.rlim_cur++) - close(testfd[num_open.rlim_cur]); - free(testfd); - testfd = NULL; + t518_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); + + for(t518_num_open.rlim_cur = 0; + t518_testfd[t518_num_open.rlim_cur] >= 0; + t518_num_open.rlim_cur++) + close(t518_testfd[t518_num_open.rlim_cur]); + free(t518_testfd); + t518_testfd = NULL; free(memchunk); return -9; } } - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max); curl_mfprintf(stderr, "%s file descriptors open\n", strbuff); #if !defined(HAVE_POLL) && !defined(USE_WINSOCK) @@ -383,28 +361,28 @@ static int test_rlimit(int keep_open) * with an indication that select limit would be exceeded. */ - num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; - if(num_open.rlim_max > num_open.rlim_cur) { + t518_num_open.rlim_cur = FD_SETSIZE - T518_SAFETY_MARGIN; + if(t518_num_open.rlim_max > t518_num_open.rlim_cur) { curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", - FD_SETSIZE); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); - close_file_descriptors(); + FD_SETSIZE); + t518_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); + t518_close_file_descriptors(); free(memchunk); return -10; } - num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; + t518_num_open.rlim_cur = FD_SETSIZE - T518_SAFETY_MARGIN; for(rl.rlim_cur = 0; - rl.rlim_cur < num_open.rlim_max; + rl.rlim_cur < t518_num_open.rlim_max; rl.rlim_cur++) { - if((testfd[rl.rlim_cur] > 0) && - ((unsigned int)testfd[rl.rlim_cur] > num_open.rlim_cur)) { + if((t518_testfd[rl.rlim_cur] > 0) && + ((unsigned int)t518_testfd[rl.rlim_cur] > t518_num_open.rlim_cur)) { curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", - FD_SETSIZE); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); - close_file_descriptors(); + FD_SETSIZE); + t518_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); + t518_close_file_descriptors(); free(memchunk); return -11; } @@ -421,15 +399,15 @@ static int test_rlimit(int keep_open) * if it is capable of fopen()ing some additional files. */ - if(!fopen_works()) { - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); + if(!t518_fopen_works()) { + tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_max); curl_msnprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open", strbuff1); - curl_mfprintf(stderr, "%s\n", msgbuff); + curl_mfprintf(stderr, "%s\n", t518_msgbuff); curl_msnprintf(strbuff, sizeof(strbuff), "fopen fails with lots of fds open"); - store_errmsg(strbuff, 0); - close_file_descriptors(); + t518_store_errmsg(strbuff, 0); + t518_close_file_descriptors(); free(memchunk); return -12; } @@ -442,7 +420,7 @@ static int test_rlimit(int keep_open) /* close file descriptors unless instructed to keep them */ if(!keep_open) { - close_file_descriptors(); + t518_close_file_descriptors(); } return 0; @@ -455,14 +433,14 @@ CURLcode test(char *URL) if(!strcmp(URL, "check")) { /* used by the test script to ask if we can run this test or not */ - if(test_rlimit(FALSE)) { - curl_mfprintf(stdout, "test_rlimit problem: %s\n", msgbuff); + if(t518_test_rlimit(FALSE)) { + curl_mfprintf(stdout, "test_rlimit problem: %s\n", t518_msgbuff); return TEST_ERR_FAILURE; } return CURLE_OK; /* sure, run this! */ } - if(test_rlimit(TRUE)) { + if(t518_test_rlimit(TRUE)) { /* failure */ return TEST_ERR_MAJOR_BAD; } @@ -472,14 +450,14 @@ CURLcode test(char *URL) if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); - close_file_descriptors(); + t518_close_file_descriptors(); return TEST_ERR_MAJOR_BAD; } curl = curl_easy_init(); if(!curl) { curl_mfprintf(stderr, "curl_easy_init() failed\n"); - close_file_descriptors(); + t518_close_file_descriptors(); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } @@ -491,7 +469,7 @@ CURLcode test(char *URL) test_cleanup: - close_file_descriptors(); + t518_close_file_descriptors(); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index e1742a4afd..22be567ff7 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -29,8 +29,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index c38d6dfeba..e56f299a9a 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -48,10 +48,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -#define NUM_HANDLES 4 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index f577c82ad5..83216f5b3d 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -36,22 +36,21 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -struct Sockets { +struct t530_Sockets { curl_socket_t *sockets; int count; /* number of sockets actually stored in array */ int max_count; /* max number of sockets that fit in allocated array */ }; -struct ReadWriteSockets { - struct Sockets read, write; +struct t530_ReadWriteSockets { + struct t530_Sockets read, write; }; /** * Remove a file descriptor from a sockets array. */ -static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention) +static void t530_removeFd(struct t530_Sockets *sockets, curl_socket_t fd, + int mention) { int i; @@ -72,14 +71,15 @@ static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention) * Add a file descriptor to a sockets array. * Return 0 on success, 1 on error. */ -static int addFd(struct Sockets *sockets, curl_socket_t fd, const char *what) +static int t530_addFd(struct t530_Sockets *sockets, curl_socket_t fd, + const char *what) { /** * To ensure we only have each file descriptor once, we remove it then add * it again. */ curl_mfprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what); - removeFd(sockets, fd, 0); + t530_removeFd(sockets, fd, 0); /* * Allocate array storage when required. */ @@ -112,10 +112,10 @@ static int socket_calls = 0; /** * Callback invoked by curl to poll reading / writing of a socket. */ -static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, - void *userp, void *socketp) +static int t530_curlSocketCallback(CURL *easy, curl_socket_t s, int action, + void *userp, void *socketp) { - struct ReadWriteSockets *sockets = userp; + struct t530_ReadWriteSockets *sockets = userp; (void)easy; /* unused */ (void)socketp; /* unused */ @@ -128,16 +128,16 @@ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, } if(action == CURL_POLL_IN || action == CURL_POLL_INOUT) - if(addFd(&sockets->read, s, "read")) + if(t530_addFd(&sockets->read, s, "read")) return -1; /* bail out */ if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT) - if(addFd(&sockets->write, s, "write")) + if(t530_addFd(&sockets->write, s, "write")) return -1; if(action == CURL_POLL_REMOVE) { - removeFd(&sockets->read, s, 1); - removeFd(&sockets->write, s, 0); + t530_removeFd(&sockets->read, s, 1); + t530_removeFd(&sockets->write, s, 0); } return 0; @@ -149,7 +149,7 @@ static int timer_calls = 0; /** * Callback invoked by curl to set a timeout. */ -static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) +static int t530_curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) { struct timeval *timeout = userp; @@ -172,7 +172,7 @@ static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) /** * Check for curl completion. */ -static int checkForCompletion(CURLM *curl, int *success) +static int t530_checkForCompletion(CURLM *curl, int *success) { int result = 0; *success = 0; @@ -198,7 +198,7 @@ static int checkForCompletion(CURLM *curl, int *success) return result; } -static int getMicroSecondTimeout(struct timeval *timeout) +static int t530_getMicroSecondTimeout(struct timeval *timeout) { struct timeval now; ssize_t result; @@ -214,8 +214,8 @@ static int getMicroSecondTimeout(struct timeval *timeout) /** * Update a fd_set with all of the sockets in use. */ -static void updateFdSet(struct Sockets *sockets, fd_set* fdset, - curl_socket_t *maxFd) +static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set* fdset, + curl_socket_t *maxFd) { int i; for(i = 0; i < sockets->count; ++i) { @@ -248,9 +248,8 @@ static int socket_action(CURLM *curl, curl_socket_t s, int evBitmask, /** * Invoke curl when a file descriptor is set. */ -static int checkFdSet(CURLM *curl, - struct Sockets *sockets, fd_set *fdset, - int evBitmask, const char *name) +static int t530_checkFdSet(CURLM *curl, struct t530_Sockets *sockets, + fd_set *fdset, int evBitmask, const char *name) { int i; int result = 0; @@ -268,7 +267,7 @@ static CURLcode testone(char *URL, int timercb, int socketcb) { CURLcode res = CURLE_OK; CURL *curl = NULL; CURLM *m = NULL; - struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; + struct t530_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; int success = 0; struct timeval timeout = {0}; timeout.tv_sec = (time_t)-1; @@ -296,10 +295,10 @@ static CURLcode testone(char *URL, int timercb, int socketcb) multi_init(m); - multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback); + multi_setopt(m, CURLMOPT_SOCKETFUNCTION, t530_curlSocketCallback); multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets); - multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback); + multi_setopt(m, CURLMOPT_TIMERFUNCTION, t530_curlTimerCallback); multi_setopt(m, CURLMOPT_TIMERDATA, &timeout); multi_add_handle(m, curl); @@ -309,7 +308,7 @@ static CURLcode testone(char *URL, int timercb, int socketcb) goto test_cleanup; } - while(!checkForCompletion(m, &success)) { + while(!t530_checkForCompletion(m, &success)) { fd_set readSet, writeSet; curl_socket_t maxFd = 0; struct timeval tv = {0}; @@ -317,11 +316,11 @@ static CURLcode testone(char *URL, int timercb, int socketcb) FD_ZERO(&readSet); FD_ZERO(&writeSet); - updateFdSet(&sockets.read, &readSet, &maxFd); - updateFdSet(&sockets.write, &writeSet, &maxFd); + t530_updateFdSet(&sockets.read, &readSet, &maxFd); + t530_updateFdSet(&sockets.write, &writeSet, &maxFd); if(timeout.tv_sec != (time_t)-1) { - int usTimeout = getMicroSecondTimeout(&timeout); + int usTimeout = t530_getMicroSecondTimeout(&timeout); tv.tv_sec = usTimeout / 1000000; tv.tv_usec = usTimeout % 1000000; } @@ -334,16 +333,19 @@ static CURLcode testone(char *URL, int timercb, int socketcb) select_test((int)maxFd, &readSet, &writeSet, NULL, &tv); /* Check the sockets for reading / writing */ - if(checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read")) { + if(t530_checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, + "read")) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; } - if(checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write")) { + if(t530_checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, + "write")) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; } - if(timeout.tv_sec != (time_t)-1 && getMicroSecondTimeout(&timeout) == 0) { + if(timeout.tv_sec != (time_t)-1 && + t530_getMicroSecondTimeout(&timeout) == 0) { /* Curl's timer has elapsed. */ if(socket_action(m, CURL_SOCKET_TIMEOUT, 0, "timeout")) { res = TEST_ERR_BAD_TIMEOUT; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index be12105896..5ac43cd6bb 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -31,8 +31,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 1e4d3839ae..9bf0a7eb52 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -23,14 +23,11 @@ ***************************************************************************/ #include "test.h" -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif #ifdef HAVE_FCNTL_H #include #endif -#include +#include "testutil.h" #include "warnless.h" #include "memdebug.h" @@ -38,7 +35,7 @@ #error "this test requires FD_SETSIZE" #endif -#define SAFETY_MARGIN (11) +#define T537_SAFETY_MARGIN (11) #if defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" @@ -48,31 +45,31 @@ #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) -static int *testfd = NULL; -static struct rlimit num_open; -static char msgbuff[256]; +static int *t537_testfd = NULL; +static struct rlimit t537_num_open; +static char t537_msgbuff[256]; -static void store_errmsg(const char *msg, int err) +static void t537_store_errmsg(const char *msg, int err) { if(!err) - curl_msnprintf(msgbuff, sizeof(msgbuff), "%s", msg); + curl_msnprintf(t537_msgbuff, sizeof(t537_msgbuff), "%s", msg); else - curl_msnprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, - err, strerror(err)); + curl_msnprintf(t537_msgbuff, sizeof(t537_msgbuff), "%s, errno %d, %s", msg, + err, strerror(err)); } -static void close_file_descriptors(void) +static void t537_close_file_descriptors(void) { - for(num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) - if(testfd[num_open.rlim_cur] > 0) - close(testfd[num_open.rlim_cur]); - free(testfd); - testfd = NULL; + for(t537_num_open.rlim_cur = 0; + t537_num_open.rlim_cur < t537_num_open.rlim_max; + t537_num_open.rlim_cur++) + if(t537_testfd[t537_num_open.rlim_cur] > 0) + close(t537_testfd[t537_num_open.rlim_cur]); + free(t537_testfd); + t537_testfd = NULL; } -static int fopen_works(void) +static int t537_fopen_works(void) { FILE *fpa[3]; int i; @@ -84,8 +81,8 @@ static int fopen_works(void) for(i = 0; i < 3; i++) { fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT); if(!fpa[i]) { - store_errmsg("fopen failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t537_store_errmsg("fopen failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); ret = 0; break; } @@ -97,28 +94,7 @@ static int fopen_works(void) return ret; } -static void rlim2str(char *buf, size_t len, rlim_t val) -{ -#ifdef RLIM_INFINITY - if(val == RLIM_INFINITY) { - curl_msnprintf(buf, len, "INFINITY"); - return; - } -#endif -#ifdef HAVE_LONGLONG - if(sizeof(rlim_t) > sizeof(long)) - curl_msnprintf(buf, len, "%llu", (unsigned long long)val); - else -#endif - { - if(sizeof(rlim_t) < sizeof(long)) - curl_msnprintf(buf, len, "%u", (unsigned int)val); - else - curl_msnprintf(buf, len, "%lu", (unsigned long)val); - } -} - -static int test_rlimit(int keep_open) +static int t537_test_rlimit(int keep_open) { int *tmpfd; rlim_t nitems, i; @@ -130,17 +106,17 @@ static int test_rlimit(int keep_open) /* get initial open file limits */ if(getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t537_store_errmsg("getrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); return -1; } /* show initial open file limits */ - rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); curl_mfprintf(stderr, "initial soft limit: %s\n", strbuff); - rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); curl_mfprintf(stderr, "initial hard limit: %s\n", strbuff); /* If the OS allows a HUGE number of open files, we do not run. @@ -171,9 +147,9 @@ static int test_rlimit(int keep_open) rl.rlim_cur = OPEN_MAX; if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { /* on failure don't abort just issue a warning */ - store_errmsg("setrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); - msgbuff[0] = '\0'; + t537_store_errmsg("setrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); + t537_msgbuff[0] = '\0'; } } #endif @@ -182,25 +158,25 @@ static int test_rlimit(int keep_open) rl.rlim_cur = rl.rlim_max; if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { /* on failure don't abort just issue a warning */ - store_errmsg("setrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); - msgbuff[0] = '\0'; + t537_store_errmsg("setrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); + t537_msgbuff[0] = '\0'; } /* get current open file limits */ if(getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t537_store_errmsg("getrlimit() failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); return -3; } /* show current open file limits */ - rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur); curl_mfprintf(stderr, "current soft limit: %s\n", strbuff); - rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max); curl_mfprintf(stderr, "current hard limit: %s\n", strbuff); } /* (rl.rlim_cur != rl.rlim_max) */ @@ -229,8 +205,8 @@ static int test_rlimit(int keep_open) if(nitems > 0x7fff) nitems = 0x40000; do { - num_open.rlim_max = sizeof(*memchunk) * nitems; - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + t537_num_open.rlim_max = sizeof(*memchunk) * nitems; + tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max); curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); if(!memchunk) { @@ -239,8 +215,8 @@ static int test_rlimit(int keep_open) } } while(nitems && !memchunk); if(!memchunk) { - store_errmsg("memchunk, malloc() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + t537_store_errmsg("memchunk, malloc() failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); return -4; } @@ -258,8 +234,8 @@ static int test_rlimit(int keep_open) #else if(rl.rlim_cur > 0) { #endif - /* soft limit minus SAFETY_MARGIN */ - num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; + /* soft limit minus T537_SAFETY_MARGIN */ + t537_num_open.rlim_max = rl.rlim_cur - T537_SAFETY_MARGIN; } else { /* a huge number of file descriptors */ @@ -267,18 +243,18 @@ static int test_rlimit(int keep_open) nitems = i; if(nitems > 0x7fff) nitems = 0x40000; - num_open.rlim_max = nitems; + t537_num_open.rlim_max = nitems; } /* verify that we won't overflow size_t in malloc() */ - if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*testfd)) { - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); + if((size_t)(t537_num_open.rlim_max) > ((size_t)-1) / sizeof(*t537_testfd)) { + tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_max); curl_msnprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); + t537_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); free(memchunk); return -5; } @@ -286,19 +262,20 @@ static int test_rlimit(int keep_open) /* allocate array for file descriptors */ do { - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max); curl_mfprintf(stderr, "allocating array for %s file descriptors\n", strbuff); - testfd = malloc(sizeof(*testfd) * (size_t)(num_open.rlim_max)); - if(!testfd) { + t537_testfd = malloc(sizeof(*t537_testfd) * + (size_t)(t537_num_open.rlim_max)); + if(!t537_testfd) { curl_mfprintf(stderr, "testfd, malloc() failed\n"); - num_open.rlim_max /= 2; + t537_num_open.rlim_max /= 2; } - } while(num_open.rlim_max && !testfd); - if(!testfd) { - store_errmsg("testfd, malloc() failed", errno); - curl_mfprintf(stderr, "%s\n", msgbuff); + } while(t537_num_open.rlim_max && !t537_testfd); + if(!t537_testfd) { + t537_store_errmsg("testfd, malloc() failed", errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); free(memchunk); return -6; } @@ -307,73 +284,74 @@ static int test_rlimit(int keep_open) curl_mfprintf(stderr, "initializing testfd array\n"); - for(num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) - testfd[num_open.rlim_cur] = -1; + for(t537_num_open.rlim_cur = 0; + t537_num_open.rlim_cur < t537_num_open.rlim_max; + t537_num_open.rlim_cur++) + t537_testfd[t537_num_open.rlim_cur] = -1; - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max); curl_mfprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ - testfd[0] = open(DEV_NULL, O_RDONLY); - if(testfd[0] < 0) { + t537_testfd[0] = open(DEV_NULL, O_RDONLY); + if(t537_testfd[0] < 0) { curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); - store_errmsg(strbuff, errno); - curl_mfprintf(stderr, "%s\n", msgbuff); - free(testfd); - testfd = NULL; + t537_store_errmsg(strbuff, errno); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); + free(t537_testfd); + t537_testfd = NULL; free(memchunk); return -7; } /* create a bunch of file descriptors */ - for(num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) { + for(t537_num_open.rlim_cur = 1; + t537_num_open.rlim_cur < t537_num_open.rlim_max; + t537_num_open.rlim_cur++) { - testfd[num_open.rlim_cur] = dup(testfd[0]); + t537_testfd[t537_num_open.rlim_cur] = dup(t537_testfd[0]); - if(testfd[num_open.rlim_cur] < 0) { + if(t537_testfd[t537_num_open.rlim_cur] < 0) { - testfd[num_open.rlim_cur] = -1; + t537_testfd[t537_num_open.rlim_cur] = -1; - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); curl_mfprintf(stderr, "%s\n", strbuff); - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); curl_mfprintf(stderr, "%s\n", strbuff); - num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN; + t537_num_open.rlim_max = t537_num_open.rlim_cur - T537_SAFETY_MARGIN; - num_open.rlim_cur -= num_open.rlim_max; - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur); + t537_num_open.rlim_cur -= t537_num_open.rlim_max; + tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_cur); curl_msnprintf(strbuff, sizeof(strbuff), "closing %s file descriptors", strbuff1); curl_mfprintf(stderr, "%s\n", strbuff); - for(num_open.rlim_cur = num_open.rlim_max; - testfd[num_open.rlim_cur] >= 0; - num_open.rlim_cur++) { - close(testfd[num_open.rlim_cur]); - testfd[num_open.rlim_cur] = -1; + for(t537_num_open.rlim_cur = t537_num_open.rlim_max; + t537_testfd[t537_num_open.rlim_cur] >= 0; + t537_num_open.rlim_cur++) { + close(t537_testfd[t537_num_open.rlim_cur]); + t537_testfd[t537_num_open.rlim_cur] = -1; } - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max); curl_mfprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); /* we don't care if we can't shrink it */ - tmpfd = realloc(testfd, sizeof(*testfd) * (size_t)(num_open.rlim_max)); + tmpfd = realloc(t537_testfd, + sizeof(*t537_testfd) * (size_t)(t537_num_open.rlim_max)); if(tmpfd) { - testfd = tmpfd; + t537_testfd = tmpfd; tmpfd = NULL; } @@ -381,7 +359,7 @@ static int test_rlimit(int keep_open) } } - rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max); + tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max); curl_mfprintf(stderr, "%s file descriptors open\n", strbuff); #if !defined(HAVE_POLL) && !defined(USE_WINSOCK) @@ -397,28 +375,28 @@ static int test_rlimit(int keep_open) * with an indication that select limit would be exceeded. */ - num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; - if(num_open.rlim_max > num_open.rlim_cur) { + t537_num_open.rlim_cur = FD_SETSIZE - T537_SAFETY_MARGIN; + if(t537_num_open.rlim_max > t537_num_open.rlim_cur) { curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", - FD_SETSIZE); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); - close_file_descriptors(); + FD_SETSIZE); + t537_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); + t537_close_file_descriptors(); free(memchunk); return -8; } - num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; + t537_num_open.rlim_cur = FD_SETSIZE - T537_SAFETY_MARGIN; for(rl.rlim_cur = 0; - rl.rlim_cur < num_open.rlim_max; + rl.rlim_cur < t537_num_open.rlim_max; rl.rlim_cur++) { - if((testfd[rl.rlim_cur] > 0) && - ((unsigned int)testfd[rl.rlim_cur] > num_open.rlim_cur)) { + if((t537_testfd[rl.rlim_cur] > 0) && + ((unsigned int)t537_testfd[rl.rlim_cur] > t537_num_open.rlim_cur)) { curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", - FD_SETSIZE); - store_errmsg(strbuff, 0); - curl_mfprintf(stderr, "%s\n", msgbuff); - close_file_descriptors(); + FD_SETSIZE); + t537_store_errmsg(strbuff, 0); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); + t537_close_file_descriptors(); free(memchunk); return -9; } @@ -435,15 +413,15 @@ static int test_rlimit(int keep_open) * if it is capable of fopen()ing some additional files. */ - if(!fopen_works()) { - rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max); + if(!t537_fopen_works()) { + tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_max); curl_msnprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open", strbuff1); - curl_mfprintf(stderr, "%s\n", msgbuff); + curl_mfprintf(stderr, "%s\n", t537_msgbuff); curl_msnprintf(strbuff, sizeof(strbuff), "fopen fails with lots of fds open"); - store_errmsg(strbuff, 0); - close_file_descriptors(); + t537_store_errmsg(strbuff, 0); + t537_close_file_descriptors(); free(memchunk); return -10; } @@ -456,7 +434,7 @@ static int test_rlimit(int keep_open) /* close file descriptors unless instructed to keep them */ if(!keep_open) { - close_file_descriptors(); + t537_close_file_descriptors(); } return 0; @@ -469,14 +447,14 @@ CURLcode test(char *URL) if(!strcmp(URL, "check")) { /* used by the test script to ask if we can run this test or not */ - if(test_rlimit(FALSE)) { - curl_mfprintf(stdout, "test_rlimit problem: %s\n", msgbuff); + if(t537_test_rlimit(FALSE)) { + curl_mfprintf(stdout, "test_rlimit problem: %s\n", t537_msgbuff); return TEST_ERR_FAILURE; } return CURLE_OK; /* sure, run this! */ } - if(test_rlimit(TRUE)) { + if(t537_test_rlimit(TRUE)) { /* failure */ return TEST_ERR_MAJOR_BAD; } @@ -486,14 +464,14 @@ CURLcode test(char *URL) if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); - close_file_descriptors(); + t537_close_file_descriptors(); return TEST_ERR_MAJOR_BAD; } curl = curl_easy_init(); if(!curl) { curl_mfprintf(stderr, "curl_easy_init() failed\n"); - close_file_descriptors(); + t537_close_file_descriptors(); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } @@ -505,7 +483,7 @@ CURLcode test(char *URL) test_cleanup: - close_file_descriptors(); + t537_close_file_descriptors(); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 4202084987..1568eee534 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -38,12 +38,11 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - #define PROXY libtest_arg2 #define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] +#undef NUM_HANDLES #define NUM_HANDLES 2 static CURL *testeh[NUM_HANDLES]; diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 9b6874ca37..fd62e32c21 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -25,17 +25,21 @@ #include "memdebug.h" -static char teststring[] = -{ 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ', - 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ', - 'w', 'i', 't', 'h', ' ', 'a', 'n', ' ', - 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'}; - CURLcode test(char *URL) { CURL *curl; CURLcode res = CURLE_OK; + static const char teststring_init[] = { + 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ', + 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ', + 'w', 'i', 't', 'h', ' ', 'a', 'n', ' ', + 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'}; + + char teststring[sizeof(teststring_init)]; + + memcpy(teststring, teststring_init, sizeof(teststring_init)); + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index ce64ae41da..24b97adc22 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -33,10 +33,7 @@ #define UPLOADTHIS "this is the blurb we want to upload\n" #ifndef LIB548 -static size_t readcallback(char *ptr, - size_t size, - size_t nmemb, - void *clientp) +static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { int *counter = (int *)clientp; @@ -55,9 +52,8 @@ static size_t readcallback(char *ptr, curl_mfprintf(stderr, "READ NOT FINE!\n"); return 0; } -static curlioerr ioctlcallback(CURL *handle, - int cmd, - void *clientp) + +static curlioerr t547_ioctl_callback(CURL *handle, int cmd, void *clientp) { int *counter = (int *)clientp; (void)handle; /* unused */ @@ -67,9 +63,6 @@ static curlioerr ioctlcallback(CURL *handle, } return CURLIOE_OK; } - - - #endif CURLcode test(char *URL) @@ -100,10 +93,10 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); #else /* 547 style, which means reading the POST data from a callback */ - test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + test_setopt(curl, CURLOPT_IOCTLFUNCTION, t547_ioctl_callback); test_setopt(curl, CURLOPT_IOCTLDATA, &counter); - test_setopt(curl, CURLOPT_READFUNCTION, readcallback); + test_setopt(curl, CURLOPT_READFUNCTION, t547_read_cb); test_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index f4fde2ff83..f6216da1f8 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -30,14 +30,13 @@ #include "warnless.h" #include "memdebug.h" -struct testdata { +struct t552_testdata { char trace_ascii; /* 1 or 0 */ }; -static -void dump(const char *text, - FILE *stream, unsigned char *ptr, size_t size, - char nohex) +static void dump(const char *text, + FILE *stream, unsigned char *ptr, size_t size, + char nohex) { size_t i; size_t c; @@ -84,12 +83,11 @@ void dump(const char *text, fflush(stream); } -static -int my_trace(CURL *handle, curl_infotype type, - char *data, size_t size, - void *userp) +static int my_trace(CURL *handle, curl_infotype type, + char *data, size_t size, + void *userp) { - struct testdata *config = (struct testdata *)userp; + struct t552_testdata *config = (struct t552_testdata *)userp; const char *text; (void)handle; /* prevent compiler warning */ @@ -123,12 +121,11 @@ int my_trace(CURL *handle, curl_infotype type, return 0; } - static size_t current_offset = 0; static char databuf[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) +static size_t t552_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ size_t available = sizeof(databuf) - current_offset; /* What we have to @@ -140,9 +137,7 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) return given; } - -static size_t write_callback(char *ptr, size_t size, size_t nmemb, - void *stream) +static size_t t552_write_cb(char *ptr, size_t size, size_t nmemb, void *stream) { int amount = curlx_uztosi(size * nmemb); curl_mprintf("%.*s", amount, (char *)ptr); @@ -150,7 +145,6 @@ static size_t write_callback(char *ptr, size_t size, size_t nmemb, return size * nmemb; } - static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) { (void)clientp; @@ -164,13 +158,11 @@ static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) return CURLIOE_UNKNOWNCMD; } - - CURLcode test(char *URL) { CURL *curl; CURLcode res = CURLE_OK; - struct testdata config; + struct t552_testdata config; size_t i; static const char fill[] = "test data"; @@ -193,10 +185,10 @@ CURLcode test(char *URL) /* Setup read callback */ test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t552_read_cb); /* Write callback */ - test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + test_setopt(curl, CURLOPT_WRITEFUNCTION, t552_write_cb); /* Ioctl function */ test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index d6d7f7cdbb..111da12125 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -55,10 +55,10 @@ static size_t myreadfunc(char *ptr, size_t size, size_t nmemb, void *stream) #define NUM_HEADERS 8 #define SIZE_HEADERS 5000 -static char testbuf[SIZE_HEADERS + 100]; - CURLcode test(char *URL) { + static char testbuf[SIZE_HEADERS + 100]; + CURL *curl; CURLcode res = CURLE_FAILED_INIT; int i; diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 94e6ad7936..5c7db7a4e5 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -25,25 +25,14 @@ #include "memdebug.h" -static char testdata[]= - "this is what we post to the silly web server\n"; - -struct WriteThis { - char *readptr; +struct t554_WriteThis { + const char *readptr; size_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t554_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { -#ifdef LIB587 - (void)ptr; - (void)size; - (void)nmemb; - (void)userp; - return CURL_READFUNC_ABORT; -#else - - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t554_WriteThis *pooh = (struct t554_WriteThis *)userp; if(size*nmemb < 1) return 0; @@ -56,19 +45,21 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) } return 0; /* no more data left to deliver */ -#endif } -static CURLcode test_once(char *URL, bool oldstyle) +static CURLcode t554_test_once(char *URL, bool oldstyle) { + static const char testdata[] = + "this is what we post to the silly web server\n"; + CURL *curl; CURLcode res = CURLE_OK; CURLFORMcode formrc; struct curl_httppost *formpost = NULL; struct curl_httppost *lastptr = NULL; - struct WriteThis pooh; - struct WriteThis pooh2; + struct t554_WriteThis pooh; + struct t554_WriteThis pooh2; pooh.readptr = testdata; pooh.sizeleft = strlen(testdata); @@ -162,7 +153,7 @@ static CURLcode test_once(char *URL, bool oldstyle) test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t554_read_cb); /* send a multi-part formpost */ test_setopt(curl, CURLOPT_HTTPPOST, formpost); @@ -196,9 +187,9 @@ CURLcode test(char *URL) return TEST_ERR_MAJOR_BAD; } - res = test_once(URL, TRUE); /* old */ + res = t554_test_once(URL, TRUE); /* old */ if(!res) - res = test_once(URL, FALSE); /* new */ + res = t554_test_once(URL, FALSE); /* new */ curl_global_cleanup(); diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index a63fc21784..9da9da368e 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -35,15 +35,9 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 +static const char uploadthis[] = "this is the blurb we want to upload\n"; -static const char uploadthis[] = - "this is the blurb we want to upload\n"; - -static size_t readcallback(char *ptr, - size_t size, - size_t nmemb, - void *clientp) +static size_t t555_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { int *counter = (int *)clientp; @@ -62,9 +56,8 @@ static size_t readcallback(char *ptr, curl_mfprintf(stderr, "READ NOT FINE!\n"); return 0; } -static curlioerr ioctlcallback(CURL *handle, - int cmd, - void *clientp) + +static curlioerr t555_ioctl_callback(CURL *handle, int cmd, void *clientp) { int *counter = (int *)clientp; (void)handle; /* unused */ @@ -95,10 +88,10 @@ CURLcode test(char *URL) easy_setopt(curl, CURLOPT_HEADER, 1L); /* read the POST data from a callback */ - easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + easy_setopt(curl, CURLOPT_IOCTLFUNCTION, t555_ioctl_callback); easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); - easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); + easy_setopt(curl, CURLOPT_READFUNCTION, t555_read_cb); easy_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 95b62ce784..6d392e6a4f 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -27,8 +27,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* * Simply download an HTTPS file! * diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index 11c9ab6e7b..d1c819182e 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -29,8 +29,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index f3e68c2da3..76935e01b1 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -30,14 +30,9 @@ #include #endif +#include "testutil.h" #include "memdebug.h" -/* build request url */ -static char *suburl(const char *base, int i) -{ - return curl_maprintf("%s%.4d", base, i); -} - /* * Test the Client->Server ANNOUNCE functionality (PUT style) */ @@ -69,7 +64,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_URL, URL); - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -110,7 +105,7 @@ CURLcode test(char *URL) sdpf = NULL; /* Make sure we can do a normal request now */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -126,7 +121,7 @@ CURLcode test(char *URL) /* Now do a POST style one */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -156,7 +151,7 @@ CURLcode test(char *URL) custom_headers = NULL; /* Make sure we can do a normal request now */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index f5d124f4d9..6ee9c15d36 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -22,13 +22,9 @@ * ***************************************************************************/ #include "test.h" -#include "memdebug.h" -/* build request url */ -static char *suburl(const char *base, int i) -{ - return curl_maprintf("%s%.4d", base, i); -} +#include "testutil.h" +#include "memdebug.h" /* * Test Session ID capture @@ -79,7 +75,7 @@ CURLcode test(char *URL) /* Go through the various Session IDs */ for(i = 0; i < 3; i++) { - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -99,7 +95,7 @@ CURLcode test(char *URL) curl_mfprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); rtsp_session_id = NULL; - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 8f803b656a..8c7831e5a0 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -22,13 +22,9 @@ * ***************************************************************************/ #include "test.h" -#include "memdebug.h" -/* build request url */ -static char *suburl(const char *base, int i) -{ - return curl_maprintf("%s%.4d", base, i); -} +#include "testutil.h" +#include "memdebug.h" CURLcode test(char *URL) { @@ -57,7 +53,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -78,7 +74,7 @@ CURLcode test(char *URL) "RAW/RAW/UDP;unicast;client_port=3056-3057"); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -93,7 +89,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index fe0f7e05ef..d0025486b1 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -39,6 +39,7 @@ # include #endif +#include "testutil.h" #include "warnless.h" #include "memdebug.h" @@ -48,12 +49,13 @@ ((int)((unsigned char)((p)[3])))) #define RTP_DATA_SIZE 12 -static const char *RTP_DATA = "$_1234\n\0Rsdf"; static int rtp_packet_count = 0; static size_t rtp_write(char *ptr, size_t size, size_t nmemb, void *stream) { + static const char *RTP_DATA = "$_1234\n\0Rsdf"; + char *data = (char *)ptr; int channel = RTP_PKT_CHANNEL(data); int message_size; @@ -95,12 +97,6 @@ static size_t rtp_write(char *ptr, size_t size, size_t nmemb, void *stream) return size * nmemb; } -/* build request url */ -static char *suburl(const char *base, int i) -{ - return curl_maprintf("%s%.4d", base, i); -} - CURLcode test(char *URL) { CURLcode res; @@ -129,7 +125,7 @@ CURLcode test(char *URL) } test_setopt(curl, CURLOPT_URL, URL); - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -151,7 +147,7 @@ CURLcode test(char *URL) goto test_cleanup; /* This PLAY starts the interleave */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -166,7 +162,7 @@ CURLcode test(char *URL) goto test_cleanup; /* The DESCRIBE request will try to consume data after the Content */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -180,7 +176,7 @@ CURLcode test(char *URL) if(res) goto test_cleanup; - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 5f57221134..8f5d2f1d46 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -30,14 +30,9 @@ #include #endif +#include "testutil.h" #include "memdebug.h" -/* build request url */ -static char *suburl(const char *base, int i) -{ - return curl_maprintf("%s%.4d", base, i); -} - /* * Test GET_PARAMETER: PUT, HEARTBEAT, and POST */ @@ -72,7 +67,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_URL, URL); /* SETUP */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -87,7 +82,7 @@ CURLcode test(char *URL) if(res) goto test_cleanup; - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -127,7 +122,7 @@ CURLcode test(char *URL) paramsf = NULL; /* Heartbeat GET_PARAMETERS */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -142,7 +137,7 @@ CURLcode test(char *URL) /* POST GET_PARAMETERS */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -161,7 +156,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POSTFIELDS, NULL); /* Make sure we can do a normal request now */ - stream_uri = suburl(URL, request++); + stream_uri = tutil_suburl(URL, request++); if(!stream_uri) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 40af2212c9..bcd0e90bdb 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -28,8 +28,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c index 4675f2d60f..696668fc6e 100644 --- a/tests/libtest/lib574.c +++ b/tests/libtest/lib574.c @@ -25,8 +25,6 @@ #include "memdebug.h" -#define TEST_HANG_TIMEOUT (60 * 1000) - static int new_fnmatch(void *ptr, const char *pattern, const char *string) { diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index d64f70d737..d02e64aaee 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -29,8 +29,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* 3x download! * 1. normal * 2. dup handle diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 014fd896ac..a78e7b8ab3 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -31,8 +31,7 @@ struct chunk_data { int print_content; }; -static -long chunk_bgn(const void *f, void *ptr, int remains) +static long chunk_bgn(const void *f, void *ptr, int remains) { const struct curl_fileinfo *finfo = f; struct chunk_data *ch_d = ptr; @@ -83,8 +82,7 @@ long chunk_bgn(const void *f, void *ptr, int remains) return CURL_CHUNK_BGN_FUNC_OK; } -static -long chunk_end(void *ptr) +static long chunk_end(void *ptr) { struct chunk_data *ch_d = ptr; if(ch_d->print_content) { diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c index 33b807afb0..9fd6aaaea3 100644 --- a/tests/libtest/lib578.c +++ b/tests/libtest/lib578.c @@ -26,12 +26,12 @@ #include "memdebug.h" /* The size of data should be kept below MAX_INITIAL_POST_SIZE! */ -static char testdata[]="this is a short string.\n"; +static char t578_testdata[] = "this is a short string.\n"; -static size_t data_size = CURL_ARRAYSIZE(testdata); +static size_t data_size = CURL_ARRAYSIZE(t578_testdata); -static int progress_callback(void *clientp, double dltotal, double dlnow, - double ultotal, double ulnow) +static int t578_progress_callback(void *clientp, double dltotal, double dlnow, + double ultotal, double ulnow) { FILE *moo = fopen(libtest_arg2, "wb"); @@ -44,7 +44,7 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, curl_mfprintf(moo, "PASSED, UL data matched data size\n"); else curl_mfprintf(moo, "Progress callback called with UL %f out of %f\n", - ulnow, ultotal); + ulnow, ultotal); fclose(moo); } return 0; @@ -75,11 +75,11 @@ CURLcode test(char *URL) /* Set the expected POST size */ test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)data_size); - test_setopt(curl, CURLOPT_POSTFIELDS, testdata); + test_setopt(curl, CURLOPT_POSTFIELDS, t578_testdata); /* we want to use our own progress function */ test_setopt(curl, CURLOPT_NOPROGRESS, 0L); - test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + test_setopt(curl, CURLOPT_PROGRESSFUNCTION, t578_progress_callback); /* get verbose debug output please */ test_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index 8bc9e2a7cd..e6f8945e42 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -25,16 +25,7 @@ #include "memdebug.h" -static const char * const testpost[]={ - "one", - "two", - "three", - "and a final longer crap: four", - NULL -}; - - -struct WriteThis { +struct t579_WriteThis { int counter; }; @@ -54,8 +45,8 @@ static void progress_final_report(void) started = FALSE; } -static int progress_callback(void *clientp, double dltotal, double dlnow, - double ultotal, double ulnow) +static int t579_progress_callback(void *clientp, double dltotal, double dlnow, + double ultotal, double ulnow) { (void)clientp; /* UNUSED */ (void)dltotal; /* UNUSED */ @@ -70,7 +61,7 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, if(!started) { FILE *moo = fopen(libtest_arg2, "ab"); curl_mfprintf(moo ? moo : stderr, "Progress: start UL %zu/%zu\n", - last_ul, last_ul_total); + last_ul, last_ul_total); if(moo) fclose(moo); else @@ -82,9 +73,17 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, return 0; } -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t579_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + static const char * const testpost[] = { + "one", + "two", + "three", + "and a final longer crap: four", + NULL + }; + + struct t579_WriteThis *pooh = (struct t579_WriteThis *)userp; const char *data; if(size*nmemb < 1) @@ -106,7 +105,7 @@ CURLcode test(char *URL) CURL *curl; CURLcode res = CURLE_OK; struct curl_slist *slist = NULL; - struct WriteThis pooh; + struct t579_WriteThis pooh; pooh.counter = 0; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { @@ -136,7 +135,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_POST, 1L); /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, t579_read_cb); /* pointer to pass to our read function */ test_setopt(curl, CURLOPT_READDATA, &pooh); @@ -155,7 +154,7 @@ CURLcode test(char *URL) /* we want to use our own progress function */ test_setopt(curl, CURLOPT_NOPROGRESS, 0L); - test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + test_setopt(curl, CURLOPT_PROGRESSFUNCTION, t579_progress_callback); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 2d2f2bcb7a..bb1fb5e611 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -29,22 +29,21 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - -struct Sockets { +struct t582_Sockets { curl_socket_t *sockets; int count; /* number of sockets actually stored in array */ int max_count; /* max number of sockets that fit in allocated array */ }; -struct ReadWriteSockets { - struct Sockets read, write; +struct t582_ReadWriteSockets { + struct t582_Sockets read, write; }; /** * Remove a file descriptor from a sockets array. */ -static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention) +static void t582_removeFd(struct t582_Sockets *sockets, curl_socket_t fd, + int mention) { int i; @@ -64,14 +63,15 @@ static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention) /** * Add a file descriptor to a sockets array. */ -static void addFd(struct Sockets *sockets, curl_socket_t fd, const char *what) +static void t582_addFd(struct t582_Sockets *sockets, curl_socket_t fd, + const char *what) { /** * To ensure we only have each file descriptor once, we remove it then add * it again. */ curl_mfprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what); - removeFd(sockets, fd, 0); + t582_removeFd(sockets, fd, 0); /* * Allocate array storage when required. */ @@ -96,23 +96,23 @@ static void addFd(struct Sockets *sockets, curl_socket_t fd, const char *what) /** * Callback invoked by curl to poll reading / writing of a socket. */ -static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, - void *userp, void *socketp) +static int t582_curlSocketCallback(CURL *easy, curl_socket_t s, int action, + void *userp, void *socketp) { - struct ReadWriteSockets *sockets = userp; + struct t582_ReadWriteSockets *sockets = userp; (void)easy; /* unused */ (void)socketp; /* unused */ if(action == CURL_POLL_IN || action == CURL_POLL_INOUT) - addFd(&sockets->read, s, "read"); + t582_addFd(&sockets->read, s, "read"); if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT) - addFd(&sockets->write, s, "write"); + t582_addFd(&sockets->write, s, "write"); if(action == CURL_POLL_REMOVE) { - removeFd(&sockets->read, s, 1); - removeFd(&sockets->write, s, 0); + t582_removeFd(&sockets->read, s, 1); + t582_removeFd(&sockets->write, s, 0); } return 0; @@ -121,7 +121,7 @@ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, /** * Callback invoked by curl to set a timeout. */ -static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) +static int t582_curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) { struct timeval *timeout = userp; @@ -139,7 +139,7 @@ static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) /** * Check for curl completion. */ -static int checkForCompletion(CURLM *curl, int *success) +static int t582_checkForCompletion(CURLM *curl, int *success) { int result = 0; *success = 0; @@ -165,7 +165,7 @@ static int checkForCompletion(CURLM *curl, int *success) return result; } -static int getMicroSecondTimeout(struct timeval *timeout) +static int t582_getMicroSecondTimeout(struct timeval *timeout) { struct timeval now; ssize_t result; @@ -181,8 +181,8 @@ static int getMicroSecondTimeout(struct timeval *timeout) /** * Update a fd_set with all of the sockets in use. */ -static void updateFdSet(struct Sockets *sockets, fd_set* fdset, - curl_socket_t *maxFd) +static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set* fdset, + curl_socket_t *maxFd) { int i; for(i = 0; i < sockets->count; ++i) { @@ -214,8 +214,8 @@ static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask, /** * Invoke curl when a file descriptor is set. */ -static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset, - int evBitmask, const char *name) +static void t582_checkFdSet(CURLM *curl, struct t582_Sockets *sockets, + fd_set *fdset, int evBitmask, const char *name) { int i; for(i = 0; i < sockets->count; ++i) { @@ -233,7 +233,7 @@ CURLcode test(char *URL) int hd; struct_stat file_info; CURLM *m = NULL; - struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; + struct t582_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; int success = 0; struct timeval timeout = {0}; timeout.tv_sec = (time_t)-1; @@ -300,15 +300,15 @@ CURLcode test(char *URL) multi_init(m); - multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback); + multi_setopt(m, CURLMOPT_SOCKETFUNCTION, t582_curlSocketCallback); multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets); - multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback); + multi_setopt(m, CURLMOPT_TIMERFUNCTION, t582_curlTimerCallback); multi_setopt(m, CURLMOPT_TIMERDATA, &timeout); multi_add_handle(m, curl); - while(!checkForCompletion(m, &success)) { + while(!t582_checkForCompletion(m, &success)) { fd_set readSet, writeSet; curl_socket_t maxFd = 0; struct timeval tv = {0}; @@ -316,11 +316,11 @@ CURLcode test(char *URL) FD_ZERO(&readSet); FD_ZERO(&writeSet); - updateFdSet(&sockets.read, &readSet, &maxFd); - updateFdSet(&sockets.write, &writeSet, &maxFd); + t582_updateFdSet(&sockets.read, &readSet, &maxFd); + t582_updateFdSet(&sockets.write, &writeSet, &maxFd); if(timeout.tv_sec != (time_t)-1) { - int usTimeout = getMicroSecondTimeout(&timeout); + int usTimeout = t582_getMicroSecondTimeout(&timeout); tv.tv_sec = usTimeout / 1000000; tv.tv_usec = usTimeout % 1000000; } @@ -332,10 +332,11 @@ CURLcode test(char *URL) select_test((int)maxFd, &readSet, &writeSet, NULL, &tv); /* Check the sockets for reading / writing */ - checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read"); - checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write"); + t582_checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read"); + t582_checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write"); - if(timeout.tv_sec != (time_t)-1 && getMicroSecondTimeout(&timeout) == 0) { + if(timeout.tv_sec != (time_t)-1 && + t582_getMicroSecondTimeout(&timeout) == 0) { /* Curl's timer has elapsed. */ notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout"); } diff --git a/tests/libtest/lib586.c b/tests/libtest/lib586.c index 2712df74f7..1cb3cf0ab9 100644 --- a/tests/libtest/lib586.c +++ b/tests/libtest/lib586.c @@ -27,22 +27,22 @@ #define THREADS 2 /* struct containing data of a thread */ -struct Tdata { +struct t586_Tdata { CURLSH *share; char *url; }; -struct userdata { +struct t586_userdata { const char *text; int counter; }; /* lock callback */ -static void test_lock(CURL *handle, curl_lock_data data, - curl_lock_access laccess, void *useptr) +static void t586_test_lock(CURL *handle, curl_lock_data data, + curl_lock_access laccess, void *useptr) { const char *what; - struct userdata *user = (struct userdata *)useptr; + struct t586_userdata *user = (struct t586_userdata *)useptr; (void)handle; (void)laccess; @@ -69,10 +69,10 @@ static void test_lock(CURL *handle, curl_lock_data data, } /* unlock callback */ -static void test_unlock(CURL *handle, curl_lock_data data, void *useptr) +static void t586_test_unlock(CURL *handle, curl_lock_data data, void *useptr) { const char *what; - struct userdata *user = (struct userdata *)useptr; + struct t586_userdata *user = (struct t586_userdata *)useptr; (void)handle; switch(data) { case CURL_LOCK_DATA_SHARE: @@ -96,10 +96,10 @@ static void test_unlock(CURL *handle, curl_lock_data data, void *useptr) } /* the dummy thread function */ -static void *test_fire(void *ptr) +static void *t586_test_fire(void *ptr) { CURLcode code; - struct Tdata *tdata = (struct Tdata*)ptr; + struct t586_Tdata *tdata = (struct t586_Tdata*)ptr; CURL *curl; curl = curl_easy_init(); @@ -134,11 +134,11 @@ CURLcode test(char *URL) CURLcode res = CURLE_OK; CURLSHcode scode = CURLSHE_OK; char *url; - struct Tdata tdata; + struct t586_Tdata tdata; CURL *curl; CURLSH *share; int i; - struct userdata user; + struct t586_userdata user; user.text = "Pigs in space"; user.counter = 0; @@ -160,11 +160,11 @@ CURLcode test(char *URL) if(CURLSHE_OK == scode) { curl_mprintf("CURLSHOPT_LOCKFUNC\n"); - scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock); + scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t586_test_lock); } if(CURLSHE_OK == scode) { curl_mprintf("CURLSHOPT_UNLOCKFUNC\n"); - scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock); + scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t586_test_unlock); } if(CURLSHE_OK == scode) { curl_mprintf("CURLSHOPT_USERDATA\n"); @@ -193,7 +193,7 @@ CURLcode test(char *URL) /* simulate thread, direct call of "thread" function */ curl_mprintf("*** run %d\n",i); - test_fire(&tdata); + t586_test_fire(&tdata); } diff --git a/tests/libtest/lib587.c b/tests/libtest/lib587.c new file mode 100644 index 0000000000..ea9862e935 --- /dev/null +++ b/tests/libtest/lib587.c @@ -0,0 +1,189 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +#include "test.h" + +#include "memdebug.h" + +struct t587_WriteThis { + const char *readptr; + size_t sizeleft; +}; + +static size_t t587_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) +{ + (void)ptr; + (void)size; + (void)nmemb; + (void)userp; + return CURL_READFUNC_ABORT; +} + +static CURLcode t587_test_once(char *URL, bool oldstyle) +{ + static const char testdata[] = + "this is what we post to the silly web server\n"; + + CURL *curl; + CURLcode res = CURLE_OK; + CURLFORMcode formrc; + + struct curl_httppost *formpost = NULL; + struct curl_httppost *lastptr = NULL; + struct t587_WriteThis pooh; + struct t587_WriteThis pooh2; + + pooh.readptr = testdata; + pooh.sizeleft = strlen(testdata); + + /* Fill in the file upload field */ + if(oldstyle) { + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile", + CURLFORM_STREAM, &pooh, + CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft, + CURLFORM_FILENAME, "postit2.c", + CURLFORM_END); + } + else { + /* new style */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile alternative", + CURLFORM_STREAM, &pooh, + CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft, + CURLFORM_FILENAME, "file name 2", + CURLFORM_END); + } + + if(formrc) + curl_mprintf("curl_formadd(1) = %d\n", (int)formrc); + + /* Now add the same data with another name and make it not look like + a file upload but still using the callback */ + + pooh2.readptr = testdata; + pooh2.sizeleft = strlen(testdata); + + /* Fill in the file upload field */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "callbackdata", + CURLFORM_STREAM, &pooh2, + CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft, + CURLFORM_END); + + if(formrc) + curl_mprintf("curl_formadd(2) = %d\n", (int)formrc); + + /* Fill in the filename field */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "filename", + CURLFORM_COPYCONTENTS, "postit2.c", + CURLFORM_END); + if(formrc) + curl_mprintf("curl_formadd(3) = %d\n", (int)formrc); + + /* Fill in a submit field too */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "submit", + CURLFORM_COPYCONTENTS, "send", + CURLFORM_CONTENTTYPE, "text/plain", + CURLFORM_END); + + if(formrc) + curl_mprintf("curl_formadd(4) = %d\n", (int)formrc); + + formrc = curl_formadd(&formpost, &lastptr, + CURLFORM_COPYNAME, "somename", + CURLFORM_BUFFER, "somefile.txt", + CURLFORM_BUFFERPTR, "blah blah", + CURLFORM_BUFFERLENGTH, (long)9, + CURLFORM_END); + + if(formrc) + curl_mprintf("curl_formadd(5) = %d\n", (int)formrc); + + curl = curl_easy_init(); + if(!curl) { + curl_mfprintf(stderr, "curl_easy_init() failed\n"); + curl_formfree(formpost); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* First set the URL that is about to receive our POST. */ + test_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + test_setopt(curl, CURLOPT_POST, 1L); + + /* Set the expected POST size */ + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); + + /* we want to use our own read function */ + test_setopt(curl, CURLOPT_READFUNCTION, t587_read_cb); + + /* send a multi-part formpost */ + test_setopt(curl, CURLOPT_HTTPPOST, formpost); + + /* get verbose debug output please */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* include headers in the output */ + test_setopt(curl, CURLOPT_HEADER, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + +test_cleanup: + + /* always cleanup */ + curl_easy_cleanup(curl); + + /* now cleanup the formpost chain */ + curl_formfree(formpost); + + return res; +} + +CURLcode test(char *URL) +{ + CURLcode res; + + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + curl_mfprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + res = t587_test_once(URL, TRUE); /* old */ + if(!res) + res = t587_test_once(URL, FALSE); /* new */ + + curl_global_cleanup(); + + return res; +} diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c index ce2b855a41..1f75770920 100644 --- a/tests/libtest/lib591.c +++ b/tests/libtest/lib591.c @@ -33,8 +33,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - CURLcode test(char *URL) { CURL *easy = NULL; diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index 71535b041d..d040f9a781 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -29,8 +29,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 - /* * Test case for below scenario: * - Connect to an FTP server using CONNECT_ONLY option diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c index d9ee121daf..9525dbbfe4 100644 --- a/tests/libtest/lib599.c +++ b/tests/libtest/lib599.c @@ -25,8 +25,8 @@ #include "memdebug.h" -static int progress_callback(void *clientp, double dltotal, - double dlnow, double ultotal, double ulnow) +static int t599_progress_callback(void *clientp, double dltotal, + double dlnow, double ultotal, double ulnow) { (void)clientp; (void)ulnow; @@ -64,7 +64,7 @@ CURLcode test(char *URL) /* we want to use our own progress function */ test_setopt(curl, CURLOPT_NOPROGRESS, 0L); - test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + test_setopt(curl, CURLOPT_PROGRESSFUNCTION, t599_progress_callback); /* get verbose debug output please */ test_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib643.c b/tests/libtest/lib643.c index 49ab41bb12..7181a28177 100644 --- a/tests/libtest/lib643.c +++ b/tests/libtest/lib643.c @@ -25,29 +25,22 @@ #include "memdebug.h" -static char testdata[]= - "dummy\n"; - -struct WriteThis { - char *readptr; +struct t643_WriteThis { + const char *readptr; curl_off_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t643_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t643_WriteThis *pooh = (struct t643_WriteThis *)userp; int eof; if(size*nmemb < 1) return 0; -#ifdef LIB645 - eof = !*pooh->readptr; -#else eof = pooh->sizeleft <= 0; if(!eof) pooh->sizeleft--; -#endif if(!eof) { *ptr = *pooh->readptr; /* copy one single byte */ @@ -58,21 +51,21 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) return 0; /* no more data left to deliver */ } -static CURLcode test_once(char *URL, bool oldstyle) +static CURLcode t643_test_once(char *URL, bool oldstyle) { + static const char testdata[] = "dummy\n"; + CURL *curl; CURLcode res = CURLE_OK; curl_mime *mime = NULL; curl_mimepart *part = NULL; - struct WriteThis pooh; - struct WriteThis pooh2; + struct t643_WriteThis pooh; + struct t643_WriteThis pooh2; curl_off_t datasize = -1; pooh.readptr = testdata; -#ifndef LIB645 datasize = (curl_off_t)strlen(testdata); -#endif pooh.sizeleft = datasize; curl = curl_easy_init(); @@ -103,7 +96,7 @@ static CURLcode test_once(char *URL, bool oldstyle) if(oldstyle) { res = curl_mime_name(part, "sendfile"); if(!res) - res = curl_mime_data_cb(part, datasize, read_callback, + res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh); if(!res) res = curl_mime_filename(part, "postit2.c"); @@ -112,7 +105,7 @@ static CURLcode test_once(char *URL, bool oldstyle) /* new style */ res = curl_mime_name(part, "sendfile alternative"); if(!res) - res = curl_mime_data_cb(part, datasize, read_callback, + res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh); if(!res) res = curl_mime_filename(part, "file name 2"); @@ -125,9 +118,7 @@ static CURLcode test_once(char *URL, bool oldstyle) a file upload but still using the callback */ pooh2.readptr = testdata; -#ifndef LIB645 datasize = (curl_off_t)strlen(testdata); -#endif pooh2.sizeleft = datasize; part = curl_mime_addpart(mime); @@ -141,7 +132,7 @@ static CURLcode test_once(char *URL, bool oldstyle) /* Fill in the file upload part */ res = curl_mime_name(part, "callbackdata"); if(!res) - res = curl_mime_data_cb(part, datasize, read_callback, + res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh2); if(res) @@ -225,7 +216,7 @@ test_cleanup: return res; } -static CURLcode cyclic_add(void) +static CURLcode t643_cyclic_add(void) { CURL *easy = curl_easy_init(); curl_mime *mime = curl_mime_init(easy); @@ -258,12 +249,12 @@ CURLcode test(char *URL) return TEST_ERR_MAJOR_BAD; } - res = test_once(URL, TRUE); /* old */ + res = t643_test_once(URL, TRUE); /* old */ if(!res) - res = test_once(URL, FALSE); /* new */ + res = t643_test_once(URL, FALSE); /* new */ if(!res) - res = cyclic_add(); + res = t643_cyclic_add(); curl_global_cleanup(); diff --git a/tests/libtest/lib645.c b/tests/libtest/lib645.c new file mode 100644 index 0000000000..7e3196bc65 --- /dev/null +++ b/tests/libtest/lib645.c @@ -0,0 +1,258 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +#include "test.h" + +#include "memdebug.h" + +struct t645_WriteThis { + const char *readptr; + curl_off_t sizeleft; +}; + +static size_t t645_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) +{ + struct t645_WriteThis *pooh = (struct t645_WriteThis *)userp; + int eof; + + if(size*nmemb < 1) + return 0; + + eof = !*pooh->readptr; + + if(!eof) { + *ptr = *pooh->readptr; /* copy one single byte */ + pooh->readptr++; /* advance pointer */ + return 1; /* we return 1 byte at a time! */ + } + + return 0; /* no more data left to deliver */ +} + +static CURLcode t645_test_once(char *URL, bool oldstyle) +{ + static const char testdata[] = "dummy\n"; + + CURL *curl; + CURLcode res = CURLE_OK; + + curl_mime *mime = NULL; + curl_mimepart *part = NULL; + struct t645_WriteThis pooh; + struct t645_WriteThis pooh2; + curl_off_t datasize = -1; + + pooh.readptr = testdata; + pooh.sizeleft = datasize; + + curl = curl_easy_init(); + if(!curl) { + curl_mfprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + mime = curl_mime_init(curl); + if(!mime) { + curl_mfprintf(stderr, "curl_mime_init() failed\n"); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + part = curl_mime_addpart(mime); + if(!part) { + curl_mfprintf(stderr, "curl_mime_addpart(1) failed\n"); + curl_mime_free(mime); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* Fill in the file upload part */ + if(oldstyle) { + res = curl_mime_name(part, "sendfile"); + if(!res) + res = curl_mime_data_cb(part, datasize, t645_read_cb, + NULL, NULL, &pooh); + if(!res) + res = curl_mime_filename(part, "postit2.c"); + } + else { + /* new style */ + res = curl_mime_name(part, "sendfile alternative"); + if(!res) + res = curl_mime_data_cb(part, datasize, t645_read_cb, + NULL, NULL, &pooh); + if(!res) + res = curl_mime_filename(part, "file name 2"); + } + + if(res) + curl_mprintf("curl_mime_xxx(1) = %s\n", curl_easy_strerror(res)); + + /* Now add the same data with another name and make it not look like + a file upload but still using the callback */ + + pooh2.readptr = testdata; + pooh2.sizeleft = datasize; + + part = curl_mime_addpart(mime); + if(!part) { + curl_mfprintf(stderr, "curl_mime_addpart(2) failed\n"); + curl_mime_free(mime); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + /* Fill in the file upload part */ + res = curl_mime_name(part, "callbackdata"); + if(!res) + res = curl_mime_data_cb(part, datasize, t645_read_cb, + NULL, NULL, &pooh2); + + if(res) + curl_mprintf("curl_mime_xxx(2) = %s\n", curl_easy_strerror(res)); + + part = curl_mime_addpart(mime); + if(!part) { + curl_mfprintf(stderr, "curl_mime_addpart(3) failed\n"); + curl_mime_free(mime); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* Fill in the filename field */ + res = curl_mime_name(part, "filename"); + if(!res) + res = curl_mime_data(part, "postit2.c", + CURL_ZERO_TERMINATED); + + if(res) + curl_mprintf("curl_mime_xxx(3) = %s\n", curl_easy_strerror(res)); + + /* Fill in a submit field too */ + part = curl_mime_addpart(mime); + if(!part) { + curl_mfprintf(stderr, "curl_mime_addpart(4) failed\n"); + curl_mime_free(mime); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + res = curl_mime_name(part, "submit"); + if(!res) + res = curl_mime_data(part, "send", + CURL_ZERO_TERMINATED); + + if(res) + curl_mprintf("curl_mime_xxx(4) = %s\n", curl_easy_strerror(res)); + + part = curl_mime_addpart(mime); + if(!part) { + curl_mfprintf(stderr, "curl_mime_addpart(5) failed\n"); + curl_mime_free(mime); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + res = curl_mime_name(part, "somename"); + if(!res) + res = curl_mime_filename(part, "somefile.txt"); + if(!res) + res = curl_mime_data(part, "blah blah", 9); + + if(res) + curl_mprintf("curl_mime_xxx(5) = %s\n", curl_easy_strerror(res)); + + /* First set the URL that is about to receive our POST. */ + test_setopt(curl, CURLOPT_URL, URL); + + /* send a multi-part mimepost */ + test_setopt(curl, CURLOPT_MIMEPOST, mime); + + /* get verbose debug output please */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* include headers in the output */ + test_setopt(curl, CURLOPT_HEADER, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + +test_cleanup: + + /* always cleanup */ + curl_easy_cleanup(curl); + + /* now cleanup the mimepost structure */ + curl_mime_free(mime); + + return res; +} + +static CURLcode t645_cyclic_add(void) +{ + CURL *easy = curl_easy_init(); + curl_mime *mime = curl_mime_init(easy); + curl_mimepart *part = curl_mime_addpart(mime); + CURLcode a1 = curl_mime_subparts(part, mime); + + if(a1 == CURLE_BAD_FUNCTION_ARGUMENT) { + curl_mime *submime = curl_mime_init(easy); + curl_mimepart *subpart = curl_mime_addpart(submime); + + curl_mime_subparts(part, submime); + a1 = curl_mime_subparts(subpart, mime); + } + + curl_mime_free(mime); + curl_easy_cleanup(easy); + if(a1 != CURLE_BAD_FUNCTION_ARGUMENT) + /* that should have failed */ + return TEST_ERR_FAILURE; + + return CURLE_OK; +} + +CURLcode test(char *URL) +{ + CURLcode res; + + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + curl_mfprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + res = t645_test_once(URL, TRUE); /* old */ + if(!res) + res = t645_test_once(URL, FALSE); /* new */ + + if(!res) + res = t645_cyclic_add(); + + curl_global_cleanup(); + + return res; +} diff --git a/tests/libtest/lib650.c b/tests/libtest/lib650.c index 59f5ba925e..4fa1571be1 100644 --- a/tests/libtest/lib650.c +++ b/tests/libtest/lib650.c @@ -25,13 +25,6 @@ #include "memdebug.h" - -static char testdata[] = - "this is what we post to the silly web server"; - -static const char testname[] = "fieldname"; - - /* This test attempts to use all form API features that are not * used elsewhere. */ @@ -60,6 +53,10 @@ CURLcode test(char *URL) char flbuf[32]; long contentlength = 0; + static const char testname[] = "fieldname"; + static char testdata[] = + "this is what we post to the silly web server"; + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib651.c b/tests/libtest/lib651.c index 856ccd123d..84e8d89fe8 100644 --- a/tests/libtest/lib651.c +++ b/tests/libtest/lib651.c @@ -25,10 +25,10 @@ #include "memdebug.h" -static char testbuf[17000]; /* more than 16K */ - CURLcode test(char *URL) { + static char testbuf[17000]; /* more than 16K */ + CURL *curl; CURLcode res = CURLE_OK; CURLFORMcode formrc; diff --git a/tests/libtest/lib652.c b/tests/libtest/lib652.c index d6be151b18..e01fbee54b 100644 --- a/tests/libtest/lib652.c +++ b/tests/libtest/lib652.c @@ -25,10 +25,10 @@ #include "memdebug.h" -static char testbuf[17000]; /* more than 16K */ - CURLcode test(char *URL) { + static char testbuf[17000]; /* more than 16K */ + CURL *curl = NULL; CURLcode res = CURLE_OK; curl_mime *mime = NULL; diff --git a/tests/libtest/lib654.c b/tests/libtest/lib654.c index 6a2daee3d9..72236c249d 100644 --- a/tests/libtest/lib654.c +++ b/tests/libtest/lib654.c @@ -25,25 +25,22 @@ #include "memdebug.h" -static char testdata[]= - "dummy\n"; - -struct WriteThis { - char *readptr; +struct t654_WriteThis { + const char *readptr; curl_off_t sizeleft; int freecount; }; static void free_callback(void *userp) { - struct WriteThis *pooh = (struct WriteThis *) userp; + struct t654_WriteThis *pooh = (struct t654_WriteThis *) userp; pooh->freecount++; } -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t654_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp; int eof; if(size*nmemb < 1) @@ -64,13 +61,15 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) CURLcode test(char *URL) { + static const char testdata[] = "dummy\n"; + CURL *easy = NULL; CURL *easy2 = NULL; curl_mime *mime = NULL; curl_mimepart *part; struct curl_slist *hdrs = NULL; CURLcode res = TEST_ERR_FAILURE; - struct WriteThis pooh; + struct t654_WriteThis pooh; /* * Check proper copy/release of mime post data bound to a duplicated @@ -110,8 +109,8 @@ CURLcode test(char *URL) part = curl_mime_addpart(mime); curl_mime_filedata(part, libtest_arg2); part = curl_mime_addpart(mime); - curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, free_callback, - &pooh); + curl_mime_data_cb(part, (curl_off_t) -1, t654_read_cb, NULL, + free_callback, &pooh); /* Bind mime data to its easy handle. */ test_setopt(easy, CURLOPT_MIMEPOST, mime); diff --git a/tests/libtest/lib655.c b/tests/libtest/lib655.c index adb3313c94..238837fe96 100644 --- a/tests/libtest/lib655.c +++ b/tests/libtest/lib655.c @@ -28,8 +28,8 @@ static const char *TEST_DATA_STRING = "Test data"; static int cb_count = 0; -static int -resolver_alloc_cb_fail(void *resolver_state, void *reserved, void *userdata) +static int resolver_alloc_cb_fail(void *resolver_state, void *reserved, + void *userdata) { (void)resolver_state; (void)reserved; @@ -43,8 +43,8 @@ resolver_alloc_cb_fail(void *resolver_state, void *reserved, void *userdata) return 1; } -static int -resolver_alloc_cb_pass(void *resolver_state, void *reserved, void *userdata) +static int resolver_alloc_cb_pass(void *resolver_state, void *reserved, + void *userdata) { (void)resolver_state; (void)reserved; @@ -84,7 +84,8 @@ CURLcode test(char *URL) res = curl_easy_perform(curl); if(res != CURLE_COULDNT_RESOLVE_HOST) { curl_mfprintf(stderr, "curl_easy_perform should have returned " - "CURLE_COULDNT_RESOLVE_HOST but instead returned error %d\n", res); + "CURLE_COULDNT_RESOLVE_HOST but instead returned error %d\n", + res); if(res == CURLE_OK) res = TEST_ERR_FAILURE; goto test_cleanup; diff --git a/tests/libtest/lib666.c b/tests/libtest/lib666.c index 4d2df8e0f1..d27825cae3 100644 --- a/tests/libtest/lib666.c +++ b/tests/libtest/lib666.c @@ -25,10 +25,10 @@ #include "memdebug.h" -static char testbuf[17000]; /* more than 16K */ - CURLcode test(char *URL) { + static char testbuf[17000]; /* more than 16K */ + CURL *curl = NULL; CURLcode res = CURLE_OK; curl_mime *mime = NULL; diff --git a/tests/libtest/lib667.c b/tests/libtest/lib667.c index 70856fcaa8..2febda615d 100644 --- a/tests/libtest/lib667.c +++ b/tests/libtest/lib667.c @@ -25,17 +25,14 @@ #include "memdebug.h" -static char testdata[]= - "dummy"; - -struct WriteThis { - char *readptr; +struct t667_WriteThis { + const char *readptr; curl_off_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t667_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t667_WriteThis *pooh = (struct t667_WriteThis *)userp; int eof; if(size*nmemb < 1) @@ -56,11 +53,13 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) CURLcode test(char *URL) { + static const char testdata[] = "dummy"; + CURL *easy = NULL; curl_mime *mime = NULL; curl_mimepart *part; CURLcode res = TEST_ERR_FAILURE; - struct WriteThis pooh; + struct t667_WriteThis pooh; /* * Check proper handling of mime encoder feature when the part read callback @@ -93,7 +92,8 @@ CURLcode test(char *URL) curl_mime_name(part, "field"); curl_mime_encoder(part, "base64"); /* Using an undefined length forces chunked transfer. */ - curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, NULL, &pooh); + curl_mime_data_cb(part, (curl_off_t) -1, t667_read_cb, + NULL, NULL, &pooh); /* Bind mime data to its easy handle. */ test_setopt(easy, CURLOPT_MIMEPOST, mime); diff --git a/tests/libtest/lib668.c b/tests/libtest/lib668.c index ef000510b1..7f2b299f2f 100644 --- a/tests/libtest/lib668.c +++ b/tests/libtest/lib668.c @@ -25,16 +25,14 @@ #include "memdebug.h" -static char testdata[]= "dummy"; - -struct WriteThis { - char *readptr; +struct t668_WriteThis { + const char *readptr; curl_off_t sizeleft; }; -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t668_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; + struct t668_WriteThis *pooh = (struct t668_WriteThis *)userp; size_t len = strlen(pooh->readptr); (void) size; /* Always 1.*/ @@ -50,11 +48,13 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) CURLcode test(char *URL) { + static const char testdata[] = "dummy"; + CURL *easy = NULL; curl_mime *mime = NULL; curl_mimepart *part; CURLcode res = TEST_ERR_FAILURE; - struct WriteThis pooh1, pooh2; + struct t668_WriteThis pooh1, pooh2; /* * Check early end of part data detection. @@ -87,12 +87,13 @@ CURLcode test(char *URL) curl_mime_name(part, "field1"); /* Early end of data detection can be done because the data size is known. */ curl_mime_data_cb(part, (curl_off_t) strlen(testdata), - read_callback, NULL, NULL, &pooh1); + t668_read_cb, NULL, NULL, &pooh1); part = curl_mime_addpart(mime); curl_mime_name(part, "field2"); /* Using an undefined length forces chunked transfer and disables early end of data detection for this part. */ - curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, NULL, &pooh2); + curl_mime_data_cb(part, (curl_off_t) -1, t668_read_cb, + NULL, NULL, &pooh2); part = curl_mime_addpart(mime); curl_mime_name(part, "field3"); /* Regular file part sources early end of data can be detected because diff --git a/tests/libtest/lib670.c b/tests/libtest/lib670.c index 2b54eac2d2..4a64e7831f 100644 --- a/tests/libtest/lib670.c +++ b/tests/libtest/lib670.c @@ -29,19 +29,17 @@ #define PAUSE_TIME 5 - -static const char testname[] = "field"; - -struct ReadThis { +#ifndef LIB670_C +#define LIB670_C +struct t670_ReadThis { CURL *easy; time_t origin; int count; }; - -static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +static size_t t670_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct ReadThis *pooh = (struct ReadThis *) userp; + struct t670_ReadThis *pooh = (struct t670_ReadThis *) userp; time_t delta; if(size * nmemb < 1) @@ -64,12 +62,16 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) curl_mfprintf(stderr, "Read callback called after EOF\n"); exit(1); } +#endif #if !defined(LIB670) && !defined(LIB672) -static int xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, - curl_off_t ultotal, curl_off_t ulnow) +#ifndef LIB670_XFERINFO_C +#define LIB670_XFERINFO_C +static int t670_xferinfo(void *clientp, + curl_off_t dltotal, curl_off_t dlnow, + curl_off_t ultotal, curl_off_t ulnow) { - struct ReadThis *pooh = (struct ReadThis *) clientp; + struct t670_ReadThis *pooh = (struct t670_ReadThis *) clientp; (void) dltotal; (void) dlnow; @@ -91,9 +93,12 @@ static int xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, return 0; } #endif +#endif CURLcode test(char *URL) { + static const char testname[] = "field"; + #if defined(LIB670) || defined(LIB671) curl_mime *mime = NULL; curl_mimepart *part; @@ -110,7 +115,7 @@ CURLcode test(char *URL) int still_running = 0; #endif - struct ReadThis pooh; + struct t670_ReadThis pooh; CURLcode res = TEST_ERR_FAILURE; /* @@ -147,7 +152,7 @@ CURLcode test(char *URL) goto test_cleanup; } - res = curl_mime_data_cb(part, (curl_off_t) 2, read_callback, + res = curl_mime_data_cb(part, (curl_off_t) 2, t670_read_cb, NULL, NULL, &pooh); /* Bind mime data to its easy handle. */ @@ -166,7 +171,7 @@ CURLcode test(char *URL) } /* We want to use our own read function. */ - test_setopt(pooh.easy, CURLOPT_READFUNCTION, read_callback); + test_setopt(pooh.easy, CURLOPT_READFUNCTION, t670_read_cb); /* Send a multi-part formpost. */ test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost); @@ -237,7 +242,7 @@ CURLcode test(char *URL) #else /* Use the easy interface. */ test_setopt(pooh.easy, CURLOPT_XFERINFODATA, &pooh); - test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, xferinfo); + test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, t670_xferinfo); test_setopt(pooh.easy, CURLOPT_NOPROGRESS, 0L); res = curl_easy_perform(pooh.easy); #endif diff --git a/tests/libtest/lib677.c b/tests/libtest/lib677.c index daabd68fae..34ecf2ba7e 100644 --- a/tests/libtest/lib677.c +++ b/tests/libtest/lib677.c @@ -27,11 +27,11 @@ #include "warnless.h" #include "memdebug.h" -static const char testcmd[] = "A1 IDLE\r\n"; -static char testbuf[1024]; - CURLcode test(char *URL) { + static const char testcmd[] = "A1 IDLE\r\n"; + static char testbuf[1024]; + CURLM *mcurl; CURL *curl = NULL; int mrun; diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 054f250ee8..4586a51896 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -30,7 +30,6 @@ #include "warnless.h" #include "memdebug.h" -#define TEST_HANG_TIMEOUT 60 * 1000 #define MAX_EASY_HANDLES 3 static int ntlm_counter[MAX_EASY_HANDLES]; diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index 64dc15e6d8..d083c39025 100755 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -209,8 +209,8 @@ print $fh <
sizeof(long)) + curl_msnprintf(buf, len, "%llu", (unsigned long long)val); + else +#endif + { + if(sizeof(rlim_t) < sizeof(long)) + curl_msnprintf(buf, len, "%u", (unsigned int)val); + else + curl_msnprintf(buf, len, "%lu", (unsigned long)val); + } +} +#endif diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 8696689d9d..750506fb2e 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -42,4 +42,17 @@ long tutil_tvdiff(struct timeval t1, struct timeval t2); */ double tutil_tvdiff_secs(struct timeval t1, struct timeval t2); +/* build request url */ +char *tutil_suburl(const char *base, int i); + +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif + +#include + +#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) +void tutil_rlim2str(char *buf, size_t len, rlim_t val); +#endif + #endif /* HEADER_CURL_LIBTEST_TESTUTIL_H */ diff --git a/tests/mk-bundle-hints.sh b/tests/mk-bundle-hints.sh deleted file mode 100755 index 67bf9361c0..0000000000 --- a/tests/mk-bundle-hints.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Viktor Szakats -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at https://curl.se/docs/copyright.html. -# -# You may opt to use, copy, modify, merge, publish, distribute and/or sell -# copies of the Software, and permit persons to whom the Software is -# furnished to do so, under the terms of the COPYING file. -# -# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY -# KIND, either express or implied. -# -# SPDX-License-Identifier: curl -# -########################################################################### - -detect_in_reused_sources=1 - -if [ "$detect_in_reused_sources" = '1' ]; then - # Make symlinks for all re-used sources - grep -E '^(lib|unit)[0-9]+_SOURCES = ' libtest/Makefile.inc unit/Makefile.inc \ - | sed -E 's@^([a-z]+)/[a-zA-Z.]+:(lib|unit)([0-9]+)_SOURCES = (lib|unit)([0-9]+).+@\1 \2 \3 \5@g' | \ - while read -r l; do - if [[ "${l}" =~ ([a-z]+)\ ([a-z]+)\ ([0-9]+)\ ([0-9]+) ]]; then - trg="${BASH_REMATCH[3]}" - src="${BASH_REMATCH[4]}" - if [ "${trg}" != "${src}" ]; then - dir="${BASH_REMATCH[1]}" - pfx="${BASH_REMATCH[2]}" - ln -s "${pfx}${src}.c" "${dir}/${pfx}${trg}.c" - fi - fi - done -fi - -# Look for symbols possibly re-used in multiple sources. -# -# Falsely picks ups symbols in re-used sources, but guarded for a single use. -# Misses shadowed variables. -# shellcheck disable=SC2046 -grep -E '^ *(static|struct) +' $(find libtest unit -maxdepth 1 -name 'lib*.c' -o -name 'unit*.c' -o -name 'mk-*.pl') \ - | grep -E '^(libtest|unit)/' \ - | grep -E '\.(c|pl):(static|struct)( +[a-zA-Z_* ]+)? +[a-zA-Z_][a-zA-Z0-9_]+ *' | sort -u \ - | grep -o -E '[a-zA-Z_][a-zA-Z0-9_]+ *[=;[({]' | tr -d '=;[({ ' \ - | grep -v -E '^(NULL$|sizeof$|CURLE_)' \ - | sort | uniq -c | sort -k 2 | grep -v -E '^ +1 ' \ - | awk '{print " \"" $2 "\","}' - -echo '---' - -# Extract list of macros that may be re-used by multiple tests. -# -# Picks up false-positive when the macro is defined to the same value everywhere. -# shellcheck disable=SC2046 -grep -E '^ *# *define +' $(find libtest unit -maxdepth 1 -name 'lib*.c' -o -name 'unit*.c' -o -name 'mk-*.pl') \ - | grep -E '^(libtest|unit)/' \ - | grep -o -E '.+\.(c|pl): *# *define +[A-Z_][A-Z0-9_]+' | sort -u \ - | grep -o -E '[A-Z_][A-Z0-9_]+' \ - | sort | uniq -c | sort -k 2 | grep -v -E '^ +1 ' \ - | awk '{print " \"" $2 "\","}' - -if [ "$detect_in_reused_sources" = '1' ]; then - # Delete symlinks for all re-used sources - find libtest unit -type l -delete -fi diff --git a/tests/mk-bundle.pl b/tests/mk-bundle.pl index 982de70635..0a29d287bb 100755 --- a/tests/mk-bundle.pl +++ b/tests/mk-bundle.pl @@ -47,80 +47,6 @@ print <
) { @@ -131,7 +57,7 @@ while(my $line = <$fh>) { my $src = "$2.c"; # Make common symbols unique across test sources - foreach my $symb ("test", @reused_symbols) { + foreach my $symb ("test", "unit_setup", "unit_stop") { print "#undef $symb\n"; print "#define $symb ${symb}_$name\n"; } @@ -139,14 +65,7 @@ while(my $line = <$fh>) { print "#define $namu\n"; print "#include \"$src\"\n"; print "#undef $namu\n"; - - # Reset macros re-used by multiple tests - foreach my $undef ("test", @reused_macros) { - print "#undef $undef\n"; - } - print "\n"; - $tlist .= " {\"$name\", test_$name},\n"; } } diff --git a/tests/server/first.c b/tests/server/first.c index 13b02d41c7..a0d473be45 100644 --- a/tests/server/first.c +++ b/tests/server/first.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) main_func = NULL; { size_t tmp; - for(tmp = 0; s_mains[tmp].ptr; ++tmp) { + for(tmp = 0; tmp < CURL_ARRAYSIZE(s_mains); ++tmp) { if(strcmp(main_name, s_mains[tmp].name) == 0) { main_func = s_mains[tmp].ptr; break; diff --git a/tests/server/mk-bundle.pl b/tests/server/mk-bundle.pl index 321709bb07..1edb6f3d8d 100755 --- a/tests/server/mk-bundle.pl +++ b/tests/server/mk-bundle.pl @@ -25,8 +25,6 @@ # Bundle up individual tests into a single binary. The resulting binary can run # individual tests by passing their name (without '.c') as the first argument. -# -# Usage: mk-bundle.pl [] use strict; use warnings; @@ -82,8 +80,7 @@ foreach my $src (@src) { print <