]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: drop mk-bundle exceptions
authorViktor Szakats <commit@vsz.me>
Tue, 27 May 2025 19:20:36 +0000 (21:20 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 11 Jun 2025 03:39:19 +0000 (05:39 +0200)
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

142 files changed:
tests/Makefile.am
tests/data/test1596
tests/libtest/Makefile.inc
tests/libtest/lib1485.c
tests/libtest/lib1500.c
tests/libtest/lib1501.c
tests/libtest/lib1502.c
tests/libtest/lib1506.c
tests/libtest/lib1507.c
tests/libtest/lib1510.c
tests/libtest/lib1512.c
tests/libtest/lib1514.c
tests/libtest/lib1515.c
tests/libtest/lib1517.c
tests/libtest/lib1518.c
tests/libtest/lib1520.c
tests/libtest/lib1522.c
tests/libtest/lib1523.c
tests/libtest/lib1525.c
tests/libtest/lib1526.c
tests/libtest/lib1527.c
tests/libtest/lib1531.c
tests/libtest/lib1533.c
tests/libtest/lib1540.c
tests/libtest/lib1541.c
tests/libtest/lib1552.c
tests/libtest/lib1553.c
tests/libtest/lib1554.c
tests/libtest/lib1555.c
tests/libtest/lib1560.c
tests/libtest/lib1564.c
tests/libtest/lib1565.c
tests/libtest/lib1576.c
tests/libtest/lib1591.c
tests/libtest/lib1592.c
tests/libtest/lib1598.c
tests/libtest/lib1662.c
tests/libtest/lib1901.c
tests/libtest/lib1911.c
tests/libtest/lib1915.c
tests/libtest/lib1940.c
tests/libtest/lib1945.c
tests/libtest/lib1947.c
tests/libtest/lib1971.c
tests/libtest/lib1975.c
tests/libtest/lib2301.c
tests/libtest/lib2302.c
tests/libtest/lib2304.c
tests/libtest/lib2402.c
tests/libtest/lib2404.c
tests/libtest/lib2502.c
tests/libtest/lib3026.c
tests/libtest/lib3105.c
tests/libtest/lib3207.c
tests/libtest/lib3208.c
tests/libtest/lib500.c
tests/libtest/lib502.c
tests/libtest/lib503.c
tests/libtest/lib504.c
tests/libtest/lib506.c
tests/libtest/lib507.c
tests/libtest/lib508.c
tests/libtest/lib510.c
tests/libtest/lib513.c
tests/libtest/lib517.c
tests/libtest/lib518.c
tests/libtest/lib525.c
tests/libtest/lib526.c
tests/libtest/lib530.c
tests/libtest/lib533.c
tests/libtest/lib537.c
tests/libtest/lib540.c
tests/libtest/lib544.c
tests/libtest/lib547.c
tests/libtest/lib552.c
tests/libtest/lib553.c
tests/libtest/lib554.c
tests/libtest/lib555.c
tests/libtest/lib560.c
tests/libtest/lib564.c
tests/libtest/lib568.c
tests/libtest/lib569.c
tests/libtest/lib570.c
tests/libtest/lib571.c
tests/libtest/lib572.c
tests/libtest/lib573.c
tests/libtest/lib574.c
tests/libtest/lib575.c
tests/libtest/lib576.c
tests/libtest/lib578.c
tests/libtest/lib579.c
tests/libtest/lib582.c
tests/libtest/lib586.c
tests/libtest/lib587.c [new file with mode: 0644]
tests/libtest/lib591.c
tests/libtest/lib597.c
tests/libtest/lib599.c
tests/libtest/lib643.c
tests/libtest/lib645.c [new file with mode: 0644]
tests/libtest/lib650.c
tests/libtest/lib651.c
tests/libtest/lib652.c
tests/libtest/lib654.c
tests/libtest/lib655.c
tests/libtest/lib666.c
tests/libtest/lib667.c
tests/libtest/lib668.c
tests/libtest/lib670.c
tests/libtest/lib677.c
tests/libtest/libntlmconnect.c
tests/libtest/mk-lib1521.pl
tests/libtest/test.h
tests/libtest/testtrace.c
tests/libtest/testutil.c
tests/libtest/testutil.h
tests/mk-bundle-hints.sh [deleted file]
tests/mk-bundle.pl
tests/server/first.c
tests/server/mk-bundle.pl
tests/unit/unit1302.c
tests/unit/unit1303.c
tests/unit/unit1305.c
tests/unit/unit1307.c
tests/unit/unit1397.c
tests/unit/unit1398.c
tests/unit/unit1399.c
tests/unit/unit1600.c
tests/unit/unit1602.c
tests/unit/unit1603.c
tests/unit/unit1605.c
tests/unit/unit1606.c
tests/unit/unit1607.c
tests/unit/unit1609.c
tests/unit/unit1616.c
tests/unit/unit1620.c
tests/unit/unit1652.c
tests/unit/unit1653.c
tests/unit/unit1654.c
tests/unit/unit1660.c
tests/unit/unit1663.c
tests/unit/unit2600.c
tests/unit/unit3200.c

index 2c8b1b30d28b41aca078b97b1f358dfa6a6447a8..3315090e2c9664b637ab8d25f38d5acef0f902c3 100644 (file)
@@ -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       \
index 8b94cd12fa09f1c4f2c7211af61499e29163cb97..5778e76b789e0f0e3ad41038f2b8cce01625deda 100644 (file)
@@ -28,7 +28,7 @@ http
 HTTP Retry-After header parsing using a date
 </name>
 <tool>
-lib%TESTNUMBER
+lib1594
 </tool>
 <command>
 http://%HOSTIP:%HTTPPORT/%TESTNUMBER
index d130d5158d6c719d5e66122740568f9fe933cf33..293b0f097013567cc4bae003ae6e00af45320699 100644 (file)
@@ -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)
 
index 71678563f2fa1998978f6a170a0443e4e69c38e6..c980dfb75c4f5ce13b54d1296b43c98f8c7e3c23 100644 (file)
@@ -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);
index b5944ef3137b6335aa1f80437808ea7f57e355bf..f72b2dd720538f7d196e1be9738264d371031241 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *curls = NULL;
index 2194127ed592f21b21ea267610387d063b3cf685..0644b837480348fd6e701667c32931b877ef04c0 100644 (file)
@@ -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
index cb7a8c2ae644f88d20660520a2a410164f5153d2..b4f56407f561b42fb4b7bc70c06e4fa4b2bc9fe0 100644 (file)
@@ -37,8 +37,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *easy = NULL;
index d7e4cb0d6281f359bcf032b3224751e4f9d7cebd..0a4507a211ad2f40651bc2d0936c6ec74877f15a 100644 (file)
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index 7525ec534298d850dd30f57a05c114903c88c7cc..f2f25f057a18c8214b2f0fb0c391cd2ff5d23258 100644 (file)
@@ -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);
index d039b7b0e3553d7f824366be1ede051be85c16bb..ec4c0baba36197842e957c1b7edf7356c0b58a0a 100644 (file)
@@ -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),
index 02b2e8cac5dc50855e60727ea337f295025162fc..763694837d13d99e9061d46d5025a6b26e55bbdf 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "memdebug.h"
 
+#undef NUM_HANDLES
 #define NUM_HANDLES 2
 
 CURLcode test(char *URL)
index 6b4e18bac0f7a2aa63539e285623532ec0e0627b..9596fb76858c9ac30790fb02bef4b543b1e7fc23 100644 (file)
 
 #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! */
index 6c07c7901b22dc68eebfb5053b4bbd3e68e08a6d..fda322e6043591e16648225b0e6b42bf849e60b4 100644 (file)
@@ -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)
index 3ae6c03c4d75902330ec5a3a084f72bd02667224..7d9e39dc1d4fb0b78526954d7fbafc4fb6cdd491 100644 (file)
 
 #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);
index 928462e0a0461cb77407565f914880639f81e29c..2278d1f4c07df97caf14a469a31294ddbf11d203 100644 (file)
 
 /* 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"
index f9070945caed96adbe05edbd13863b7afc10d82c..9eb28402281d53d3fee8b30542bb68f21bb5e800 100644 (file)
 #define TO "<recipient@example.com>"
 #define FROM "<sender@example.com>"
 
-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);
index 1c0d945293f387b2651336e7740e6b0337186e98..6d3b8d5ea9ea3e27bb6cd74b93c0a45c8630d60e 100644 (file)
@@ -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;
index 80e01aea6dff128a5fe78eacce6b79f0e2157d56..e26db4d1ef0b724e6925dab7e5301686f78e6094 100644 (file)
@@ -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);
index 481384320f780704cc175b015c6e823693317f0e..7802293a5cc046ae0cb4a1037fb6e3f293b3aec0 100644 (file)
 
 #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);
 
index cf6ca1e4297935fed603307239e78a31216fb5d5..487b2818fdbff441a897dc849360f0ce64de148b 100644 (file)
 
 #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);
 
index aa5aa286ab37034153dabfb3816bb45ac90f13ea..cc7151058acd21cacd79b3105a851890835f2996 100644 (file)
 
 #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);
index 1155296fccb8f6ba79e9708b57ee1ac9b863f745..a33b9c4093b71569a3f9349cdc3d72fd945cbe0c 100644 (file)
 #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 */
index 68fdb2b6d2b2948f855ab6db2f2830299d5dd8cd..620405f04c64abd0cab53dfa660f8f52f2b452a8 100644 (file)
@@ -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,
index aad97d2af2b6577a92c1a8a6f703d97ff7f9ca58..35e905c1d9a042950a0673428650e6d3526c1255 100644 (file)
@@ -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);
index d09e0e66e7e3a9ef19fd216e43181067c9432ed2..a228da28671eecb657be712cd1e284fa18cce759 100644 (file)
@@ -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);
index b61f162ed9a5c69cbdbefbc10e31879b92ad6476..eef97038869a58266d7e9a0f123070643a3bfd9b 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *curls = NULL;
index a1c04314ee080754eb2c6fa25474c192f7aa86fa..e20f18831ff7773cd406366009ab58dcd463c01d 100644 (file)
 #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;
index 4fc408f609f67530d51dfe97b0f69a727115ef5c..b33d03d9c0b12d597c2ee626f9bcf4d322d7f6cd 100644 (file)
@@ -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! */
index eda2328a33c68244fa9b0919420e9eeae9f0cfb9..f66b89c89ee03f326d584f3f319e1ace8e44a262 100644 (file)
@@ -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;
index a0b9baa1bfa62196270ef42afa7e92d60adaa5f4..af75b89ea818d54fa4ee3c010913bf4261dd6f33 100644 (file)
@@ -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,
index 83c774df7006dff7ee5d88a8182f6624ef934037..08a76d74f7a069a64924ea82c4a6ca5b6a542346 100644 (file)
@@ -27,7 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
 #define WAKEUP_NUM 10
 
 CURLcode test(char *URL)
index d83add89599156897da5f8e34e196e0f17445d97..992a3dead5cf17f280cfa9cbdfa4f14164013ffa 100644 (file)
 #include <pthread.h>
 #include <unistd.h>
 
-#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 */
index 279d6fbc97f1e17b8a5faea3ec5f84f998a341b4..98a7a6c7b1f00959a3ed299464f788f97e7ecb06 100644 (file)
 
 #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) {
index 7d1c012698e1c076e3391375ad3a9e2a8074638c..ae341aae59842bb091483bc18317e19eccc94d9c 100644 (file)
 #include <stdio.h>
 #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);
index 99f088d661b070c9ca38a7139d5c7d9f812d7181..efb42540702ced553c145396a2ef3995cea590de 100644 (file)
@@ -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"
index e2a3cfeb0acd7b905431cd4026a47ea58352c5f9..aba94129c9eefc347b837b9cb00381d8ee0cbf4e 100644 (file)
@@ -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);
 
index 1e9e2b061754abe294c9769206c95f0e9c655148..6d70de403587dcf45689bb19ed0e733653eba30a 100644 (file)
  ***************************************************************************/
 #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);
index 6d5f3d4aa024be881a1b587e70741b4f1987a507..0ae6bc5ded1a371ef19e4e12464eb0e6f26759fc 100644 (file)
 #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);
index 6dd4dcb1b00404dbf1ce7a12f8915be3159723d2..3621040ec8edc7a6a4857ab1427d5b8be7f2ee98 100644 (file)
    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;
index 02c225a3237bf0a5110a45c2a4229dfa01351914..4fd0354059b01f5165ad6f14043a3de36576f2ae 100644 (file)
 #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;
index c90a3e0a53b57eca163a7b7cc595d6264e6e7e54..60b14f02a5cfdbe56d4ec7bca35dd7409fd7e099 100644 (file)
 
 #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);
