aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/FILEFORMAT12
-rw-r--r--tests/README211
-rw-r--r--tests/data/Makefile.am15
-rw-r--r--tests/data/test112997
-rw-r--r--tests/data/test113097
-rw-r--r--tests/data/test113195
-rw-r--r--tests/data/test120479
-rw-r--r--tests/data/test1304
-rw-r--r--tests/data/test13042
-rw-r--r--tests/data/test1314
-rw-r--r--tests/data/test1310125
-rw-r--r--tests/data/test131164
-rw-r--r--tests/data/test131264
-rw-r--r--tests/data/test131364
-rw-r--r--tests/data/test131479
-rw-r--r--tests/data/test1324
-rw-r--r--tests/data/test1334
-rw-r--r--tests/data/test1344
-rw-r--r--tests/data/test2574
-rw-r--r--tests/data/test3144
-rw-r--r--tests/data/test3202
-rw-r--r--tests/data/test3212
-rw-r--r--tests/data/test3222
-rw-r--r--tests/data/test3242
-rw-r--r--tests/data/test45
-rw-r--r--tests/data/test5043
-rw-r--r--tests/data/test5385
-rw-r--r--tests/data/test5547
-rw-r--r--tests/data/test5691
-rw-r--r--tests/data/test5723
-rw-r--r--tests/data/test5733
-rw-r--r--tests/data/test5837
-rw-r--r--tests/data/test58751
-rw-r--r--tests/data/test70960
-rw-r--r--tests/data/test71057
-rw-r--r--tests/data/test81452
-rw-r--r--tests/getpart.pm4
-rw-r--r--tests/libtest/Makefile.inc21
-rw-r--r--tests/libtest/first.c56
-rw-r--r--tests/libtest/lib500.c2
-rw-r--r--tests/libtest/lib502.c94
-rw-r--r--tests/libtest/lib503.c128
-rw-r--r--tests/libtest/lib504.c122
-rw-r--r--tests/libtest/lib505.c6
-rw-r--r--tests/libtest/lib506.c3
-rw-r--r--tests/libtest/lib507.c123
-rw-r--r--tests/libtest/lib518.c7
-rw-r--r--tests/libtest/lib525.c169
-rw-r--r--tests/libtest/lib526.c237
-rw-r--r--tests/libtest/lib530.c181
-rw-r--r--tests/libtest/lib533.c151
-rw-r--r--tests/libtest/lib536.c153
-rw-r--r--tests/libtest/lib537.c7
-rw-r--r--tests/libtest/lib540.c177
-rw-r--r--tests/libtest/lib541.c13
-rw-r--r--tests/libtest/lib542.c13
-rw-r--r--tests/libtest/lib554.c19
-rw-r--r--tests/libtest/lib555.c116
-rw-r--r--tests/libtest/lib560.c80
-rw-r--r--tests/libtest/lib562.c14
-rw-r--r--tests/libtest/lib564.c120
-rw-r--r--tests/libtest/lib566.c1
-rw-r--r--tests/libtest/lib567.c2
-rw-r--r--tests/libtest/lib568.c1
-rw-r--r--tests/libtest/lib569.c1
-rw-r--r--tests/libtest/lib570.c1
-rw-r--r--tests/libtest/lib571.c4
-rw-r--r--tests/libtest/lib572.c1
-rw-r--r--tests/libtest/lib573.c93
-rw-r--r--tests/libtest/lib574.c1
-rw-r--r--tests/libtest/lib575.c87
-rw-r--r--tests/libtest/lib576.c2
-rw-r--r--tests/libtest/lib578.c1
-rw-r--r--tests/libtest/lib579.c1
-rw-r--r--tests/libtest/lib582.c176
-rw-r--r--tests/libtest/lib583.c59
-rw-r--r--tests/libtest/lib586.c246
-rw-r--r--tests/libtest/test.h338
-rwxr-xr-xtests/memanalyze.pl8
-rwxr-xr-xtests/runtests.pl479
-rw-r--r--tests/server/.gitignore1
-rw-r--r--tests/server/Makefile.inc7
-rw-r--r--tests/server/fake_ntlm.c283
-rw-r--r--tests/server/getpart.c8
-rw-r--r--tests/server/sws.c91
-rw-r--r--tests/serverhelp.pm33
-rw-r--r--tests/sshhelp.pm117
-rwxr-xr-xtests/sshserver.pl11
-rw-r--r--tests/unit/curlcheck.h4
-rw-r--r--tests/unit/unit1300.c4
-rw-r--r--tests/unit/unit1302.c65
-rw-r--r--tests/unit/unit1304.c2
92 files changed, 3575 insertions, 1903 deletions
diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT
index 74fecacdd..72af82325 100644
--- a/tests/FILEFORMAT
+++ b/tests/FILEFORMAT
@@ -158,7 +158,8 @@ rtsp-ipv6
imap
pop3
smtp
-http+tls-srp
+httptls+srp
+httptls+srp-ipv6
Give only one per line. This subsection is mandatory.
</server>
@@ -176,13 +177,14 @@ idn
ipv6
large_file
libz
-netrc_debug
NSS
NTLM
OpenSSL
SSL
socks
unittest
+debug
+TLS-SRP
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
@@ -228,7 +230,8 @@ command is run. They are cleared again after the command has been run.
Variables are first substituted as in the <command> section.
</setenv>
-<command [option="no-output"] [timeout="secs"] [delay="secs"] [type="perl"]>
+<command [option="no-output/no-include"] [timeout="secs"] [delay="secs"]
+ [type="perl"]>
command line to run, there's a bunch of %variables that get replaced
accordingly.
@@ -248,6 +251,9 @@ Set option="no-output" to prevent the test script to slap on the --output
argument that directs the output to a file. The --output is also not added if
the verify/stdout section is used.
+Set option="no-include" to prevent the test script to slap on the --include
+argument.
+
Set timeout="secs" to override default server logs advisor read lock timeout.
This timeout is used by the test harness, once that the command has completed
execution, to wait for the test server to write out server side log files and
diff --git a/tests/README b/tests/README
index 4d8e70c78..f0248e632 100644
--- a/tests/README
+++ b/tests/README
@@ -6,13 +6,44 @@
The cURL Test Suite
-Requires:
+ 1. Running
+ 1.1 Requires to run
+ 1.2 Port numbers used by test servers
+ 1.3 Test servers
+ 1.4 Run
+ 1.5 Shell startup scripts
+ 1.6 Memory test
+ 1.7 Debug
+ 1.8 Logs
+ 1.9 Test input files
+ 1.10 Code coverage
+ 1.11 Remote testing
+
+ 2. Numbering
+ 2.1 Test case numbering
+
+ 3. Write tests
+ 3.1 test data
+ 3.2 curl tests
+ 3.3 libcurl tests
+ 3.4 unit tests
+
+ 4. TODO
+ 4.1 More protocols
+ 4.2 SOCKS auth
+
+==============================================================================
+
+1. Running
+
+ 1.1 Requires to run
+
perl (and a unix-style shell)
diff (when a test fails, a diff is shown)
stunnel (for HTTPS and FTPS tests)
OpenSSH or SunSSH (for SCP, SFTP and SOCKS4/5 tests)
-Ports used by default:
+ 1.2 Port numbers used by test servers
- TCP/8990 for HTTP
- TCP/8991 for HTTPS
@@ -28,25 +59,36 @@ Ports used by default:
- TCP/9001 for POP3
- TCP/9002 for IMAP
- TCP/9003 for SMTP
+ - TCP/9004 for SMTP IPv6
+ - TCP/9005 for RTSP
+ - TCP/9006 for RTSP IPv6
+ - TCP/9007 for GOPHER
+ - TCP/9008 for GOPHER IPv6
+ - TCP/9008 for HTTPS server with TLS-SRP support
+
+ 1.3 Test servers
The test suite runs simple FTP, POP3, IMAP, SMTP, HTTP and TFTP stand-alone
- servers on these ports to which it makes requests. For SSL tests, it runs
- stunnel to handle encryption to the regular servers. For SSH, it runs a
- standard OpenSSH server. For SOCKS4/5 tests SSH is used to perform the SOCKS
- functionality and requires a SSH client and server.
+ servers on the ports listed above to which it makes requests. For SSL tests,
+ it runs stunnel to handle encryption to the regular servers. For SSH, it
+ runs a standard OpenSSH server. For SOCKS4/5 tests SSH is used to perform
+ the SOCKS functionality and requires a SSH client and server.
- The base port number shown above can be changed using runtests' -b option
- to allow running more than one instance of the test suite simultaneously
- on one machine.
+ The base port number (8990), which all the individual port numbers are
+ indexed from, can be set explicitly using runtests.pl' -b option to allow
+ running more than one instance of the test suite simultaneously on one
+ machine, or just move the servers in case you have local services on any of
+ those ports.
+
+ 1.4 Run
-Run:
'make test'. This builds the test suite support code and invokes the
'runtests.pl' perl script to run all the tests. Edit the top variables
of that script in case you have some specific needs, or run the script
manually (after the support code has been built).
The script breaks on the first test that doesn't do OK. Use -a to prevent
- the script from abort on the first error. Run the script with -v for more
+ the script from aborting on the first error. Run the script with -v for more
verbose output. Use -d to run the test servers with debug output enabled as
well. Specifying -k keeps all the log files generated by the test intact.
@@ -56,7 +98,8 @@ Run:
3 to 9. Any test numbers starting with ! are disabled, as are any test
numbers found in the file data/DISABLED (one per line).
-Shell startup scripts:
+ 1.5 Shell startup scripts
+
Tests which use the ssh test server, SCP/SFTP/SOCKS tests, might be badly
influenced by the output of system wide or user specific shell startup
scripts, .bashrc, .profile, /etc/csh.cshrc, .login, /etc/bashrc, etc. which
@@ -71,44 +114,45 @@ Shell startup scripts:
output of a shell startup script. Locate, cleanup or adjust the shell
script.
-Memory:
+ 1.6 Memory test
+
The test script will check that all allocated memory is freed properly IF
curl has been built with the CURLDEBUG define set. The script will
- automatically detect if that is the case, and it will use the ../memanalyze
- script to analyze the memory debugging output.
+ automatically detect if that is the case, and it will use the
+ 'memanalyze.pl' script to analyze the memory debugging output.
+
+ Also, if you run tests on a machine where valgrind is found, the script will
+ use valgrind to run the test with (unless you use -n) to further verify
+ correctness.
- The -t option will enable torture testing mode, which runs each test
- many times but causes a different memory allocation to fail on each
- successive run. This tests the out of memory error handling code to
- ensure that memory leaks do not occur even in those situations.
+ runtests.pl's -t option will enable torture testing mode, which runs each
+ test many times and makes each different memory allocation fail on each
+ successive run. This tests the out of memory error handling code to ensure
+ that memory leaks do not occur even in those situations.
+
+ 1.7 Debug
-Debug:
If a test case fails, you can conveniently get the script to invoke the
debugger (gdb) for you with the server running and the exact same command
line parameters that failed. Just invoke 'runtests.pl <test number> -g' and
then just type 'run' in the debugger to perform the command through the
debugger.
- If a test case causes a core dump, analyze it by running gdb like:
-
- # gdb ../curl/src core
+ 1.8 Logs
- ... and get a stack trace with the gdb command:
+ All logs are generated in the logs/ subdirectory (it is emptied first in the
+ runtests.pl script). Use runtests.pl -k to force it to keep the temporary
+ files after the test run since successful runs will clean it up otherwise.
- (gdb) where
+ 1.9 Test input files
-Logs:
- All logs are generated in the logs/ subdirectory (it is emptied first
- in the runtests.pl script). Use runtests.pl -k to keep the temporary files
- after the test run.
-
-Data:
All test cases are put in the data/ subdirectory. Each test is stored in the
file named according to the test number.
See FILEFORMAT for the description of the test case files.
-Code coverage:
+ 1.10 Code coverage
+
gcc provides a tool that can determine the code coverage figures for
the test suite. To use it, configure curl with
CFLAGS='-fprofile-arcs -ftest-coverage -g -O0'. Make sure you run the normal
@@ -125,38 +169,83 @@ Code coverage:
The text mode tool gcov may also be used, but it doesn't handle object files
in more than one directory very well.
-Remote testing:
+ 1.11 Remote testing
+
The runtests.pl script provides some hooks to allow curl to be tested on a
machine where perl can not be run. The test framework in this case runs on
a workstation where perl is available, while curl itself is run on a remote
system using ssh or some other remote execution method. See the comments at
the beginning of runtests.pl for details.
-TEST CASE NUMBERS
-
- So far, we've used this system:
-
- 1 - 99 HTTP
- 100 - 199 FTP*
- 200 - 299 FILE*
- 300 - 399 HTTPS
- 400 - 499 FTPS
- 500 - 599 libcurl source code tests, not using the curl command tool
- 600 - 699 SCP/SFTP
- 700 - 799 SOCKS4 (even numbers) and SOCK5 (odd numbers)
- 800 - 899 POP3, IMAP, SMTP
- 1000 - 1299 miscellaneous*
- 1300 - 1399 unit tests*
- 1400 - 1999 miscellaneous*
- 2000 - x multiple sequential protocols per test case*
-
- Since 30-apr-2003, there's nothing in the system that requires us to keep
- within these number series, and those sections marked with * actually
- contain tests for a variety of protocols. Each test case now specifies
- its own server requirements, independent of test number.
-
-TODO:
-
- * Add tests for TELNET, LDAP, DICT...
- * SOCKS4/5 test deficiencies - no proxy authentication tests as SSH (the
- test mechanism) doesn't support them
+2. Numbering
+
+ 2.1 Test case numbering
+
+ 1 - 99 HTTP
+ 100 - 199 FTP*
+ 200 - 299 FILE*
+ 300 - 399 HTTPS
+ 400 - 499 FTPS
+ 500 - 599 libcurl source code tests, not using the curl command tool
+ 600 - 699 SCP/SFTP
+ 700 - 799 SOCKS4 (even numbers) and SOCK5 (odd numbers)
+ 800 - 899 POP3, IMAP, SMTP
+ 1000 - 1299 miscellaneous*
+ 1300 - 1399 unit tests*
+ 1400 - 1999 miscellaneous*
+ 2000 - x multiple sequential protocols per test case*
+
+ Since 30-apr-2003, there's nothing in the system that requires us to keep
+ within these number series, and those sections marked with * actually
+ contain tests for a variety of protocols. Each test case now specifies its
+ own server requirements, independent of test number.
+
+3. Write tests
+
+ Here's a quick description on writing test cases. We basically have three
+ kinds of tests: the ones that test the curl tool, the ones that build small
+ applications and test libcurl directly and the unit tests that test
+ individual (possibly internal) functions.
+
+ 3.1 test data
+
+ Each test has a master file that controls all the test data. What to read,
+ what the protocol exchange should look like, what exit code to expect and
+ what command line arguments to use etc.
+
+ These files are tests/data/test[num] where [num] is described in section 2
+ of this document, and the XML-like file format of them is described in the
+ separate tests/FILEFORMAT document.
+
+ 3.2 curl tests
+
+ A test case that runs the curl tool and verifies that it gets the correct
+ data, it sends the correct data, it uses the correct protocol primitives
+ etc.
+
+ 3.3 libcurl tests
+
+ The libcurl tests are identical to the curl ones, except that they use a
+ specific and dedicated custom-built program to run instead of "curl". This
+ tool is built from source code placed in tests/libtest and if you want to
+ make a new libcurl test that is where you add your code.
+
+ 3.4 unit tests
+
+ Unit tests are tests in the 13xx sequence and they are placed in tests/unit.
+ There's a tests/unit/README describing the specific set of checks and macros
+ that may be used when writing tests that verify behaviors of specific
+ individual functions.
+
+ The unit tests depend on curl being built with debug enabled.
+
+4. TODO
+
+ 4.1 More protocols
+
+ Add tests for TELNET, LDAP, DICT...
+
+ 4.2 SOCKS auth
+
+ SOCKS4/5 test deficiencies - no proxy authentication tests as SSH (the
+ test mechanism) doesn't support them
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 363c40628..8471736ca 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -53,9 +53,11 @@ test605 test606 test607 test608 test609 test610 test611 test612 test613 \
test614 test615 test616 test617 test618 test619 test620 test621 test622 \
test623 test624 test625 test626 test627 test628 test629 test630 test631 \
test632 test633 test634 test635 test636 test637 test700 test701 test702 \
-test703 test704 test705 test706 test707 test708 test800 test801 test802 \
+test703 test704 test705 test706 test707 test708 test709 test710 \
+test800 test801 test802 \
test803 test804 test805 test806 test807 test808 test809 test810 test811 \
-test812 test813 test1000 test1001 test1002 test1003 test1004 test1005 \
+test812 test813 test814 \
+test1000 test1001 test1002 test1003 test1004 test1005 \
test1006 test1007 test1008 test1009 test1010 test1011 test1012 test1013 \
test1014 test1015 test1016 test1017 test1018 test1019 test1020 test1021 \
test1022 test1023 test1024 test1025 test1026 test1027 test1028 test1029 \
@@ -71,9 +73,12 @@ test1094 test1095 test1096 test1097 test1098 test1099 test1100 test1101 \
test1102 test1103 test1104 test1105 test1106 test1107 test1108 test1109 \
test1110 test1111 test1112 test1113 test1114 test1115 test1116 test1117 \
test1118 test1119 test1120 test1121 test1122 test1123 test1124 test1125 \
-test1126 test1127 test1128 test1200 test1201 test1202 test1203 test1300 \
-test1301 test1302 test1303 test1304 test1305 test1306 test1307 test1308 \
-test1309 test2000 test2001 test2002 test2003 test2004
+test1126 test1127 test1128 test1129 test1130 test1131 \
+test1200 test1201 test1202 test1203 test1204 \
+test1300 test1301 test1302 test1303 test1304 test1305 \
+test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \
+test1314 \
+test2000 test2001 test2002 test2003 test2004
EXTRA_DIST = $(TESTCASES) DISABLED
diff --git a/tests/data/test1129 b/tests/data/test1129
new file mode 100644
index 000000000..f47141cd3
--- /dev/null
+++ b/tests/data/test1129
@@ -0,0 +1,97 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+Expect: 100-continue
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 404 NOOOOOOOOO
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+</data>
+
+<data1>
+HTTP/1.1 404 NEITHER
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+</data1>
+
+# we use skip to make the test server never read the full payload off
+# the socket and instead return the response at once
+<servercmd>
+skip: 1025
+</servercmd>
+</reply>
+
+#
+# Client-side
+<client>
+# 1025 x 'x'
+<file name="log/file1129">
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+</file>
+<server>
+http
+</server>
+ <name>
+HTTP POST expect 100-continue with a 404
+ </name>
+ <command option="no-output">
+-d @log/file1129 http://%HOSTIP:%HTTPPORT/1129 http://%HOSTIP:%HTTPPORT/11290001
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<stdout>
+HTTP/1.1 404 NOOOOOOOOO
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+HTTP/1.1 404 NEITHER
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+</stdout>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+POST /1129 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 1025
+Content-Type: application/x-www-form-urlencoded
+Expect: 100-continue
+
+POST /11290001 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 1025
+Content-Type: application/x-www-form-urlencoded
+Expect: 100-continue
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test1130 b/tests/data/test1130
new file mode 100644
index 000000000..eb1e59f5b
--- /dev/null
+++ b/tests/data/test1130
@@ -0,0 +1,97 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP POST
+Expect: 100-continue
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 404 NOOOOOOOOO
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+</data>
+
+<data1>
+HTTP/1.1 404 NEITHER
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+</data1>
+
+# we use skip to make the test server never read the full payload off
+# the socket and instead return the response at once
+<servercmd>
+skip: 100
+</servercmd>
+</reply>
+
+#
+# Client-side
+<client>
+# 100 x 'x'
+<file name="log/file1130">
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+</file>
+<server>
+http
+</server>
+ <name>
+HTTP POST forced expect 100-continue with a 404
+ </name>
+ <command option="no-output">
+-d @log/file1130 http://%HOSTIP:%HTTPPORT/1130 http://%HOSTIP:%HTTPPORT/11300001 -H "Expect: 100-continue"
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<stdout>
+HTTP/1.1 404 NOOOOOOOOO
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+HTTP/1.1 404 NEITHER
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Content-Type: text/html
+
+-foo-
+</stdout>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+POST /1130 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Expect: 100-continue
+Content-Length: 100
+Content-Type: application/x-www-form-urlencoded
+
+POST /11300001 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Expect: 100-continue
+Content-Length: 100
+Content-Type: application/x-www-form-urlencoded
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test1131 b/tests/data/test1131
new file mode 100644
index 000000000..96843af54
--- /dev/null
+++ b/tests/data/test1131
@@ -0,0 +1,95 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP PUT
+Expect: 100-continue
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 400 NOOOOOOOOO
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 9
+Content-Type: text/html
+
+FAILURE1
+</data>
+
+<data1>
+HTTP/1.1 400 NEITHER
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 9
+Content-Type: text/html
+
+FAILURE2
+</data1>
+
+# we use skip to make the test server never read the full payload off
+# the socket and instead return the response at once
+<servercmd>
+skip: 100
+</servercmd>
+</reply>
+
+#
+# Client-side
+<client>
+# 100 x 'x'
+<file name="log/file1131">
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+</file>
+<server>
+http
+</server>
+ <name>
+HTTP PUT expect 100-continue with a 400
+ </name>
+ <command option="no-output">
+-T log/file1131 http://%HOSTIP:%HTTPPORT/1131 -T log/file1131 http://%HOSTIP:%HTTPPORT/11310001
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<stdout>
+HTTP/1.1 400 NOOOOOOOOO
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 9
+Content-Type: text/html
+
+FAILURE1
+HTTP/1.1 400 NEITHER
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 9
+Content-Type: text/html
+
+FAILURE2
+</stdout>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+PUT /1131 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 100
+Expect: 100-continue
+
+PUT /11310001 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 100
+Expect: 100-continue
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test1204 b/tests/data/test1204
new file mode 100644
index 000000000..02502fb8e
--- /dev/null
+++ b/tests/data/test1204
@@ -0,0 +1,79 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+HTTP Basic auth
+--anyauth
+</keywords>
+</info>
+# Server-side
+<reply>
+<data>
+HTTP/1.1 401 Authorization Required swsbounce
+Server: Apache/1.3.27 (Darwin) PHP/4.1.2
+WWW-Authenticate: X-MobileMe-AuthToken realm="Newcastle", Basic realm="fun fun fun"
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 26
+
+This is not the real page
+</data>
+
+# This is supposed to be returned when the server gets the second request
+<data1>
+HTTP/1.1 200 OK
+Server: Apache/1.3.27 (Darwin) PHP/4.1.2
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 23
+
+This IS the real page!
+</data1>
+
+<datacheck>
+HTTP/1.1 401 Authorization Required swsbounce
+Server: Apache/1.3.27 (Darwin) PHP/4.1.2
+WWW-Authenticate: X-MobileMe-AuthToken realm="Newcastle", Basic realm="fun fun fun"
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 26
+
+HTTP/1.1 200 OK
+Server: Apache/1.3.27 (Darwin) PHP/4.1.2
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 23
+
+This IS the real page!
+</datacheck>
+
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP with WWW-Authenticate and multiple auths in a single line
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/1204 -u testuser:testpass --anyauth
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1204 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+GET /1204 HTTP/1.1
+Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test130 b/tests/data/test130
index fbcf5251b..dcc46fc8f 100644
--- a/tests/data/test130
+++ b/tests/data/test130
@@ -37,9 +37,9 @@ ftp
FTP (optional .netrc; no user/pass) dir list PASV
</name>
<command>
---netrc-optional --netrc-file log/netrc ftp://%HOSTIP:%FTPPORT/
+--netrc-optional --netrc-file log/netrc130 ftp://%HOSTIP:%FTPPORT/
</command>
-<file name="log/netrc" >
+<file name="log/netrc130" >
# the following two lines were created while testing curl
machine %HOSTIP login user1 password passwd1
machine %HOSTIP login user2 password passwd2
diff --git a/tests/data/test1304 b/tests/data/test1304
index f438a6929..d518de9e4 100644
--- a/tests/data/test1304
+++ b/tests/data/test1304
@@ -21,7 +21,7 @@ netrc parsing unit tests
<tool>
unit1304
</tool>
-<file name="log/netrc">
+<file name="log/netrc1304">
machine example.com login admin password passwd
machine curl.example.com login none password none
</file>
diff --git a/tests/data/test131 b/tests/data/test131
index ad7f9e22a..86501c627 100644
--- a/tests/data/test131
+++ b/tests/data/test131
@@ -38,9 +38,9 @@ ftp
FTP (optional .netrc; user/no pass) dir list PASV
</name>
<command>
---netrc-optional --netrc-file log/netrc ftp://user2@%HOSTIP:%FTPPORT/
+--netrc-optional --netrc-file log/netrc131 ftp://user2@%HOSTIP:%FTPPORT/
</command>
-<file name="log/netrc" >
+<file name="log/netrc131" >
# the following two lines were created while testing curl
machine %HOSTIP login user1 password passwd1
machine %HOSTIP login user2 password passwd2
diff --git a/tests/data/test1310 b/tests/data/test1310
new file mode 100644
index 000000000..840f3c5fa
--- /dev/null
+++ b/tests/data/test1310
@@ -0,0 +1,125 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+HTTP NTLM auth
+</keywords>
+</info>
+# Server-side
+<reply>
+
+<!-- no <data> in this test since we have NTLM from the start
+
+This is supposed to be returned when the server gets a first
+Authorization: NTLM line passed-in from the client -->
+
+<data1001>
+HTTP/1.1 401 Now gimme that second request of crap
+Server: Microsoft-IIS/5.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 34
+WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
+
+This is not the real page either!
+</data1001>
+
+# This is supposed to be returned when the server gets the second
+# Authorization: NTLM line passed-in from the client
+<data1002>
+HTTP/1.1 200 Things are fine in server land swsclose
+Server: Microsoft-IIS/5.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 32
+
+Finally, this is the real page!
+</data1002>
+
+<datacheck>
+HTTP/1.1 401 Now gimme that second request of crap
+Server: Microsoft-IIS/5.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 34
+WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
+
+HTTP/1.1 200 Things are fine in server land swsclose
+Server: Microsoft-IIS/5.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 32
+
+Finally, this is the real page!
+</datacheck>
+
+</reply>
+
+# Client-side
+<client>
+<features>
+NTLM_WB
+debug
+</features>
+<server>
+http
+</server>
+ <name>
+HTTP with NTLM delegation to winbind helper
+ </name>
+ <setenv>
+# we force our own host name, in order to make the test machine independent
+CURL_GETHOSTNAME=curlhost
+# we try to use the LD_PRELOAD hack, if not a debug build
+LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
+# set path to fake_auth instead of real ntlm_auth to generate NTLM type1 and type 3 messages
+CURL_NTLM_WB_FILE=%PWD/server/fake_ntlm
+# set source directory so fake_ntlm can find the test files
+CURL_NTLM_AUTH_SRCDIR=%SRCDIR
+# set the test number
+CURL_NTLM_AUTH_TESTNUM=1310
+ </setenv>
+ <command>
+http://%HOSTIP:%HTTPPORT/1310 -u testuser:anypasswd --ntlm-wb
+</command>
+<precheck>
+chkhostname curlhost
+</precheck>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1310 HTTP/1.1
+Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAA
+User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+GET /1310 HTTP/1.1
+Authorization: NTLM TlRMTVNTUAADAAAAGAAYAE8AAAAYABgAZwAAAAAAAABAAAAACAAIAEAAAAAHAAcASAAAAAAAAAAAAAAAggEAAHRlc3R1c2VyVU5LTk9XTlpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOQ==
+User-Agent: curl/7.10.6-pre1 (i686-pc-linux-gnu) libcurl/7.10.6-pre1 OpenSSL/0.9.7a ipv6 zlib/1.1.3
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+</verify>
+# Input and output (type 1 message) for fake_ntlm
+<ntlm_auth_type1>
+<input>
+YR
+</input>
+<output>
+YR TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAA
+</output>
+</ntlm_auth_type1>
+# Input and output (type 3 message) for fake_ntlm
+<ntlm_auth_type3>
+<input>
+TT TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA==
+</input>
+<output>
+KK TlRMTVNTUAADAAAAGAAYAE8AAAAYABgAZwAAAAAAAABAAAAACAAIAEAAAAAHAAcASAAAAAAAAAAAAAAAggEAAHRlc3R1c2VyVU5LTk9XTlpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOQ==
+</output>
+</ntlm_auth_type3>
+</testcase>
diff --git a/tests/data/test1311 b/tests/data/test1311
new file mode 100644
index 000000000..e47647c38
--- /dev/null
+++ b/tests/data/test1311
@@ -0,0 +1,64 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+-J
+</keywords>
+</info>
+
+#
+<reply>
+<data nocheck="yes">
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Content-Disposition: filename=name1311; charset=funny; option=strange
+
+12345
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+# this relies on the debug feature to allow us to set directory to store the
+# -J output in
+<features>
+debug
+</features>
+<server>
+http
+</server>
+<name>
+HTTP GET with -J and Content-Disposition
+</name>
+<setenv>
+CURL_TESTDIR=%PWD/log
+</setenv>
+<command option="no-output,no-include">
+http://%HOSTIP:%HTTPPORT/1311 -J -O
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1311 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+<file name="log/name1311">
+12345
+</file>
+
+</verify>
+</testcase>
diff --git a/tests/data/test1312 b/tests/data/test1312
new file mode 100644
index 000000000..92144015a
--- /dev/null
+++ b/tests/data/test1312
@@ -0,0 +1,64 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+-J
+</keywords>
+</info>
+
+#
+<reply>
+<data nocheck="yes">
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Content-Disposition: inline; filename="name1312;weird"
+
+12345
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+# this relies on the debug feature to allow us to set directory to store the
+# -J output in
+<features>
+debug
+</features>
+<server>
+http
+</server>
+<name>
+HTTP GET with -J, Content-Disposition and ; in filename
+</name>
+<setenv>
+CURL_TESTDIR=%PWD/log
+</setenv>
+<command option="no-output,no-include">
+http://%HOSTIP:%HTTPPORT/1312 -J -O
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1312 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+<file name="log/name1312;weird">
+12345
+</file>
+
+</verify>
+</testcase>
diff --git a/tests/data/test1313 b/tests/data/test1313
new file mode 100644
index 000000000..2331ae9ee
--- /dev/null
+++ b/tests/data/test1313
@@ -0,0 +1,64 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+-J
+</keywords>
+</info>
+
+#
+<reply>
+<data nocheck="yes">
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Content-Disposition: inline; filename='name1313
+
+12345
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+# this relies on the debug feature to allow us to set directory to store the
+# -J output in
+<features>
+debug
+</features>
+<server>
+http
+</server>
+<name>
+HTTP GET with -J, Content-Disposition, uneven quotes
+</name>
+<setenv>
+CURL_TESTDIR=%PWD/log
+</setenv>
+<command option="no-output,no-include">
+http://%HOSTIP:%HTTPPORT/1313 -J -O
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1313 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+<file name="log/name1313">
+12345
+</file>
+
+</verify>
+</testcase>
diff --git a/tests/data/test1314 b/tests/data/test1314
new file mode 100644
index 000000000..078ada64a
--- /dev/null
+++ b/tests/data/test1314
@@ -0,0 +1,79 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+HTTP proxy
+followlocation
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data>
+HTTP/1.1 301 This is a weirdo text message swsbounce
+Server: test-server/fake
+Location: //somewhere.example.com/reply/1314
+Content-Length: 32
+Connection: close
+
+Redirect to the same URL again!
+</data>
+
+<data1>
+HTTP/1.1 200 okidoki
+Server: test-server/fake
+Content-Length: 4
+Connection: close
+
+moo
+</data1>
+
+<datacheck>
+HTTP/1.1 301 This is a weirdo text message swsbounce
+Server: test-server/fake
+Location: //somewhere.example.com/reply/1314
+Content-Length: 32
+Connection: close
+
+HTTP/1.1 200 okidoki
+Server: test-server/fake
+Content-Length: 4
+Connection: close
+
+moo
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP Location: following a // prefixed url
+ </name>
+ <command>
+http://firstplace.example.com/want/1314 -L -x http://%HOSTIP:%HTTPPORT
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent: curl/.*
+</strip>
+<protocol>
+GET http://firstplace.example.com/want/1314 HTTP/1.1
+Host: firstplace.example.com
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+GET http://somewhere.example.com/reply/1314 HTTP/1.1
+Host: somewhere.example.com
+Accept: */*
+Proxy-Connection: Keep-Alive
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test132 b/tests/data/test132
index 8d9e3ed60..ed96953bb 100644
--- a/tests/data/test132
+++ b/tests/data/test132
@@ -37,9 +37,9 @@ ftp
FTP (optional .netrc; user/passwd supplied) dir list PASV
</name>
<command>
---netrc-optional --netrc-file log/netrc ftp://mary:mark@%HOSTIP:%FTPPORT/
+--netrc-optional --netrc-file log/netrc132 ftp://mary:mark@%HOSTIP:%FTPPORT/
</command>
-<file name="log/netrc" >
+<file name="log/netrc132" >
# the following two lines were created while testing curl
machine %HOSTIP login user1 password passwd1
machine %HOSTIP login user2 password passwd2
diff --git a/tests/data/test133 b/tests/data/test133
index a15cfc371..085092d01 100644
--- a/tests/data/test133
+++ b/tests/data/test133
@@ -37,9 +37,9 @@ ftp
FTP (compulsory .netrc; ignored user/passwd) dir list PASV
</name>
<command>
--n --netrc-file log/netrc ftp://mary:mark@%HOSTIP:%FTPPORT/
+-n --netrc-file log/netrc133 ftp://mary:mark@%HOSTIP:%FTPPORT/
</command>
-<file name="log/netrc" >
+<file name="log/netrc133" >
# the following two lines were created while testing curl
machine %HOSTIP login user1 password passwd1
machine %HOSTIP login user2 password passwd2
diff --git a/tests/data/test134 b/tests/data/test134
index 83035849e..8a3ba6204 100644
--- a/tests/data/test134
+++ b/tests/data/test134
@@ -37,9 +37,9 @@ ftp
FTP (optional .netrc; programmatic user/passwd) dir list PASV
</name>
<command>
---netrc-optional --netrc-file log/netrc -u romulus:rhemus ftp://mary:mark@%HOSTIP:%FTPPORT/
+--netrc-optional --netrc-file log/netrc134 -u romulus:rhemus ftp://mary:mark@%HOSTIP:%FTPPORT/
</command>
-<file name="log/netrc" >
+<file name="log/netrc134" >
# the following two lines were created while testing curl
machine %HOSTIP login user1 password passwd1
machine %HOSTIP login user2 password passwd2
diff --git a/tests/data/test257 b/tests/data/test257
index cc3b7f00a..45642d571 100644
--- a/tests/data/test257
+++ b/tests/data/test257
@@ -71,11 +71,11 @@ http
HTTP Location: following with --netrc-optional
</name>
<command>
-http://supersite.com/want/257 -L -x http://%HOSTIP:%HTTPPORT --netrc-optional --netrc-file log/netrc
+http://supersite.com/want/257 -L -x http://%HOSTIP:%HTTPPORT --netrc-optional --netrc-file log/netrc257
</command>
# netrc auth for two out of three sites:
-<file name="log/netrc">
+<file name="log/netrc257">
machine supersite.com login user1 password passwd1
machine anotherone.com login user2 password passwd2
</file>
diff --git a/tests/data/test31 b/tests/data/test31
index d06bc1180..5afe81df6 100644
--- a/tests/data/test31
+++ b/tests/data/test31
@@ -18,6 +18,28 @@ Content-Type: text/html
Funny-head: yesyes
Set-Cookie: foobar=name; domain=anything.com; path=/ ; secure
Set-Cookie:ismatch=this ; domain=127.0.0.1; path=/silly/
+Set-Cookie: sec1value=secure1 ; domain=127.0.0.1; path=/secure1/ ; secure
+Set-Cookie: sec2value=secure2 ; domain=127.0.0.1; path=/secure2/ ; secure=
+Set-Cookie: sec3value=secure3 ; domain=127.0.0.1; path=/secure3/ ; secure=
+Set-Cookie: sec4value=secure4 ; secure=; domain=127.0.0.1; path=/secure4/ ;
+Set-Cookie: sec5value=secure5 ; secure; domain=127.0.0.1; path=/secure5/ ;
+Set-Cookie: sec6value=secure6 ; secure ; domain=127.0.0.1; path=/secure6/ ;
+Set-Cookie: sec7value=secure7 ; secure ; domain=127.0.0.1; path=/secure7/ ;
+Set-Cookie: sec8value=secure8 ; secure= ; domain=127.0.0.1; path=/secure8/ ;
+Set-Cookie: secure=very1 ; secure=; domain=127.0.0.1; path=/secure9/;
+Set-Cookie: httpo1=value1 ; domain=127.0.0.1; path=/p1/; httponly
+Set-Cookie: httpo2=value2 ; domain=127.0.0.1; path=/p2/; httponly=
+Set-Cookie: httpo3=value3 ; httponly; domain=127.0.0.1; path=/p3/;
+Set-Cookie: httpo4=value4 ; httponly=; domain=127.0.0.1; path=/p4/;
+Set-Cookie: httponly=myvalue1 ; domain=127.0.0.1; path=/p4/; httponly
+Set-Cookie: httpandsec=myvalue2 ; domain=127.0.0.1; path=/p4/; httponly; secure
+Set-Cookie: httpandsec2=myvalue3; domain=127.0.0.1; path=/p4/; httponly=; secure
+Set-Cookie: httpandsec3=myvalue4 ; domain=127.0.0.1; path=/p4/; httponly; secure=
+Set-Cookie: httpandsec4=myvalue5 ; domain=127.0.0.1; path=/p4/; httponly=; secure=
+Set-Cookie: httpandsec5=myvalue6 ; domain=127.0.0.1; path=/p4/; secure; httponly=
+Set-Cookie: httpandsec6=myvalue7 ; domain=127.0.0.1; path=/p4/; secure=; httponly=
+Set-Cookie: httpandsec7=myvalue8 ; domain=127.0.0.1; path=/p4/; secure; httponly
+Set-Cookie: httpandsec8=myvalue9; domain=127.0.0.1; path=/p4/; secure=; httponly
Set-Cookie: partmatch=present; domain=127.0.0.1 ; path=/;
Set-Cookie:eat=this; domain=moo.foo.moo;
Set-Cookie: eat=this-too; domain=.foo.moo;
@@ -69,6 +91,28 @@ Accept: */*
# This file was generated by libcurl! Edit at your own risk.
.127.0.0.1 TRUE /silly/ FALSE 0 ismatch this
+.127.0.0.1 TRUE /secure1/ TRUE 0 sec1value secure1
+.127.0.0.1 TRUE /secure2/ TRUE 0 sec2value secure2
+.127.0.0.1 TRUE /secure3/ TRUE 0 sec3value secure3
+.127.0.0.1 TRUE /secure4/ TRUE 0 sec4value secure4
+.127.0.0.1 TRUE /secure5/ TRUE 0 sec5value secure5
+.127.0.0.1 TRUE /secure6/ TRUE 0 sec6value secure6
+.127.0.0.1 TRUE /secure7/ TRUE 0 sec7value secure7
+.127.0.0.1 TRUE /secure8/ TRUE 0 sec8value secure8
+.127.0.0.1 TRUE /secure9/ TRUE 0 secure very1
+#HttpOnly_.127.0.0.1 TRUE /p1/ FALSE 0 httpo1 value1
+#HttpOnly_.127.0.0.1 TRUE /p2/ FALSE 0 httpo2 value2
+#HttpOnly_.127.0.0.1 TRUE /p3/ FALSE 0 httpo3 value3
+#HttpOnly_.127.0.0.1 TRUE /p4/ FALSE 0 httpo4 value4
+#HttpOnly_.127.0.0.1 TRUE /p4/ FALSE 0 httponly myvalue1
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec myvalue2
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec2 myvalue3
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec3 myvalue4
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec4 myvalue5
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec5 myvalue6
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec6 myvalue7
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec7 myvalue8
+#HttpOnly_.127.0.0.1 TRUE /p4/ TRUE 0 httpandsec8 myvalue9
.127.0.0.1 TRUE / FALSE 0 partmatch present
127.0.0.1 FALSE /we/want/ FALSE 2054030187 nodomain value
#HttpOnly_127.0.0.1 FALSE /silly/ FALSE 0 magic yessir
diff --git a/tests/data/test320 b/tests/data/test320
index bfef00cb2..899bec597 100644
--- a/tests/data/test320
+++ b/tests/data/test320
@@ -41,7 +41,7 @@ Accept: */*
# Client-side
<client>
<server>
-http+tls-srp
+httptls+srp
</server>
<features>
TLS-SRP
diff --git a/tests/data/test321 b/tests/data/test321
index 84c19bc85..ccdfb86d0 100644
--- a/tests/data/test321
+++ b/tests/data/test321
@@ -10,7 +10,7 @@ FAILURE
# Client-side
<client>
<server>
-http+tls-srp
+httptls+srp
</server>
<features>
TLS-SRP
diff --git a/tests/data/test322 b/tests/data/test322
index f44deb54b..f35345ead 100644
--- a/tests/data/test322
+++ b/tests/data/test322
@@ -10,7 +10,7 @@ FAILURE
# Client-side
<client>
<server>
-http+tls-srp
+httptls+srp
</server>
<features>
TLS-SRP
diff --git a/tests/data/test324 b/tests/data/test324
index df150ab3c..bc1c48fea 100644
--- a/tests/data/test324
+++ b/tests/data/test324
@@ -10,7 +10,7 @@ FAILURE
# Client-side
<client>
<server>
-http+tls-srp
+httptls+srp
</server>
<features>
TLS-SRP
diff --git a/tests/data/test4 b/tests/data/test4
index ce6bfc8f0..df69d3274 100644
--- a/tests/data/test4
+++ b/tests/data/test4
@@ -30,7 +30,7 @@ http
Replaced internal and added custom HTTP headers
</name>
<command>
- -H "extra-header: here" -H "Accept: replaced" http://%HOSTIP:%HTTPPORT/4
+ -H "extra-header: here" -H "Accept: replaced" -H "X-Custom-Header;" -H "X-Test: foo; " -H "X-Test:" -H "X-Test2: foo;" -H "X-Test3: " -H "X-Test4; " -H "X-Test5;ignored" http://%HOSTIP:%HTTPPORT/4
</command>
</client>
@@ -45,6 +45,9 @@ GET /4 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
extra-header: here
Accept: replaced
+X-Custom-Header:
+X-Test: foo;
+X-Test2: foo;
</protocol>
</verify>
diff --git a/tests/data/test504 b/tests/data/test504
index 573ab51c7..2d3a3dd0d 100644
--- a/tests/data/test504
+++ b/tests/data/test504
@@ -35,9 +35,10 @@ http://%HOSTIP:%HTTPSPORT/504 %HOSTIP:55555
</client>
# Verify data after the test has been "shot"
+# TEST_ERR_SUCCESS is errorcode 120
<verify>
<errorcode>
-100
+120
</errorcode>
</verify>
</testcase>
diff --git a/tests/data/test538 b/tests/data/test538
index f33b2a654..d2fecd353 100644
--- a/tests/data/test538
+++ b/tests/data/test538
@@ -32,11 +32,10 @@ ftp://%HOSTIP:%FTPPORT/538
</client>
# Verify data after the test has been "shot"
+# TEST_ERR_SUCCESS is errorcode 120
<verify>
-# ok, the error code here is supposed to be 100 for the fine case since
-# that's just how lib504.c is written
<errorcode>
-100
+120
</errorcode>
<protocol>
USER anonymous
diff --git a/tests/data/test554 b/tests/data/test554
index 7fdc353fc..9d9bbcca7 100644
--- a/tests/data/test554
+++ b/tests/data/test554
@@ -45,7 +45,7 @@ s/boundary=----------------------------[a-z0-9]*/boundary=----------------------
POST /554 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 561
+Content-Length: 732
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------
@@ -67,6 +67,11 @@ postit2.c
Content-Disposition: form-data; name="submit"
send
+------------------------------
+Content-Disposition: form-data; name="somename"; filename="somefile.txt"
+Content-Type: application/octet-stream
+
+blah blah
--------------------------------
</protocol>
</verify>
diff --git a/tests/data/test569 b/tests/data/test569
index 5cd4797fe..c4c62a4c3 100644
--- a/tests/data/test569
+++ b/tests/data/test569
@@ -51,6 +51,7 @@ Curl-Private: swsclose
CSeq: 6
</data6>
+</reply>
# Client-Side
<client>
diff --git a/tests/data/test572 b/tests/data/test572
index c06e531fc..83ae646e2 100644
--- a/tests/data/test572
+++ b/tests/data/test572
@@ -28,10 +28,11 @@ Cseq: 2
scale=enormous
speed=ludicrous
+
</data2>
<data3>
-RTSP/1.0 200 OK
+RTSP/1.0 204 OK
Server: RTSPD/libcurl-test
Session: getparams-test
Cseq: 3
diff --git a/tests/data/test573 b/tests/data/test573
index 909ae3cf7..54ff8fb94 100644
--- a/tests/data/test573
+++ b/tests/data/test573
@@ -1,7 +1,8 @@
<testcase>
<info>
<keywords>
-FILE
+HTTP
+multi
</keywords>
</info>
#
diff --git a/tests/data/test583 b/tests/data/test583
index 2129ee729..8fca7d23c 100644
--- a/tests/data/test583
+++ b/tests/data/test583
@@ -35,9 +35,8 @@ sftp://localhost:%SSHPORT%PWD/log/upload583.txt %USER:
# Verify data after the test has been "shot"
<verify>
-<strip>
-</strip>
-<protocol>
-</protocol>
+<errorcode>
+0
+</errorcode>
</verify>
</testcase>
diff --git a/tests/data/test587 b/tests/data/test587
new file mode 100644
index 000000000..6e1239a6a
--- /dev/null
+++ b/tests/data/test587
@@ -0,0 +1,51 @@
+<testcase>
+#
+# Server-side
+<reply>
+<data>
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib587
+</tool>
+
+ <name>
+HTTP multi-part formpost with aborted read callback
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/587
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strippart>
+s/^------------------------------[a-z0-9]*/------------------------------/
+s/boundary=----------------------------[a-z0-9]*/boundary=----------------------------/
+</strippart>
+<protocol>
+POST /587 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 732
+Expect: 100-continue
+Content-Type: multipart/form-data; boundary=----------------------------
+
+------------------------------
+Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
+
+</protocol>
+# CURLE_ABORTED_BY_CALLBACK (42)
+<errorcode>
+42
+</errorcode>
+</verify>
+</testcase>
diff --git a/tests/data/test709 b/tests/data/test709
new file mode 100644
index 000000000..6620f89a7
--- /dev/null
+++ b/tests/data/test709
@@ -0,0 +1,60 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+SOCKS5
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+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-side
+<client>
+<server>
+http
+socks5
+</server>
+<setenv>
+http_proxy=socks5://%HOSTIP:%SOCKSPORT
+</setenv>
+ <name>
+HTTP GET via SOCKS5 set in environment
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/709
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /709 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test710 b/tests/data/test710
new file mode 100644
index 000000000..884eb50a0
--- /dev/null
+++ b/tests/data/test710
@@ -0,0 +1,57 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+SOCKS5
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+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-side
+<client>
+<server>
+http
+socks5
+</server>
+ <name>
+HTTP GET via SOCKS5 set with --proxy
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/710 --proxy socks5://%HOSTIP:%SOCKSPORT
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /710 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+</verify>
+</testcase>
diff --git a/tests/data/test814 b/tests/data/test814
new file mode 100644
index 000000000..1fc060777
--- /dev/null
+++ b/tests/data/test814
@@ -0,0 +1,52 @@
+<testcase>
+<info>
+<keywords>
+SMTP
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+smtp
+</server>
+ <name>
+SMTP without --mail-from
+ </name>
+<stdin>
+From: different
+To: another
+
+body
+</stdin>
+ <command>
+smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 814@foo -T -
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+EHLO user
+MAIL FROM:<>
+RCPT TO:<814@foo>
+DATA
+QUIT
+</protocol>
+<upload>
+From: different
+To: another
+
+body
+
+.
+</upload>
+</verify>
+</testcase>
diff --git a/tests/getpart.pm b/tests/getpart.pm
index 4d47736b6..83e56ca92 100644
--- a/tests/getpart.pm
+++ b/tests/getpart.pm
@@ -63,6 +63,10 @@ sub getpartattr {
}
last;
}
+ # detect end of section when part wasn't found
+ elsif((1 ==$inside) && ($_ =~ /^ *\<\/$section\>/)) {
+ last;
+ }
elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) {
$inside--;
}
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 98e33c1f1..86b3b29ab 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -15,7 +15,7 @@ noinst_PROGRAMS = chkhostname \
lib579 lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 \
lib543 lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 \
lib556 lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 lib568 \
- lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585
+ lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib587
chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c
chkhostname_LDADD = @CURL_NETWORK_LIBS@
@@ -26,7 +26,7 @@ lib500_SOURCES = lib500.c $(SUPPORTFILES)
lib501_SOURCES = lib501.c $(SUPPORTFILES)
-lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL)
+lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
@@ -56,7 +56,7 @@ lib516_SOURCES = lib516.c $(SUPPORTFILES)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
-lib518_SOURCES = lib518.c $(SUPPORTFILES)
+lib518_SOURCES = lib518.c $(SUPPORTFILES) $(WARNLESS)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
@@ -89,11 +89,11 @@ lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
-lib537_SOURCES = lib537.c $(SUPPORTFILES)
+lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
-lib540_SOURCES = lib540.c $(SUPPORTFILES) $(WARNLESS)
+lib540_SOURCES = lib540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib541_SOURCES = lib541.c $(SUPPORTFILES)
@@ -113,7 +113,7 @@ lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548
lib549_SOURCES = lib549.c $(SUPPORTFILES)
-lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL)
+lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib552_SOURCES = lib552.c $(SUPPORTFILES)
@@ -125,11 +125,11 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
-lib560_SOURCES = lib560.c $(SUPPORTFILES) $(WARNLESS)
+lib560_SOURCES = lib560.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib574_SOURCES = lib574.c $(SUPPORTFILES)
-lib575_SOURCES = lib575.c $(SUPPORTFILES) $(WARNLESS)
+lib575_SOURCES = lib575.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib576_SOURCES = lib576.c $(SUPPORTFILES)
@@ -154,7 +154,7 @@ lib571_SOURCES = lib571.c $(SUPPORTFILES)
lib572_SOURCES = lib572.c $(SUPPORTFILES)
-lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL)
+lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib578_SOURCES = lib578.c $(SUPPORTFILES)
@@ -166,3 +166,6 @@ lib583_SOURCES = lib583.c $(SUPPORTFILES)
lib585_SOURCES = lib500.c $(SUPPORTFILES)
lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585
+
+lib587_SOURCES = lib554.c $(SUPPORTFILES)
+lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587
diff --git a/tests/libtest/first.c b/tests/libtest/first.c
index 205d3943f..57e6ddd79 100644
--- a/tests/libtest/first.c
+++ b/tests/libtest/first.c
@@ -30,19 +30,25 @@
# include "memdebug.h"
#endif
-int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
- struct timeval *tv)
+int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
+ struct timeval *tv)
{
+ if(nfds < 0) {
+ SET_SOCKERRNO(EINVAL);
+ return -1;
+ }
#ifdef USE_WINSOCK
- /* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is
- * case when 'num_fds <= 0. So sleep.
+ /*
+ * Winsock select() requires that at least one of the three fd_set
+ * pointers is not NULL and points to a non-empty fdset. IOW Winsock
+ * select() can not be used to sleep without a single fd_set.
*/
- if (num_fds <= 0) {
+ if(!nfds) {
Sleep(1000*tv->tv_sec + tv->tv_usec/1000);
return 0;
}
#endif
- return select(num_fds, rd, wr, exc, tv);
+ return select(nfds, rd, wr, exc, tv);
}
char *libtest_arg2=NULL;
@@ -50,28 +56,31 @@ char *libtest_arg3=NULL;
int test_argc;
char **test_argv;
+struct timeval tv_test_start; /* for test timing */
+
#ifdef UNITTESTS
int unitfail; /* for unittests */
#endif
-int main(int argc, char **argv)
-{
- char *URL;
-
#ifdef CURLDEBUG
- /* this sends all memory debug messages to a logfile named memdump */
- char *env = curl_getenv("CURL_MEMDEBUG");
+static void memory_tracking_init(void)
+{
+ char *env;
+ /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
+ env = curl_getenv("CURL_MEMDEBUG");
if(env) {
/* use the value as file name */
- char *s = strdup(env);
+ char fname[CURL_MT_LOGFNAME_BUFSIZE];
+ if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE)
+ env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0';
+ strcpy(fname, env);
curl_free(env);
- curl_memdebug(s);
- free(s);
- /* this weird strdup() and stuff here is to make the curl_free() get
- called before the memdebug() as otherwise the memdebug tracing will
- with tracing a free() without an alloc! */
+ curl_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! */
}
- /* this enables the fail-on-alloc-number-N functionality */
+ /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
env = curl_getenv("CURL_MEMLIMIT");
if(env) {
char *endptr;
@@ -80,8 +89,17 @@ int main(int argc, char **argv)
curl_memlimit(num);
curl_free(env);
}
+}
+#else
+# define memory_tracking_init() Curl_nop_stmt
#endif
+int main(int argc, char **argv)
+{
+ char *URL;
+
+ memory_tracking_init();
+
/*
* Setup proper locale from environment. This is needed to enable locale-
* specific behaviour by the C library in order to test for undesired side
diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c
index 8ebeb1292..51680fc31 100644
--- a/tests/libtest/lib500.c
+++ b/tests/libtest/lib500.c
@@ -52,7 +52,7 @@ static void setupcallbacks(CURL *curl)
}
#else
-#define setupcallbacks(x)
+#define setupcallbacks(x) Curl_nop_stmt
#endif
diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c
index 9ade12afb..554583ae2 100644
--- a/tests/libtest/lib502.c
+++ b/tests/libtest/lib502.c
@@ -22,10 +22,10 @@
#include "test.h"
#include "testutil.h"
+#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Get a single URL without select().
@@ -33,71 +33,57 @@
int test(char *URL)
{
- CURL *c;
+ CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
- int running=1;
- struct timeval mp_start;
- char mp_timedout = FALSE;
+ int running;
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- if ((c = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ global_init(CURL_GLOBAL_ALL);
- test_setopt(c, CURLOPT_URL, URL);
+ easy_init(c);
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_setopt(c, CURLOPT_URL, URL);
- if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (running) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- fprintf(stderr, "nothing left running.\n");
- break;
- }
- }
+ multi_add_handle(m, c);
+
+ for(;;) {
+ struct timeval timeout;
+ fd_set fdread, fdwrite, fdexcep;
+ int maxfd = -99;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000L; /* 100 ms */
+
+ multi_perform(m, &running);
- if (mp_timedout) {
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
+
+ if(!running)
+ break; /* done */
+
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ abort_on_test_timeout();
}
test_cleanup:
- if(m) {
- curl_multi_remove_handle(m, c);
- curl_multi_cleanup(m);
- }
+ /* proper cleanup sequence - type PA */
+
+ curl_multi_remove_handle(m, c);
+ curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c
index 25a641548..f3f96aaa5 100644
--- a/tests/libtest/lib503.c
+++ b/tests/libtest/lib503.c
@@ -21,14 +21,11 @@
***************************************************************************/
#include "test.h"
-#include <sys/types.h>
-
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Source code in here hugely as reported in bug report 651460 by
@@ -40,123 +37,62 @@
int test(char *URL)
{
- CURL *c;
+ CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
int running;
- char done = FALSE;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
-
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
- if ((c = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- test_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
- test_setopt(c, CURLOPT_URL, URL);
- test_setopt(c, CURLOPT_USERPWD, "test:ing");
- test_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
- test_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
- test_setopt(c, CURLOPT_HEADER, 1L);
-
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ global_init(CURL_GLOBAL_ALL);
- if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_init(c);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
+ easy_setopt(c, CURLOPT_URL, URL);
+ easy_setopt(c, CURLOPT_USERPWD, "test:ing");
+ easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
+ easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
+ easy_setopt(c, CURLOPT_HEADER, 1L);
- while(!done) {
- fd_set rd, wr, exc;
- int max_fd;
+ multi_init(m);
+
+ multi_add_handle(m, c);
+
+ for(;;) {
struct timeval interval;
+ fd_set rd, wr, exc;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (res == CURLM_CALL_MULTI_PERFORM) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- done = TRUE;
- break;
- }
- }
- if (mp_timedout || done)
- break;
-
- if (res != CURLM_OK) {
- fprintf(stderr, "not okay???\n");
- break;
- }
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
+ if(!running)
+ break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 89;
- break;
- }
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
- if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
- fprintf(stderr, "bad select??\n");
- res = 95;
- break;
- }
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- res = CURLM_CALL_MULTI_PERFORM;
- }
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
}
test_cleanup:
- if(m) {
- curl_multi_remove_handle(m, c);
- curl_multi_cleanup(m);
- }
+ /* proper cleanup sequence - type PA */
+
+ curl_multi_remove_handle(m, c);
+ curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c
index f45ac256b..358fc98dc 100644
--- a/tests/libtest/lib504.c
+++ b/tests/libtest/lib504.c
@@ -21,14 +21,11 @@
***************************************************************************/
#include "test.h"
-#include <sys/types.h>
-
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Source code in here hugely as reported in bug report 651464 by
@@ -39,85 +36,41 @@
*/
int test(char *URL)
{
- CURL *c;
+ CURL *c = NULL;
int res = 0;
CURLM *m = NULL;
fd_set rd, wr, exc;
- CURLMcode ret;
- char done = FALSE;
int running;
- int max_fd;
- int rc;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
-
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
- if ((c = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
+
+ global_init(CURL_GLOBAL_ALL);
+
+ easy_init(c);
/* The point here is that there must not be anything running on the given
proxy port */
if (libtest_arg2)
- test_setopt(c, CURLOPT_PROXY, libtest_arg2);
- test_setopt(c, CURLOPT_URL, URL);
- test_setopt(c, CURLOPT_VERBOSE, 1L);
-
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
+ easy_setopt(c, CURLOPT_URL, URL);
+ easy_setopt(c, CURLOPT_VERBOSE, 1L);
- if ((ret = curl_multi_add_handle(m, c)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", ret);
- curl_multi_cleanup(m);
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_add_handle(m, c);
- while (!done) {
+ for(;;) {
struct timeval interval;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
fprintf(stderr, "curl_multi_perform()\n");
- ret = CURLM_CALL_MULTI_PERFORM;
+ multi_perform(m, &running);
- while (ret == CURLM_CALL_MULTI_PERFORM) {
- ret = curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- }
- if (mp_timedout)
- break;
+ abort_on_test_timeout();
if(!running) {
/* This is where this code is expected to reach */
@@ -125,47 +78,34 @@ int test(char *URL)
CURLMsg *msg = curl_multi_info_read(m, &numleft);
fprintf(stderr, "Expected: not running\n");
if(msg && !numleft)
- res = 100; /* this is where we should be */
+ res = TEST_ERR_SUCCESS; /* this is where we should be */
else
- res = 99; /* not correct */
- break;
- }
- fprintf(stderr, "running == %d, ret == %d\n", running, ret);
-
- if (ret != CURLM_OK) {
- res = 2;
- break;
+ res = TEST_ERR_FAILURE; /* not correct */
+ break; /* done */
}
+ fprintf(stderr, "running == %d\n", running);
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
fprintf(stderr, "curl_multi_fdset()\n");
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 3;
- break;
- }
- rc = select_test(max_fd+1, &rd, &wr, &exc, &interval);
- fprintf(stderr, "select returned %d\n", rc);
- }
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
+
+ abort_on_test_timeout();
}
test_cleanup:
- if(m) {
- curl_multi_remove_handle(m, c);
- curl_multi_cleanup(m);
- }
+ /* proper cleanup sequence - type PA */
+
+ curl_multi_remove_handle(m, c);
+ curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c
index 0a255d673..394131ebe 100644
--- a/tests/libtest/lib505.c
+++ b/tests/libtest/lib505.c
@@ -24,12 +24,6 @@
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c
index 6476b9546..4477eaa50 100644
--- a/tests/libtest/lib506.c
+++ b/tests/libtest/lib506.c
@@ -20,9 +20,6 @@
*
***************************************************************************/
#include "test.h"
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
#include <curl/mprintf.h>
diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c
index c5a009d8c..87c21defb 100644
--- a/tests/libtest/lib507.c
+++ b/tests/libtest/lib507.c
@@ -25,75 +25,40 @@
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
- CURL* curls;
- CURLM* multi;
+ CURL* curls = NULL;
+ CURLM* multi = NULL;
int still_running;
int i = -1;
int res = 0;
CURLMsg *msg;
- CURLMcode ret;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
-
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
- if ((multi = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- if ((curls = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_multi_cleanup(multi);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ global_init(CURL_GLOBAL_ALL);
- test_setopt(curls, CURLOPT_URL, URL);
- test_setopt(curls, CURLOPT_HEADER, 1L);
+ multi_init(multi);
- if ((ret = curl_multi_add_handle(multi, curls)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", ret);
- curl_easy_cleanup(curls);
- curl_multi_cleanup(multi);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_init(curls);
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
+ easy_setopt(curls, CURLOPT_URL, URL);
+ easy_setopt(curls, CURLOPT_HEADER, 1L);
- do {
- ret = curl_multi_perform(multi, &still_running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- } while (ret == CURLM_CALL_MULTI_PERFORM);
+ multi_add_handle(multi, curls);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_perform(multi, &still_running);
- while ((!ml_timedout) && (!mp_timedout) && (still_running)) {
+ abort_on_test_timeout();
+
+ while(still_running) {
struct timeval timeout;
- int rc;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -101,49 +66,29 @@ int test(char *URL)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
-
- curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
- rc = select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
- switch(rc) {
- case -1:
- break;
- case 0:
- default:
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
- do {
- ret = curl_multi_perform(multi, &still_running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- } while (ret == CURLM_CALL_MULTI_PERFORM);
- break;
- }
- }
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- i = TEST_ERR_RUNS_FOREVER;
- }
- else {
- msg = curl_multi_info_read(multi, &still_running);
- if(msg)
- /* this should now contain a result code from the easy handle,
- get it */
- i = msg->data.result;
+ multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ abort_on_test_timeout();
+
+ multi_perform(multi, &still_running);
+
+ abort_on_test_timeout();
}
+ msg = curl_multi_info_read(multi, &still_running);
+ if(msg)
+ /* this should now contain a result code from the easy handle,
+ get it */
+ i = msg->data.result;
+
test_cleanup:
+ /* undocumented cleanup sequence - type UA */
+
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c
index c483d7ade..23f7f17c6 100644
--- a/tests/libtest/lib518.c
+++ b/tests/libtest/lib518.c
@@ -21,9 +21,6 @@
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
@@ -33,10 +30,8 @@
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
+#include "warnless.h"
#include "memdebug.h"
#ifndef FD_SETSIZE
diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c
index f034050eb..ca128cb9c 100644
--- a/tests/libtest/lib525.c
+++ b/tests/libtest/lib525.c
@@ -21,45 +21,45 @@
***************************************************************************/
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
int res = 0;
- CURL *curl;
- FILE *hd_src ;
+ CURL *curl = NULL;
+ FILE *hd_src = NULL;
int hd ;
int error;
struct_stat file_info;
- int running;
- char done=FALSE;
CURLM *m = NULL;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
+ int running;
+
+ start_test_timing();
- if (!libtest_arg2) {
+ if(!libtest_arg2) {
+#ifdef LIB529
+ /* test 529 */
+ fprintf(stderr, "Usage: lib529 [url] [uploadfile]\n");
+#else
+ /* test 525 */
fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n");
- return -1;
+#endif
+ return TEST_ERR_USAGE;
}
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
- fprintf(stderr, "fopen() failed with error: %d %s\n",
+ fprintf(stderr, "fopen() failed with error: %d (%s)\n",
error, strerror(error));
- fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
- return TEST_ERR_MAJOR_BAD;
+ fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
+ return TEST_ERR_FOPEN;
}
/* get the file size of the local file */
@@ -67,40 +67,35 @@ int test(char *URL)
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
- fprintf(stderr, "fstat() failed with error: %d %s\n",
+ fprintf(stderr, "fstat() failed with error: %d (%s)\n",
error, strerror(error));
- fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
+ fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
fclose(hd_src);
- return -1;
+ return TEST_ERR_FSTAT;
}
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
+ res_global_init(CURL_GLOBAL_ALL);
+ if(res) {
fclose(hd_src);
- return TEST_ERR_MAJOR_BAD;
+ return res;
}
- if ((curl = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- fclose(hd_src);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_init(curl);
/* enable uploading */
- test_setopt(curl, CURLOPT_UPLOAD, 1L);
+ easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
- test_setopt(curl,CURLOPT_URL, URL);
+ easy_setopt(curl,CURLOPT_URL, URL);
/* go verbose */
- test_setopt(curl, CURLOPT_VERBOSE, 1L);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* use active FTP */
- test_setopt(curl, CURLOPT_FTPPORT, "-");
+ easy_setopt(curl, CURLOPT_FTPPORT, "-");
/* now specify which file to upload */
- test_setopt(curl, CURLOPT_READDATA, hd_src);
+ easy_setopt(curl, CURLOPT_READDATA, hd_src);
/* NOTE: if you want this code to work on Windows with libcurl as a DLL, you
MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
@@ -111,114 +106,60 @@ int test(char *URL)
option you MUST make sure that the type of the passed-in argument is a
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
make sure that to pass in a type 'long' argument. */
- test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
- (curl_off_t)file_info.st_size);
-
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- fclose(hd_src);
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
- if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- fclose(hd_src);
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_add_handle(m, curl);
- while (!done) {
- fd_set rd, wr, exc;
- int max_fd;
+ for(;;) {
struct timeval interval;
+ fd_set rd, wr, exc;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (res == CURLM_CALL_MULTI_PERFORM) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- done = TRUE;
- break;
- }
- }
- if (mp_timedout || done)
- break;
-
- if (res != CURLM_OK) {
- fprintf(stderr, "not okay???\n");
- break;
- }
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
+ if(!running)
+ break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 189;
- break;
- }
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
- if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
- fprintf(stderr, "bad select??\n");
- res = 195;
- break;
- }
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- res = CURLM_CALL_MULTI_PERFORM;
- }
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
}
test_cleanup:
#ifdef LIB529
/* test 529 */
- if(m) {
- curl_multi_remove_handle(m, curl);
- curl_multi_cleanup(m);
- }
+ /* proper cleanup sequence - type PA */
+ curl_multi_remove_handle(m, curl);
+ curl_multi_cleanup(m);
curl_easy_cleanup(curl);
+ curl_global_cleanup();
#else
/* test 525 */
- if(m)
- curl_multi_remove_handle(m, curl);
+ /* proper cleanup sequence - type PB */
+ curl_multi_remove_handle(m, curl);
curl_easy_cleanup(curl);
- if(m)
- curl_multi_cleanup(m);
+ curl_multi_cleanup(m);
+ curl_global_cleanup();
#endif
- fclose(hd_src); /* close the local file */
+ /* close the local file */
+ fclose(hd_src);
- curl_global_cleanup();
return res;
}
diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c
index a0085ec3c..9db04dba7 100644
--- a/tests/libtest/lib526.c
+++ b/tests/libtest/lib526.c
@@ -40,16 +40,13 @@
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
@@ -58,192 +55,130 @@ int test(char *URL)
int res = 0;
CURL *curl[NUM_HANDLES];
int running;
- char done=FALSE;
CURLM *m = NULL;
- int current=0;
- int i, j;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
-
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
+ int current = 0;
+ int i;
+
+ for(i=0; i < NUM_HANDLES; i++)
+ curl[i] = NULL;
+
+ start_test_timing();
+
+ global_init(CURL_GLOBAL_ALL);
/* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
- curl[i] = curl_easy_init();
- if(!curl[i]) {
- fprintf(stderr, "curl_easy_init() failed "
- "on handle #%d\n", i);
- for (j=i-1; j >= 0; j--) {
- curl_easy_cleanup(curl[j]);
- }
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
- res = curl_easy_setopt(curl[i], CURLOPT_URL, URL);
- if(res) {
- fprintf(stderr, "curl_easy_setopt() failed "
- "on handle #%d\n", i);
- for (j=i; j >= 0; j--) {
- curl_easy_cleanup(curl[j]);
- }
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
-
+ easy_init(curl[i]);
+ /* specify target */
+ easy_setopt(curl[i], CURLOPT_URL, URL);
/* go verbose */
- res = curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
- if(res) {
- fprintf(stderr, "curl_easy_setopt() failed "
- "on handle #%d\n", i);
- for (j=i; j >= 0; j--) {
- curl_easy_cleanup(curl[j]);
- }
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
+ easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
}
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- for(i=0; i < NUM_HANDLES; i++) {
- curl_easy_cleanup(curl[i]);
- }
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
- if ((res = (int)curl_multi_add_handle(m, curl[current])) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- for(i=0; i < NUM_HANDLES; i++) {
- curl_easy_cleanup(curl[i]);
- }
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
-
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_add_handle(m, curl[current]);
fprintf(stderr, "Start at URL 0\n");
- while (!done) {
- fd_set rd, wr, exc;
- int max_fd;
+ for(;;) {
struct timeval interval;
+ fd_set rd, wr, exc;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (res == CURLM_CALL_MULTI_PERFORM) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
+ if(!running) {
#ifdef LIB527
- /* NOTE: this code does not remove the handle from the multi handle
- here, which would be the nice, sane and documented way of working.
- This however tests that the API survives this abuse gracefully. */
- curl_easy_cleanup(curl[current]);
+ /* NOTE: this code does not remove the handle from the multi handle
+ here, which would be the nice, sane and documented way of working.
+ This however tests that the API survives this abuse gracefully. */
+ curl_easy_cleanup(curl[current]);
+ curl[current] = NULL;
#endif
- if(++current < NUM_HANDLES) {
- fprintf(stderr, "Advancing to URL %d\n", current);
+ if(++current < NUM_HANDLES) {
+ fprintf(stderr, "Advancing to URL %d\n", current);
#ifdef LIB532
- /* first remove the only handle we use */
- curl_multi_remove_handle(m, curl[0]);
-
- /* make us re-use the same handle all the time, and try resetting
- the handle first too */
- curl_easy_reset(curl[0]);
- test_setopt(curl[0], CURLOPT_URL, URL);
- test_setopt(curl[0], CURLOPT_VERBOSE, 1L);
-
- /* re-add it */
- res = (int)curl_multi_add_handle(m, curl[0]);
+ /* first remove the only handle we use */
+ curl_multi_remove_handle(m, curl[0]);
+
+ /* make us re-use the same handle all the time, and try resetting
+ the handle first too */
+ curl_easy_reset(curl[0]);
+ easy_setopt(curl[0], CURLOPT_URL, URL);
+ /* go verbose */
+ easy_setopt(curl[0], CURLOPT_VERBOSE, 1L);
+
+ /* re-add it */
+ multi_add_handle(m, curl[0]);
#else
- res = (int)curl_multi_add_handle(m, curl[current]);
+ multi_add_handle(m, curl[current]);
#endif
- if(res) {
- fprintf(stderr, "add handle failed: %d.\n", res);
- res = 243;
- break;
- }
- }
- else
- done = TRUE; /* bail out */
- break;
}
- }
- if (mp_timedout || done)
- break;
-
- if (res != CURLM_OK) {
- fprintf(stderr, "not okay???\n");
- break;
+ else {
+ break; /* done */
+ }
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 189;
- break;
- }
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
- if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
- fprintf(stderr, "bad select??\n");
- res = 195;
- break;
- }
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- res = CURLM_CALL_MULTI_PERFORM;
- }
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
}
-#ifdef LIB532
test_cleanup:
-#endif
-#ifndef LIB527
- /* get NUM_HANDLES easy handles */
+#if defined(LIB526)
+
+ /* test 526 and 528 */
+ /* proper cleanup sequence - type PB */
+
for(i=0; i < NUM_HANDLES; i++) {
-#ifdef LIB526
- if(m)
- curl_multi_remove_handle(m, curl[i]);
-#endif
+ curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]);
}
-#endif
- if(m)
- curl_multi_cleanup(m);
+ curl_multi_cleanup(m);
+ curl_global_cleanup();
+#elif defined(LIB527)
+
+ /* test 527 */
+
+ /* Upon non-failure test flow the easy's have already been cleanup'ed. In
+ case there is a failure we arrive here with easy's that have not been
+ cleanup'ed yet, in this case we have to cleanup them or otherwise these
+ will be leaked, let's use undocumented cleanup sequence - type UB */
+
+ if(res)
+ for(i=0; i < NUM_HANDLES; i++)
+ curl_easy_cleanup(curl[i]);
+
+ curl_multi_cleanup(m);
curl_global_cleanup();
+
+#elif defined(LIB532)
+
+ /* test 532 */
+ /* undocumented cleanup sequence - type UB */
+
+ for(i=0; i < NUM_HANDLES; i++)
+ curl_easy_cleanup(curl[i]);
+ curl_multi_cleanup(m);
+ curl_global_cleanup();
+
+#endif
+
return res;
}
diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c
index add64ea31..ad84ff8a5 100644
--- a/tests/libtest/lib530.c
+++ b/tests/libtest/lib530.c
@@ -21,22 +21,11 @@
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
@@ -45,173 +34,71 @@ int test(char *URL)
int res = 0;
CURL *curl[NUM_HANDLES];
int running;
- char done=FALSE;
- CURLM *m;
- int i, j;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
+ CURLM *m = NULL;
+ int i;
char target_url[256];
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
+ for(i=0; i < NUM_HANDLES; i++)
+ curl[i] = NULL;
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
+
+ global_init(CURL_GLOBAL_ALL);
+
+ multi_init(m);
/* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
- curl[i] = curl_easy_init();
- if(!curl[i]) {
- fprintf(stderr, "curl_easy_init() failed "
- "on handle #%d\n", i);
- for (j=i-1; j >= 0; j--) {
- curl_multi_remove_handle(m, curl[j]);
- curl_easy_cleanup(curl[j]);
- }
- curl_multi_cleanup(m);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
+ /* get an easy handle */
+ easy_init(curl[i]);
+ /* specify target */
sprintf(target_url, "%s%04i", URL, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
-
- res = curl_easy_setopt(curl[i], CURLOPT_URL, target_url);
- if(res) {
- fprintf(stderr, "curl_easy_setopt() failed "
- "on handle #%d\n", i);
- for (j=i; j >= 0; j--) {
- curl_multi_remove_handle(m, curl[j]);
- curl_easy_cleanup(curl[j]);
- }
- curl_multi_cleanup(m);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
-
+ easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
- res = curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
- if(res) {
- fprintf(stderr, "curl_easy_setopt() failed "
- "on handle #%d\n", i);
- for (j=i; j >= 0; j--) {
- curl_multi_remove_handle(m, curl[j]);
- curl_easy_cleanup(curl[j]);
- }
- curl_multi_cleanup(m);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
-
+ easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
- res = curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L);
- if(res) {
- fprintf(stderr, "curl_easy_setopt() failed "
- "on handle #%d\n", i);
- for (j=i; j >= 0; j--) {
- curl_multi_remove_handle(m, curl[j]);
- curl_easy_cleanup(curl[j]);
- }
- curl_multi_cleanup(m);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
-
+ easy_setopt(curl[i], CURLOPT_HEADER, 1L);
/* add handle to multi */
- if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "on handle #%d with code %d\n", i, res);
- curl_easy_cleanup(curl[i]);
- for (j=i-1; j >= 0; j--) {
- curl_multi_remove_handle(m, curl[j]);
- curl_easy_cleanup(curl[j]);
- }
- curl_multi_cleanup(m);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD + i;
- }
+ multi_add_handle(m, curl[i]);
}
- curl_multi_setopt(m, CURLMOPT_PIPELINING, 1L);
-
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_setopt(m, CURLMOPT_PIPELINING, 1L);
fprintf(stderr, "Start at URL 0\n");
- while (!done) {
- fd_set rd, wr, exc;
- int max_fd;
+ for(;;) {
struct timeval interval;
+ fd_set rd, wr, exc;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (res == CURLM_CALL_MULTI_PERFORM) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- done = TRUE; /* bail out */
- break;
- }
- }
- if (mp_timedout || done)
- break;
-
- if (res != CURLM_OK) {
- fprintf(stderr, "not okay???\n");
- break;
- }
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
+ if(!running)
+ break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 189;
- break;
- }
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
- if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
- fprintf(stderr, "bad select??\n");
- res = 195;
- break;
- }
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- res = CURLM_CALL_MULTI_PERFORM;
- }
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
}
-/* test_cleanup: */
+test_cleanup:
+
+ /* proper cleanup sequence - type PB */
- /* cleanup NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]);
diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c
index 606eba75c..fdc18a1eb 100644
--- a/tests/libtest/lib533.c
+++ b/tests/libtest/lib533.c
@@ -23,156 +23,89 @@
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
int res = 0;
- CURL *curl;
+ CURL *curl = NULL;
int running;
- char done=FALSE;
CURLM *m = NULL;
int current=0;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
-
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
- if ((curl = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- test_setopt(curl, CURLOPT_URL, URL);
- test_setopt(curl, CURLOPT_VERBOSE, 1);
- test_setopt(curl, CURLOPT_FAILONERROR, 1);
+ global_init(CURL_GLOBAL_ALL);
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_init(curl);
- if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_setopt(curl, CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
+
+ multi_init(m);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_add_handle(m, curl);
fprintf(stderr, "Start at URL 0\n");
- while (!done) {
- fd_set rd, wr, exc;
- int max_fd;
+ for(;;) {
struct timeval interval;
+ fd_set rd, wr, exc;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (res == CURLM_CALL_MULTI_PERFORM) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- if(!current++) {
- fprintf(stderr, "Advancing to URL 1\n");
- /* remove the handle we use */
- curl_multi_remove_handle(m, curl);
-
- /* make us re-use the same handle all the time, and try resetting
- the handle first too */
- curl_easy_reset(curl);
- test_setopt(curl, CURLOPT_URL, libtest_arg2);
- test_setopt(curl, CURLOPT_VERBOSE, 1);
- test_setopt(curl, CURLOPT_FAILONERROR, 1);
-
- /* re-add it */
- res = (int)curl_multi_add_handle(m, curl);
- if(res) {
- fprintf(stderr, "add handle failed: %d.\n", res);
- res = 243;
- break;
- }
- }
- else
- done = TRUE; /* bail out */
- break;
- }
- }
- if (mp_timedout || done)
- break;
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
+ if(!running) {
+ if(!current++) {
+ fprintf(stderr, "Advancing to URL 1\n");
+ /* remove the handle we use */
+ curl_multi_remove_handle(m, curl);
- if (res != CURLM_OK) {
- fprintf(stderr, "not okay???\n");
- break;
+ /* make us re-use the same handle all the time, and try resetting
+ the handle first too */
+ curl_easy_reset(curl);
+ easy_setopt(curl, CURLOPT_URL, libtest_arg2);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
+
+ /* re-add it */
+ multi_add_handle(m, curl);
+ }
+ else
+ break; /* done */
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 189;
- break;
- }
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
- if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
- fprintf(stderr, "bad select??\n");
- res = 195;
- break;
- }
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- res = CURLM_CALL_MULTI_PERFORM;
- }
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
}
test_cleanup:
+ /* undocumented cleanup sequence - type UB */
+
curl_easy_cleanup(curl);
- if(m)
- curl_multi_cleanup(m);
+ curl_multi_cleanup(m);
curl_global_cleanup();
return res;
diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c
index dca880cea..e3ae402b7 100644
--- a/tests/libtest/lib536.c
+++ b/tests/libtest/lib536.c
@@ -21,128 +21,117 @@
***************************************************************************/
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
-static CURLMcode perform(CURLM * multi)
+static int perform(CURLM *multi)
{
int handles;
- CURLMcode code;
fd_set fdread, fdwrite, fdexcep;
- struct timeval mp_start;
- char mp_timedout = FALSE;
-
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- for (;;) {
- static struct timeval timeout = /* 100 ms */ { 0, 100000L };
- int maxfd = -1;
-
- code = curl_multi_perform(multi, &handles);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (handles <= 0)
- return CURLM_OK;
-
- switch (code) {
- case CURLM_OK:
- break;
- case CURLM_CALL_MULTI_PERFORM:
- continue;
- default:
- return code;
- }
+ int res = 0;
+
+ for(;;) {
+ struct timeval interval;
+ int maxfd = -99;
+
+ interval.tv_sec = 0;
+ interval.tv_usec = 100000L; /* 100 ms */
+
+ res_multi_perform(multi, &handles);
+ if(res)
+ return res;
+
+ res_test_timedout();
+ if(res)
+ return res;
+
+ if(!handles)
+ break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
- curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
- /* In a real-world program you OF COURSE check the return code of the
- function calls. On success, the value of maxfd is guaranteed to be
- greater or equal than -1. We call select(maxfd + 1, ...), specially in
- case of (maxfd == -1), we call select(0, ...), which is basically equal
- to sleep. */
+ res_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
+ if(res)
+ return res;
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1)
- return (CURLMcode) ~CURLM_OK;
+ res_select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval);
+ if(res)
+ return res;
+
+ res_test_timedout();
+ if(res)
+ return res;
}
- /* We only reach this point if (mp_timedout) */
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- return (CURLMcode) ~CURLM_OK;
+ return 0; /* success */
}
int test(char *URL)
{
- CURLM *multi;
- CURL *easy;
+ CURLM *multi = NULL;
+ CURL *easy = NULL;
int res = 0;
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- if ((multi = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ global_init(CURL_GLOBAL_ALL);
- if ((easy = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_multi_cleanup(multi);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(multi);
- curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
+ easy_init(easy);
- test_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
- test_setopt(easy, CURLOPT_FAILONERROR, 1L);
- test_setopt(easy, CURLOPT_URL, URL);
+ multi_setopt(multi, CURLMOPT_PIPELINING, 1L);
- if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
- printf("curl_multi_add_handle() failed\n");
- res = TEST_ERR_MAJOR_BAD;
- } else {
- if (perform(multi) != CURLM_OK)
- printf("retrieve 1 failed\n");
+ easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
+ easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
+ easy_setopt(easy, CURLOPT_URL, URL);
- curl_multi_remove_handle(multi, easy);
+ res_multi_add_handle(multi, easy);
+ if(res) {
+ printf("curl_multi_add_handle() 1 failed\n");
+ goto test_cleanup;
}
+
+ res = perform(multi);
+ if(res) {
+ printf("retrieve 1 failed\n");
+ goto test_cleanup;
+ }
+
+ curl_multi_remove_handle(multi, easy);
+
curl_easy_reset(easy);
- test_setopt(easy, CURLOPT_FAILONERROR, 1L);
- test_setopt(easy, CURLOPT_URL, libtest_arg2);
+ easy_setopt(easy, CURLOPT_FAILONERROR, 1L);
+ easy_setopt(easy, CURLOPT_URL, libtest_arg2);
- if (curl_multi_add_handle(multi, easy) != CURLM_OK) {
+ res_multi_add_handle(multi, easy);
+ if(res) {
printf("curl_multi_add_handle() 2 failed\n");
- res = TEST_ERR_MAJOR_BAD;
- } else {
- if (perform(multi) != CURLM_OK)
- printf("retrieve 2 failed\n");
+ goto test_cleanup;
+ }
- curl_multi_remove_handle(multi, easy);
+ res = perform(multi);
+ if(res) {
+ printf("retrieve 2 failed\n");
+ goto test_cleanup;
}
+ curl_multi_remove_handle(multi, easy);
+
test_cleanup:
+ /* undocumented cleanup sequence - type UB */
+
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c
index 97119129b..24d252235 100644
--- a/tests/libtest/lib537.c
+++ b/tests/libtest/lib537.c
@@ -21,9 +21,6 @@
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
@@ -33,10 +30,8 @@
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
+#include "warnless.h"
#include "memdebug.h"
#if !defined(HAVE_POLL_FINE) && \
diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c
index 55457dd46..21d14872b 100644
--- a/tests/libtest/lib540.c
+++ b/tests/libtest/lib540.c
@@ -30,84 +30,111 @@
#include "test.h"
+#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
+#define TEST_HANG_TIMEOUT 60 * 1000
+
#define PROXY libtest_arg2
#define PROXYUSERPWD libtest_arg3
#define HOST test_argv[4]
-static int init(CURLM *cm, const char* url, const char* userpwd,
+#define NUM_HANDLES 2
+
+CURL *eh[NUM_HANDLES];
+
+static int init(int num, CURLM *cm, const char* url, const char* userpwd,
struct curl_slist *headers)
{
- CURL *eh;
- int res;
+ int res = 0;
- if ((eh = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- return 1; /* failure */
- }
+ res_easy_init(eh[num]);
+ if(res)
+ goto init_failed;
- res = curl_easy_setopt(eh, CURLOPT_URL, url);
- if(res) return 1;
- res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY);
- if(res) return 1;
- res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd);
- if(res) return 1;
- res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
- if(res) return 1;
- res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L);
- if(res) return 1;
- res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L);
- if(res) return 1;
- res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */
- if(res) return 1;
-
- if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- return 1; /* failure */
- }
+ res_easy_setopt(eh[num], CURLOPT_URL, url);
+ if(res)
+ goto init_failed;
+
+ res_easy_setopt(eh[num], CURLOPT_PROXY, PROXY);
+ if(res)
+ goto init_failed;
+
+ res_easy_setopt(eh[num], CURLOPT_PROXYUSERPWD, userpwd);
+ if(res)
+ goto init_failed;
+
+ res_easy_setopt(eh[num], CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
+ if(res)
+ goto init_failed;
+
+ res_easy_setopt(eh[num], CURLOPT_VERBOSE, 1L);
+ if(res)
+ goto init_failed;
+
+ res_easy_setopt(eh[num], CURLOPT_HEADER, 1L);
+ if(res)
+ goto init_failed;
+
+ res_easy_setopt(eh[num], CURLOPT_HTTPHEADER, headers); /* custom Host: */
+ if(res)
+ goto init_failed;
+
+ res_multi_add_handle(cm, eh[num]);
+ if(res)
+ goto init_failed;
return 0; /* success */
+
+init_failed:
+
+ curl_easy_cleanup(eh[num]);
+ eh[num] = NULL;
+
+ return res; /* failure */
}
-static int loop(CURLM *cm, const char* url, const char* userpwd,
+static int loop(int num, CURLM *cm, const char* url, const char* userpwd,
struct curl_slist *headers)
{
CURLMsg *msg;
- CURLMcode code;
long L;
- int M, Q, U = -1;
+ int Q, U = -1;
fd_set R, W, E;
struct timeval T;
+ int res = 0;
- if(init(cm, url, userpwd, headers))
- return 1; /* failure */
+ res = init(num, cm, url, userpwd, headers);
+ if(res)
+ return res;
while (U) {
- do {
- code = curl_multi_perform(cm, &U);
- } while (code == CURLM_CALL_MULTI_PERFORM);
+ int M = -99;
+
+ res_multi_perform(cm, &U);
+ if(res)
+ return res;
+
+ res_test_timedout();
+ if(res)
+ return res;
if (U) {
FD_ZERO(&R);
FD_ZERO(&W);
FD_ZERO(&E);
- if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
- fprintf(stderr, "E: curl_multi_fdset\n");
- return 1; /* failure */
- }
+ res_multi_fdset(cm, &R, &W, &E, &M);
+ if(res)
+ return res;
- /* In a real-world program you OF COURSE check the return that maxfd is
- bigger than -1 so that the call to select() below makes sense! */
+ /* At this point, M is guaranteed to be greater or equal than -1. */
- if (curl_multi_timeout(cm, &L)) {
- fprintf(stderr, "E: curl_multi_timeout\n");
- return 1; /* failure */
- }
+ res_multi_timeout(cm, &L);
+ if(res)
+ return res;
if(L != -1) {
T.tv_sec = L/1000;
@@ -118,24 +145,33 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
T.tv_usec = 0;
}
- if (0 > select(M+1, &R, &W, &E, &T)) {
- fprintf(stderr, "E: select\n");
- return 1; /* failure */
- }
+ res_select_test(M+1, &R, &W, &E, &T);
+ if(res)
+ return res;
}
- while ((msg = curl_multi_info_read(cm, &Q))) {
- if (msg->msg == CURLMSG_DONE) {
+ while((msg = curl_multi_info_read(cm, &Q)) != NULL) {
+ if(msg->msg == CURLMSG_DONE) {
+ int i;
CURL *e = msg->easy_handle;
fprintf(stderr, "R: %d - %s\n", (int)msg->data.result,
curl_easy_strerror(msg->data.result));
curl_multi_remove_handle(cm, e);
curl_easy_cleanup(e);
+ for(i=0; i < NUM_HANDLES; i++) {
+ if(eh[i] == e) {
+ eh[i] = NULL;
+ break;
+ }
+ }
}
- else {
+ else
fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg);
- }
}
+
+ res_test_timedout();
+ if(res)
+ return res;
}
return 0; /* success */
@@ -146,7 +182,13 @@ int test(char *URL)
CURLM *cm = NULL;
struct curl_slist *headers = NULL;
char buffer[246]; /* naively fixed-size */
- int res;
+ int res = 0;
+ int i;
+
+ for(i=0; i < NUM_HANDLES; i++)
+ eh[i] = NULL;
+
+ start_test_timing();
if(test_argc < 4)
return 99;
@@ -160,30 +202,37 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
+ res_global_init(CURL_GLOBAL_ALL);
+ if(res) {
curl_slist_free_all(headers);
- return TEST_ERR_MAJOR_BAD;
+ return res;
}
- if ((cm = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_slist_free_all(headers);
+ res_multi_init(cm);
+ if(res) {
curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
+ curl_slist_free_all(headers);
+ return res;
}
- res = loop(cm, URL, PROXYUSERPWD, headers);
+ res = loop(0, cm, URL, PROXYUSERPWD, headers);
if(res)
goto test_cleanup;
fprintf(stderr, "lib540: now we do the request again\n");
- res = loop(cm, URL, PROXYUSERPWD, headers);
+
+ res = loop(1, cm, URL, PROXYUSERPWD, headers);
test_cleanup:
- curl_multi_cleanup(cm);
+ /* proper cleanup sequence - type PB */
+ for(i=0; i < NUM_HANDLES; i++) {
+ curl_multi_remove_handle(cm, eh[i]);
+ curl_easy_cleanup(eh[i]);
+ }
+
+ curl_multi_cleanup(cm);
curl_global_cleanup();
curl_slist_free_all(headers);
diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c
index 6af7bc5cf..5fe8dd8ad 100644
--- a/tests/libtest/lib541.c
+++ b/tests/libtest/lib541.c
@@ -21,23 +21,10 @@
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include "memdebug.h"
/*
diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c
index efe8ea24e..84f493f3e 100644
--- a/tests/libtest/lib542.c
+++ b/tests/libtest/lib542.c
@@ -21,23 +21,10 @@
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include "memdebug.h"
/*
diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c
index ed8d13f05..d20429d91 100644
--- a/tests/libtest/lib554.c
+++ b/tests/libtest/lib554.c
@@ -40,6 +40,14 @@ struct WriteThis {
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
{
+#ifdef LIB587
+ (void)ptr;
+ (void)size;
+ (void)nmemb;
+ (void)userp;
+ return CURL_READFUNC_ABORT;
+#else
+
struct WriteThis *pooh = (struct WriteThis *)userp;
if(size*nmemb < 1)
@@ -53,6 +61,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
}
return 0; /* no more data left to deliver */
+#endif
}
int test(char *URL)
@@ -136,6 +145,16 @@ int test(char *URL)
if(formrc)
printf("curl_formadd(3) = %d\n", (int)formrc);
+ formrc = curl_formadd(&formpost, &lastptr,
+ CURLFORM_COPYNAME, "somename",
+ CURLFORM_BUFFER, "somefile.txt",
+ CURLFORM_BUFFERPTR, "blah blah",
+ CURLFORM_BUFFERLENGTH, 9,
+ CURLFORM_END);
+
+ if(formrc)
+ printf("curl_formadd(4) = %d\n", (int)formrc);
+
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_formfree(formpost);
diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c
index c67501521..49a81bf57 100644
--- a/tests/libtest/lib555.c
+++ b/tests/libtest/lib555.c
@@ -30,9 +30,10 @@
#include "test.h"
#include "testutil.h"
+#include "warnless.h"
#include "memdebug.h"
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
#define UPLOADTHIS "this is the blurb we want to upload\n"
@@ -74,95 +75,82 @@ static curlioerr ioctlcallback(CURL *handle,
int test(char *URL)
{
- int res;
- CURL *curl;
+ int res = 0;
+ CURL *curl = NULL;
int counter=0;
CURLM *m = NULL;
int running=1;
- struct timeval mp_start;
- char mp_timedout = FALSE;
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- if ((curl = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ global_init(CURL_GLOBAL_ALL);
+
+ easy_init(curl);
- test_setopt(curl, CURLOPT_URL, URL);
- test_setopt(curl, CURLOPT_VERBOSE, 1L);
- test_setopt(curl, CURLOPT_HEADER, 1L);
+ easy_setopt(curl, CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ easy_setopt(curl, CURLOPT_HEADER, 1L);
/* read the POST data from a callback */
- test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
- test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
- test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
- test_setopt(curl, CURLOPT_READDATA, &counter);
+ easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
+ easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
+ easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
+ easy_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */
- test_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
+ easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
- test_setopt(curl, CURLOPT_POST, 1L);
+ easy_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII. */
- test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
+ easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
- test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
- test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
- test_setopt(curl, CURLOPT_PROXYAUTH,
+ easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
+ easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3);
+ easy_setopt(curl, CURLOPT_PROXYAUTH,
(long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) );
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
- if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
-
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
+ multi_add_handle(m, curl);
while (running) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
+ struct timeval timeout;
+ fd_set fdread, fdwrite, fdexcep;
+ int maxfd = -99;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000L; /* 100 ms */
+
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
#ifdef TPF
sleep(1); /* avoid ctl-10 dump */
#endif
- if (running <= 0) {
- fprintf(stderr, "nothing left running.\n");
- break;
- }
- }
- if (mp_timedout) {
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ if(!running)
+ break; /* done */
+
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ abort_on_test_timeout();
}
test_cleanup:
- if(m) {
- curl_multi_remove_handle(m, curl);
- curl_multi_cleanup(m);
- }
+ /* proper cleanup sequence - type PA */
+
+ curl_multi_remove_handle(m, curl);
+ curl_multi_cleanup(m);
curl_easy_cleanup(curl);
curl_global_cleanup();
diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c
index e375be535..e8be1c7bd 100644
--- a/tests/libtest/lib560.c
+++ b/tests/libtest/lib560.c
@@ -21,7 +21,11 @@
***************************************************************************/
#include "test.h"
+#include "testutil.h"
#include "warnless.h"
+#include "memdebug.h"
+
+#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Simply download a HTTPS file!
@@ -35,46 +39,44 @@
*/
int test(char *URL)
{
- CURL *http_handle;
+ CURL *http_handle = NULL;
CURLM *multi_handle = NULL;
- CURLMcode code;
- int res;
+ int res = 0;
int still_running; /* keep number of running handles */
- http_handle = curl_easy_init();
- if (!http_handle)
- return TEST_ERR_MAJOR_BAD;
+ start_test_timing();
+
+ /*
+ ** curl_global_init called indirectly from curl_easy_init.
+ */
+
+ easy_init(http_handle);
/* set options */
- test_setopt(http_handle, CURLOPT_URL, URL);
- test_setopt(http_handle, CURLOPT_HEADER, 1L);
- test_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
- test_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
+ easy_setopt(http_handle, CURLOPT_URL, URL);
+ easy_setopt(http_handle, CURLOPT_HEADER, 1L);
+ easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L);
+ easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L);
/* init a multi stack */
- multi_handle = curl_multi_init();
- if (!multi_handle) {
- curl_easy_cleanup(http_handle);
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(multi_handle);
/* add the individual transfers */
- curl_multi_add_handle(multi_handle, http_handle);
+ multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */
- do {
- code = curl_multi_perform(multi_handle, &still_running);
- } while(code == CURLM_CALL_MULTI_PERFORM);
+ multi_perform(multi_handle, &still_running);
+
+ abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
- int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -85,33 +87,25 @@ int test(char *URL)
timeout.tv_usec = 0;
/* get file descriptors from the transfers */
- curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
-
- /* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1 so
- that the call to select() below makes sense! */
-
- rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
-
- switch(rc) {
- case -1:
- /* select error */
- break;
- case 0:
- default:
- /* timeout or readable/writable sockets */
- do {
- code = curl_multi_perform(multi_handle, &still_running);
- } while(code == CURLM_CALL_MULTI_PERFORM);
- break;
- }
+ multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ abort_on_test_timeout();
+
+ /* timeout or readable/writable sockets */
+ multi_perform(multi_handle, &still_running);
+
+ abort_on_test_timeout();
}
test_cleanup:
- if(multi_handle)
- curl_multi_cleanup(multi_handle);
+ /* undocumented cleanup sequence - type UA */
+ curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle);
curl_global_cleanup();
diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c
index 657a2d3cd..a5f0ea534 100644
--- a/tests/libtest/lib562.c
+++ b/tests/libtest/lib562.c
@@ -19,26 +19,12 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include "memdebug.h"
/*
diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c
index d831d21e1..ed00e1bf6 100644
--- a/tests/libtest/lib564.c
+++ b/tests/libtest/lib564.c
@@ -19,138 +19,74 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
int res = 0;
- CURL *curl;
+ CURL *curl = NULL;
int running;
- char done=FALSE;
CURLM *m = NULL;
- struct timeval ml_start;
- struct timeval mp_start;
- char ml_timedout = FALSE;
- char mp_timedout = FALSE;
-
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
- if ((curl = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- test_setopt(curl, CURLOPT_URL, URL);
- test_setopt(curl, CURLOPT_VERBOSE, 1);
- test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
- test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ global_init(CURL_GLOBAL_ALL);
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_init(curl);
- if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_setopt(curl, CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ easy_setopt(curl, CURLOPT_PROXY, libtest_arg2);
+ easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+
+ multi_init(m);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_add_handle(m, curl);
fprintf(stderr, "Start at URL 0\n");
- while (!done) {
- fd_set rd, wr, exc;
- int max_fd;
+ for(;;) {
struct timeval interval;
+ fd_set rd, wr, exc;
+ int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
-
- while (res == CURLM_CALL_MULTI_PERFORM) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- done = TRUE; /* bail out */
- break;
- }
- }
- if (mp_timedout || done)
- break;
-
- if (res != CURLM_OK) {
- fprintf(stderr, "not okay???\n");
- break;
- }
+ multi_perform(m, &running);
+
+ abort_on_test_timeout();
+
+ if(!running)
+ break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
- max_fd = 0;
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- res = 189;
- break;
- }
+ multi_fdset(m, &rd, &wr, &exc, &maxfd);
- if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
- fprintf(stderr, "bad select??\n");
- res = 195;
- break;
- }
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
- res = CURLM_CALL_MULTI_PERFORM;
- }
+ select_test(maxfd+1, &rd, &wr, &exc, &interval);
- if (ml_timedout || mp_timedout) {
- if (ml_timedout) fprintf(stderr, "ml_timedout\n");
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
}
test_cleanup:
+ /* undocumented cleanup sequence - type UB */
+
curl_easy_cleanup(curl);
- if(m)
- curl_multi_cleanup(m);
+ curl_multi_cleanup(m);
curl_global_cleanup();
return res;
diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c
index 4aa6d98e9..ba839d65f 100644
--- a/tests/libtest/lib566.c
+++ b/tests/libtest/lib566.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include "memdebug.h"
diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c
index 7466e7475..573529cd8 100644
--- a/tests/libtest/lib567.c
+++ b/tests/libtest/lib567.c
@@ -19,8 +19,8 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
+
#include "memdebug.h"
/*
diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c
index df0cd88d1..4b15821f2 100644
--- a/tests/libtest/lib568.c
+++ b/tests/libtest/lib568.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#ifdef HAVE_SYS_STAT_H
diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c
index 366e4c344..a434d7459 100644
--- a/tests/libtest/lib569.c
+++ b/tests/libtest/lib569.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include <curl/mprintf.h>
diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c
index 29d30dbef..a9fac9915 100644
--- a/tests/libtest/lib570.c
+++ b/tests/libtest/lib570.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include <curl/mprintf.h>
diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c
index 1b2bf7b74..c5f7240d0 100644
--- a/tests/libtest/lib571.c
+++ b/tests/libtest/lib571.c
@@ -19,12 +19,8 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c
index b54877cd4..3df4d036a 100644
--- a/tests/libtest/lib572.c
+++ b/tests/libtest/lib572.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#ifdef HAVE_SYS_STAT_H
diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c
index 466185844..943f6e8c8 100644
--- a/tests/libtest/lib573.c
+++ b/tests/libtest/lib573.c
@@ -19,14 +19,13 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include "testutil.h"
+#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000
-#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
/*
* Get a single URL without select().
@@ -34,65 +33,51 @@
int test(char *URL)
{
- CURL *c;
+ CURL *c = NULL;
CURLM *m = NULL;
int res = 0;
- int running=1;
+ int running = 1;
double connect_time = 0.0;
- struct timeval mp_start;
- char mp_timedout = FALSE;
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
- return TEST_ERR_MAJOR_BAD;
- }
+ start_test_timing();
- if ((c = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ global_init(CURL_GLOBAL_ALL);
- test_setopt(c, CURLOPT_HEADER, 1L);
- test_setopt(c, CURLOPT_URL, URL);
+ easy_init(c);
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_setopt(c, CURLOPT_HEADER, 1L);
+ easy_setopt(c, CURLOPT_URL, URL);
- if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(c);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
- mp_timedout = FALSE;
- mp_start = tutil_tvnow();
+ multi_add_handle(m, c);
while (running) {
- res = (int)curl_multi_perform(m, &running);
- if (tutil_tvdiff(tutil_tvnow(), mp_start) >
- MULTI_PERFORM_HANG_TIMEOUT) {
- mp_timedout = TRUE;
- break;
- }
- if (running <= 0) {
- fprintf(stderr, "nothing left running.\n");
- break;
- }
- }
+ struct timeval timeout;
+ fd_set fdread, fdwrite, fdexcep;
+ int maxfd = -99;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000L; /* 100 ms */
+
+ multi_perform(m, &running);
- if (mp_timedout) {
- if (mp_timedout) fprintf(stderr, "mp_timedout\n");
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
+ abort_on_test_timeout();
+
+ if(!running)
+ break; /* done */
+
+ FD_ZERO(&fdread);
+ FD_ZERO(&fdwrite);
+ FD_ZERO(&fdexcep);
+
+ multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ abort_on_test_timeout();
}
curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
@@ -103,10 +88,10 @@ int test(char *URL)
test_cleanup:
- if(m) {
- curl_multi_remove_handle(m, c);
- curl_multi_cleanup(m);
- }
+ /* proper cleanup sequence - type PA */
+
+ curl_multi_remove_handle(m, c);
+ curl_multi_cleanup(m);
curl_easy_cleanup(c);
curl_global_cleanup();
diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c
index 8c5781609..afb2bceae 100644
--- a/tests/libtest/lib574.c
+++ b/tests/libtest/lib574.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include "memdebug.h"
diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c
index 4d0b16576..942df68c5 100644
--- a/tests/libtest/lib575.c
+++ b/tests/libtest/lib575.c
@@ -19,17 +19,16 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
+#define TEST_HANG_TIMEOUT 60 * 1000
+
/* 3x download!
* 1. normal
* 2. dup handle
@@ -38,26 +37,21 @@
int test(char *URL)
{
- CURLMcode m;
- CURL *handle = NULL, *duphandle;
+ CURL *handle = NULL;
+ CURL *duphandle = NULL;
CURLM *mhandle = NULL;
int res = 0;
int still_running = 0;
- if(curl_global_init(CURL_GLOBAL_ALL)) {
- fprintf(stderr, "curl_global_init() failed\n");
- goto test_cleanup;
- }
+ start_test_timing();
- handle = curl_easy_init();
- if(!handle) {
- res = CURLE_OUT_OF_MEMORY;
- goto test_cleanup;
- }
+ global_init(CURL_GLOBAL_ALL);
- test_setopt(handle, CURLOPT_URL, URL);
- test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
- test_setopt(handle, CURLOPT_VERBOSE, 1L);
+ easy_init(handle);
+
+ easy_setopt(handle, CURLOPT_URL, URL);
+ easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
+ easy_setopt(handle, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(handle);
if(res)
@@ -73,51 +67,48 @@ int test(char *URL)
curl_easy_cleanup(handle);
handle = duphandle;
- mhandle = curl_multi_init();
- if(!mhandle) {
- fprintf(stderr, "curl_multi_init() failed\n");
- goto test_cleanup;
- }
+ multi_init(mhandle);
- curl_multi_add_handle(mhandle, handle);
+ multi_add_handle(mhandle, handle);
- while(CURLM_CALL_MULTI_PERFORM ==
- curl_multi_perform(mhandle, &still_running));
+ multi_perform(mhandle, &still_running);
+
+ abort_on_test_timeout();
while(still_running) {
- static struct timeval timeout = /* 100 ms */ { 0, 100000L };
- int rc;
+ struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int max_fdset = -1;
+ int maxfd = -99;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100000L; /* 100 ms */
+
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
- m = curl_multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &max_fdset);
- if(m != CURLM_OK) {
- fprintf(stderr, "curl_multi_fdset() error\n");
- goto test_cleanup;
- }
- /* We call select(max_fdset + 1, ...), specially in case of (maxfd == -1),
- * we call select(0, ...), which is basically equal to sleep. */
- rc = select(max_fdset + 1, &fdread, &fdwrite, &fdexcep, &timeout);
- if(rc == -1) {
- fprintf(stderr, "select() error\n");
- goto test_cleanup;
- }
- else {
- while(CURLM_CALL_MULTI_PERFORM ==
- curl_multi_perform(mhandle, &still_running));
- }
+ multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);
+
+ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
+
+ select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
+
+ abort_on_test_timeout();
+
+ multi_perform(mhandle, &still_running);
+
+ abort_on_test_timeout();
}
test_cleanup:
- if(mhandle)
- curl_multi_cleanup(mhandle);
- if(handle)
- curl_easy_cleanup(handle);
+
+ /* undocumented cleanup sequence - type UA */
+
+ curl_multi_cleanup(mhandle);
+ curl_easy_cleanup(handle);
curl_global_cleanup();
+
return res;
}
diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c
index 48841b59d..61bb61325 100644
--- a/tests/libtest/lib576.c
+++ b/tests/libtest/lib576.c
@@ -19,8 +19,8 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
+
#include "testutil.h"
#include "memdebug.h"
diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c
index 51ead8722..a39b31772 100644
--- a/tests/libtest/lib578.c
+++ b/tests/libtest/lib578.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include "memdebug.h"
diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c
index ad8ba7e97..56193a181 100644
--- a/tests/libtest/lib579.c
+++ b/tests/libtest/lib579.c
@@ -19,7 +19,6 @@
* KIND, either express or implied.
*
***************************************************************************/
-
#include "test.h"
#include "memdebug.h"
diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c
index 3b7f1afee..25b70609c 100644
--- a/tests/libtest/lib582.c
+++ b/tests/libtest/lib582.c
@@ -21,20 +21,19 @@
***************************************************************************/
#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
-#define MAIN_LOOP_HANG_TIMEOUT 4 * 1000
+#define TEST_HANG_TIMEOUT 60 * 1000
struct Sockets
{
- curl_socket_t* sockets;
- int count;
+ curl_socket_t *sockets;
+ int count; /* number of sockets actually stored in array */
+ int max_count; /* max number of sockets that fit in allocated array */
};
struct ReadWriteSockets
@@ -54,8 +53,9 @@ static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
for (i = 0; i < sockets->count; ++i) {
if (sockets->sockets[i] == fd) {
- memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
- sizeof(curl_socket_t) * (sockets->count - i - 1));
+ if (i < sockets->count - 1)
+ memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
+ sizeof(curl_socket_t) * (sockets->count - (i + 1)));
--sockets->count;
}
}
@@ -72,8 +72,29 @@ static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what)
*/
fprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what);
removeFd(sockets, fd, 0);
- sockets->sockets = realloc(sockets->sockets,
- sizeof(curl_socket_t) * (sockets->count + 1));
+ /*
+ * Allocate array storage when required.
+ */
+ if(!sockets->sockets) {
+ sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
+ if(!sockets->sockets)
+ return;
+ sockets->max_count = 20;
+ }
+ else if(sockets->count + 1 > sockets->max_count) {
+ curl_socket_t *oldptr = sockets->sockets;
+ sockets->sockets = realloc(oldptr, sizeof(curl_socket_t) *
+ (sockets->max_count + 20));
+ if(!sockets->sockets) {
+ /* cleanup in test_cleanup */
+ sockets->sockets = oldptr;
+ return;
+ }
+ sockets->max_count += 20;
+ }
+ /*
+ * Add file descriptor to array.
+ */
sockets->sockets[sockets->count] = fd;
++sockets->count;
}
@@ -177,13 +198,12 @@ static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
}
}
-static void notifyCurl(CURL* curl, curl_socket_t s, int evBitmask,
- const char* info)
+static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask,
+ const char *info)
{
int numhandles = 0;
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
- if (result != CURLM_OK && result != CURLM_CALL_MULTI_PERFORM)
- {
+ if (result != CURLM_OK) {
fprintf(stderr, "Curl error on %s: %i (%s)\n",
info, result, curl_multi_strerror(result));
}
@@ -192,14 +212,12 @@ static void notifyCurl(CURL* curl, curl_socket_t s, int evBitmask,
/**
* Invoke curl when a file descriptor is set.
*/
-static void checkFdSet(CURL* curl, struct Sockets* sockets, fd_set* fdset,
- int evBitmask, const char* name)
+static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
+ int evBitmask, const char *name)
{
int i;
- for (i = 0; i < sockets->count; ++i)
- {
- if (FD_ISSET(sockets->sockets[i], fdset))
- {
+ for (i = 0; i < sockets->count; ++i) {
+ if (FD_ISSET(sockets->sockets[i], fdset)) {
notifyCurl(curl, sockets->sockets[i], evBitmask, name);
}
}
@@ -208,30 +226,30 @@ static void checkFdSet(CURL* curl, struct Sockets* sockets, fd_set* fdset,
int test(char *URL)
{
int res = 0;
- CURL *curl;
- FILE *hd_src ;
+ CURL *curl = NULL;
+ FILE *hd_src = NULL;
int hd ;
int error;
struct_stat file_info;
CURLM *m = NULL;
- struct timeval ml_start;
- char ml_timedout = FALSE;
- struct ReadWriteSockets sockets = {{0, 0}, {0, 0}};
+ struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
struct timeval timeout = {-1, 0};
int success = 0;
+ start_test_timing();
+
if (!libtest_arg3) {
fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n");
- return -1;
+ return TEST_ERR_USAGE;
}
hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) {
error = ERRNO;
- fprintf(stderr, "fopen() failed with error: %d %s\n",
+ fprintf(stderr, "fopen() failed with error: %d (%s)\n",
error, strerror(error));
- fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
- return TEST_ERR_MAJOR_BAD;
+ fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
+ return TEST_ERR_FOPEN;
}
/* get the file size of the local file */
@@ -239,71 +257,49 @@ int test(char *URL)
if(hd == -1) {
/* can't open file, bail out */
error = ERRNO;
- fprintf(stderr, "fstat() failed with error: %d %s\n",
+ fprintf(stderr, "fstat() failed with error: %d (%s)\n",
error, strerror(error));
- fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
+ fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
fclose(hd_src);
- return -1;
+ return TEST_ERR_FSTAT;
}
fprintf(stderr, "Set to upload %d bytes\n", (int)file_info.st_size);
- if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
- fprintf(stderr, "curl_global_init() failed\n");
+ res_global_init(CURL_GLOBAL_ALL);
+ if(res) {
fclose(hd_src);
- return TEST_ERR_MAJOR_BAD;
+ return res;
}
- if ((curl = curl_easy_init()) == NULL) {
- fprintf(stderr, "curl_easy_init() failed\n");
- fclose(hd_src);
- curl_global_cleanup();
- return TEST_ERR_MAJOR_BAD;
- }
+ easy_init(curl);
/* enable uploading */
- test_setopt(curl, CURLOPT_UPLOAD, 1L);
+ easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
- test_setopt(curl,CURLOPT_URL, URL);
+ easy_setopt(curl,CURLOPT_URL, URL);
/* go verbose */
- test_setopt(curl, CURLOPT_VERBOSE, 1L);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* now specify which file to upload */
- test_setopt(curl, CURLOPT_READDATA, hd_src);
+ easy_setopt(curl, CURLOPT_READDATA, hd_src);
- test_setopt(curl, CURLOPT_USERPWD, libtest_arg3);
- test_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
- test_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
+ easy_setopt(curl, CURLOPT_USERPWD, libtest_arg3);
+ easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
+ easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
- test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
- (curl_off_t)file_info.st_size);
+ easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
- if ((m = curl_multi_init()) == NULL) {
- fprintf(stderr, "curl_multi_init() failed\n");
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- fclose(hd_src);
- return TEST_ERR_MAJOR_BAD;
- }
- test_multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback);
- test_multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
-
- test_multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
- test_multi_setopt(m, CURLMOPT_TIMERDATA, &timeout);
-
- if ((res = (int)curl_multi_add_handle(m, curl)) != CURLM_OK) {
- fprintf(stderr, "curl_multi_add_handle() failed, "
- "with code %d\n", res);
- curl_multi_cleanup(m);
- curl_easy_cleanup(curl);
- curl_global_cleanup();
- fclose(hd_src);
- return TEST_ERR_MAJOR_BAD;
- }
+ multi_init(m);
+
+ multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback);
+ multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
+
+ multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
+ multi_setopt(m, CURLMOPT_TIMERDATA, &timeout);
- ml_timedout = FALSE;
- ml_start = tutil_tvnow();
+ multi_add_handle(m, curl);
while (!checkForCompletion(m, &success))
{
@@ -311,12 +307,6 @@ int test(char *URL)
curl_socket_t maxFd = 0;
struct timeval tv = {10, 0};
- if (tutil_tvdiff(tutil_tvnow(), ml_start) >
- MAIN_LOOP_HANG_TIMEOUT) {
- ml_timedout = TRUE;
- break;
- }
-
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
updateFdSet(&sockets.read, &readSet, &maxFd);
@@ -345,6 +335,8 @@ int test(char *URL)
/* Curl's timer has elapsed. */
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
}
+
+ abort_on_test_timeout();
}
if (!success)
@@ -352,28 +344,24 @@ int test(char *URL)
fprintf(stderr, "Error uploading file.\n");
res = TEST_ERR_MAJOR_BAD;
}
- else if (ml_timedout) {
- fprintf(stderr, "ABORTING TEST, since it seems "
- "that it would have run forever.\n");
- res = TEST_ERR_RUNS_FOREVER;
- }
test_cleanup:
- if(m)
- curl_multi_remove_handle(m, curl);
+ /* proper cleanup sequence - type PB */
+
+ curl_multi_remove_handle(m, curl);
curl_easy_cleanup(curl);
- if(m) {
- fprintf(stderr, "Now multi-cleanup!\n");
- curl_multi_cleanup(m);
- }
+ curl_multi_cleanup(m);
+ curl_global_cleanup();
+
+ /* close the local file */
+ fclose(hd_src);
- fclose(hd_src); /* close the local file */
- if (sockets.read.sockets != 0)
+ /* free local memory */
+ if(sockets.read.sockets)
free(sockets.read.sockets);
- if (sockets.write.sockets != 0)
+ if(sockets.write.sockets)
free(sockets.write.sockets);
- curl_global_cleanup();
return res;
}
diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c
index f1270e1d3..ad5a5cea7 100644
--- a/tests/libtest/lib583.c
+++ b/tests/libtest/lib583.c
@@ -26,48 +26,59 @@
#include "test.h"
-#include <unistd.h>
#include <sys/stat.h>
+#include "memdebug.h"
+
int test(char *URL)
{
- CURLMcode retVal;
int stillRunning;
- CURLM* multiHandle;
- CURL* curl;
- int res;
+ CURLM* multiHandle = NULL;
+ CURL* curl = NULL;
+ int res = 0;
+
+ global_init(CURL_GLOBAL_ALL);
+
+ multi_init(multiHandle);
+
+ easy_init(curl);
- curl_global_init(CURL_GLOBAL_ALL);
+ easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
+ easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
+ easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
- multiHandle = curl_multi_init();
- curl = curl_easy_init();
+ easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+ easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- test_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
- test_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
- test_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
+ easy_setopt(curl, CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
- curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+ multi_add_handle(multiHandle, curl);
- curl_easy_setopt(curl, CURLOPT_URL, URL);
- curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
+ /* this tests if removing an easy handle immediately after multi
+ perform has been called succeeds or not. */
- curl_multi_add_handle(multiHandle, curl);
- retVal = curl_multi_perform(multiHandle, &stillRunning);
- if (retVal != CURLM_OK)
- fprintf(stderr, "curl_multi_perform() failed!n");
+ fprintf(stderr, "curl_multi_perform()...\n");
- fprintf(stderr, "curl_multi_remove_handle()!\n");
- retVal = curl_multi_remove_handle(multiHandle, curl);
- if (retVal == CURLM_OK)
- fprintf(stderr, "curl_multi_remove_handle() was successful!\n");
+ multi_perform(multiHandle, &stillRunning);
+
+ fprintf(stderr, "curl_multi_perform() succeeded\n");
+
+ fprintf(stderr, "curl_multi_remove_handle()...\n");
+ res = (int) curl_multi_remove_handle(multiHandle, curl);
+ if(res)
+ fprintf(stderr, "curl_multi_remove_handle() failed, "
+ "with code %d\n", res);
else
- fprintf(stderr, "curl_multi_remove_handle() failed\n");
+ fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
test_cleanup:
+ /* undocumented cleanup sequence - type UB */
+
curl_easy_cleanup(curl);
curl_multi_cleanup(multiHandle);
+ curl_global_cleanup();
return res;
}
diff --git a/tests/libtest/lib586.c b/tests/libtest/lib586.c
new file mode 100644
index 000000000..2cf04fe85
--- /dev/null
+++ b/tests/libtest/lib586.c
@@ -0,0 +1,246 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2011, 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 http://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 <curl/mprintf.h>
+
+#include "memdebug.h"
+
+#define THREADS 2
+
+/* struct containing data of a thread */
+struct Tdata {
+ CURLSH *share;
+ char *url;
+};
+
+struct userdata {
+ char *text;
+ int counter;
+};
+
+/* lock callback */
+static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
+ void *useptr )
+{
+ const char *what;
+ struct userdata *user = (struct userdata *)useptr;
+
+ (void)handle;
+ (void)laccess;
+
+ switch ( data ) {
+ case CURL_LOCK_DATA_SHARE:
+ what = "share";
+ break;
+ case CURL_LOCK_DATA_DNS:
+ what = "dns";
+ break;
+ case CURL_LOCK_DATA_COOKIE:
+ what = "cookie";
+ break;
+ case CURL_LOCK_DATA_SSL_SESSION:
+ what = "ssl_session";
+ break;
+ default:
+ fprintf(stderr, "lock: no such data: %d\n", (int)data);
+ return;
+ }
+ printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
+ user->counter++;
+}
+
+/* unlock callback */
+static void my_unlock(CURL *handle, curl_lock_data data, void *useptr )
+{
+ const char *what;
+ struct userdata *user = (struct userdata *)useptr;
+ (void)handle;
+ switch ( data ) {
+ case CURL_LOCK_DATA_SHARE:
+ what = "share";
+ break;
+ case CURL_LOCK_DATA_DNS:
+ what = "dns";
+ break;
+ case CURL_LOCK_DATA_COOKIE:
+ what = "cookie";
+ break;
+ case CURL_LOCK_DATA_SSL_SESSION:
+ what = "ssl_session";
+ break;
+ default:
+ fprintf(stderr, "unlock: no such data: %d\n", (int)data);
+ return;
+ }
+ printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
+ user->counter++;
+}
+
+/* the dummy thread function */
+static void *fire(void *ptr)
+{
+ CURLcode code;
+ struct Tdata *tdata = (struct Tdata*)ptr;
+ CURL *curl;
+ int i=0;
+
+ if ((curl = curl_easy_init()) == NULL) {
+ fprintf(stderr, "curl_easy_init() failed\n");
+ return NULL;
+ }
+
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
+ printf( "CURLOPT_SHARE\n" );
+ curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
+
+ printf( "PERFORM\n" );
+ code = curl_easy_perform(curl);
+ if( code != CURLE_OK ) {
+ fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
+ tdata->url, i, (int)code);
+ }
+
+ printf( "CLEANUP\n" );
+ curl_easy_cleanup(curl);
+
+ return NULL;
+}
+
+/* test function */
+int test(char *URL)
+{
+ int res;
+ CURLSHcode scode = CURLSHE_OK;
+ char *url;
+ struct Tdata tdata;
+ CURL *curl;
+ CURLSH *share;
+ int i;
+ struct userdata user;
+
+ user.text = (char *)"Pigs in space";
+ user.counter = 0;
+
+ printf( "GLOBAL_INIT\n" );
+ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ fprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ /* prepare share */
+ printf( "SHARE_INIT\n" );
+ if ((share = curl_share_init()) == NULL) {
+ fprintf(stderr, "curl_share_init() failed\n");
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ if ( CURLSHE_OK == scode ) {
+ printf( "CURLSHOPT_LOCKFUNC\n" );
+ scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock);
+ }
+ if ( CURLSHE_OK == scode ) {
+ printf( "CURLSHOPT_UNLOCKFUNC\n" );
+ scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock);
+ }
+ if ( CURLSHE_OK == scode ) {
+ printf( "CURLSHOPT_USERDATA\n" );
+ scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
+ }
+ if ( CURLSHE_OK == scode ) {
+ printf( "CURL_LOCK_DATA_SSL_SESSION\n" );
+ scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
+ }
+
+ if ( CURLSHE_OK != scode ) {
+ fprintf(stderr, "curl_share_setopt() failed\n");
+ curl_share_cleanup(share);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+
+ res = 0;
+
+ /* start treads */
+ for (i=1; i<=THREADS; i++ ) {
+
+ /* set thread data */
+ tdata.url = URL;
+ tdata.share = share;
+
+ /* simulate thread, direct call of "thread" function */
+ printf( "*** run %d\n",i );
+ fire( &tdata );
+ }
+
+
+ /* fetch a another one */
+ printf( "*** run %d\n", i );
+ if ((curl = curl_easy_init()) == NULL) {
+ fprintf(stderr, "curl_easy_init() failed\n");
+ curl_share_cleanup(share);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ url = URL;
+ test_setopt( curl, CURLOPT_URL, url );
+ printf( "CURLOPT_SHARE\n" );
+ test_setopt( curl, CURLOPT_SHARE, share );
+
+ printf( "PERFORM\n" );
+ curl_easy_perform( curl );
+
+ /* try to free share, expect to fail because share is in use*/
+ printf( "try SHARE_CLEANUP...\n" );
+ scode = curl_share_cleanup( share );
+ if ( scode==CURLSHE_OK )
+ {
+ fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
+ share = NULL;
+ } else {
+ printf( "SHARE_CLEANUP failed, correct\n" );
+ }
+
+test_cleanup:
+
+ /* clean up last handle */
+ printf( "CLEANUP\n" );
+ curl_easy_cleanup( curl );
+
+ /* free share */
+ printf( "SHARE_CLEANUP\n" );
+ scode = curl_share_cleanup( share );
+ if ( scode!=CURLSHE_OK )
+ fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
+ (int)scode);
+
+ printf( "GLOBAL_CLEANUP\n" );
+ curl_global_cleanup();
+
+ return res;
+}
+
diff --git a/tests/libtest/test.h b/tests/libtest/test.h
index 33d7bed83..81c435d1f 100644
--- a/tests/libtest/test.h
+++ b/tests/libtest/test.h
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <errno.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -51,9 +50,6 @@
# include "select.h"
#endif
-#define TEST_ERR_MAJOR_BAD 100
-#define TEST_ERR_RUNS_FOREVER 99
-
#define test_setopt(A,B,C) \
if((res = curl_easy_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup
@@ -67,8 +63,10 @@ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
extern int test_argc;
extern char **test_argv;
-extern int select_test(int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
- struct timeval *tv);
+extern struct timeval tv_test_start; /* for test timing */
+
+extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
+ struct timeval *tv);
extern int test(char *URL); /* the actual test function provided by each
individual libXXX.c file */
@@ -76,3 +74,331 @@ extern int test(char *URL); /* the actual test function provided by each
#ifdef UNITTESTS
extern int unitfail;
#endif
+
+/*
+** TEST_ERR_* values must be greater than CURL_LAST CURLcode in order
+** to avoid confusion with any CURLcode or CURLMcode. These TEST_ERR_*
+** codes are returned to signal test specific situations and should
+** not get mixed with CURLcode or CURLMcode values.
+**
+** For portability reasons TEST_ERR_* values should be less than 127.
+*/
+
+#define TEST_ERR_MAJOR_BAD 126
+#define TEST_ERR_RUNS_FOREVER 125
+#define TEST_ERR_EASY_INIT 124
+#define TEST_ERR_MULTI_INIT 123
+#define TEST_ERR_NUM_HANDLES 122
+#define TEST_ERR_SELECT 121
+#define TEST_ERR_SUCCESS 120
+#define TEST_ERR_FAILURE 119
+#define TEST_ERR_USAGE 118
+#define TEST_ERR_FOPEN 117
+#define TEST_ERR_FSTAT 116
+
+/*
+** Macros for test source code readability/maintainability.
+**
+** All of the following macros require that an int data type 'res' variable
+** exists in scope where macro is used, and that it has been initialized to
+** zero before the macro is used.
+**
+** exe_* and chk_* macros are helper macros not intended to be used from
+** outside of this header file. Arguments 'Y' and 'Z' of these represent
+** source code file and line number, while Arguments 'A', 'B', etc, are
+** the arguments used to actually call a libcurl function.
+**
+** All easy_* and multi_* macros call a libcurl function and evaluate if
+** the function has succeeded or failed. When the function succeeds 'res'
+** variable is not set nor cleared and program continues normal flow. On
+** the other hand if function fails 'res' variable is set and a jump to
+** label 'test_cleanup' is performed.
+**
+** Every easy_* and multi_* macros have a res_easy_* and res_multi_* macro
+** counterpart that operates in tha same way with the exception that no
+** jump takes place in case of failure. res_easy_* and res_multi_* macros
+** should be immediately followed by checking if 'res' variable has been
+** set.
+**
+** 'res' variable when set will hold a CURLcode, CURLMcode, or any of the
+** TEST_ERR_* values defined above. It is advisable to return this value
+** as test result.
+*/
+
+/* ---------------------------------------------------------------- */
+
+#define exe_easy_init(A,Y,Z) do { \
+ if(((A) = curl_easy_init()) == NULL) { \
+ fprintf(stderr, "%s:%d curl_easy_init() failed\n", (Y), (Z)); \
+ res = TEST_ERR_EASY_INIT; \
+ } \
+} WHILE_FALSE
+
+#define res_easy_init(A) \
+ exe_easy_init((A),(__FILE__),(__LINE__))
+
+#define chk_easy_init(A,Y,Z) do { \
+ exe_easy_init((A),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define easy_init(A) \
+ chk_easy_init((A),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_multi_init(A,Y,Z) do { \
+ if(((A) = curl_multi_init()) == NULL) { \
+ fprintf(stderr, "%s:%d curl_multi_init() failed\n", (Y), (Z)); \
+ res = TEST_ERR_MULTI_INIT; \
+ } \
+} WHILE_FALSE
+
+#define res_multi_init(A) \
+ exe_multi_init((A),(__FILE__),(__LINE__))
+
+#define chk_multi_init(A,Y,Z) do { \
+ exe_multi_init((A),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define multi_init(A) \
+ chk_multi_init((A),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_easy_setopt(A,B,C,Y,Z) do { \
+ CURLcode ec; \
+ if((ec = curl_easy_setopt((A),(B),(C))) != CURLE_OK) { \
+ fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_easy_strerror(ec)); \
+ res = (int)ec; \
+ } \
+} WHILE_FALSE
+
+#define res_easy_setopt(A,B,C) \
+ exe_easy_setopt((A),(B),(C),(__FILE__),(__LINE__))
+
+#define chk_easy_setopt(A,B,C,Y,Z) do { \
+ exe_easy_setopt((A),(B),(C),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define easy_setopt(A,B,C) \
+ chk_easy_setopt((A),(B),(C),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_multi_setopt(A,B,C,Y,Z) do { \
+ CURLMcode ec; \
+ if((ec = curl_multi_setopt((A),(B),(C))) != CURLM_OK) { \
+ fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
+ res = (int)ec; \
+ } \
+} WHILE_FALSE
+
+#define res_multi_setopt(A,B,C) \
+ exe_multi_setopt((A),(B),(C),(__FILE__),(__LINE__))
+
+#define chk_multi_setopt(A,B,C,Y,Z) do { \
+ exe_multi_setopt((A),(B),(C),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define multi_setopt(A,B,C) \
+ chk_multi_setopt((A),(B),(C),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_multi_add_handle(A,B,Y,Z) do { \
+ CURLMcode ec; \
+ if((ec = curl_multi_add_handle((A),(B))) != CURLM_OK) { \
+ fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
+ res = (int)ec; \
+ } \
+} WHILE_FALSE
+
+#define res_multi_add_handle(A,B) \
+ exe_multi_add_handle((A),(B),(__FILE__),(__LINE__))
+
+#define chk_multi_add_handle(A,B,Y,Z) do { \
+ exe_multi_add_handle((A),(B),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define multi_add_handle(A,B) \
+ chk_multi_add_handle((A),(B),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_multi_perform(A,B,Y,Z) do { \
+ CURLMcode ec; \
+ if((ec = curl_multi_perform((A),(B))) != CURLM_OK) { \
+ fprintf(stderr, "%s:%d curl_multi_perform() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
+ res = (int)ec; \
+ } \
+ else if(*((B)) < 0) { \
+ fprintf(stderr, "%s:%d curl_multi_perform() succeeded, " \
+ "but returned invalid running_handles value (%d)\n", \
+ (Y), (Z), (int)*((B))); \
+ res = TEST_ERR_NUM_HANDLES; \
+ } \
+} WHILE_FALSE
+
+#define res_multi_perform(A,B) \
+ exe_multi_perform((A),(B),(__FILE__),(__LINE__))
+
+#define chk_multi_perform(A,B,Y,Z) do { \
+ exe_multi_perform((A),(B),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define multi_perform(A,B) \
+ chk_multi_perform((A),(B),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_multi_fdset(A,B,C,D,E,Y,Z) do { \
+ CURLMcode ec; \
+ if((ec = curl_multi_fdset((A),(B),(C),(D),(E))) != CURLM_OK) { \
+ fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
+ res = (int)ec; \
+ } \
+ else if(*((E)) < -1) { \
+ fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \
+ "but returned invalid max_fd value (%d)\n", \
+ (Y), (Z), (int)*((E))); \
+ res = TEST_ERR_NUM_HANDLES; \
+ } \
+} WHILE_FALSE
+
+#define res_multi_fdset(A,B,C,D,E) \
+ exe_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
+
+#define chk_multi_fdset(A,B,C,D,E,Y,Z) do { \
+ exe_multi_fdset((A),(B),(C),(D),(E),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define multi_fdset(A,B,C,D,E) \
+ chk_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_multi_timeout(A,B,Y,Z) do { \
+ CURLMcode ec; \
+ if((ec = curl_multi_timeout((A),(B))) != CURLM_OK) { \
+ fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
+ res = (int)ec; \
+ } \
+} WHILE_FALSE
+
+#define res_multi_timeout(A,B) \
+ exe_multi_timeout((A),(B),(__FILE__),(__LINE__))
+
+#define chk_multi_timeout(A,B,Y,Z) do { \
+ exe_multi_timeout((A),(B),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define multi_timeout(A,B) \
+ chk_multi_timeout((A),(B),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_select_test(A,B,C,D,E,Y,Z) do { \
+ int ec; \
+ if(select_wrapper((A),(B),(C),(D),(E)) == -1 ) { \
+ ec = SOCKERRNO; \
+ fprintf(stderr, "%s:%d select() failed, with " \
+ "errno %d (%s)\n", \
+ (Y), (Z), ec, strerror(ec)); \
+ res = TEST_ERR_SELECT; \
+ } \
+} WHILE_FALSE
+
+#define res_select_test(A,B,C,D,E) \
+ exe_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
+
+#define chk_select_test(A,B,C,D,E,Y,Z) do { \
+ exe_select_test((A),(B),(C),(D),(E),(Y),(Z)); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define select_test(A,B,C,D,E) \
+ chk_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define start_test_timing() do { \
+ tv_test_start = tutil_tvnow(); \
+} WHILE_FALSE
+
+#define exe_test_timedout(Y,Z) do { \
+ if(tutil_tvdiff(tutil_tvnow(), tv_test_start) > TEST_HANG_TIMEOUT) { \
+ fprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
+ "that it would have run forever.\n", (Y), (Z)); \
+ res = TEST_ERR_RUNS_FOREVER; \
+ } \
+} WHILE_FALSE
+
+#define res_test_timedout() \
+ exe_test_timedout((__FILE__),(__LINE__))
+
+#define chk_test_timedout(Y,Z) do { \
+ exe_test_timedout(Y,Z); \
+ if(res) \
+ goto test_cleanup; \
+} WHILE_FALSE
+
+#define abort_on_test_timeout() \
+ chk_test_timedout((__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
+
+#define exe_global_init(A,Y,Z) do { \
+ CURLcode ec; \
+ if((ec = curl_global_init((A))) != CURLE_OK) { \
+ fprintf(stderr, "%s:%d curl_global_init() failed, " \
+ "with code %d (%s)\n", \
+ (Y), (Z), (int)ec, curl_easy_strerror(ec)); \
+ res = (int)ec; \
+ } \
+} WHILE_FALSE
+
+#define res_global_init(A) \
+ exe_global_init((A),(__FILE__),(__LINE__))
+
+#define chk_global_init(A,Y,Z) do { \
+ exe_global_init((A),(Y),(Z)); \
+ if(res) \
+ return res; \
+} WHILE_FALSE
+
+/* global_init() is different than other macros. In case of
+ failure it 'return's instead of going to 'test_cleanup'. */
+
+#define global_init(A) \
+ chk_global_init((A),(__FILE__),(__LINE__))
+
+/* ---------------------------------------------------------------- */
diff --git a/tests/memanalyze.pl b/tests/memanalyze.pl
index 2650590a6..bf5393365 100755
--- a/tests/memanalyze.pl
+++ b/tests/memanalyze.pl
@@ -236,6 +236,14 @@ while(<FILE>) {
$getfile{$1}="$source:$linenum";
$openfile++;
}
+ elsif($function =~ /socketpair\(\) = (\d*) (\d*)/) {
+ $filedes{$1}=1;
+ $getfile{$1}="$source:$linenum";
+ $openfile++;
+ $filedes{$2}=1;
+ $getfile{$2}="$source:$linenum";
+ $openfile++;
+ }
elsif($function =~ /accept\(\) = (\d*)/) {
$filedes{$1}=1;
$getfile{$1}="$source:$linenum";
diff --git a/tests/runtests.pl b/tests/runtests.pl
index a498963d0..964e3b800 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -100,7 +100,7 @@ use sshhelp qw(
find_sshd
find_ssh
find_sftp
- find_gnutls_serv
+ find_httptlssrv
sshversioninfo
);
@@ -115,28 +115,29 @@ my $CLIENT6IP="[::1]"; # address which curl uses for incoming connections
my $base = 8990; # base port number
-my $HTTPPORT; # HTTP server port
-my $HTTP6PORT; # HTTP IPv6 server port
-my $HTTPSPORT; # HTTPS server port
-my $FTPPORT; # FTP server port
-my $FTP2PORT; # FTP server 2 port
-my $FTPSPORT; # FTPS server port
-my $FTP6PORT; # FTP IPv6 server port
-my $TFTPPORT; # TFTP
-my $TFTP6PORT; # TFTP
-my $SSHPORT; # SCP/SFTP
-my $SOCKSPORT; # SOCKS4/5 port
-my $POP3PORT; # POP3
-my $POP36PORT; # POP3 IPv6 server port
-my $IMAPPORT; # IMAP
-my $IMAP6PORT; # IMAP IPv6 server port
-my $SMTPPORT; # SMTP
-my $SMTP6PORT; # SMTP IPv6 server port
-my $RTSPPORT; # RTSP
-my $RTSP6PORT; # RTSP IPv6 server port
-my $GOPHERPORT; # Gopher
-my $GOPHER6PORT; # Gopher IPv6 server port
-my $HTTPTLSSRPPORT; # TLS-SRP HTTP port
+my $HTTPPORT; # HTTP server port
+my $HTTP6PORT; # HTTP IPv6 server port
+my $HTTPSPORT; # HTTPS (stunnel) server port
+my $FTPPORT; # FTP server port
+my $FTP2PORT; # FTP server 2 port
+my $FTPSPORT; # FTPS (stunnel) server port
+my $FTP6PORT; # FTP IPv6 server port
+my $TFTPPORT; # TFTP
+my $TFTP6PORT; # TFTP
+my $SSHPORT; # SCP/SFTP
+my $SOCKSPORT; # SOCKS4/5 port
+my $POP3PORT; # POP3
+my $POP36PORT; # POP3 IPv6 server port
+my $IMAPPORT; # IMAP
+my $IMAP6PORT; # IMAP IPv6 server port
+my $SMTPPORT; # SMTP
+my $SMTP6PORT; # SMTP IPv6 server port
+my $RTSPPORT; # RTSP
+my $RTSP6PORT; # RTSP IPv6 server port
+my $GOPHERPORT; # Gopher
+my $GOPHER6PORT; # Gopher IPv6 server port
+my $HTTPTLSPORT; # HTTP TLS (non-stunnel) server port
+my $HTTPTLS6PORT; # HTTP TLS (non-stunnel) IPv6 server port
my $srcdir = $ENV{'srcdir'} || '.';
my $CURL="../src/curl".exe_ext(); # what curl executable to run on the tests
@@ -191,6 +192,7 @@ my $valgrind = checktestcmd("valgrind");
my $valgrind_logfile="--logfile";
my $valgrind_tool;
my $gdb = checktestcmd("gdb");
+my $httptlssrv = find_httptlssrv();
my $ssl_version; # set if libcurl is built with SSL support
my $large_file; # set if libcurl is built with large file support
@@ -203,6 +205,7 @@ my $has_ipv6; # set if libcurl is built with IPv6 support
my $has_libz; # set if libcurl is built with libz support
my $has_getrlimit; # set if system has getrlimit()
my $has_ntlm; # set if libcurl is built with NTLM support
+my $has_ntlm_wb; # set if libcurl is built with NTLM delegation to winbind
my $has_charconv;# set if libcurl is built with CharConv support
my $has_tls_srp; # set if libcurl is built with TLS-SRP support
@@ -219,7 +222,8 @@ my $ssllib; # name of the lib we use (for human presentation)
my $has_crypto; # set if libcurl is built with cryptographic support
my $has_textaware; # set if running on a system that has a text mode concept
# on files. Windows for example
-my @protocols; # array of supported protocols
+
+my @protocols; # array of lowercase supported protocol servers
my $skipped=0; # number of tests skipped; reported in main loop
my %skipped; # skipped{reason}=counter, reasons for skip
@@ -258,6 +262,7 @@ my $verbose;
my $debugprotocol;
my $anyway;
my $gdbthis; # run test case with gdb debugger
+my $gdbxwin; # use windowed gdb when using gdb
my $keepoutfiles; # keep stdout and stderr files after tests
my $listonly; # only list the tests
my $postmortem; # display detailed info about failed tests
@@ -308,7 +313,7 @@ $SIG{TERM} = \&catch_zap;
# to prevent them to interfere with our testing!
my $protocol;
-foreach $protocol (('ftp', 'http', 'ftps', 'https', 'no')) {
+foreach $protocol (('ftp', 'http', 'ftps', 'https', 'no', 'all')) {
my $proxy = "${protocol}_proxy";
# clear lowercase version
delete $ENV{$proxy} if($ENV{$proxy});
@@ -338,7 +343,7 @@ sub init_serverpidfile_hash {
}
}
}
- for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'gopher', 'http+tls-srp')) {
+ for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'gopher', 'httptls')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2)) {
my $serv = servername_id($proto, $ipvnum, $idnum);
@@ -391,7 +396,7 @@ sub startnew {
die "error: exec() has returned";
}
- # Ugly hack but ssh client doesn't support pid files
+ # Ugly hack but ssh client and gnutls-serv don't support pid files
if ($fake) {
if(open(OUT, ">$pidfile")) {
print OUT $child . "\n";
@@ -630,20 +635,20 @@ sub stopserver {
# All servers relative to the given one must be stopped also
#
my @killservers;
- if($server =~ /^(ftp|http|imap|pop3|smtp)s(.*)$/) {
- # given an ssl server, also kill non-ssl underlying one
+ if($server =~ /^(ftp|http|imap|pop3|smtp)s((\d*)(-ipv6|))$/) {
+ # given a stunnel based ssl server, also kill non-ssl underlying one
push @killservers, "${1}${2}";
}
- elsif($server =~ /^(ftp|http|imap|pop3|smtp)(.*)$/) {
- # given a non-ssl server, also kill ssl piggybacking one
+ elsif($server =~ /^(ftp|http|imap|pop3|smtp)((\d*)(-ipv6|))$/) {
+ # given a non-ssl server, also kill stunnel based ssl piggybacking one
push @killservers, "${1}s${2}";
}
- elsif($server =~ /^(socks)(.*)$/) {
- # given an socks server, also kill ssh underlying one
+ elsif($server =~ /^(socks)((\d*)(-ipv6|))$/) {
+ # given a socks server, also kill ssh underlying one
push @killservers, "ssh${2}";
}
- elsif($server =~ /^(ssh)(.*)$/) {
- # given an ssh server, also kill socks piggybacking one
+ elsif($server =~ /^(ssh)((\d*)(-ipv6|))$/) {
+ # given a ssh server, also kill socks piggybacking one
push @killservers, "socks${2}";
}
push @killservers, $server;
@@ -652,8 +657,7 @@ sub stopserver {
#
foreach my $server (@killservers) {
if($run{$server}) {
- # we must prepend a space since $pidlist may already contain
- # a pid
+ # we must prepend a space since $pidlist may already contain a pid
$pidlist .= " $run{$server}";
$run{$server} = 0;
}
@@ -678,8 +682,8 @@ sub stopserver {
# Verify that the server that runs on $ip, $port is our server. This also
# implies that we can speak with it, as there might be occasions when the
# server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't
-# assign requested address" #
-
+# assign requested address")
+#
sub verifyhttp {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
@@ -758,8 +762,8 @@ sub verifyhttp {
# Verify that the server that runs on $ip, $port is our server. This also
# implies that we can speak with it, as there might be occasions when the
# server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't
-# assign requested address" #
-
+# assign requested address")
+#
sub verifyftp {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
@@ -830,8 +834,8 @@ sub verifyftp {
# Verify that the server that runs on $ip, $port is our server. This also
# implies that we can speak with it, as there might be occasions when the
# server runs fine but we cannot talk to it ("Failed to connect to ::1: Can't
-# assign requested address" #
-
+# assign requested address")
+#
sub verifyrtsp {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
@@ -903,7 +907,7 @@ sub verifyrtsp {
# Verify that the ssh server has written out its pidfile, recovering
# the pid from the file and returning it if a process with that pid is
# actually alive.
-
+#
sub verifyssh {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
@@ -929,7 +933,7 @@ sub verifyssh {
#######################################################################
# Verify that we can connect to the sftp server, properly authenticate
# with generated config and key files and run a simple remote pwd.
-
+#
sub verifysftp {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
@@ -964,17 +968,16 @@ sub verifysftp {
}
#######################################################################
-# Verify that the TLS-SRP HTTP server that runs on $ip, $port is our server.
-# This also implies that we can speak with it, as there might be occasions when
-# the server runs fine but we cannot talk to it ("Failed to connect to ::1:
-# Can't assign requested address" #
-
-sub verifyhttptlssrp {
+# Verify that the non-stunnel HTTP TLS extensions capable server that runs
+# on $ip, $port is our server. This also implies that we can speak with it,
+# as there might be occasions when the server runs fine but we cannot talk
+# to it ("Failed to connect to ::1: Can't assign requested address")
+#
+sub verifyhttptls {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
my $pidfile = server_pidfilename($proto, $ipvnum, $idnum);
my $pid = 0;
- my $bonus="";
my $verifyout = "$LOGDIR/".
servername_canon($proto, $ipvnum, $idnum) .'_verify.out';
@@ -989,7 +992,9 @@ sub verifyhttptlssrp {
$flags .= "--verbose ";
$flags .= "--globoff ";
$flags .= "--insecure ";
- $flags .= "--tlsauthtype SRP --tlsuser jsmith --tlspassword abc ";
+ $flags .= "--tlsauthtype SRP ";
+ $flags .= "--tlsuser jsmith ";
+ $flags .= "--tlspassword abc ";
$flags .= "\"https://$ip:$port/verifiedserver\"";
my $cmd = "$VCURL $flags 2>$verifylog";
@@ -1025,6 +1030,16 @@ sub verifyhttptlssrp {
if($data && ($data =~ /GNUTLS/) && open(FILE, "<$pidfile")) {
$pid=0+<FILE>;
close(FILE);
+ if($pid > 0) {
+ # if we have a pid it is actually our httptls server,
+ # since runhttptlsserver() unlinks previous pidfile
+ if(!kill(0, $pid)) {
+ logmsg "RUN: $server server has died after starting up\n";
+ checkdied($pid);
+ unlink($pidfile);
+ $pid = -1;
+ }
+ }
return $pid;
}
elsif($res == 6) {
@@ -1041,7 +1056,7 @@ sub verifyhttptlssrp {
#######################################################################
# STUB for verifying socks
-
+#
sub verifysocks {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
@@ -1070,6 +1085,11 @@ sub verifysocks {
# particular can take a long time to start if it needs to generate
# keys on a slow or loaded host.
#
+# Just for convenience, test harness uses 'https' and 'httptls' literals
+# as values for 'proto' variable in order to differentiate different
+# servers. 'https' literal is used for stunnel based https test servers,
+# and 'httptls' is used for non-stunnel https test servers.
+#
my %protofunc = ('http' => \&verifyhttp,
'https' => \&verifyhttp,
@@ -1083,7 +1103,7 @@ my %protofunc = ('http' => \&verifyhttp,
'ssh' => \&verifyssh,
'socks' => \&verifysocks,
'gopher' => \&verifyhttp,
- 'http+tls-srp' => \&verifyhttptlssrp);
+ 'httptls' => \&verifyhttptls);
sub verifyserver {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
@@ -1124,7 +1144,6 @@ sub runhttpserver {
my $logfile;
my $flags = "";
-
if($ipv6) {
# if IPv6, use a different setup
$ipvnum = 6;
@@ -1191,7 +1210,7 @@ sub runhttpserver {
}
#######################################################################
-# start the https server (or rather, tunnel)
+# start the https stunnel based server
#
sub runhttpsserver {
my ($verbose, $ipv6, $certfile) = @_;
@@ -1274,14 +1293,14 @@ sub runhttpsserver {
}
#######################################################################
-# start the TLS-SRP HTTP server
+# start the non-stunnel HTTP TLS extensions capable server
#
-sub runhttptlssrpserver {
- my ($verbose) = @_;
- my $proto = "http+tls-srp";
- my $ip = $HOSTIP;
- my $port = $HTTPTLSSRPPORT;
- my $ipvnum = 4;
+sub runhttptlsserver {
+ my ($verbose, $ipv6) = @_;
+ my $proto = "httptls";
+ my $port = ($ipv6 && ($ipv6 =~ /6$/)) ? $HTTPTLS6PORT : $HTTPTLSPORT;
+ my $ip = ($ipv6 && ($ipv6 =~ /6$/)) ? "$HOST6IP" : "$HOSTIP";
+ my $ipvnum = ($ipv6 && ($ipv6 =~ /6$/)) ? 6 : 4;
my $idnum = 1;
my $server;
my $srvrname;
@@ -1289,6 +1308,10 @@ sub runhttptlssrpserver {
my $logfile;
my $flags = "";
+ if(!$httptlssrv) {
+ return (0,0);
+ }
+
$server = servername_id($proto, $ipvnum, $idnum);
$pidfile = $serverpidfile{$server};
@@ -1308,23 +1331,16 @@ sub runhttptlssrpserver {
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
- $flags .= "--fork " if($forkserver);
$flags .= "--http ";
- $flags .= "-d 1 " if($debugprotocol);
+ $flags .= "--debug 1 " if($debugprotocol);
$flags .= "--port $port ";
- $flags .= "--srppasswd certs/srp-verifier-db --srppasswdconf certs/srp-verifier-conf ";
- $flags .=" >log/gnutls.out 2>&1";
+ $flags .= "--srppasswd certs/srp-verifier-db ";
+ $flags .= "--srppasswdconf certs/srp-verifier-conf";
- # Find gnutls-serv
- my $gnutlsserv = find_gnutls_serv();
- if(!$gnutlsserv) {
- logmsg "RUN: cannot find gnutls-serv\n";
- return (0,0);
- }
- my $cmd = "$gnutlsserv $flags";
- my ($httptlssrppid, $pid2) = startnew($cmd, $pidfile, 1, 1);
+ my $cmd = "$httptlssrv $flags > $logfile 2>&1";
+ my ($httptlspid, $pid2) = startnew($cmd, $pidfile, 10, 1); # fake pidfile
- if($httptlssrppid <= 0 || !kill(0, $httptlssrppid)) {
+ if($httptlspid <= 0 || !kill(0, $httptlspid)) {
# it is NOT alive
logmsg "RUN: failed to start the $srvrname server\n";
stopserver($server, "$pid2");
@@ -1333,12 +1349,12 @@ sub runhttptlssrpserver {
return (0,0);
}
- # Server is up. Verify that we can speak to it.
+ # Server is up. Verify that we can speak to it. PID is from fake pidfile
my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
if(!$pid3) {
logmsg "RUN: $srvrname server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
- stopserver($server, "$httptlssrppid $pid2");
+ stopserver($server, "$httptlspid $pid2");
displaylogs($testnumcheck);
$doesntrun{$pidfile} = 1;
return (0,0);
@@ -1346,12 +1362,12 @@ sub runhttptlssrpserver {
$pid2 = $pid3;
if($verbose) {
- logmsg "RUN: $srvrname server is now running PID $httptlssrppid\n";
+ logmsg "RUN: $srvrname server is now running PID $httptlspid\n";
}
sleep(1);
- return ($httptlssrppid, $pid2);
+ return ($httptlspid, $pid2);
}
#######################################################################
@@ -1901,7 +1917,7 @@ sub runsocksserver {
# start our socks server
my $cmd="$ssh -N -F $sshconfig $ip > $sshlog 2>&1";
- my ($sshpid, $pid2) = startnew($cmd, $pidfile, 30, 1);
+ my ($sshpid, $pid2) = startnew($cmd, $pidfile, 30, 1); # fake pidfile
if($sshpid <= 0 || !kill(0, $sshpid)) {
# it is NOT alive
@@ -1915,7 +1931,7 @@ sub runsocksserver {
return (0,0);
}
- # Ugly hack but ssh doesn't support pid files
+ # Ugly hack but ssh doesn't support pid files. PID is from fake pidfile.
my $pid3 = verifyserver($proto, $ipvnum, $idnum, $ip, $port);
if(!$pid3) {
logmsg "RUN: $srvrname server failed verification\n";
@@ -1984,7 +2000,6 @@ sub filteroff {
# compare test results with the expected output, we might filter off
# some pattern that is allowed to differ, output test results
#
-
sub compare {
# filter off patterns _before_ this comparison!
my ($subject, $firstref, $secondref)=@_;
@@ -2116,29 +2131,22 @@ sub checksystem {
$has_openssl=1;
$ssllib="polarssl";
}
- elsif ($libcurl =~ /axtls/i) {
- $has_axtls=1;
- $ssllib="axTLS";
- }
+ elsif ($libcurl =~ /axtls/i) {
+ $has_axtls=1;
+ $ssllib="axTLS";
+ }
}
elsif($_ =~ /^Protocols: (.*)/i) {
# these are the protocols compiled in to this libcurl
- @protocols = split(' ', $1);
+ @protocols = split(' ', lc($1));
# Generate a "proto-ipv6" version of each protocol to match the
# IPv6 <server> name. This works even if IPv6 support isn't
# compiled in because the <features> test will fail.
- push @protocols, map($_ . "-ipv6", @protocols);
-
- # Hack - we need a different, non-stunnel server to test HTTP
- # TLS-SRP, but we don't want to add HTTP+TLS-SRP as a protocol
- # throughout curl
- if ($has_gnutls) {
- push @protocols, ('http+tls-srp');
- }
+ push @protocols, map($_ . '-ipv6', @protocols);
# 'none' is used in test cases to mean no server
- push @protocols, ('none');
+ push @protocols, 'none';
}
elsif($_ =~ /^Features: (.*)/i) {
$feat = $1;
@@ -2172,6 +2180,10 @@ sub checksystem {
# NTLM enabled
$has_ntlm=1;
}
+ if($feat =~ /NTLM_WB/i) {
+ # NTLM delegation to winbind daemon ntlm_auth helper enabled
+ $has_ntlm_wb=1;
+ }
if($feat =~ /CharConv/i) {
# CharConv enabled
$has_charconv=1;
@@ -2181,6 +2193,27 @@ sub checksystem {
$has_tls_srp=1;
}
}
+ #
+ # Test harness currently uses a non-stunnel server in order to
+ # run HTTP TLS-SRP tests required when curl is built with https
+ # protocol support and TLS-SRP feature enabled. For convenience
+ # 'httptls' may be included in the test harness protocols array
+ # to differentiate this from classic stunnel based 'https' test
+ # harness server.
+ #
+ if($has_tls_srp) {
+ my $add_httptls;
+ for(@protocols) {
+ if($_ =~ /^https(-ipv6|)$/) {
+ $add_httptls=1;
+ last;
+ }
+ }
+ if($add_httptls && (! grep /^httptls$/, @protocols)) {
+ push @protocols, 'httptls';
+ push @protocols, 'httptls-ipv6';
+ }
+ }
}
if(!$curl) {
logmsg "unable to get curl's version, further details are:\n";
@@ -2302,6 +2335,13 @@ sub checksystem {
logmsg sprintf("IMAP-IPv6/%d ", $IMAP6PORT);
logmsg sprintf("SMTP-IPv6/%d\n", $SMTP6PORT);
}
+ if($httptlssrv) {
+ logmsg sprintf("* HTTPTLS/%d ", $HTTPTLSPORT);
+ if($has_ipv6) {
+ logmsg sprintf("HTTPTLS-IPv6/%d ", $HTTPTLS6PORT);
+ }
+ logmsg "\n";
+ }
$has_textaware = ($^O eq 'MSWin32') || ($^O eq 'msys');
@@ -2314,36 +2354,57 @@ sub checksystem {
#
sub subVariables {
my ($thing) = @_;
- $$thing =~ s/%HOSTIP/$HOSTIP/g;
- $$thing =~ s/%HTTPPORT/$HTTPPORT/g;
- $$thing =~ s/%HOST6IP/$HOST6IP/g;
- $$thing =~ s/%HTTP6PORT/$HTTP6PORT/g;
- $$thing =~ s/%HTTPSPORT/$HTTPSPORT/g;
- $$thing =~ s/%FTPPORT/$FTPPORT/g;
+
+ # ports
+
$$thing =~ s/%FTP6PORT/$FTP6PORT/g;
$$thing =~ s/%FTP2PORT/$FTP2PORT/g;
$$thing =~ s/%FTPSPORT/$FTPSPORT/g;
- $$thing =~ s/%SRCDIR/$srcdir/g;
- $$thing =~ s/%PWD/$pwd/g;
- $$thing =~ s/%TFTPPORT/$TFTPPORT/g;
- $$thing =~ s/%TFTP6PORT/$TFTP6PORT/g;
- $$thing =~ s/%SSHPORT/$SSHPORT/g;
- $$thing =~ s/%SOCKSPORT/$SOCKSPORT/g;
- $$thing =~ s/%POP3PORT/$POP3PORT/g;
- $$thing =~ s/%POP36PORT/$POP36PORT/g;
- $$thing =~ s/%IMAPPORT/$IMAPPORT/g;
+ $$thing =~ s/%FTPPORT/$FTPPORT/g;
+
+ $$thing =~ s/%GOPHER6PORT/$GOPHER6PORT/g;
+ $$thing =~ s/%GOPHERPORT/$GOPHERPORT/g;
+
+ $$thing =~ s/%HTTPTLS6PORT/$HTTPTLS6PORT/g;
+ $$thing =~ s/%HTTPTLSPORT/$HTTPTLSPORT/g;
+ $$thing =~ s/%HTTP6PORT/$HTTP6PORT/g;
+ $$thing =~ s/%HTTPSPORT/$HTTPSPORT/g;
+ $$thing =~ s/%HTTPPORT/$HTTPPORT/g;
+
$$thing =~ s/%IMAP6PORT/$IMAP6PORT/g;
- $$thing =~ s/%SMTPPORT/$SMTPPORT/g;
+ $$thing =~ s/%IMAPPORT/$IMAPPORT/g;
+
+ $$thing =~ s/%POP36PORT/$POP36PORT/g;
+ $$thing =~ s/%POP3PORT/$POP3PORT/g;
+
+ $$thing =~ s/%RTSP6PORT/$RTSP6PORT/g;
+ $$thing =~ s/%RTSPPORT/$RTSPPORT/g;
+
$$thing =~ s/%SMTP6PORT/$SMTP6PORT/g;
+ $$thing =~ s/%SMTPPORT/$SMTPPORT/g;
+
+ $$thing =~ s/%SOCKSPORT/$SOCKSPORT/g;
+ $$thing =~ s/%SSHPORT/$SSHPORT/g;
+
+ $$thing =~ s/%TFTP6PORT/$TFTP6PORT/g;
+ $$thing =~ s/%TFTPPORT/$TFTPPORT/g;
+
+ # client IP addresses
+
+ $$thing =~ s/%CLIENT6IP/$CLIENT6IP/g;
+ $$thing =~ s/%CLIENTIP/$CLIENTIP/g;
+
+ # server IP addresses
+
+ $$thing =~ s/%HOST6IP/$HOST6IP/g;
+ $$thing =~ s/%HOSTIP/$HOSTIP/g;
+
+ # misc
+
$$thing =~ s/%CURL/$CURL/g;
+ $$thing =~ s/%PWD/$pwd/g;
+ $$thing =~ s/%SRCDIR/$srcdir/g;
$$thing =~ s/%USER/$USER/g;
- $$thing =~ s/%CLIENTIP/$CLIENTIP/g;
- $$thing =~ s/%CLIENT6IP/$CLIENT6IP/g;
- $$thing =~ s/%RTSPPORT/$RTSPPORT/g;
- $$thing =~ s/%RTSP6PORT/$RTSP6PORT/g;
- $$thing =~ s/%GOPHERPORT/$GOPHERPORT/g;
- $$thing =~ s/%GOPHER6PORT/$GOPHER6PORT/g;
- $$thing =~ s/%HTTPTLSSRPPORT/$HTTPTLSSRPPORT/g;
# The purpose of FTPTIME2 and FTPTIME3 is to provide times that can be
# used for time-out tests and that whould work on most hosts as these
@@ -2490,6 +2551,11 @@ sub singletest {
next;
}
}
+ elsif($f eq "debug") {
+ if($debug_build) {
+ next;
+ }
+ }
elsif($f eq "large_file") {
if($large_file) {
next;
@@ -2515,6 +2581,11 @@ sub singletest {
next;
}
}
+ elsif($f eq "NTLM_WB") {
+ if($has_ntlm_wb) {
+ next;
+ }
+ }
elsif($f eq "getrlimit") {
if($has_getrlimit) {
next;
@@ -2534,7 +2605,7 @@ sub singletest {
next;
}
# See if this "feature" is in the list of supported protocols
- elsif (grep /^$f$/, @protocols) {
+ elsif (grep /^\Q$f\E$/i, @protocols) {
next;
}
@@ -2809,8 +2880,14 @@ sub singletest {
}
elsif(!$tool) {
# run curl, add --verbose for debug information output
- $cmd = "-1 ".$cmd if(exists $feature{"SSL"} && ($has_axtls));
- $cmdargs ="$out --include --verbose --trace-time $cmd";
+ $cmd = "-1 ".$cmd if(exists $feature{"SSL"} && ($has_axtls));
+
+ my $inc="";
+ if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-include/)) {
+ $inc = "--include ";
+ }
+
+ $cmdargs ="$out $inc--verbose --trace-time $cmd";
}
else {
$cmdargs = " $cmd"; # $cmd is the command line for the test file
@@ -2904,7 +2981,8 @@ sub singletest {
"$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd");
}
elsif($gdbthis) {
- runclient("$gdb --directory libtest $DBGCURL -x $LOGDIR/gdbcmd");
+ my $GDBW = ($gdbxwin) ? "-w" : "";
+ runclient("$gdb --directory libtest $DBGCURL $GDBW -x $LOGDIR/gdbcmd");
$cmdres=0; # makes it always continue after a debugged run
}
else {
@@ -2964,6 +3042,10 @@ sub singletest {
# Test harness ssh server does not have this synchronization mechanism,
# this implies that some ssh server based tests might need a small delay
# once that the client command has run to avoid false test failures.
+ #
+ # gnutls-serv also lacks this synchronization mechanism, so gnutls-serv
+ # based tests might need a small delay once that the client command has
+ # run to avoid false test failures.
sleep($postcommanddelay) if($postcommanddelay);
@@ -2981,20 +3063,20 @@ sub singletest {
my @killservers;
foreach my $server (@killtestservers) {
chomp $server;
- if($server =~ /^(ftp|http|imap|pop3|smtp)s(.*)$/) {
- # given an ssl server, also kill non-ssl underlying one
+ if($server =~ /^(ftp|http|imap|pop3|smtp)s((\d*)(-ipv6|))$/) {
+ # given a stunnel ssl server, also kill non-ssl underlying one
push @killservers, "${1}${2}";
}
- elsif($server =~ /^(ftp|http|imap|pop3|smtp)(.*)$/) {
- # given a non-ssl server, also kill ssl piggybacking one
+ elsif($server =~ /^(ftp|http|imap|pop3|smtp)((\d*)(-ipv6|))$/) {
+ # given a non-ssl server, also kill stunnel piggybacking one
push @killservers, "${1}s${2}";
}
- elsif($server =~ /^(socks)(.*)$/) {
- # given an socks server, also kill ssh underlying one
+ elsif($server =~ /^(socks)((\d*)(-ipv6|))$/) {
+ # given a socks server, also kill ssh underlying one
push @killservers, "ssh${2}";
}
- elsif($server =~ /^(ssh)(.*)$/) {
- # given an ssh server, also kill socks piggybacking one
+ elsif($server =~ /^(ssh)((\d*)(-ipv6|))$/) {
+ # given a ssh server, also kill socks piggybacking one
push @killservers, "socks${2}";
}
push @killservers, $server;
@@ -3085,6 +3167,7 @@ sub singletest {
my $errorcode = $err[0] || "0";
my $ok="";
my $res;
+ chomp $errorcode;
if (@validstdout) {
# verify redirected stdout
my @actual = loadarray($STDOUT);
@@ -3272,7 +3355,7 @@ sub singletest {
}
else {
if(!$short) {
- printf("\n%s returned $cmdres, %d was expected\n",
+ printf("\n%s returned $cmdres, when expecting %s\n",
(!$tool)?"curl":$tool, $errorcode);
}
logmsg " exit FAILED\n";
@@ -3379,6 +3462,7 @@ sub singletest {
#######################################################################
# Stop all running test servers
+#
sub stopservers {
my $verbose = $_[0];
#
@@ -3426,17 +3510,17 @@ sub stopservers {
# startservers() starts all the named servers
#
# Returns: string with error reason or blank for success
-
+#
sub startservers {
my @what = @_;
my ($pid, $pid2);
for(@what) {
my (@whatlist) = split(/\s+/,$_);
my $what = lc($whatlist[0]);
- $what =~ s/[^a-z0-9-+]//g;
+ $what =~ s/[^a-z0-9-]//g;
my $certfile;
- if($what =~ /^(ftp|http|imap|pop3|smtp)s(.*)$/) {
+ if($what =~ /^(ftp|http|imap|pop3|smtp)s((\d*)(-ipv6|))$/) {
$certfile = ($whatlist[1]) ? $whatlist[1] : 'stunnel.pem';
}
@@ -3541,7 +3625,6 @@ sub startservers {
$run{'rtsp-ipv6'}="$pid $pid2";
}
}
-
elsif($what eq "ftps") {
if(!$stunnel) {
# we can't run ftps tests without stunnel
@@ -3578,11 +3661,11 @@ sub startservers {
}
elsif($what eq "https") {
if(!$stunnel) {
- # we can't run ftps tests without stunnel
+ # we can't run https tests without stunnel
return "no stunnel";
}
if(!$ssl_version) {
- # we can't run ftps tests if libcurl is SSL-less
+ # we can't run https tests if libcurl is SSL-less
return "curl lacks SSL support";
}
if($runcert{'https'} && ($runcert{'https'} ne $certfile)) {
@@ -3608,18 +3691,34 @@ sub startservers {
$run{'https'}="$pid $pid2";
}
}
- elsif($what eq "http+tls-srp") {
- if(!$has_gnutls) {
- return "no GnuTLS";
+ elsif($what eq "httptls") {
+ if(!$httptlssrv) {
+ # for now, we can't run http TLS-EXT tests without gnutls-serv
+ return "no gnutls-serv";
+ }
+ if(!$run{'httptls'}) {
+ ($pid, $pid2) = runhttptlsserver($verbose, "IPv4");
+ if($pid <= 0) {
+ return "failed starting HTTPTLS server (gnutls-serv)";
+ }
+ logmsg sprintf("* pid httptls => %d %d\n", $pid, $pid2)
+ if($verbose);
+ $run{'httptls'}="$pid $pid2";
+ }
+ }
+ elsif($what eq "httptls-ipv6") {
+ if(!$httptlssrv) {
+ # for now, we can't run http TLS-EXT tests without gnutls-serv
+ return "no gnutls-serv";
}
- if(!$run{'http+tls-srp'}) {
- ($pid, $pid2) = runhttptlssrpserver($verbose);
+ if(!$run{'httptls-ipv6'}) {
+ ($pid, $pid2) = runhttptlsserver($verbose, "IPv6");
if($pid <= 0) {
- return "failed starting HTTP+TLS-SRP server (gnutls-serv)";
+ return "failed starting HTTPTLS-IPv6 server (gnutls-serv)";
}
- logmsg sprintf("* pid http+tls-srp => %d %d\n", $pid, $pid2)
+ logmsg sprintf("* pid httptls-ipv6 => %d %d\n", $pid, $pid2)
if($verbose);
- $run{'http+tls-srp'}="$pid $pid2";
+ $run{'httptls-ipv6'}="$pid $pid2";
}
}
elsif($what eq "tftp") {
@@ -3697,7 +3796,6 @@ sub startservers {
#
# Returns: a string, blank if everything is fine or a reason why it failed
#
-
sub serverfortest {
my ($testnum)=@_;
@@ -3708,14 +3806,28 @@ sub serverfortest {
return "no server specified";
}
- for (@what) {
- my $proto = lc($_);
- chomp $proto;
- $proto =~ s/\s.*//g; # take first word
- if (! grep /^\Q$proto\E$/, @protocols) {
- if (substr($proto,0,5) ne "socks") {
- return "curl lacks $proto support";
+ for(my $i = scalar(@what) - 1; $i >= 0; $i--) {
+ my $srvrline = $what[$i];
+ chomp $srvrline if($srvrline);
+ if($srvrline =~ /^(\S+)((\s*)(.*))/) {
+ my $server = "${1}";
+ my $lnrest = "${2}";
+ my $tlsext;
+ if($server =~ /^(httptls)(\+)(ext|srp)(\d*)(-ipv6|)$/) {
+ $server = "${1}${4}${5}";
+ $tlsext = uc("TLS-${3}");
+ }
+ if(! grep /^\Q$server\E$/, @protocols) {
+ if(substr($server,0,5) ne "socks") {
+ if($tlsext) {
+ return "curl lacks $tlsext support";
+ }
+ else {
+ return "curl lacks $server support";
+ }
+ }
}
+ $what[$i] = "$server$lnrest" if($tlsext);
}
}
@@ -3895,6 +4007,11 @@ while(@ARGV) {
# run this test with gdb
$gdbthis=1;
}
+ elsif ($ARGV[0] eq "-gw") {
+ # run this test with windowed gdb
+ $gdbthis=1;
+ $gdbxwin=1;
+ }
elsif($ARGV[0] eq "-s") {
# short output
$short=1;
@@ -3966,6 +4083,7 @@ Usage: runtests.pl [options] [test selection(s)]
-c path use this curl executable
-d display server debug info
-g run the test case with gdb
+ -gw run the test case with gdb as a windowed application
-h this help text
-k keep stdout and stderr files present after tests
-l list all test case names/descriptions
@@ -4072,29 +4190,29 @@ if ($gdbthis) {
}
}
-$HTTPPORT = $base++; # HTTP server port
-$HTTPSPORT = $base++; # HTTPS server port
-$FTPPORT = $base++; # FTP server port
-$FTPSPORT = $base++; # FTPS server port
-$HTTP6PORT = $base++; # HTTP IPv6 server port (different IP protocol
- # but we follow the same port scheme anyway)
-$FTP2PORT = $base++; # FTP server 2 port
-$FTP6PORT = $base++; # FTP IPv6 port
-$TFTPPORT = $base++; # TFTP (UDP) port
-$TFTP6PORT = $base++; # TFTP IPv6 (UDP) port
-$SSHPORT = $base++; # SSH (SCP/SFTP) port
-$SOCKSPORT = $base++; # SOCKS port
-$POP3PORT = $base++;
-$POP36PORT = $base++;
-$IMAPPORT = $base++;
-$IMAP6PORT = $base++;
-$SMTPPORT = $base++;
-$SMTP6PORT = $base++;
-$RTSPPORT = $base++;
-$RTSP6PORT = $base++;
-$GOPHERPORT =$base++;
-$GOPHER6PORT=$base++;
-$HTTPTLSSRPPORT=$base++;
+$HTTPPORT = $base++; # HTTP server port
+$HTTPSPORT = $base++; # HTTPS (stunnel) server port
+$FTPPORT = $base++; # FTP server port
+$FTPSPORT = $base++; # FTPS (stunnel) server port
+$HTTP6PORT = $base++; # HTTP IPv6 server port
+$FTP2PORT = $base++; # FTP server 2 port
+$FTP6PORT = $base++; # FTP IPv6 port
+$TFTPPORT = $base++; # TFTP (UDP) port
+$TFTP6PORT = $base++; # TFTP IPv6 (UDP) port
+$SSHPORT = $base++; # SSH (SCP/SFTP) port
+$SOCKSPORT = $base++; # SOCKS port
+$POP3PORT = $base++; # POP3 server port
+$POP36PORT = $base++; # POP3 IPv6 server port
+$IMAPPORT = $base++; # IMAP server port
+$IMAP6PORT = $base++; # IMAP IPv6 server port
+$SMTPPORT = $base++; # SMTP server port
+$SMTP6PORT = $base++; # SMTP IPv6 server port
+$RTSPPORT = $base++; # RTSP server port
+$RTSP6PORT = $base++; # RTSP IPv6 server port
+$GOPHERPORT = $base++; # Gopher IPv4 server port
+$GOPHER6PORT = $base++; # Gopher IPv6 server port
+$HTTPTLSPORT = $base++; # HTTP TLS (non-stunnel) server port
+$HTTPTLS6PORT = $base++; # HTTP TLS (non-stunnel) IPv6 server port
#######################################################################
# clear and create logging directory:
@@ -4251,6 +4369,9 @@ sub displaylogs {
if(($log =~ /^file\d+\.txt/) && ($log !~ /^file$testnum\.txt/)) {
next; # skip fileNnn.txt of other tests
}
+ if(($log =~ /^netrc\d+/) && ($log !~ /^netrc$testnum/)) {
+ next; # skip netrcNnn of other tests
+ }
if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(\..*|)$/)) {
next; # skip valgrindNnn of other tests
}
diff --git a/tests/server/.gitignore b/tests/server/.gitignore
index 9e9dd37a2..8007bec8b 100644
--- a/tests/server/.gitignore
+++ b/tests/server/.gitignore
@@ -4,3 +4,4 @@ rtspd
sockfilt
sws
tftpd
+fake_ntlm
diff --git a/tests/server/Makefile.inc b/tests/server/Makefile.inc
index be3f06808..6b0ee72f0 100644
--- a/tests/server/Makefile.inc
+++ b/tests/server/Makefile.inc
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd
+noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd fake_ntlm
CURLX_SRCS = \
$(top_srcdir)/lib/mprintf.c \
@@ -63,3 +63,8 @@ tftpd_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) $(UTIL) \
tftp.h
tftpd_LDADD = @TEST_SERVER_LIBS@
tftpd_CFLAGS = $(AM_CFLAGS)
+
+fake_ntlm_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) $(UTIL) \
+ fake_ntlm.c
+fake_ntlm_LDADD = @TEST_SERVER_LIBS@
+fake_ntlm_CFLAGS = $(AM_CFLAGS)
diff --git a/tests/server/fake_ntlm.c b/tests/server/fake_ntlm.c
new file mode 100644
index 000000000..9bed5963d
--- /dev/null
+++ b/tests/server/fake_ntlm.c
@@ -0,0 +1,283 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2010, Mandy Wu, <mandy.wu@intel.com>
+ *
+ * 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 http://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.
+ *
+ ***************************************************************************/
+
+/*
+ * This is a fake ntlm_auth, which is used for testing NTLM single-sign-on.
+ * When DEBUGBUILD is defined, libcurl invoke this tool instead of real winbind
+ * daemon helper /usr/bin/ntlm_auth. This tool will accept commands and
+ * responses with a pre-written string saved in test case test2005.
+ */
+
+#define CURL_NO_OLDIES
+
+#include "setup.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#define ENABLE_CURLX_PRINTF
+#include "curlx.h" /* from the private lib dir */
+#include "getpart.h"
+#include "util.h"
+
+/* include memdebug.h last */
+#include "memdebug.h"
+
+#ifndef DEFAULT_LOGFILE
+#define DEFAULT_LOGFILE "log/fake_ntlm.log"
+#endif
+
+const char *serverlogfile = DEFAULT_LOGFILE;
+
+/*
+ * Returns an allocated buffer with printable representation of input
+ * buffer contents or returns NULL on out of memory condition.
+ */
+static char *printable(char *inbuf, size_t inlength)
+{
+ char *outbuf;
+ char *newbuf;
+ size_t newsize;
+ size_t outsize;
+ size_t outincr = 0;
+ size_t i, o = 0;
+
+#define HEX_FMT_STR "[0x%02X]"
+#define HEX_STR_LEN 6
+#define NOTHING_STR "[NOTHING]"
+#define NOTHING_LEN 9
+
+ if(!inlength)
+ inlength = strlen(inbuf);
+
+ if(inlength) {
+ outincr = ((inlength/2) < (HEX_STR_LEN+1)) ? HEX_STR_LEN+1 : inlength/2;
+ outsize = inlength + outincr;
+ }
+ else
+ outsize = NOTHING_LEN + 1;
+
+ outbuf = malloc(outsize);
+ if(!outbuf)
+ return NULL;
+
+ if(!inlength) {
+ sprintf(&outbuf[0], "%s", NOTHING_STR);
+ return outbuf;
+ }
+
+ for(i=0; i<inlength; i++) {
+
+ if(o > outsize - (HEX_STR_LEN + 1)) {
+ newsize = outsize + outincr;
+ newbuf = realloc(outbuf, newsize);
+ if(!newbuf) {
+ free(outbuf);
+ return NULL;
+ }
+ outbuf = newbuf;
+ outsize = newsize;
+ }
+
+ if((inbuf[i] > 0x20) && (inbuf[i] < 0x7F)) {
+ outbuf[o] = inbuf[i];
+ o++;
+ }
+ else {
+ sprintf(&outbuf[o], HEX_FMT_STR, inbuf[i]);
+ o += HEX_STR_LEN;
+ }
+
+ }
+ outbuf[o] = '\0';
+
+ return outbuf;
+}
+
+int main(int argc, char *argv[])
+{
+ char buf[1024];
+ FILE *stream;
+ char *filename;
+ int error;
+ char *type1_input = NULL, *type3_input = NULL;
+ char *type1_output = NULL, *type3_output = NULL;
+ size_t size = 0;
+ long testnum;
+ const char *env;
+ int arg = 1;
+ char *helper_user = (char *)"unknown";
+ char *helper_proto = (char *)"unknown";
+ char *helper_domain = (char *)"unknown";
+ bool use_cached_creds = FALSE;
+ char *msgbuf;
+
+ buf[0] = '\0';
+
+ while(argc > arg) {
+ if(!strcmp("--use-cached-creds", argv[arg])) {
+ use_cached_creds = TRUE;
+ arg++;
+ }
+ else if(!strcmp("--helper-protocol", argv[arg])) {
+ arg++;
+ if(argc > arg)
+ helper_proto = argv[arg++];
+ }
+ else if(!strcmp("--username", argv[arg])) {
+ arg++;
+ if(argc > arg)
+ helper_user = argv[arg++];
+ }
+ else if(!strcmp("--domain", argv[arg])) {
+ arg++;
+ if(argc > arg)
+ helper_domain = argv[arg++];
+ }
+ else {
+ puts("Usage: fake_ntlm [option]\n"
+ " --use-cached-creds\n"
+ " --helper-protocol [protocol]\n"
+ " --username [username]\n"
+ " --domain [domain]");
+ exit(1);
+ }
+ }
+
+ logmsg("fake_ntlm (user: %s) (proto: %s) (domain: %s) (cached creds: %s)",
+ helper_user, helper_proto, helper_domain,
+ (use_cached_creds) ? "yes" : "no");
+
+ env = getenv("CURL_NTLM_AUTH_TESTNUM");
+ if (env) {
+ char *endptr;
+ long lnum = strtol(env, &endptr, 10);
+ if((endptr != env + strlen(env)) || (lnum < 1L)) {
+ logmsg("Test number not valid in CURL_NTLM_AUTH_TESTNUM");
+ exit(1);
+ }
+ testnum = lnum;
+ } else {
+ logmsg("Test number not specified in CURL_NTLM_AUTH_TESTNUM");
+ exit(1);
+ }
+
+ env = getenv("CURL_NTLM_AUTH_SRCDIR");
+ if (env) {
+ path = env;
+ }
+
+ filename = test2file(testnum);
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", testnum);
+ exit(1);
+ }
+ else {
+ /* get the ntlm_auth input/output */
+ error = getpart(&type1_input, &size, "ntlm_auth_type1", "input", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 1 input failed with error: %d", error);
+ exit(1);
+ }
+ }
+
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", testnum);
+ exit(1);
+ }
+ else {
+ size = 0;
+ error = getpart(&type3_input, &size, "ntlm_auth_type3", "input", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 3 input failed with error: %d", error);
+ exit(1);
+ }
+ }
+
+ while(fgets(buf, sizeof(buf), stdin)) {
+ if(strcmp(buf, type1_input) == 0) {
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", testnum);
+ exit(1);
+ }
+ else {
+ size = 0;
+ error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 1 output failed with error: %d", error);
+ exit(1);
+ }
+ }
+ printf("%s", type1_output);
+ fflush(stdout);
+ }
+ else if(strncmp(buf, type3_input, strlen(type3_input)) == 0) {
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", testnum);
+ exit(1);
+ }
+ else {
+ size = 0;
+ error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 3 output failed with error: %d", error);
+ exit(1);
+ }
+ }
+ printf("%s", type3_output);
+ fflush(stdout);
+ }
+ else {
+ printf("Unknown request\n");
+ msgbuf = printable(buf, 0);
+ if(msgbuf) {
+ logmsg("invalid input: '%s'\n", msgbuf);
+ free(msgbuf);
+ }
+ else
+ logmsg("OOM formatting invalid input: '%s'\n", buf);
+ exit(1);
+ }
+ }
+ return 1;
+}
diff --git a/tests/server/getpart.c b/tests/server/getpart.c
index 743cb21b9..9384d0cb0 100644
--- a/tests/server/getpart.c
+++ b/tests/server/getpart.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -49,7 +49,7 @@ struct SessionHandle {
#ifdef DEBUG_GETPART
#define show(x) printf x
#else
-#define show(x)
+#define show(x) Curl_nop_stmt
#endif
#if defined(_MSC_VER) && defined(_DLL)
@@ -166,7 +166,9 @@ static int appenddata(char **dst_buf, /* dest buffer */
if(src_b64) {
/* base64 decode the given buffer */
- src_len = Curl_base64_decode(src_buf, &buf64.as_uchar);
+ int error = (int) Curl_base64_decode(src_buf, &buf64.as_uchar, &src_len);
+ if(error)
+ return GPE_OUT_OF_MEMORY;
src_buf = buf64.as_char;
if(!src_len || !src_buf) {
/*
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 949831d6c..b2d6df7a6 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -107,7 +107,7 @@ struct httprequest {
bool digest; /* Authorization digest header found */
bool ntlm; /* Authorization ntlm header found */
int writedelay; /* if non-zero, delay this number of seconds between
- writes in the response */
+ writes in the response */
int pipe; /* if non-zero, expect this many requests to do a "piped"
request/response */
int skip; /* if non-zero, the server is instructed to not read this
@@ -117,6 +117,7 @@ struct httprequest {
int rcmd; /* doing a special command, see defines above */
int prot_version; /* HTTP version * 10 */
bool pipelining; /* true if request is pipelined */
+ int callcount; /* times ProcessRequest() gets called */
};
static int ProcessRequest(struct httprequest *req);
@@ -308,13 +309,16 @@ static int ProcessRequest(struct httprequest *req)
bool chunked = FALSE;
static char request[REQUEST_KEYWORD_SIZE];
static char doc[MAXDOCNAMELEN];
- char logbuf[256];
+ char logbuf[456];
int prot_major, prot_minor;
char *end;
int error;
end = strstr(line, end_of_headers);
- logmsg("ProcessRequest() called");
+ req->callcount++;
+
+ logmsg("Process %d bytes request%s", req->offset,
+ req->callcount > 1?" [CONTINUED]":"");
/* try to figure out the request characteristics as soon as possible, but
only once! */
@@ -346,7 +350,7 @@ static int ProcessRequest(struct httprequest *req)
FILE *stream;
char *filename;
- if((strlen(doc) + strlen(request)) < 200)
+ if((strlen(doc) + strlen(request)) < 400)
sprintf(logbuf, "Got request: %s %s HTTP/%d.%d",
request, doc, prot_major, prot_minor);
else
@@ -397,12 +401,13 @@ static int ProcessRequest(struct httprequest *req)
return 1; /* done */
}
else {
+ char *orgcmd = NULL;
char *cmd = NULL;
size_t cmdsize = 0;
int num=0;
/* get the custom server control "commands" */
- error = getpart(&cmd, &cmdsize, "reply", "servercmd", stream);
+ error = getpart(&orgcmd, &cmdsize, "reply", "servercmd", stream);
fclose(stream);
if(error) {
logmsg("getpart() failed with error: %d", error);
@@ -410,8 +415,9 @@ static int ProcessRequest(struct httprequest *req)
return 1; /* done */
}
- if(cmdsize) {
- logmsg("Found a reply-servercmd section!");
+ cmd = orgcmd;
+ while(cmd && cmdsize) {
+ char *check;
if(!strncmp(CMD_AUTH_REQUIRED, cmd, strlen(CMD_AUTH_REQUIRED))) {
logmsg("instructed to require authorization header");
@@ -445,9 +451,26 @@ static int ProcessRequest(struct httprequest *req)
else {
logmsg("funny instruction found: %s", cmd);
}
+ /* try to deal with CRLF or just LF */
+ check = strchr(cmd, '\r');
+ if(!check)
+ check = strchr(cmd, '\n');
+
+ if(check) {
+ /* get to the letter following the newline */
+ while((*check == '\r') || (*check == '\n'))
+ check++;
+
+ if(!*check)
+ /* if we reached a zero, get out */
+ break;
+ cmd = check;
+ }
+ else
+ break;
}
- if(cmd)
- free(cmd);
+ if(orgcmd)
+ free(orgcmd);
}
}
else {
@@ -481,13 +504,17 @@ static int ProcessRequest(struct httprequest *req)
}
}
}
+ else if((req->offset >= 3) && (req->testno == DOCNUMBER_NOTHING)) {
+ logmsg("** Unusual request. Starts with %02x %02x %02x",
+ line[0], line[1], line[2]);
+ }
if(!end) {
/* we don't have a complete request yet! */
- logmsg("ProcessRequest returned without a complete request");
+ logmsg("request not complete yet");
return 0; /* not complete yet */
}
- logmsg("ProcessRequest found a complete request");
+ logmsg("- request found to be complete");
if(use_gopher) {
/* when using gopher we cannot check the request until the entire
@@ -616,10 +643,11 @@ static int ProcessRequest(struct httprequest *req)
req->ntlm = TRUE; /* NTLM found */
logmsg("Received NTLM type-1, sending back data %ld", req->partno);
}
- else if((req->partno >= 1000) && strstr(req->reqbuf, "Authorization: Basic")) {
- /* If the client is passing this Basic-header and the part number is already
- >=1000, we add 1 to the part number. This allows simple Basic authentication
- negotiation to work in the test suite. */
+ else if((req->partno >= 1000) &&
+ strstr(req->reqbuf, "Authorization: Basic")) {
+ /* If the client is passing this Basic-header and the part number is
+ already >=1000, we add 1 to the part number. This allows simple Basic
+ authentication negotiation to work in the test suite. */
req->partno += 1;
logmsg("Received Basic request, sending back data %ld", req->partno);
}
@@ -631,6 +659,7 @@ static int ProcessRequest(struct httprequest *req)
req->prot_version >= 11 &&
end &&
req->reqbuf + req->offset > end + strlen(end_of_headers) &&
+ !req->cl &&
(!strncmp(req->reqbuf, "GET", strlen("GET")) ||
!strncmp(req->reqbuf, "HEAD", strlen("HEAD")))) {
/* If we have a persistent connection, HTTP version >= 1.1
@@ -655,8 +684,10 @@ static int ProcessRequest(struct httprequest *req)
makes the server NOT wait for PUT/POST data and you can then make the
test case send a rejection before any such data has been sent. Test case
154 uses this.*/
- if(req->auth_req && !req->auth)
+ if(req->auth_req && !req->auth) {
+ logmsg("Return early due to auth requested by none provided");
return 1; /* done */
+ }
if(req->cl > 0) {
if(req->cl <= req->offset - (end - req->reqbuf) - strlen(end_of_headers))
@@ -756,6 +787,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
req->rcmd = RCMD_NORMALREQ;
req->prot_version = 0;
req->pipelining = FALSE;
+ req->callcount = 0;
/*** end of httprequest init ***/
@@ -767,9 +799,9 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
}
else {
if(req->skip)
- /* we are instructed to not read the entire thing, so we make sure to only
- read what we're supposed to and NOT read the enire thing the client
- wants to send! */
+ /* we are instructed to not read the entire thing, so we make sure to
+ only read what we're supposed to and NOT read the enire thing the
+ client wants to send! */
got = sread(sock, reqbuf + req->offset, req->cl);
else
got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset);
@@ -851,7 +883,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
char partbuf[80]="data";
- logmsg("Send response number %ld part %ld", req->testno, req->partno);
+ logmsg("Send response test%ld section <data%ld>", req->testno, req->partno);
switch(req->rcmd) {
default:
@@ -1394,8 +1426,13 @@ int main(int argc, char *argv[])
break;
}
- if(req.open)
- logmsg("=> persistant connection request ended, awaits new request");
+ if(req.open) {
+ logmsg("=> persistant connection request ended, awaits new request\n");
+ /*
+ const char *keepopen="[KEEPING CONNECTION OPEN]";
+ storerequest((char *)keepopen, strlen(keepopen));
+ */
+ }
/* if we got a CONNECT, loop and get another request as well! */
} while(req.open || (req.testno == DOCNUMBER_CONNECT));
@@ -1403,6 +1440,14 @@ int main(int argc, char *argv[])
break;
logmsg("====> Client disconnect");
+
+ if(!req.open)
+ /* When instructed to close connection after server-reply we
+ wait a very small amount of time before doing so. If this
+ is not done client might get an ECONNRESET before reading
+ a single byte of server-reply. */
+ wait_ms(50);
+
sclose(msgsock);
msgsock = CURL_SOCKET_BAD;
diff --git a/tests/serverhelp.pm b/tests/serverhelp.pm
index faaeebfd0..a1d1dc367 100644
--- a/tests/serverhelp.pm
+++ b/tests/serverhelp.pm
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2011, 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
@@ -63,6 +63,13 @@ use vars qw(
#***************************************************************************
+# Just for convenience, test harness uses 'https' and 'httptls' literals as
+# values for 'proto' variable in order to differentiate different servers.
+# 'https' literal is used for stunnel based https test servers, and 'httptls'
+# is used for non-stunnel https test servers.
+
+
+#***************************************************************************
# Return server characterization factors given a server id string.
#
sub serverfactors {
@@ -71,18 +78,20 @@ sub serverfactors {
my $ipvnum;
my $idnum;
- if($server =~ /^((ftp|http|imap|pop3|smtp)s?)(\d*)(-ipv6|)$/) {
+ if($server =~
+ /^((ftp|http|imap|pop3|smtp)s?)(\d*)(-ipv6|)$/) {
$proto = $1;
$idnum = ($3 && ($3 > 1)) ? $3 : 1;
$ipvnum = ($4 && ($4 =~ /6$/)) ? 6 : 4;
}
- elsif($server =~ /^(tftp|sftp|socks|ssh|rtsp)(\d*)(-ipv6|)$/) {
+ elsif($server =~
+ /^(tftp|sftp|socks|ssh|rtsp|gopher|httptls)(\d*)(-ipv6|)$/) {
$proto = $1;
$idnum = ($2 && ($2 > 1)) ? $2 : 1;
$ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4;
}
else {
- die "invalid server id: $server"
+ die "invalid server id: '$server'"
}
return($proto, $ipvnum, $idnum);
}
@@ -95,16 +104,16 @@ sub servername_str {
my ($proto, $ipver, $idnum) = @_;
$proto = uc($proto) if($proto);
- die "unsupported protocol: $proto" unless($proto &&
- ($proto =~ /^(((FTP|HTTP|IMAP|POP3|SMTP)S?)|(TFTP|SFTP|SOCKS|SSH|RTSP|GOPHER|HTTP\+TLS-SRP))$/));
+ die "unsupported protocol: '$proto'" unless($proto &&
+ ($proto =~ /^(((FTP|HTTP|IMAP|POP3|SMTP)S?)|(TFTP|SFTP|SOCKS|SSH|RTSP|GOPHER|HTTPTLS))$/));
$ipver = (not $ipver) ? 'ipv4' : lc($ipver);
- die "unsupported IP version: $ipver" unless($ipver &&
+ die "unsupported IP version: '$ipver'" unless($ipver &&
($ipver =~ /^(4|6|ipv4|ipv6|-ipv4|-ipv6)$/));
$ipver = ($ipver =~ /6$/) ? '-IPv6' : '';
$idnum = 1 if(not $idnum);
- die "unsupported ID number: $idnum" unless($idnum &&
+ die "unsupported ID number: '$idnum'" unless($idnum &&
($idnum =~ /^(\d+)$/));
$idnum = '' unless($idnum > 1);
@@ -188,7 +197,7 @@ sub server_outputfilename {
#
sub mainsockf_pidfilename {
my ($proto, $ipver, $idnum) = @_;
- die "unsupported protocol: $proto" unless($proto &&
+ die "unsupported protocol: '$proto'" unless($proto &&
(lc($proto) =~ /^(ftp|imap|pop3|smtp)s?$/));
my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.pid':'_sockfilt.pid';
return '.'. servername_canon($proto, $ipver, $idnum) ."$trailer";
@@ -200,7 +209,7 @@ sub mainsockf_pidfilename {
#
sub mainsockf_logfilename {
my ($logdir, $proto, $ipver, $idnum) = @_;
- die "unsupported protocol: $proto" unless($proto &&
+ die "unsupported protocol: '$proto'" unless($proto &&
(lc($proto) =~ /^(ftp|imap|pop3|smtp)s?$/));
my $trailer = (lc($proto) =~ /^ftps?$/) ? '_sockctrl.log':'_sockfilt.log';
return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
@@ -212,7 +221,7 @@ sub mainsockf_logfilename {
#
sub datasockf_pidfilename {
my ($proto, $ipver, $idnum) = @_;
- die "unsupported protocol: $proto" unless($proto &&
+ die "unsupported protocol: '$proto'" unless($proto &&
(lc($proto) =~ /^ftps?$/));
my $trailer = '_sockdata.pid';
return '.'. servername_canon($proto, $ipver, $idnum) ."$trailer";
@@ -224,7 +233,7 @@ sub datasockf_pidfilename {
#
sub datasockf_logfilename {
my ($logdir, $proto, $ipver, $idnum) = @_;
- die "unsupported protocol: $proto" unless($proto &&
+ die "unsupported protocol: '$proto'" unless($proto &&
(lc($proto) =~ /^ftps?$/));
my $trailer = '_sockdata.log';
return "${logdir}/". servername_canon($proto, $ipver, $idnum) ."$trailer";
diff --git a/tests/sshhelp.pm b/tests/sshhelp.pm
index 493cbfed8..ced9a01d1 100644
--- a/tests/sshhelp.pm
+++ b/tests/sshhelp.pm
@@ -39,6 +39,7 @@ use vars qw(
$sftpsrvexe
$sftpexe
$sshkeygenexe
+ $httptlssrvexe
$sshdconfig
$sshconfig
$sftpconfig
@@ -52,6 +53,7 @@ use vars qw(
$cliprvkeyf
$clipubkeyf
@sftppath
+ @httptlssrvpath
);
@@ -95,7 +97,7 @@ use vars qw(
find_sftpsrv
find_sftp
find_sshkeygen
- find_gnutls_serv
+ find_httptlssrv
logmsg
sshversioninfo
);
@@ -104,27 +106,28 @@ use vars qw(
#***************************************************************************
# Global variables initialization
#
-$sshdexe = 'sshd' .exe_ext(); # base name and ext of ssh daemon
-$sshexe = 'ssh' .exe_ext(); # base name and ext of ssh client
-$sftpsrvexe = 'sftp-server' .exe_ext(); # base name and ext of sftp-server
-$sftpexe = 'sftp' .exe_ext(); # base name and ext of sftp client
-$sshkeygenexe = 'ssh-keygen' .exe_ext(); # base name and ext of ssh-keygen
-$sshdconfig = 'curl_sshd_config'; # ssh daemon config file
-$sshconfig = 'curl_ssh_config'; # ssh client config file
-$sftpconfig = 'curl_sftp_config'; # sftp client config file
-$sshdlog = undef; # ssh daemon log file
-$sshlog = undef; # ssh client log file
-$sftplog = undef; # sftp client log file
-$sftpcmds = 'curl_sftp_cmds'; # sftp client commands batch file
-$knownhosts = 'curl_client_knownhosts'; # ssh knownhosts file
-$hstprvkeyf = 'curl_host_dsa_key'; # host private key file
-$hstpubkeyf = 'curl_host_dsa_key.pub'; # host public key file
-$cliprvkeyf = 'curl_client_key'; # client private key file
-$clipubkeyf = 'curl_client_key.pub'; # client public key file
+$sshdexe = 'sshd' .exe_ext(); # base name and ext of ssh daemon
+$sshexe = 'ssh' .exe_ext(); # base name and ext of ssh client
+$sftpsrvexe = 'sftp-server' .exe_ext(); # base name and ext of sftp-server
+$sftpexe = 'sftp' .exe_ext(); # base name and ext of sftp client
+$sshkeygenexe = 'ssh-keygen' .exe_ext(); # base name and ext of ssh-keygen
+$httptlssrvexe = 'gnutls-serv' .exe_ext(); # base name and ext of gnutls-serv
+$sshdconfig = 'curl_sshd_config'; # ssh daemon config file
+$sshconfig = 'curl_ssh_config'; # ssh client config file
+$sftpconfig = 'curl_sftp_config'; # sftp client config file
+$sshdlog = undef; # ssh daemon log file
+$sshlog = undef; # ssh client log file
+$sftplog = undef; # sftp client log file
+$sftpcmds = 'curl_sftp_cmds'; # sftp client commands batch file
+$knownhosts = 'curl_client_knownhosts'; # ssh knownhosts file
+$hstprvkeyf = 'curl_host_dsa_key'; # host private key file
+$hstpubkeyf = 'curl_host_dsa_key.pub'; # host public key file
+$cliprvkeyf = 'curl_client_key'; # client private key file
+$clipubkeyf = 'curl_client_key.pub'; # client public key file
#***************************************************************************
-# Absolute paths where to look for sftp-server plugin
+# Absolute paths where to look for sftp-server plugin, when not in PATH
#
@sftppath = qw(
/usr/lib/openssh
@@ -150,6 +153,30 @@ $clipubkeyf = 'curl_client_key.pub'; # client public key file
#***************************************************************************
+# Absolute paths where to look for httptlssrv (gnutls-serv), when not in PATH
+#
+@httptlssrvpath = qw(
+ /usr/sbin
+ /usr/libexec
+ /usr/lib
+ /usr/lib/misc
+ /usr/lib64/misc
+ /usr/local/bin
+ /usr/local/sbin
+ /usr/local/libexec
+ /opt/local/bin
+ /opt/local/sbin
+ /opt/local/libexec
+ /usr/freeware/bin
+ /usr/freeware/sbin
+ /usr/freeware/libexec
+ /opt/gnutls/bin
+ /opt/gnutls/sbin
+ /opt/gnutls/libexec
+ );
+
+
+#***************************************************************************
# Return file extension for executable files on this operating system
#
sub exe_ext {
@@ -273,7 +300,7 @@ sub find_file {
my @path = @_;
foreach (@path) {
my $file = File::Spec->catfile($_, $fn);
- if(-e $file) {
+ if(-e $file && ! -d $file) {
return $file;
}
}
@@ -281,9 +308,27 @@ sub find_file {
#***************************************************************************
+# Find an executable file somewhere in the given path
+#
+sub find_exe_file {
+ my $fn = $_[0];
+ shift;
+ my @path = @_;
+ my $xext = exe_ext();
+ foreach (@path) {
+ my $file = File::Spec->catfile($_, $fn);
+ if(-e $file && ! -d $file) {
+ return $file if(-x $file);
+ return $file if(($xext) && (lc($file) =~ /\Q$xext\E$/));
+ }
+ }
+}
+
+
+#***************************************************************************
# Find a file in environment path or in our sftppath
#
-sub find_sfile {
+sub find_file_spath {
my $filename = $_[0];
my @spath;
push(@spath, File::Spec->path());
@@ -291,18 +336,24 @@ sub find_sfile {
return find_file($filename, @spath);
}
+
#***************************************************************************
-# Find gnutls-serv and return canonical filename
+# Find an executable file in environment path or in our httptlssrvpath
#
-sub find_gnutls_serv {
- return find_file("gnutls-serv", split(':', $ENV{PATH}));
+sub find_exe_file_hpath {
+ my $filename = $_[0];
+ my @hpath;
+ push(@hpath, File::Spec->path());
+ push(@hpath, @httptlssrvpath);
+ return find_exe_file($filename, @hpath);
}
+
#***************************************************************************
# Find ssh daemon and return canonical filename
#
sub find_sshd {
- return find_sfile($sshdexe);
+ return find_file_spath($sshdexe);
}
@@ -310,7 +361,7 @@ sub find_sshd {
# Find ssh client and return canonical filename
#
sub find_ssh {
- return find_sfile($sshexe);
+ return find_file_spath($sshexe);
}
@@ -318,7 +369,7 @@ sub find_ssh {
# Find sftp-server plugin and return canonical filename
#
sub find_sftpsrv {
- return find_sfile($sftpsrvexe);
+ return find_file_spath($sftpsrvexe);
}
@@ -326,7 +377,7 @@ sub find_sftpsrv {
# Find sftp client and return canonical filename
#
sub find_sftp {
- return find_sfile($sftpexe);
+ return find_file_spath($sftpexe);
}
@@ -334,7 +385,15 @@ sub find_sftp {
# Find ssh-keygen and return canonical filename
#
sub find_sshkeygen {
- return find_sfile($sshkeygenexe);
+ return find_file_spath($sshkeygenexe);
+}
+
+
+#***************************************************************************
+# Find httptlssrv (gnutls-serv) and return canonical filename
+#
+sub find_httptlssrv {
+ return find_exe_file_hpath($httptlssrvexe);
}
diff --git a/tests/sshserver.pl b/tests/sshserver.pl
index b4390158d..8bb8bcdcf 100755
--- a/tests/sshserver.pl
+++ b/tests/sshserver.pl
@@ -6,7 +6,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2011, 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
@@ -362,8 +362,10 @@ if((($sshid =~ /OpenSSH/) && ($sshvernum < 299)) ||
#***************************************************************************
# Generate host and client key files for curl's tests
#
-if((! -e $hstprvkeyf) || (! -e $hstpubkeyf) ||
- (! -e $cliprvkeyf) || (! -e $clipubkeyf)) {
+if((! -e $hstprvkeyf) || (! -s $hstprvkeyf) ||
+ (! -e $hstpubkeyf) || (! -s $hstpubkeyf) ||
+ (! -e $cliprvkeyf) || (! -s $cliprvkeyf) ||
+ (! -e $clipubkeyf) || (! -s $clipubkeyf)) {
# Make sure all files are gone so ssh-keygen doesn't complain
unlink($hstprvkeyf, $hstpubkeyf, $cliprvkeyf, $clipubkeyf);
logmsg 'generating host keys...' if($verbose);
@@ -706,8 +708,9 @@ if(system "$sshd -t -f $sshdconfig > $sshdlog 2>&1") {
#***************************************************************************
# Generate ssh client host key database file for curl's tests
#
-if(! -e $knownhosts) {
+if((! -e $knownhosts) || (! -s $knownhosts)) {
logmsg 'generating ssh client known hosts file...' if($verbose);
+ unlink($knownhosts);
if(open(DSAKEYFILE, "<$hstpubkeyf")) {
my @dsahostkey = do { local $/ = ' '; <DSAKEYFILE> };
if(close(DSAKEYFILE)) {
diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h
index 4b4d32c8d..96203e075 100644
--- a/tests/unit/curlcheck.h
+++ b/tests/unit/curlcheck.h
@@ -49,7 +49,7 @@
fprintf(stderr, "%s:%d test failed: '%s'\n", \
__FILE__, __LINE__, msg); \
unitfail++; \
- } while(0)
+ } WHILE_FALSE
/* The abort macros mark the current test step as failed, and exit the test */
@@ -74,7 +74,7 @@
__FILE__, __LINE__, msg); \
unitfail++; \
goto unit_test_abort; \
- } while(0)
+ } WHILE_FALSE
diff --git a/tests/unit/unit1300.c b/tests/unit/unit1300.c
index 199cf2c9e..2b8341683 100644
--- a/tests/unit/unit1300.c
+++ b/tests/unit/unit1300.c
@@ -40,8 +40,10 @@ static CURLcode unit_setup(void)
if(!llist)
return CURLE_OUT_OF_MEMORY;
llist_destination = Curl_llist_alloc(test_curl_llist_dtor);
- if(!llist_destination)
+ if(!llist_destination) {
+ Curl_llist_destroy(llist, NULL);
return CURLE_OUT_OF_MEMORY;
+ }
return CURLE_OK;
}
diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c
index 7a61ec062..fc50c8865 100644
--- a/tests/unit/unit1302.c
+++ b/tests/unit/unit1302.c
@@ -45,63 +45,80 @@ UNITTEST_START
char *output;
unsigned char *decoded;
-size_t rc;
+size_t size = 0;
+unsigned char anychar = 'x';
+CURLcode rc;
-rc = Curl_base64_encode(data, "i", 1, &output);
-fail_unless( rc == 4 , "return code should be 4" );
+rc = Curl_base64_encode(data, "i", 1, &output, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 4, "size should be 4");
verify_memory( output, "aQ==", 4);
Curl_safefree(output);
-rc = Curl_base64_encode(data, "ii", 2, &output);
-fail_unless( rc == 4 , "return code should be 4" );
+rc = Curl_base64_encode(data, "ii", 2, &output, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 4, "size should be 4");
verify_memory( output, "aWk=", 4);
Curl_safefree(output);
-rc = Curl_base64_encode(data, "iii", 3, &output);
-fail_unless( rc == 4 , "return code should be 4" );
+rc = Curl_base64_encode(data, "iii", 3, &output, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 4, "size should be 4");
verify_memory( output, "aWlp", 4);
Curl_safefree(output);
-rc = Curl_base64_encode(data, "iiii", 4, &output);
-fail_unless( rc == 8 , "return code should be 8" );
+rc = Curl_base64_encode(data, "iiii", 4, &output, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 8, "size should be 8");
verify_memory( output, "aWlpaQ==", 8);
Curl_safefree(output);
/* 0 length makes it do strlen() */
-rc = Curl_base64_encode(data, "iiii", 0, &output);
-fail_unless( rc == 8 , "return code should be 8" );
+rc = Curl_base64_encode(data, "iiii", 0, &output, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 8, "size should be 8");
verify_memory( output, "aWlpaQ==", 8);
Curl_safefree(output);
-rc = Curl_base64_decode("aWlpaQ==", &decoded);
-fail_unless(rc == 4, "return code should be 4");
+rc = Curl_base64_decode("aWlpaQ==", &decoded, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 4, "size should be 4");
verify_memory(decoded, "iiii", 4);
Curl_safefree(decoded);
-rc = Curl_base64_decode("aWlp", &decoded);
-fail_unless(rc == 3, "return code should be 3");
+rc = Curl_base64_decode("aWlp", &decoded, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 3, "size should be 3");
verify_memory(decoded, "iii", 3);
Curl_safefree(decoded);
-rc = Curl_base64_decode("aWk=", &decoded);
-fail_unless(rc == 2, "return code should be 2");
+rc = Curl_base64_decode("aWk=", &decoded, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 2, "size should be 2");
verify_memory(decoded, "ii", 2);
Curl_safefree(decoded);
-rc = Curl_base64_decode("aQ==", &decoded);
-fail_unless(rc == 1, "return code should be 1");
+rc = Curl_base64_decode("aQ==", &decoded, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 1, "size should be 1");
verify_memory(decoded, "i", 2);
Curl_safefree(decoded);
/* this is an illegal input */
-decoded = NULL;
-rc = Curl_base64_decode("aQ", &decoded);
-fail_unless(rc == 0, "return code should be 0");
+size = 1; /* not zero */
+decoded = &anychar; /* not NULL */
+rc = Curl_base64_decode("aQ", &decoded, &size);
+/* return code indiferent, but output shall be as follows */
+fail_unless(size == 0, "size should be 0");
fail_if(decoded, "returned pointer should be NULL");
/* this is garbage input that libcurl decodes as far as possible */
-rc = Curl_base64_decode("a\x1f==", &decoded);
-fail_unless(rc == 1, "return code should be 1");
+size = 0;
+decoded = NULL;
+rc = Curl_base64_decode("a\x1f==", &decoded, &size);
+fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
+fail_unless(size == 1, "size should be 1");
+fail_if(!decoded, "returned pointer should not be NULL");
Curl_safefree(decoded);
UNITTEST_STOP
diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c
index 7b2985c58..8ddd8caee 100644
--- a/tests/unit/unit1304.c
+++ b/tests/unit/unit1304.c
@@ -41,7 +41,7 @@ static void unit_stop(void)
UNITTEST_START
int result;
- static const char* filename1 = "log/netrc";
+ static const char* filename1 = "log/netrc1304";
memcpy(filename, filename1, strlen(filename1));
/*