From: Viktor Szakats Date: Wed, 11 Jun 2025 14:28:42 +0000 (+0200) Subject: libtests: stop building the sames source multiple times X-Git-Tag: curl-8_15_0~281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9460d623776f6e439e8e5851cfa17b3b0a6cdc0;p=thirdparty%2Fcurl.git libtests: stop building the sames source multiple times After this patch there is no more double/multiple compile of the same libtest source under a different libtest ID. Each libtest is compiled once, and changing behavior at runtime based on test ID. - drop recently added physical clones for two prevously multi-compiled tests: - merge lib587 into lib554 again, branch at runtime. - merge lib645 into lib643 again, branch at runtime. - replace existing dynamic branching to use `testnum` instead of a manually rolled `testno` based on an extra command-line argument. lib1571, lib1576. - mk-bundle.pl: stop defining `LIB*` macros. No longer used. - libtests: drop all `LIB*_C` guards. - Make these tests branch at runtime, stop building copies: - lib585, based on lib500 - lib565, based on lib510 - lib529, based on lib525 - lib527, lib532, based on lib526 - lib545, based on lib544 - lib548, based on lib547 - lib696, based on lib556 - lib584, based on lib589 - lib1539, based on lib1514 - lib1543, based on lib1518 - lib1917, based on lib1916 - lib1946, based on lib1940 - lib671, 672, 673, based on lib670 Follow-up to 02dd471bbf8e04fc595ad0f28c965c278ffcefd0 #17591 Follow-up to 6897aeb10561b55c6659866fc0518dd67422f267 #17468 Closes #17598 --- diff --git a/tests/data/test1539 b/tests/data/test1539 index 3ef12fe5ee..0431ba670b 100644 --- a/tests/data/test1539 +++ b/tests/data/test1539 @@ -24,7 +24,7 @@ Connection: close http -lib%TESTNUMBER +lib1514 HTTP 1.0 POST with read callback and unknown data size diff --git a/tests/data/test1543 b/tests/data/test1543 index be7ede2092..3aefe57ef1 100644 --- a/tests/data/test1543 +++ b/tests/data/test1543 @@ -38,7 +38,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib1518 diff --git a/tests/data/test1571 b/tests/data/test1571 index 7512330f26..e75423a73c 100644 --- a/tests/data/test1571 +++ b/tests/data/test1571 @@ -69,7 +69,7 @@ lib%TESTNUMBER CURLFOLLOW_OBEYCODE with custom POST method, 302 => GET -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1571 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1572 b/tests/data/test1572 index edd2fdeafb..4c2329506e 100644 --- a/tests/data/test1572 +++ b/tests/data/test1572 @@ -69,7 +69,7 @@ lib1571 CURLFOLLOW_OBEYCODE with custom POST method, 308 => custom -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1571 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1573 b/tests/data/test1573 index 8a4af400f4..0e36d620f8 100644 --- a/tests/data/test1573 +++ b/tests/data/test1573 @@ -69,7 +69,7 @@ lib1571 CURLFOLLOW_OBEYCODE with custom GET method, 301 => custom -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1573 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1574 b/tests/data/test1574 index a191ed4c32..6afc24b2ab 100644 --- a/tests/data/test1574 +++ b/tests/data/test1574 @@ -69,7 +69,7 @@ lib1571 CURLFOLLOW_FIRSTONLY with custom GET method, 301 => GET -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1574 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1575 b/tests/data/test1575 index 90d49c99a8..1d1e4b7ed3 100644 --- a/tests/data/test1575 +++ b/tests/data/test1575 @@ -69,7 +69,7 @@ lib1571 CURLFOLLOW_FIRSTONLY with custom POST method, 308 => POST -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1575 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1576 b/tests/data/test1576 index 5ed2c23347..3b243bc632 100644 --- a/tests/data/test1576 +++ b/tests/data/test1576 @@ -69,7 +69,7 @@ lib%TESTNUMBER CURLFOLLOW_OBEYCODE with custom PUT method, 302 => custom -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1576 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1578 b/tests/data/test1578 index d6ebb6e53f..ba43782506 100644 --- a/tests/data/test1578 +++ b/tests/data/test1578 @@ -69,7 +69,7 @@ lib1576 CURLFOLLOW_FIRSTONLY with custom PUT method, 302 => PUT -http://%HOSTIP:%HTTPPORT/%TESTNUMBER %TESTNUMBER +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1581 b/tests/data/test1581 index a8e387a0f1..98c78b613a 100644 --- a/tests/data/test1581 +++ b/tests/data/test1581 @@ -69,7 +69,7 @@ lib1571 CURLFOLLOW_OBEYCODE with custom POST301 method, 301 => custom -http://%HOSTIP:%HTTPPORT/%TESTNUMBER 1581 +http://%HOSTIP:%HTTPPORT/%TESTNUMBER diff --git a/tests/data/test1917 b/tests/data/test1917 index a2cb981b72..622623dc55 100644 --- a/tests/data/test1917 +++ b/tests/data/test1917 @@ -33,7 +33,7 @@ mqtt MQTT PUBLISH with CURLOPT_POST set (no payload) -lib%TESTNUMBER +lib1916 "mqtt://%HOSTIP:%MQTTPORT/%20" diff --git a/tests/data/test1946 b/tests/data/test1946 index 220df012b8..20854e16ba 100644 --- a/tests/data/test1946 +++ b/tests/data/test1946 @@ -44,7 +44,7 @@ http curl_easy_header with redirect but get headers from first request -lib%TESTNUMBER +lib1940 diff --git a/tests/data/test527 b/tests/data/test527 index 3a303e9a00..2522af586b 100644 --- a/tests/data/test527 +++ b/tests/data/test527 @@ -27,7 +27,7 @@ file contents should appear once for each file ftp -lib%TESTNUMBER +lib526 FTP RETR same file using different handles but same connection diff --git a/tests/data/test529 b/tests/data/test529 index c92b377ef7..243cc11d77 100644 --- a/tests/data/test529 +++ b/tests/data/test529 @@ -20,7 +20,7 @@ multi ftp -lib%TESTNUMBER +lib525 FTP PORT upload using multi interface (weird cleanup function sequence) diff --git a/tests/data/test532 b/tests/data/test532 index 128b2d8802..255c055188 100644 --- a/tests/data/test532 +++ b/tests/data/test532 @@ -27,7 +27,7 @@ file contents should appear once for each file ftp -lib%TESTNUMBER +lib526 FTP RETR same file using reset handles between each transfer diff --git a/tests/data/test545 b/tests/data/test545 index 1401ebc5ea..0bdb628153 100644 --- a/tests/data/test545 +++ b/tests/data/test545 @@ -26,7 +26,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib544 diff --git a/tests/data/test548 b/tests/data/test548 index 98b43642bd..2ad40e4589 100644 --- a/tests/data/test548 +++ b/tests/data/test548 @@ -73,7 +73,7 @@ http # tool to use -lib%TESTNUMBER +lib547 NTLM diff --git a/tests/data/test565 b/tests/data/test565 index cd398a7435..a6b29e17c2 100644 --- a/tests/data/test565 +++ b/tests/data/test565 @@ -63,7 +63,7 @@ crypto # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib510 diff --git a/tests/data/test584 b/tests/data/test584 index a263e71879..81c9b84037 100644 --- a/tests/data/test584 +++ b/tests/data/test584 @@ -44,7 +44,7 @@ http # tool to invoke -lib%TESTNUMBER +lib589 diff --git a/tests/data/test585 b/tests/data/test585 index 393498c613..e5138cdb17 100644 --- a/tests/data/test585 +++ b/tests/data/test585 @@ -43,7 +43,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib500 diff --git a/tests/data/test586 b/tests/data/test586 index a708f3b595..b1cd990025 100644 --- a/tests/data/test586 +++ b/tests/data/test586 @@ -32,7 +32,7 @@ last line ftp -lib585 +lib500 FTP and open/close socket callbacks diff --git a/tests/data/test587 b/tests/data/test587 index c896a5b6bf..44e1fb047d 100644 --- a/tests/data/test587 +++ b/tests/data/test587 @@ -25,7 +25,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib554 diff --git a/tests/data/test595 b/tests/data/test595 index 13d6bb927d..9a80aa7e26 100644 --- a/tests/data/test595 +++ b/tests/data/test595 @@ -29,7 +29,7 @@ ftp # tool is what to use instead of 'curl' -lib585 +lib500 diff --git a/tests/data/test596 b/tests/data/test596 index 30e401df7a..38f24ab92c 100644 --- a/tests/data/test596 +++ b/tests/data/test596 @@ -29,7 +29,7 @@ ftp # tool is what to use instead of 'curl' -lib585 +lib500 diff --git a/tests/data/test645 b/tests/data/test645 index 68c78ce9a1..c198cbbaeb 100644 --- a/tests/data/test645 +++ b/tests/data/test645 @@ -47,7 +47,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib643 diff --git a/tests/data/test671 b/tests/data/test671 index e49aacd51a..310a902b14 100644 --- a/tests/data/test671 +++ b/tests/data/test671 @@ -40,7 +40,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib670 diff --git a/tests/data/test672 b/tests/data/test672 index 387058d891..e295b2f07b 100644 --- a/tests/data/test672 +++ b/tests/data/test672 @@ -40,7 +40,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib670 diff --git a/tests/data/test673 b/tests/data/test673 index 5cc3e015a3..e4db3cf83a 100644 --- a/tests/data/test673 +++ b/tests/data/test673 @@ -40,7 +40,7 @@ http # tool is what to use instead of 'curl' -lib%TESTNUMBER +lib670 diff --git a/tests/data/test696 b/tests/data/test696 index 1af5fc7a84..2b53c4fc98 100644 --- a/tests/data/test696 +++ b/tests/data/test696 @@ -25,7 +25,7 @@ Connection: close http -lib%TESTNUMBER +lib556 CONNECT_ONLY and doing a second curl_easy_perform diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index d8c5e14c3d..987eecb144 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -38,18 +38,17 @@ SUPPORTFILES = $(TIMEDIFF) $(FIRSTFILES) test.h LIBTESTPROGS = libauthretry libntlmconnect libprereq \ lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib509 \ lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 \ - lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib529 lib530 lib532 \ + lib520 lib521 lib523 lib524 lib525 lib526 lib530 \ lib533 lib536 lib537 lib539 lib540 lib541 lib542 lib543 \ - lib544 lib545 \ - lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 lib557 lib558 \ - lib559 lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 lib570 \ + lib544 \ + lib547 lib549 lib552 lib553 lib554 lib555 lib556 lib557 lib558 \ + lib559 lib560 lib562 lib564 lib566 lib567 lib568 lib569 lib570 \ lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \ - lib583 lib584 lib585 lib586 lib587 lib589 lib590 lib591 lib597 lib598 \ + lib583 lib586 lib589 lib590 lib591 lib597 lib598 \ lib599 \ - lib643 lib645 lib650 lib651 lib652 lib653 lib654 lib655 lib658 \ + lib643 lib650 lib651 lib652 lib653 lib654 lib655 lib658 \ lib659 lib661 lib666 lib667 lib668 \ - lib670 lib671 lib672 lib673 lib674 lib676 lib677 lib678 lib694 lib695 \ - lib696 \ + lib670 lib674 lib676 lib677 lib678 lib694 lib695 \ lib751 \ lib1156 \ lib1301 \ @@ -59,8 +58,8 @@ LIBTESTPROGS = libauthretry libntlmconnect libprereq \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \ lib1518 lib1520 lib1521 lib1522 lib1523 \ lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \ - lib1534 lib1535 lib1536 lib1537 lib1538 lib1539 \ - lib1540 lib1541 lib1542 lib1543 lib1545 \ + lib1534 lib1535 lib1536 lib1537 lib1538 \ + lib1540 lib1541 lib1542 lib1545 \ lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \ lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 lib1571 \ lib1576 \ @@ -70,9 +69,9 @@ LIBTESTPROGS = libauthretry libntlmconnect libprereq \ \ lib1900 lib1901 \ lib1903 lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 lib1913 \ - lib1915 lib1916 lib1917 lib1918 lib1919 \ + lib1915 lib1916 lib1918 lib1919 \ lib1933 lib1934 lib1935 lib1936 lib1937 lib1938 lib1939 lib1940 \ - lib1945 lib1946 lib1947 lib1948 lib1955 lib1956 lib1957 lib1958 lib1959 \ + lib1945 lib1947 lib1948 lib1955 lib1956 lib1957 lib1958 lib1959 \ lib1960 lib1964 \ lib1970 lib1971 lib1972 lib1973 lib1974 lib1975 lib1977 lib1978 \ lib2301 lib2302 lib2304 lib2306 lib2308 lib2309 \ @@ -151,23 +150,10 @@ lib525_LDADD = $(TESTUTIL_LIBS) lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib526_LDADD = $(TESTUTIL_LIBS) -lib526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB526 - -lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib527_LDADD = $(TESTUTIL_LIBS) -lib527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB527 - -lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE) -lib529_LDADD = $(TESTUTIL_LIBS) -lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529 lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib530_LDADD = $(TESTUTIL_LIBS) -lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib532_LDADD = $(TESTUTIL_LIBS) -lib532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB532 - lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib533_LDADD = $(TESTUTIL_LIBS) @@ -189,14 +175,8 @@ lib543_SOURCES = lib543.c $(SUPPORTFILES) lib544_SOURCES = lib544.c $(SUPPORTFILES) -lib545_SOURCES = lib544.c $(SUPPORTFILES) -lib545_CPPFLAGS = $(AM_CPPFLAGS) -DLIB545 - lib547_SOURCES = lib547.c $(SUPPORTFILES) -lib548_SOURCES = lib547.c $(SUPPORTFILES) -lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548 - lib549_SOURCES = lib549.c $(SUPPORTFILES) lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS) @@ -224,9 +204,6 @@ lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib564_LDADD = $(TESTUTIL_LIBS) -lib565_SOURCES = lib510.c $(SUPPORTFILES) -lib565_CPPFLAGS = $(AM_CPPFLAGS) -DLIB565 - lib566_SOURCES = lib566.c $(SUPPORTFILES) $(MULTIBYTE) lib567_SOURCES = lib567.c $(SUPPORTFILES) @@ -265,17 +242,8 @@ lib582_LDADD = $(TESTUTIL_LIBS) lib583_SOURCES = lib583.c $(SUPPORTFILES) -lib584_SOURCES = lib589.c $(SUPPORTFILES) -lib584_CPPFLAGS = $(AM_CPPFLAGS) -DLIB584 - -lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(MULTIBYTE) -lib585_LDADD = $(TESTUTIL_LIBS) -lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 - lib586_SOURCES = lib586.c $(SUPPORTFILES) -lib587_SOURCES = lib587.c $(SUPPORTFILES) - lib589_SOURCES = lib589.c $(SUPPORTFILES) lib590_SOURCES = lib590.c $(SUPPORTFILES) @@ -292,8 +260,6 @@ lib599_SOURCES = lib599.c $(SUPPORTFILES) $(MULTIBYTE) lib643_SOURCES = lib643.c $(SUPPORTFILES) -lib645_SOURCES = lib645.c $(SUPPORTFILES) - lib650_SOURCES = lib650.c $(SUPPORTFILES) lib651_SOURCES = lib651.c $(SUPPORTFILES) @@ -324,18 +290,6 @@ lib668_LDADD = $(TESTUTIL_LIBS) lib670_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib670_LDADD = $(TESTUTIL_LIBS) -lib670_CPPFLAGS = $(AM_CPPFLAGS) -DLIB670 - -lib671_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib671_LDADD = $(TESTUTIL_LIBS) -lib671_CPPFLAGS = $(AM_CPPFLAGS) -DLIB671 - -lib672_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib672_LDADD = $(TESTUTIL_LIBS) -lib672_CPPFLAGS = $(AM_CPPFLAGS) -DLIB672 - -lib673_SOURCES = lib670.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib673_LDADD = $(TESTUTIL_LIBS) lib674_SOURCES = lib674.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib674_LDADD = $(TESTUTIL_LIBS) @@ -353,9 +307,6 @@ lib694_SOURCES = lib694.c $(SUPPORTFILES) lib695_SOURCES = lib695.c $(SUPPORTFILES) -lib696_SOURCES = lib556.c $(SUPPORTFILES) $(WARNLESS) -lib696_CPPFLAGS = $(AM_CPPFLAGS) -DLIB696 - lib751_SOURCES = lib751.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib751_LDADD = $(TESTUTIL_LIBS) @@ -466,10 +417,6 @@ lib1537_LDADD = $(TESTUTIL_LIBS) lib1538_SOURCES = lib1538.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1538_LDADD = $(TESTUTIL_LIBS) -lib1539_SOURCES = lib1514.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib1539_LDADD = $(TESTUTIL_LIBS) -lib1539_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1539 - lib1540_SOURCES = lib1540.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(WARNLESS) lib1540_LDADD = $(TESTUTIL_LIBS) @@ -479,9 +426,6 @@ lib1541_LDADD = $(TESTUTIL_LIBS) lib1542_SOURCES = lib1542.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) $(WARNLESS) lib1542_LDADD = $(TESTUTIL_LIBS) -lib1543_SOURCES = lib1518.c $(SUPPORTFILES) -lib1543_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1543 - lib1545_SOURCES = lib1545.c $(SUPPORTFILES) lib1550_SOURCES = lib1550.c $(SUPPORTFILES) @@ -527,7 +471,6 @@ lib1568_SOURCES = lib1568.c $(SUPPORTFILES) lib1569_SOURCES = lib1569.c $(SUPPORTFILES) lib1571_SOURCES = lib1571.c $(SUPPORTFILES) -lib1571_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1571 lib1576_SOURCES = lib1576.c $(SUPPORTFILES) @@ -588,9 +531,6 @@ lib1915_LDADD = $(TESTUTIL_LIBS) lib1916_SOURCES = lib1916.c $(SUPPORTFILES) $(WARNLESS) -lib1917_SOURCES = lib1916.c $(SUPPORTFILES) $(WARNLESS) -lib1917_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1917 - lib1918_SOURCES = lib1918.c $(SUPPORTFILES) $(WARNLESS) lib1919_SOURCES = lib1919.c $(SUPPORTFILES) $(WARNLESS) @@ -622,10 +562,6 @@ lib1940_LDADD = $(TESTUTIL_LIBS) lib1945_SOURCES = lib1945.c $(SUPPORTFILES) lib1945_LDADD = $(TESTUTIL_LIBS) -lib1946_SOURCES = lib1940.c $(SUPPORTFILES) -lib1946_LDADD = $(TESTUTIL_LIBS) -lib1946_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1946 - lib1947_SOURCES = lib1947.c $(SUPPORTFILES) lib1947_LDADD = $(TESTUTIL_LIBS) diff --git a/tests/libtest/lib1514.c b/tests/libtest/lib1514.c index 9596fb7685..612fad8f4e 100644 --- a/tests/libtest/lib1514.c +++ b/tests/libtest/lib1514.c @@ -30,8 +30,6 @@ #include "memdebug.h" -#ifndef LIB1514_C -#define LIB1514_C struct t1514_WriteThis { char *readptr; size_t sizeleft; @@ -53,7 +51,6 @@ static size_t t1514_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) return 0; /* no more data left to deliver */ } -#endif CURLcode test(char *URL) { @@ -74,10 +71,11 @@ CURLcode test(char *URL) /* Purposely omit to set CURLOPT_POSTFIELDSIZE */ easy_setopt(curl, CURLOPT_READFUNCTION, t1514_read_cb); easy_setopt(curl, CURLOPT_READDATA, &pooh); -#ifdef LIB1539 - /* speak HTTP 1.0 - no chunked! */ - easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); -#endif + + if(testnum == 1539) { + /* speak HTTP 1.0 - no chunked! */ + easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + } result = curl_easy_perform(curl); diff --git a/tests/libtest/lib1518.c b/tests/libtest/lib1518.c index 2278d1f4c0..d317169ceb 100644 --- a/tests/libtest/lib1518.c +++ b/tests/libtest/lib1518.c @@ -27,8 +27,6 @@ /* Test inspired by github issue 3340 */ -#ifndef LIB1518_C -#define LIB1518_C static size_t t1518_write_cb(char *buffer, size_t size, size_t nitems, void *outstream) { @@ -38,7 +36,6 @@ static size_t t1518_write_cb(char *buffer, size_t size, size_t nitems, (void)outstream; return 0; } -#endif CURLcode test(char *URL) { @@ -48,18 +45,15 @@ CURLcode test(char *URL) long curlRedirectCount; char *effectiveUrl = NULL; char *redirectUrl = NULL; -#ifdef LIB1543 CURLU *urlu = NULL; -#endif curl = curl_easy_init(); if(!curl) { curl_mfprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } -#ifdef LIB1543 - /* set CURLOPT_URLU */ - { + if(testnum == 1543) { + /* set CURLOPT_URLU */ CURLUcode rc = CURLUE_OK; urlu = curl_url(); if(urlu) @@ -68,14 +62,13 @@ CURLcode test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_CURLU, urlu); + test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + } + else { + test_setopt(curl, CURLOPT_URL, URL); + /* just to make it explicit and visible in this test: */ + test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L); } - test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); -#else - test_setopt(curl, CURLOPT_URL, URL); - /* just to make it explicit and visible in this test: */ - test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L); -#endif - /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); @@ -104,8 +97,7 @@ test_cleanup: /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); -#ifdef LIB1543 - curl_url_cleanup(urlu); -#endif + if(testnum == 1543) + curl_url_cleanup(urlu); return res; } diff --git a/tests/libtest/lib1571.c b/tests/libtest/lib1571.c index 599475742e..faf178a6fb 100644 --- a/tests/libtest/lib1571.c +++ b/tests/libtest/lib1571.c @@ -29,7 +29,6 @@ CURLcode test(char *URL) { CURLcode res; CURL *curl; - int testno = atoi(libtest_arg2); if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); @@ -46,15 +45,16 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_URL, URL); - if((testno == 1571) || (testno == 1575) || (testno == 1581)) { + if((testnum == 1571) || (testnum == 1572) || + (testnum == 1575) || (testnum == 1581)) { test_setopt(curl, CURLOPT_POSTFIELDS, "moo"); } - if(testno == 1581) { + if(testnum == 1581) { test_setopt(curl, CURLOPT_POSTREDIR, (long)CURL_REDIR_POST_301); } test_setopt(curl, CURLOPT_CUSTOMREQUEST, "IGLOO"); - if((testno == 1574) || (testno == 1575)) { + if((testnum == 1574) || (testnum == 1575)) { test_setopt(curl, CURLOPT_FOLLOWLOCATION, CURLFOLLOW_FIRSTONLY); } else { diff --git a/tests/libtest/lib1576.c b/tests/libtest/lib1576.c index 98a7a6c7b1..df34a9a205 100644 --- a/tests/libtest/lib1576.c +++ b/tests/libtest/lib1576.c @@ -52,7 +52,6 @@ CURLcode test(char *URL) CURLcode res; CURL *curl; struct curl_slist *pHeaderList = NULL; - int testno = atoi(libtest_arg2); if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); @@ -75,7 +74,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1576_testdata)); test_setopt(curl, CURLOPT_CUSTOMREQUEST, "CURL"); - if(testno == 1578) { + if(testnum == 1578 || testnum == 1580) { test_setopt(curl, CURLOPT_FOLLOWLOCATION, CURLFOLLOW_FIRSTONLY); } else { diff --git a/tests/libtest/lib1916.c b/tests/libtest/lib1916.c index b8655191ee..ca9bdea34b 100644 --- a/tests/libtest/lib1916.c +++ b/tests/libtest/lib1916.c @@ -39,12 +39,13 @@ CURLcode test(char *URL) curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, URL); -#ifdef LIB1917 - /* without any postfields set! */ - curl_easy_setopt(curl, CURLOPT_POST, 1L); -#else - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, ""); -#endif + if(testnum == 1917) { + /* without any postfields set! */ + curl_easy_setopt(curl, CURLOPT_POST, 1L); + } + else { + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, ""); + } res = curl_easy_perform(curl); if(res) { curl_mprintf("res: %d\n", res); diff --git a/tests/libtest/lib1940.c b/tests/libtest/lib1940.c index 60b14f02a5..a7b8f5b168 100644 --- a/tests/libtest/lib1940.c +++ b/tests/libtest/lib1940.c @@ -26,9 +26,6 @@ #include "memdebug.h" -#ifndef LIB1940_C -#define LIB1940_C - 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 */ @@ -80,7 +77,6 @@ static void t1940_showem(CURL *easy, int header_request, unsigned int type) } } } -#endif CURLcode test(char *URL) { @@ -88,11 +84,12 @@ CURLcode test(char *URL) CURLcode res = CURLE_OK; int header_request; -#ifdef LIB1946 - header_request = 0; -#else - header_request = -1; -#endif + if(testnum == 1946) { + header_request = 0; + } + else { + header_request = -1; + } global_init(CURL_GLOBAL_DEFAULT); easy_init(easy); diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index e7623e5aaa..425d1ef16f 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -26,8 +26,6 @@ #include "testtrace.h" #include "memdebug.h" -#ifdef LIB585 - static int testcounter; static curl_socket_t tst_opensocket(void *clientp, @@ -54,9 +52,6 @@ static void setupcallbacks(CURL *curl) testcounter = 0; } -#endif - - CURLcode test(char *URL) { CURLcode res; @@ -87,9 +82,8 @@ CURLcode test(char *URL) if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp")) test_setopt(curl, CURLOPT_FTPPORT, "-"); -#ifdef LIB585 - setupcallbacks(curl); -#endif + if(testnum == 585 || testnum == 586 || testnum == 595 || testnum == 596) + setupcallbacks(curl); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 4be925917a..0869b04abf 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -25,9 +25,6 @@ #include "memdebug.h" -#ifndef LIB510_C -#define LIB510_C - struct t510_WriteThis { int counter; }; @@ -62,7 +59,6 @@ static size_t t510_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) } return 0; /* no more data left to deliver */ } -#endif CURLcode test(char *URL) { @@ -113,10 +109,10 @@ CURLcode test(char *URL) /* enforce chunked transfer by setting the header */ test_setopt(curl, CURLOPT_HTTPHEADER, slist); -#ifdef LIB565 - test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); - test_setopt(curl, CURLOPT_USERPWD, "foo:bar"); -#endif + if(testnum == 565) { + test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); + test_setopt(curl, CURLOPT_USERPWD, "foo:bar"); + } /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 22be567ff7..16f9a6e9b3 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -42,13 +42,12 @@ CURLcode test(char *URL) start_test_timing(); if(!libtest_arg2) { -#ifdef LIB529 - /* test 529 */ - curl_mfprintf(stderr, "Usage: lib529 [url] [uploadfile]\n"); -#else - /* test 525 */ - curl_mfprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); -#endif + if(testnum == 529) { + curl_mfprintf(stderr, "Usage: lib529 [url] [uploadfile]\n"); + } + else { /* testnum == 525 */ + curl_mfprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); + } return TEST_ERR_USAGE; } @@ -143,21 +142,20 @@ CURLcode test(char *URL) test_cleanup: -#ifdef LIB529 - /* test 529 */ - /* proper cleanup sequence - type PA */ - curl_multi_remove_handle(m, curl); - curl_multi_cleanup(m); - curl_easy_cleanup(curl); - curl_global_cleanup(); -#else - /* test 525 */ - /* proper cleanup sequence - type PB */ - curl_multi_remove_handle(m, curl); - curl_easy_cleanup(curl); - curl_multi_cleanup(m); - curl_global_cleanup(); -#endif + if(testnum == 529) { + /* proper cleanup sequence - type PA */ + curl_multi_remove_handle(m, curl); + curl_multi_cleanup(m); + curl_easy_cleanup(curl); + curl_global_cleanup(); + } + else { /* testnum == 525 */ + /* proper cleanup sequence - type PB */ + curl_multi_remove_handle(m, curl); + curl_easy_cleanup(curl); + curl_multi_cleanup(m); + curl_global_cleanup(); + } /* close the local file */ fclose(hd_src); diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index e56f299a9a..3b068488a5 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -27,13 +27,13 @@ * sharing within the multi handle all transfers are performed on the same * persistent connection. * - * This source code is used for lib526, lib527 and lib532 with only #ifdefs + * This source code is used for test526, test527 and test532 with branches * controlling the small differences. * - * - lib526 closes all easy handles after + * - test526 closes all easy handles after * they all have transferred the file over the single connection - * - lib527 closes each easy handle after each single transfer. - * - lib532 uses only a single easy handle that is removed, reset and then + * - test527 closes each easy handle after each single transfer. + * - test532 uses only a single easy handle that is removed, reset and then * re-added for each transfer * * Test case 526, 527 and 532 use FTP, while test 528 uses the lib526 tool but @@ -92,16 +92,19 @@ CURLcode test(char *URL) abort_on_test_timeout(); if(!running) { -#ifdef LIB527 - /* NOTE: this code does not remove the handle from the multi handle - here, which would be the nice, sane and documented way of working. - This however tests that the API survives this abuse gracefully. */ - curl_easy_cleanup(curl[current]); - curl[current] = NULL; -#endif + + if(testnum == 527) { + /* NOTE: this code does not remove the handle from the multi handle + here, which would be the nice, sane and documented way of working. + This however tests that the API survives this abuse gracefully. */ + curl_easy_cleanup(curl[current]); + curl[current] = NULL; + } + if(++current < NUM_HANDLES) { curl_mfprintf(stderr, "Advancing to URL %d\n", current); -#ifdef LIB532 + + if(testnum == 532) { /* first remove the only handle we use */ curl_multi_remove_handle(m, curl[0]); @@ -114,9 +117,10 @@ CURLcode test(char *URL) /* re-add it */ multi_add_handle(m, curl[0]); -#else - multi_add_handle(m, curl[current]); -#endif + } + else { + multi_add_handle(m, curl[current]); + } } else { break; /* done */ @@ -138,45 +142,37 @@ CURLcode test(char *URL) test_cleanup: -#if defined(LIB526) - - /* test 526 and 528 */ - /* proper cleanup sequence - type PB */ + if(testnum == 526 || testnum == 528) { + /* proper cleanup sequence - type PB */ - for(i = 0; i < NUM_HANDLES; i++) { - curl_multi_remove_handle(m, curl[i]); - curl_easy_cleanup(curl[i]); + for(i = 0; i < NUM_HANDLES; i++) { + curl_multi_remove_handle(m, curl[i]); + curl_easy_cleanup(curl[i]); + } + curl_multi_cleanup(m); + curl_global_cleanup(); } - curl_multi_cleanup(m); - curl_global_cleanup(); - -#elif defined(LIB527) - - /* test 527 */ - - /* Upon non-failure test flow the easy's have already been cleanup'ed. In - case there is a failure we arrive here with easy's that have not been - cleanup'ed yet, in this case we have to cleanup them or otherwise these - will be leaked, let's use undocumented cleanup sequence - type UB */ + else if(testnum == 527) { + /* Upon non-failure test flow the easy's have already been cleanup'ed. In + case there is a failure we arrive here with easy's that have not been + cleanup'ed yet, in this case we have to cleanup them or otherwise these + will be leaked, let's use undocumented cleanup sequence - type UB */ + + if(res != CURLE_OK) + for(i = 0; i < NUM_HANDLES; i++) + curl_easy_cleanup(curl[i]); + + curl_multi_cleanup(m); + curl_global_cleanup(); + } + else { /* testnum == 532 */ + /* undocumented cleanup sequence - type UB */ - if(res != CURLE_OK) for(i = 0; i < NUM_HANDLES; i++) curl_easy_cleanup(curl[i]); - - curl_multi_cleanup(m); - curl_global_cleanup(); - -#elif defined(LIB532) - - /* test 532 */ - /* undocumented cleanup sequence - type UB */ - - for(i = 0; i < NUM_HANDLES; i++) - curl_easy_cleanup(curl[i]); - curl_multi_cleanup(m); - curl_global_cleanup(); - -#endif + curl_multi_cleanup(m); + curl_global_cleanup(); + } return res; } diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index fd62e32c21..b12e3483e6 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -55,9 +55,8 @@ CURLcode test(char *URL) /* First set the URL that is about to receive our POST. */ test_setopt(curl, CURLOPT_URL, URL); -#ifdef LIB545 - test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(teststring)); -#endif + if(testnum == 545) + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(teststring)); test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring); diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 24b97adc22..c24619db57 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -32,7 +32,6 @@ #define UPLOADTHIS "this is the blurb we want to upload\n" -#ifndef LIB548 static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { int *counter = (int *)clientp; @@ -63,15 +62,12 @@ static curlioerr t547_ioctl_callback(CURL *handle, int cmd, void *clientp) } return CURLIOE_OK; } -#endif CURLcode test(char *URL) { CURLcode res; CURL *curl; -#ifndef LIB548 int counter = 0; -#endif if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); @@ -88,20 +84,21 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_HEADER, 1L); -#ifdef LIB548 - /* set the data to POST with a mere pointer to a null-terminated string */ - test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); -#else - /* 547 style, which means reading the POST data from a callback */ - test_setopt(curl, CURLOPT_IOCTLFUNCTION, t547_ioctl_callback); - test_setopt(curl, CURLOPT_IOCTLDATA, &counter); - - 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)! */ - test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); -#endif + if(testnum == 548) { + /* set the data to POST with a mere pointer to a null-terminated string */ + test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); + } + else { + /* 547 style, which means reading the POST data from a callback */ + test_setopt(curl, CURLOPT_IOCTLFUNCTION, t547_ioctl_callback); + test_setopt(curl, CURLOPT_IOCTLDATA, &counter); + + 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)! */ + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); + } test_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_PROXY, libtest_arg2); test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 5c7db7a4e5..f5df319ec0 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -38,13 +38,22 @@ static size_t t554_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) return 0; if(pooh->sizeleft) { - *ptr = pooh->readptr[0]; /* copy one single byte */ - pooh->readptr++; /* advance pointer */ - pooh->sizeleft--; /* less data left */ - return 1; /* we return 1 byte at a time! */ + *ptr = pooh->readptr[0]; /* copy one single byte */ + pooh->readptr++; /* advance pointer */ + pooh->sizeleft--; /* less data left */ + return 1; /* we return 1 byte at a time! */ } - return 0; /* no more data left to deliver */ + return 0; /* no more data left to deliver */ +} + +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 t554_test_once(char *URL, bool oldstyle) @@ -153,7 +162,12 @@ static CURLcode t554_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, t554_read_cb); + if(testnum == 587) { + test_setopt(curl, CURLOPT_READFUNCTION, t587_read_cb); + } + else { + test_setopt(curl, CURLOPT_READFUNCTION, t554_read_cb); + } /* send a multi-part formpost */ test_setopt(curl, CURLOPT_HTTPPOST, formpost); diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 9da9da368e..70cbc90360 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -68,7 +68,6 @@ static curlioerr t555_ioctl_callback(CURL *handle, int cmd, void *clientp) return CURLIOE_OK; } - CURLcode test(char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index c3eeea1814..e3daabd4a7 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -30,9 +30,7 @@ CURLcode test(char *URL) { CURLcode res; CURL *curl; -#ifdef LIB696 int transfers = 0; -#endif if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); @@ -50,9 +48,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L); -#ifdef LIB696 again: -#endif res = curl_easy_perform(curl); @@ -101,12 +97,12 @@ again: res = TEST_ERR_FAILURE; } -#ifdef LIB696 - ++transfers; - /* perform the transfer a second time */ - if(!res && transfers == 1) - goto again; -#endif + if(testnum == 696) { + ++transfers; + /* perform the transfer a second time */ + if(!res && transfers == 1) + goto again; + } test_cleanup: diff --git a/tests/libtest/lib587.c b/tests/libtest/lib587.c deleted file mode 100644 index ea9862e935..0000000000 --- a/tests/libtest/lib587.c +++ /dev/null @@ -1,189 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ -#include "test.h" - -#include "memdebug.h" - -struct t587_WriteThis { - const char *readptr; - size_t sizeleft; -}; - -static size_t t587_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) -{ - (void)ptr; - (void)size; - (void)nmemb; - (void)userp; - return CURL_READFUNC_ABORT; -} - -static CURLcode t587_test_once(char *URL, bool oldstyle) -{ - static const char testdata[] = - "this is what we post to the silly web server\n"; - - CURL *curl; - CURLcode res = CURLE_OK; - CURLFORMcode formrc; - - struct curl_httppost *formpost = NULL; - struct curl_httppost *lastptr = NULL; - struct t587_WriteThis pooh; - struct t587_WriteThis pooh2; - - pooh.readptr = testdata; - pooh.sizeleft = strlen(testdata); - - /* Fill in the file upload field */ - if(oldstyle) { - formrc = curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "sendfile", - CURLFORM_STREAM, &pooh, - CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft, - CURLFORM_FILENAME, "postit2.c", - CURLFORM_END); - } - else { - /* new style */ - formrc = curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "sendfile alternative", - CURLFORM_STREAM, &pooh, - CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft, - CURLFORM_FILENAME, "file name 2", - CURLFORM_END); - } - - if(formrc) - curl_mprintf("curl_formadd(1) = %d\n", (int)formrc); - - /* Now add the same data with another name and make it not look like - a file upload but still using the callback */ - - pooh2.readptr = testdata; - pooh2.sizeleft = strlen(testdata); - - /* Fill in the file upload field */ - formrc = curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "callbackdata", - CURLFORM_STREAM, &pooh2, - CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft, - CURLFORM_END); - - if(formrc) - curl_mprintf("curl_formadd(2) = %d\n", (int)formrc); - - /* Fill in the filename field */ - formrc = curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "filename", - CURLFORM_COPYCONTENTS, "postit2.c", - CURLFORM_END); - if(formrc) - curl_mprintf("curl_formadd(3) = %d\n", (int)formrc); - - /* Fill in a submit field too */ - formrc = curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "submit", - CURLFORM_COPYCONTENTS, "send", - CURLFORM_CONTENTTYPE, "text/plain", - CURLFORM_END); - - if(formrc) - curl_mprintf("curl_formadd(4) = %d\n", (int)formrc); - - formrc = curl_formadd(&formpost, &lastptr, - CURLFORM_COPYNAME, "somename", - CURLFORM_BUFFER, "somefile.txt", - CURLFORM_BUFFERPTR, "blah blah", - CURLFORM_BUFFERLENGTH, (long)9, - CURLFORM_END); - - if(formrc) - curl_mprintf("curl_formadd(5) = %d\n", (int)formrc); - - curl = curl_easy_init(); - if(!curl) { - curl_mfprintf(stderr, "curl_easy_init() failed\n"); - curl_formfree(formpost); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - /* First set the URL that is about to receive our POST. */ - test_setopt(curl, CURLOPT_URL, URL); - - /* Now specify we want to POST data */ - test_setopt(curl, CURLOPT_POST, 1L); - - /* Set the expected POST size */ - test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); - - /* we want to use our own read function */ - test_setopt(curl, CURLOPT_READFUNCTION, t587_read_cb); - - /* send a multi-part formpost */ - test_setopt(curl, CURLOPT_HTTPPOST, formpost); - - /* get verbose debug output please */ - test_setopt(curl, CURLOPT_VERBOSE, 1L); - - /* include headers in the output */ - test_setopt(curl, CURLOPT_HEADER, 1L); - - /* Perform the request, res will get the return code */ - res = curl_easy_perform(curl); - -test_cleanup: - - /* always cleanup */ - curl_easy_cleanup(curl); - - /* now cleanup the formpost chain */ - curl_formfree(formpost); - - return res; -} - -CURLcode test(char *URL) -{ - CURLcode res; - - if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - curl_mfprintf(stderr, "curl_global_init() failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - res = t587_test_once(URL, TRUE); /* old */ - if(!res) - res = t587_test_once(URL, FALSE); /* new */ - - curl_global_cleanup(); - - return res; -} diff --git a/tests/libtest/lib589.c b/tests/libtest/lib589.c index d2faa5f00d..a58f704106 100644 --- a/tests/libtest/lib589.c +++ b/tests/libtest/lib589.c @@ -47,8 +47,7 @@ CURLcode test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ -#ifdef LIB584 - { + if(testnum == 584) { curl_mime *mime = curl_mime_init(curl); curl_mimepart *part = curl_mime_addpart(mime); curl_mime_name(part, "fake"); @@ -59,7 +58,6 @@ CURLcode test(char *URL) if(res) goto test_cleanup; } -#endif test_setopt(curl, CURLOPT_MIMEPOST, NULL); diff --git a/tests/libtest/lib643.c b/tests/libtest/lib643.c index 7181a28177..a3e8a714a9 100644 --- a/tests/libtest/lib643.c +++ b/tests/libtest/lib643.c @@ -38,9 +38,14 @@ static size_t t643_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) if(size*nmemb < 1) return 0; - eof = pooh->sizeleft <= 0; - if(!eof) - pooh->sizeleft--; + if(testnum == 643) { + eof = pooh->sizeleft <= 0; + if(!eof) + pooh->sizeleft--; + } + else { + eof = !*pooh->readptr; + } if(!eof) { *ptr = *pooh->readptr; /* copy one single byte */ @@ -65,7 +70,8 @@ static CURLcode t643_test_once(char *URL, bool oldstyle) curl_off_t datasize = -1; pooh.readptr = testdata; - datasize = (curl_off_t)strlen(testdata); + if(testnum == 643) + datasize = (curl_off_t)strlen(testdata); pooh.sizeleft = datasize; curl = curl_easy_init(); @@ -118,7 +124,8 @@ static CURLcode t643_test_once(char *URL, bool oldstyle) a file upload but still using the callback */ pooh2.readptr = testdata; - datasize = (curl_off_t)strlen(testdata); + if(testnum == 643) + datasize = (curl_off_t)strlen(testdata); pooh2.sizeleft = datasize; part = curl_mime_addpart(mime); diff --git a/tests/libtest/lib645.c b/tests/libtest/lib645.c deleted file mode 100644 index 7e3196bc65..0000000000 --- a/tests/libtest/lib645.c +++ /dev/null @@ -1,258 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ -#include "test.h" - -#include "memdebug.h" - -struct t645_WriteThis { - const char *readptr; - curl_off_t sizeleft; -}; - -static size_t t645_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) -{ - struct t645_WriteThis *pooh = (struct t645_WriteThis *)userp; - int eof; - - if(size*nmemb < 1) - return 0; - - eof = !*pooh->readptr; - - if(!eof) { - *ptr = *pooh->readptr; /* copy one single byte */ - pooh->readptr++; /* advance pointer */ - return 1; /* we return 1 byte at a time! */ - } - - return 0; /* no more data left to deliver */ -} - -static CURLcode t645_test_once(char *URL, bool oldstyle) -{ - static const char testdata[] = "dummy\n"; - - CURL *curl; - CURLcode res = CURLE_OK; - - curl_mime *mime = NULL; - curl_mimepart *part = NULL; - struct t645_WriteThis pooh; - struct t645_WriteThis pooh2; - curl_off_t datasize = -1; - - pooh.readptr = testdata; - pooh.sizeleft = datasize; - - curl = curl_easy_init(); - if(!curl) { - curl_mfprintf(stderr, "curl_easy_init() failed\n"); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - mime = curl_mime_init(curl); - if(!mime) { - curl_mfprintf(stderr, "curl_mime_init() failed\n"); - curl_easy_cleanup(curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - part = curl_mime_addpart(mime); - if(!part) { - curl_mfprintf(stderr, "curl_mime_addpart(1) failed\n"); - curl_mime_free(mime); - curl_easy_cleanup(curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - /* Fill in the file upload part */ - if(oldstyle) { - res = curl_mime_name(part, "sendfile"); - if(!res) - res = curl_mime_data_cb(part, datasize, t645_read_cb, - NULL, NULL, &pooh); - if(!res) - res = curl_mime_filename(part, "postit2.c"); - } - else { - /* new style */ - res = curl_mime_name(part, "sendfile alternative"); - if(!res) - res = curl_mime_data_cb(part, datasize, t645_read_cb, - NULL, NULL, &pooh); - if(!res) - res = curl_mime_filename(part, "file name 2"); - } - - if(res) - curl_mprintf("curl_mime_xxx(1) = %s\n", curl_easy_strerror(res)); - - /* Now add the same data with another name and make it not look like - a file upload but still using the callback */ - - pooh2.readptr = testdata; - pooh2.sizeleft = datasize; - - part = curl_mime_addpart(mime); - if(!part) { - curl_mfprintf(stderr, "curl_mime_addpart(2) failed\n"); - curl_mime_free(mime); - curl_easy_cleanup(curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - /* Fill in the file upload part */ - res = curl_mime_name(part, "callbackdata"); - if(!res) - res = curl_mime_data_cb(part, datasize, t645_read_cb, - NULL, NULL, &pooh2); - - if(res) - curl_mprintf("curl_mime_xxx(2) = %s\n", curl_easy_strerror(res)); - - part = curl_mime_addpart(mime); - if(!part) { - curl_mfprintf(stderr, "curl_mime_addpart(3) failed\n"); - curl_mime_free(mime); - curl_easy_cleanup(curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - /* Fill in the filename field */ - res = curl_mime_name(part, "filename"); - if(!res) - res = curl_mime_data(part, "postit2.c", - CURL_ZERO_TERMINATED); - - if(res) - curl_mprintf("curl_mime_xxx(3) = %s\n", curl_easy_strerror(res)); - - /* Fill in a submit field too */ - part = curl_mime_addpart(mime); - if(!part) { - curl_mfprintf(stderr, "curl_mime_addpart(4) failed\n"); - curl_mime_free(mime); - curl_easy_cleanup(curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - res = curl_mime_name(part, "submit"); - if(!res) - res = curl_mime_data(part, "send", - CURL_ZERO_TERMINATED); - - if(res) - curl_mprintf("curl_mime_xxx(4) = %s\n", curl_easy_strerror(res)); - - part = curl_mime_addpart(mime); - if(!part) { - curl_mfprintf(stderr, "curl_mime_addpart(5) failed\n"); - curl_mime_free(mime); - curl_easy_cleanup(curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - res = curl_mime_name(part, "somename"); - if(!res) - res = curl_mime_filename(part, "somefile.txt"); - if(!res) - res = curl_mime_data(part, "blah blah", 9); - - if(res) - curl_mprintf("curl_mime_xxx(5) = %s\n", curl_easy_strerror(res)); - - /* First set the URL that is about to receive our POST. */ - test_setopt(curl, CURLOPT_URL, URL); - - /* send a multi-part mimepost */ - test_setopt(curl, CURLOPT_MIMEPOST, mime); - - /* get verbose debug output please */ - test_setopt(curl, CURLOPT_VERBOSE, 1L); - - /* include headers in the output */ - test_setopt(curl, CURLOPT_HEADER, 1L); - - /* Perform the request, res will get the return code */ - res = curl_easy_perform(curl); - -test_cleanup: - - /* always cleanup */ - curl_easy_cleanup(curl); - - /* now cleanup the mimepost structure */ - curl_mime_free(mime); - - return res; -} - -static CURLcode t645_cyclic_add(void) -{ - CURL *easy = curl_easy_init(); - curl_mime *mime = curl_mime_init(easy); - curl_mimepart *part = curl_mime_addpart(mime); - CURLcode a1 = curl_mime_subparts(part, mime); - - if(a1 == CURLE_BAD_FUNCTION_ARGUMENT) { - curl_mime *submime = curl_mime_init(easy); - curl_mimepart *subpart = curl_mime_addpart(submime); - - curl_mime_subparts(part, submime); - a1 = curl_mime_subparts(subpart, mime); - } - - curl_mime_free(mime); - curl_easy_cleanup(easy); - if(a1 != CURLE_BAD_FUNCTION_ARGUMENT) - /* that should have failed */ - return TEST_ERR_FAILURE; - - return CURLE_OK; -} - -CURLcode test(char *URL) -{ - CURLcode res; - - if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - curl_mfprintf(stderr, "curl_global_init() failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - res = t645_test_once(URL, TRUE); /* old */ - if(!res) - res = t645_test_once(URL, FALSE); /* new */ - - if(!res) - res = t645_cyclic_add(); - - curl_global_cleanup(); - - return res; -} diff --git a/tests/libtest/lib670.c b/tests/libtest/lib670.c index 4a64e7831f..051142a488 100644 --- a/tests/libtest/lib670.c +++ b/tests/libtest/lib670.c @@ -29,8 +29,6 @@ #define PAUSE_TIME 5 -#ifndef LIB670_C -#define LIB670_C struct t670_ReadThis { CURL *easy; time_t origin; @@ -62,11 +60,7 @@ static size_t t670_read_cb(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) -#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) @@ -92,28 +86,13 @@ static int t670_xferinfo(void *clientp, 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; -#else - CURLFORMcode formrc; struct curl_httppost *formpost = NULL; - struct curl_httppost *lastptr = NULL; -#endif -#if defined(LIB670) || defined(LIB672) - CURLM *multi = NULL; - CURLMcode mres; - CURLMsg *msg; - int msgs_left; - int still_running = 0; -#endif struct t670_ReadThis pooh; CURLcode res = TEST_ERR_FAILURE; @@ -140,121 +119,131 @@ CURLcode test(char *URL) /* include headers in the output */ test_setopt(pooh.easy, CURLOPT_HEADER, 1L); -#if defined(LIB670) || defined(LIB671) - /* Build the mime tree. */ - mime = curl_mime_init(pooh.easy); - part = curl_mime_addpart(mime); - res = curl_mime_name(part, testname); - if(res != CURLE_OK) { - curl_mfprintf(stderr, - "Something went wrong when building the mime structure: %d\n", - res); - goto test_cleanup; - } + if(testnum == 670 || testnum == 671) { + curl_mimepart *part; + /* Build the mime tree. */ + mime = curl_mime_init(pooh.easy); + part = curl_mime_addpart(mime); + res = curl_mime_name(part, testname); + if(res != CURLE_OK) { + curl_mfprintf(stderr, + "Something went wrong when building the mime structure: %d\n", + res); + goto test_cleanup; + } + + res = curl_mime_data_cb(part, (curl_off_t) 2, t670_read_cb, + NULL, NULL, &pooh); - res = curl_mime_data_cb(part, (curl_off_t) 2, t670_read_cb, - NULL, NULL, &pooh); - - /* Bind mime data to its easy handle. */ - if(res == CURLE_OK) - test_setopt(pooh.easy, CURLOPT_MIMEPOST, mime); -#else - /* Build the form. */ - formrc = curl_formadd(&formpost, &lastptr, - CURLFORM_COPYNAME, testname, - CURLFORM_STREAM, &pooh, - CURLFORM_CONTENTLEN, (curl_off_t) 2, - CURLFORM_END); - if(formrc) { - curl_mfprintf(stderr, "curl_formadd() = %d\n", (int) formrc); - goto test_cleanup; + /* Bind mime data to its easy handle. */ + if(res == CURLE_OK) + test_setopt(pooh.easy, CURLOPT_MIMEPOST, mime); } + else { + struct curl_httppost *lastptr = NULL; + CURLFORMcode formrc; + /* Build the form. */ + formrc = curl_formadd(&formpost, &lastptr, + CURLFORM_COPYNAME, testname, + CURLFORM_STREAM, &pooh, + CURLFORM_CONTENTLEN, (curl_off_t) 2, + CURLFORM_END); + if(formrc) { + curl_mfprintf(stderr, "curl_formadd() = %d\n", (int) formrc); + goto test_cleanup; + } - /* We want to use our own read function. */ - test_setopt(pooh.easy, CURLOPT_READFUNCTION, t670_read_cb); + /* We want to use our own read function. */ + test_setopt(pooh.easy, CURLOPT_READFUNCTION, t670_read_cb); - /* Send a multi-part formpost. */ - test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost); -#endif + /* Send a multi-part formpost. */ + test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost); + } -#if defined(LIB670) || defined(LIB672) - /* Use the multi interface. */ - multi = curl_multi_init(); - mres = curl_multi_add_handle(multi, pooh.easy); - while(!mres) { - struct timeval timeout; - int rc = 0; - fd_set fdread; - fd_set fdwrite; - fd_set fdexcept; - int maxfd = -1; - - mres = curl_multi_perform(multi, &still_running); - if(!still_running || mres != CURLM_OK) - break; - - if(pooh.origin) { - time_t delta = time(NULL) - pooh.origin; - - if(delta >= 4 * PAUSE_TIME) { - curl_mfprintf(stderr, "unpausing failed: drain problem?\n"); - res = CURLE_OPERATION_TIMEDOUT; + if(testnum == 670 || testnum == 672) { + CURLMcode mres; + CURLM *multi; + /* Use the multi interface. */ + multi = curl_multi_init(); + mres = curl_multi_add_handle(multi, pooh.easy); + while(!mres) { + struct timeval timeout; + int rc = 0; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcept; + int maxfd = -1; + int still_running = 0; + + mres = curl_multi_perform(multi, &still_running); + if(!still_running || mres != CURLM_OK) break; - } - if(delta >= PAUSE_TIME) - curl_easy_pause(pooh.easy, CURLPAUSE_CONT); - } + if(pooh.origin) { + time_t delta = time(NULL) - pooh.origin; + + if(delta >= 4 * PAUSE_TIME) { + curl_mfprintf(stderr, "unpausing failed: drain problem?\n"); + res = CURLE_OPERATION_TIMEDOUT; + break; + } - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcept); - timeout.tv_sec = 0; - timeout.tv_usec = 1000000 * PAUSE_TIME / 10; - mres = curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcept, &maxfd); - if(mres) - break; + if(delta >= PAUSE_TIME) + curl_easy_pause(pooh.easy, CURLPAUSE_CONT); + } + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcept); + timeout.tv_sec = 0; + timeout.tv_usec = 1000000 * PAUSE_TIME / 10; + mres = curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcept, &maxfd); + if(mres) + break; #ifdef _WIN32 - if(maxfd == -1) - Sleep(100); - else + if(maxfd == -1) + Sleep(100); + else #endif - rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcept, &timeout); - if(rc == -1) { - curl_mfprintf(stderr, "Select error\n"); - break; - } - } - - if(mres != CURLM_OK) - for(;;) { - msg = curl_multi_info_read(multi, &msgs_left); - if(!msg) + rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcept, &timeout); + if(rc == -1) { + curl_mfprintf(stderr, "Select error\n"); break; - if(msg->msg == CURLMSG_DONE) { - res = msg->data.result; } } - curl_multi_remove_handle(multi, pooh.easy); - curl_multi_cleanup(multi); - -#else - /* Use the easy interface. */ - test_setopt(pooh.easy, CURLOPT_XFERINFODATA, &pooh); - test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, t670_xferinfo); - test_setopt(pooh.easy, CURLOPT_NOPROGRESS, 0L); - res = curl_easy_perform(pooh.easy); -#endif + if(mres != CURLM_OK) + for(;;) { + int msgs_left; + CURLMsg *msg; + msg = curl_multi_info_read(multi, &msgs_left); + if(!msg) + break; + if(msg->msg == CURLMSG_DONE) { + res = msg->data.result; + } + } + curl_multi_remove_handle(multi, pooh.easy); + curl_multi_cleanup(multi); + } + else { + /* Use the easy interface. */ + test_setopt(pooh.easy, CURLOPT_XFERINFODATA, &pooh); + test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, t670_xferinfo); + test_setopt(pooh.easy, CURLOPT_NOPROGRESS, 0L); + res = curl_easy_perform(pooh.easy); + } test_cleanup: curl_easy_cleanup(pooh.easy); -#if defined(LIB670) || defined(LIB671) - curl_mime_free(mime); -#else - curl_formfree(formpost); -#endif + + if(testnum == 670 || testnum == 671) { + curl_mime_free(mime); + } + else { + curl_formfree(formpost); + } curl_global_cleanup(); return res; diff --git a/tests/mk-bundle.pl b/tests/mk-bundle.pl index 0a29d287bb..ff4c7ad1ae 100755 --- a/tests/mk-bundle.pl +++ b/tests/mk-bundle.pl @@ -53,7 +53,6 @@ while(my $line = <$fh>) { chomp $line; if($line =~ /([a-z0-9]+)_SOURCES\ =\ ([a-z0-9]+)\.c/) { my $name = $1; - my $namu = uc($name); my $src = "$2.c"; # Make common symbols unique across test sources @@ -62,9 +61,7 @@ while(my $line = <$fh>) { print "#define $symb ${symb}_$name\n"; } - print "#define $namu\n"; print "#include \"$src\"\n"; - print "#undef $namu\n"; print "\n"; $tlist .= " {\"$name\", test_$name},\n"; }