From: Viktor Szakats Date: Thu, 13 Nov 2025 01:11:48 +0000 (+0100) Subject: tests/data: add `%includetext`, dedupe XML payloads into external file X-Git-Tag: rc-8_18_0-1~315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca27404d2737e64bdc803fc7456e9a72bf61bb01;p=thirdparty%2Fcurl.git tests/data: add `%includetext`, dedupe XML payloads into external file To reduce duplication and to avoid keeping XML-like markup within XML markup (`test*`), that was tripping `xmllint`. Ref: #19470 Closes #19504 --- diff --git a/REUSE.toml b/REUSE.toml index fff5380164..e9e9ecf03d 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -35,6 +35,7 @@ path = [ "RELEASE-NOTES", "renovate.json", "tests/certs/**", + "tests/data/data**", "tests/data/test**", "tests/valgrind.supp", ] diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index df5eed8ac6..3897deb9cb 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -106,6 +106,11 @@ 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: + + %includetext filename% + ## Conditional lines Lines in the test file can be made to appear conditionally on a specific diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index c9e3f75ba1..d417a70a40 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -283,4 +283,4 @@ test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 test3209 test3210 test3211 test3212 test3213 test3214 test3215 \ test4000 test4001 -EXTRA_DIST = $(TESTCASES) DISABLED +EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 diff --git a/tests/data/data-xml1 b/tests/data/data-xml1 new file mode 100644 index 0000000000..76d8a4afd4 --- /dev/null +++ b/tests/data/data-xml1 @@ -0,0 +1,112 @@ + + + + + 1612 + 1998-08-21 04:01:29 + 2004-10-18 02:22:23 + curl + curl and libcurl + Command line tool and library for client-side URL transfers. + curl and libcurl is a tool for transferring files%CR +using URL syntax. It supports HTTP, HTTPS, FTP,%CR +FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR +well as HTTP-post, HTTP-put, cookies, FTP upload,%CR +resumed transfers, passwords, portnumbers, SSL%CR +certificates, Kerberos, and proxies. It is powered%CR +by libcurl, the client-side URL transfer library.%CR +There are bindings to libcurl for over 20%CR +languages and environments.%CR + + 5784.57 + 3.16 + 169 + 6594.54 + 13.81 + 105 + 8.50 + 21 + 183 + 323 + Default + http://freshmeat.net/projects/curl/ + http://freshmeat.net/redir/curl/1612/url_homepage/ + http://freshmeat.net/redir/curl/1612/url_tgz/ + http://freshmeat.net/redir/curl/1612/url_bz2/ + http://freshmeat.net/redir/curl/1612/url_zip/ + http://freshmeat.net/redir/curl/1612/url_changelog/ + http://freshmeat.net/redir/curl/1612/url_rpm/ + http://freshmeat.net/redir/curl/1612/url_deb/ + http://freshmeat.net/redir/curl/1612/url_osx/ + http://freshmeat.net/redir/curl/1612/url_bsdport/ + + http://freshmeat.net/redir/curl/1612/url_cvs/ + http://freshmeat.net/redir/curl/1612/url_list/ + http://freshmeat.net/redir/curl/1612/url_mirror/ + + MIT/X Consortium License + + 7.12.2 + 176085 + 2004-10-18 02:22:23 + + + + + Daniel Stenberg + http://freshmeat.net/~bagder/ + Owner + + + + 12 + 226 + 3 + 2 + 188 + 216 + 200 + 220 + 164 + 90 + 89 + 809 + 150 + 224 + 900 + 839 + + + + 0 + 7464 + 7464 + OpenSSL (Default) + + + 0 + 0 + 7443 + OpenLDAP + + + 0 + 0 + 12351 + zlib + + + 0 + 0 + 32047 + Heimdal + + + 0 + 0 + 44532 + c-ares + + + + diff --git a/tests/data/test1123 b/tests/data/test1123 index d0fc9fb066..80ec7b4cb3 100644 --- a/tests/data/test1123 +++ b/tests/data/test1123 @@ -35,118 +35,7 @@ Vary: Accept-Encoding%CR Content-Type: text/html; charset=ISO-8859-1%CR Transfer-Encoding: deflate, chunked%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/data/test1277 b/tests/data/test1277 index b229a0e1c2..56275d2bc5 100644 --- a/tests/data/test1277 +++ b/tests/data/test1277 @@ -39,118 +39,7 @@ Content-Type: text/html; charset=ISO-8859-1%CR Transfer-Encoding: gzip, chunked%CR Content-Encoding: deflate%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/data/test222 b/tests/data/test222 index e1b3bceb3a..0f09d9caaa 100644 --- a/tests/data/test222 +++ b/tests/data/test222 @@ -33,118 +33,7 @@ Content-Type: text/html; charset=ISO-8859-1%CR Content-Encoding: deflate%CR Content-Length: 1305%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/data/test230 b/tests/data/test230 index 45f0a7f884..9d7703ed19 100644 --- a/tests/data/test230 +++ b/tests/data/test230 @@ -33,118 +33,7 @@ Content-Type: text/html; charset=ISO-8859-1%CR Content-Encoding: deflate, identity, gzip%CR Content-Length: 1328%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/data/test232 b/tests/data/test232 index 94cb1b9f99..9fe30dd005 100644 --- a/tests/data/test232 +++ b/tests/data/test232 @@ -33,118 +33,7 @@ Content-Type: text/html; charset=ISO-8859-1%CR Content-Encoding: deflate%CR Content-Length: 1287%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/data/test314 b/tests/data/test314 index 4f14957a43..6074da33c3 100644 --- a/tests/data/test314 +++ b/tests/data/test314 @@ -35,118 +35,7 @@ Content-Type: text/html; charset=ISO-8859-1%CR Content-Encoding: br%CR Content-Length: 1056%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/data/test396 b/tests/data/test396 index 5dd3faed13..bc29bad5f7 100644 --- a/tests/data/test396 +++ b/tests/data/test396 @@ -32,118 +32,7 @@ Content-Type: text/html; charset=ISO-8859-1%CR Content-Encoding: zstd%CR Content-Length: 1309%CR %CR - - - - - 1612 - 1998-08-21 04:01:29 - 2004-10-18 02:22:23 - curl - curl and libcurl - Command line tool and library for client-side URL transfers. - curl and libcurl is a tool for transferring files%CR -using URL syntax. It supports HTTP, HTTPS, FTP,%CR -FTPS, DICT, TELNET, LDAP, FILE, and GOPHER, as%CR -well as HTTP-post, HTTP-put, cookies, FTP upload,%CR -resumed transfers, passwords, portnumbers, SSL%CR -certificates, Kerberos, and proxies. It is powered%CR -by libcurl, the client-side URL transfer library.%CR -There are bindings to libcurl for over 20%CR -languages and environments.%CR - - 5784.57 - 3.16 - 169 - 6594.54 - 13.81 - 105 - 8.50 - 21 - 183 - 323 - Default - http://freshmeat.net/projects/curl/ - http://freshmeat.net/redir/curl/1612/url_homepage/ - http://freshmeat.net/redir/curl/1612/url_tgz/ - http://freshmeat.net/redir/curl/1612/url_bz2/ - http://freshmeat.net/redir/curl/1612/url_zip/ - http://freshmeat.net/redir/curl/1612/url_changelog/ - http://freshmeat.net/redir/curl/1612/url_rpm/ - http://freshmeat.net/redir/curl/1612/url_deb/ - http://freshmeat.net/redir/curl/1612/url_osx/ - http://freshmeat.net/redir/curl/1612/url_bsdport/ - - http://freshmeat.net/redir/curl/1612/url_cvs/ - http://freshmeat.net/redir/curl/1612/url_list/ - http://freshmeat.net/redir/curl/1612/url_mirror/ - - MIT/X Consortium License - - 7.12.2 - 176085 - 2004-10-18 02:22:23 - - - - - Daniel Stenberg - http://freshmeat.net/~bagder/ - Owner - - - - 12 - 226 - 3 - 2 - 188 - 216 - 200 - 220 - 164 - 90 - 89 - 809 - 150 - 224 - 900 - 839 - - - - 0 - 7464 - 7464 - OpenSSL (Default) - - - 0 - 0 - 7443 - OpenLDAP - - - 0 - 0 - 12351 - zlib - - - 0 - 0 - 32047 - Heimdal - - - 0 - 0 - 44532 - c-ares - - - - +%includetext %SRCDIR/data/data-xml1% diff --git a/tests/testutil.pm b/tests/testutil.pm index 126f83e021..35fe4bd633 100644 --- a/tests/testutil.pm +++ b/tests/testutil.pm @@ -100,8 +100,11 @@ sub clearlogs { ####################################################################### sub includefile { - my ($f) = @_; + my ($f, $text) = @_; open(F, "<$f"); + if($text) { + binmode F, ':crlf'; + } my @a = ; close(F); return join("", @a); @@ -147,12 +150,15 @@ 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 # include a file - $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1)/ge; + $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge; } my $prevupdate; # module scope so it remembers the last value