From: Viktor Szakats Date: Mon, 1 Dec 2025 12:31:42 +0000 (+0100) Subject: tests/data: move `--libcurl` output to external data files X-Git-Tag: rc-8_18_0-2~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d75716e4e55c7074566f48d8c03bfd721461e105;p=thirdparty%2Fcurl.git tests/data: move `--libcurl` output to external data files To make the test files XML-compliant, and the expected results possibly easier to manage by keeping them in `.c` files. Non-XML-compliant files are down to 36 after this patch. Also: - make all macro expansions apply to `%includetext` contents. Closes #19799 --- diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index 90a249fac2..c655a4d863 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -115,7 +115,8 @@ the include instruction: %include filename% Or, a variant of the above where the file is loaded as a newline-agnostic -text file, and `%CR`, `%SP`, `%TAB` macros are expanded after inclusion: +text file, and whitespace, special character macros and variables expanded +after inclusion: %includetext filename% diff --git a/scripts/checksrc-all.pl b/scripts/checksrc-all.pl index 08ff6cfbf5..764895148e 100755 --- a/scripts/checksrc-all.pl +++ b/scripts/checksrc-all.pl @@ -22,6 +22,7 @@ if(@ARGV) { } @files = grep !/\/CMakeFiles\//, @files; +@files = grep !/tests\/data\/data.+\.c/, @files; @files = map { dirname($_) } @files; my @dirs = sort { $a cmp $b } keys %{{ map { $_ => 1 } @files }}; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 18c6969391..910dbd6991 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -283,4 +283,6 @@ test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 test3209 test3210 test3211 test3212 test3213 test3214 test3215 test3216 \ test4000 test4001 -EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 +EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 \ +data1400.c data1401.c data1402.c data1403.c data1404.c data1405.c data1406.c \ +data1407.c data1420.c data1465.c data1481.c diff --git a/tests/data/data1400.c b/tests/data/data1400.c new file mode 100644 index 0000000000..8aeb3c8fc8 --- /dev/null +++ b/tests/data/data1400.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1401.c b/tests/data/data1401.c new file mode 100644 index 0000000000..dfea0bb673 --- /dev/null +++ b/tests/data/data1401.c @@ -0,0 +1,58 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + struct curl_slist *slist1; + + slist1 = NULL; + slist1 = curl_slist_append(slist1, "X-Files: Mulder"); + slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user"); + curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); + curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http"); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1402.c b/tests/data/data1402.c new file mode 100644 index 0000000000..917b4aa822 --- /dev/null +++ b/tests/data/data1402.c @@ -0,0 +1,48 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1403.c b/tests/data/data1403.c new file mode 100644 index 0000000000..38226573cd --- /dev/null +++ b/tests/data/data1403.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER\?foo=bar&baz=quux"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1404.c b/tests/data/data1404.c new file mode 100644 index 0000000000..24b68adb06 --- /dev/null +++ b/tests/data/data1404.c @@ -0,0 +1,83 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + curl_mime *mime1; + curl_mimepart *part1; + curl_mime *mime2; + curl_mimepart *part2; + struct curl_slist *slist1; + + mime1 = NULL; + mime2 = NULL; + slist1 = NULL; + slist1 = curl_slist_append(slist1, "X-testheader-1: header 1"); + slist1 = curl_slist_append(slist1, "X-testheader-2: header 2"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + mime1 = curl_mime_init(hnd); + part1 = curl_mime_addpart(mime1); + curl_mime_data(part1, "value", CURL_ZERO_TERMINATED); + curl_mime_name(part1, "name"); + part1 = curl_mime_addpart(mime1); + mime2 = curl_mime_init(hnd); + part2 = curl_mime_addpart(mime2); + curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); + part2 = curl_mime_addpart(mime2); + curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); + curl_mime_encoder(part2, "8bit"); + curl_mime_type(part2, "magic/content"); + part2 = curl_mime_addpart(mime2); + curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); + curl_mime_headers(part2, slist1, 1); + slist1 = NULL; + curl_mime_subparts(part1, mime2); + mime2 = NULL; + curl_mime_name(part1, "file"); + curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_mime_free(mime1); + mime1 = NULL; + curl_mime_free(mime2); + mime2 = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1405.c b/tests/data/data1405.c new file mode 100644 index 0000000000..e80b77edda --- /dev/null +++ b/tests/data/data1405.c @@ -0,0 +1,66 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + struct curl_slist *slist1; + struct curl_slist *slist2; + struct curl_slist *slist3; + + slist1 = NULL; + slist1 = curl_slist_append(slist1, "NOOP 1"); + slist1 = curl_slist_append(slist1, "*FAIL"); + slist2 = NULL; + slist2 = curl_slist_append(slist2, "NOOP 3"); + slist3 = NULL; + slist3 = curl_slist_append(slist3, "NOOP 2"); + slist3 = curl_slist_append(slist3, "*FAIL HARD"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "ftp://%HOSTIP:%FTPPORT/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L); + curl_easy_setopt(hnd, CURLOPT_QUOTE, slist1); + curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, slist2); + curl_easy_setopt(hnd, CURLOPT_PREQUOTE, slist3); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + curl_slist_free_all(slist2); + slist2 = NULL; + curl_slist_free_all(slist3); + slist3 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1406.c b/tests/data/data1406.c new file mode 100644 index 0000000000..b71dffa88f --- /dev/null +++ b/tests/data/data1406.c @@ -0,0 +1,56 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + struct curl_slist *slist1; + + slist1 = NULL; + slist1 = curl_slist_append(slist1, "recipient.one@example.com"); + slist1 = curl_slist_append(slist1, "recipient.two@example.com"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + curl_easy_setopt(hnd, CURLOPT_MAIL_FROM, "sender@example.com"); + curl_easy_setopt(hnd, CURLOPT_MAIL_RCPT, slist1); + curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1407.c b/tests/data/data1407.c new file mode 100644 index 0000000000..f1d2b30f0f --- /dev/null +++ b/tests/data/data1407.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "pop3://%HOSTIP:%POP3PORT/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 1L); + curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1420.c b/tests/data/data1420.c new file mode 100644 index 0000000000..8405d8ba4c --- /dev/null +++ b/tests/data/data1420.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1"); + curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1465.c b/tests/data/data1465.c new file mode 100644 index 0000000000..09e13f28d5 --- /dev/null +++ b/tests/data/data1465.c @@ -0,0 +1,48 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "ab\201cd\000e\\\"\?\r\n\t\001fghi\x1ajklm\xfd"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)24); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1481.c b/tests/data/data1481.c new file mode 100644 index 0000000000..b8741c0d95 --- /dev/null +++ b/tests/data/data1481.c @@ -0,0 +1,49 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://moo/"); + curl_easy_setopt(hnd, CURLOPT_PROXY, "http://%HOSTIP:%HTTPPORT"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_SSLVERSION, (long)(CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_3)); + curl_easy_setopt(hnd, CURLOPT_PROXY_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/test1400 b/tests/data/test1400 index 9c54240c2f..5b7758fae8 100644 --- a/tests/data/test1400 +++ b/tests/data/test1400 @@ -4,7 +4,6 @@ HTTP HTTP GET --libcurl -notxml @@ -49,7 +48,6 @@ Accept: */* -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # CURLOPT_INTERLEAVEDATA requires RTSP protocol # configurations - just ignore them @@ -62,52 +60,7 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1400.c% diff --git a/tests/data/test1401 b/tests/data/test1401 index e2f51f3911..87ed2e4543 100644 --- a/tests/data/test1401 +++ b/tests/data/test1401 @@ -7,7 +7,6 @@ HTTP Basic auth HTTP set cookie cookies --libcurl -notxml @@ -71,64 +70,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - struct curl_slist *slist1; - - slist1 = NULL; - slist1 = curl_slist_append(slist1, "X-Files: Mulder"); - slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user"); - curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); - curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip"); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http"); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1401.c% diff --git a/tests/data/test1402 b/tests/data/test1402 index 77c0798da2..86eb102045 100644 --- a/tests/data/test1402 +++ b/tests/data/test1402 @@ -53,8 +53,6 @@ Content-Type: application/x-www-form-urlencoded foo=bar&baz=quux -# curl's default user-agent varies with version, libraries etc. -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -65,54 +63,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1402.c% diff --git a/tests/data/test1403 b/tests/data/test1403 index 94ada0fdd9..6627b70aa1 100644 --- a/tests/data/test1403 +++ b/tests/data/test1403 @@ -50,8 +50,6 @@ Accept: */* -# curl's default user-agent varies with version, libraries etc. -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -62,52 +60,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER\?foo=bar&baz=quux"); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1403.c% diff --git a/tests/data/test1404 b/tests/data/test1404 index 3ffcde8939..4471101246 100644 --- a/tests/data/test1404 +++ b/tests/data/test1404 @@ -6,7 +6,6 @@ HTTP HTTP FORMPOST HTTP file upload --libcurl -notxml @@ -95,8 +94,6 @@ dummy data ------------------------------9ef8d6205763--%CR -# curl's default user-agent varies with version, libraries etc. -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -109,89 +106,7 @@ $_ = '' if /CURLOPT_TIMEOUT_MS/ $_ = '' if /\/\* "value" \*\// -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - curl_mime *mime1; - curl_mimepart *part1; - curl_mime *mime2; - curl_mimepart *part2; - struct curl_slist *slist1; - - mime1 = NULL; - mime2 = NULL; - slist1 = NULL; - slist1 = curl_slist_append(slist1, "X-testheader-1: header 1"); - slist1 = curl_slist_append(slist1, "X-testheader-2: header 2"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - mime1 = curl_mime_init(hnd); - part1 = curl_mime_addpart(mime1); - curl_mime_data(part1, "value", CURL_ZERO_TERMINATED); - curl_mime_name(part1, "name"); - part1 = curl_mime_addpart(mime1); - mime2 = curl_mime_init(hnd); - part2 = curl_mime_addpart(mime2); - curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); - part2 = curl_mime_addpart(mime2); - curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); - curl_mime_encoder(part2, "8bit"); - curl_mime_type(part2, "magic/content"); - part2 = curl_mime_addpart(mime2); - curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); - curl_mime_headers(part2, slist1, 1); - slist1 = NULL; - curl_mime_subparts(part1, mime2); - mime2 = NULL; - curl_mime_name(part1, "file"); - curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_mime_free(mime1); - mime1 = NULL; - curl_mime_free(mime2); - mime2 = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1404.c% diff --git a/tests/data/test1405 b/tests/data/test1405 index 84ccd6a0fb..880f345e72 100644 --- a/tests/data/test1405 +++ b/tests/data/test1405 @@ -6,7 +6,6 @@ FTP post-quote pre-quote --libcurl -notxml # Server-side @@ -62,74 +61,6 @@ RETR %TESTNUMBER NOOP 3 QUIT - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - struct curl_slist *slist1; - struct curl_slist *slist2; - struct curl_slist *slist3; - - slist1 = NULL; - slist1 = curl_slist_append(slist1, "NOOP 1"); - slist1 = curl_slist_append(slist1, "*FAIL"); - slist2 = NULL; - slist2 = curl_slist_append(slist2, "NOOP 3"); - slist3 = NULL; - slist3 = curl_slist_append(slist3, "NOOP 2"); - slist3 = curl_slist_append(slist3, "*FAIL HARD"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "ftp://%HOSTIP:%FTPPORT/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L); - curl_easy_setopt(hnd, CURLOPT_QUOTE, slist1); - curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, slist2); - curl_easy_setopt(hnd, CURLOPT_PREQUOTE, slist3); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - curl_slist_free_all(slist2); - slist2 = NULL; - curl_slist_free_all(slist3); - slist3 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # CURLOPT_USERAGENT and CURLOPT_MAXREDIRS requires HTTP protocol # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol @@ -146,5 +77,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1405.c% + diff --git a/tests/data/test1406 b/tests/data/test1406 index 776c880dad..0dfa41839b 100644 --- a/tests/data/test1406 +++ b/tests/data/test1406 @@ -5,7 +5,6 @@ SMTP --libcurl -notxml @@ -63,67 +62,9 @@ To: another body . - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - struct curl_slist *slist1; - - slist1 = NULL; - slist1 = curl_slist_append(slist1, "recipient.one@example.com"); - slist1 = curl_slist_append(slist1, "recipient.two@example.com"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - curl_easy_setopt(hnd, CURLOPT_MAIL_FROM, "sender@example.com"); - curl_easy_setopt(hnd, CURLOPT_MAIL_RCPT, slist1); - curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # These options vary with configurations - just ignore them # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol -$_ = '' if /CURLOPT_USERAGENT/ $_ = '' if /CURLOPT_MAXREDIRS/ $_ = '' if /CURLOPT_SSL_VERIFYPEER/ $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ @@ -133,5 +74,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1406.c% + diff --git a/tests/data/test1407 b/tests/data/test1407 index f767622b0b..300b5efdae 100644 --- a/tests/data/test1407 +++ b/tests/data/test1407 @@ -6,7 +6,6 @@ POP3 Clear Text LIST --libcurl -notxml @@ -50,56 +49,9 @@ PASS secret LIST %TESTNUMBER QUIT - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "pop3://%HOSTIP:%POP3PORT/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 1L); - curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # These options vary with configurations - just ignore them +# CURLOPT_USERAGENT and CURLOPT_MAXREDIRS requires HTTP protocol # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol $_ = '' if /CURLOPT_USERAGENT/ $_ = '' if /CURLOPT_MAXREDIRS/ @@ -111,5 +63,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1407.c% + diff --git a/tests/data/test1420 b/tests/data/test1420 index 22d918acf5..530cf985bd 100644 --- a/tests/data/test1420 +++ b/tests/data/test1420 @@ -6,7 +6,6 @@ IMAP Clear Text FETCH --libcurl -notxml @@ -56,57 +55,9 @@ A003 SELECT %TESTNUMBER A004 FETCH 1 BODY[] A005 LOGOUT - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1"); - curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # These options vary with configurations - just ignore them # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol -$_ = '' if /CURLOPT_USERAGENT/ $_ = '' if /CURLOPT_MAXREDIRS/ $_ = '' if /CURLOPT_SSL_VERIFYPEER/ $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ @@ -115,5 +66,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1420.c% + diff --git a/tests/data/test1465 b/tests/data/test1465 index b9e85535ba..0026ae3831 100644 --- a/tests/data/test1465 +++ b/tests/data/test1465 @@ -4,7 +4,6 @@ HTTP HTTP POST --libcurl -notxml @@ -57,7 +56,6 @@ Content-Type: application/x-www-form-urlencoded %hex[ab%81cd%00e\"?%0D%0A%09%01fghi%1Ajklm%FD]hex% - # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -68,54 +66,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "ab\201cd\000e\\\"\?\r\n\t\001fghi\x1ajklm\xfd"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)24); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1465.c% diff --git a/tests/data/test1481 b/tests/data/test1481 index 30b6d420e1..a3e2595450 100644 --- a/tests/data/test1481 +++ b/tests/data/test1481 @@ -4,7 +4,6 @@ HTTP HTTP GET --libcurl -notxml @@ -52,7 +51,6 @@ Proxy-Connection: Keep-Alive -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # CURLOPT_INTERLEAVEDATA requires RTSP protocol # configurations - just ignore them @@ -64,55 +62,7 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://moo/"); - curl_easy_setopt(hnd, CURLOPT_PROXY, "http://%HOSTIP:%HTTPPORT"); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_SSLVERSION, (long)(CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_3)); - curl_easy_setopt(hnd, CURLOPT_PROXY_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1481.c% diff --git a/tests/runner.pm b/tests/runner.pm index 10be04bd4b..97c62023dd 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -101,6 +101,8 @@ use testutil qw( logmsg runclient exerunner + subtextfile + subchars subbase64 subsha256base64file substrippemfile @@ -367,6 +369,10 @@ sub prepro { $data_crlf = ""; } subvariables(\$s, $testnum, "%"); + if(subtextfile(\$s)) { + subvariables(\$s, $testnum, "%"); + } + subchars(\$s); subbase64(\$s); subsha256base64file(\$s); substrippemfile(\$s); diff --git a/tests/testutil.pm b/tests/testutil.pm index 4666770f07..80479a0c75 100644 --- a/tests/testutil.pm +++ b/tests/testutil.pm @@ -38,6 +38,8 @@ BEGIN { runclientoutput setlogfunc exerunner + subtextfile + subchars subbase64 subnewlines subsha256base64file @@ -110,6 +112,25 @@ sub includefile { return join("", @a); } +sub subtextfile { + my ($thing) = @_; + + my $count = ($$thing =~ s/%includetext ([^%]*)%[\n\r]+/includefile($1, 1)/ge); + + return $count > 0; +} + +sub subchars { + my ($thing) = @_; + + $$thing =~ s/%SP/ /g; # space + $$thing =~ s/%TAB/\t/g; # horizontal tab + $$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d + $$thing =~ s/%LT//g; + $$thing =~ s/%AMP/&/g; +} + sub subbase64 { my ($thing) = @_; @@ -150,16 +171,6 @@ sub subbase64 { $$thing =~ s/%%DAYS%%/%alternatives[$d,$d2]/; } - # include a file, expand space macros - $$thing =~ s/%includetext ([^%]*)%[\n\r]+/includefile($1, 1)/ge; - - $$thing =~ s/%SP/ /g; # space - $$thing =~ s/%TAB/\t/g; # horizontal tab - $$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d - $$thing =~ s/%LT//g; - $$thing =~ s/%AMP/&/g; - # include a file $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge; }