diff options
Diffstat (limited to 'tests')
67 files changed, 1123 insertions, 206 deletions
diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT index 505c573cb..85e731966 100644 --- a/tests/FILEFORMAT +++ b/tests/FILEFORMAT @@ -249,6 +249,7 @@ unittest unix-sockets WinSSL ld_preload +alt-svc as well as each protocol that curl supports. A protocol only needs to be specified if it is different from the server (useful when the server diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index 3d13e3a27..2eca9c670 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -56,11 +56,11 @@ test289 test290 test291 test292 test293 test294 test295 test296 test297 \ test298 test299 test300 test301 test302 test303 test304 test305 test306 \ test307 test308 test309 test310 test311 test312 test313 test314 test315 \ test316 test317 test318 test319 test320 test321 test322 test323 test324 \ -test325 test326 test327 test328 test329 test330 \ +test325 test326 test327 test328 test329 test330 test331 \ \ test340 \ \ -test350 test351 test352 test353 test354 \ +test350 test351 test352 test353 test354 test355 test356 \ test393 test394 test395 \ \ test400 test401 test402 test403 test404 test405 test406 test407 test408 \ @@ -83,7 +83,7 @@ test617 test618 test619 test620 test621 test622 test623 test624 test625 \ test626 test627 test628 test629 test630 test631 test632 test633 test634 \ test635 test636 test637 test638 test639 test640 test641 test642 \ test643 test644 test645 test646 test647 test648 test649 test650 test651 \ -test652 test653 test654 test655 test656 test658 \ +test652 test653 test654 test655 test656 test658 test659 \ \ test700 test701 test702 test703 test704 test705 test706 test707 test708 \ test709 test710 test711 test712 test713 test714 test715 \ @@ -174,7 +174,7 @@ test1516 test1517 test1518 test1519 test1520 test1521 test1522 \ \ test1525 test1526 test1527 test1528 test1529 test1530 test1531 test1532 \ test1533 test1534 test1535 test1536 test1537 test1538 \ -test1540 \ +test1540 test1541 \ test1550 test1551 test1552 test1553 test1554 test1555 test1556 test1557 \ test1558 test1560 test1561 test1562 \ \ @@ -183,13 +183,13 @@ test1590 test1591 test1592 \ test1600 test1601 test1602 test1603 test1604 test1605 test1606 test1607 \ test1608 test1609 test1620 test1621 \ \ -test1650 test1651 test1652 test1653 \ +test1650 test1651 test1652 test1653 test1654 \ \ test1700 test1701 test1702 \ \ test1800 test1801 \ \ -test1900 test1901 test1902 test1903 test1904 \ +test1900 test1901 test1902 test1903 test1904 test1905 \ \ test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \ test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \ diff --git a/tests/data/test1026 b/tests/data/test1026 index bd5dc9c85..6bda7a43f 100644 --- a/tests/data/test1026 +++ b/tests/data/test1026 @@ -28,7 +28,7 @@ curl --manual # Search for these two sentinel lines in the manual output; if they are found, # then chances are good the entire manual is there. <postcheck> -perl -e 'open(IN,$ARGV[0]); my $lines=grep(/(a\s*tool\s*to\s*transfer\s*data)|(mailing\s*lists\s*to\s*discuss\s*curl)/, <IN>); exit ($lines != 2); # Let this file pass an XML syntax check: </IN>' log/stdout1026 +perl -e 'open(IN,$ARGV[0]); my $lines=grep(/(curl\s*-\s*transfer\sa\s*URL)|(CONTRIBUTORS)/, <IN>); exit ($lines != 2); # Let this file pass an XML syntax check: </IN>' log/stdout1026 </postcheck> </client> diff --git a/tests/data/test1034 b/tests/data/test1034 index beab0d3c0..b4ffc8a98 100644 --- a/tests/data/test1034 +++ b/tests/data/test1034 @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> <testcase> <info> <keywords> diff --git a/tests/data/test1046 b/tests/data/test1046 index bc4e5c293..e86e1329c 100644 --- a/tests/data/test1046 +++ b/tests/data/test1046 @@ -40,7 +40,7 @@ HTTP-IPv6 GET with numeric localhost --interface </command> # --interface doesn't accept an address surrounded by [] so %CLIENT6IP is out <precheck> -perl -e "print 'Test requires default test server host address' if ( '%CLIENT6IP' ne '[::1]' );" +perl -e "print 'Test requires default test client host address' if ( '%CLIENT6IP' ne '[::1]' );" </precheck> </client> diff --git a/tests/data/test1048 b/tests/data/test1048 index f94ae58d1..5ed267b55 100644 --- a/tests/data/test1048 +++ b/tests/data/test1048 @@ -48,7 +48,7 @@ FTP-IPv6 dir list PASV with localhost --interface </command> # --interface doesn't accept an address surrounded by [] so %CLIENT6IP is out <precheck> -perl -e "print 'Test requires default test server host address' if ( '%CLIENT6IP' ne '[::1]' );" +perl -e "print 'Test requires default test client host address' if ( '%CLIENT6IP' ne '[::1]' );" </precheck> </client> diff --git a/tests/data/test1050 b/tests/data/test1050 index a0e5beab1..281936bfe 100644 --- a/tests/data/test1050 +++ b/tests/data/test1050 @@ -43,7 +43,7 @@ FTP-IPv6 dir list, EPRT with specified IP </command> # --interface doesn't accept an address surrounded by [] so %CLIENT6IP is out <precheck> -perl -e "print 'Test requires default test server host address' if ( '%CLIENT6IP' ne '[::1]' );" +perl -e "print 'Test requires default test client host address' if ( '%CLIENT6IP' ne '[::1]' );" </precheck> </client> diff --git a/tests/data/test1082 b/tests/data/test1082 index d58dd25cd..8e4078b2d 100644 --- a/tests/data/test1082 +++ b/tests/data/test1082 @@ -35,7 +35,7 @@ HTTP GET with localhost --interface http://%HOSTIP:%HTTPPORT/1082 --interface localhost </command> <precheck> -perl -e "print 'Test requires default test server host address' if ( '%CLIENTIP' ne '127.0.0.1' );" +perl -e "print 'Test requires default test client host address' if ( '%CLIENTIP' ne '127.0.0.1' );" </precheck> </client> diff --git a/tests/data/test1083 b/tests/data/test1083 index e441278da..1b1db0539 100644 --- a/tests/data/test1083 +++ b/tests/data/test1083 @@ -39,7 +39,7 @@ HTTP-IPv6 GET with ip6-localhost --interface -g "http://%HOST6IP:%HTTP6PORT/1083" --interface ip6-localhost </command> <precheck> -perl -e "if ('%CLIENT6IP' ne '[::1]') {print 'Test requires default test server host address';} else {exec './server/resolve --ipv6 ip6-localhost'; print 'Cannot run precheck resolve';}" +perl -e "if ('%CLIENT6IP' ne '[::1]') {print 'Test requires default test client host address';} else {exec './server/resolve --ipv6 ip6-localhost'; print 'Cannot run precheck resolve';}" </precheck> </client> diff --git a/tests/data/test1097 b/tests/data/test1097 index 7512a2e7d..7eb7b5f3d 100644 --- a/tests/data/test1097 +++ b/tests/data/test1097 @@ -60,7 +60,7 @@ http://test.a.galaxy.far.far.away.1097:%HTTPPORT/1097 --proxy http://%HOSTIP:%HT <strip> ^User-Agent: curl/.* </strip> -<protocol> +<protocol nonewline="yes"> CONNECT test.a.galaxy.far.far.away.1097:%HTTPPORT HTTP/1.1
Host: test.a.galaxy.far.far.away.1097:%HTTPPORT
Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
@@ -71,9 +71,10 @@ POST /1097 HTTP/1.1 User-Agent: curl/7.19.5-CVS (i686-pc-linux-gnu) libcurl/7.19.5-CVS OpenSSL/0.9.8g zlib/1.2.3.3 c-ares/1.6.1-CVS libidn/1.12 libssh2/1.0.1_CVS
Host: test.a.galaxy.far.far.away.1097:%HTTPPORT
Accept: */*
-Content-Length: 0
+Content-Length: 11
Content-Type: application/x-www-form-urlencoded
+dummy=value </protocol> </verify> diff --git a/tests/data/test1133 b/tests/data/test1133 index d71155eda..737f9d9e2 100644 --- a/tests/data/test1133 +++ b/tests/data/test1133 @@ -29,7 +29,7 @@ HTTP RFC1867-type formposting with filename/data contains ',', ';', '"' http://%HOSTIP:%HTTPPORT/we/want/1133 -F "file=@\"log/test1133,and;.txt\";type=mo/foo;filename=\"faker,and;.txt\"" -F 'file2=@"log/test1133,and;.txt"' -F 'file3=@"log/test1133,and;.txt";type=m/f,"log/test1133,and;.txt"' -F a="{\"field1\":\"value1\",\"field2\":\"value2\"}" -F 'b=" \\value1;type=\"whatever\" "; type=text/foo; charset=utf-8 ; filename=param_b' </command> # We create this file before the command is invoked! -<file name=log/test1133,and;.txt> +<file name="log/test1133,and;.txt"> foo bar This is a bar foo bar diff --git a/tests/data/test1149 b/tests/data/test1149 index ae081a8a9..f826391e9 100644 --- a/tests/data/test1149 +++ b/tests/data/test1149 @@ -1,5 +1,5 @@ -# based on test1010 <testcase> +# based on test1010 <info> <keywords> FTP diff --git a/tests/data/test1156 b/tests/data/test1156 index fb4836242..f78dc998f 100644 --- a/tests/data/test1156 +++ b/tests/data/test1156 @@ -67,4 +67,5 @@ http://%HOSTIP:%HTTPPORT/want/1156 <errorcode> 0 </errorcode> +</verify> </testcase> diff --git a/tests/data/test1160 b/tests/data/test1160 index 3fe689e96..63dd0a7a0 100644 --- a/tests/data/test1160 +++ b/tests/data/test1160 @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> <testcase> <info> <keywords> diff --git a/tests/data/test1262 b/tests/data/test1262 index 4b08a2cf2..ed526c099 100644 --- a/tests/data/test1262 +++ b/tests/data/test1262 @@ -1,5 +1,5 @@ -# similar to test 139 but with a reversed time condition <testcase> +# similar to test 139 but with a reversed time condition <info> <keywords> FTP diff --git a/tests/data/test1263 b/tests/data/test1263 index 7946916e2..7462db4d4 100644 --- a/tests/data/test1263 +++ b/tests/data/test1263 @@ -1,5 +1,5 @@ -# similar to test 1260 <testcase> +# similar to test 1260 <info> <keywords> HTTP diff --git a/tests/data/test1291 b/tests/data/test1291 index 12d65f3d8..3f1575184 100644 --- a/tests/data/test1291 +++ b/tests/data/test1291 @@ -1,7 +1,6 @@ +<testcase> # This test case is primarily meant to verify that parsing and adding the 100K # files is a swift operation. -# -<testcase> <info> <keywords> HTTP diff --git a/tests/data/test1307 b/tests/data/test1307 index 82ed3c07f..c4f7ac729 100644 --- a/tests/data/test1307 +++ b/tests/data/test1307 @@ -15,6 +15,7 @@ none </server> <features> unittest +ftp </features> <name> internal Curl_fnmatch() testing diff --git a/tests/data/test1404 b/tests/data/test1404 index a00bf10a3..a7b8cc823 100644 --- a/tests/data/test1404 +++ b/tests/data/test1404 @@ -94,6 +94,8 @@ s/(USERAGENT, \")[^\"]+/${1}stripped/ $_ = '' if /CURLOPT_SSL_VERIFYPEER/ $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ $_ = '' if /CURLOPT_HTTP_VERSION/ +# CURL_DOES_CONVERSION generates an extra comment. +$_ = '' if /\/\* "value" \*\// </stripfile> <file name="log/test1404.c" mode="text"> /********* Sample code generated by the curl command line tool ********** diff --git a/tests/data/test1425 b/tests/data/test1425 Binary files differindex 0044c69d5..ce9ba97fb 100644 --- a/tests/data/test1425 +++ b/tests/data/test1425 diff --git a/tests/data/test1426 b/tests/data/test1426 Binary files differindex dd6a8d117..851d8c3fb 100644 --- a/tests/data/test1426 +++ b/tests/data/test1426 diff --git a/tests/data/test1449 b/tests/data/test1449 index d30c13c68..1911b0272 100644 --- a/tests/data/test1449 +++ b/tests/data/test1449 @@ -1,5 +1,5 @@ -# initially based on test110 <testcase> +# initially based on test110 <info> <keywords> FTP diff --git a/tests/data/test1455 b/tests/data/test1455 index 0b77dc4f5..7276ea4ec 100644 --- a/tests/data/test1455 +++ b/tests/data/test1455 @@ -9,7 +9,7 @@ HTTP GET # # Server-side <reply name="1455"> -<data nocheck=yes> +<data nocheck="yes"> HTTP/1.1 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake diff --git a/tests/data/test1456 b/tests/data/test1456 index 07a6e7c03..007473618 100644 --- a/tests/data/test1456 +++ b/tests/data/test1456 @@ -9,7 +9,7 @@ IPv6 # # Server-side <reply> -<data nocheck=yes> +<data nocheck="yes"> HTTP/1.1 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake @@ -21,7 +21,7 @@ Connection: close Content-Type: text/html Funny-head: yesyes --foo- +These data aren't actually sent to the client </data> </reply> diff --git a/tests/data/test1457 b/tests/data/test1457 index aad6d43d4..575748f46 100644 --- a/tests/data/test1457 +++ b/tests/data/test1457 @@ -29,7 +29,7 @@ http Check if %{stderr} and %{stdout} switch between stdout and stderr. </name> <command> -http://%HOSTIP:%HTTPPORT/1457 --write-out 'line1%{stderr}line2%{stdout}line3' +http://%HOSTIP:%HTTPPORT/1457 --silent --write-out 'line1%{stderr}line2%{stdout}line3' </command> </client> @@ -45,7 +45,6 @@ Content-Type: text/plain testdata line1line3 </stdout> -#note: as of now <stderr> doesn't actually exist in runtests.pl <stderr nonewline="yes"> line2 </stderr> diff --git a/tests/data/test1506 b/tests/data/test1506 index 815fef923..7377dd6e0 100644 --- a/tests/data/test1506 +++ b/tests/data/test1506 @@ -88,9 +88,13 @@ Accept: */* * Connection #2 to host server3.example.com left intact * Closing connection 0 * Connection #3 to host server4.example.com left intact +* Closing connection +* Closing connection +* Closing connection </file> <stripfile> $_ = '' if (($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +s/^(\* Closing connection) [123](?=\r?\n)/$1/ </stripfile> </verify> </testcase> diff --git a/tests/data/test1541 b/tests/data/test1541 new file mode 100644 index 000000000..e18bb47df --- /dev/null +++ b/tests/data/test1541 @@ -0,0 +1,34 @@ +<testcase> +<info> +<keywords> +HTTP +HTTP GET +multi-threaded +connection-sharing +</keywords> +</info> + +# Server-side +<reply> +</reply> + +# Client-side +<client> +<server> +http +</server> +<tool> +lib1541 +</tool> + <name> +connection sharing using 67 parallel threads for 7 seconds + </name> + <command> +http://%HOSTIP:%HTTPPORT/1 +</command> +</client> + +# Verify data after the test has been "shot" +<verify> +</verify> +</testcase> diff --git a/tests/data/test1561 b/tests/data/test1561 index ff448c95f..69352fda2 100644 --- a/tests/data/test1561 +++ b/tests/data/test1561 @@ -18,6 +18,15 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake Set-Cookie: super=secret; domain=example.com; path=/1561; secure; Set-Cookie: supersuper=secret; domain=example.com; path=/1561/login/; secure; +Set-Cookie: __Secure-SID=12345; Domain=example.com +Set-Cookie: __Secure-SID=12346; Secure; Domain=example.com +Set-Cookie: supersupersuper=secret; __Secure-SID=12346; Secure; Domain=example.com +Set-Cookie: __Host-SID=22345 +Set-Cookie: __Host-SID=22346; Secure +Set-Cookie: __Host-SID=22347; Domain=example.com +Set-Cookie: __Host-SID=22348; Domain=example.com; Path=/ +Set-Cookie: __Host-SID=22349; Secure; Domain=example.com; Path=/ +Set-Cookie: __Host-SID=12346; Secure; Path=/ Content-Length: 7 nomnom @@ -33,6 +42,14 @@ Set-Cookie: public=yes; domain=example.com; path=/foo; Set-Cookie: supersuper=secret; domain=example.com; path=/1561/login/en; Set-Cookie: supersuper=secret; domain=example.com; path=/1561/login; Set-Cookie: secureoverhttp=yes; domain=example.com; path=/1561; secure; +Set-Cookie: __Secure-SID=22345; Domain=example.com +Set-Cookie: __Secure-SID=22346; Secure; Domain=example.com +Set-Cookie: __Host-SID=32345 +Set-Cookie: __Host-SID=32346; Secure +Set-Cookie: __Host-SID=32347; Domain=example.com +Set-Cookie: __Host-SID=32348; Domain=example.com; Path=/ +Set-Cookie: __Host-SID=32349; Secure; Domain=example.com; Path=/ +Set-Cookie: __Host-SID=32350; Secure; Path=/ Content-Length: 7 nomnom @@ -77,6 +94,9 @@ Accept: */* # This file was generated by libcurl! Edit at your own risk. .example.com TRUE /foo FALSE 0 public yes +www.example.com FALSE / TRUE 0 __Host-SID 12346 +.example.com TRUE / TRUE 0 supersupersuper secret +.example.com TRUE / TRUE 0 __Secure-SID 12346 .example.com TRUE /1561/login/ TRUE 0 supersuper secret #HttpOnly_.example.com TRUE /15 FALSE 0 super secret </file> diff --git a/tests/data/test1654 b/tests/data/test1654 new file mode 100644 index 000000000..175076c8a --- /dev/null +++ b/tests/data/test1654 @@ -0,0 +1,58 @@ +<testcase> +<info> +<keywords> +unittest +alt-svc +altsvc +</keywords> +</info> + +<client> +<server> +none +</server> +<features> +unittest +alt-svc +</features> + +# This date is exactly "20190124 22:34:21" UTC +<setenv> +CURL_TIME=1548369261 +</setenv> +<name> +alt-svc +</name> +<command> +log/1654 +</command> +<tool> +unit1654 +</tool> +<file name="log/1654" mode="text"> +h2 example.com 443 h3 shiny.example.com 8443 "20191231 00:00:00" 0 1 +# a comment +h2c example.com 443 h3 shiny.example.com 8443 "20291231 23:30:00" 0 1 + h1 example.com 443 h3 shiny.example.com 8443 "20121231 00:00:01" 0 1 + h3 example.com 443 h3 shiny.example.com 8443 "20131231 00:00:00" 0 1 + # also a comment +bad example.com 443 h3 shiny.example.com 8443 "20191231 00:00:00" 0 1 +rubbish +</file> +</client> +<verify> +<file name="log/1654-out" mode="text"> +# Your alt-svc cache. https://curl.haxx.se/docs/alt-svc.html +# This file was generated by libcurl! Edit at your own risk. +h2 example.com 443 h3 shiny.example.com 8443 "20191231 00:00:00" 0 1 +h2c example.com 443 h3 shiny.example.com 8443 "20291231 23:30:00" 0 1 +h1 example.com 443 h3 shiny.example.com 8443 "20121231 00:00:01" 0 1 +h3 example.com 443 h3 shiny.example.com 8443 "20131231 00:00:00" 0 1 +h1 example.org 8080 h2 example.com 8080 "20190125 22:34:21" 0 0 +h1 2.example.org 8080 h3 2.example.org 8080 "20190125 22:34:21" 0 0 +h1 3.example.org 8080 h2 example.com 8080 "20190125 22:34:21" 0 0 +h1 3.example.org 8080 h3 yesyes.com 8080 "20190125 22:34:21" 0 0 +h2c example.org 80 h2 example.com 443 "20190124 22:36:21" 0 0 +</file> +</verify> +</testcase> diff --git a/tests/data/test1905 b/tests/data/test1905 new file mode 100644 index 000000000..0459b10b4 --- /dev/null +++ b/tests/data/test1905 @@ -0,0 +1,60 @@ +<testcase> +<info> +<keywords> +HTTP +cookies +FLUSH +</keywords> +</info> + +# Server-side +<reply> +<data nocheck="yes"> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Type: text/html +Funny-head: yesyes swsclose +Set-Cookie: foobar=name; +Set-Cookie: secondcookie=present; + +</data> +</reply> + +# Client-side +<client> +<server> +http +</server> + <name> +CURLOPT_COOKIELIST set to "FLUSH" of a shared cookie object + </name> +<tool> +lib1905 +</tool> +<command> +http://%HOSTIP:%HTTPPORT/we/want/1905 +</command> +</client> + +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET /we/want/1905 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol> +<file name="log/cookies1905" mode="text"> +# Netscape HTTP Cookie File +# https://curl.haxx.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +%HOSTIP FALSE /we/want/ FALSE 0 secondcookie present +%HOSTIP FALSE /we/want/ FALSE 0 foobar name +</file> +</verify> +</testcase> diff --git a/tests/data/test2056 b/tests/data/test2056 index f00e21204..5d2584eec 100644 --- a/tests/data/test2056 +++ b/tests/data/test2056 @@ -8,17 +8,7 @@ HTTP Negotiate auth (stub krb5) </info> # Server-side <reply> -<!-- First request, expect 401 Negotiate --> -<data> -HTTP/1.1 401 Authorization Required -Server: Microsoft-IIS/7.0 -Content-Type: text/html; charset=iso-8859-1 -WWW-Authenticate: Negotiate -Content-Length: 13 - -Not yet sir! -</data> -<!-- Second request, expect success in one shot --> +<!-- First request, expect success in one shot --> <data1> HTTP/1.1 200 Things are fine in server land Server: Microsoft-IIS/7.0 @@ -29,12 +19,6 @@ Content-Length: 15 Nice auth sir! </data1> <datacheck> -HTTP/1.1 401 Authorization Required -Server: Microsoft-IIS/7.0 -Content-Type: text/html; charset=iso-8859-1 -WWW-Authenticate: Negotiate -Content-Length: 13 - HTTP/1.1 200 Things are fine in server land Server: Microsoft-IIS/7.0 Content-Type: text/html; charset=iso-8859-1 @@ -75,10 +59,6 @@ CURL_STUB_GSS_CREDS="KRB5_Alice" <protocol> GET /2056 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
-Accept: */*
-
-GET /2056 HTTP/1.1
-Host: %HOSTIP:%HTTPPORT
Authorization: Negotiate IktSQjVfQWxpY2UiOkhUVFBAMTI3LjAuMC4xOjE6QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==
Accept: */*
diff --git a/tests/data/test2057 b/tests/data/test2057 index 562505168..92d7824c1 100644 --- a/tests/data/test2057 +++ b/tests/data/test2057 @@ -8,17 +8,7 @@ HTTP Negotiate auth (stub ntlm) </info> # Server-side <reply> -<!-- First request, expect 401 Negotiate --> -<data> -HTTP/1.1 401 Authorization Required -Server: Microsoft-IIS/7.0 -Content-Type: text/html; charset=iso-8859-1 -WWW-Authenticate: Negotiate -Content-Length: 13 - -Not yet sir! -</data> -<!-- Second request, expect 401 (ntlm challenge) --> +<!-- First request, expect 401 (ntlm challenge) --> <data1> HTTP/1.1 401 Authorization Required Server: Microsoft-IIS/7.0 @@ -28,7 +18,7 @@ Content-Length: 19 Still not yet sir! </data1> -<!-- Third request, expect success --> +<!-- Second request, expect success --> <data2> HTTP/1.1 200 Things are fine in server land Server: Microsoft-IIS/7.0 @@ -42,12 +32,6 @@ Nice auth sir! HTTP/1.1 401 Authorization Required Server: Microsoft-IIS/7.0 Content-Type: text/html; charset=iso-8859-1 -WWW-Authenticate: Negotiate -Content-Length: 13 - -HTTP/1.1 401 Authorization Required -Server: Microsoft-IIS/7.0 -Content-Type: text/html; charset=iso-8859-1 WWW-Authenticate: Negotiate Qw== Content-Length: 19 @@ -91,10 +75,6 @@ CURL_STUB_GSS_CREDS="NTLM_Alice" <protocol> GET /2057 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
-Accept: */*
-
-GET /2057 HTTP/1.1
-Host: %HOSTIP:%HTTPPORT
Authorization: Negotiate Ik5UTE1fQWxpY2UiOkhUVFBAMTI3LjAuMC4xOjI6QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==
Accept: */*
diff --git a/tests/data/test327 b/tests/data/test327 index 1aa672d0c..3a1c07162 100644 --- a/tests/data/test327 +++ b/tests/data/test327 @@ -31,7 +31,7 @@ Content-Type: text/html Funny-head: yesyes swsclose Set-Cookie: foobar=name; expires=Thu, 01 Jan 1970 00:00:00 GMT; -</data> +</data2> </reply> # Client-side diff --git a/tests/data/test331 b/tests/data/test331 new file mode 100644 index 000000000..54b86d2a1 --- /dev/null +++ b/tests/data/test331 @@ -0,0 +1,65 @@ +<testcase> +<info> +<keywords> +HTTP +HTTP GET +cookies +</keywords> +</info> + +# Server-side +<reply> +<data> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Type: text/html +Content-Length: 4 +Set-Cookie: moo=yes; + +hej +</data> +<data2> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Type: text/html +Content-Length: 0 +Funny-head: yesyes swsclose + +</data2> +</reply> + +# Client-side +<client> +<server> +http +</server> + <name> +HTTP with cookie using host name 'moo' + </name> + <command> +-x http://%HOSTIP:%HTTPPORT http://moo/we/want/331 -b none http://moo/we/want/3310002 +</command> +</client> + +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET http://moo/we/want/331 HTTP/1.1
+Host: moo
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+GET http://moo/we/want/3310002 HTTP/1.1
+Host: moo
+Accept: */*
+Proxy-Connection: Keep-Alive
+Cookie: moo=yes
+
+</protocol> +</verify> +</testcase> diff --git a/tests/data/test355 b/tests/data/test355 new file mode 100644 index 000000000..e9c4cb28f --- /dev/null +++ b/tests/data/test355 @@ -0,0 +1,57 @@ +<testcase> +<info> +<keywords> +HTTP +Alt-Svc +</keywords> +</info> + +# +# Server-side +<reply> +<data> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 6 +Connection: close +Content-Type: text/html +Funny-head: yesyes + +-foo- +</data> +</reply> + +# +# Client-side +<client> +<features> +alt-svc +</features> +<server> +http +</server> + <name> +load Alt-Svc from file and use + </name> + <command> +http://%HOSTIP:%HTTPPORT/355 --alt-svc "" +</command> +<file name="log/altsvc-355"> +h1 example.com 80 h1 %HOSTIP %HTTPPORT "20290222 22:19:28" 0 0 +</file> +</client> + +# +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET /355 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol> +</verify> +</testcase> diff --git a/tests/data/test356 b/tests/data/test356 new file mode 100644 index 000000000..e2ac4860d --- /dev/null +++ b/tests/data/test356 @@ -0,0 +1,70 @@ +<testcase> +<info> +<keywords> +HTTP +Alt-Svc +</keywords> +</info> + +# +# Server-side +<reply> +<data> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Content-Length: 6 +Connection: close +Content-Type: text/html +Funny-head: yesyes +Alt-Svc: h1="nowhere.foo:81" + +-foo- +</data> +</reply> + +# +# Client-side +<client> +<features> +debug +alt-svc +</features> +<server> +http +</server> + <name> +parse incoming Alt-Svc and save to file + </name> +<setenv> +# make debug-curl accept Alt-Svc over plain HTTP +CURL_ALTSVC_HTTP="yeah" +</setenv> + <command> +http://%HOSTIP:%HTTPPORT/356 --alt-svc "log/altsvc-356" +</command> +</client> + +# +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET /356 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol> +<stripfile> +# strip out the (dynamic) expire date from the file so that the rest +# matches +s/\"([^\"]*)\"/TIMESTAMP/ +</stripfile> +<file name="log/altsvc-356"> +# Your alt-svc cache. https://curl.haxx.se/docs/alt-svc.html +# This file was generated by libcurl! Edit at your own risk. +h1 %HOSTIP %HTTPPORT h1 nowhere.foo 81 TIMESTAMP 0 0 +</file> +</verify> +</testcase> diff --git a/tests/data/test506 b/tests/data/test506 index 30f4aa9c0..8f06e0e4f 100644 --- a/tests/data/test506 +++ b/tests/data/test506 @@ -228,9 +228,6 @@ lock: share [Pigs in space]: 94 unlock: share [Pigs in space]: 95 GLOBAL_CLEANUP </stdout> -<stderr> -http://%HOSTIP:%HTTPPORT/506 -</stderr> <file name="log/jar506" mode="text"> # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html diff --git a/tests/data/test578 b/tests/data/test578 index abbe49a3c..788ed72f0 100644 --- a/tests/data/test578 +++ b/tests/data/test578 @@ -38,7 +38,7 @@ lib578 HTTP POST lower than MAX_INITIAL_POST_SIZE with progress callback </name> <command> -http://%HOSTIP:%HTTPPORT/500 log/ip578 +http://%HOSTIP:%HTTPPORT/578 log/ip578 </command> </client> diff --git a/tests/data/test597 b/tests/data/test597 index 458bb6453..3eb9ed8b8 100644 --- a/tests/data/test597 +++ b/tests/data/test597 @@ -31,7 +31,6 @@ ftp://%HOSTIP:%FTPPORT USER anonymous
PASS ftp@example.com
PWD
-QUIT
</protocol> </verify> </testcase> diff --git a/tests/data/test658 b/tests/data/test658 index c75293c6d..2ed6d6429 100644 --- a/tests/data/test658 +++ b/tests/data/test658 @@ -3,6 +3,7 @@ <keywords> HTTP HTTP GET +CURLOPT_CURLU </keywords> </info> <reply> @@ -29,7 +30,7 @@ http lib658 </tool> <name> -HTTP GET +Pass URL to libcurl with CURLOPT_CURLU </name> <command> http://%HOSTIP:%HTTPPORT/658 @@ -45,6 +46,7 @@ GET /658 HTTP/1.1 Host: %HOSTIP:%HTTPPORT
Accept: */*
+</protocol> </verify> </testcase> diff --git a/tests/data/test659 b/tests/data/test659 new file mode 100644 index 000000000..43e1aaf92 --- /dev/null +++ b/tests/data/test659 @@ -0,0 +1,54 @@ +<testcase> +<info> +<keywords> +HTTP +HTTP GET +CURLOPT_CURLU +proxy +</keywords> +</info> +<reply> +<data nocheck="yes"> +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT +ETag: "21025-dc7-39462498" +Accept-Ranges: bytes +Content-Length: 6 +Connection: close +Content-Type: text/html +Funny-head: yesyes + +-foo- +</data> +</reply> +<client> +<server> +http +</server> +<tool> +lib659 +</tool> +<name> +CURLOPT_CURLU without the path set - over proxy + </name> + <command> +http://%HOSTIP:%HTTPPORT +</command> +</client> + +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET http://www.example.com:80/ HTTP/1.1
+Host: www.example.com
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+</protocol> +</verify> + +</testcase> diff --git a/tests/data/test8 b/tests/data/test8 index e6d0f500e..2fc190060 100644 --- a/tests/data/test8 +++ b/tests/data/test8 @@ -46,7 +46,6 @@ Set-Cookie: trailingspace = removed; path=/we/want; Set-Cookie: nocookie=yes; path=/WE; Set-Cookie: blexp=yesyes; domain=%HOSTIP; domain=%HOSTIP; expiry=totally bad; Set-Cookie: partialip=nono; domain=.0.0.1; -Set-Cookie: chocolate=chip; domain=curl; path=/we/want; </file> <precheck> diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 56c84a765..29ab0a9c4 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -131,8 +131,13 @@ endif lib1521.c: $(top_srcdir)/tests/libtest/mk-lib1521.pl $(top_srcdir)/include/curl/curl.h @PERL@ $(top_srcdir)/tests/libtest/mk-lib1521.pl < $(top_srcdir)/include/curl/curl.h > lib1521.c +CHECKSRC = $(CS_$(V)) +CS_0 = @echo " RUN " $@; +CS_1 = +CS_ = $(CS_0) + checksrc: - @PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c + $(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c if CURLDEBUG # for debug builds, we scan the sources on all regular make invokes diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 2e5236fad..e38f48102 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -22,18 +22,19 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \ lib583 lib585 lib586 lib587 lib589 lib590 lib591 lib597 lib598 lib599 \ lib643 lib644 lib645 lib650 lib651 lib652 lib653 lib654 lib655 lib658 \ + lib659 \ lib1156 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \ lib1518 lib1520 lib1521 lib1522 \ lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \ lib1534 lib1535 lib1536 lib1537 lib1538 \ - lib1540 \ + lib1540 lib1541 \ lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \ lib1558 \ lib1560 \ lib1591 lib1592 \ - lib1900 \ + lib1900 lib1905 \ lib2033 chkdecimalpoint_SOURCES = chkdecimalpoint.c ../../lib/mprintf.c \ @@ -345,6 +346,10 @@ lib658_SOURCES = lib658.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib658_LDADD = $(TESTUTIL_LIBS) lib658_CPPFLAGS = $(AM_CPPFLAGS) +lib659_SOURCES = lib659.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib659_LDADD = $(TESTUTIL_LIBS) +lib659_CPPFLAGS = $(AM_CPPFLAGS) + lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) lib1500_LDADD = $(TESTUTIL_LIBS) lib1500_CPPFLAGS = $(AM_CPPFLAGS) @@ -488,6 +493,10 @@ lib1540_SOURCES = lib1540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1540_LDADD = $(TESTUTIL_LIBS) lib1540_CPPFLAGS = $(AM_CPPFLAGS) +lib1541_SOURCES = lib1541.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1541_LDADD = $(TESTUTIL_LIBS) +lib1541_CPPFLAGS = $(AM_CPPFLAGS) + lib1550_SOURCES = lib1550.c $(SUPPORTFILES) lib1550_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1517 @@ -535,6 +544,10 @@ lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1900_LDADD = $(TESTUTIL_LIBS) lib1900_CPPFLAGS = $(AM_CPPFLAGS) +lib1905_SOURCES = lib1905.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1905_LDADD = $(TESTUTIL_LIBS) +lib1905_CPPFLAGS = $(AM_CPPFLAGS) + lib2033_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib2033_LDADD = $(TESTUTIL_LIBS) lib2033_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PIPELINING diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 405e6f84a..d687bf276 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -96,7 +96,7 @@ static void memory_tracking_init(void) env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0'; strcpy(fname, env); curl_free(env); - curl_memdebug(fname); + curl_dbg_memdebug(fname); /* this weird stuff here is to make curl_free() get called before curl_memdebug() as otherwise memory tracking will log a free() without an alloc! */ @@ -107,7 +107,7 @@ static void memory_tracking_init(void) char *endptr; long num = strtol(env, &endptr, 10); if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) - curl_memlimit(num); + curl_dbg_memlimit(num); curl_free(env); } } diff --git a/tests/libtest/lib1537.c b/tests/libtest/lib1537.c index 9832c3a30..7c5dde042 100644 --- a/tests/libtest/lib1537.c +++ b/tests/libtest/lib1537.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -30,7 +30,7 @@ int test(char *URL) CURLcode res = CURLE_OK; char *ptr = NULL; int asize; - int outlen; + int outlen = 0; char *raw; (void)URL; /* we don't use this */ diff --git a/tests/libtest/lib1541.c b/tests/libtest/lib1541.c new file mode 100644 index 000000000..983a47e01 --- /dev/null +++ b/tests/libtest/lib1541.c @@ -0,0 +1,151 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.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. + * + ***************************************************************************/ +#include "test.h" + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#ifdef HAVE_PTHREAD_H +#include <pthread.h> +#include <time.h> + +/* number of threads to fire up in parallel */ +#define NUM_THREADS 67 + +/* for how many seconds each thread will loop */ +#define RUN_FOR_SECONDS 7 + +static pthread_mutex_t connlock; + +static size_t write_db(void *ptr, size_t size, size_t nmemb, void *data) +{ + /* not interested in the downloaded bytes, return the size */ + (void)ptr; /* unused */ + (void)data; /* unused */ + return (size_t)(size * nmemb); +} + +static void lock_cb(CURL *handle, curl_lock_data data, + curl_lock_access access, void *userptr) +{ + (void)access; /* unused */ + (void)userptr; /* unused */ + (void)handle; /* unused */ + (void)data; /* unused */ + pthread_mutex_lock(&connlock); +} + +static void unlock_cb(CURL *handle, curl_lock_data data, + void *userptr) +{ + (void)userptr; /* unused */ + (void)handle; /* unused */ + (void)data; /* unused */ + pthread_mutex_unlock(&connlock); +} + +static void init_locks(void) +{ + pthread_mutex_init(&connlock, NULL); +} + +static void kill_locks(void) +{ + pthread_mutex_destroy(&connlock); +} + +struct initurl { + const char *url; + CURLSH *share; + int threadno; +}; + +static void *run_thread(void *ptr) +{ + struct initurl *u = (struct initurl *)ptr; + int i; + time_t end = time(NULL) + RUN_FOR_SECONDS; + + for(i = 0; time(NULL) < end; i++) { + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, u->url); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); + curl_easy_setopt(curl, CURLOPT_SHARE, u->share); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_db); + curl_easy_perform(curl); /* ignores error */ + curl_easy_cleanup(curl); + fprintf(stderr, "Thread %d transfer %d\n", u->threadno, i); + } + + return NULL; +} + +int test(char *URL) +{ + pthread_t tid[NUM_THREADS]; + int i; + int error; + CURLSH *share; + struct initurl url[NUM_THREADS]; + + /* Must initialize libcurl before any threads are started */ + curl_global_init(CURL_GLOBAL_ALL); + + share = curl_share_init(); + curl_share_setopt(share, CURLSHOPT_LOCKFUNC, lock_cb); + curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, unlock_cb); + curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); + + init_locks(); + + for(i = 0; i< NUM_THREADS; i++) { + url[i].url = URL; + url[i].share = share; + url[i].threadno = i; + error = pthread_create(&tid[i], NULL, run_thread, &url[i]); + if(0 != error) + fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); + else + fprintf(stderr, "Thread %d, gets %s\n", i, URL); + } + + /* now wait for all threads to terminate */ + for(i = 0; i< NUM_THREADS; i++) { + error = pthread_join(tid[i], NULL); + fprintf(stderr, "Thread %d terminated\n", i); + } + + kill_locks(); + + curl_share_cleanup(share); + curl_global_cleanup(); + return 0; +} + +#else /* without pthread, this test doesn't work */ +int test(char *URL) +{ + (void)URL; + return 0; +} +#endif diff --git a/tests/libtest/lib1555.c b/tests/libtest/lib1555.c index e4f2255ac..f7193b5be 100644 --- a/tests/libtest/lib1555.c +++ b/tests/libtest/lib1555.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,14 +36,16 @@ static int progressCallback(void *arg, double ulnow) { CURLcode res = 0; + char buffer[256]; + size_t n = 0; (void)arg; (void)dltotal; (void)dlnow; (void)ultotal; (void)ulnow; - res = curl_easy_recv(curl, NULL, 0, NULL); + res = curl_easy_recv(curl, buffer, 256, &n); printf("curl_easy_recv returned %d\n", res); - res = curl_easy_send(curl, NULL, 0, NULL); + res = curl_easy_send(curl, buffer, n, &n); printf("curl_easy_send returned %d\n", res); return 1; diff --git a/tests/libtest/lib1900.c b/tests/libtest/lib1900.c index 1e10bdf34..2a70f8eba 100644 --- a/tests/libtest/lib1900.c +++ b/tests/libtest/lib1900.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2013 - 2018, Linus Nielsen Feltzing, <linus@haxx.se> + * Copyright (C) 2013 - 2019, Linus Nielsen Feltzing, <linus@haxx.se> * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -138,7 +138,7 @@ int test(char *URL) CURLM *m = NULL; CURLMsg *msg; /* for picking up messages with the transfer status */ int msgs_left; /* how many messages are left */ - int running; + int running = 0; int handlenum = 0; struct timeval last_handle_add; diff --git a/tests/libtest/lib1905.c b/tests/libtest/lib1905.c new file mode 100644 index 000000000..b09c4f526 --- /dev/null +++ b/tests/libtest/lib1905.c @@ -0,0 +1,93 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.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. + * + ***************************************************************************/ +#include "test.h" + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +int test(char *URL) +{ + CURLM *cm = NULL; + CURLSH *sh = NULL; + CURL *ch = NULL; + int unfinished; + + cm = curl_multi_init(); + if(!cm) + return 1; + sh = curl_share_init(); + if(!sh) + goto cleanup; + + curl_share_setopt(sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + curl_share_setopt(sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + + ch = curl_easy_init(); + if(!ch) + goto cleanup; + + curl_easy_setopt(ch, CURLOPT_SHARE, sh); + curl_easy_setopt(ch, CURLOPT_URL, URL); + curl_easy_setopt(ch, CURLOPT_COOKIEFILE, "log/cookies1905"); + curl_easy_setopt(ch, CURLOPT_COOKIEJAR, "log/cookies1905"); + + curl_multi_add_handle(cm, ch); + + unfinished = 1; + while(unfinished) { + int MAX = 0; + long max_tout; + fd_set R, W, E; + struct timeval timeout; + + FD_ZERO(&R); + FD_ZERO(&W); + FD_ZERO(&E); + curl_multi_perform(cm, &unfinished); + + curl_multi_fdset(cm, &R, &W, &E, &MAX); + curl_multi_timeout(cm, &max_tout); + + if(max_tout > 0) { + timeout.tv_sec = max_tout / 1000; + timeout.tv_usec = (max_tout % 1000) * 1000; + } + else { + timeout.tv_sec = 0; + timeout.tv_usec = 1000; + } + + select(MAX + 1, &R, &W, &E, &timeout); + } + + curl_easy_setopt(ch, CURLOPT_COOKIELIST, "FLUSH"); + curl_easy_setopt(ch, CURLOPT_SHARE, NULL); + + curl_multi_remove_handle(cm, ch); + cleanup: + curl_easy_cleanup(ch); + curl_share_cleanup(sh); + curl_multi_cleanup(cm); + + return 0; +} diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 69b2c09dd..0595000ce 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -70,7 +70,7 @@ int test(char *URL) "GET /556 HTTP/1.2\r\n" "Host: ninja\r\n\r\n"; #endif - size_t iolen; + size_t iolen = 0; res = curl_easy_send(curl, request, strlen(request), &iolen); diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index d7f38c4c8..e34505cd2 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,20 +32,12 @@ /* * Test case for below scenario: * - Connect to an FTP server using CONNECT_ONLY option - * - transfer some files with re-using the connection (omitted in test case) - * - Disconnect from FTP server with sending QUIT command * * The test case originated for verifying CONNECT_ONLY option shall not * block after protocol connect is done, but it returns the message * with function curl_multi_info_read(). */ -enum { - CONNECT_ONLY_PHASE = 0, - QUIT_PHASE, - LAST_PHASE -}; - int test(char *URL) { CURL *easy = NULL; @@ -53,7 +45,6 @@ int test(char *URL) int res = 0; int running; int msgs_left; - int phase; CURLMsg *msg; start_test_timing(); @@ -64,76 +55,65 @@ int test(char *URL) multi_init(multi); - for(phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) { - /* go verbose */ - easy_setopt(easy, CURLOPT_VERBOSE, 1L); - - /* specify target */ - easy_setopt(easy, CURLOPT_URL, URL); - - /* enable 'CONNECT_ONLY' option when in connect phase */ - if(phase == CONNECT_ONLY_PHASE) - easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L); - - /* enable 'NOBODY' option to send 'QUIT' command in quit phase */ - if(phase == QUIT_PHASE) { - easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L); - easy_setopt(easy, CURLOPT_NOBODY, 1L); - easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L); - } + /* go verbose */ + easy_setopt(easy, CURLOPT_VERBOSE, 1L); - multi_add_handle(multi, easy); + /* specify target */ + easy_setopt(easy, CURLOPT_URL, URL); - for(;;) { - struct timeval interval; - fd_set fdread; - fd_set fdwrite; - fd_set fdexcep; - long timeout = -99; - int maxfd = -99; + easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L); - multi_perform(multi, &running); + multi_add_handle(multi, easy); - abort_on_test_timeout(); + for(;;) { + struct timeval interval; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + long timeout = -99; + int maxfd = -99; - if(!running) - break; /* done */ + multi_perform(multi, &running); - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcep); + abort_on_test_timeout(); - multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + if(!running) + break; /* done */ - /* At this point, maxfd is guaranteed to be greater or equal than -1. */ + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); - multi_timeout(multi, &timeout); + multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); - /* At this point, timeout is guaranteed to be greater or equal than - -1. */ + /* At this point, maxfd is guaranteed to be greater or equal than -1. */ - if(timeout != -1L) { - int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; - interval.tv_sec = itimeout/1000; - interval.tv_usec = (itimeout%1000)*1000; - } - else { - interval.tv_sec = TEST_HANG_TIMEOUT/1000 + 1; - interval.tv_usec = 0; - } + multi_timeout(multi, &timeout); - select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &interval); + /* At this point, timeout is guaranteed to be greater or equal than + -1. */ - abort_on_test_timeout(); + if(timeout != -1L) { + int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; + interval.tv_sec = itimeout/1000; + interval.tv_usec = (itimeout%1000)*1000; + } + else { + interval.tv_sec = TEST_HANG_TIMEOUT/1000 + 1; + interval.tv_usec = 0; } - msg = curl_multi_info_read(multi, &msgs_left); - if(msg) - res = msg->data.result; + select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &interval); - multi_remove_handle(multi, easy); + abort_on_test_timeout(); } + msg = curl_multi_info_read(multi, &msgs_left); + if(msg) + res = msg->data.result; + + multi_remove_handle(multi, easy); + test_cleanup: /* undocumented cleanup sequence - type UA */ diff --git a/tests/libtest/lib659.c b/tests/libtest/lib659.c new file mode 100644 index 000000000..b37e8e940 --- /dev/null +++ b/tests/libtest/lib659.c @@ -0,0 +1,75 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.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. + * + ***************************************************************************/ +#include "test.h" + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +/* + * Get a single URL without select(). + */ + +int test(char *URL) +{ + CURL *handle = NULL; + CURLcode res = 0; + CURLU *urlp = NULL; + + global_init(CURL_GLOBAL_ALL); + easy_init(handle); + + urlp = curl_url(); + + if(!urlp) { + fprintf(stderr, "problem init URL api."); + goto test_cleanup; + } + + /* this doesn't set the PATH part */ + if(curl_url_set(urlp, CURLUPART_HOST, "www.example.com", 0) || + curl_url_set(urlp, CURLUPART_SCHEME, "http", 0) || + curl_url_set(urlp, CURLUPART_PORT, "80", 0)) { + fprintf(stderr, "problem setting CURLUPART"); + goto test_cleanup; + } + + easy_setopt(handle, CURLOPT_CURLU, urlp); + easy_setopt(handle, CURLOPT_VERBOSE, 1L); + easy_setopt(handle, CURLOPT_PROXY, URL); + + res = curl_easy_perform(handle); + + if(res) { + fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n", + __FILE__, __LINE__, res, curl_easy_strerror(res)); + goto test_cleanup; + } + +test_cleanup: + + curl_url_cleanup(urlp); + curl_easy_cleanup(handle); + curl_global_cleanup(); + + return res; +} diff --git a/tests/libtest/stub_gssapi.c b/tests/libtest/stub_gssapi.c index 377b75452..873e263dc 100644 --- a/tests/libtest/stub_gssapi.c +++ b/tests/libtest/stub_gssapi.c @@ -44,15 +44,15 @@ enum min_err_code { GSS_LAST }; -const char *min_err_table[] = { - "stub-gss: no error", - "stub-gss: no memory", - "stub-gss: invalid arguments", - "stub-gss: invalid credentials", - "stub-gss: invalid context", - "stub-gss: server returned error", - "stub-gss: cannot find a mechanism", - NULL +static const char *min_err_table[] = { + "stub-gss: no error", + "stub-gss: no memory", + "stub-gss: invalid arguments", + "stub-gss: invalid credentials", + "stub-gss: invalid context", + "stub-gss: server returned error", + "stub-gss: cannot find a mechanism", + NULL }; struct gss_ctx_id_t_desc_struct { diff --git a/tests/runtests.1 b/tests/runtests.1 index 472cdb5b0..c43decc64 100644 --- a/tests/runtests.1 +++ b/tests/runtests.1 @@ -20,7 +20,7 @@ .\" * .\" ************************************************************************** .\" -.TH runtests.pl 1 "May 05, 2017" "Curl 7.64.0" "runtests" +.TH runtests.pl 1 "May 05, 2017" "Curl 7.64.1" "runtests" .SH NAME runtests.pl \- run one or more test cases diff --git a/tests/runtests.pl b/tests/runtests.pl index 6c8b903c3..1fb7354ec 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -6,7 +6,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -233,6 +233,7 @@ my $has_crypto; # set if libcurl is built with cryptographic support my $has_cares; # set if built with c-ares my $has_threadedres;# set if built with threaded resolver my $has_psl; # set if libcurl is built with PSL support +my $has_altsvc; # set if libcurl is built with alt-svc support my $has_ldpreload; # set if curl is built for systems supporting LD_PRELOAD my $has_multissl; # set if curl is build with MultiSSL support my $has_manual; # set if curl is built with built-in manual @@ -257,7 +258,6 @@ my $has_sslpinning; # built with a TLS backend that supports pinning my $has_shared = "unknown"; # built shared my $resolver; # name of the resolver backend (for human presentation) -my $ssllib; # name of the SSL library we use (for human presentation) my $has_textaware; # set if running on a system that has a text mode concept # on files. Windows for example @@ -2688,55 +2688,45 @@ sub checksystem { # Win32-style path. $pwd = pathhelp::sys_native_current_path(); } - if ($libcurl =~ /winssl/i) { + if ($libcurl =~ /(winssl|schannel)/i) { $has_winssl=1; $has_sslpinning=1; - $ssllib="WinSSL"; } elsif ($libcurl =~ /openssl/i) { $has_openssl=1; $has_sslpinning=1; - $ssllib="OpenSSL"; } elsif ($libcurl =~ /gnutls/i) { $has_gnutls=1; $has_sslpinning=1; - $ssllib="GnuTLS"; } elsif ($libcurl =~ /nss/i) { $has_nss=1; $has_sslpinning=1; - $ssllib="NSS"; } elsif ($libcurl =~ /(yassl|wolfssl)/i) { $has_yassl=1; $has_sslpinning=1; - $ssllib="yassl"; } elsif ($libcurl =~ /polarssl/i) { $has_polarssl=1; $has_sslpinning=1; - $ssllib="polarssl"; } elsif ($libcurl =~ /securetransport/i) { $has_darwinssl=1; $has_sslpinning=1; - $ssllib="DarwinSSL"; } elsif ($libcurl =~ /BoringSSL/i) { $has_boringssl=1; $has_sslpinning=1; - $ssllib="BoringSSL"; } elsif ($libcurl =~ /libressl/i) { $has_libressl=1; $has_sslpinning=1; - $ssllib="libressl"; } elsif ($libcurl =~ /mbedTLS/i) { $has_mbedtls=1; $has_sslpinning=1; - $ssllib="mbedTLS"; } if ($libcurl =~ /ares/i) { $has_cares=1; @@ -2744,7 +2734,6 @@ sub checksystem { } if ($libcurl =~ /mesalink/i) { $has_mesalink=1; - $ssllib="MesaLink"; } } elsif($_ =~ /^Protocols: (.*)/i) { @@ -2850,6 +2839,10 @@ sub checksystem { # PSL enabled $has_psl=1; } + if($feat =~ /alt-svc/i) { + # alt-svc enabled + $has_altsvc=1; + } if($feat =~ /AsynchDNS/i) { if(!$has_cares) { # this means threaded resolver @@ -3279,7 +3272,7 @@ sub singletest { next; } } - elsif($1 eq "WinSSL") { + elsif(($1 eq "WinSSL") || ($1 eq "Schannel")) { if($has_winssl) { next; } @@ -3399,6 +3392,11 @@ sub singletest { next; } } + elsif($1 eq "alt-svc") { + if($has_altsvc) { + next; + } + } elsif($1 eq "manual") { if($has_manual) { next; @@ -3452,7 +3450,7 @@ sub singletest { next; } } - elsif($1 eq "WinSSL") { + elsif(($1 eq "WinSSL") || ($1 eq "Schannel")) { if(!$has_winssl) { next; } @@ -3746,6 +3744,7 @@ sub singletest { # if this section exists, we verify that the stdout contained this: my @validstdout = fixarray ( getpart("verify", "stdout") ); + my @validstderr = fixarray ( getpart("verify", "stderr") ); # if this section exists, we verify upload my @upload = getpart("verify", "upload"); @@ -4229,6 +4228,57 @@ sub singletest { $ok .= "-"; # stdout not checked } + if (@validstderr) { + # verify redirected stderr + my @actual = loadarray($STDERR); + + # what parts to cut off from stderr + my @stripfile = getpart("verify", "stripfile"); + + foreach my $strip (@stripfile) { + chomp $strip; + my @newgen; + for(@actual) { + eval $strip; + if($_) { + push @newgen, $_; + } + } + # this is to get rid of array entries that vanished (zero + # length) because of replacements + @actual = @newgen; + } + + # variable-replace in the stderr we have from the test case file + @validstderr = fixarray(@validstderr); + + # get all attributes + my %hash = getpartattr("verify", "stderr"); + + # get the mode attribute + my $filemode=$hash{'mode'}; + if($filemode && ($filemode eq "text") && $has_textaware) { + # text mode when running on windows: fix line endings + map s/\r\n/\n/g, @validstderr; + map s/\n/\r\n/g, @validstderr; + } + + if($hash{'nonewline'}) { + # Yes, we must cut off the final newline from the final line + # of the protocol data + chomp($validstderr[$#validstderr]); + } + + $res = compare($testnum, $testname, "stderr", \@actual, \@validstderr); + if($res) { + return 1; + } + $ok .= "r"; + } + else { + $ok .= "-"; # stderr not checked + } + if(@protocol) { # Verify the sent request my @out = loadarray($SERVERIN); diff --git a/tests/server/Makefile.am b/tests/server/Makefile.am index f2067f2e2..ef3303ec1 100644 --- a/tests/server/Makefile.am +++ b/tests/server/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -56,8 +56,13 @@ include Makefile.inc EXTRA_DIST = base64.pl Makefile.inc CMakeLists.txt +CHECKSRC = $(CS_$(V)) +CS_0 = @echo " RUN " $@; +CS_1 = +CS_ = $(CS_0) + checksrc: - @PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c + $(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c if CURLDEBUG # for debug builds, we scan the sources on all regular make invokes diff --git a/tests/testcurl.1 b/tests/testcurl.1 index 5c9ddc27f..755f51112 100644 --- a/tests/testcurl.1 +++ b/tests/testcurl.1 @@ -20,7 +20,7 @@ .\" * .\" ************************************************************************** .\" -.TH testcurl.pl 1 "October 22, 2016" "Curl 7.64.0" "testcurl" +.TH testcurl.pl 1 "October 22, 2016" "Curl 7.64.1" "testcurl" .SH NAME testcurl.pl \- (automatically) test curl diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index fab82d2b0..6996cad6a 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -64,8 +64,13 @@ AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS # Makefile.inc provides neat definitions include Makefile.inc +CHECKSRC = $(CS_$(V)) +CS_0 = @echo " RUN " $@; +CS_1 = +CS_ = $(CS_0) + checksrc: - @PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c + $(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c if BUILD_UNITTESTS noinst_PROGRAMS = $(UNITPROGS) diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 82eaec797..f3cba1c2a 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -11,7 +11,7 @@ UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \ unit1399 \ unit1600 unit1601 unit1602 unit1603 unit1604 unit1605 unit1606 unit1607 \ unit1608 unit1609 unit1620 unit1621 \ - unit1650 unit1651 unit1652 unit1653 + unit1650 unit1651 unit1652 unit1653 unit1654 unit1300_SOURCES = unit1300.c $(UNITFILES) unit1300_CPPFLAGS = $(AM_CPPFLAGS) @@ -115,3 +115,6 @@ unit1652_CPPFLAGS = $(AM_CPPFLAGS) unit1653_SOURCES = unit1653.c $(UNITFILES) unit1653_CPPFLAGS = $(AM_CPPFLAGS) + +unit1654_SOURCES = unit1654.c $(UNITFILES) +unit1654_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c index d6664ff69..91e4606b7 100644 --- a/tests/unit/unit1307.c +++ b/tests/unit/unit1307.c @@ -23,6 +23,17 @@ #include "curl_fnmatch.h" +static CURLcode unit_setup(void) +{ + return CURLE_OK; +} + +static void unit_stop(void) +{ +} + +#ifndef CURL_DISABLE_FTP + /* CURL_FNMATCH_MATCH 0 CURL_FNMATCH_NOMATCH 1 @@ -239,15 +250,6 @@ static const struct testcase tests[] = { "a", NOMATCH|LINUX_FAIL} }; -static CURLcode unit_setup(void) -{ - return CURLE_OK; -} - -static void unit_stop(void) -{ -} - static const char *ret2name(int i) { switch(i) { @@ -308,3 +310,14 @@ UNITTEST_START } } UNITTEST_STOP + +#else + +UNITTEST_START +{ + /* nothing to do, just fail */ + return 1; +} +UNITTEST_STOP + +#endif diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c index 64b6371ee..22c2e8482 100644 --- a/tests/unit/unit1607.c +++ b/tests/unit/unit1607.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,6 +25,10 @@ #include "connect.h" #include "share.h" +/* retrieves ip address and port from a sockaddr structure. + note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */ +bool getaddressinfo(struct sockaddr *sa, char *addr, long *port); + #include "memdebug.h" /* LAST include file */ static struct Curl_easy *easy; @@ -159,8 +163,8 @@ UNITTEST_START if(tests[i].address[j] == &skip) continue; - if(addr && !Curl_getaddressinfo(addr->ai_addr, - ipaddress, &port)) { + if(addr && !getaddressinfo(addr->ai_addr, + ipaddress, &port)) { fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n", __FILE__, __LINE__, i); problem = true; diff --git a/tests/unit/unit1608.c b/tests/unit/unit1608.c index 9ae474ba9..4fc24704b 100644 --- a/tests/unit/unit1608.c +++ b/tests/unit/unit1608.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,9 @@ #include "hostip.h" +CURLcode Curl_shuffle_addr(struct Curl_easy *data, + Curl_addrinfo **addr); + #define NUM_ADDRS 8 static struct Curl_addrinfo addrs[NUM_ADDRS]; diff --git a/tests/unit/unit1609.c b/tests/unit/unit1609.c index 2b99bee9b..865c9e459 100644 --- a/tests/unit/unit1609.c +++ b/tests/unit/unit1609.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,6 +25,10 @@ #include "connect.h" #include "share.h" +/* retrieves ip address and port from a sockaddr structure. + note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */ +bool getaddressinfo(struct sockaddr *sa, char *addr, long *port); + #include "memdebug.h" /* LAST include file */ static struct Curl_easy *easy; @@ -158,8 +162,8 @@ UNITTEST_START if(!addr && !tests[i].address[j]) break; - if(addr && !Curl_getaddressinfo(addr->ai_addr, - ipaddress, &port)) { + if(addr && !getaddressinfo(addr->ai_addr, + ipaddress, &port)) { fprintf(stderr, "%s:%d tests[%d] failed. getaddressinfo failed.\n", __FILE__, __LINE__, i); problem = true; diff --git a/tests/unit/unit1650.c b/tests/unit/unit1650.c index adc91236a..cd6f519f7 100644 --- a/tests/unit/unit1650.c +++ b/tests/unit/unit1650.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -152,7 +152,7 @@ static struct dohresp resp[] = { UNITTEST_START { - size_t size; + size_t size = 0; unsigned char buffer[256]; size_t i; unsigned char *p; diff --git a/tests/unit/unit1651.c b/tests/unit/unit1651.c index fcd3b54db..db3a0f35b 100644 --- a/tests/unit/unit1651.c +++ b/tests/unit/unit1651.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -352,6 +352,8 @@ UNITTEST_START struct Curl_easy *data = curl_easy_init(); int i; int byte; + if(!data) + return 2; memset(&conn, 0, sizeof(struct connectdata)); /* this is a lot of assuming, but we expect the parsing function to only diff --git a/tests/unit/unit1654.c b/tests/unit/unit1654.c new file mode 100644 index 000000000..7532c6d61 --- /dev/null +++ b/tests/unit/unit1654.c @@ -0,0 +1,124 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.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. + * + ***************************************************************************/ +#include "curlcheck.h" + +#include "urldata.h" +#include "altsvc.h" + +static CURLcode +unit_setup(void) +{ + return CURLE_OK; +} + +static void +unit_stop(void) +{ + curl_global_cleanup(); +} + +#if defined(CURL_DISABLE_HTTP) || !defined(USE_ALTSVC) +UNITTEST_START +{ + return 0; /* nothing to do when HTTP is disabled or alt-svc support is + missing */ +} +UNITTEST_STOP +#else +UNITTEST_START +{ + char outname[256]; + CURL *curl; + CURLcode result; + struct altsvcinfo *asi = Curl_altsvc_init(); + if(!asi) + return 1; + result = Curl_altsvc_load(asi, arg); + if(result) + return result; + curl = curl_easy_init(); + if(!curl) + goto fail; + fail_unless(asi->num == 4, "wrong number of entries"); + msnprintf(outname, sizeof(outname), "%s-out", arg); + + result = Curl_altsvc_parse(curl, asi, "h2=\"example.com:8080\"", + ALPN_h1, "example.org", 8080); + if(result) { + fprintf(stderr, "Curl_altsvc_parse() failed!\n"); + unitfail++; + } + fail_unless(asi->num == 5, "wrong number of entries"); + + result = Curl_altsvc_parse(curl, asi, "h3=\":8080\"", + ALPN_h1, "2.example.org", 8080); + if(result) { + fprintf(stderr, "Curl_altsvc_parse(2) failed!\n"); + unitfail++; + } + fail_unless(asi->num == 6, "wrong number of entries"); + + result = Curl_altsvc_parse(curl, asi, + "h2=\"example.com:8080\", h3=\"yesyes.com\"", + ALPN_h1, "3.example.org", 8080); + if(result) { + fprintf(stderr, "Curl_altsvc_parse(3) failed!\n"); + unitfail++; + } + /* that one should make two entries */ + fail_unless(asi->num == 8, "wrong number of entries"); + + result = Curl_altsvc_parse(curl, asi, "h2=\"example.com:443\"; ma = 120;", + ALPN_h2c, "example.org", 80); + if(result) { + fprintf(stderr, "Curl_altsvc_parse(4) failed!\n"); + unitfail++; + } + fail_unless(asi->num == 9, "wrong number of entries"); + + result = Curl_altsvc_parse(curl, asi, + "h2=\":443\", h3=\":443\"; ma = 120; persist = 1", + ALPN_h1, "curl.haxx.se", 80); + if(result) { + fprintf(stderr, "Curl_altsvc_parse(5) failed!\n"); + unitfail++; + } + fail_unless(asi->num == 11, "wrong number of entries"); + + /* clear that one again and decrease the counter */ + result = Curl_altsvc_parse(curl, asi, "clear;", + ALPN_h1, "curl.haxx.se", 80); + if(result) { + fprintf(stderr, "Curl_altsvc_parse(6) failed!\n"); + unitfail++; + } + fail_unless(asi->num == 9, "wrong number of entries"); + + Curl_altsvc_save(asi, outname); + + curl_easy_cleanup(curl); + fail: + Curl_altsvc_cleanup(asi); + return unitfail; +} +UNITTEST_STOP +#endif |