index 5a4361fbd140673eaafee1dda6bb5298d43dd68a..8bb87a28d73a2612953c51d23d01d13ad0a251e3 100644 (file)
@@ -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);
index 3288939fca33327330096cd50355a259f41fa993..9d9559a1424620d03d8981bf5ad0cf46b2e0f3bc 100644 (file)
@@ -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) {
index c36a0c2bc6debf66413f0b948a2f5752d839ca02..4bbdc207aefa07b77c6060752e5941a6bc9bdef4 100644 (file)
 
 #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");
index b9fdc84786ec6993d8687b7601ce4afc3db1cc0f..ade53bc47752ce99ee533ccc36763ff167c0c458 100644 (file)
 
 #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");
index 8a370928a3269719cae37b85b192e9a39c781122..8603f314141799223ed9a006346833c8dcd6906b 100644 (file)
@@ -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);
index 1207a3a9af18e4e833a897b2a2cc3e8f6d7a3278..010e3b09116ffb89a4f0aa8dc659d419638e88e7 100644 (file)
@@ -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);
index 74053538bf4efce351616d7c2d818d0a4cf2486d..9c2828ca84ed6a4028721fc1498fcf0e4aff084b 100644 (file)
@@ -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);
index 9e3e8fba7904799432bc60dedc9c7582e51ad502..808b96629019bc3c407c02c26786f40edcc1b325 100644 (file)
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index c4d8e5df58b6d4762e36d14dce5baf01cba3edc7..5876f766757a07f2f1f0e7b991b078bddd70386e 100644 (file)
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index 8979d19b0523a506b9405b595fc14e8413608826..99cb8ed37a19f2ccbc87629720820bbf75f90eee 100644 (file)
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index a94b1a271df2915535b77a7c2d34fd7e5436ec06..28580e995679db4b2c29da6d73822c1a5e85bdd1 100644 (file)
 
 #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 <process.h>
-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 <pthread.h>
 #include <unistd.h>
 
-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);
index c41a59a1b6abd0e21e382ddcb5e093578413017d..c8a1a78f069554e3008504c303f6dbc682bc8049 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *curls = NULL;
index 5baec357d1f15017567e0f879dc7b00af3363ac7..294c8e62406021d505fc2ac62bf5ed0cd9784565 100644 (file)
@@ -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);
 
index ce3a4cbe9cf2c126de141e3d7ea4cfdc8dd99196..846e8fcf9b3fb622ff70db2b0f35b55f9c76dbde 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *curl = NULL;
index 1a9222edc82b8b07999cb61bb95dacb672072997..e7623e5aaa5678dcd29f6a5a8fe47318cda04263 100644 (file)
@@ -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
index 44ad6f6790210083f5d7dc00c2323fee508882ce..0a0208294d347c0ad965f2f17db276e8d04eca31 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 /*
  * Get a single URL without select().
  */
index cac2a755cbce515cb592a2ebc81041df5e3b04c0..4356f5aad48202d4d04b812f9e5e299b9d9c085f 100644 (file)
@@ -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.
index 93d38a0b24611f7959d9684204df826565a6855a..989fa4dcf7a5e6f7e1424be0992301adaae9c9fc 100644 (file)
@@ -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.
index 8680c6ec6d8ece7fe784b8d9f9839f3ec974e889..89a5ccb5abf60a21dea1eff32f472eeae483d6ad 100644 (file)
  *
  ***************************************************************************/
 #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);
index f86ee79b923bddd8933191fb3c4afbb35543352f..53b554d19453f3e6465afe08e2da7e8772f658b5 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *curls = NULL;
index 8480cd7d144da7490e199d1cffc59685bdc523ae..968125c28d7a392204050fdde109561f28dfd1c3 100644 (file)
 
 #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);
index 0c7a7d14935e600608bc9d25bbf18ab952b8d4d2..4be925917a8cb24907600ce575c8bd8b4b5b8af5 100644 (file)
 
 #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);
index af40e6ee09d69594f3880be11059b2910daae288..c0153f0247adfee24dc9d7a5c3674933f61f7955 100644 (file)
@@ -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);
index d7849f1dcceb561052f17b6648aaff8aea34b0c5..32175d00eebeca60682941a7f36ba622b50c429c 100644 (file)
 
 #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;
 
index 3bc2fa5ed97d3c429edc5e0ea59eac1d7961aec4..f9df1b4b4f398db3647f0c2513a74fb1d6230d74 100644 (file)
  ***************************************************************************/
 #include "test.h"
 
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#include <limits.h>
 
+#include "testutil.h"
 #include "warnless.h"
 #include "memdebug.h"
 
 #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"
 
 #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();
 
index e1742a4afdb3f46e441262a842c3b306947f2191..22be567ff7cad3b23c40acb88b29e360a8d7e11e 100644 (file)
@@ -29,8 +29,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index c38d6dfebaf1dd3da257c13152a2fac887454326..e56f299a9ade0f7ae25f9e5202a40e5466e82f74 100644 (file)
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index f577c82ad574a7f371cf2243591685d208f291c7..83216f5b3dd86dc95f8e9fd222b8597ad7122ee4 100644 (file)
 #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;
index be12105896639472fbda2534a7d3f6528c3af776..5ac43cd6bb4d0920205dc63f4fca4eef08214587 100644 (file)
@@ -31,8 +31,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index 1e4d3839aea0d9769052da9d191750c6ff7b6e76..9bf0a7eb5298fb6e3921c922ce75374e9e50f749 100644 (file)
  ***************************************************************************/
 #include "test.h"
 
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#include <limits.h>
 
+#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"
 
 #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();
 
index 42020849874ca2fca66576aff273c96524495a99..1568eee534e27d25868c9801fde0c398f95466ce 100644 (file)
 #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];
index 9b6874ca372123c7276b441afe2dfc58b2ccf398..fd62e32c21ed6e28b4c82e1475dcb73a3bd59ca8 100644 (file)
 
 #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;
index ce64ae41da8bec460826dae24a5b6f203e6eec16..24b97adc22e20090ed725e777371a50f38934860 100644 (file)
 #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)! */
index f4fde2ff8313952c4f63e6ad93aa0905ab82f1f9..f6216da1f8b614e03700e5db93b50050c7f21bfa 100644 (file)
 #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);
index d6d7f7cdbbad7ac508066c96b90ad986eaaef5ba..111da121259f5ee08af10ec5f3ef73f5f3ebb49a 100644 (file)
@@ -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;
index 94e6ad79366fef8808c4ac2d7ddde9f66b6988fe..5c7db7a4e56b38fc347b81c65eb34496c9bbfb55 100644 (file)
 
 #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();
 
index a63fc2178482606638b0d98cd4bc9f611a8b6eb6..9da9da368e4e672d8e20332404e315f2f0eb9038 100644 (file)
 #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)! */
index 95b62ce784b650d0cb0026a64af8a22dc0eae623..6d392e6a4f9f7d3226a2c1ff520aff3f1704f3ac 100644 (file)
@@ -27,8 +27,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 /*
  * Simply download an HTTPS file!
  *
index 11c9ab6e7b165692a531a24b9fbcf6e502b0b0c6..d1c819182e2676f1131d1d1799327a4d5d4d8c70 100644 (file)
@@ -29,8 +29,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
index f3e68c2da3ce833c141295a907ea206c073d27e6..76935e01b1b2ce5feac85e49c497fc73286361a5 100644 (file)
 #include <fcntl.h>
 #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;
index f5d124f4d98739aaafc5cf0dce334cec9a64f411..6ee9c15d36ed751bb788ee23289d19349a8b97a4 100644 (file)
  *
  ***************************************************************************/
 #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;
index 8f803b656ad9c323cf3b03f3863d3fbafd38a56e..8c7831e5a0734fc1e8dde6d7bdd082f1a98887fd 100644 (file)
  *
  ***************************************************************************/
 #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;
index fe0f7e05efcbf1257e62087420a2c218496f3eb4..d0025486b1766d2923ee9df44b9ee594812967bb 100644 (file)
@@ -39,6 +39,7 @@
 #  include <fcntl.h>
 #endif
 
+#include "testutil.h"
 #include "warnless.h"
 #include "memdebug.h"
 
                              ((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;
index 5f5722113451d3a6ce0a4c0ac37258d146510da3..8f5d2f1d46930eb053dda69c9d33b651a29ab23a 100644 (file)
 #include <fcntl.h>
 #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;
index 40af2212c9d4e1feb3032abcdafaa7edf088458f..bcd0e90bdb00412a5ca4cdbbba47fe20daf562cb 100644 (file)
@@ -28,8 +28,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 /*
  * Get a single URL without select().
  */
index 4675f2d60fbba0586880244fce36b405cd01cb21..696668fc6ee080bb71c544f8f055fd5d038d483f 100644 (file)
@@ -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)
 {
index d64f70d737d1320531a613307848a9eb3be38f9c..d02e64aaee8b10d2492071cd2b615ddbe4045a33 100644 (file)
@@ -29,8 +29,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 /* 3x download!
  * 1. normal
  * 2. dup handle
index 014fd896ac74123bf2712dc708e48a311493c58f..a78e7b8ab311fe494694eed8d73336924e569139 100644 (file)
@@ -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) {
index 33b807afb0e508b3194230fd7b439a3bd1efd731..9fd6aaaea3fe350faf0c6960e026eb6b5a6973ab 100644 (file)
 #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);
index 8bc9e2a7cd23663c3e7969072e143f572a92ad4d..e6f8945e4206e706fd8a8fcf4a33bd5e2b860fb6 100644 (file)
 
 #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);
index 2d2f2bcb7a23ca1f3b9018c2d06eb6cf22606048..bb1fb5e6114f68c2778049b010d7f3f930ff2da6 100644 (file)
 #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");
     }
index 2712df74f7fff91f763a767b7038f86c182f073f..1cb3cf0ab91e2ac5d609f8c437191246d35e81f7 100644 (file)
 #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 (file)
index 0000000..ea9862e
--- /dev/null
@@ -0,0 +1,189 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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;
+}
index ce2b855a41224bb937c9a29e8d95beb6cf83b8f5..1f75770920a897aef2d4fc8de60c74b7c4b4f6dc 100644 (file)
@@ -33,8 +33,6 @@
 #include "warnless.h"
 #include "memdebug.h"
 
-#define TEST_HANG_TIMEOUT 60 * 1000
-
 CURLcode test(char *URL)
 {
   CURL *easy = NULL;
index 71535b041d3c2e17330dcd7e38418fc658414995..d040f9a7813518a6ea05c79246f657c9bacc1c72 100644 (file)
@@ -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
index d9ee121daf140d7baaeeabe83efd779a7c9efd95..9525dbbfe40ac80f12d7853ed6602327c3487a98 100644 (file)
@@ -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);
index 49ab41bb12d1d2ea669c6025e2cbbe4fc25401ca..7181a28177f49e2e79806f9461359447cfbfa833 100644 (file)
 
 #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 (file)
index 0000000..7e3196b
--- /dev/null
@@ -0,0 +1,258 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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;
+}
index 59f5ba925e80294da4294e60738c495136d4ae3a..4fa1571be1aa214507a78b5c79a3e67ba92b8d35 100644 (file)
 
 #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;
index 856ccd123dd91574cf4552497dc30f8149ee4082..84e8d89fe890a1ac90a7a667a21b365d81240c4c 100644 (file)
 
 #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;
index d6be151b18488817dbab68ce8869374b40b3514c..e01fbee54bfb2e7bdc1dae50b929f7e3c6884df6 100644 (file)
 
 #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;
index 6a2daee3d9b3cd7eb0f5012da20dba16a646632f..72236c249d6aa77c8846ca2bfbfbd77ca8ce0675 100644 (file)
 
 #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);
index adb3313c948421388ed1cbfb4f606665dceb417a..238837fe96f33b0a6d1ba3df406dc2c30567663f 100644 (file)
@@ -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;
index 4d2df8e0f1e64e340de39f07292334b53017c3e3..d27825cae385e93df765200a19c23c24d7e2a194 100644 (file)
 
 #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;
index 70856fcaa870e9d9294250508ed725d11e1502f2..2febda615d465b020ffb15e01af3ac0c9723544a 100644 (file)
 
 #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);
index ef000510b1125de1a218942968ff1f8e01a76968..7f2b299f2f1cec1027bba28d8e9b28d3993497d1 100644 (file)
 
 #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
index 2b54eac2d2668554a18c704c44019a0c436d45af..4a64e7831fd5e31ead3949996da3bb182019edda 100644 (file)
 
 #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
index daabd68faebf3ff9c525edd6ad21f972f999aa57..34ecf2ba7ec2379d7888bb6e938db9fe45073af7 100644 (file)
 #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;
index 054f250ee8474392c7dd7198038b612f88357eaf..4586a51896b9e3c607d39c6329ae57d5ea6d8312 100644 (file)
@@ -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];
index 64dc15e6d85b08b01201ae46b5251d43855308b5..d083c3902515a6c2527201447fd884e2cc80aa21 100755 (executable)
@@ -209,8 +209,8 @@ print $fh <<HEADER
 
 /* This source code is generated by mk-lib1521.pl ! */
 
-struct testdata {
-    char *blaha;
+struct t1521_testdata {
+  char *blaha;
 };
 
 #define LO $minlong
@@ -275,7 +275,7 @@ static void errnull(const char *name, CURLcode val, int lineno)
          name, val, curl_easy_strerror(val), lineno);
 }
 
-static void geterr(const char *name, CURLcode val, int lineno)
+static void t1521_geterr(const char *name, CURLcode val, int lineno)
 {
   printf("CURLINFO_%s returned %d, \\"%s\\" on line %d\\n",
          name, val, curl_easy_strerror(val), lineno);
@@ -340,7 +340,7 @@ CURLcode test(char *URL)
   struct curl_httppost *httppost = NULL;
   curl_mime *mimepost = NULL;
   FILE *stream = stderr;
-  struct testdata object;
+  struct t1521_testdata object;
   CURLU *curlu = (CURLU *)&object;
   char *charp;
   long val;
@@ -556,7 +556,7 @@ MOO
           ($_ =~ /^CURLINFO_([^ ]*) *= *CURLINFO_([^ ]*)/)) {
        my ($info, $type)=($1, $2);
        my $c = "  res = curl_easy_getinfo(curl, CURLINFO_$info,";
-       my $check = "  if(res)\n    geterr(\"$info\", res, __LINE__);\n";
+       my $check = "  if(res)\n    t1521_geterr(\"$info\", res, __LINE__);\n";
        if($type eq "STRING") {
          print $fh "$c &charp);\n$check";
        }
index 4c672e8a99292dec2fd2aa1112413ac035410504..753d549498498f59e155927b8b6141d3d92df5b5 100644 (file)
@@ -527,3 +527,10 @@ extern CURLcode test(char *URL); /* the actual test function provided by each
     return CURLE_UNSUPPORTED_PROTOCOL;          \
   }
 #endif
+
+/* Set default that each test may override */
+#undef TEST_HANG_TIMEOUT
+#define TEST_HANG_TIMEOUT 60 * 1000
+
+#undef NUM_HANDLES
+#define NUM_HANDLES 4
index 63bd17fe343b1c2ce0872793686e09f3340a8972..36942124d28b94304421b498a450eceda74eeb23 100644 (file)
@@ -32,9 +32,9 @@ struct libtest_trace_cfg libtest_debug_config;
 static time_t epoch_offset; /* for test time tracing */
 static int    known_offset; /* for test time tracing */
 
-static
-void libtest_debug_dump(const char *timebuf, const char *text, FILE *stream,
-                        const unsigned char *ptr, size_t size, int nohex)
+static void libtest_debug_dump(const char *timebuf, const char *text,
+                               FILE *stream, const unsigned char *ptr,
+                               size_t size, int nohex)
 {
   size_t i;
   size_t c;
index 27cb9373afc40a74bedc2ec7828930c8de6e9545..e9672d82a3c2e911a559064da78b24b59c530936 100644 (file)
@@ -129,3 +129,32 @@ double tutil_tvdiff_secs(struct timeval newer, struct timeval older)
       (double)(newer.tv_usec-older.tv_usec)/1000000.0;
   return (double)(newer.tv_usec-older.tv_usec)/1000000.0;
 }
+
+/* build request url */
+char *tutil_suburl(const char *base, int i)
+{
+  return curl_maprintf("%s%.4d", base, i);
+}
+
+#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+void tutil_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);
+  }
+}
+#endif
index 8696689d9d036098e8c428236ed1a08bd3aeeb1b..750506fb2e329543cc73ae0f4e2f564d79f8dd95 100644 (file)
@@ -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 <sys/resource.h>
+#endif
+
+#include <limits.h>
+
+#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 (executable)
index 67bf936..0000000
+++ /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
index 982de7063506d2499f66a36c1b26e92acba5780f..0a29d287bb01ee85bc3b9fb01659a902c13e01b9 100755 (executable)
@@ -47,80 +47,6 @@ print <<HEADER
 HEADER
     ;
 
