diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/Makefile.am | 3 | ||||
-rw-r--r-- | tests/data/test585 | 69 | ||||
-rw-r--r-- | tests/data/test586 | 59 | ||||
-rw-r--r-- | tests/libtest/Makefile.inc | 5 | ||||
-rw-r--r-- | tests/libtest/lib500.c | 35 |
5 files changed, 169 insertions, 2 deletions
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index ac5299714..2249394d9 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -47,7 +47,8 @@ test542 test543 test544 test545 test546 test547 test548 test549 test550 \ test551 test552 test553 test554 test555 test556 test557 test560 test561 \ test562 test563 test564 test565 test566 test567 test568 test569 test570 \ test571 test572 test573 test574 test575 test576 test578 test579 test580 \ -test581 test582 test583 test584 test600 test601 test602 test603 test604 \ +test581 test582 test583 test584 test585 test586 \ +test600 test601 test602 test603 test604 \ 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 \ diff --git a/tests/data/test585 b/tests/data/test585 new file mode 100644 index 000000000..32cb06fec --- /dev/null +++ b/tests/data/test585 @@ -0,0 +1,69 @@ +<testcase> +<info> +<keywords> +HTTP +HTTP GET +multi +CURLOPT_OPENSOCKETFUNCTION +CURLOPT_CLOSESOCKETFUNCTION +</keywords> +</info> + +# Server-side +<reply> +<data> +HTTP/1.1 302 eat this! +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Location: this-is-the-first.html +Content-Length: 0 +Connection: close + +</data> +<datacheck> +[OPEN] counter: 1 +HTTP/1.1 302 eat this! +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Location: this-is-the-first.html +Content-Length: 0 +Connection: close + +[CLOSE] counter: 1 +</datacheck> +</reply> + +# Client-side +<client> +<server> +http +</server> +<features> +http +</features> +# tool is what to use instead of 'curl' +<tool> +lib585 +</tool> + + <name> +socket open/close callbacks + </name> + <command> +http://%HOSTIP:%HTTPPORT/585 +</command> +</client> + +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +GET /585 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol> +</verify> +</testcase> diff --git a/tests/data/test586 b/tests/data/test586 new file mode 100644 index 000000000..c0857bdd8 --- /dev/null +++ b/tests/data/test586 @@ -0,0 +1,59 @@ +<testcase> +<info> +<keywords> +FTP +PASV +CURLOPT_PORT +</keywords> +</info> +# +# Server-side +<reply> +<data> +line 1 +line 2 +last line +</data> +<datacheck> +[OPEN] counter: 1 +[OPEN] counter: 2 +line 1 +line 2 +last line +[CLOSE] counter: 2 +[CLOSE] counter: 1 +</datacheck> +</reply> + +# +# Client-side +<client> +<server> +ftp +</server> +<tool> +lib585 +</tool> + <name> +FTP and open/close socket callbacks + </name> + <command> +ftp://%HOSTIP:%FTPPORT/586 +</command> +</client> + +# +# Verify data after the test has been "shot" +<verify> +<protocol> +USER anonymous
+PASS ftp@example.com
+PWD
+EPSV
+TYPE I
+SIZE 586
+RETR 586
+QUIT
+</protocol> +</verify> +</testcase> diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index a210cbfe3..06cda1e92 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -12,7 +12,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 + lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -160,3 +160,6 @@ lib579_SOURCES = lib579.c $(SUPPORTFILES) lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) lib583_SOURCES = lib583.c $(SUPPORTFILES) + +lib585_SOURCES = lib500.c $(SUPPORTFILES) +lib585_CFLAGS = -DLIB585 diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index b88bfd8bc..166bb85ab 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -23,6 +23,39 @@ #include "memdebug.h" +#ifdef LIB585 + +int counter; + +static int opensocket(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *addr) +{ + (void)clientp; + (void)purpose; + printf("[OPEN] counter: %d\n", ++counter); + return socket(addr->family, addr->socktype, addr->protocol); +} + +static int closesocket(void *clientp, curl_socket_t sock) +{ + (void)clientp; + printf("[CLOSE] counter: %d\n", counter--); + return sclose(sock); +} + +static void setupcallbacks(CURL *curl) +{ + curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); + counter = 0; +} + +#else +#define setupcallbacks(x) +#endif + + int test(char *URL) { CURLcode res; @@ -43,6 +76,8 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_HEADER, 1L); + setupcallbacks(curl); + res = curl_easy_perform(curl); if(!res) { |