-# TODO: Some of these might be subject for de-duplication or sync.
-my @reused_symbols = (
-    "ReadThis",
-    "ReadWriteSockets",
-    "Sockets",
-    "Tdata",
-    "WriteThis",
-    "addFd",
-    "checkFdSet",
-    "checkForCompletion",
-    "close_file_descriptors",
-    "curl",  # shadow
-    "curlSocketCallback",
-    "curlTimerCallback",
-    "cyclic_add",
-    "easy",  # unit
-    "fopen_works",
-    "getMicroSecondTimeout",
-    "geterr",
-    "hash_static",  # unit
-    "header_callback",
-    "ioctlcallback",
-    "msgbuff",
-    "mydtor",  # unit
-    "num_open",
-    "progress_callback",
-    "read_callback",
-    "readcallback",
-    "recv_pong",
-    "removeFd",
-    "rlim2str",
-    "run_thread",
-    "seek_callback",
-    "send_ping",
-    "showem",
-    "store_errmsg",
-    "suburl",
-    "test_failure",  # shadow
-    "test_fire",
-    "test_lock",
-    "test_once",
-    "test_parse",  # unit
-    "test_rlimit",
-    "test_unlock",
-    "testbuf",
-    "testcase",  # unit
-    "testdata",
-    "testfd",
-    "testname",
-    "testpost",
-    "tests",  # unit
-    "teststring",
-    "trailers_callback",
-    "transfer_status",
-    "unit_setup",  # unit
-    "unit_stop",  # unit
-    "updateFdSet",
-    "userdata",
-    "websocket",
-    "websocket_close",
-    "write_callback",
-    "write_cb",
-    "writecb",
-    "xferinfo",
-    );
-
-# TODO: Some of these may be #undef-ed manually at the end of each source
-my @reused_macros = (
-    "HEADER_REQUEST",
-    "NUM_HANDLES",
-    "SAFETY_MARGIN",
-    "TEST_HANG_TIMEOUT",
-    );
-
 my $tlist = "";
 
 while(my $line = <$fh>) {
@@ -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";
     }
 }
index 13b02d41c7a3ba950dc3bc3a39f19750d9209322..a0d473be4519418d8e4842eaf0a2a87462701058 100644 (file)
@@ -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;
index 321709bb0706347353bd1701700695034204d341..1edb6f3d8d0c3f10c6220911ad58d7f093b36ab0 100755 (executable)
@@ -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 [<server_c>]
 
 use strict;
 use warnings;
@@ -82,8 +80,7 @@ foreach my $src (@src) {
 
 print <<FOOTER
 static const struct onemain s_mains[] = {
-${tlist}  {NULL, NULL}
-};
+$tlist};
 
 #include "first.c"
 FOOTER
index d0e85f634fdc0eae06329e99632654402505ff4d..e9056e4a572807bcb795cc7b61ba75237ee18998 100644 (file)
 #include "curlx/base64.h"
 #include "memdebug.h" /* LAST include file */
 
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1302_easy;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  testdata = curl_easy_init();
-  if(!testdata) {
+  t1302_easy = curl_easy_init();
+  if(!t1302_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -45,7 +45,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(testdata);
+  curl_easy_cleanup(t1302_easy);
   curl_global_cleanup();
 }
 
index 95f0630560ff5759a6fc30ffa00f54d89fbc547a..d6d39f810e15e478653d839ea7713d1c7bfae340 100644 (file)
 #include "connect.h"
 #include "memdebug.h" /* LAST include file */
 
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1303_easy;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  testdata = curl_easy_init();
-  if(!testdata) {
+  t1303_easy = curl_easy_init();
+  if(!t1303_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -44,7 +44,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(testdata);
+  curl_easy_cleanup(t1303_easy);
   curl_global_cleanup();
 }
 
@@ -55,8 +55,8 @@ static void unit_stop(void)
 /* macro to set the pretended current time */
 #define NOW(x,y) now.tv_sec = x; now.tv_usec = y
 /* macro to set the millisecond based timeouts to use */
-#define TIMEOUTS(x,y) testdata->set.timeout = x; \
-                      testdata->set.connecttimeout = y
+#define TIMEOUTS(x,y) t1303_easy->set.timeout = x; \
+                      t1303_easy->set.connecttimeout = y
 
 /*
  * To test:
@@ -137,16 +137,16 @@ UNITTEST_START
   };
 
   /* this is the pretended start time of the transfer */
-  testdata->progress.t_startsingle.tv_sec = BASE;
-  testdata->progress.t_startsingle.tv_usec = 0;
-  testdata->progress.t_startop.tv_sec = BASE;
-  testdata->progress.t_startop.tv_usec = 0;
+  t1303_easy->progress.t_startsingle.tv_sec = BASE;
+  t1303_easy->progress.t_startsingle.tv_usec = 0;
+  t1303_easy->progress.t_startop.tv_sec = BASE;
+  t1303_easy->progress.t_startop.tv_usec = 0;
 
   for(i = 0; i < CURL_ARRAYSIZE(run); i++) {
     timediff_t timeout;
     NOW(run[i].now_s, run[i].now_us);
     TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
-    timeout =  Curl_timeleft(testdata, &now, run[i].connecting);
+    timeout =  Curl_timeleft(t1303_easy, &now, run[i].connecting);
     if(timeout != run[i].result)
       fail(run[i].comment);
   }
index 2df5f284a2271f480ebce5a7cd2b32de795054d0..ebff79c2f167e00b6bc7224339b6c1f046a52f83 100644 (file)
 
 #include "memdebug.h" /* LAST include file */
 
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1305_easy;
 static struct Curl_dnscache hp;
 static char *data_key;
 static struct Curl_dns_entry *data_node;
 
 static CURLcode unit_setup(void)
 {
-  testdata = curl_easy_init();
-  if(!testdata) {
+  t1305_easy = curl_easy_init();
+  if(!t1305_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -66,7 +66,7 @@ static void unit_stop(void)
   free(data_key);
   Curl_dnscache_destroy(&hp);
 
-  curl_easy_cleanup(testdata);
+  curl_easy_cleanup(t1305_easy);
   curl_global_cleanup();
 }
 
index 5f678cffc90e6bb886f58c652a1189f030bf10de..c3329c51f18f09218006e98cd5eefc70468ae292 100644 (file)
@@ -57,202 +57,6 @@ static void unit_stop(void)
 #define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER)
 #define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER)
 
-struct testcase {
-  const char *pattern;
-  const char *string;
-  int result;
-};
-
-static const struct testcase tests[] = {
-  /* brackets syntax */
-  {"*[*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
-   "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
-   "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\001\177[[[[[[[[[[[[[[[[[[[[[",
-   "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
-   "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
-   "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[",
-   NOMATCH|MAC_FAIL},
-
-  { "\\[",                      "[",                      MATCH },
-  { "[",                        "[",             NOMATCH|LINUX_MATCH|MAC_FAIL},
-  { "[]",                       "[]",            NOMATCH|LINUX_MATCH|MAC_FAIL},
-  { "[][]",                     "[",                      MATCH },
-  { "[][]",                     "]",                      MATCH },
-  { "[[]",                      "[",                      MATCH },
-  { "[[[]",                     "[",                      MATCH },
-  { "[[[[]",                    "[",                      MATCH },
-  { "[[[[]",                    "[",                      MATCH },
-
-  { "[][[]",                    "]",                      MATCH },
-  { "[][[[]",                   "[",                      MATCH },
-  { "[[]",                      "]",                      NOMATCH },
-
-  { "[a@]",                     "a",                      MATCH },
-
-  { "[a-z]",                    "a",                      MATCH },
-  { "[a-z]",                    "A",                      NOMATCH },
-  { "?[a-z]",                   "?Z",                     NOMATCH },
-  { "[A-Z]",                    "C",                      MATCH },
-  { "[A-Z]",                    "c",                      NOMATCH },
-  { "[0-9]",                    "7",                      MATCH },
-  { "[7-8]",                    "7",                      MATCH },
-  { "[7-]",                     "7",                      MATCH },
-  { "[7-]",                     "-",                      MATCH },
-  { "[7-]",                     "[",                      NOMATCH },
-  { "[a-bA-F]",                 "F",                      MATCH },
-  { "[a-bA-B9]",                "9",                      MATCH },
-  { "[a-bA-B98]",               "8",                      MATCH },
-  { "[a-bA-B98]",               "C",                      NOMATCH },
-  { "[a-bA-Z9]",                "F",                      MATCH },
-  { "[a-bA-Z9]ero*",            "Zero chance.",           MATCH },
-  { "S[a-][x]opho*",            "Saxophone",              MATCH },
-  { "S[a-][x]opho*",            "SaXophone",              NOMATCH },
-  { "S[a-][x]*.txt",            "S-x.txt",                MATCH },
-  { "[\\a-\\b]",                "a",                      MATCH },
-  { "[\\a-\\b]",                "b",                      MATCH },
-  { "[?*[][?*[][?*[]",          "?*[",                    MATCH },
-  { "[][?*-]",                  "]",                      MATCH },
-  { "[][?*-]",                  "[",                      MATCH },
-  { "[][?*-]",                  "?",                      MATCH },
-  { "[][?*-]",                  "*",                      MATCH },
-  { "[][?*-]",                  "-",                      MATCH },
-  { "[]?*-]",                   "-",                      MATCH },
-  { "[\xFF]",                   "\xFF", MATCH|LINUX_FAIL|MAC_FAIL},
-  { "?/b/c",                    "a/b/c",                  MATCH },
-  { "^_{}~",                    "^_{}~",                  MATCH },
-  { "!#%+,-./01234567889",      "!#%+,-./01234567889",    MATCH },
-  { "PQRSTUVWXYZ]abcdefg",      "PQRSTUVWXYZ]abcdefg",    MATCH },
-  { ":;=@ABCDEFGHIJKLMNO",      ":;=@ABCDEFGHIJKLMNO",    MATCH },
-
-  /* negate */
-  { "[!a]",                     "b",                      MATCH },
-  { "[!a]",                     "a",                      NOMATCH },
-  { "[^a]",                     "b",                      MATCH },
-  { "[^a]",                     "a",                      NOMATCH },
-  { "[^a-z0-9A-Z]",             "a",                      NOMATCH },
-  { "[^a-z0-9A-Z]",             "-",                      MATCH },
-  { "curl[!a-z]lib",            "curl lib",               MATCH },
-  { "curl[! ]lib",              "curl lib",               NOMATCH },
-  { "[! ][ ]",                  "  ",                     NOMATCH },
-  { "[! ][ ]",                  "a ",                     MATCH },
-  { "*[^a].t?t",                "a.txt",                  NOMATCH },
-  { "*[^a].t?t",                "ba.txt",                 NOMATCH },
-  { "*[^a].t?t",                "ab.txt",                 MATCH },
-  { "*[^a]",                    "",                       NOMATCH },
-  { "[!\xFF]",                  "",             NOMATCH|LINUX_FAIL},
-  { "[!\xFF]",                  "\xFF",  NOMATCH|LINUX_FAIL|MAC_FAIL},
-  { "[!\xFF]",                  "a",      MATCH|LINUX_FAIL|MAC_FAIL},
-  { "[!?*[]",                   "?",                      NOMATCH },
-  { "[!!]",                     "!",                      NOMATCH },
-  { "[!!]",                     "x",                      MATCH },
-
-  { "[[:alpha:]]",              "a",                      MATCH },
-  { "[[:alpha:]]",              "9",                      NOMATCH },
-  { "[[:alnum:]]",              "a",                      MATCH },
-  { "[[:alnum:]]",              "[",                      NOMATCH },
-  { "[[:alnum:]]",              "]",                      NOMATCH },
-  { "[[:alnum:]]",              "9",                      MATCH },
-  { "[[:digit:]]",              "9",                      MATCH },
-  { "[[:xdigit:]]",             "9",                      MATCH },
-  { "[[:xdigit:]]",             "F",                      MATCH },
-  { "[[:xdigit:]]",             "G",                      NOMATCH },
-  { "[[:upper:]]",              "U",                      MATCH },
-  { "[[:upper:]]",              "u",                      NOMATCH },
-  { "[[:lower:]]",              "l",                      MATCH },
-  { "[[:lower:]]",              "L",                      NOMATCH },
-  { "[[:print:]]",              "L",                      MATCH },
-  { "[[:print:]]",              "\10",                    NOMATCH },
-  { "[[:print:]]",              "\10",                    NOMATCH },
-  { "[[:space:]]",              " ",                      MATCH },
-  { "[[:space:]]",              "x",                      NOMATCH },
-  { "[[:graph:]]",              " ",                      NOMATCH },
-  { "[[:graph:]]",              "x",                      MATCH },
-  { "[[:blank:]]",              "\t",                     MATCH },
-  { "[[:blank:]]",              " ",                      MATCH },
-  { "[[:blank:]]",              "\r",                     NOMATCH },
-  { "[^[:blank:]]",             "\t",                     NOMATCH },
-  { "[^[:print:]]",             "\10",                    MATCH },
-  { "[[:lower:]][[:lower:]]",   "ll",                     MATCH },
-  { "[[:foo:]]",                "bar",                    NOMATCH|MAC_FAIL},
-  { "[[:foo:]]",                "f]",         MATCH|LINUX_NOMATCH|MAC_FAIL},
-
-  { "Curl[[:blank:]];-)",       "Curl ;-)",               MATCH },
-  { "*[[:blank:]]*",            " ",                      MATCH },
-  { "*[[:blank:]]*",            "",                       NOMATCH },
-  { "*[[:blank:]]*",            "hi, im_Pavel",           MATCH },
-
-  /* common using */
-  { "filename.dat",             "filename.dat",           MATCH },
-  { "*curl*",                   "lets use curl!!",        MATCH },
-  { "filename.txt",             "filename.dat",           NOMATCH },
-  { "*.txt",                    "text.txt",               MATCH },
-  { "*.txt",                    "a.txt",                  MATCH },
-  { "*.txt",                    ".txt",                   MATCH },
-  { "*.txt",                    "txt",                    NOMATCH },
-  { "??.txt",                   "99.txt",                 MATCH },
-  { "??.txt",                   "a99.txt",                NOMATCH },
-  { "?.???",                    "a.txt",                  MATCH },
-  { "*.???",                    "somefile.dat",           MATCH },
-  { "*.???",                    "photo.jpeg",             NOMATCH },
-  { ".*",                       ".htaccess",              MATCH },
-  { ".*",                       ".",                      MATCH },
-  { ".*",                       "..",                     MATCH },
-
-  /* many stars => one star */
-  { "**.txt",                   "text.txt",               MATCH },
-  { "***.txt",                  "t.txt",                  MATCH },
-  { "****.txt",                 ".txt",                   MATCH },
-
-  /* empty string or pattern */
-  { "",                         "",                       MATCH },
-  { "",                         "hello",                  NOMATCH },
-  { "file",                     "",                       NOMATCH  },
-  { "?",                        "",                       NOMATCH },
-  { "*",                        "",                       MATCH },
-  { "x",                        "",                       NOMATCH },
-
-  /* backslash */
-  { "\\",                       "\\",                     MATCH|LINUX_NOMATCH},
-  { "\\\\",                     "\\",                     MATCH },
-  { "\\\\",                     "\\\\",                   NOMATCH },
-  { "\\?",                      "?",                      MATCH },
-  { "\\*",                      "*",                      MATCH },
-  { "?.txt",                    "?.txt",                  MATCH },
-  { "*.txt",                    "*.txt",                  MATCH },
-  { "\\?.txt",                  "?.txt",                  MATCH },
-  { "\\*.txt",                  "*.txt",                  MATCH },
-  { "\\?.txt",                  "x.txt",                  NOMATCH },
-  { "\\*.txt",                  "x.txt",                  NOMATCH },
-  { "\\*\\\\.txt",              "*\\.txt",                MATCH },
-  { "*\\**\\?*\\\\*",           "cc*cc?cccc",             NOMATCH },
-  { "*\\?*\\**",                "cc?cc",                  NOMATCH },
-  { "\\\"\\$\\&\\'\\(\\)",      "\"$&'()",                MATCH },
-  { "\\*\\?\\[\\\\\\`\\|",      "*?[\\`|",                MATCH },
-  { "[\\a\\b]c",                "ac",                     MATCH },
-  { "[\\a\\b]c",                "bc",                     MATCH },
-  { "[\\a\\b]d",                "bc",                     NOMATCH },
-  { "[a-bA-B\\?]",              "?",                      MATCH },
-  { "cu[a-ab-b\\r]l",           "curl",                   MATCH },
-  { "[\\a-z]",                  "c",                      MATCH },
-
-  { "?*?*?.*?*",                "abc.c",                  MATCH },
-  { "?*?*?.*?*",                "abcc",                   NOMATCH },
-  { "?*?*?.*?*",                "abc.",                   NOMATCH },
-  { "?*?*?.*?*",                "abc.c++",                MATCH },
-  { "?*?*?.*?*",                "abcdef.c++",             MATCH },
-  { "?*?*?.?",                  "abcdef.c",               MATCH },
-  { "?*?*?.?",                  "abcdef.cd",              NOMATCH },
-
-  /* https://codepoints.net/U+00E4 Latin Small Letter A with Diaeresis */
-  { "Lindm\xc3\xa4tarv",        "Lindm\xc3\xa4tarv",      MATCH },
-
-  { "",                         "",                       MATCH},
-  {"**]*[*[\x13]**[*\x13)]*]*[**[*\x13~r-]*]**[.*]*[\xe3\xe3\xe3\xe3\xe3\xe3"
-   "\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3"
-   "\xe3\xe3\xe3\xe3\xe3*[\x13]**[*\x13)]*]*[*[\x13]*[~r]*]*\xba\x13\xa6~b-]*",
-                                "a",                      NOMATCH|LINUX_FAIL}
-};
-
 static const char *ret2name(int i)
 {
   switch(i) {
@@ -276,6 +80,203 @@ enum system {
 
 UNITTEST_START
 {
+  struct testcase {
+    const char *pattern;
+    const char *string;
+    int result;
+  };
+
+  static const struct testcase tests[] = {
+    /* brackets syntax */
+    {"*[*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
+     "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
+     "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\001\177[[[[[[[[[[[[[[[[[[[[[",
+     "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
+     "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
+     "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[",
+     NOMATCH|MAC_FAIL},
+
+    { "\\[",                      "[",                      MATCH },
+    { "[",                        "[",           NOMATCH|LINUX_MATCH|MAC_FAIL},
+    { "[]",                       "[]",          NOMATCH|LINUX_MATCH|MAC_FAIL},
+    { "[][]",                     "[",                      MATCH },
+    { "[][]",                     "]",                      MATCH },
+    { "[[]",                      "[",                      MATCH },
+    { "[[[]",                     "[",                      MATCH },
+    { "[[[[]",                    "[",                      MATCH },
+    { "[[[[]",                    "[",                      MATCH },
+
+    { "[][[]",                    "]",                      MATCH },
+    { "[][[[]",                   "[",                      MATCH },
+    { "[[]",                      "]",                      NOMATCH },
+
+    { "[a@]",                     "a",                      MATCH },
+
+    { "[a-z]",                    "a",                      MATCH },
+    { "[a-z]",                    "A",                      NOMATCH },
+    { "?[a-z]",                   "?Z",                     NOMATCH },
+    { "[A-Z]",                    "C",                      MATCH },
+    { "[A-Z]",                    "c",                      NOMATCH },
+    { "[0-9]",                    "7",                      MATCH },
+    { "[7-8]",                    "7",                      MATCH },
+    { "[7-]",                     "7",                      MATCH },
+    { "[7-]",                     "-",                      MATCH },
+    { "[7-]",                     "[",                      NOMATCH },
+    { "[a-bA-F]",                 "F",                      MATCH },
+    { "[a-bA-B9]",                "9",                      MATCH },
+    { "[a-bA-B98]",               "8",                      MATCH },
+    { "[a-bA-B98]",               "C",                      NOMATCH },
+    { "[a-bA-Z9]",                "F",                      MATCH },
+    { "[a-bA-Z9]ero*",            "Zero chance.",           MATCH },
+    { "S[a-][x]opho*",            "Saxophone",              MATCH },
+    { "S[a-][x]opho*",            "SaXophone",              NOMATCH },
+    { "S[a-][x]*.txt",            "S-x.txt",                MATCH },
+    { "[\\a-\\b]",                "a",                      MATCH },
+    { "[\\a-\\b]",                "b",                      MATCH },
+    { "[?*[][?*[][?*[]",          "?*[",                    MATCH },
+    { "[][?*-]",                  "]",                      MATCH },
+    { "[][?*-]",                  "[",                      MATCH },
+    { "[][?*-]",                  "?",                      MATCH },
+    { "[][?*-]",                  "*",                      MATCH },
+    { "[][?*-]",                  "-",                      MATCH },
+    { "[]?*-]",                   "-",                      MATCH },
+    { "[\xFF]",                   "\xFF", MATCH|LINUX_FAIL|MAC_FAIL},
+    { "?/b/c",                    "a/b/c",                  MATCH },
+    { "^_{}~",                    "^_{}~",                  MATCH },
+    { "!#%+,-./01234567889",      "!#%+,-./01234567889",    MATCH },
+    { "PQRSTUVWXYZ]abcdefg",      "PQRSTUVWXYZ]abcdefg",    MATCH },
+    { ":;=@ABCDEFGHIJKLMNO",      ":;=@ABCDEFGHIJKLMNO",    MATCH },
+
+    /* negate */
+    { "[!a]",                     "b",                      MATCH },
+    { "[!a]",                     "a",                      NOMATCH },
+    { "[^a]",                     "b",                      MATCH },
+    { "[^a]",                     "a",                      NOMATCH },
+    { "[^a-z0-9A-Z]",             "a",                      NOMATCH },
+    { "[^a-z0-9A-Z]",             "-",                      MATCH },
+    { "curl[!a-z]lib",            "curl lib",               MATCH },
+    { "curl[! ]lib",              "curl lib",               NOMATCH },
+    { "[! ][ ]",                  "  ",                     NOMATCH },
+    { "[! ][ ]",                  "a ",                     MATCH },
+    { "*[^a].t?t",                "a.txt",                  NOMATCH },
+    { "*[^a].t?t",                "ba.txt",                 NOMATCH },
+    { "*[^a].t?t",                "ab.txt",                 MATCH },
+    { "*[^a]",                    "",                       NOMATCH },
+    { "[!\xFF]",                  "",             NOMATCH|LINUX_FAIL},
+    { "[!\xFF]",                  "\xFF",  NOMATCH|LINUX_FAIL|MAC_FAIL},
+    { "[!\xFF]",                  "a",      MATCH|LINUX_FAIL|MAC_FAIL},
+    { "[!?*[]",                   "?",                      NOMATCH },
+    { "[!!]",                     "!",                      NOMATCH },
+    { "[!!]",                     "x",                      MATCH },
+
+    { "[[:alpha:]]",              "a",                      MATCH },
+    { "[[:alpha:]]",              "9",                      NOMATCH },
+    { "[[:alnum:]]",              "a",                      MATCH },
+    { "[[:alnum:]]",              "[",                      NOMATCH },
+    { "[[:alnum:]]",              "]",                      NOMATCH },
+    { "[[:alnum:]]",              "9",                      MATCH },
+    { "[[:digit:]]",              "9",                      MATCH },
+    { "[[:xdigit:]]",             "9",                      MATCH },
+    { "[[:xdigit:]]",             "F",                      MATCH },
+    { "[[:xdigit:]]",             "G",                      NOMATCH },
+    { "[[:upper:]]",              "U",                      MATCH },
+    { "[[:upper:]]",              "u",                      NOMATCH },
+    { "[[:lower:]]",              "l",                      MATCH },
+    { "[[:lower:]]",              "L",                      NOMATCH },
+    { "[[:print:]]",              "L",                      MATCH },
+    { "[[:print:]]",              "\10",                    NOMATCH },
+    { "[[:print:]]",              "\10",                    NOMATCH },
+    { "[[:space:]]",              " ",                      MATCH },
+    { "[[:space:]]",              "x",                      NOMATCH },
+    { "[[:graph:]]",              " ",                      NOMATCH },
+    { "[[:graph:]]",              "x",                      MATCH },
+    { "[[:blank:]]",              "\t",                     MATCH },
+    { "[[:blank:]]",              " ",                      MATCH },
+    { "[[:blank:]]",              "\r",                     NOMATCH },
+    { "[^[:blank:]]",             "\t",                     NOMATCH },
+    { "[^[:print:]]",             "\10",                    MATCH },
+    { "[[:lower:]][[:lower:]]",   "ll",                     MATCH },
+    { "[[:foo:]]",                "bar",                    NOMATCH|MAC_FAIL},
+    { "[[:foo:]]",                "f]",         MATCH|LINUX_NOMATCH|MAC_FAIL},
+
+    { "Curl[[:blank:]];-)",       "Curl ;-)",               MATCH },
+    { "*[[:blank:]]*",            " ",                      MATCH },
+    { "*[[:blank:]]*",            "",                       NOMATCH },
+    { "*[[:blank:]]*",            "hi, im_Pavel",           MATCH },
+
+    /* common using */
+    { "filename.dat",             "filename.dat",           MATCH },
+    { "*curl*",                   "lets use curl!!",        MATCH },
+    { "filename.txt",             "filename.dat",           NOMATCH },
+    { "*.txt",                    "text.txt",               MATCH },
+    { "*.txt",                    "a.txt",                  MATCH },
+    { "*.txt",                    ".txt",                   MATCH },
+    { "*.txt",                    "txt",                    NOMATCH },
+    { "??.txt",                   "99.txt",                 MATCH },
+    { "??.txt",                   "a99.txt",                NOMATCH },
+    { "?.???",                    "a.txt",                  MATCH },
+    { "*.???",                    "somefile.dat",           MATCH },
+    { "*.???",                    "photo.jpeg",             NOMATCH },
+    { ".*",                       ".htaccess",              MATCH },
+    { ".*",                       ".",                      MATCH },
+    { ".*",                       "..",                     MATCH },
+
+    /* many stars => one star */
+    { "**.txt",                   "text.txt",               MATCH },
+    { "***.txt",                  "t.txt",                  MATCH },
+    { "****.txt",                 ".txt",                   MATCH },
+
+    /* empty string or pattern */
+    { "",                         "",                       MATCH },
+    { "",                         "hello",                  NOMATCH },
+    { "file",                     "",                       NOMATCH  },
+    { "?",                        "",                       NOMATCH },
+    { "*",                        "",                       MATCH },
+    { "x",                        "",                       NOMATCH },
+
+    /* backslash */
+    { "\\",                       "\\",                   MATCH|LINUX_NOMATCH},
+    { "\\\\",                     "\\",                     MATCH },
+    { "\\\\",                     "\\\\",                   NOMATCH },
+    { "\\?",                      "?",                      MATCH },
+    { "\\*",                      "*",                      MATCH },
+    { "?.txt",                    "?.txt",                  MATCH },
+    { "*.txt",                    "*.txt",                  MATCH },
+    { "\\?.txt",                  "?.txt",                  MATCH },
+    { "\\*.txt",                  "*.txt",                  MATCH },
+    { "\\?.txt",                  "x.txt",                  NOMATCH },
+    { "\\*.txt",                  "x.txt",                  NOMATCH },
+    { "\\*\\\\.txt",              "*\\.txt",                MATCH },
+    { "*\\**\\?*\\\\*",           "cc*cc?cccc",             NOMATCH },
+    { "*\\?*\\**",                "cc?cc",                  NOMATCH },
+    { "\\\"\\$\\&\\'\\(\\)",      "\"$&'()",                MATCH },
+    { "\\*\\?\\[\\\\\\`\\|",      "*?[\\`|",                MATCH },
+    { "[\\a\\b]c",                "ac",                     MATCH },
+    { "[\\a\\b]c",                "bc",                     MATCH },
+    { "[\\a\\b]d",                "bc",                     NOMATCH },
+    { "[a-bA-B\\?]",              "?",                      MATCH },
+    { "cu[a-ab-b\\r]l",           "curl",                   MATCH },
+    { "[\\a-z]",                  "c",                      MATCH },
+
+    { "?*?*?.*?*",                "abc.c",                  MATCH },
+    { "?*?*?.*?*",                "abcc",                   NOMATCH },
+    { "?*?*?.*?*",                "abc.",                   NOMATCH },
+    { "?*?*?.*?*",                "abc.c++",                MATCH },
+    { "?*?*?.*?*",                "abcdef.c++",             MATCH },
+    { "?*?*?.?",                  "abcdef.c",               MATCH },
+    { "?*?*?.?",                  "abcdef.cd",              NOMATCH },
+
+    /* https://codepoints.net/U+00E4 Latin Small Letter A with Diaeresis */
+    { "Lindm\xc3\xa4tarv",        "Lindm\xc3\xa4tarv",      MATCH },
+
+    { "",                         "",                       MATCH},
+    {"**]*[*[\x13]**[*\x13)]*]*[**[*\x13~r-]*]**[.*]*[\xe3\xe3\xe3\xe3\xe3\xe3"
+     "\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3"
+     "\xe3\xe3\xe3\xe3\xe3*[\x13]**[*\x13)]*]*[*[\x13]*[~r]*]*\xba\x13\xa6~b-]"
+     "*",
+                                  "a",                      NOMATCH|LINUX_FAIL}
+  };
+
   int i;
   enum system machine;
 
index 1ac2fa9be9bc8440f5f02baa38608ad068105982..68acb4d2302dbf6ad1f76be931506639ba68f525 100644 (file)
@@ -36,67 +36,68 @@ static void unit_stop(void)
 /* only these backends define the tested functions */
 #if defined(USE_OPENSSL) || defined(USE_SCHANNEL)
 #include "vtls/hostcheck.h"
-struct testcase {
-  const char *host;
-  const char *pattern;
-  bool match;
-};
-
-static struct testcase tests[] = {
-  {"", "", FALSE},
-  {"a", "", FALSE},
-  {"", "b", FALSE},
-  {"a", "b", FALSE},
-  {"aa", "bb", FALSE},
-  {"\xff", "\xff", TRUE},
-  {"aa.aa.aa", "aa.aa.bb", FALSE},
-  {"aa.aa.aa", "aa.aa.aa", TRUE},
-  {"aa.aa.aa", "*.aa.bb", FALSE},
-  {"aa.aa.aa", "*.aa.aa", TRUE},
-  {"192.168.0.1", "192.168.0.1", TRUE},
-  {"192.168.0.1", "*.168.0.1", FALSE},
-  {"192.168.0.1", "*.0.1", FALSE},
-  {"h.ello", "*.ello", FALSE},
-  {"h.ello.", "*.ello", FALSE},
-  {"h.ello", "*.ello.", FALSE},
-  {"h.e.llo", "*.e.llo", TRUE},
-  {"h.e.llo", " *.e.llo", FALSE},
-  {" h.e.llo", "*.e.llo", TRUE},
-  {"h.e.llo.", "*.e.llo", TRUE},
-  {"*.e.llo.", "*.e.llo", TRUE},
-  {"************.e.llo.", "*.e.llo", TRUE},
-  {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
-   "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
-   "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
-   "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
-   "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
-   ".e.llo.", "*.e.llo", TRUE},
-  {"\xfe\xfe.e.llo.", "*.e.llo", TRUE},
-  {"h.e.llo.", "*.e.llo.", TRUE},
-  {"h.e.llo", "*.e.llo.", TRUE},
-  {".h.e.llo", "*.e.llo.", FALSE},
-  {"h.e.llo", "*.*.llo.", FALSE},
-  {"h.e.llo", "h.*.llo", FALSE},
-  {"h.e.llo", "h.e.*", FALSE},
-  {"hello", "*.ello", FALSE},
-  {"hello", "**llo", FALSE},
-  {"bar.foo.example.com", "*.example.com", FALSE},
-  {"foo.example.com", "*.example.com", TRUE},
-  {"baz.example.net", "b*z.example.net", FALSE},
-  {"foobaz.example.net", "*baz.example.net", FALSE},
-  {"xn--l8j.example.local", "x*.example.local", FALSE},
-  {"xn--l8j.example.net", "*.example.net", TRUE},
-  {"xn--l8j.example.net", "*j.example.net", FALSE},
-  {"xn--l8j.example.net", "xn--l8j.example.net", TRUE},
-  {"xn--l8j.example.net", "xn--l8j.*.net", FALSE},
-  {"xl8j.example.net", "*.example.net", TRUE},
-  {"fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE},
-  {"fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE},
-  {NULL, NULL, FALSE}
-};
 
 UNITTEST_START
 {
+  struct testcase {
+    const char *host;
+    const char *pattern;
+    bool match;
+  };
+
+  static struct testcase tests[] = {
+    {"", "", FALSE},
+    {"a", "", FALSE},
+    {"", "b", FALSE},
+    {"a", "b", FALSE},
+    {"aa", "bb", FALSE},
+    {"\xff", "\xff", TRUE},
+    {"aa.aa.aa", "aa.aa.bb", FALSE},
+    {"aa.aa.aa", "aa.aa.aa", TRUE},
+    {"aa.aa.aa", "*.aa.bb", FALSE},
+    {"aa.aa.aa", "*.aa.aa", TRUE},
+    {"192.168.0.1", "192.168.0.1", TRUE},
+    {"192.168.0.1", "*.168.0.1", FALSE},
+    {"192.168.0.1", "*.0.1", FALSE},
+    {"h.ello", "*.ello", FALSE},
+    {"h.ello.", "*.ello", FALSE},
+    {"h.ello", "*.ello.", FALSE},
+    {"h.e.llo", "*.e.llo", TRUE},
+    {"h.e.llo", " *.e.llo", FALSE},
+    {" h.e.llo", "*.e.llo", TRUE},
+    {"h.e.llo.", "*.e.llo", TRUE},
+    {"*.e.llo.", "*.e.llo", TRUE},
+    {"************.e.llo.", "*.e.llo", TRUE},
+    {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+     "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
+     "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
+     "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
+     "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+     ".e.llo.", "*.e.llo", TRUE},
+    {"\xfe\xfe.e.llo.", "*.e.llo", TRUE},
+    {"h.e.llo.", "*.e.llo.", TRUE},
+    {"h.e.llo", "*.e.llo.", TRUE},
+    {".h.e.llo", "*.e.llo.", FALSE},
+    {"h.e.llo", "*.*.llo.", FALSE},
+    {"h.e.llo", "h.*.llo", FALSE},
+    {"h.e.llo", "h.e.*", FALSE},
+    {"hello", "*.ello", FALSE},
+    {"hello", "**llo", FALSE},
+    {"bar.foo.example.com", "*.example.com", FALSE},
+    {"foo.example.com", "*.example.com", TRUE},
+    {"baz.example.net", "b*z.example.net", FALSE},
+    {"foobaz.example.net", "*baz.example.net", FALSE},
+    {"xn--l8j.example.local", "x*.example.local", FALSE},
+    {"xn--l8j.example.net", "*.example.net", TRUE},
+    {"xn--l8j.example.net", "*j.example.net", FALSE},
+    {"xn--l8j.example.net", "xn--l8j.example.net", TRUE},
+    {"xn--l8j.example.net", "xn--l8j.*.net", FALSE},
+    {"xl8j.example.net", "*.example.net", TRUE},
+    {"fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE},
+    {"fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE},
+    {NULL, NULL, FALSE}
+  };
+
   int i;
   for(i = 0; tests[i].host; i++) {
     if(tests[i].match != Curl_cert_hostcheck(tests[i].pattern,
index 52c571d899ea8c246faff78d8d52be49191057d6..32d32160ed768fe5a2310ae807489eec8f9688b6 100644 (file)
 #pragma GCC diagnostic ignored "-Wformat"
 #endif
 
-static CURLcode unit_setup(void) {return CURLE_OK;}
-static void unit_stop(void) {}
+static CURLcode unit_setup(void)
+{
+  return CURLE_OK;
+}
+
+static void unit_stop(void)
+{
+}
 
 UNITTEST_START
 
index 5fb2659235a8be3e351900029a504340ccc16ca8..b2e764ca7ff8c6848a91b7e1efaae3b890d871d0 100644 (file)
 
 static int usec_magnitude = 1000000;
 
-static bool unit_setup(void)
+static CURLcode unit_setup(void)
 {
   return CURLE_OK;
 }
 
 static void unit_stop(void)
 {
-
 }
 
 /*
index ee36c5e65cec81abd6a53588617a403dfcfecfd7..2ed82eaff92b2ccd38eb771fb5ec5ecdf6c988f5 100644 (file)
 #include "urldata.h"
 #include "curl_ntlm_core.h"
 
-static CURL *easy;
+static CURL *t1600_easy;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  easy = curl_easy_init();
-  if(!easy) {
+  t1600_easy = curl_easy_init();
+  if(!t1600_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -43,7 +43,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(easy);
+  curl_easy_cleanup(t1600_easy);
   curl_global_cleanup();
 }
 
index cc0c19384ff11ed2daecfe2c053bdede9b7da2ef..29562c6143ac40bfd467d52edb8304bc98afe03d 100644 (file)
@@ -29,9 +29,9 @@
 
 #include <memdebug.h> /* LAST include file */
 
-static struct Curl_hash hash_static;
+static struct Curl_hash t1602_hash_static;
 
-static void mydtor(void *p)
+static void t1602_mydtor(void *p)
 {
   int *ptr = (int *)p;
   free(ptr);
@@ -39,14 +39,14 @@ static void mydtor(void *p)
 
 static CURLcode unit_setup(void)
 {
-  Curl_hash_init(&hash_static, 7, Curl_hash_str,
-                 curlx_str_key_compare, mydtor);
+  Curl_hash_init(&t1602_hash_static, 7, Curl_hash_str,
+                 curlx_str_key_compare, t1602_mydtor);
   return CURLE_OK;
 }
 
 static void unit_stop(void)
 {
-  Curl_hash_destroy(&hash_static);
+  Curl_hash_destroy(&t1602_hash_static);
 }
 
 UNITTEST_START
@@ -62,17 +62,17 @@ UNITTEST_START
   value = malloc(sizeof(int));
   abort_unless(value != NULL, "Out of memory");
   *value = 199;
-  nodep = Curl_hash_add(&hash_static, &key, klen, value);
+  nodep = Curl_hash_add(&t1602_hash_static, &key, klen, value);
   if(!nodep)
     free(value);
   abort_unless(nodep, "insertion into hash failed");
-  Curl_hash_clean(&hash_static);
+  Curl_hash_clean(&t1602_hash_static);
 
   /* Attempt to add another key/value pair */
   value2 = malloc(sizeof(int));
   abort_unless(value2 != NULL, "Out of memory");
   *value2 = 204;
-  nodep = Curl_hash_add(&hash_static, &key2, klen, value2);
+  nodep = Curl_hash_add(&t1602_hash_static, &key2, klen, value2);
   if(!nodep)
     free(value2);
   abort_unless(nodep, "insertion into hash failed");
index 78f7fd8fcf0b0f63ab144085d219ed4665f0d5c0..20861ea86a5823646c4d8b8b91c85fa8e1b4b469 100644 (file)
 #include "hash.h"
 #include <memdebug.h> /* LAST include file */
 
-static struct Curl_hash hash_static;
+static struct Curl_hash t1603_hash_static;
 static const size_t slots = 3;
 
-static void mydtor(void *p)
+static void t1603_mydtor(void *p)
 {
   /* Data are statically allocated */
  (void)p; /* unused */
@@ -48,14 +48,14 @@ static void my_elem_dtor(void *key, size_t key_len, void *p)
 
 static CURLcode unit_setup(void)
 {
-  Curl_hash_init(&hash_static, slots, Curl_hash_str,
-                 curlx_str_key_compare, mydtor);
+  Curl_hash_init(&t1603_hash_static, slots, Curl_hash_str,
+                 curlx_str_key_compare, t1603_mydtor);
   return CURLE_OK;
 }
 
 static void unit_stop(void)
 {
-  Curl_hash_destroy(&hash_static);
+  Curl_hash_destroy(&t1603_hash_static);
 }
 
 UNITTEST_START
@@ -78,100 +78,100 @@ UNITTEST_START
                   "Warning: hashes are not computed as expected on this "
                   "architecture; test coverage will be less comprehensive\n");
 
-  nodep = Curl_hash_add(&hash_static, &key1, strlen(key1), &key1);
+  nodep = Curl_hash_add(&t1603_hash_static, &key1, strlen(key1), &key1);
   fail_unless(nodep, "insertion into hash failed");
-  nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(nodep == key1, "hash retrieval failed");
 
-  nodep = Curl_hash_add(&hash_static, &key2, strlen(key2), &key2);
+  nodep = Curl_hash_add(&t1603_hash_static, &key2, strlen(key2), &key2);
   fail_unless(nodep, "insertion into hash failed");
-  nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key2, strlen(key2));
   fail_unless(nodep == key2, "hash retrieval failed");
 
-  nodep = Curl_hash_add(&hash_static, &key3, strlen(key3), &key3);
+  nodep = Curl_hash_add(&t1603_hash_static, &key3, strlen(key3), &key3);
   fail_unless(nodep, "insertion into hash failed");
-  nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key3, strlen(key3));
   fail_unless(nodep == key3, "hash retrieval failed");
 
   /* The fourth element exceeds the number of slots & collides */
-  nodep = Curl_hash_add(&hash_static, &key4, strlen(key4), &key4);
+  nodep = Curl_hash_add(&t1603_hash_static, &key4, strlen(key4), &key4);
   fail_unless(nodep, "insertion into hash failed");
-  nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(nodep == key4, "hash retrieval failed");
 
   /* Make sure all elements are still accessible */
-  nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(nodep == key1, "hash retrieval failed");
-  nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key2, strlen(key2));
   fail_unless(nodep == key2, "hash retrieval failed");
-  nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key3, strlen(key3));
   fail_unless(nodep == key3, "hash retrieval failed");
-  nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(nodep == key4, "hash retrieval failed");
 
   /* Delete the second of two entries in a bucket */
-  rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
+  rc = Curl_hash_delete(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(rc == 0, "hash delete failed");
-  nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(nodep == key1, "hash retrieval failed");
-  nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(!nodep, "hash retrieval should have failed");
 
   /* Insert that deleted node again */
-  nodep = Curl_hash_add(&hash_static, &key4, strlen(key4), &key4);
+  nodep = Curl_hash_add(&t1603_hash_static, &key4, strlen(key4), &key4);
   fail_unless(nodep, "insertion into hash failed");
-  nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(nodep == key4, "hash retrieval failed");
 
   /* Delete the first of two entries in a bucket */
-  rc = Curl_hash_delete(&hash_static, &key1, strlen(key1));
+  rc = Curl_hash_delete(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(rc == 0, "hash delete failed");
-  nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(!nodep, "hash retrieval should have failed");
-  nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(nodep == key4, "hash retrieval failed");
 
   /* Delete the remaining one of two entries in a bucket */
-  rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
+  rc = Curl_hash_delete(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(rc == 0, "hash delete failed");
-  nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(!nodep, "hash retrieval should have failed");
-  nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(!nodep, "hash retrieval should have failed");
 
   /* Delete an already deleted node */
-  rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
+  rc = Curl_hash_delete(&t1603_hash_static, &key4, strlen(key4));
   fail_unless(rc, "hash delete should have failed");
 
   /* Replace an existing node */
-  nodep = Curl_hash_add(&hash_static, &key1, strlen(key1), &notakey);
+  nodep = Curl_hash_add(&t1603_hash_static, &key1, strlen(key1), &notakey);
   fail_unless(nodep, "insertion into hash failed");
-  nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(nodep == notakey, "hash retrieval failed");
 
   /* Make sure all remaining elements are still accessible */
-  nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key2, strlen(key2));
   fail_unless(nodep == key2, "hash retrieval failed");
-  nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
+  nodep = Curl_hash_pick(&t1603_hash_static, &key3, strlen(key3));
   fail_unless(nodep == key3, "hash retrieval failed");
 
   /* Add element with own destructor */
-  nodep = Curl_hash_add2(&hash_static, &key1, strlen(key1), &key1,
+  nodep = Curl_hash_add2(&t1603_hash_static, &key1, strlen(key1), &key1,
                          my_elem_dtor);
   fail_unless(nodep, "add2 insertion into hash failed");
   fail_unless(elem_dtor_calls == 0, "element destructor count should be 0");
   /* Add it again, should invoke destructor on first */
-  nodep = Curl_hash_add2(&hash_static, &key1, strlen(key1), &key1,
+  nodep = Curl_hash_add2(&t1603_hash_static, &key1, strlen(key1), &key1,
                          my_elem_dtor);
   fail_unless(nodep, "add2 again, insertion into hash failed");
   fail_unless(elem_dtor_calls == 1, "element destructor count should be 1");
   /* remove, should invoke destructor */
-  rc = Curl_hash_delete(&hash_static, &key1, strlen(key1));
+  rc = Curl_hash_delete(&t1603_hash_static, &key1, strlen(key1));
   fail_unless(rc == 0, "hash delete failed");
   fail_unless(elem_dtor_calls == 2, "element destructor count should be 1");
 
 
   /* Clean up */
-  Curl_hash_clean(&hash_static);
+  Curl_hash_clean(&t1603_hash_static);
 
 UNITTEST_STOP
index d0006d2b5f00f9d980cb8068f0ff09febcd807fd..30b62a80803d9217a0800e9162a30c63011651b3 100644 (file)
 
 #include "llist.h"
 
-static CURL *easy;
+static CURL *t1605_easy;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  easy = curl_easy_init();
-  if(!easy) {
+  t1605_easy = curl_easy_init();
+  if(!t1605_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -42,7 +42,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(easy);
+  curl_easy_cleanup(t1605_easy);
   curl_global_cleanup();
 }
 
@@ -50,10 +50,10 @@ UNITTEST_START
   int len;
   char *esc;
 
-  esc = curl_easy_escape(easy, "", -1);
+  esc = curl_easy_escape(t1605_easy, "", -1);
   fail_unless(esc == NULL, "negative string length can't work");
 
-  esc = curl_easy_unescape(easy, "%41%41%41%41", -1, &len);
+  esc = curl_easy_unescape(t1605_easy, "%41%41%41%41", -1, &len);
   fail_unless(esc == NULL, "negative string length can't work");
 
 UNITTEST_STOP
index b7f557d6898f577905c5c466c2bee2106a19eb7f..1e3297036a17b283cb7b837287c394a8f35925e3 100644 (file)
 #include "speedcheck.h"
 #include "urldata.h"
 
-static struct Curl_easy *easy;
+static struct Curl_easy *t1606_easy;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  easy = curl_easy_init();
-  if(!easy) {
+  t1606_easy = curl_easy_init();
+  if(!t1606_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
@@ -43,7 +43,7 @@ static CURLcode unit_setup(void)
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(easy);
+  curl_easy_cleanup(t1606_easy);
   curl_global_cleanup();
 }
 
@@ -57,14 +57,14 @@ static int runawhile(long time_limit,
   CURLcode result;
   int finaltime;
 
-  curl_easy_setopt(easy, CURLOPT_LOW_SPEED_LIMIT, speed_limit);
-  curl_easy_setopt(easy, CURLOPT_LOW_SPEED_TIME, time_limit);
-  Curl_speedinit(easy);
+  curl_easy_setopt(t1606_easy, CURLOPT_LOW_SPEED_LIMIT, speed_limit);
+  curl_easy_setopt(t1606_easy, CURLOPT_LOW_SPEED_TIME, time_limit);
+  Curl_speedinit(t1606_easy);
 
   do {
     /* fake the current transfer speed */
-    easy->progress.current_speed = speed;
-    result = Curl_speedcheck(easy, now);
+    t1606_easy->progress.current_speed = speed;
+    result = Curl_speedcheck(t1606_easy, now);
     if(result)
       break;
     /* step the time */
index 62dde130af05e26f0bc3f0be7312b689e0352f0c..59b85eaacb18b61f858fde83bc724fc72bd5b36a 100644 (file)
@@ -42,23 +42,6 @@ static CURLcode unit_setup(void)
 
   return res;
 }
-
-struct testcase {
-  /* host:port:address[,address]... */
-  const char *optval;
-
-  /* lowercase host and port to retrieve the addresses from hostcache */
-  const char *host;
-  int port;
-
-  /* whether we expect a permanent or non-permanent cache entry */
-  bool permanent;
-
-  /* 0 to 9 addresses expected from hostcache */
-  const char *address[10];
-};
-
-
 /* In builds without IPv6 support CURLOPT_RESOLVE should skip over those
    addresses, so we have to do that as well. */
 static const char skip = 0;
@@ -68,46 +51,61 @@ static const char skip = 0;
 #define IPV6ONLY(x) &skip
 #endif
 
-/* CURLOPT_RESOLVE address parsing tests */
-static const struct testcase tests[] = {
-  /* spaces aren't allowed, for now */
-  { "test.com:80:127.0.0.1, 127.0.0.2",
-    "test.com", 80, TRUE, { NULL, }
-  },
-  { "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
-    "test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
-  },
-  { "test.com:80:::1,127.0.0.1",
-    "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
-  },
-  { "test.com:80:[::1],127.0.0.1",
-    "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
-  },
-  { "test.com:80:::1",
-    "test.com", 80, TRUE, { IPV6ONLY("::1"), }
-  },
-  { "test.com:80:[::1]",
-    "test.com", 80, TRUE, { IPV6ONLY("::1"), }
-  },
-  { "test.com:80:127.0.0.1",
-    "test.com", 80, TRUE, { "127.0.0.1", }
-  },
-  { "test.com:80:,127.0.0.1",
-    "test.com", 80, TRUE, { "127.0.0.1", }
-  },
-  { "test.com:80:127.0.0.1,",
-    "test.com", 80, TRUE, { "127.0.0.1", }
-  },
-  { "test.com:0:127.0.0.1",
-    "test.com", 0, TRUE, { "127.0.0.1", }
-  },
-  { "+test.com:80:127.0.0.1,",
-    "test.com", 80, FALSE, { "127.0.0.1", }
-  },
-};
-
 UNITTEST_START
 {
+  struct testcase {
+    /* host:port:address[,address]... */
+    const char *optval;
+
+    /* lowercase host and port to retrieve the addresses from hostcache */
+    const char *host;
+    int port;
+
+    /* whether we expect a permanent or non-permanent cache entry */
+    bool permanent;
+
+    /* 0 to 9 addresses expected from hostcache */
+    const char *address[10];
+  };
+
+  /* CURLOPT_RESOLVE address parsing tests */
+  static const struct testcase tests[] = {
+    /* spaces aren't allowed, for now */
+    { "test.com:80:127.0.0.1, 127.0.0.2",
+      "test.com", 80, TRUE, { NULL, }
+    },
+    { "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
+      "test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
+    },
+    { "test.com:80:::1,127.0.0.1",
+      "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
+    },
+    { "test.com:80:[::1],127.0.0.1",
+      "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
+    },
+    { "test.com:80:::1",
+      "test.com", 80, TRUE, { IPV6ONLY("::1"), }
+    },
+    { "test.com:80:[::1]",
+      "test.com", 80, TRUE, { IPV6ONLY("::1"), }
+    },
+    { "test.com:80:127.0.0.1",
+      "test.com", 80, TRUE, { "127.0.0.1", }
+    },
+    { "test.com:80:,127.0.0.1",
+      "test.com", 80, TRUE, { "127.0.0.1", }
+    },
+    { "test.com:80:127.0.0.1,",
+      "test.com", 80, TRUE, { "127.0.0.1", }
+    },
+    { "test.com:0:127.0.0.1",
+      "test.com", 0, TRUE, { "127.0.0.1", }
+    },
+    { "+test.com:80:127.0.0.1,",
+      "test.com", 80, FALSE, { "127.0.0.1", }
+    },
+  };
+
   int i;
   struct Curl_multi *multi = NULL;
   struct Curl_easy *easy = NULL;
index c0b4058e26b68777932b4a835eca6b628f4db966..19dcb1771cde46f93808731c21dcc31930b4ccd5 100644 (file)
@@ -43,19 +43,6 @@ static CURLcode unit_setup(void)
   return res;
 }
 
-struct testcase {
-  /* host:port:address[,address]... */
-  const char *optval;
-
-  /* lowercase host and port to retrieve the addresses from hostcache */
-  const char *host;
-  int port;
-
-  /* 0 to 9 addresses expected from hostcache */
-  const char *address[10];
-};
-
-
 /* CURLOPT_RESOLVE address parsing test - to test the following defect fix:
 
  1) if there is already existing host:port pair in the DNS cache and
@@ -88,18 +75,30 @@ Test:
  expected result: cached address has zero timestamp and new address
 */
 
-static const struct testcase tests[] = {
-  /* spaces aren't allowed, for now */
-  { "test.com:80:127.0.0.1",
-    "test.com", 80, { "127.0.0.1", }
-  },
-  { "test.com:80:127.0.0.2",
-    "test.com", 80, { "127.0.0.2", }
-  },
-};
-
 UNITTEST_START
 {
+  struct testcase {
+    /* host:port:address[,address]... */
+    const char *optval;
+
+    /* lowercase host and port to retrieve the addresses from hostcache */
+    const char *host;
+    int port;
+
+    /* 0 to 9 addresses expected from hostcache */
+    const char *address[10];
+  };
+
+  static const struct testcase tests[] = {
+    /* spaces aren't allowed, for now */
+    { "test.com:80:127.0.0.1",
+      "test.com", 80, { "127.0.0.1", }
+    },
+    { "test.com:80:127.0.0.2",
+      "test.com", 80, { "127.0.0.2", }
+    },
+  };
+
   int i;
   struct Curl_multi *multi = NULL;
   struct Curl_easy *easy = NULL;
index 20067c67e97938838111e654e7deee34fb539289..4520503c9eb72b4a7407fa68f5c59cd2172cffa3 100644 (file)
@@ -27,9 +27,9 @@
 #include <uint-hash.h>
 #include <memdebug.h> /* LAST include file */
 
-static struct uint_hash hash_static;
+static struct uint_hash t1616_hash_static;
 
-static void mydtor(unsigned int id, void *elem)
+static void t1616_mydtor(unsigned int id, void *elem)
 {
   int *ptr = (int *)elem;
   (void)id;
@@ -38,13 +38,13 @@ static void mydtor(unsigned int id, void *elem)
 
 static CURLcode unit_setup(void)
 {
-  Curl_uint_hash_init(&hash_static, 15, mydtor);
+  Curl_uint_hash_init(&t1616_hash_static, 15, t1616_mydtor);
   return CURLE_OK;
 }
 
 static void unit_stop(void)
 {
-  Curl_uint_hash_destroy(&hash_static);
+  Curl_uint_hash_destroy(&t1616_hash_static);
 }
 
 UNITTEST_START
@@ -59,27 +59,27 @@ UNITTEST_START
   value = malloc(sizeof(int));
   abort_unless(value != NULL, "Out of memory");
   *value = 199;
-  ok = Curl_uint_hash_set(&hash_static, key, value);
+  ok = Curl_uint_hash_set(&t1616_hash_static, key, value);
   if(!ok)
     free(value);
   abort_unless(ok, "insertion into hash failed");
-  v = Curl_uint_hash_get(&hash_static, key);
+  v = Curl_uint_hash_get(&t1616_hash_static, key);
   abort_unless(v == value, "lookup present entry failed");
-  v = Curl_uint_hash_get(&hash_static, key2);
+  v = Curl_uint_hash_get(&t1616_hash_static, key2);
   abort_unless(!v, "lookup missing entry failed");
-  Curl_uint_hash_clear(&hash_static);
+  Curl_uint_hash_clear(&t1616_hash_static);
 
   /* Attempt to add another key/value pair */
   value2 = malloc(sizeof(int));
   abort_unless(value2 != NULL, "Out of memory");
   *value2 = 204;
-  ok = Curl_uint_hash_set(&hash_static, key2, value2);
+  ok = Curl_uint_hash_set(&t1616_hash_static, key2, value2);
   if(!ok)
     free(value2);
   abort_unless(ok, "insertion into hash failed");
-  v = Curl_uint_hash_get(&hash_static, key2);
+  v = Curl_uint_hash_get(&t1616_hash_static, key2);
   abort_unless(v == value2, "lookup present entry failed");
-  v = Curl_uint_hash_get(&hash_static, key);
+  v = Curl_uint_hash_get(&t1616_hash_static, key);
   abort_unless(!v, "lookup missing entry failed");
 
 UNITTEST_STOP
index 29c8539c9d6074d6bd758d817b45dbf56cce6c2d..736f69e081fd89a0d99a7ed5e4e9837a023c8010 100644 (file)
@@ -40,7 +40,7 @@ static void unit_stop(void)
   curl_global_cleanup();
 }
 
-static void test_parse(
+static void t1620_parse(
   const char *input,
   const char *exp_username,
   const char *exp_password,
@@ -106,20 +106,21 @@ UNITTEST_START
   rc = Curl_init_do(empty, empty->conn);
   fail_unless(rc == CURLE_OK, "Curl_init_do() failed");
 
-  test_parse("hostname", "hostname", NULL, NULL);
-  test_parse("user:password", "user", "password", NULL);
-  test_parse("user:password;options", "user", "password", "options");
-  test_parse("user:password;options;more", "user", "password", "options;more");
-  test_parse("", "", NULL, NULL);
-  test_parse(":", "", "", NULL);
-  test_parse(":;", "", "", NULL);
-  test_parse(":password", "", "password", NULL);
-  test_parse(":password;", "", "password", NULL);
-  test_parse(";options", "", NULL, "options");
-  test_parse("user;options", "user", NULL, "options");
-  test_parse("user:;options", "user", "", "options");
-  test_parse("user;options:password", "user", "password", "options");
-  test_parse("user;options:", "user", "", "options");
+  t1620_parse("hostname", "hostname", NULL, NULL);
+  t1620_parse("user:password", "user", "password", NULL);
+  t1620_parse("user:password;options", "user", "password", "options");
+  t1620_parse("user:password;options;more", "user", "password",
+              "options;more");
+  t1620_parse("", "", NULL, NULL);
+  t1620_parse(":", "", "", NULL);
+  t1620_parse(":;", "", "", NULL);
+  t1620_parse(":password", "", "password", NULL);
+  t1620_parse(":password;", "", "password", NULL);
+  t1620_parse(";options", "", NULL, "options");
+  t1620_parse("user;options", "user", NULL, "options");
+  t1620_parse("user:;options", "user", "", "options");
+  t1620_parse("user;options:password", "user", "password", "options");
+  t1620_parse("user;options:", "user", "", "options");
 
   Curl_freeset(empty);
   for(i = (enum dupstring)0; i < STRING_LAST; i++) {
index c8cd06dacf1cba0f7941dceecc30c7f06ba9acd1..a4a6ecd6699c2a0d317ee7b1c90570824d2770cf 100644 (file)
@@ -32,7 +32,7 @@
  * updated to still be valid.
  */
 
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1652_easy;
 
 static char input[4096];
 static char output[4096];
@@ -45,9 +45,8 @@ int debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
  * for the unit test to inspect. Since we know that we're only dealing with
  * text we can afford the luxury of skipping the type check here.
  */
-int
-debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
-                void *userptr)
+int debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
+              void *userptr)
 {
   (void)handle;
   (void)type;
@@ -58,26 +57,24 @@ debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
   return 0;
 }
 
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  testdata = curl_easy_init();
-  if(!testdata) {
+  t1652_easy = curl_easy_init();
+  if(!t1652_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
-  curl_easy_setopt(testdata, CURLOPT_DEBUGFUNCTION, debugf_cb);
-  curl_easy_setopt(testdata, CURLOPT_VERBOSE, 1L);
+  curl_easy_setopt(t1652_easy, CURLOPT_DEBUGFUNCTION, debugf_cb);
+  curl_easy_setopt(t1652_easy, CURLOPT_VERBOSE, 1L);
   return res;
 }
 
-static void
-unit_stop(void)
+static void unit_stop(void)
 {
-  curl_easy_cleanup(testdata);
+  curl_easy_cleanup(t1652_easy);
   curl_global_cleanup();
 }
 
@@ -101,62 +98,65 @@ UNITTEST_START
 #endif
 #endif
 
-/* Injecting a simple short string via a format */
-curl_msnprintf(input, sizeof(input), "Simple Test");
-Curl_infof(testdata, "%s", input);
-fail_unless(verify(output, input) == 0, "Simple string test");
-
-/* Injecting a few different variables with a format */
-Curl_infof(testdata, "%s %u testing %lu", input, 42, 43L);
-fail_unless(verify(output, "Simple Test 42 testing 43\n") == 0,
-            "Format string");
-
-/* Variations of empty strings */
-Curl_infof(testdata, "");
-fail_unless(strlen(output) == 1, "Empty string");
-Curl_infof(testdata, "%s", (char *)NULL);
-fail_unless(verify(output, "(nil)") == 0, "Passing NULL as string");
-
-/* Note: libcurl's tracebuffer hold 2048 bytes, so the max strlen() we
- * get out of it is 2047, since we need a \0 at the end.
- * Curl_infof() in addition adds a \n at the end, making the effective
- * output 2046 characters.
- * Any input that long or longer will truncated, ending in '...\n'.
- */
-
-/* A string just long enough to not be truncated */
-memset(input, '\0', sizeof(input));
-memset(input, 'A', 2045);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-/* output is input + \n */
-fail_unless(strlen(output) == 2046, "No truncation of infof input");
-fail_unless(verify(output, input) == 0, "No truncation of infof input");
-fail_unless(output[sizeof(output) - 1] == '\0',
-            "No truncation of infof input");
-
-/* Just over the limit without newline for truncation via '...' */
-memset(input + 2045, 'A', 4);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-fail_unless(strlen(output) == 2047, "Truncation of infof input 1");
-fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 1");
-
-/* Just over the limit with newline for truncation via '...' */
-memset(input + 2045, 'A', 4);
-memset(input + 2045 + 4, '\n', 1);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-fail_unless(strlen(output) == 2047, "Truncation of infof input 2");
-fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 2");
-
-/* Way over the limit for truncation via '...' */
-memset(input, '\0', sizeof(input));
-memset(input, 'A', sizeof(input) - 1);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-fail_unless(strlen(output) == 2047, "Truncation of infof input 3");
-fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 3");
+  /* Injecting a simple short string via a format */
+  curl_msnprintf(input, sizeof(input), "Simple Test");
+  Curl_infof(t1652_easy, "%s", input);
+  fail_unless(verify(output, input) == 0, "Simple string test");
+
+  /* Injecting a few different variables with a format */
+  Curl_infof(t1652_easy, "%s %u testing %lu", input, 42, 43L);
+  fail_unless(verify(output, "Simple Test 42 testing 43\n") == 0,
+              "Format string");
+
+  /* Variations of empty strings */
+  Curl_infof(t1652_easy, "");
+  fail_unless(strlen(output) == 1, "Empty string");
+  Curl_infof(t1652_easy, "%s", (char *)NULL);
+  fail_unless(verify(output, "(nil)") == 0, "Passing NULL as string");
+
+  /* Note: libcurl's tracebuffer hold 2048 bytes, so the max strlen() we
+   * get out of it is 2047, since we need a \0 at the end.
+   * Curl_infof() in addition adds a \n at the end, making the effective
+   * output 2046 characters.
+   * Any input that long or longer will truncated, ending in '...\n'.
+   */
+
+  /* A string just long enough to not be truncated */
+  memset(input, '\0', sizeof(input));
+  memset(input, 'A', 2045);
+  Curl_infof(t1652_easy, "%s", input);
+  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  /* output is input + \n */
+  fail_unless(strlen(output) == 2046, "No truncation of infof input");
+  fail_unless(verify(output, input) == 0, "No truncation of infof input");
+  fail_unless(output[sizeof(output) - 1] == '\0',
+              "No truncation of infof input");
+
+  /* Just over the limit without newline for truncation via '...' */
+  memset(input + 2045, 'A', 4);
+  Curl_infof(t1652_easy, "%s", input);
+  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  fail_unless(strlen(output) == 2047, "Truncation of infof input 1");
+  fail_unless(output[sizeof(output) - 1] == '\0',
+              "Truncation of infof input 1");
+
+  /* Just over the limit with newline for truncation via '...' */
+  memset(input + 2045, 'A', 4);
+  memset(input + 2045 + 4, '\n', 1);
+  Curl_infof(t1652_easy, "%s", input);
+  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  fail_unless(strlen(output) == 2047, "Truncation of infof input 2");
+  fail_unless(output[sizeof(output) - 1] == '\0',
+              "Truncation of infof input 2");
+
+  /* Way over the limit for truncation via '...' */
+  memset(input, '\0', sizeof(input));
+  memset(input, 'A', sizeof(input) - 1);
+  Curl_infof(t1652_easy, "%s", input);
+  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  fail_unless(strlen(output) == 2047, "Truncation of infof input 3");
+  fail_unless(output[sizeof(output) - 1] == '\0',
+              "Truncation of infof input 3");
 
 #if defined(CURL_GNUC_DIAG) && !defined(__clang__)
 #pragma GCC diagnostic pop
index ae10e8bb9068659689057c7ce18c3b7735d2bb63..76958450eabef3a4dc22b9d9012aca429aa20199 100644 (file)
 
 static CURLU *u;
 
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
 {
   return CURLE_OK;
 }
 
-static void
-unit_stop(void)
+static void unit_stop(void)
 {
   curl_global_cleanup();
 }
index 73bf17a0c61ffd3dc378eca6f897220d9d55cbf1..7515df305e73006cd250433947107895665af5c9 100644 (file)
 #include "urldata.h"
 #include "altsvc.h"
 
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
 {
   return CURLE_OK;
 }
 
-static void
-unit_stop(void)
+static void unit_stop(void)
 {
   curl_global_cleanup();
 }
index 2ab9aa33324fbc0c1108659c004220c862e90916..4e24d01a800c5939fbc8467d75b09f1cec8d270e 100644 (file)
 #include "urldata.h"
 #include "hsts.h"
 
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
 {
   return CURLE_OK;
 }
 
-static void
-unit_stop(void)
+static void unit_stop(void)
 {
   curl_global_cleanup();
 }
index f60d60f625c2e9113217248fcc823a16cb5b6092..bed8c77a8ff945626df40f05f35c63c997ad5f0b 100644 (file)
@@ -48,7 +48,7 @@ static void unit_stop(void)
   curl_global_cleanup();
 }
 
-static void test_parse(
+static void t1663_parse(
   const char *input_data,
   const char *exp_dev,
   const char *exp_iface,
@@ -81,17 +81,17 @@ static void test_parse(
 
 UNITTEST_START
 {
-  test_parse("dev", "dev", NULL, NULL, CURLE_OK);
-  test_parse("if!eth0", NULL, "eth0", NULL, CURLE_OK);
-  test_parse("host!myname", NULL, NULL, "myname", CURLE_OK);
-  test_parse("ifhost!eth0!myname", NULL, "eth0", "myname", CURLE_OK);
-  test_parse("", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
-  test_parse("!", "!", NULL, NULL, CURLE_OK);
-  test_parse("if!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
-  test_parse("if!eth0!blubb", NULL, "eth0!blubb", NULL, CURLE_OK);
-  test_parse("host!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
-  test_parse("ifhost!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
-  test_parse("ifhost!eth0", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
-  test_parse("ifhost!eth0!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+  t1663_parse("dev", "dev", NULL, NULL, CURLE_OK);
+  t1663_parse("if!eth0", NULL, "eth0", NULL, CURLE_OK);
+  t1663_parse("host!myname", NULL, NULL, "myname", CURLE_OK);
+  t1663_parse("ifhost!eth0!myname", NULL, "eth0", "myname", CURLE_OK);
+  t1663_parse("", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+  t1663_parse("!", "!", NULL, NULL, CURLE_OK);
+  t1663_parse("if!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+  t1663_parse("if!eth0!blubb", NULL, "eth0!blubb", NULL, CURLE_OK);
+  t1663_parse("host!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+  t1663_parse("ifhost!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+  t1663_parse("ifhost!eth0", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+  t1663_parse("ifhost!eth0!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
 }
 UNITTEST_STOP
index 16f5c5ce6b44a6fffaf6affae44faec9ba264067..6aa922160f616c21aaf42ff392d7f4aa1b796fd7 100644 (file)
 #include "curl_trc.h"
 #include "memdebug.h"
 
-static CURL *easy;
+static CURL *t2600_easy;
 
 static CURLcode unit_setup(void)
 {
   CURLcode res = CURLE_OK;
 
   global_init(CURL_GLOBAL_ALL);
-  easy = curl_easy_init();
-  if(!easy) {
+  t2600_easy = curl_easy_init();
+  if(!t2600_easy) {
     curl_global_cleanup();
     return CURLE_OUT_OF_MEMORY;
   }
   curl_global_trace("all");
-  curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L);
+  curl_easy_setopt(t2600_easy, CURLOPT_VERBOSE, 1L);
   return res;
 }
 
 static void unit_stop(void)
 {
-  curl_easy_cleanup(easy);
+  curl_easy_cleanup(t2600_easy);
   curl_global_cleanup();
 }
 
@@ -312,23 +312,23 @@ static void test_connect(struct test_case *tc)
 
   list = curl_slist_append(NULL, tc->resolve_info);
   fail_unless(list, "error allocating resolve list entry");
-  curl_easy_setopt(easy, CURLOPT_RESOLVE, list);
-  curl_easy_setopt(easy, CURLOPT_IPRESOLVE, (long)tc->ip_version);
-  curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS,
+  curl_easy_setopt(t2600_easy, CURLOPT_RESOLVE, list);
+  curl_easy_setopt(t2600_easy, CURLOPT_IPRESOLVE, (long)tc->ip_version);
+  curl_easy_setopt(t2600_easy, CURLOPT_CONNECTTIMEOUT_MS,
                    (long)tc->connect_timeout_ms);
-  curl_easy_setopt(easy, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
+  curl_easy_setopt(t2600_easy, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
                    (long)tc->he_timeout_ms);
 
-  curl_easy_setopt(easy, CURLOPT_URL, tc->url);
+  curl_easy_setopt(t2600_easy, CURLOPT_URL, tc->url);
   memset(&tr, 0, sizeof(tr));
   tr.cf6.family = "v6";
   tr.cf4.family = "v4";
 
   tr.started = curlx_now();
-  tr.result = curl_easy_perform(easy);
+  tr.result = curl_easy_perform(t2600_easy);
   tr.ended = curlx_now();
 
-  curl_easy_setopt(easy, CURLOPT_RESOLVE, NULL);
+  curl_easy_setopt(t2600_easy, CURLOPT_RESOLVE, NULL);
   curl_slist_free_all(list);
   list = NULL;
   current_tc = NULL;
index 60e34ac337c875d22e67c11697155cdae7bd4927..866be9eca81b92f49d01e0d910f1e0361e1dabc9 100644 (file)
@@ -42,9 +42,8 @@ static CURLcode unit_setup(void)
   return CURLE_OK;
 }
 
-static CURLcode unit_stop(void)
+static void unit_stop(void)
 {
-  return CURLE_OK;
 }
 
 #if defined(CURL_GNUC_DIAG) || defined(__clang__)