From 7196d784d330df3030b782e097799629f4b80a61 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Dec 2002 12:11:16 +0000 Subject: The first ever attempts to do pure libcurl test cases --- tests/libtest/Makefile.am | 20 ++++++++++++++++++++ tests/libtest/first.c | 10 ++++++++++ tests/libtest/last.c | 1 + tests/libtest/lib500.c | 12 ++++++++++++ tests/libtest/lib501.c | 13 +++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 tests/libtest/Makefile.am create mode 100644 tests/libtest/first.c create mode 100644 tests/libtest/last.c create mode 100644 tests/libtest/lib500.c create mode 100644 tests/libtest/lib501.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am new file mode 100644 index 000000000..d172b2abd --- /dev/null +++ b/tests/libtest/Makefile.am @@ -0,0 +1,20 @@ +# +# $Id$ +# + +AUTOMAKE_OPTIONS = foreign nostdinc + +INCLUDES = -I$(top_srcdir)/include + +LIBDIR = ../../lib + +# here are all tools used for running libcurl tests +bin_PROGRAMS = lib500 lib501 + +lib500_SOURCES = lib500.c +lib500_LDADD = $(LIBDIR)/libcurl.la +lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib501_SOURCES = lib501.c +lib501_LDADD = $(LIBDIR)/libcurl.la +lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/first.c b/tests/libtest/first.c new file mode 100644 index 000000000..303766fc8 --- /dev/null +++ b/tests/libtest/first.c @@ -0,0 +1,10 @@ +#include + +int main(int argc, char **argv) +{ + if(argc< 2 ) { + fprintf(stderr, "Pass URL as argument please\n"); + return 1; + } + + curl_memdebug("memdump"); diff --git a/tests/libtest/last.c b/tests/libtest/last.c new file mode 100644 index 000000000..5c34318c2 --- /dev/null +++ b/tests/libtest/last.c @@ -0,0 +1 @@ +} diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c new file mode 100644 index 000000000..a825b930c --- /dev/null +++ b/tests/libtest/lib500.c @@ -0,0 +1,12 @@ +#include "first.c" + +fprintf(stderr, "URL: %s\n", argv[1]); + +CURL *curl; +curl = curl_easy_init(); +curl_easy_setopt(curl, CURLOPT_URL, argv[1]); +curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); +curl_easy_perform(curl); +curl_easy_cleanup(curl); + +#include "last.c" diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c new file mode 100644 index 000000000..4199598fa --- /dev/null +++ b/tests/libtest/lib501.c @@ -0,0 +1,13 @@ +#include "first.c" + +fprintf(stderr, "URL: %s\n", argv[1]); + +CURL *curl; +CURLcode res; +curl = curl_easy_init(); +curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); +res = curl_easy_perform(curl); +curl_easy_cleanup(curl); + +return res; +#include "last.c" -- cgit v1.2.1 From ae10d9cf22bedc202dc66b08db5b6aa3b1f78a14 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Dec 2002 13:36:50 +0000 Subject: no more --- tests/libtest/last.c | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/libtest/last.c (limited to 'tests/libtest') diff --git a/tests/libtest/last.c b/tests/libtest/last.c deleted file mode 100644 index 5c34318c2..000000000 --- a/tests/libtest/last.c +++ /dev/null @@ -1 +0,0 @@ -} -- cgit v1.2.1 From f26b709c50d44a60527aa21b86adfdc086b88ba6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Dec 2002 13:39:02 +0000 Subject: link the test tools this way instead --- tests/libtest/Makefile.am | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index d172b2abd..c4777eadf 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -11,10 +11,15 @@ LIBDIR = ../../lib # here are all tools used for running libcurl tests bin_PROGRAMS = lib500 lib501 -lib500_SOURCES = lib500.c +lib500_SOURCES = lib500.c first.c test.h lib500_LDADD = $(LIBDIR)/libcurl.la lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la -lib501_SOURCES = lib501.c +lib501_SOURCES = lib501.c first.c test.h lib501_LDADD = $(LIBDIR)/libcurl.la lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la + +setup: + for file in lib*.c; do \ + echo $$file; \ + done -- cgit v1.2.1 From 0f493b6038d257bbfea2344a58847fedc9378671 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Dec 2002 13:40:16 +0000 Subject: fixes --- tests/libtest/first.c | 16 ++++++++++++++++ tests/libtest/lib500.c | 21 +++++++++++---------- tests/libtest/lib501.c | 21 +++++++++++---------- tests/libtest/test.h | 3 +++ 4 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 tests/libtest/test.h (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 303766fc8..4f42136a0 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -1,10 +1,26 @@ #include +#ifdef MALLOCDEBUG +/* provide a proto for this debug function */ +extern void curl_memdebug(const char *); +#endif + +/* test is provided in the test code file */ +CURLcode test(char *url); + int main(int argc, char **argv) { + char *URL; if(argc< 2 ) { fprintf(stderr, "Pass URL as argument please\n"); return 1; } + URL = argv[1]; /* provide this to the rest */ + + fprintf(stderr, "URL: %s\n", URL); +#ifdef MALLOCDEBUG curl_memdebug("memdump"); +#endif + return test(URL); +} diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index a825b930c..f78ab5561 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -1,12 +1,13 @@ -#include "first.c" +#include "test.h" -fprintf(stderr, "URL: %s\n", argv[1]); +CURLcode test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return res; +} -CURL *curl; -curl = curl_easy_init(); -curl_easy_setopt(curl, CURLOPT_URL, argv[1]); -curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); -curl_easy_perform(curl); -curl_easy_cleanup(curl); - -#include "last.c" diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index 4199598fa..2ed1a9ae4 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -1,13 +1,14 @@ -#include "first.c" +#include "test.h" -fprintf(stderr, "URL: %s\n", argv[1]); +CURLcode test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); -CURL *curl; -CURLcode res; -curl = curl_easy_init(); -curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); -res = curl_easy_perform(curl); -curl_easy_cleanup(curl); + (void)URL; /* we don't use this */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return res; +} -return res; -#include "last.c" diff --git a/tests/libtest/test.h b/tests/libtest/test.h new file mode 100644 index 000000000..959270a30 --- /dev/null +++ b/tests/libtest/test.h @@ -0,0 +1,3 @@ +#include +#include + -- cgit v1.2.1 From ead065d8030ad58ebecf276b175431687aafa066 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Dec 2002 13:44:26 +0000 Subject: remove test piece --- tests/libtest/Makefile.am | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c4777eadf..f11ff10fa 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -18,8 +18,3 @@ lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la lib501_SOURCES = lib501.c first.c test.h lib501_LDADD = $(LIBDIR)/libcurl.la lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la - -setup: - for file in lib*.c; do \ - echo $$file; \ - done -- cgit v1.2.1 From d346ba5c3c685ecb58e40b1fdd48c0f6dca332b5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Dec 2002 13:40:25 +0000 Subject: lib502.c for multi interface tests on a single URL without select() --- tests/libtest/Makefile.am | 6 +++++- tests/libtest/lib502.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib502.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index f11ff10fa..103f3e1c6 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include LIBDIR = ../../lib # here are all tools used for running libcurl tests -bin_PROGRAMS = lib500 lib501 +bin_PROGRAMS = lib500 lib501 lib502 lib500_SOURCES = lib500.c first.c test.h lib500_LDADD = $(LIBDIR)/libcurl.la @@ -18,3 +18,7 @@ lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la lib501_SOURCES = lib501.c first.c test.h lib501_LDADD = $(LIBDIR)/libcurl.la lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib502_SOURCES = lib502.c first.c test.h +lib502_LDADD = $(LIBDIR)/libcurl.la +lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c new file mode 100644 index 000000000..55ca6c5db --- /dev/null +++ b/tests/libtest/lib502.c @@ -0,0 +1,33 @@ +#include "test.h" + +/* + * Get a single URL without select(). + */ + +CURLcode test(char *URL) +{ + CURL *c; + CURLM *m; + CURLMcode res; + int running=1; + + curl_global_init(CURL_GLOBAL_ALL); + c = curl_easy_init(); + curl_easy_setopt(c, CURLOPT_URL, URL); + m = curl_multi_init(); + + res = curl_multi_add_handle(m, c); + while (running) { + res = curl_multi_perform(m, &running); + if (running <= 0) { + fprintf(stderr, "nothing left running.\n"); + break; + } + } + curl_multi_remove_handle(m, c); + curl_easy_cleanup(c); + curl_multi_cleanup(m); + + return 0; +} + -- cgit v1.2.1 From 57572e550f446b1532efb06a5cd2c7af59c5f62f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Dec 2002 14:14:35 +0000 Subject: include files without the curl/ to reduce the risk of us including the wrong set of include files during tests --- tests/libtest/Makefile.am | 2 +- tests/libtest/test.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 103f3e1c6..1ba02bf80 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc -INCLUDES = -I$(top_srcdir)/include +INCLUDES = -I$(top_srcdir)/include/curl LIBDIR = ../../lib diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 959270a30..d9fbef311 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,3 +1,3 @@ -#include +#include #include -- cgit v1.2.1 From 57f0e3292d7ae14e623c5d212ba7e5ad96f106e5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Dec 2002 16:21:18 +0000 Subject: used this to verify bug report 651460 --- tests/libtest/lib503.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/libtest/lib503.c (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c new file mode 100644 index 000000000..a6f5d3f2c --- /dev/null +++ b/tests/libtest/lib503.c @@ -0,0 +1,77 @@ +#include "test.h" + +/* + * Source code in here hugely as reported in bug report 651460 by + * Christopher R. Palmer. + * + * Use multi interface to get HTTPS document over proxy, and provide + * auth info. + */ + +CURLcode test(char *URL) +{ + CURL *c; + CURLM *m; + + curl_global_init(CURL_GLOBAL_ALL); + c = curl_easy_init(); + curl_easy_setopt(c, CURLOPT_PROXY, arg2); /* set in first.c */ + curl_easy_setopt(c, CURLOPT_URL, URL); + curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); + curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); + curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1); + curl_easy_setopt(c, CURLOPT_HEADER, 1); + + { + CURLMcode res; + int running; + char done=FALSE; + + m = curl_multi_init(); + + res = curl_multi_add_handle(m, c); + + while(!done) { + fd_set rd, wr, exc; + int max_fd; + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = curl_multi_perform(m, &running); + if (running <= 0) { + done = TRUE; + break; + } + } + if(done) + break; + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + return 80; + } + + 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"); + return 89; + } + + if (select(max_fd+1, &rd, &wr, &exc, NULL) == -1) { + fprintf(stderr, "bad select??\n"); + return 95; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + } + curl_multi_remove_handle(m, c); + curl_easy_cleanup(c); + curl_multi_cleanup(m); + + return 0; +} + -- cgit v1.2.1 From 13722f536e5e7116f5ccbf625746366e74eda7a5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Dec 2002 16:22:17 +0000 Subject: added 503 --- tests/libtest/Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 1ba02bf80..d06be2245 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include/curl LIBDIR = ../../lib # here are all tools used for running libcurl tests -bin_PROGRAMS = lib500 lib501 lib502 +bin_PROGRAMS = lib500 lib501 lib502 lib503 lib500_SOURCES = lib500.c first.c test.h lib500_LDADD = $(LIBDIR)/libcurl.la @@ -22,3 +22,7 @@ lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la lib502_SOURCES = lib502.c first.c test.h lib502_LDADD = $(LIBDIR)/libcurl.la lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib503_SOURCES = lib503.c first.c test.h +lib503_LDADD = $(LIBDIR)/libcurl.la +lib503_DEPENDENCIES = $(LIBDIR)/libcurl.la -- cgit v1.2.1 From 4938991ab830435601e5dd4edfe3b188a60269c5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Dec 2002 16:22:57 +0000 Subject: set up arg2 to point to argv[2] to be used at will by programs --- tests/libtest/first.c | 5 +++++ tests/libtest/test.h | 2 ++ 2 files changed, 7 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 4f42136a0..528f1785c 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -8,6 +8,8 @@ extern void curl_memdebug(const char *); /* test is provided in the test code file */ CURLcode test(char *url); +char *arg2=NULL; + int main(int argc, char **argv) { char *URL; @@ -15,6 +17,9 @@ int main(int argc, char **argv) fprintf(stderr, "Pass URL as argument please\n"); return 1; } + if(argc>2) + arg2=argv[2]; + URL = argv[1]; /* provide this to the rest */ fprintf(stderr, "URL: %s\n", URL); diff --git a/tests/libtest/test.h b/tests/libtest/test.h index d9fbef311..a0d430842 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,3 +1,5 @@ #include #include +extern char *arg2; /* set by first.c to the argv[2] or NULL */ + -- cgit v1.2.1 From e0d6ebc2f23e6e59790608cc48f2ffb6311d1bfd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Dec 2002 16:24:04 +0000 Subject: please mr CVS ignore these --- tests/libtest/.cvsignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/libtest/.cvsignore (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore new file mode 100644 index 000000000..1d3bca873 --- /dev/null +++ b/tests/libtest/.cvsignore @@ -0,0 +1,8 @@ +lib500 +lib501 +lib502 +lib503 +.libs +.deps +Makefile +Makefile.in -- cgit v1.2.1 From 2b839853ecf83a7470520897ae700d9160c7aab2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 16 Dec 2002 15:30:10 +0000 Subject: Added test case 504, using multi interface and a local proxy without anything listening on the port we use. --- tests/libtest/Makefile.am | 7 ++++- tests/libtest/lib504.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib504.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index d06be2245..c25838b5a 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include/curl LIBDIR = ../../lib # here are all tools used for running libcurl tests -bin_PROGRAMS = lib500 lib501 lib502 lib503 +bin_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib500_SOURCES = lib500.c first.c test.h lib500_LDADD = $(LIBDIR)/libcurl.la @@ -26,3 +26,8 @@ lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la lib503_SOURCES = lib503.c first.c test.h lib503_LDADD = $(LIBDIR)/libcurl.la lib503_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib504_SOURCES = lib504.c first.c test.h +lib504_LDADD = $(LIBDIR)/libcurl.la +lib504_DEPENDENCIES = $(LIBDIR)/libcurl.la + diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c new file mode 100644 index 000000000..f6a066570 --- /dev/null +++ b/tests/libtest/lib504.c @@ -0,0 +1,76 @@ +#include "test.h" + +/* + * Source code in here hugely as reported in bug report 651464 by + * Christopher R. Palmer. + * + * Use multi interface to get document over proxy with bad port number. + * This caused the interface to "hang" in libcurl 7.10.2. + */ +CURLcode test(char *URL) +{ + CURL *c; + CURLcode ret=CURLE_OK; + CURLM *m; + fd_set rd, wr, exc; + CURLMcode res; + int running; + int max_fd; + + curl_global_init(CURL_GLOBAL_ALL); + c = curl_easy_init(); + + /* the point here being that there must not run anything on the given + proxy port */ + curl_easy_setopt(c, CURLOPT_PROXY, arg2); + curl_easy_setopt(c, CURLOPT_URL, URL); + curl_easy_setopt(c, CURLOPT_VERBOSE, 1); + + m = curl_multi_init(); + + do { + res = curl_multi_add_handle(m, c); + while (res == CURLM_CALL_MULTI_PERFORM) + res = curl_multi_perform(m, &running); + + if(!running) { + /* This is where this code is expected to reach */ + int numleft; + CURLMsg *msg = curl_multi_info_read(m, &numleft); + fprintf(stderr, "Not running\n"); + if(msg && !numleft) + ret = 100; /* this is where we should be */ + else + ret = 99; /* not correct */ + break; + } + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + ret = 2; + break; + } + + 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"); + ret = 3; + break; + } + + select(max_fd+1, &rd, &wr, &exc, NULL); + + fprintf(stderr, "not reached!\n"); + } while(0); + + curl_multi_remove_handle(m, c); + curl_easy_cleanup(c); + curl_multi_cleanup(m); + + return ret; +} + -- cgit v1.2.1 From 5a4c56fc448f1e58096d50198b6bf69c3fb2c0c4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Dec 2002 09:40:13 +0000 Subject: don't install the test programs --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c25838b5a..6ecc2607a 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include/curl LIBDIR = ../../lib # here are all tools used for running libcurl tests -bin_PROGRAMS = lib500 lib501 lib502 lib503 lib504 +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib500_SOURCES = lib500.c first.c test.h lib500_LDADD = $(LIBDIR)/libcurl.la -- cgit v1.2.1 From 5359bc80836869d7b706e62e81a2800275198434 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 7 Jan 2003 09:27:32 +0000 Subject: ignore lib504 too --- tests/libtest/.cvsignore | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore index 1d3bca873..6d7164761 100644 --- a/tests/libtest/.cvsignore +++ b/tests/libtest/.cvsignore @@ -6,3 +6,4 @@ lib503 .deps Makefile Makefile.in +lib504 -- cgit v1.2.1 From 61421b7a8f97f91c3a362f5e82f08f351b45cb04 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 8 Jan 2003 09:33:19 +0000 Subject: include curl.h without directory --- tests/libtest/first.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 528f1785c..c09d12dcd 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -1,4 +1,4 @@ -#include +#include #ifdef MALLOCDEBUG /* provide a proto for this debug function */ -- cgit v1.2.1 From 2288086695f6eb50a4928e23d8858e303eefe17f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 8 Jan 2003 09:37:35 +0000 Subject: nah, include test.h instead --- tests/libtest/first.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index c09d12dcd..ac230b973 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -1,4 +1,4 @@ -#include +#include "test.h" #ifdef MALLOCDEBUG /* provide a proto for this debug function */ -- cgit v1.2.1 From a302ff1605daa452287cdcb789c4b533d9bad598 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 23 Jan 2003 19:41:30 +0000 Subject: string.h keeps the proto for memset() on some platforms, used for FD_ZERO --- tests/libtest/test.h | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index a0d430842..1e5b67c96 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,5 +1,6 @@ #include #include +#include extern char *arg2; /* set by first.c to the argv[2] or NULL */ -- cgit v1.2.1 From 606f72bb1346af228db4079f690ff3ba7af42844 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 Mar 2003 08:53:44 +0000 Subject: Setup include path to the lib dir to enable inclusion of "config.h" --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 6ecc2607a..1363add60 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc -INCLUDES = -I$(top_srcdir)/include/curl +INCLUDES = -I$(top_srcdir)/include/curl -I$(top_srcdir)/lib LIBDIR = ../../lib -- cgit v1.2.1 From f8d552dde584b2615143a258e624d85a911c7a65 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 Mar 2003 08:54:11 +0000 Subject: include "config.h" from the lib's private dir --- tests/libtest/test.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 1e5b67c96..0451f88ca 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -2,5 +2,11 @@ #include #include +#ifdef HAVE_CONFIG_H +/* Now include the config.h file from libcurl's private libdir, so that we + get good in-depth knowledge about the system we're building this on */ +#include "config.h" +#endif + extern char *arg2; /* set by first.c to the argv[2] or NULL */ -- cgit v1.2.1 From f317f8b149c170be732670f8239812854e8c0f03 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 Mar 2003 08:54:45 +0000 Subject: Add include files to prevent warnings on some (HPUX) systems. --- tests/libtest/lib503.c | 6 ++++++ tests/libtest/lib504.c | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index a6f5d3f2c..c77e084bc 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -1,5 +1,11 @@ #include "test.h" +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include + /* * Source code in here hugely as reported in bug report 651460 by * Christopher R. Palmer. diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index f6a066570..d340c509c 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -1,5 +1,11 @@ #include "test.h" +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include + /* * Source code in here hugely as reported in bug report 651464 by * Christopher R. Palmer. -- cgit v1.2.1 From 38cf0268c0d1c3a8af5237fa357ce1c33a9912d7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 13 Mar 2003 15:54:46 +0000 Subject: use include path from BUILD dir since we want the config.h --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 1363add60..e7d3338c0 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc -INCLUDES = -I$(top_srcdir)/include/curl -I$(top_srcdir)/lib +INCLUDES = -I$(top_srcdir)/include/curl -I$(top_builddir)/lib LIBDIR = ../../lib -- cgit v1.2.1 From 8319ea70787ab197f1433621be040aa9584c320f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 Mar 2003 17:20:26 +0000 Subject: more defensive checking as platforms differ... --- tests/libtest/lib504.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index d340c509c..9acd71bdf 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -34,11 +34,13 @@ CURLcode test(char *URL) m = curl_multi_init(); + res = curl_multi_add_handle(m, c); + if(res && (res != CURLM_CALL_MULTI_PERFORM)) + return 1; /* major failure */ do { - res = curl_multi_add_handle(m, c); - while (res == CURLM_CALL_MULTI_PERFORM) + do { res = curl_multi_perform(m, &running); - + } while (res == CURLM_CALL_MULTI_PERFORM); if(!running) { /* This is where this code is expected to reach */ int numleft; @@ -50,6 +52,7 @@ CURLcode test(char *URL) ret = 99; /* not correct */ break; } + fprintf(stderr, "running %d res %d\n", running, res); if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); @@ -62,16 +65,17 @@ CURLcode test(char *URL) FD_ZERO(&exc); max_fd = 0; + fprintf(stderr, "_fdset()\n"); if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) { fprintf(stderr, "unexpected failured of fdset.\n"); ret = 3; break; } - + fprintf(stderr, "select\n"); select(max_fd+1, &rd, &wr, &exc, NULL); - fprintf(stderr, "not reached!\n"); - } while(0); + fprintf(stderr, "loop!\n"); + } while(1); curl_multi_remove_handle(m, c); curl_easy_cleanup(c); -- cgit v1.2.1 From b4e84ca7d2d326ba452b243afea521828df01ec8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 1 Apr 2003 07:13:04 +0000 Subject: lib505.c is a new test case for ftp uploading with rename --- tests/libtest/Makefile.am | 6 ++- tests/libtest/lib505.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib505.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e7d3338c0..0bcdc8868 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = -I$(top_srcdir)/include/curl -I$(top_builddir)/lib LIBDIR = ../../lib # here are all tools used for running libcurl tests -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib500_SOURCES = lib500.c first.c test.h lib500_LDADD = $(LIBDIR)/libcurl.la @@ -31,3 +31,7 @@ lib504_SOURCES = lib504.c first.c test.h lib504_LDADD = $(LIBDIR)/libcurl.la lib504_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib505_SOURCES = lib505.c first.c test.h +lib505_LDADD = $(LIBDIR)/libcurl.la +lib505_DEPENDENCIES = $(LIBDIR)/libcurl.la + diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c new file mode 100644 index 000000000..9aeb878bc --- /dev/null +++ b/tests/libtest/lib505.c @@ -0,0 +1,107 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_TYPES_ +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +/* + * This example shows an FTP upload, with a rename of the file just after + * a successful upload. + * + * Example based on source code provided by Erick Nuwendam. Thanks! + */ + +CURLcode test(char *URL) +{ + CURL *curl; + CURLcode res; + FILE *hd_src ; + int hd ; + struct stat file_info; + + struct curl_slist *headerlist=NULL; + const char *buf_1 = "RNFR 505"; + const char *buf_2 = "RNTO 505-forreal"; + + /* get the file size of the local file */ + hd = open(arg2, O_RDONLY) ; + if(hd == -1) { + /* can't open file, bail out */ + return -1; + } + fstat(hd, &file_info); + close(hd); + + /* get a FILE * of the same file, could also be made with + fdopen() from the previous descriptor, but hey this is just + an example! */ + hd_src = fopen(arg2, "rb"); + if(NULL == hd_src) { + return -2; /* if this happens things are major weird */ + } + + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + /* get a curl handle */ + curl = curl_easy_init(); + if(curl) { + /* build a list of commands to pass to libcurl */ + headerlist = curl_slist_append(headerlist, buf_1); + headerlist = curl_slist_append(headerlist, buf_2); + + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + + /* enable verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, URL); + + /* pass in that last of FTP commands to run after the transfer */ + curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); + + /* now specify which file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + + /* and give the size of the upload (optional) */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_info.st_size); + + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + /* clean up the FTP commands list */ + curl_slist_free_all (headerlist); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + fclose(hd_src); /* close the local file */ + + curl_global_cleanup(); + return res; +} -- cgit v1.2.1 From d37031f14e6b0077c45d9fa80e89d9fa19304eb6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 1 Apr 2003 07:13:28 +0000 Subject: ignore lib505 too --- tests/libtest/.cvsignore | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore index 6d7164761..5644e8538 100644 --- a/tests/libtest/.cvsignore +++ b/tests/libtest/.cvsignore @@ -7,3 +7,4 @@ lib503 Makefile Makefile.in lib504 +lib505 -- cgit v1.2.1 From 4b1203d4c9051442a0f5544421886df7ac67ff1d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 15 Apr 2003 13:32:26 +0000 Subject: include config.h before all system headers, so that _FILE_OFFSET_BITS and similar is set properly by us first --- tests/libtest/test.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 0451f88ca..f11bfdd6c 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,12 +1,12 @@ -#include -#include -#include - #ifdef HAVE_CONFIG_H /* Now include the config.h file from libcurl's private libdir, so that we get good in-depth knowledge about the system we're building this on */ #include "config.h" #endif +#include +#include +#include + extern char *arg2; /* set by first.c to the argv[2] or NULL */ -- cgit v1.2.1 From 9a12db1aa2128abbb82ecfc4904a90b9941d1261 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 15 Apr 2003 14:18:37 +0000 Subject: typecast the setting of the size, as it might be an off_t which is bigger than long and libcurl expects a long... --- tests/libtest/lib505.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 9aeb878bc..6945598c1 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -47,13 +47,16 @@ CURLcode test(char *URL) const char *buf_2 = "RNTO 505-forreal"; /* get the file size of the local file */ - hd = open(arg2, O_RDONLY) ; + hd = stat(arg2, &file_info); if(hd == -1) { /* can't open file, bail out */ return -1; } - fstat(hd, &file_info); - close(hd); + + if(! file_info.st_size) { + fprintf(stderr, "WARNING: file %s has no size!\n", arg2); + return -4; + } /* get a FILE * of the same file, could also be made with fdopen() from the previous descriptor, but hey this is just @@ -89,7 +92,8 @@ CURLcode test(char *URL) curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); /* and give the size of the upload (optional) */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_info.st_size); + curl_easy_setopt(curl, CURLOPT_INFILESIZE, + (long)file_info.st_size); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); -- cgit v1.2.1 From 6ff5621dd77766e833820ebbdd81e582c972e29c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 10 Jun 2003 12:05:12 +0000 Subject: more generic --- tests/libtest/Makefile.am | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 0bcdc8868..d7cdea430 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -8,30 +8,31 @@ INCLUDES = -I$(top_srcdir)/include/curl -I$(top_builddir)/lib LIBDIR = ../../lib +SUPPORTFILES = first.c test.h + # here are all tools used for running libcurl tests noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 -lib500_SOURCES = lib500.c first.c test.h +lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la -lib501_SOURCES = lib501.c first.c test.h +lib501_SOURCES = lib501.c $(SUPPORTFILES) lib501_LDADD = $(LIBDIR)/libcurl.la lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la -lib502_SOURCES = lib502.c first.c test.h +lib502_SOURCES = lib502.c $(SUPPORTFILES) lib502_LDADD = $(LIBDIR)/libcurl.la lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la -lib503_SOURCES = lib503.c first.c test.h +lib503_SOURCES = lib503.c $(SUPPORTFILES) lib503_LDADD = $(LIBDIR)/libcurl.la lib503_DEPENDENCIES = $(LIBDIR)/libcurl.la -lib504_SOURCES = lib504.c first.c test.h +lib504_SOURCES = lib504.c $(SUPPORTFILES) lib504_LDADD = $(LIBDIR)/libcurl.la lib504_DEPENDENCIES = $(LIBDIR)/libcurl.la -lib505_SOURCES = lib505.c first.c test.h +lib505_SOURCES = lib505.c $(SUPPORTFILES) lib505_LDADD = $(LIBDIR)/libcurl.la lib505_DEPENDENCIES = $(LIBDIR)/libcurl.la - -- cgit v1.2.1 From 449e5bc2ad1d83de50779686679de6158ae9ff03 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 4 Jul 2003 16:37:16 +0000 Subject: CURLDEBUG not MALLOCDEBUG anymore --- tests/libtest/first.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index ac230b973..6b9af9bcf 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -1,6 +1,6 @@ #include "test.h" -#ifdef MALLOCDEBUG +#ifdef CURLDEBUG /* provide a proto for this debug function */ extern void curl_memdebug(const char *); #endif @@ -24,7 +24,7 @@ int main(int argc, char **argv) fprintf(stderr, "URL: %s\n", URL); -#ifdef MALLOCDEBUG +#ifdef CURLDEBUG curl_memdebug("memdump"); #endif return test(URL); -- cgit v1.2.1 From 26f5c53be80404dbb55d7ee03a7580dbbf8e56a4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 11 Aug 2003 06:44:46 +0000 Subject: test case 506 added, written by Dirk Manske --- tests/libtest/Makefile.am | 7 +- tests/libtest/lib506.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib506.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index d7cdea430..b901c545d 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -11,7 +11,7 @@ LIBDIR = ../../lib SUPPORTFILES = first.c test.h # here are all tools used for running libcurl tests -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -36,3 +36,8 @@ lib504_DEPENDENCIES = $(LIBDIR)/libcurl.la lib505_SOURCES = lib505.c $(SUPPORTFILES) lib505_LDADD = $(LIBDIR)/libcurl.la lib505_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib506_SOURCES = lib506.c $(SUPPORTFILES) +lib506_LDADD = $(LIBDIR)/libcurl.la +lib506_DEPENDENCIES = $(LIBDIR)/libcurl.la + diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c new file mode 100644 index 000000000..52f6a38e7 --- /dev/null +++ b/tests/libtest/lib506.c @@ -0,0 +1,210 @@ +#include "test.h" +#include +#include +#include + +const char *HOSTHEADER = "Host: www.host.foo.com"; +const char *JAR = "log/jar506"; +#define THREADS 2 + + +/* struct containing data of a thread */ +struct Tdata { + CURLSH *share; + char *url; +}; + + +/* lock callback */ +void lock(CURL *handle, curl_lock_data data, curl_lock_access access, + void *useptr ) +{ + const char *what; + (void)handle; + (void)access; + 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; + default: + fprintf(stderr, "lock: no such data: %d\n",data); + return; + } + printf("lock: %s <%s>\n", what, (char *)useptr); +} + +/* unlock callback */ +void unlock(CURL *handle, curl_lock_data data, void *useptr ) +{ + const char *what; + (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; + default: + fprintf(stderr, "unlock: no such data: %d\n",data); + return; + } + printf("unlock: %s <%s>\n", what, (char *)useptr); +} + + +/* build host entry */ +struct curl_slist *sethost(struct curl_slist *headers) +{ + (void)headers; + return curl_slist_append(NULL, HOSTHEADER ); +} + + +/* the dummy thread function */ +void *fire(void *ptr) +{ + CURLcode code; + struct curl_slist *headers; + struct Tdata *tdata = (struct Tdata*)ptr; + CURL *curl = curl_easy_init(); + int i; + + headers = sethost(NULL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, (void*)headers); + curl_easy_setopt(curl, CURLOPT_URL, (void*)tdata->url); + printf( "CURLOPT_SHARE\n" ); + curl_easy_setopt(curl, CURLOPT_SHARE, (void*)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, code); + } + + printf( "CLEANUP\n" ); + curl_easy_cleanup(curl); + curl_slist_free_all(headers); + + return NULL; +} + + +/* build request url */ +char *suburl(char *base, int i) +{ + int len = strlen(base); + char *url = (char *)malloc(len+5); + if (!url) { + abort(); + } + strcpy(url, base); + strcat(url, "0000"); + url[len+3] = 48+i; + return url; +} + + +/* test function */ +CURLcode test(char *URL) +{ + CURLcode res; + CURLSHcode scode; + char *url; + struct Tdata tdata; + CURL *curl; + CURLSH *share; + struct curl_slist *headers; + int i; + + printf( "GLOBAL_INIT\n" ); + curl_global_init( CURL_GLOBAL_ALL ); + + /* prepare share */ + printf( "SHARE_INIT\n" ); + share = curl_share_init(); + curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); + curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); + curl_share_setopt( share, CURLSHOPT_USERDATA, "Pigs in space"); + printf( "CURL_LOCK_DATA_COOKIE\n" ); + curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + printf( "CURL_LOCK_DATA_DNS\n" ); + curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + + res = 0; + + /* start treads */ + for (i=1; i<=THREADS; i++ ) { + + /* set thread data */ + tdata.url = suburl( URL, i ); /* must be freed */ + tdata.share = share; + + /* simulate thread, direct call of "thread" function */ + printf( "*** run %d\n",i ); + fire( &tdata ); + + free( tdata.url ); + + } + + + /* fetch a another one and save cookies */ + printf( "*** run %d\n", i ); + curl = curl_easy_init(); + + url = suburl( URL, i ); + headers = sethost( NULL ); + curl_easy_setopt( curl, CURLOPT_HTTPHEADER, (void*)headers ); + curl_easy_setopt( curl, CURLOPT_URL, url ); + printf( "CURLOPT_SHARE\n" ); + curl_easy_setopt( curl, CURLOPT_SHARE, share ); + printf( "CURLOPT_COOKIEJAR\n" ); + curl_easy_setopt( curl, CURLOPT_COOKIEJAR, JAR ); + + 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" ); + } + + /* clean up last handle */ + printf( "CLEANUP\n" ); + curl_easy_cleanup( curl ); + curl_slist_free_all( headers ); + free(url); + + + /* 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", scode); + } + + printf( "GLOBAL_CLEANUP\n" ); + curl_global_cleanup(); + + return res; +} + -- cgit v1.2.1 From ae66bd128443d5a9b524d75be08e658e013ca957 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 14 Aug 2003 13:00:34 +0000 Subject: ignore lib506 too --- tests/libtest/.cvsignore | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore index 5644e8538..765fdac1c 100644 --- a/tests/libtest/.cvsignore +++ b/tests/libtest/.cvsignore @@ -8,3 +8,4 @@ Makefile Makefile.in lib504 lib505 +lib506 -- cgit v1.2.1 From d412724598dbff1e779534cf30a241ec38b0d280 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Aug 2003 09:37:28 +0000 Subject: test507 for multi with bad host name --- tests/libtest/Makefile.am | 5 ++++- tests/libtest/lib507.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib507.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index b901c545d..99d7d8cf5 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -11,7 +11,7 @@ LIBDIR = ../../lib SUPPORTFILES = first.c test.h # here are all tools used for running libcurl tests -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -41,3 +41,6 @@ lib506_SOURCES = lib506.c $(SUPPORTFILES) lib506_LDADD = $(LIBDIR)/libcurl.la lib506_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib507_SOURCES = lib507.c $(SUPPORTFILES) +lib507_LDADD = $(LIBDIR)/libcurl.la +lib507_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c new file mode 100644 index 000000000..14004f3d9 --- /dev/null +++ b/tests/libtest/lib507.c @@ -0,0 +1,50 @@ +#include "test.h" + +CURLcode test(char *URL) +{ + CURL* curls; + CURLM* multi; + int still_running; + int i; + CURLMsg *msg; + + multi = curl_multi_init(); + + curls=curl_easy_init(); + curl_easy_setopt(curls, CURLOPT_URL, URL); + curl_multi_add_handle(multi, curls); + + while ( CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi, &still_running) ); + while(still_running) { + struct timeval timeout; + int rc; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd; + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + timeout.tv_sec = 1; + timeout.tv_usec = 0; + curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); + switch(rc) { + case -1: + break; + case 0: + default: + while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi, &still_running)); + break; + } + } + msg = curl_multi_info_read(multi, &still_running); + /* this should now contain a result code from the easy handle, + get it */ + i = msg->data.result; + + curl_multi_cleanup(multi); + curl_easy_cleanup(curls); + + return i; /* return the final return code */ +} -- cgit v1.2.1 From 3a5a6038e7b8f7101e5c50992c62e0a2882b95a1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Aug 2003 09:38:49 +0000 Subject: better ignore pattern --- tests/libtest/.cvsignore | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore index 765fdac1c..bec8bfc02 100644 --- a/tests/libtest/.cvsignore +++ b/tests/libtest/.cvsignore @@ -1,11 +1,5 @@ -lib500 -lib501 -lib502 -lib503 .libs .deps Makefile Makefile.in -lib504 -lib505 -lib506 +lib50[0-9] -- cgit v1.2.1 From f52534522ce447afa6556079ff534a6d859397ae Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 7 Oct 2003 14:43:48 +0000 Subject: test case 508 added to test callback-based POST --- tests/libtest/Makefile.am | 7 ++++- tests/libtest/lib508.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib508.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 99d7d8cf5..52f9e6e57 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -11,7 +11,8 @@ LIBDIR = ../../lib SUPPORTFILES = first.c test.h # here are all tools used for running libcurl tests -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ + lib508 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -44,3 +45,7 @@ lib506_DEPENDENCIES = $(LIBDIR)/libcurl.la lib507_SOURCES = lib507.c $(SUPPORTFILES) lib507_LDADD = $(LIBDIR)/libcurl.la lib507_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib508_SOURCES = lib508.c $(SUPPORTFILES) +lib508_LDADD = $(LIBDIR)/libcurl.la +lib508_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c new file mode 100644 index 000000000..e6798da2e --- /dev/null +++ b/tests/libtest/lib508.c @@ -0,0 +1,67 @@ +#include "test.h" + +static char data[]="this is what we post to the silly web server\n"; + +struct WriteThis { + char *readptr; + int sizeleft; +}; + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *)userp; + + if(size*nmemb < 1) + return 0; + + if(pooh->sizeleft) { + *(char *)ptr = pooh->readptr[0]; /* copy one single byte */ + pooh->readptr++; /* advance pointer */ + pooh->sizeleft--; /* less data left */ + return 1; /* we return 1 byte at a time! */ + } + + return -1; /* no more data left to deliver */ +} + +CURLcode test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + struct WriteThis pooh; + + pooh.readptr = data; + pooh.sizeleft = strlen(data); + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); + + /* Set the expected POST size */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return res; +} -- cgit v1.2.1 From da0b380655ad10865c8e56b15641373b656f0807 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 24 Oct 2003 20:58:34 +0000 Subject: don't select() forever, set a timeout so at least the test fails nice --- tests/libtest/lib503.c | 3 ++- tests/libtest/lib504.c | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index c77e084bc..126e257a6 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -40,6 +40,7 @@ CURLcode test(char *URL) while(!done) { fd_set rd, wr, exc; int max_fd; + struct timeval interval={1,0}; while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(m, &running); @@ -66,7 +67,7 @@ CURLcode test(char *URL) return 89; } - if (select(max_fd+1, &rd, &wr, &exc, NULL) == -1) { + if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); return 95; } diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 9acd71bdf..9eba0b764 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -22,6 +22,7 @@ CURLcode test(char *URL) CURLMcode res; int running; int max_fd; + int rc; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -36,26 +37,29 @@ CURLcode test(char *URL) res = curl_multi_add_handle(m, c); if(res && (res != CURLM_CALL_MULTI_PERFORM)) - return 1; /* major failure */ + return 1; /* major failure */ do { + struct timeval interval={1,0}; + + fprintf(stderr, "curl_multi_perform()\n"); + do { res = curl_multi_perform(m, &running); - } while (res == CURLM_CALL_MULTI_PERFORM); + } while (res == CURLM_CALL_MULTI_PERFORM); if(!running) { /* This is where this code is expected to reach */ int numleft; CURLMsg *msg = curl_multi_info_read(m, &numleft); - fprintf(stderr, "Not running\n"); + fprintf(stderr, "Expected: not running\n"); if(msg && !numleft) ret = 100; /* this is where we should be */ else ret = 99; /* not correct */ break; } - fprintf(stderr, "running %d res %d\n", running, res); + fprintf(stderr, "running == %d, res == %d\n", running, res); if (res != CURLM_OK) { - fprintf(stderr, "not okay???\n"); ret = 2; break; } @@ -65,17 +69,16 @@ CURLcode test(char *URL) FD_ZERO(&exc); max_fd = 0; - fprintf(stderr, "_fdset()\n"); + 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"); ret = 3; break; } - fprintf(stderr, "select\n"); - select(max_fd+1, &rd, &wr, &exc, NULL); - - fprintf(stderr, "loop!\n"); - } while(1); + rc = select(max_fd+1, &rd, &wr, &exc, &interval); + fprintf(stderr, "select returned %d\n", rc); + + } while(rc); curl_multi_remove_handle(m, c); curl_easy_cleanup(c); -- cgit v1.2.1 From 245ab7c79642bc055445aac77e3307cab279d23a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 25 Oct 2003 06:03:50 +0000 Subject: avoid dependence on the order of the fields in the timeval struct, pointed out by Gisle Vanem --- tests/libtest/lib503.c | 5 ++++- tests/libtest/lib504.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 126e257a6..f324b35d6 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -40,7 +40,10 @@ CURLcode test(char *URL) while(!done) { fd_set rd, wr, exc; int max_fd; - struct timeval interval={1,0}; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(m, &running); diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 9eba0b764..0a9aff2cc 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -39,7 +39,10 @@ CURLcode test(char *URL) if(res && (res != CURLM_CALL_MULTI_PERFORM)) return 1; /* major failure */ do { - struct timeval interval={1,0}; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; fprintf(stderr, "curl_multi_perform()\n"); -- cgit v1.2.1 From 527850928d349269029a38bace3aba9cb925d31b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 Nov 2003 13:07:54 +0000 Subject: Define TRUE and FALSE unless already present. I've moved away those definitions from the global curl header and thus this needs to do it themselves. --- tests/libtest/test.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index f11bfdd6c..8a6c02130 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -8,5 +8,13 @@ #include #include +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + extern char *arg2; /* set by first.c to the argv[2] or NULL */ -- cgit v1.2.1 From 989ec98ebdc1c73b70b957f9eeacb4de7882970a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 16 Dec 2003 09:49:36 +0000 Subject: modified and corrected test 506 --- tests/libtest/lib506.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 52f6a38e7..998c1370c 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -14,20 +14,27 @@ struct Tdata { char *url; }; +struct userdata { + char *text; + int counter; +}; /* lock callback */ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, void *useptr ) { const char *what; + struct userdata *user = (struct userdata *)useptr; + (void)handle; (void)access; + switch ( data ) { case CURL_LOCK_DATA_SHARE: - what = "share "; + what = "share"; break; case CURL_LOCK_DATA_DNS: - what = "dns "; + what = "dns"; break; case CURL_LOCK_DATA_COOKIE: what = "cookie"; @@ -36,20 +43,22 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, fprintf(stderr, "lock: no such data: %d\n",data); return; } - printf("lock: %s <%s>\n", what, (char *)useptr); + printf("lock: %-6s <%s>: %d\n", what, user->text, user->counter); + user->counter++; } /* unlock callback */ void 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 "; + what = "share"; break; case CURL_LOCK_DATA_DNS: - what = "dns "; + what = "dns"; break; case CURL_LOCK_DATA_COOKIE: what = "cookie"; @@ -58,7 +67,8 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr ) fprintf(stderr, "unlock: no such data: %d\n",data); return; } - printf("unlock: %s <%s>\n", what, (char *)useptr); + printf("unlock: %-6s <%s>: %d\n", what, user->text, user->counter); + user->counter++; } @@ -127,6 +137,10 @@ CURLcode test(char *URL) CURLSH *share; struct curl_slist *headers; int i; + struct userdata user; + + user.text = (char *)"Pigs in space"; + user.counter = 0; printf( "GLOBAL_INIT\n" ); curl_global_init( CURL_GLOBAL_ALL ); @@ -136,7 +150,7 @@ CURLcode test(char *URL) share = curl_share_init(); curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); - curl_share_setopt( share, CURLSHOPT_USERDATA, "Pigs in space"); + curl_share_setopt( share, CURLSHOPT_USERDATA, &user); printf( "CURL_LOCK_DATA_COOKIE\n" ); curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); printf( "CURL_LOCK_DATA_DNS\n" ); -- cgit v1.2.1 From b60e0fa97ed7ddc66d0ad6d00dfd78319bb6ad36 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Jan 2004 22:29:29 +0000 Subject: David J Meyer's large file support. --- tests/libtest/lib505.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 6945598c1..0efaf76cc 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -92,8 +92,8 @@ CURLcode test(char *URL) curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); /* and give the size of the upload (optional) */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE, - (long)file_info.st_size); + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, + file_info.st_size); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); -- cgit v1.2.1 From 3a61c98b6537b69db9b225caa30ec52fc7101aa6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 12 Jan 2004 15:26:32 +0000 Subject: Peter Sylvester brought code that now allows a callback to modified the URL even when the multi interface is used, and then libcurl will simulate a "follow location" to that new URL. Test 509 was added to test this feature. --- tests/libtest/Makefile.am | 6 +- tests/libtest/lib509.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib509.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 52f9e6e57..9a358f09d 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -12,7 +12,7 @@ SUPPORTFILES = first.c test.h # here are all tools used for running libcurl tests noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 + lib508 lib509 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -49,3 +49,7 @@ lib507_DEPENDENCIES = $(LIBDIR)/libcurl.la lib508_SOURCES = lib508.c $(SUPPORTFILES) lib508_LDADD = $(LIBDIR)/libcurl.la lib508_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib509_SOURCES = lib509.c $(SUPPORTFILES) +lib509_LDADD = $(LIBDIR)/libcurl.la +lib509_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c new file mode 100644 index 000000000..d9774d129 --- /dev/null +++ b/tests/libtest/lib509.c @@ -0,0 +1,260 @@ +#include "test.h" + +#ifdef USE_SSLEAY + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +typedef struct sslctxparm_st { + CURL* curl; + int accesstype ; + unsigned char * accessinfoURL ; + +} sslctxparm; + + +static unsigned char *i2s_ASN1_IA5STRING( ASN1_IA5STRING *ia5) +{ + unsigned char *tmp; + if(!ia5 || !ia5->length) return NULL; + tmp = OPENSSL_malloc(ia5->length + 1); + memcpy(tmp, ia5->data, ia5->length); + tmp[ia5->length] = 0; + return tmp; +} + +/* A conveniance routine to get an access URI. */ + +static unsigned char *my_get_ext(X509 * cert, const int type, + int extensiontype) +{ + int i; + STACK_OF(ACCESS_DESCRIPTION) * accessinfo ; + accessinfo = X509_get_ext_d2i(cert, extensiontype, NULL, NULL) ; + + if (!sk_ACCESS_DESCRIPTION_num(accessinfo)) + return NULL; + + for (i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) { + ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i); + if (OBJ_obj2nid(ad->method) == type) { + if (ad->location->type == GEN_URI) { + return i2s_ASN1_IA5STRING(ad->location->d.ia5); + } + return NULL; + } + } + return NULL; +} + +void * globalparm = NULL; + +static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) +{ + sslctxparm * p = (sslctxparm *) arg; + int ok, err; + + fprintf(stderr,"ssl_app_verify_callback sslctxparm=%p ctx=%p\n", + (void *)p, (void*)ctx); + +#if OPENSSL_VERSION_NUMBER<0x00907000L +/* not necessary in openssl 0.9.7 or later */ + + fprintf(stderr,"This version %s of openssl does not support a parm (%p)" + ", getting a global static %p \n", + OPENSSL_VERSION_TEXT, (void *)p, (void *)globalparm); + + p = globalparm; +#endif + +/* The following error should not occur. We test this to avoid segfault. */ + if (!p || !ctx) { + fprintf(stderr,"Internal error in ssl_app_verify_callback " + "sslctxparm=%p ctx=%p\n",(void *)p,(void*)ctx); + return 0; + } + + ok= X509_verify_cert(ctx); + err=X509_STORE_CTX_get_error(ctx); + +/* The following seems to be a problem in 0.9.7/8 openssl versions */ + +#if 1 + if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT || + err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { + fprintf(stderr,"X509_verify_cert: repairing self signed\n") ; + X509_STORE_CTX_set_error(ctx,X509_V_OK); + ok = 1; + } +#endif + + if (ok && ctx->cert) { + unsigned char * accessinfoURL ; + + accessinfoURL = my_get_ext(ctx->cert,p->accesstype ,NID_info_access); + if (accessinfoURL) { + + if (strcmp((char *)p->accessinfoURL, (char *)accessinfoURL)) { + fprintf(stderr, "Setting URL <%s>, was <%s>\n", + accessinfoURL,p->accessinfoURL); + OPENSSL_free(p->accessinfoURL); + p->accessinfoURL = accessinfoURL; + curl_easy_setopt(p->curl, CURLOPT_URL,p->accessinfoURL); + } + else + OPENSSL_free(accessinfoURL); + } + } + return(ok); +} + + +static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) +{ + sslctxparm * p = (sslctxparm *) parm; + + SSL_CTX * ctx = (SSL_CTX *) sslctx ; + fprintf(stderr,"sslctxfun start curl=%p ctx=%p parm=%p\n", + (void *)curl,(void *)ctx,(void *)p); + + SSL_CTX_set_quiet_shutdown(ctx,1); + SSL_CTX_set_cipher_list(ctx,"RC4-MD5"); + SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); + +/* one might assume that the cert validaton would not fail when setting this, + but it still does, see the error handling in the call back */ + + SSL_CTX_set_verify_depth(ctx,0); + SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL); + +#if OPENSSL_VERSION_NUMBER<0x00907000L +/* in newer openssl versions we can set a parameter for the call back. */ + fprintf(stderr,"This version %s of openssl does not support a parm," + " setting global one\n", OPENSSL_VERSION_TEXT); + /* this is only done to support 0.9.6 version */ + globalparm = parm; + +/* in 0.9.6 the parm is not taken */ +#endif + SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm); + fprintf(stderr,"sslctxfun end\n"); + + return CURLE_OK ; +} + + +CURLcode test(char *URL) +{ + CURLM* multi; + sslctxparm p; + + int i; + CURLMsg *msg; + + curl_global_init(CURL_GLOBAL_ALL); + + p.curl = curl_easy_init(); + + p.accessinfoURL = (unsigned char *) strdup(URL); + p.accesstype = OBJ_obj2nid(OBJ_txt2obj("AD_DVCS",0)) ; + + curl_easy_setopt(p.curl, CURLOPT_URL, p.accessinfoURL); + + curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun) ; + curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p); + + curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYHOST, 1); + + fprintf(stderr,"Going to perform %s\n",p.accessinfoURL); + + { + CURLMcode res; + int running; + char done=FALSE; + + multi = curl_multi_init(); + + res = curl_multi_add_handle(multi, p.curl); + + while(!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = curl_multi_perform(multi, &running); + fprintf(stderr, "running=%d res=%d\n",running,res); + if (running <= 0) { + done = TRUE; + break; + } + } + if(done) + break; + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + return 80; + } + + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&exc); + max_fd = 0; + + if (curl_multi_fdset(multi, &rd, &wr, &exc, &max_fd) != CURLM_OK) { + fprintf(stderr, "unexpected failured of fdset.\n"); + return 89; + } + + if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + return 95; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + msg = curl_multi_info_read(multi, &running); + /* this should now contain a result code from the easy handle, get it */ + i = msg->data.result; + } + + fprintf(stderr, "all done\n"); + + curl_multi_remove_handle(multi, p.curl); + curl_easy_cleanup(p.curl); + curl_multi_cleanup(multi); + + curl_global_cleanup(); + free(p.accessinfoURL); + + return i; +} +#else /* USE_SSLEAY */ +CURLcode test(char *URL) +{ + (void)URL; + return CURLE_FAILED_INIT; +} +#endif /* USE_SSLEAY */ -- cgit v1.2.1 From 4ba05e1128fd39d13379db7d595b9a2fc6b391d3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 13 Jan 2004 07:35:28 +0000 Subject: include setup.h from the lib dir instead to get even more private stuff from the libcurl build, but right now for the USE_SSLEAY define. --- tests/libtest/test.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 8a6c02130..b0b119e5b 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,7 +1,9 @@ #ifdef HAVE_CONFIG_H -/* Now include the config.h file from libcurl's private libdir, so that we - get good in-depth knowledge about the system we're building this on */ -#include "config.h" +/* Now include the setup.h file from libcurl's private libdir (the source + version, but that might include "config.h" from the build dir so we need + both of them in the include path), so that we get good in-depth knowledge + about the system we're building this on */ +#include "setup.h" #endif #include -- cgit v1.2.1 From 206039cb766cb604154bd3f0bbd14354141839fd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 13 Jan 2004 07:36:13 +0000 Subject: fix the include path to point to the libcurl's source dir too for the setup.h inclusion --- tests/libtest/Makefile.am | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 9a358f09d..24f72d842 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -1,12 +1,39 @@ +############################################################################# +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| # -# $Id$ +# Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. +# +# In order to be useful for every potential user, curl and libcurl are +# dual-licensed under the MPL and the MIT/X-derivate licenses. +# +# 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 MPL or the MIT/X-derivate +# licenses. You may pick one of these licenses. # +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +# $Id$ +############################################################################# AUTOMAKE_OPTIONS = foreign nostdinc -INCLUDES = -I$(top_srcdir)/include/curl -I$(top_builddir)/lib +# $(top_srcdir)/include/curl is for the main curl include files, to make it +# easier to include this specific set of curl headers, and NOT the ones +# possibly already installed in the system. +# -I$(top_srcdir)/lib is for the setup.h file, included by test.h +# -I$(top_builddir)/lib is for the config.h file, possibly included by the +# setup.h file +INCLUDES = -I$(top_srcdir)/include/curl \ + -I$(top_srcdir)/lib \ + -I$(top_builddir)/lib -LIBDIR = ../../lib +LIBDIR = $(top_builddir)/lib SUPPORTFILES = first.c test.h -- cgit v1.2.1 From 3c1bb361939e7462dd4956da6f03fe5209f2ae59 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 13 Jan 2004 08:57:01 +0000 Subject: use the *correct* header! --- tests/libtest/Makefile.am | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 24f72d842..4c62a4a17 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -1,26 +1,25 @@ -############################################################################# -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # # Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. # -# In order to be useful for every potential user, curl and libcurl are -# dual-licensed under the MPL and the MIT/X-derivate licenses. +# 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 MPL or the MIT/X-derivate -# licenses. You may pick one of these licenses. +# 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. # # $Id$ -############################################################################# - +########################################################################### AUTOMAKE_OPTIONS = foreign nostdinc # $(top_srcdir)/include/curl is for the main curl include files, to make it -- cgit v1.2.1 From 3d99b566a639379e873721e9f29bd04a9df9a861 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 30 Jan 2004 09:26:23 +0000 Subject: added lib510.c for callback POST using chunked encoding --- tests/libtest/Makefile.am | 6 +++- tests/libtest/lib510.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib510.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 4c62a4a17..c636a0901 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -38,7 +38,7 @@ SUPPORTFILES = first.c test.h # here are all tools used for running libcurl tests noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 + lib508 lib509 lib510 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -79,3 +79,7 @@ lib508_DEPENDENCIES = $(LIBDIR)/libcurl.la lib509_SOURCES = lib509.c $(SUPPORTFILES) lib509_LDADD = $(LIBDIR)/libcurl.la lib509_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib510_SOURCES = lib510.c $(SUPPORTFILES) +lib510_LDADD = $(LIBDIR)/libcurl.la +lib510_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c new file mode 100644 index 000000000..1cf440bd3 --- /dev/null +++ b/tests/libtest/lib510.c @@ -0,0 +1,80 @@ +#include "test.h" + +static const char *post[]={ + "one", + "two", + "three", + "and a final longer crap: four", + NULL +}; + + +struct WriteThis { + int counter; +}; + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *)userp; + const char *data; + + if(size*nmemb < 1) + return 0; + + data = post[pooh->counter]; + + if(data) { + size_t len = strlen(data); + memcpy(ptr, data, len); + pooh->counter++; /* advance pointer */ + return len; + } + return 0; /* no more data left to deliver */ +} + +CURLcode test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + struct curl_slist *slist = NULL; + + struct WriteThis pooh; + pooh.counter = 0; + + slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* enforce chunked transfer by setting the header */ + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + + /* clean up the headers list */ + curl_slist_free_all(slist); + + } + return res; +} -- cgit v1.2.1 From a5c4442ebf63c3583ae7c2000376158e7efaf5e9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 5 Feb 2004 12:34:17 +0000 Subject: changed the test() function to return type int --- tests/libtest/first.c | 2 +- tests/libtest/lib501.c | 2 +- tests/libtest/lib502.c | 2 +- tests/libtest/lib503.c | 4 ++-- tests/libtest/lib504.c | 2 +- tests/libtest/lib505.c | 2 +- tests/libtest/lib506.c | 2 +- tests/libtest/lib507.c | 2 +- tests/libtest/lib508.c | 2 +- tests/libtest/lib509.c | 3 +-- tests/libtest/lib510.c | 2 +- 11 files changed, 12 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 6b9af9bcf..d8bfdd19a 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -6,7 +6,7 @@ extern void curl_memdebug(const char *); #endif /* test is provided in the test code file */ -CURLcode test(char *url); +int test(char *url); char *arg2=NULL; diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index 2ed1a9ae4..b0ff0a731 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -1,6 +1,6 @@ #include "test.h" -CURLcode test(char *URL) +int test(char *URL) { CURLcode res; CURL *curl = curl_easy_init(); diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 55ca6c5db..ac298f0fc 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -4,7 +4,7 @@ * Get a single URL without select(). */ -CURLcode test(char *URL) +int test(char *URL) { CURL *c; CURLM *m; diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index f324b35d6..f74ad3f38 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -14,7 +14,7 @@ * auth info. */ -CURLcode test(char *URL) +int test(char *URL) { CURL *c; CURLM *m; @@ -82,6 +82,6 @@ CURLcode test(char *URL) curl_easy_cleanup(c); curl_multi_cleanup(m); - return 0; + return CURLE_OK; } diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 0a9aff2cc..f2a202199 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -13,7 +13,7 @@ * Use multi interface to get document over proxy with bad port number. * This caused the interface to "hang" in libcurl 7.10.2. */ -CURLcode test(char *URL) +int test(char *URL) { CURL *c; CURLcode ret=CURLE_OK; diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 0efaf76cc..131df7856 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -34,7 +34,7 @@ * Example based on source code provided by Erick Nuwendam. Thanks! */ -CURLcode test(char *URL) +int test(char *URL) { CURL *curl; CURLcode res; diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 998c1370c..40f726178 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -127,7 +127,7 @@ char *suburl(char *base, int i) /* test function */ -CURLcode test(char *URL) +int test(char *URL) { CURLcode res; CURLSHcode scode; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 14004f3d9..f45169496 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -1,6 +1,6 @@ #include "test.h" -CURLcode test(char *URL) +int test(char *URL) { CURL* curls; CURLM* multi; diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index e6798da2e..6a826b7b0 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -24,7 +24,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) return -1; /* no more data left to deliver */ } -CURLcode test(char *URL) +int test(char *URL) { CURL *curl; CURLcode res=CURLE_OK; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index d9774d129..0f956ebfb 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -159,8 +159,7 @@ static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) return CURLE_OK ; } - -CURLcode test(char *URL) +int test(char *URL) { CURLM* multi; sslctxparm p; diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 1cf440bd3..051a773c5 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -32,7 +32,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) return 0; /* no more data left to deliver */ } -CURLcode test(char *URL) +int test(char *URL) { CURL *curl; CURLcode res=CURLE_OK; -- cgit v1.2.1 From 648c5b05c025a02ec81d933921552e06767c26a0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Feb 2004 08:25:48 +0000 Subject: Uninitialized variable set. --- tests/libtest/lib506.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 40f726178..91137fb97 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -87,7 +87,7 @@ void *fire(void *ptr) struct curl_slist *headers; struct Tdata *tdata = (struct Tdata*)ptr; CURL *curl = curl_easy_init(); - int i; + int i=0; headers = sethost(NULL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); -- cgit v1.2.1 From b440c6638fce6b90cd4d3210513c5f1679787607 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Feb 2004 08:28:00 +0000 Subject: return 'res' to better discover test failures and to stop compiler warnings about it never being used --- tests/libtest/lib502.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index ac298f0fc..0a852c998 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -28,6 +28,6 @@ int test(char *URL) curl_easy_cleanup(c); curl_multi_cleanup(m); - return 0; + return res; } -- cgit v1.2.1 From d25a0a1bc873a13976b545007b7e33a7295b9ad7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Feb 2004 12:17:42 +0000 Subject: return an int, not a CURLcode --- tests/libtest/lib504.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index f2a202199..7133fc6df 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -16,7 +16,7 @@ int test(char *URL) { CURL *c; - CURLcode ret=CURLE_OK; + int ret=0; CURLM *m; fd_set rd, wr, exc; CURLMcode res; -- cgit v1.2.1 From 12b71e422fe292ae2b6a006894fc3156c5a82322 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Feb 2004 12:18:34 +0000 Subject: return an int --- tests/libtest/lib506.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 91137fb97..91ccb4ab2 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -129,7 +129,7 @@ char *suburl(char *base, int i) /* test function */ int test(char *URL) { - CURLcode res; + int res; CURLSHcode scode; char *url; struct Tdata tdata; -- cgit v1.2.1 From debbcf81bb812b3170dc393296663bf9fac182e3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Feb 2004 07:57:31 +0000 Subject: ignore more --- tests/libtest/.cvsignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore index bec8bfc02..50dcefd47 100644 --- a/tests/libtest/.cvsignore +++ b/tests/libtest/.cvsignore @@ -2,4 +2,4 @@ .deps Makefile Makefile.in -lib50[0-9] +lib5[0-9][0-9] -- cgit v1.2.1 From 349a15b089aa588196bf52420b1d3a32de657206 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Feb 2004 12:59:57 +0000 Subject: provide a test() proto --- tests/libtest/test.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index b0b119e5b..481716e6f 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -19,4 +19,5 @@ #endif extern char *arg2; /* set by first.c to the argv[2] or NULL */ - +int test(char *URL); /* the actual test function provided by each individual + libXXX.c file */ -- cgit v1.2.1 From 134cb66129d1ad360ec50dda455886854b2a0cdd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Feb 2004 13:00:05 +0000 Subject: return int from test() --- tests/libtest/lib500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index f78ab5561..7cbc65e3f 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -1,6 +1,6 @@ #include "test.h" -CURLcode test(char *URL) +int test(char *URL) { CURLcode res; CURL *curl = curl_easy_init(); -- cgit v1.2.1 From fa8ecd3d53cabc747cf2930bc9c3710b39b92ec5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Feb 2004 13:00:33 +0000 Subject: typecast the type to an int on return --- tests/libtest/lib500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 7cbc65e3f..5943b5849 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -8,6 +8,6 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); res = curl_easy_perform(curl); curl_easy_cleanup(curl); - return res; + return (int)res; } -- cgit v1.2.1 From eebcf9094234c1d80e66b8ad21a158eecfdb185d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Feb 2004 13:03:04 +0000 Subject: provide protos to the functions to prevent warnings --- tests/libtest/lib506.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 91ccb4ab2..03acf9a10 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -7,6 +7,12 @@ const char *HOSTHEADER = "Host: www.host.foo.com"; const char *JAR = "log/jar506"; #define THREADS 2 +void lock(CURL *handle, curl_lock_data data, curl_lock_access access, + void *useptr ); +void unlock(CURL *handle, curl_lock_data data, void *useptr ); +struct curl_slist *sethost(struct curl_slist *headers); +void *fire(void *ptr); +char *suburl(char *base, int i); /* struct containing data of a thread */ struct Tdata { -- cgit v1.2.1 From 7729c63be04d6612126a991dd25507716babae0e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Feb 2004 15:39:06 +0000 Subject: fixed the no-ssl version to return int as well --- tests/libtest/lib509.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 0f956ebfb..d1f32e7c6 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -251,7 +251,7 @@ int test(char *URL) return i; } #else /* USE_SSLEAY */ -CURLcode test(char *URL) +int test(char *URL) { (void)URL; return CURLE_FAILED_INIT; -- cgit v1.2.1 From 8777ba7e42b342e13d9a39c5d6d331801cfab13b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 20 Feb 2004 08:51:43 +0000 Subject: include sys/select.h to prevent picky compiler warnings when using select() without proto --- tests/libtest/lib503.c | 3 +++ tests/libtest/lib504.c | 3 +++ tests/libtest/lib507.c | 7 +++++++ tests/libtest/lib509.c | 3 +++ 4 files changed, 16 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index f74ad3f38..2e4f74232 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -5,6 +5,9 @@ #endif #include #include +#ifdef HAVE_SYS_SELECT_H +#include +#endif /* * Source code in here hugely as reported in bug report 651460 by diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 7133fc6df..269c1a231 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -5,6 +5,9 @@ #endif #include #include +#ifdef HAVE_SYS_SELECT_H +#include +#endif /* * Source code in here hugely as reported in bug report 651464 by diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index f45169496..89591f483 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -1,5 +1,12 @@ #include "test.h" +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif + int test(char *URL) { CURL* curls; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index d1f32e7c6..84c4ee5de 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -7,6 +7,9 @@ #endif #include #include +#ifdef HAVE_SYS_SELECT_H +#include +#endif #include #include -- cgit v1.2.1 From b2cff76722152f48d3774939ae5e3b6824797032 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 25 Feb 2004 15:43:15 +0000 Subject: typecast to int when printfing CURLcode --- tests/libtest/lib506.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 03acf9a10..037b87532 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -106,7 +106,7 @@ void *fire(void *ptr) code = curl_easy_perform(curl); if( code != CURLE_OK ) { fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n", - tdata->url, i, code); + tdata->url, i, (int)code); } printf( "CLEANUP\n" ); -- cgit v1.2.1 From 6e3fa90c9e69541990f2da44a1cb7911886feea7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Mar 2004 10:09:16 +0000 Subject: We let this file include more generic headers that many libtests need anyway to reduce the amount of #include stuff in each single libNNN.c file. unistd.h was added to prevent select() warnings on FreeBSD --- tests/libtest/test.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 481716e6f..f0e13b20f 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -10,6 +10,18 @@ #include #include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +/* since so many tests use select(), we can just as well include it here */ +#include +#endif +#ifdef HAVE_UNISTD_H +/* at least somewhat oldish FreeBSD systems need this for select() */ +#include +#endif + #ifndef FALSE #define FALSE 0 #endif -- cgit v1.2.1 From 87a1c7033eba20fc91cb4a5b0b96fb2f6f301ad1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Mar 2004 10:09:30 +0000 Subject: removed include stuff now handled by test.h --- tests/libtest/lib503.c | 6 ------ tests/libtest/lib504.c | 6 ------ tests/libtest/lib507.c | 7 ------- tests/libtest/lib509.c | 6 ------ 4 files changed, 25 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 2e4f74232..e2bd42145 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -1,13 +1,7 @@ #include "test.h" -#ifdef HAVE_SYS_SOCKET_H -#include -#endif #include #include -#ifdef HAVE_SYS_SELECT_H -#include -#endif /* * Source code in here hugely as reported in bug report 651460 by diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 269c1a231..bfffd3971 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -1,13 +1,7 @@ #include "test.h" -#ifdef HAVE_SYS_SOCKET_H -#include -#endif #include #include -#ifdef HAVE_SYS_SELECT_H -#include -#endif /* * Source code in here hugely as reported in bug report 651464 by diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 89591f483..f45169496 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -1,12 +1,5 @@ #include "test.h" -#ifdef HAVE_SYS_SOCKET_H -#include -#endif -#ifdef HAVE_SYS_SELECT_H -#include -#endif - int test(char *URL) { CURL* curls; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 84c4ee5de..b6e9ca6dd 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -2,14 +2,8 @@ #ifdef USE_SSLEAY -#ifdef HAVE_SYS_SOCKET_H -#include -#endif #include #include -#ifdef HAVE_SYS_SELECT_H -#include -#endif #include #include -- cgit v1.2.1 From f8ff0f6befc92288a83b109ef3a61d82d48f3140 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 12 Mar 2004 12:05:33 +0000 Subject: minor variable type fix --- tests/libtest/lib508.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 6a826b7b0..ddec600b0 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -4,7 +4,7 @@ static char data[]="this is what we post to the silly web server\n"; struct WriteThis { char *readptr; - int sizeleft; + size_t sizeleft; }; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) @@ -43,7 +43,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_POST, TRUE); /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); -- cgit v1.2.1 From 4e84ac4db84db4cea763569953d23c5a298fb6bf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 23 Mar 2004 08:46:08 +0000 Subject: minor edits to make picky compilers whine less --- tests/libtest/lib506.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 037b87532..943d9a9aa 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -46,7 +46,7 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, what = "cookie"; break; default: - fprintf(stderr, "lock: no such data: %d\n",data); + fprintf(stderr, "lock: no such data: %d\n", (int)data); return; } printf("lock: %-6s <%s>: %d\n", what, user->text, user->counter); @@ -70,7 +70,7 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr ) what = "cookie"; break; default: - fprintf(stderr, "unlock: no such data: %d\n",data); + fprintf(stderr, "unlock: no such data: %d\n", (int)data); return; } printf("unlock: %-6s <%s>: %d\n", what, user->text, user->counter); @@ -120,7 +120,7 @@ void *fire(void *ptr) /* build request url */ char *suburl(char *base, int i) { - int len = strlen(base); + size_t len = strlen(base); char *url = (char *)malloc(len+5); if (!url) { abort(); @@ -218,9 +218,8 @@ int test(char *URL) printf( "SHARE_CLEANUP\n" ); scode = curl_share_cleanup( share ); if ( scode!=CURLSHE_OK ) - { - fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", scode); - } + fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", + (int)scode); printf( "GLOBAL_CLEANUP\n" ); curl_global_cleanup(); -- cgit v1.2.1 From aba6c2b89d96f661c2b4d77fc925b47921008e3d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 14 Apr 2004 06:30:37 +0000 Subject: Added test case 511 in an attempt to repeat bug report #934666 "storage leak in ftp.c", but it shows no leaking. --- tests/libtest/Makefile.am | 9 +++++++-- tests/libtest/lib511.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/lib511.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c636a0901..a62ab5114 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -34,11 +34,12 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib +# these files are used in every single test program below SUPPORTFILES = first.c test.h -# here are all tools used for running libcurl tests +# These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 + lib508 lib509 lib510 lib511 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -83,3 +84,7 @@ lib509_DEPENDENCIES = $(LIBDIR)/libcurl.la lib510_SOURCES = lib510.c $(SUPPORTFILES) lib510_LDADD = $(LIBDIR)/libcurl.la lib510_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib511_SOURCES = lib511.c $(SUPPORTFILES) +lib511_LDADD = $(LIBDIR)/libcurl.la +lib511_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c new file mode 100644 index 000000000..9b9980a71 --- /dev/null +++ b/tests/libtest/lib511.c @@ -0,0 +1,14 @@ +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_FILETIME, 1); + curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return (int)res; +} + -- cgit v1.2.1 From c3dd928e29aca65ae38ece892c6801f0bd294088 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 14 Apr 2004 06:53:34 +0000 Subject: enable verbose as well --- tests/libtest/lib511.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 9b9980a71..4afb1dc9f 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -7,6 +7,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_FILETIME, 1); curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); res = curl_easy_perform(curl); curl_easy_cleanup(curl); return (int)res; -- cgit v1.2.1 From 2f53da5e7ae16fc66c87ed479c8cdc20cb6305fd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 27 Apr 2004 10:59:43 +0000 Subject: make the loop use a fixed number of attempts to prevent eternal loops --- tests/libtest/lib504.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index bfffd3971..5f2c6acfc 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -20,6 +20,7 @@ int test(char *URL) int running; int max_fd; int rc; + int loop=100; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -78,7 +79,9 @@ int test(char *URL) rc = select(max_fd+1, &rd, &wr, &exc, &interval); fprintf(stderr, "select returned %d\n", rc); - } while(rc); + /* we only allow a certain number of loops to avoid hanging here + forever */ + } while(rc && (--loop>0)); curl_multi_remove_handle(m, c); curl_easy_cleanup(c); -- cgit v1.2.1 From 707f217b2d52ebaa9d5973ef701fb465c2ba057d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 29 Apr 2004 10:56:22 +0000 Subject: new test case for a simple curl_easy_duphandle() test --- tests/libtest/Makefile.am | 6 +++++- tests/libtest/lib512.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib512.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a62ab5114..1fd9cd4be 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 + lib508 lib509 lib510 lib511 lib512 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -88,3 +88,7 @@ lib510_DEPENDENCIES = $(LIBDIR)/libcurl.la lib511_SOURCES = lib511.c $(SUPPORTFILES) lib511_LDADD = $(LIBDIR)/libcurl.la lib511_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib512_SOURCES = lib512.c $(SUPPORTFILES) +lib512_LDADD = $(LIBDIR)/libcurl.la +lib512_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c new file mode 100644 index 000000000..9c8c8e63e --- /dev/null +++ b/tests/libtest/lib512.c @@ -0,0 +1,41 @@ +#include "test.h" + +/* Test case code based on source in a bug report filed by James Bursa on + 28 Apr 2004 */ + +int test(char *URL) +{ + CURLcode code; + CURL *curl; + CURL *curl2; + + code = curl_global_init(CURL_GLOBAL_ALL); + if(code != CURLE_OK) + return 1; + + curl = curl_easy_init(); + if(!curl) + return 2; + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + + curl2 = curl_easy_duphandle(curl); + if(!curl2) + return 3; + + code = curl_easy_setopt(curl2, CURLOPT_URL, URL); + if(code != CURLE_OK) + return 4; + + code = curl_easy_perform(curl2); + if(code != CURLE_OK) + return 5; + + curl_easy_cleanup(curl2); + + curl_easy_cleanup(curl); + + return 0; +} + -- cgit v1.2.1 From 58387b91f93a1b439c851813e5ac131375a57f84 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 May 2004 10:57:07 +0000 Subject: printf %s with plain 'char *', not unsigned ones to silence icc's picky warnings --- tests/libtest/lib509.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index b6e9ca6dd..54d23e972 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -110,7 +110,7 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) if (strcmp((char *)p->accessinfoURL, (char *)accessinfoURL)) { fprintf(stderr, "Setting URL <%s>, was <%s>\n", - accessinfoURL,p->accessinfoURL); + (char *)accessinfoURL, (char *)p->accessinfoURL); OPENSSL_free(p->accessinfoURL); p->accessinfoURL = accessinfoURL; curl_easy_setopt(p->curl, CURLOPT_URL,p->accessinfoURL); @@ -179,7 +179,7 @@ int test(char *URL) curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYHOST, 1); - fprintf(stderr,"Going to perform %s\n",p.accessinfoURL); + fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL); { CURLMcode res; -- cgit v1.2.1 From 84b52e92f4b1394851af28eeb15fca6beac56246 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 May 2004 13:29:04 +0000 Subject: simplied the creation of new urls --- tests/libtest/lib506.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 943d9a9aa..22f5d0698 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -3,6 +3,8 @@ #include #include +#include + const char *HOSTHEADER = "Host: www.host.foo.com"; const char *JAR = "log/jar506"; #define THREADS 2 @@ -120,15 +122,7 @@ void *fire(void *ptr) /* build request url */ char *suburl(char *base, int i) { - size_t len = strlen(base); - char *url = (char *)malloc(len+5); - if (!url) { - abort(); - } - strcpy(url, base); - strcat(url, "0000"); - url[len+3] = 48+i; - return url; + return curl_maprintf("%s000%c", base, 48+i); } @@ -168,14 +162,14 @@ int test(char *URL) for (i=1; i<=THREADS; i++ ) { /* set thread data */ - tdata.url = suburl( URL, i ); /* must be freed */ + tdata.url = suburl( URL, i ); /* must be curl_free()d */ tdata.share = share; /* simulate thread, direct call of "thread" function */ printf( "*** run %d\n",i ); fire( &tdata ); - free( tdata.url ); + curl_free( tdata.url ); } @@ -211,8 +205,8 @@ int test(char *URL) printf( "CLEANUP\n" ); curl_easy_cleanup( curl ); curl_slist_free_all( headers ); - free(url); - + + curl_free(url); /* free share */ printf( "SHARE_CLEANUP\n" ); -- cgit v1.2.1 From 4ab0d74250b3a69e3980ca961b9867bf365580ab Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 14 May 2004 08:40:33 +0000 Subject: enable memory debugging the same way the curl command line tool already does --- tests/libtest/first.c | 19 ++++++++++++++++--- tests/libtest/test.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index d8bfdd19a..c4f35df22 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -3,6 +3,7 @@ #ifdef CURLDEBUG /* provide a proto for this debug function */ extern void curl_memdebug(const char *); +extern void curl_memlimit(int); #endif /* test is provided in the test code file */ @@ -13,6 +14,21 @@ char *arg2=NULL; 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"); + if(env) { + curl_free(env); + curl_memdebug("memdump"); + } + /* this enables the fail-on-alloc-number-N functionality */ + env = curl_getenv("CURL_MEMLIMIT"); + if(env) { + curl_memlimit(atoi(env)); + curl_free(env); + } +#endif if(argc< 2 ) { fprintf(stderr, "Pass URL as argument please\n"); return 1; @@ -24,8 +40,5 @@ int main(int argc, char **argv) fprintf(stderr, "URL: %s\n", URL); -#ifdef CURLDEBUG - curl_memdebug("memdump"); -#endif return test(URL); } diff --git a/tests/libtest/test.h b/tests/libtest/test.h index f0e13b20f..a442ba4bd 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From e2e593a036c992f2d38e060e14b52c4a8862ca2d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 14 May 2004 09:22:12 +0000 Subject: clean up properly on failure to enable easier libcurl leak detection --- tests/libtest/lib503.c | 2 +- tests/libtest/lib504.c | 82 ++++++++++++++++++++++++++------------------------ tests/libtest/lib505.c | 9 ++++-- tests/libtest/lib506.c | 16 +++++++--- tests/libtest/lib507.c | 7 +++-- 5 files changed, 65 insertions(+), 51 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index e2bd42145..59cf4e655 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -54,7 +54,7 @@ int test(char *URL) if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); - return 80; + break; } FD_ZERO(&rd); diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 5f2c6acfc..df2e3ff2c 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -35,53 +35,55 @@ int test(char *URL) res = curl_multi_add_handle(m, c); if(res && (res != CURLM_CALL_MULTI_PERFORM)) - return 1; /* major failure */ - do { - struct timeval interval; + ; /* major failure */ + else { + do { + struct timeval interval; - interval.tv_sec = 1; - interval.tv_usec = 0; + interval.tv_sec = 1; + interval.tv_usec = 0; - fprintf(stderr, "curl_multi_perform()\n"); + fprintf(stderr, "curl_multi_perform()\n"); - do { - res = curl_multi_perform(m, &running); - } while (res == CURLM_CALL_MULTI_PERFORM); - if(!running) { - /* This is where this code is expected to reach */ - int numleft; - CURLMsg *msg = curl_multi_info_read(m, &numleft); - fprintf(stderr, "Expected: not running\n"); - if(msg && !numleft) - ret = 100; /* this is where we should be */ - else - ret = 99; /* not correct */ - break; - } - fprintf(stderr, "running == %d, res == %d\n", running, res); + do { + res = curl_multi_perform(m, &running); + } while (res == CURLM_CALL_MULTI_PERFORM); + if(!running) { + /* This is where this code is expected to reach */ + int numleft; + CURLMsg *msg = curl_multi_info_read(m, &numleft); + fprintf(stderr, "Expected: not running\n"); + if(msg && !numleft) + ret = 100; /* this is where we should be */ + else + ret = 99; /* not correct */ + break; + } + fprintf(stderr, "running == %d, res == %d\n", running, res); - if (res != CURLM_OK) { - ret = 2; - break; - } + if (res != CURLM_OK) { + ret = 2; + break; + } - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&exc); - max_fd = 0; + 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"); - ret = 3; - break; - } - rc = select(max_fd+1, &rd, &wr, &exc, &interval); - fprintf(stderr, "select returned %d\n", rc); + 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"); + ret = 3; + break; + } + rc = select(max_fd+1, &rd, &wr, &exc, &interval); + fprintf(stderr, "select returned %d\n", rc); - /* we only allow a certain number of loops to avoid hanging here - forever */ - } while(rc && (--loop>0)); + /* we only allow a certain number of loops to avoid hanging here + forever */ + } while(rc && (--loop>0)); + } curl_multi_remove_handle(m, c); curl_easy_cleanup(c); diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 131df7856..62c7b6880 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -72,9 +72,14 @@ int test(char *URL) /* get a curl handle */ curl = curl_easy_init(); if(curl) { + struct curl_slist *hl; /* build a list of commands to pass to libcurl */ - headerlist = curl_slist_append(headerlist, buf_1); - headerlist = curl_slist_append(headerlist, buf_2); + hl = curl_slist_append(headerlist, buf_1); + if(hl) { + headerlist = curl_slist_append(hl, buf_2); + if(hl) + headerlist = hl; + } /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 22f5d0698..52a4094a2 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -148,13 +148,19 @@ int test(char *URL) /* prepare share */ printf( "SHARE_INIT\n" ); share = curl_share_init(); - curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); - curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); - curl_share_setopt( share, CURLSHOPT_USERDATA, &user); + scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); + scode += curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); + scode += curl_share_setopt( share, CURLSHOPT_USERDATA, &user); printf( "CURL_LOCK_DATA_COOKIE\n" ); - curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + scode += curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); printf( "CURL_LOCK_DATA_DNS\n" ); - curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + scode += curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + + if(scode) { + curl_share_cleanup(share); + return 2; + } + res = 0; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index f45169496..b16c23368 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -39,9 +39,10 @@ int test(char *URL) } } msg = curl_multi_info_read(multi, &still_running); - /* this should now contain a result code from the easy handle, - get it */ - i = msg->data.result; + if(msg) + /* this should now contain a result code from the easy handle, + get it */ + i = msg->data.result; curl_multi_cleanup(multi); curl_easy_cleanup(curls); -- cgit v1.2.1 From eb946690d2c0c8f7fcae6b190651029830fa29e9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 May 2004 06:55:04 +0000 Subject: make it not leak memory when it returns prematurely --- tests/libtest/lib509.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 54d23e972..41508ea56 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -161,7 +161,7 @@ int test(char *URL) CURLM* multi; sslctxparm p; - int i; + int i = 0; CURLMsg *msg; curl_global_init(CURL_GLOBAL_ALL); @@ -211,7 +211,8 @@ int test(char *URL) if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); - return 80; + i = 80; + break; } FD_ZERO(&rd); @@ -221,19 +222,22 @@ int test(char *URL) if (curl_multi_fdset(multi, &rd, &wr, &exc, &max_fd) != CURLM_OK) { fprintf(stderr, "unexpected failured of fdset.\n"); - return 89; + i = 89; + break; } if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); - return 95; + i =95; + break; } res = CURLM_CALL_MULTI_PERFORM; } msg = curl_multi_info_read(multi, &running); /* this should now contain a result code from the easy handle, get it */ - i = msg->data.result; + if(msg) + i = msg->data.result; } fprintf(stderr, "all done\n"); -- cgit v1.2.1 From 0383f7f19dfdb8ad66797a338aa95fe7b3287d83 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 May 2004 07:45:20 +0000 Subject: modified to not leak memory if a libcurl function returns failure, for better memory leak detection --- tests/libtest/lib510.c | 4 +++- tests/libtest/lib512.c | 65 +++++++++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 28 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 051a773c5..4dfdbd962 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -72,9 +72,11 @@ int test(char *URL) /* always cleanup */ curl_easy_cleanup(curl); + } + + if(slist) /* clean up the headers list */ curl_slist_free_all(slist); - } return res; } diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index 9c8c8e63e..d52baa6d0 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -8,34 +8,45 @@ int test(char *URL) CURLcode code; CURL *curl; CURL *curl2; + int rc = 99; code = curl_global_init(CURL_GLOBAL_ALL); - if(code != CURLE_OK) - return 1; - - curl = curl_easy_init(); - if(!curl) - return 2; - - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_HEADER, 1); - - curl2 = curl_easy_duphandle(curl); - if(!curl2) - return 3; - - code = curl_easy_setopt(curl2, CURLOPT_URL, URL); - if(code != CURLE_OK) - return 4; - - code = curl_easy_perform(curl2); - if(code != CURLE_OK) - return 5; - - curl_easy_cleanup(curl2); - - curl_easy_cleanup(curl); - - return 0; + if(code == CURLE_OK) { + + curl = curl_easy_init(); + if(curl) { + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + + curl2 = curl_easy_duphandle(curl); + if(curl2) { + + code = curl_easy_setopt(curl2, CURLOPT_URL, URL); + if(code == CURLE_OK) { + + code = curl_easy_perform(curl2); + if(code == CURLE_OK) + rc = 0; + else + rc = 1; + } + else + rc = 2; + + curl_easy_cleanup(curl2); + } + else + rc = 3; + + curl_easy_cleanup(curl); + } + else + rc = 4; + } + else + rc = 5; + + return rc; } -- cgit v1.2.1 From 7e186f9a63209136b2069d92aef83ed844a4215a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 19 May 2004 09:24:18 +0000 Subject: just code formatting and killed whitespace --- tests/libtest/lib509.c | 68 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 41508ea56..eabddacee 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -20,21 +20,21 @@ typedef struct sslctxparm_st { - CURL* curl; - int accesstype ; - unsigned char * accessinfoURL ; - + CURL* curl; + int accesstype; + unsigned char * accessinfoURL; } sslctxparm; static unsigned char *i2s_ASN1_IA5STRING( ASN1_IA5STRING *ia5) { - unsigned char *tmp; - if(!ia5 || !ia5->length) return NULL; - tmp = OPENSSL_malloc(ia5->length + 1); - memcpy(tmp, ia5->data, ia5->length); - tmp[ia5->length] = 0; - return tmp; + unsigned char *tmp; + if(!ia5 || !ia5->length) + return NULL; + tmp = OPENSSL_malloc(ia5->length + 1); + memcpy(tmp, ia5->data, ia5->length); + tmp[ia5->length] = 0; + return tmp; } /* A conveniance routine to get an access URI. */ @@ -45,10 +45,10 @@ static unsigned char *my_get_ext(X509 * cert, const int type, int i; STACK_OF(ACCESS_DESCRIPTION) * accessinfo ; accessinfo = X509_get_ext_d2i(cert, extensiontype, NULL, NULL) ; - + if (!sk_ACCESS_DESCRIPTION_num(accessinfo)) return NULL; - + for (i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) { ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i); if (OBJ_obj2nid(ad->method) == type) { @@ -57,7 +57,7 @@ static unsigned char *my_get_ext(X509 * cert, const int type, } return NULL; } - } + } return NULL; } @@ -73,16 +73,16 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) #if OPENSSL_VERSION_NUMBER<0x00907000L /* not necessary in openssl 0.9.7 or later */ - + fprintf(stderr,"This version %s of openssl does not support a parm (%p)" ", getting a global static %p \n", OPENSSL_VERSION_TEXT, (void *)p, (void *)globalparm); - + p = globalparm; #endif /* The following error should not occur. We test this to avoid segfault. */ - if (!p || !ctx) { + if (!p || !ctx) { fprintf(stderr,"Internal error in ssl_app_verify_callback " "sslctxparm=%p ctx=%p\n",(void *)p,(void*)ctx); return 0; @@ -96,7 +96,7 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) #if 1 if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT || err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { - fprintf(stderr,"X509_verify_cert: repairing self signed\n") ; + fprintf(stderr,"X509_verify_cert: repairing self signed\n") ; X509_STORE_CTX_set_error(ctx,X509_V_OK); ok = 1; } @@ -104,20 +104,20 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) if (ok && ctx->cert) { unsigned char * accessinfoURL ; - + accessinfoURL = my_get_ext(ctx->cert,p->accesstype ,NID_info_access); if (accessinfoURL) { - if (strcmp((char *)p->accessinfoURL, (char *)accessinfoURL)) { + if (strcmp((char *)p->accessinfoURL, (char *)accessinfoURL)) { fprintf(stderr, "Setting URL <%s>, was <%s>\n", (char *)accessinfoURL, (char *)p->accessinfoURL); OPENSSL_free(p->accessinfoURL); p->accessinfoURL = accessinfoURL; curl_easy_setopt(p->curl, CURLOPT_URL,p->accessinfoURL); } - else + else OPENSSL_free(accessinfoURL); - } + } } return(ok); } @@ -126,11 +126,11 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) { sslctxparm * p = (sslctxparm *) parm; - + SSL_CTX * ctx = (SSL_CTX *) sslctx ; fprintf(stderr,"sslctxfun start curl=%p ctx=%p parm=%p\n", (void *)curl,(void *)ctx,(void *)p); - + SSL_CTX_set_quiet_shutdown(ctx,1); SSL_CTX_set_cipher_list(ctx,"RC4-MD5"); SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); @@ -139,7 +139,7 @@ static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) but it still does, see the error handling in the call back */ SSL_CTX_set_verify_depth(ctx,0); - SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL); + SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL); #if OPENSSL_VERSION_NUMBER<0x00907000L /* in newer openssl versions we can set a parameter for the call back. */ @@ -148,9 +148,9 @@ static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) /* this is only done to support 0.9.6 version */ globalparm = parm; -/* in 0.9.6 the parm is not taken */ +/* in 0.9.6 the parm is not taken */ #endif - SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm); + SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm); fprintf(stderr,"sslctxfun end\n"); return CURLE_OK ; @@ -166,17 +166,17 @@ int test(char *URL) curl_global_init(CURL_GLOBAL_ALL); - p.curl = curl_easy_init(); + p.curl = curl_easy_init(); p.accessinfoURL = (unsigned char *) strdup(URL); p.accesstype = OBJ_obj2nid(OBJ_txt2obj("AD_DVCS",0)) ; - + curl_easy_setopt(p.curl, CURLOPT_URL, p.accessinfoURL); - curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun) ; - curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p); + curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun) ; + curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p); - curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYHOST, 1); fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL); @@ -208,7 +208,7 @@ int test(char *URL) } if(done) break; - + if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); i = 80; @@ -246,10 +246,10 @@ int test(char *URL) curl_easy_cleanup(p.curl); curl_multi_cleanup(multi); - curl_global_cleanup(); + curl_global_cleanup(); free(p.accessinfoURL); - return i; + return i; } #else /* USE_SSLEAY */ int test(char *URL) -- cgit v1.2.1 From 7291772b1f62b858a7b15182aacc75f8bebe9e77 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 21 Jun 2004 14:08:48 +0000 Subject: added test case 513 --- tests/libtest/Makefile.am | 6 +++++- tests/libtest/lib513.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib513.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 1fd9cd4be..d659cca1b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 + lib508 lib509 lib510 lib511 lib512 lib513 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -92,3 +92,7 @@ lib511_DEPENDENCIES = $(LIBDIR)/libcurl.la lib512_SOURCES = lib512.c $(SUPPORTFILES) lib512_LDADD = $(LIBDIR)/libcurl.la lib512_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib513_SOURCES = lib513.c $(SUPPORTFILES) +lib513_LDADD = $(LIBDIR)/libcurl.la +lib513_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c new file mode 100644 index 000000000..3d886dd61 --- /dev/null +++ b/tests/libtest/lib513.c @@ -0,0 +1,47 @@ +#include "test.h" + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +{ + (void)ptr; + (void)size; + (void)nmemb; + (void)userp; + return CURL_READFUNC_ABORT; +} + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); + + /* Set the expected POST size */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1); + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, NULL); + + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return (int)res; +} -- cgit v1.2.1 From 185baf036b9bcfe1386a6fd1549ca5403ec66812 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 30 Jun 2004 11:09:16 +0000 Subject: NOBODY set TRUE after a POST makes a good HEAD now --- tests/libtest/Makefile.am | 6 +++++- tests/libtest/lib514.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib514.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index d659cca1b..688c7a4b2 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 + lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -96,3 +96,7 @@ lib512_DEPENDENCIES = $(LIBDIR)/libcurl.la lib513_SOURCES = lib513.c $(SUPPORTFILES) lib513_LDADD = $(LIBDIR)/libcurl.la lib513_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib514_SOURCES = lib514.c $(SUPPORTFILES) +lib514_LDADD = $(LIBDIR)/libcurl.la +lib514_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c new file mode 100644 index 000000000..7100fd8a5 --- /dev/null +++ b/tests/libtest/lib514.c @@ -0,0 +1,43 @@ +#include "test.h" + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Based on a bug report by Niels van Tongeren on June 29, 2004: + + A weird situation occurs when request 1 is a POST request and the request + 2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS, + CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we + set the CURLOPT_NOBODY option to '1'. + + */ + + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3); + curl_easy_setopt(curl, CURLOPT_POST, 1); + + /* this is where transfer 1 would take place, but skip that and change + options right away instead */ + + curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a fine HEAD request */ + + /* Perform the request 2, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return (int)res; +} -- cgit v1.2.1 From 0c54013ee374a92960c32011c16278e799f58dbf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 14 Jul 2004 14:20:53 +0000 Subject: An Andres Garcia fix: add a typecast to make it work better --- tests/libtest/lib505.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 62c7b6880..10aa1ab19 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -1,8 +1,8 @@ /***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * $Id$ @@ -59,7 +59,7 @@ int test(char *URL) } /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just + fdopen() from the previous descriptor, but hey this is just an example! */ hd_src = fopen(arg2, "rb"); if(NULL == hd_src) { @@ -98,7 +98,7 @@ int test(char *URL) /* and give the size of the upload (optional) */ curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, - file_info.st_size); + (curl_off_t)file_info.st_size); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); -- cgit v1.2.1 From 2b1673c9c83f693fdf243607f9141e5e897e0ba8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 8 Sep 2004 08:08:38 +0000 Subject: Now the test servers and test cases can run on a custom port number. There's no fixed port numbers in use anymore. Starting now, the default ports the servers use are 8990 - 8993. There's no option to modify these yet, but changing the $base option in the top of the runtests.pl script. --- tests/libtest/lib509.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index eabddacee..9e535e9b6 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -18,6 +18,7 @@ #include #include +int portnum; /* the HTTPS port number we use */ typedef struct sslctxparm_st { CURL* curl; @@ -63,6 +64,8 @@ static unsigned char *my_get_ext(X509 * cert, const int type, void * globalparm = NULL; +char newurl[512]; + static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) { sslctxparm * p = (sslctxparm *) arg; @@ -113,7 +116,15 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) (char *)accessinfoURL, (char *)p->accessinfoURL); OPENSSL_free(p->accessinfoURL); p->accessinfoURL = accessinfoURL; - curl_easy_setopt(p->curl, CURLOPT_URL,p->accessinfoURL); + + /* We need to be able to deal with a custom port number, but the + URL in the cert uses a static one. We thus need to create a new + URL that uses the currently requested port number which may not + be the one this URL uses! */ + sprintf(newurl, "https://localhost:%d/509", portnum); + fprintf(stderr, "But *really* Setting URL <%s>\n", newurl); + + curl_easy_setopt(p->curl, CURLOPT_URL, newurl); } else OPENSSL_free(accessinfoURL); @@ -164,6 +175,10 @@ int test(char *URL) int i = 0; CURLMsg *msg; + if(arg2) { + portnum = atoi(arg2); + } + curl_global_init(CURL_GLOBAL_ALL); p.curl = curl_easy_init(); -- cgit v1.2.1 From 23550fe5def6db95598d877464f7a41465ee37c0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 22 Sep 2004 18:21:45 +0000 Subject: Dan Fandrich's fix to use 127.0.0.1 instead of localhost to not depend on it resolving nicely --- tests/libtest/lib509.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 9e535e9b6..d20c31524 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -121,7 +121,7 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) URL in the cert uses a static one. We thus need to create a new URL that uses the currently requested port number which may not be the one this URL uses! */ - sprintf(newurl, "https://localhost:%d/509", portnum); + sprintf(newurl, "https://127.0.0.1:%d/509", portnum); fprintf(stderr, "But *really* Setting URL <%s>\n", newurl); curl_easy_setopt(p->curl, CURLOPT_URL, newurl); -- cgit v1.2.1 From e2fe03df8ed10f1454888af03413f5c554095eec Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 3 Oct 2004 08:15:40 +0000 Subject: removed trailing whitespace --- tests/libtest/lib503.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 59cf4e655..aeb85db36 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -51,7 +51,7 @@ int test(char *URL) } if(done) break; - + if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); break; @@ -78,7 +78,7 @@ int test(char *URL) curl_multi_remove_handle(m, c); curl_easy_cleanup(c); curl_multi_cleanup(m); - + return CURLE_OK; } -- cgit v1.2.1 From 59c063dfd38972e06a7f3a0b8f94860a67acdc96 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Nov 2004 23:11:04 +0000 Subject: Fix behaviour when passing NULL to CURLOPT_POSTFIELDS and CURLOPT_HTTPPOST. --- tests/libtest/Makefile.am | 10 +++++++++- tests/libtest/lib515.c | 24 ++++++++++++++++++++++++ tests/libtest/lib516.c | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib515.c create mode 100644 tests/libtest/lib516.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 688c7a4b2..06fbe5519 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 lib514 + lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -100,3 +100,11 @@ lib513_DEPENDENCIES = $(LIBDIR)/libcurl.la lib514_SOURCES = lib514.c $(SUPPORTFILES) lib514_LDADD = $(LIBDIR)/libcurl.la lib514_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib515_SOURCES = lib515.c $(SUPPORTFILES) +lib515_LDADD = $(LIBDIR)/libcurl.la +lib515_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib516_SOURCES = lib516.c $(SUPPORTFILES) +lib516_LDADD = $(LIBDIR)/libcurl.la +lib516_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c new file mode 100644 index 000000000..ce075110d --- /dev/null +++ b/tests/libtest/lib515.c @@ -0,0 +1,24 @@ +#include "test.h" + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a zero byte POST request */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return (int)res; +} diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c new file mode 100644 index 000000000..6e71fb4bb --- /dev/null +++ b/tests/libtest/lib516.c @@ -0,0 +1,23 @@ +#include "test.h" + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a zero byte POST request */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return (int)res; +} -- cgit v1.2.1 From 66f6f430567526305c6fcc8c4ec2ae19f4a84e08 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 15 Nov 2004 21:49:35 +0000 Subject: added test case 517: 22 tests of the curl_getdate() function --- tests/libtest/Makefile.am | 6 +++++- tests/libtest/lib517.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib517.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 06fbe5519..923652065 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 + lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -108,3 +108,7 @@ lib515_DEPENDENCIES = $(LIBDIR)/libcurl.la lib516_SOURCES = lib516.c $(SUPPORTFILES) lib516_LDADD = $(LIBDIR)/libcurl.la lib516_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib517_SOURCES = lib517.c $(SUPPORTFILES) +lib517_LDADD = $(LIBDIR)/libcurl.la +lib517_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c new file mode 100644 index 000000000..ea296914f --- /dev/null +++ b/tests/libtest/lib517.c @@ -0,0 +1,41 @@ +#include "test.h" + +const char *dates[]={ + "Sun, 06 Nov 1994 08:49:37 GMT", + "Sunday, 06-Nov-94 08:49:37 GMT", + "Sun Nov 6 08:49:37 1994", + "06 Nov 1994 08:49:37 GMT", + "06-Nov-94 08:49:37 GMT", + "Nov 6 08:49:37 1994", + "06 Nov 1994 08:49:37", + "06-Nov-94 08:49:37", + "1994 Nov 6 08:49:37", + "GMT 08:49:37 06-Nov-94 Sunday", + "94 6 Nov 08:49:37", + "1994 Nov 6", + "06-Nov-94", + "Sun Nov 6 94", + "1994.Nov.6", + "Sun/Nov/6/94/GMT", + "Sun, 06 Nov 1994 08:49:37 CET", + "06 Nov 1994 08:49:37 EST", + "Sun, 12 Sep 2004 15:05:58 -0700", + "Sat, 11 Sep 2004 21:32:11 +0200", + "20040912 15:05:58 -0700", + "20040911 +0200", + "2094 Nov 6", + NULL +}; + +int test(char *URL) +{ + int i; + + (void)URL; /* not used */ + + for(i=0; dates[i]; i++) { + printf("%d: %s => %ld\n", i, dates[i], (long)curl_getdate(dates[i], NULL)); + } + + return 0; +} -- cgit v1.2.1 From 1a05a90f1ce86394d7966aaaa9539adaa228c6bf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 19 Nov 2004 08:52:33 +0000 Subject: David Phillips' FD_SETSIZE fix --- tests/libtest/Makefile.am | 7 ++++++- tests/libtest/lib518.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib518.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 923652065..f394ec14b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,7 +39,8 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 + lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ + lib518 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -112,3 +113,7 @@ lib516_DEPENDENCIES = $(LIBDIR)/libcurl.la lib517_SOURCES = lib517.c $(SUPPORTFILES) lib517_LDADD = $(LIBDIR)/libcurl.la lib517_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib518_SOURCES = lib518.c $(SUPPORTFILES) +lib518_LDADD = $(LIBDIR)/libcurl.la +lib518_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c new file mode 100644 index 000000000..f12bca6de --- /dev/null +++ b/tests/libtest/lib518.c @@ -0,0 +1,47 @@ +#include "test.h" + +#include +#include +#include + +#include + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifndef FD_SETSIZE +#error "this test requires FD_SETSIZE" +#endif + +#define NUM_OPEN (FD_SETSIZE + 10) + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + int fd[NUM_OPEN]; + int i; + + /* open a lot of file descriptors */ + for (i = 0; i < NUM_OPEN; i++) { + fd[i] = open("/dev/null", O_RDONLY); + if (fd[i] == -1) { + fprintf(stderr, "open: attempt #%i: failed to open /dev/null\n", i); + for (i--; i >= 0; i--) + close(fd[i]); + return CURLE_FAILED_INIT; + } + } + + curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + + for (i = 0; i < NUM_OPEN; i++) + close(fd[i]); + + return (int)res; +} -- cgit v1.2.1 From cca9fca89409a73f393d8de42b30572bba3d7a14 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Fri, 19 Nov 2004 13:50:41 +0000 Subject: ifdef for portable "/dev/null". --- tests/libtest/lib518.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index f12bca6de..e981e0080 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -16,6 +16,12 @@ #define NUM_OPEN (FD_SETSIZE + 10) +#if defined(WIN32) || defined(_WIN32) || defined(MSDOS) +#define DEV_NULL "NUL" +#else +#define DEV_NULL "/dev/null" +#endif + int test(char *URL) { CURLcode res; @@ -25,9 +31,9 @@ int test(char *URL) /* open a lot of file descriptors */ for (i = 0; i < NUM_OPEN; i++) { - fd[i] = open("/dev/null", O_RDONLY); + fd[i] = open(DEV_NULL, O_RDONLY); if (fd[i] == -1) { - fprintf(stderr, "open: attempt #%i: failed to open /dev/null\n", i); + fprintf(stderr, "open: attempt #%i: failed to open %s\n", i, DEV_NULL); for (i--; i >= 0; i--) close(fd[i]); return CURLE_FAILED_INIT; -- cgit v1.2.1 From a4e1ac79527d8ac3552d96a00e5f2966123d0374 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 22 Nov 2004 22:26:46 +0000 Subject: David Phillips fix for test 518 and my extension to make it not run on systems that can't run it fine. --- tests/libtest/lib518.c | 69 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index e981e0080..86ee23ad7 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -1,8 +1,23 @@ #include "test.h" +#ifdef HAVE_SYS_TYPES_H #include +#endif +#ifdef HAVE_SYS_STAT_H #include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif +#ifdef HAVE_FCNTL_H #include +#endif +#ifdef UNISTD_H +#include +#endif #include @@ -15,6 +30,7 @@ #endif #define NUM_OPEN (FD_SETSIZE + 10) +#define NUM_NEEDED (NUM_OPEN + 16) #if defined(WIN32) || defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" @@ -22,24 +38,56 @@ #define DEV_NULL "/dev/null" #endif +#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) int test(char *URL) { - CURLcode res; - CURL *curl; + struct rlimit rl; int fd[NUM_OPEN]; int i; + CURLcode res; + CURL *curl; - /* open a lot of file descriptors */ - for (i = 0; i < NUM_OPEN; i++) { - fd[i] = open(DEV_NULL, O_RDONLY); + /* get open file limits */ + if (getrlimit(RLIMIT_NOFILE, &rl) == -1) { + fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE\n"); + goto skip_open; + } + + /* check that hard limit is high enough */ + if (rl.rlim_max < NUM_NEEDED) { + fprintf(stderr, "warning: RLIMIT_NOFILE hard limit is too low\n"); + goto skip_open; + } + + /* increase soft limit if needed */ + if (rl.rlim_cur < NUM_NEEDED) { + rl.rlim_cur = NUM_NEEDED; + if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { + fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE\n"); + goto skip_open; + } + } + + /* open a dummy descriptor */ + fd[0] = open(DEV_NULL, O_RDONLY); + if (fd[0] == -1) { + fprintf(stderr, "open: failed to open %s\n", DEV_NULL); + return CURLE_FAILED_INIT; + } + + /* create a bunch of file descriptors */ + for (i = 1; i < NUM_OPEN; i++) { + fd[i] = dup(fd[0]); if (fd[i] == -1) { - fprintf(stderr, "open: attempt #%i: failed to open %s\n", i, DEV_NULL); + fprintf(stderr, "dup: attempt #%i failed\n", i); for (i--; i >= 0; i--) close(fd[i]); return CURLE_FAILED_INIT; } } +skip_open: + curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); @@ -51,3 +99,12 @@ int test(char *URL) return (int)res; } +#else +/* system lacks getrlimit() and/or setrlimit() */ +int test(char *URL) +{ + (void)URL; + fprintf(stderr, "system lacks necessary system function(s)"); + return 1; +} +#endif -- cgit v1.2.1 From be5cc378c8f49c135ab7cc0d7378dc8b035a20be Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 23 Nov 2004 09:50:16 +0000 Subject: introducing the client/precheck concept to allow test 518 to *only* run when it actually can run and test the FD_SETSIZE stuff it is meant to test --- tests/libtest/lib518.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 86ee23ad7..4be7b7f85 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -39,24 +39,20 @@ #endif #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) -int test(char *URL) + +static int rlimit(void) { struct rlimit rl; - int fd[NUM_OPEN]; - int i; - CURLcode res; - CURL *curl; - /* get open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) == -1) { fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE\n"); - goto skip_open; + return -1; } /* check that hard limit is high enough */ if (rl.rlim_max < NUM_NEEDED) { fprintf(stderr, "warning: RLIMIT_NOFILE hard limit is too low\n"); - goto skip_open; + return -1; } /* increase soft limit if needed */ @@ -64,10 +60,32 @@ int test(char *URL) rl.rlim_cur = NUM_NEEDED; if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE\n"); - goto skip_open; + return -1; + } + } + return 0; +} + +int test(char *URL) +{ + int fd[NUM_OPEN]; + int i; + CURLcode res; + CURL *curl; + + if(!strcmp(URL, "check")) { + /* used by the test script to ask if we can run this test or not */ + if(rlimit()) { + printf("rlimit problems\n"); + return 1; } + return 0; /* sure, run this! */ } + if(rlimit()) + /* failure */ + return 100; + /* open a dummy descriptor */ fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] == -1) { @@ -86,8 +104,6 @@ int test(char *URL) } } -skip_open: - curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); @@ -104,7 +120,7 @@ skip_open: int test(char *URL) { (void)URL; - fprintf(stderr, "system lacks necessary system function(s)"); + printf("system lacks necessary system function(s)"); return 1; } #endif -- cgit v1.2.1 From 0d7446c134c4b77dcc7b796698e224a809a0d4db Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 28 Nov 2004 08:57:03 +0000 Subject: add more info to the stderr output --- tests/libtest/lib518.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 4be7b7f85..e626e54cb 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -43,6 +43,10 @@ static int rlimit(void) { struct rlimit rl; + + fprintf(stderr, "NUM_OPEN: %d\n", NUM_OPEN); + fprintf(stderr, "NUM_NEEDED: %d\n", NUM_NEEDED); + /* get open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) == -1) { fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE\n"); @@ -51,7 +55,8 @@ static int rlimit(void) /* check that hard limit is high enough */ if (rl.rlim_max < NUM_NEEDED) { - fprintf(stderr, "warning: RLIMIT_NOFILE hard limit is too low\n"); + fprintf(stderr, "warning: RLIMIT_NOFILE hard limit %d < %d\n", + (int)rl.rlim_max, NUM_NEEDED); return -1; } -- cgit v1.2.1 From 113531432ab3d7d7cdabf3af34226a6da2c3daa2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 1 Dec 2004 10:34:46 +0000 Subject: make the "check" actually open all those file desciptors as well to make sure it works, as it has proved to not work in some cases (like on Tor Arntsen's AIX 5100-06 xlc 5.0 --disable-shared runs). --- tests/libtest/lib518.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index e626e54cb..1c858ee35 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -40,8 +40,11 @@ #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) +static int fd[NUM_OPEN]; + static int rlimit(void) { + int i; struct rlimit rl; fprintf(stderr, "NUM_OPEN: %d\n", NUM_OPEN); @@ -57,7 +60,7 @@ static int rlimit(void) if (rl.rlim_max < NUM_NEEDED) { fprintf(stderr, "warning: RLIMIT_NOFILE hard limit %d < %d\n", (int)rl.rlim_max, NUM_NEEDED); - return -1; + return -2; } /* increase soft limit if needed */ @@ -65,16 +68,33 @@ static int rlimit(void) rl.rlim_cur = NUM_NEEDED; if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE\n"); - return -1; + return -3; + } + } + + /* open a dummy descriptor */ + fd[0] = open(DEV_NULL, O_RDONLY); + if (fd[0] == -1) { + fprintf(stderr, "open: failed to open %s\n", DEV_NULL); + return -4; + } + + /* create a bunch of file descriptors */ + for (i = 1; i < NUM_OPEN; i++) { + fd[i] = dup(fd[0]); + if (fd[i] == -1) { + fprintf(stderr, "dup: attempt #%i failed\n", i); + for (i--; i >= 0; i--) + close(fd[i]); + return -5; } } + return 0; } int test(char *URL) { - int fd[NUM_OPEN]; - int i; CURLcode res; CURL *curl; @@ -91,32 +111,13 @@ int test(char *URL) /* failure */ return 100; - /* open a dummy descriptor */ - fd[0] = open(DEV_NULL, O_RDONLY); - if (fd[0] == -1) { - fprintf(stderr, "open: failed to open %s\n", DEV_NULL); - return CURLE_FAILED_INIT; - } - - /* create a bunch of file descriptors */ - for (i = 1; i < NUM_OPEN; i++) { - fd[i] = dup(fd[0]); - if (fd[i] == -1) { - fprintf(stderr, "dup: attempt #%i failed\n", i); - for (i--; i >= 0; i--) - close(fd[i]); - return CURLE_FAILED_INIT; - } - } - curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); res = curl_easy_perform(curl); curl_easy_cleanup(curl); - for (i = 0; i < NUM_OPEN; i++) - close(fd[i]); + /* we never close the file descriptors */ return (int)res; } -- cgit v1.2.1 From e587a56fc0e3d643b58e8090163a5ecd7516fa35 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Wed, 1 Dec 2004 13:41:22 +0000 Subject: Use "HAVE_SYS_TYPES_H". --- tests/libtest/lib505.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 10aa1ab19..c398d39f2 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -13,7 +13,7 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif -#ifdef HAVE_SYS_TYPES_ +#ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_STAT_H -- cgit v1.2.1 From 0d0d5e7ee3b8575118d8d268802623f2a9a49ee5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 Dec 2004 21:22:51 +0000 Subject: Harshal Pradhan fixed changing username/password on a persitent HTTP connection. --- tests/libtest/Makefile.am | 6 +++++- tests/libtest/lib519.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib519.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index f394ec14b..e5bc1eab4 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -40,7 +40,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 + lib518 lib519 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -117,3 +117,7 @@ lib517_DEPENDENCIES = $(LIBDIR)/libcurl.la lib518_SOURCES = lib518.c $(SUPPORTFILES) lib518_LDADD = $(LIBDIR)/libcurl.la lib518_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib519_SOURCES = lib519.c $(SUPPORTFILES) +lib519_LDADD = $(LIBDIR)/libcurl.la +lib519_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c new file mode 100644 index 000000000..007703e11 --- /dev/null +++ b/tests/libtest/lib519.c @@ -0,0 +1,21 @@ +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed"); + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + /* get first page */ + res = curl_easy_perform(curl); + + curl_easy_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe"); + /* get second page */ + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + return (int)res; +} + -- cgit v1.2.1 From aacc79a3a3d323a6462a765deb5be5a27c60601f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Jan 2005 22:40:56 +0000 Subject: Use the same work-around for the memdebug stuff as in the command line client, to allow the contents of the env var decide the file name. --- tests/libtest/first.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index c4f35df22..a7f317355 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -19,8 +19,14 @@ int main(int argc, char **argv) /* this sends all memory debug messages to a logfile named memdump */ char *env = curl_getenv("CURL_MEMDEBUG"); if(env) { + /* use the value as file name */ + char *s = strdup(env); curl_free(env); - curl_memdebug("memdump"); + 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! */ } /* this enables the fail-on-alloc-number-N functionality */ env = curl_getenv("CURL_MEMLIMIT"); -- cgit v1.2.1 From 6a2e21ec8cbaf7c719902e06953d9dbec629ad4f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 9 Feb 2005 13:06:40 +0000 Subject: FTP code turned into state machine. Not completely yet, but a good start. The tag 'before_ftp_statemachine' was set just before this commit in case of future need. --- tests/libtest/lib511.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 4afb1dc9f..c0861a053 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -9,7 +9,6 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_NOBODY, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); res = curl_easy_perform(curl); - curl_easy_cleanup(curl); + curl_easy_cleanup(curl); return (int)res; } - -- cgit v1.2.1 From 702664e9591197c10ec36ab7a0ab7395b77726d7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 8 Mar 2005 08:09:14 +0000 Subject: Dominick Meglio reported that using CURLOPT_FILETIME when transferring a FTP file got a Last-Modified: header written to the data stream, corrupting the actual data. This was because some conditions from the previous FTP code was not properly brought into the new FTP code. I fixed and I added test case 520 to verify. (This bug was introduced in 7.13.1) --- tests/libtest/Makefile.am | 8 ++++++-- tests/libtest/lib520.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/lib520.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e5bc1eab4..acdeb5501 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -40,7 +40,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 + lib518 lib519 lib520 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -121,3 +121,7 @@ lib518_DEPENDENCIES = $(LIBDIR)/libcurl.la lib519_SOURCES = lib519.c $(SUPPORTFILES) lib519_LDADD = $(LIBDIR)/libcurl.la lib519_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib520_SOURCES = lib520.c $(SUPPORTFILES) +lib520_LDADD = $(LIBDIR)/libcurl.la +lib520_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c new file mode 100644 index 000000000..efc2823a1 --- /dev/null +++ b/tests/libtest/lib520.c @@ -0,0 +1,13 @@ +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_FILETIME, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return (int)res; +} -- cgit v1.2.1 From d26cfd5791c13daa7b263368959f0ec85774402e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 9 Mar 2005 07:56:32 +0000 Subject: skip the test of "2094 Nov 6" for now, since the 64bit time_t systems return different values for it... --- tests/libtest/lib517.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index ea296914f..1a4aefc54 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -23,7 +23,7 @@ const char *dates[]={ "Sat, 11 Sep 2004 21:32:11 +0200", "20040912 15:05:58 -0700", "20040911 +0200", - "2094 Nov 6", +/* "2094 Nov 6", See ../data/test517 for details */ NULL }; -- cgit v1.2.1 From 346992c366bf0504211479bd16120d1ad188befb Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 31 Mar 2005 14:10:54 +0000 Subject: Attempt to make this code more forgiving for systems that doesn't detect the failed connect "immediately". --- tests/libtest/lib504.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index df2e3ff2c..5ba9362bb 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -20,7 +20,7 @@ int test(char *URL) int running; int max_fd; int rc; - int loop=100; + int loop=10; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -44,7 +44,7 @@ int test(char *URL) interval.tv_usec = 0; fprintf(stderr, "curl_multi_perform()\n"); - + do { res = curl_multi_perform(m, &running); } while (res == CURLM_CALL_MULTI_PERFORM); @@ -79,10 +79,10 @@ int test(char *URL) } rc = select(max_fd+1, &rd, &wr, &exc, &interval); fprintf(stderr, "select returned %d\n", rc); - + /* we only allow a certain number of loops to avoid hanging here forever */ - } while(rc && (--loop>0)); + } while(--loop>0); } curl_multi_remove_handle(m, c); -- cgit v1.2.1 From 63d109f7be8ddd027c86355dd09d02189b731a46 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 18 Apr 2005 19:41:04 +0000 Subject: Olivier reported that even though he used CURLOPT_PORT, libcurl clearly still used the default port. He was right. I fixed the problem and added the test cases 521, 522 and 523 to verify the fix. --- tests/libtest/Makefile.am | 10 +++++++++- tests/libtest/lib521.c | 16 ++++++++++++++++ tests/libtest/lib523.c | 17 +++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib521.c create mode 100644 tests/libtest/lib523.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index acdeb5501..ccbe2aa16 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -40,7 +40,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 lib520 + lib518 lib519 lib520 lib521 lib523 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -125,3 +125,11 @@ lib519_DEPENDENCIES = $(LIBDIR)/libcurl.la lib520_SOURCES = lib520.c $(SUPPORTFILES) lib520_LDADD = $(LIBDIR)/libcurl.la lib520_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib521_SOURCES = lib521.c $(SUPPORTFILES) +lib521_LDADD = $(LIBDIR)/libcurl.la +lib521_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib523_SOURCES = lib523.c $(SUPPORTFILES) +lib523_LDADD = $(LIBDIR)/libcurl.la +lib523_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c new file mode 100644 index 000000000..96630f303 --- /dev/null +++ b/tests/libtest/lib521.c @@ -0,0 +1,16 @@ +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_PORT, atoi(arg2)); + curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return (int)res; +} + diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c new file mode 100644 index 000000000..d0a41c5f5 --- /dev/null +++ b/tests/libtest/lib523.c @@ -0,0 +1,17 @@ +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_PROXY, arg2); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_PORT, 19999); + curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return (int)res; +} + -- cgit v1.2.1 From e3a530eb612d77e5021a7d6a0e79f3c98522d790 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 27 May 2005 11:01:41 +0000 Subject: =?UTF-8?q?Andr=E9s=20Garc=EDa=20fixed=20a=20warning=20appearing?= =?UTF-8?q?=20on=20windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/libtest/lib505.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index c398d39f2..148778186 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -40,7 +40,7 @@ int test(char *URL) CURLcode res; FILE *hd_src ; int hd ; - struct stat file_info; + struct_stat file_info; struct curl_slist *headerlist=NULL; const char *buf_1 = "RNFR 505"; -- cgit v1.2.1 From 34a827bbfe6f10588ead48f2bb9721c6c927ec89 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Thu, 28 Jul 2005 13:20:27 +0000 Subject: Needs 'struct_stat'. Increased verbosity. --- tests/libtest/lib505.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 148778186..dc82e2d8f 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -8,6 +8,7 @@ * $Id$ */ +#include "setup.h" /* struct_stat etc. */ #include "test.h" #ifdef HAVE_SYS_SOCKET_H @@ -46,10 +47,16 @@ int test(char *URL) const char *buf_1 = "RNFR 505"; const char *buf_2 = "RNTO 505-forreal"; + if (!arg2) { + fprintf(stderr, "Usage: \n"); + return -1; + } + /* get the file size of the local file */ hd = stat(arg2, &file_info); if(hd == -1) { /* can't open file, bail out */ + fprintf(stderr, "WARNING: cannot open file %s\n", arg2); return -1; } -- cgit v1.2.1 From 7d68101f83a28323fa24b1f705881415ccbe6467 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 3 Mar 2006 13:09:30 +0000 Subject: Prevent uploading to a URL that has no file name part. --- tests/libtest/Makefile.am | 8 ++++++-- tests/libtest/lib524.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/lib524.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index ccbe2aa16..2af887726 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -40,7 +40,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 lib520 lib521 lib523 + lib518 lib519 lib520 lib521 lib523 lib524 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -133,3 +133,7 @@ lib521_DEPENDENCIES = $(LIBDIR)/libcurl.la lib523_SOURCES = lib523.c $(SUPPORTFILES) lib523_LDADD = $(LIBDIR)/libcurl.la lib523_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib524_SOURCES = lib524.c $(SUPPORTFILES) +lib524_LDADD = $(LIBDIR)/libcurl.la +lib524_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c new file mode 100644 index 000000000..be9f43466 --- /dev/null +++ b/tests/libtest/lib524.c @@ -0,0 +1,15 @@ +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + return (int)res; +} + -- cgit v1.2.1 From 6a03ab3ad4f1835f47a8fcbc6a8b4a070541d4e6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 8 Jun 2006 22:43:21 +0000 Subject: lib525.c does a FTP upload with PORT using multi interface --- tests/libtest/Makefile.am | 6 ++- tests/libtest/lib525.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib525.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 2af887726..95cd9fb9f 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -40,7 +40,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 lib520 lib521 lib523 lib524 + lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -137,3 +137,7 @@ lib523_DEPENDENCIES = $(LIBDIR)/libcurl.la lib524_SOURCES = lib524.c $(SUPPORTFILES) lib524_LDADD = $(LIBDIR)/libcurl.la lib524_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib525_SOURCES = lib525.c $(SUPPORTFILES) +lib525_LDADD = $(LIBDIR)/libcurl.la +lib525_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c new file mode 100644 index 000000000..b4cde12a2 --- /dev/null +++ b/tests/libtest/lib525.c @@ -0,0 +1,129 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include +#include +#include + +int test(char *URL) +{ + CURLMcode res = CURLE_OK; + CURL *curl; + FILE *hd_src ; + int hd ; + struct stat file_info; + int running; + char done=FALSE; + CURLM *m; + + /* get the file size of the local file */ + hd = open(arg2, O_RDONLY) ; + fstat(hd, &file_info); + close(hd) ; + + /* get a FILE * of the same file, could also be made with + fdopen() from the previous descriptor, but hey this is just + an example! */ + hd_src = fopen(arg2, "rb"); + + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + /* get a curl handle */ + curl = curl_easy_init(); + if(!curl) + return 100; /* major bad */ + + + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, URL); + + /* go verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* use active FTP */ + curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); + + /* now specify which file to upload */ + curl_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 + do so will give you a crash since a DLL may not use the variable's memory + when passed in to it from an app like this. */ + + /* Set the size of the file to upload (optional). If you give a *_LARGE + 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. */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, + (curl_off_t)file_info.st_size); + + m = curl_multi_init(); + + res = curl_multi_add_handle(m, curl); + + while(!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = curl_multi_perform(m, &running); + if (running <= 0) { + done = TRUE; + break; + } + } + if(done) + break; + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + break; + } + + 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; + } + + if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + res = 195; + break; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + + curl_multi_remove_handle(m, curl); + curl_easy_cleanup(curl); + curl_multi_cleanup(m); + + fclose(hd_src); /* close the local file */ + + curl_global_cleanup(); + return (int)res; +} -- cgit v1.2.1 From 7929600798c8117d3ce6bf458a293b65c8f4a7b5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 9 Jun 2006 08:25:16 +0000 Subject: stricter type use to please compilers --- tests/libtest/lib525.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index b4cde12a2..3726bf6dd 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -16,7 +16,7 @@ int test(char *URL) { - CURLMcode res = CURLE_OK; + int res = 0; CURL *curl; FILE *hd_src ; int hd ; @@ -73,7 +73,7 @@ int test(char *URL) m = curl_multi_init(); - res = curl_multi_add_handle(m, curl); + res = (int)curl_multi_add_handle(m, curl); while(!done) { fd_set rd, wr, exc; @@ -84,7 +84,7 @@ int test(char *URL) interval.tv_usec = 0; while (res == CURLM_CALL_MULTI_PERFORM) { - res = curl_multi_perform(m, &running); + res = (int)curl_multi_perform(m, &running); if (running <= 0) { done = TRUE; break; @@ -125,5 +125,5 @@ int test(char *URL) fclose(hd_src); /* close the local file */ curl_global_cleanup(); - return (int)res; + return res; } -- cgit v1.2.1 From cc5174a89a6092d92903708cf75fdb0b91f4b740 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Sat, 10 Jun 2006 17:35:28 +0000 Subject: Fix "'x' might be used uninitialized in this function" warnings. --- tests/libtest/lib505.c | 2 +- tests/libtest/lib507.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index dc82e2d8f..7de0bc1e9 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -38,7 +38,7 @@ int test(char *URL) { CURL *curl; - CURLcode res; + CURLcode res = CURLE_OK; FILE *hd_src ; int hd ; struct_stat file_info; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index b16c23368..4e776ec4a 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -5,7 +5,7 @@ int test(char *URL) CURL* curls; CURLM* multi; int still_running; - int i; + int i = -1; CURLMsg *msg; multi = curl_multi_init(); -- cgit v1.2.1 From 773bec5ae5b7a7fe4ef8c4c0e75b8872c5b4da69 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 17 Jul 2006 14:32:19 +0000 Subject: Fix compiler warning "enumerated type mixed with another type" --- tests/libtest/lib506.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 52a4094a2..ecf17fa22 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -130,7 +130,7 @@ char *suburl(char *base, int i) int test(char *URL) { int res; - CURLSHcode scode; + CURLSHcode scode = CURLSHE_OK; char *url; struct Tdata tdata; CURL *curl; @@ -148,15 +148,29 @@ int test(char *URL) /* prepare share */ printf( "SHARE_INIT\n" ); share = curl_share_init(); - scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); - scode += curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); - scode += curl_share_setopt( share, CURLSHOPT_USERDATA, &user); - printf( "CURL_LOCK_DATA_COOKIE\n" ); - scode += curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); - printf( "CURL_LOCK_DATA_DNS\n" ); - scode += curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); - - if(scode) { + + if ( CURLSHE_OK == scode ) { + printf( "CURLSHOPT_LOCKFUNC\n" ); + scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); + } + if ( CURLSHE_OK == scode ) { + printf( "CURLSHOPT_UNLOCKFUNC\n" ); + scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, 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_COOKIE\n" ); + scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + } + if ( CURLSHE_OK == scode ) { + printf( "CURL_LOCK_DATA_DNS\n" ); + scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + } + + if ( CURLSHE_OK != scode ) { curl_share_cleanup(share); return 2; } -- cgit v1.2.1 From b33f47804da5125d22f490ddcb6feba908bc2c36 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 7 Aug 2006 18:06:37 +0000 Subject: Allow again proper compilation outside of the source tree --- tests/libtest/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 95cd9fb9f..e1b5cf1c3 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -28,9 +28,10 @@ AUTOMAKE_OPTIONS = foreign nostdinc # -I$(top_srcdir)/lib is for the setup.h file, included by test.h # -I$(top_builddir)/lib is for the config.h file, possibly included by the # setup.h file + INCLUDES = -I$(top_srcdir)/include/curl \ - -I$(top_srcdir)/lib \ - -I$(top_builddir)/lib + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib LIBDIR = $(top_builddir)/lib -- cgit v1.2.1 From b7eeb6e67fca686f840eacd6b8394edb58b07482 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 7 Sep 2006 21:49:20 +0000 Subject: Major overhaul introducing http pipelining support and shared connection cache within the multi handle. --- tests/libtest/Makefile.am | 12 ++++- tests/libtest/lib526.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib526.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e1b5cf1c3..4f721e19e 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -41,7 +41,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 lib520 lib521 lib523 lib524 lib525 + lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -142,3 +142,13 @@ lib524_DEPENDENCIES = $(LIBDIR)/libcurl.la lib525_SOURCES = lib525.c $(SUPPORTFILES) lib525_LDADD = $(LIBDIR)/libcurl.la lib525_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib526_SOURCES = lib526.c $(SUPPORTFILES) +lib526_LDADD = $(LIBDIR)/libcurl.la +lib526_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib527_SOURCES = lib526.c $(SUPPORTFILES) +lib527_CFLAGS = -DLIB527 +lib527_LDADD = $(LIBDIR)/libcurl.la +lib527_DEPENDENCIES = $(LIBDIR)/libcurl.la + diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c new file mode 100644 index 000000000..5050b27f2 --- /dev/null +++ b/tests/libtest/lib526.c @@ -0,0 +1,129 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +/* + * This code sets up multiple easy handles that transfer a single file from + * the same URL, in a serial manner after each other. Due to the connection + * sharing within the multi handle all transfers are performed on the same + * persistent connection. + * + * This source code is used for lib526 _and_ lib527 with only #ifdefs + * controlling the small differences. lib526 closes all easy handles after + * they all have transfered the file over the single connection, while lib527 + * closes each easy handle after each single transfer. 526 and 527 use FTP, + * while 528 uses the lib526 tool but use HTTP. + */ + +#include "test.h" + +#include +#include +#include + +#define NUM_HANDLES 4 + +int test(char *URL) +{ + int res = 0; + CURL *curl[NUM_HANDLES]; + int running; + char done=FALSE; + CURLM *m; + int current=0; + int i; + + /* In windows, this will init the winsock stuff */ + curl_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]) + return 100 + i; /* major bad */ + curl_easy_setopt(curl[i], CURLOPT_URL, URL); + + /* go verbose */ + curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1); + } + + m = curl_multi_init(); + + res = (int)curl_multi_add_handle(m, curl[current]); + + fprintf(stderr, "Start at URL 0\n"); + + while(!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = (int)curl_multi_perform(m, &running); + if (running <= 0) { +#ifdef LIB527 + curl_easy_cleanup(curl[current]); +#endif + if(++current < NUM_HANDLES) { + fprintf(stderr, "Advancing to URL %d\n", current); + res = (int)curl_multi_add_handle(m, curl[current]); + if(res) { + fprintf(stderr, "add handle failed: %d.\n", res); + res = 243; + break; + } + } + else + done = TRUE; /* bail out */ + break; + } + } + if(done) + break; + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + break; + } + + 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; + } + + if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + res = 195; + break; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + +#ifndef LIB527 + /* get NUM_HANDLES easy handles */ + for(i=0; i < NUM_HANDLES; i++) { + curl_multi_remove_handle(m, curl[i]); + curl_easy_cleanup(curl[i]); + } +#endif + curl_multi_cleanup(m); + + curl_global_cleanup(); + return res; +} -- cgit v1.2.1 From e3c15fc4b9e9ebc9b5e7aa056b10ae0caeaef90d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 8 Sep 2006 11:56:56 +0000 Subject: test 530 is the first ever HTTP pipelining test for libcurl --- tests/libtest/Makefile.am | 6 ++- tests/libtest/lib530.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib530.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 4f721e19e..877532dd9 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -41,7 +41,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 + lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib530 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -152,3 +152,7 @@ lib527_CFLAGS = -DLIB527 lib527_LDADD = $(LIBDIR)/libcurl.la lib527_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib530_SOURCES = lib530.c $(SUPPORTFILES) +lib530_CFLAGS = -DLIB530 +lib530_LDADD = $(LIBDIR)/libcurl.la +lib530_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c new file mode 100644 index 000000000..3b2c95051 --- /dev/null +++ b/tests/libtest/lib530.c @@ -0,0 +1,120 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +/* + * This code sets up multiple easy handles that transfer a single file from + * the same URL, in a serial manner after each other. Due to the connection + * sharing within the multi handle all transfers are performed on the same + * persistent connection. + * + * This source code is used for lib526 _and_ lib527 with only #ifdefs + * controlling the small differences. lib526 closes all easy handles after + * they all have transfered the file over the single connection, while lib527 + * closes each easy handle after each single transfer. 526 and 527 use FTP, + * while 528 uses the lib526 tool but use HTTP. + */ + +#include "test.h" + +#include +#include +#include + +#define NUM_HANDLES 4 + +int test(char *URL) +{ + int res = 0; + CURL *curl[NUM_HANDLES]; + int running; + char done=FALSE; + CURLM *m; + int current=0; + int i; + + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + m = curl_multi_init(); + + /* get NUM_HANDLES easy handles */ + for(i=0; i < NUM_HANDLES; i++) { + curl[i] = curl_easy_init(); + if(!curl[i]) + return 100 + i; /* major bad */ + curl_easy_setopt(curl[i], CURLOPT_URL, URL); + + /* go verbose */ + curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1); + + /* include headers */ + curl_easy_setopt(curl[i], CURLOPT_HEADER, 1); + + res = (int)curl_multi_add_handle(m, curl[i]); + } + + curl_multi_setopt(m, CURLMOPT_PIPELINING, 1); + + fprintf(stderr, "Start at URL 0\n"); + + while(!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = (int)curl_multi_perform(m, &running); + if (running <= 0) { + done = TRUE; /* bail out */ + break; + } + } + if(done) + break; + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + break; + } + + 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; + } + + if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + res = 195; + break; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + + /* get NUM_HANDLES easy handles */ + for(i=0; i < NUM_HANDLES; i++) { + curl_multi_remove_handle(m, curl[i]); + curl_easy_cleanup(curl[i]); + } + + curl_multi_cleanup(m); + + curl_global_cleanup(); + return res; +} -- cgit v1.2.1 From e9160a31e04601beabdcba68a2fa0d051ac78398 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 8 Sep 2006 12:03:55 +0000 Subject: removed the comment that isn't valid for this file, just a copy'n paste error --- tests/libtest/lib530.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 3b2c95051..85b2e74ad 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -8,24 +8,10 @@ * $Id$ */ -/* - * This code sets up multiple easy handles that transfer a single file from - * the same URL, in a serial manner after each other. Due to the connection - * sharing within the multi handle all transfers are performed on the same - * persistent connection. - * - * This source code is used for lib526 _and_ lib527 with only #ifdefs - * controlling the small differences. lib526 closes all easy handles after - * they all have transfered the file over the single connection, while lib527 - * closes each easy handle after each single transfer. 526 and 527 use FTP, - * while 528 uses the lib526 tool but use HTTP. - */ - #include "test.h" #include #include -#include #define NUM_HANDLES 4 @@ -36,7 +22,6 @@ int test(char *URL) int running; char done=FALSE; CURLM *m; - int current=0; int i; /* In windows, this will init the winsock stuff */ -- cgit v1.2.1 From 145084b69973fe355a0114f63aef6336f7a94e77 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Sat, 9 Sep 2006 16:55:21 +0000 Subject: Print usage in case 'arg2 == NULL'. --- tests/libtest/lib525.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 3726bf6dd..9946ce354 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -25,6 +25,11 @@ int test(char *URL) char done=FALSE; CURLM *m; + if (!arg2) { + fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); + return -1; + } + /* get the file size of the local file */ hd = open(arg2, O_RDONLY) ; fstat(hd, &file_info); -- cgit v1.2.1 From e134a4020885701b583b8af2e9d0414b090512f6 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Sun, 10 Sep 2006 19:01:04 +0000 Subject: Added select_test() function to allow selecting on no sockets on Winsock. --- tests/libtest/first.c | 15 +++++++++++++++ tests/libtest/lib503.c | 2 +- tests/libtest/lib504.c | 2 +- tests/libtest/lib507.c | 2 +- tests/libtest/lib509.c | 2 +- tests/libtest/lib525.c | 2 +- tests/libtest/lib526.c | 2 +- tests/libtest/lib530.c | 2 +- tests/libtest/test.h | 4 ++++ 9 files changed, 26 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index a7f317355..fda1a7fb5 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -9,6 +9,21 @@ extern void curl_memlimit(int); /* test is provided in the test code file */ int test(char *url); +int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, + struct timeval *tv) +{ +#ifdef WIN32 + /* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is + * case when 'num_fds <= 0. So sleep. + */ + if (num_fds <= 0) { + Sleep(1000*tv->tv_sec + tv->tv_usec/1000); + return 0; + } +#endif + return select(num_fds, rd, wr, exc, tv); +} + char *arg2=NULL; int main(int argc, char **argv) diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index aeb85db36..4e7ac82db 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -67,7 +67,7 @@ int test(char *URL) return 89; } - if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); return 95; } diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 5ba9362bb..843e9ebd0 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -77,7 +77,7 @@ int test(char *URL) ret = 3; break; } - rc = select(max_fd+1, &rd, &wr, &exc, &interval); + rc = select_test(max_fd+1, &rd, &wr, &exc, &interval); fprintf(stderr, "select returned %d\n", rc); /* we only allow a certain number of loops to avoid hanging here diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 4e776ec4a..8fc4ca3ce 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -28,7 +28,7 @@ int test(char *URL) timeout.tv_sec = 1; timeout.tv_usec = 0; curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); - rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); + rc = select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); switch(rc) { case -1: break; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index d20c31524..415208ac7 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -241,7 +241,7 @@ int test(char *URL) break; } - if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); i =95; break; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 9946ce354..77e5c203a 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -114,7 +114,7 @@ int test(char *URL) break; } - if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); res = 195; break; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 5050b27f2..de3a36d02 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -106,7 +106,7 @@ int test(char *URL) break; } - if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); res = 195; break; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 85b2e74ad..3e6cd3fac 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -83,7 +83,7 @@ int test(char *URL) break; } - if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { fprintf(stderr, "bad select??\n"); res = 195; break; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index a442ba4bd..83ec94b65 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -32,5 +32,9 @@ #endif extern char *arg2; /* set by first.c to the argv[2] or NULL */ + +int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, + struct timeval *tv); + int test(char *URL); /* the actual test function provided by each individual libXXX.c file */ -- cgit v1.2.1 From 29dc39fce1126265d8526be15beec3e3fdc1c11d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 11 Sep 2006 17:18:18 +0000 Subject: - Fixed my breakage from earlier today so that doing curl_easy_cleanup() on a handle that is part of a multi handle first removes the handle from the stack. - Added CURLOPT_SSL_SESSIONID_CACHE and --no-sessionid to disable SSL session-ID re-use on demand since there obviously are broken servers out there that misbehave with session-IDs used. --- tests/libtest/lib526.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index de3a36d02..04240808f 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -71,6 +71,9 @@ int test(char *URL) res = (int)curl_multi_perform(m, &running); if (running <= 0) { #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]); #endif if(++current < NUM_HANDLES) { -- cgit v1.2.1 From 5a6c89661a96fa2139fa0cff07de2f2eff369127 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 12 Sep 2006 01:17:16 +0000 Subject: Cygwin preprocessor adjustments --- tests/libtest/first.c | 2 +- tests/libtest/lib518.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index fda1a7fb5..8050537db 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -12,7 +12,7 @@ int test(char *url); int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv) { -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) /* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is * case when 'num_fds <= 0. So sleep. */ diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 1c858ee35..d0c200774 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -32,7 +32,7 @@ #define NUM_OPEN (FD_SETSIZE + 10) #define NUM_NEEDED (NUM_OPEN + 16) -#if defined(WIN32) || defined(_WIN32) || defined(MSDOS) +#if (defined(WIN32) || defined(_WIN32) || defined(MSDOS)) && !defined(__CYGWIN__) #define DEV_NULL "NUL" #else #define DEV_NULL "/dev/null" -- cgit v1.2.1 From ae13c93b7db9f9c68eaf95150ed551b3b649d8c4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 28 Sep 2006 21:26:06 +0000 Subject: Reported in #1561470 (http://curl.haxx.se/bug/view.cgi?id=1561470), libcurl would crash if a bad function sequence was used when shutting down after using the multi interface (i.e using easy_cleanup after multi_cleanup) so precautions have been added to make sure it doesn't any more - test case 529 was added to verify. --- tests/libtest/Makefile.am | 12 +++++++++--- tests/libtest/lib525.c | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 877532dd9..4b52a5f9a 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -39,9 +39,10 @@ LIBDIR = $(top_builddir)/lib SUPPORTFILES = first.c test.h # These are all libcurl test programs -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 \ - lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 lib517 \ - lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 lib530 +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ + lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ + lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ + lib529 lib530 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -152,6 +153,11 @@ lib527_CFLAGS = -DLIB527 lib527_LDADD = $(LIBDIR)/libcurl.la lib527_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib529_SOURCES = lib525.c $(SUPPORTFILES) +lib529_CFLAGS = -DLIB529 +lib529_LDADD = $(LIBDIR)/libcurl.la +lib529_DEPENDENCIES = $(LIBDIR)/libcurl.la + lib530_SOURCES = lib530.c $(SUPPORTFILES) lib530_CFLAGS = -DLIB530 lib530_LDADD = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 77e5c203a..240628028 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -123,9 +123,17 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } +#ifdef LIB529 + /* test 529 */ + curl_multi_remove_handle(m, curl); + curl_multi_cleanup(m); + curl_easy_cleanup(curl); +#else + /* test 525 */ curl_multi_remove_handle(m, curl); curl_easy_cleanup(curl); curl_multi_cleanup(m); +#endif fclose(hd_src); /* close the local file */ -- cgit v1.2.1 From 552b963e6defebd6d0d6d41f8c74798d856c313c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 4 Oct 2006 21:11:08 +0000 Subject: Dmitriy Sergeyev provided an example source code that crashed CVS libcurl but that worked nicely in 7.15.5. I converted it into test case 532 and fixed the problem. --- tests/libtest/Makefile.am | 8 +++++++- tests/libtest/lib526.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 4b52a5f9a..01b702015 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -42,7 +42,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 + lib529 lib530 lib532 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -145,6 +145,7 @@ lib525_LDADD = $(LIBDIR)/libcurl.la lib525_DEPENDENCIES = $(LIBDIR)/libcurl.la lib526_SOURCES = lib526.c $(SUPPORTFILES) +lib526_CFLAGS = -DLIB526 lib526_LDADD = $(LIBDIR)/libcurl.la lib526_DEPENDENCIES = $(LIBDIR)/libcurl.la @@ -162,3 +163,8 @@ lib530_SOURCES = lib530.c $(SUPPORTFILES) lib530_CFLAGS = -DLIB530 lib530_LDADD = $(LIBDIR)/libcurl.la lib530_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib532_SOURCES = lib526.c $(SUPPORTFILES) +lib532_CFLAGS = -DLIB532 +lib532_LDADD = $(LIBDIR)/libcurl.la +lib532_DEPENDENCIES = $(LIBDIR)/libcurl.la diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 04240808f..bf16c510e 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -14,11 +14,17 @@ * sharing within the multi handle all transfers are performed on the same * persistent connection. * - * This source code is used for lib526 _and_ lib527 with only #ifdefs - * controlling the small differences. lib526 closes all easy handles after - * they all have transfered the file over the single connection, while lib527 - * closes each easy handle after each single transfer. 526 and 527 use FTP, - * while 528 uses the lib526 tool but use HTTP. + * This source code is used for lib526, lib527 and lib532 with only #ifdefs + * controlling the small differences. + * + * - lib526 closes all easy handles after + * they all have transfered the file over the single connection + * - lib527 closes each easy handle after each single transfer. + * - lib532 uses only a single easy handle that is removed, reset and then + * re-added for each transfer + * + * Test case 526, 527 and 532 use FTP, while test 528 uses the lib526 tool but + * with HTTP. */ #include "test.h" @@ -78,7 +84,21 @@ int test(char *URL) #endif 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]); + curl_easy_setopt(curl[0], CURLOPT_URL, URL); + curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1); + + /* re-add it */ + res = (int)curl_multi_add_handle(m, curl[0]); +#else res = (int)curl_multi_add_handle(m, curl[current]); +#endif if(res) { fprintf(stderr, "add handle failed: %d.\n", res); res = 243; @@ -121,7 +141,9 @@ int test(char *URL) #ifndef LIB527 /* get NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { +#ifdef LIB526 curl_multi_remove_handle(m, curl[i]); +#endif curl_easy_cleanup(curl[i]); } #endif -- cgit v1.2.1 From befc30bc55cebe958d652ec4f5d31aa8565773c1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 6 Oct 2006 21:19:57 +0000 Subject: Bogdan Nicula's hanging test case was converted to test case 533 and the test now runs fine. --- tests/libtest/Makefile.am | 7 ++- tests/libtest/lib533.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib533.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 01b702015..4b6070b5b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -42,7 +42,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 + lib529 lib530 lib532 lib533 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -168,3 +168,8 @@ lib532_SOURCES = lib526.c $(SUPPORTFILES) lib532_CFLAGS = -DLIB532 lib532_LDADD = $(LIBDIR)/libcurl.la lib532_DEPENDENCIES = $(LIBDIR)/libcurl.la + +lib533_SOURCES = lib533.c $(SUPPORTFILES) +lib533_LDADD = $(LIBDIR)/libcurl.la +lib533_DEPENDENCIES = $(LIBDIR)/libcurl.la + diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c new file mode 100644 index 000000000..60ff9d0eb --- /dev/null +++ b/tests/libtest/lib533.c @@ -0,0 +1,113 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include +#include +#include + +int test(char *URL) +{ + int res = 0; + CURL *curl; + int running; + char done=FALSE; + CURLM *m; + int current=0; + int i; + + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + curl = curl_easy_init(); + if(!curl) + return 100 + i; /* major bad */ + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* go verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + m = curl_multi_init(); + + res = (int)curl_multi_add_handle(m, curl); + + fprintf(stderr, "Start at URL 0\n"); + + while(!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; + + interval.tv_sec = 1; + interval.tv_usec = 0; + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = (int)curl_multi_perform(m, &running); + 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); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 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(done) + break; + + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + break; + } + + 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; + } + + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + res = 195; + break; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + + curl_easy_cleanup(curl); + curl_multi_cleanup(m); + + curl_global_cleanup(); + return res; +} -- cgit v1.2.1 From 2c62dfd1248d0313c582f686acdd1d0f4641171a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 8 Oct 2006 08:50:12 +0000 Subject: modified lib533 to accept both URLs on the command line --- tests/libtest/lib533.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 60ff9d0eb..e7e59677e 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -61,7 +61,7 @@ int test(char *URL) /* make us re-use the same handle all the time, and try resetting the handle first too */ curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_URL, arg2); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* re-add it */ -- cgit v1.2.1 From 2ad7fcbc2fdaab3c544dea037d2e451a255ef6a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 8 Oct 2006 10:51:53 +0000 Subject: test 534 added in an attempt to repeat Bogdan Nicula's bug... --- tests/libtest/lib533.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index e7e59677e..afbb7bd27 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -8,6 +8,8 @@ * $Id$ */ +/* used for test case 533 and 534 */ + #include "test.h" #include -- cgit v1.2.1 From a1de9367ecc17ae1d77e46b76fb1aba6c9f3ccb2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Oct 2006 06:58:05 +0000 Subject: Bogdan Nicula's second test case (posted Sun, 08 Oct 2006) converted to test case 535 and it now runs fine. Again a problem with the pipelining code not taking all possible (error) conditions into account. --- tests/libtest/lib533.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index afbb7bd27..3a1e7dff6 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -34,9 +34,8 @@ int test(char *URL) return 100 + i; /* major bad */ curl_easy_setopt(curl, CURLOPT_URL, URL); - - /* go verbose */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); m = curl_multi_init(); @@ -65,6 +64,7 @@ int test(char *URL) curl_easy_reset(curl); curl_easy_setopt(curl, CURLOPT_URL, arg2); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); /* re-add it */ res = (int)curl_multi_add_handle(m, curl); -- cgit v1.2.1 From 15e3dfe1d34040165d5ef12c69e8b91dc8eda8ef Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 9 Oct 2006 11:21:40 +0000 Subject: Compiler warning fix --- tests/libtest/lib533.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 3a1e7dff6..dab8f6bb6 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -24,14 +24,13 @@ int test(char *URL) char done=FALSE; CURLM *m; int current=0; - int i; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); if(!curl) - return 100 + i; /* major bad */ + return 100; /* major bad */ curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); -- cgit v1.2.1 From c144adf77c7e11ebb571399c50d022c88e020044 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Oct 2006 21:26:09 +0000 Subject: used for test 535 too --- tests/libtest/lib533.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index dab8f6bb6..a4b6877ef 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -8,7 +8,7 @@ * $Id$ */ -/* used for test case 533 and 534 */ +/* used for test case 533, 534 and 535 */ #include "test.h" -- cgit v1.2.1 From cbcdd337aaae878dc47df10f9c21f77cbebadc77 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Oct 2006 21:29:53 +0000 Subject: Added test case 536 in an attempt to add Bogdan Nicula's problematic case with multi interface and pipelining. This test just works and did not repeat the problem his test code showed, but could still serve as a useful test. --- tests/libtest/Makefile.am | 6 +++- tests/libtest/lib536.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib536.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 4b6070b5b..b8f58f331 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -42,7 +42,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 + lib529 lib530 lib532 lib533 lib536 lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_LDADD = $(LIBDIR)/libcurl.la @@ -173,3 +173,7 @@ lib533_SOURCES = lib533.c $(SUPPORTFILES) lib533_LDADD = $(LIBDIR)/libcurl.la lib533_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib536_SOURCES = lib536.c $(SUPPORTFILES) +lib536_LDADD = $(LIBDIR)/libcurl.la +lib536_DEPENDENCIES = $(LIBDIR)/libcurl.la + diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c new file mode 100644 index 000000000..a1099fe62 --- /dev/null +++ b/tests/libtest/lib536.c @@ -0,0 +1,82 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include +#include +#include + +static CURLMcode perform(CURLM * multi); + +static CURLMcode perform(CURLM * multi) +{ + int handles, maxfd; + CURLMcode code; + fd_set fdread, fdwrite, fdexcep; + + for (;;) { + code = curl_multi_perform(multi, &handles); + if (handles <= 0) + return CURLM_OK; + + switch (code) { + case CURLM_OK: + break; + case CURLM_CALL_MULTI_PERFORM: + continue; + default: + return code; + } + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + if (maxfd < 0) + return -1; + if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1) + return -1; + } +} + +int test(char *URL) +{ + CURLM *multi = curl_multi_init(); + CURL *easy = curl_easy_init(); + + curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1); + + curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); + curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); + curl_easy_setopt(easy, CURLOPT_URL, URL); + + curl_multi_add_handle(multi, easy); + if (perform(multi) != CURLM_OK) + printf("retrieve 1 failed\n"); + + curl_multi_remove_handle(multi, easy); + curl_easy_reset(easy); + + curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); + curl_easy_setopt(easy, CURLOPT_URL, arg2); + + curl_multi_add_handle(multi, easy); + if (perform(multi) != CURLM_OK) + printf("retrieve 2 failed\n"); + + curl_multi_remove_handle(multi, easy); + curl_easy_cleanup(easy); + curl_multi_cleanup(multi); + + printf("Finished!\n"); + + return 0; +} -- cgit v1.2.1 From 8274447dd9ad74bf179973679250175f29b174e9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 10 Oct 2006 23:50:37 +0000 Subject: Call curl_global_cleanup() in all code paths before exiting test --- tests/libtest/lib525.c | 6 ++++-- tests/libtest/lib526.c | 4 +++- tests/libtest/lib530.c | 4 +++- tests/libtest/lib533.c | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 240628028..9dcddaecf 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -45,9 +45,11 @@ int test(char *URL) /* get a curl handle */ curl = curl_easy_init(); - if(!curl) + if(!curl) { + fclose(hd_src); + curl_global_cleanup(); return 100; /* major bad */ - + } /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index bf16c510e..dce6a9f1b 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -51,8 +51,10 @@ int test(char *URL) /* get NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { curl[i] = curl_easy_init(); - if(!curl[i]) + if(!curl[i]) { + curl_global_cleanup(); return 100 + i; /* major bad */ + } curl_easy_setopt(curl[i], CURLOPT_URL, URL); /* go verbose */ diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 3e6cd3fac..d062886f4 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -32,8 +32,10 @@ int test(char *URL) /* get NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { curl[i] = curl_easy_init(); - if(!curl[i]) + if(!curl[i]) { + curl_global_cleanup(); return 100 + i; /* major bad */ + } curl_easy_setopt(curl[i], CURLOPT_URL, URL); /* go verbose */ diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index a4b6877ef..74499c232 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -29,8 +29,10 @@ int test(char *URL) curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); - if(!curl) + if(!curl) { + curl_global_cleanup(); return 100; /* major bad */ + } curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); -- cgit v1.2.1 From 943f0733bb187dfacdfdc23806ab030cee97c9fc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 10 Oct 2006 23:58:02 +0000 Subject: Compiler warning fix --- tests/libtest/lib536.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index a1099fe62..40b45e47d 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -41,9 +41,9 @@ static CURLMcode perform(CURLM * multi) FD_ZERO(&fdexcep); curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); if (maxfd < 0) - return -1; + return (CURLMcode) ~CURLM_OK; if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1) - return -1; + return (CURLMcode) ~CURLM_OK; } } -- cgit v1.2.1 From e150150d9f1e0578c85af05de15ab6336066cec1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 11 Oct 2006 16:01:16 +0000 Subject: Remove redundant __CYGWIN__ symbol check --- tests/libtest/first.c | 2 +- tests/libtest/lib518.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 8050537db..fda1a7fb5 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -12,7 +12,7 @@ int test(char *url); int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv) { -#if defined(WIN32) && !defined(__CYGWIN__) +#ifdef WIN32 /* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is * case when 'num_fds <= 0. So sleep. */ diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index d0c200774..1c858ee35 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -32,7 +32,7 @@ #define NUM_OPEN (FD_SETSIZE + 10) #define NUM_NEEDED (NUM_OPEN + 16) -#if (defined(WIN32) || defined(_WIN32) || defined(MSDOS)) && !defined(__CYGWIN__) +#if defined(WIN32) || defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" #else #define DEV_NULL "/dev/null" -- cgit v1.2.1 From 5df4be11657fc49d74e1e6b39c0003f7cf2f3772 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Oct 2006 21:05:40 +0000 Subject: Check for USE_WINSOCK instead of WIN32 where the check was done to verify winsock API availability. --- tests/libtest/first.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index fda1a7fb5..782daca17 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -12,7 +12,7 @@ int test(char *url); int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv) { -#ifdef WIN32 +#ifdef USE_WINSOCK /* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is * case when 'num_fds <= 0. So sleep. */ -- cgit v1.2.1 From ead6ab2ef765ec8c917ba8f5424d72a6624b0b20 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 17:29:25 +0000 Subject: Abort test if it seems that it would have run forever. This is just to prevent test hanging and actually is an indication that there's a condition that is not being properly handled at some point in the library. Loop counter limits might need to be further increased on false positives. --- tests/libtest/lib504.c | 15 ++++++++++++--- tests/libtest/lib507.c | 29 +++++++++++++++++++++-------- tests/libtest/lib509.c | 30 ++++++++++++++++++++++-------- tests/libtest/lib525.c | 15 ++++++++++++--- tests/libtest/lib526.c | 15 ++++++++++++--- tests/libtest/lib530.c | 15 ++++++++++++--- tests/libtest/lib533.c | 15 ++++++++++++--- tests/libtest/lib536.c | 8 +++++++- 8 files changed, 110 insertions(+), 32 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 843e9ebd0..fed91232c 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -20,7 +20,8 @@ int test(char *URL) int running; int max_fd; int rc; - int loop=10; + int loop1 = 10; + int loop2 = 20; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -42,12 +43,15 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; + int loop2 = 20; fprintf(stderr, "curl_multi_perform()\n"); do { res = curl_multi_perform(m, &running); - } while (res == CURLM_CALL_MULTI_PERFORM); + } while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)); + if (loop2 <= 0) + break; if(!running) { /* This is where this code is expected to reach */ int numleft; @@ -82,7 +86,12 @@ int test(char *URL) /* we only allow a certain number of loops to avoid hanging here forever */ - } while(--loop>0); + } while(--loop1>0); + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + ret = 77; + } } curl_multi_remove_handle(m, c); diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 8fc4ca3ce..e4b1e35a8 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -7,6 +7,8 @@ int test(char *URL) int still_running; int i = -1; CURLMsg *msg; + int loop1 = 20; + int loop2 = 40; multi = curl_multi_init(); @@ -14,8 +16,10 @@ int test(char *URL) curl_easy_setopt(curls, CURLOPT_URL, URL); curl_multi_add_handle(multi, curls); - while ( CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi, &still_running) ); - while(still_running) { + while ((--loop1>0) && (CURLM_CALL_MULTI_PERFORM == + curl_multi_perform(multi, &still_running))); + + while ((loop1>0) && (--loop2>0) && (still_running)) { struct timeval timeout; int rc; fd_set fdread; @@ -34,15 +38,24 @@ int test(char *URL) break; case 0: default: - while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multi, &still_running)); + loop1 = 20; + while ((--loop1>0) && (CURLM_CALL_MULTI_PERFORM == + curl_multi_perform(multi, &still_running))); break; } } - 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; + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + i = 77; + } + 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; + } curl_multi_cleanup(multi); curl_easy_cleanup(curls); diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 415208ac7..9327d728f 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -175,6 +175,9 @@ int test(char *URL) int i = 0; CURLMsg *msg; + int loop1 = 40; + int loop2 = 20; + if(arg2) { portnum = atoi(arg2); } @@ -205,15 +208,16 @@ int test(char *URL) res = curl_multi_add_handle(multi, p.curl); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = curl_multi_perform(multi, &running); fprintf(stderr, "running=%d res=%d\n",running,res); if (running <= 0) { @@ -221,7 +225,7 @@ int test(char *URL) break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -249,13 +253,23 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - msg = curl_multi_info_read(multi, &running); - /* this should now contain a result code from the easy handle, get it */ - if(msg) - i = msg->data.result; + + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + i = 77; + } + else { + msg = curl_multi_info_read(multi, &running); + /* this should now contain a result code from the easy handle, get it */ + if(msg) + i = msg->data.result; + } } - fprintf(stderr, "all done\n"); + if ((loop1>0) && (loop2>0)) { + fprintf(stderr, "all done\n"); + } curl_multi_remove_handle(multi, p.curl); curl_easy_cleanup(p.curl); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 9dcddaecf..b5b522de1 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -24,6 +24,8 @@ int test(char *URL) int running; char done=FALSE; CURLM *m; + int loop1 = 40; + int loop2 = 20; if (!arg2) { fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); @@ -82,22 +84,23 @@ int test(char *URL) res = (int)curl_multi_add_handle(m, curl); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = (int)curl_multi_perform(m, &running); if (running <= 0) { done = TRUE; break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -125,6 +128,12 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + res = 77; + } + #ifdef LIB529 /* test 529 */ curl_multi_remove_handle(m, curl); diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index dce6a9f1b..e521b6021 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -44,6 +44,8 @@ int test(char *URL) CURLM *m; int current=0; int i; + int loop1 = 40; + int loop2 = 20; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -67,15 +69,16 @@ int test(char *URL) fprintf(stderr, "Start at URL 0\n"); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = (int)curl_multi_perform(m, &running); if (running <= 0) { #ifdef LIB527 @@ -112,7 +115,7 @@ int test(char *URL) break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -140,6 +143,12 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + res = 77; + } + #ifndef LIB527 /* get NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index d062886f4..6ee346d94 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -23,6 +23,8 @@ int test(char *URL) char done=FALSE; CURLM *m; int i; + int loop1 = 40; + int loop2 = 20; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -51,22 +53,23 @@ int test(char *URL) fprintf(stderr, "Start at URL 0\n"); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = (int)curl_multi_perform(m, &running); if (running <= 0) { done = TRUE; /* bail out */ break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -94,6 +97,12 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + res = 77; + } + /* get NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { curl_multi_remove_handle(m, curl[i]); diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 74499c232..4403f75ff 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -24,6 +24,8 @@ int test(char *URL) char done=FALSE; CURLM *m; int current=0; + int loop1 = 40; + int loop2 = 20; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -44,15 +46,16 @@ int test(char *URL) fprintf(stderr, "Start at URL 0\n"); - while(!done) { + while ((--loop1>0) && (loop2>0) && (!done)) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; + loop2 = 20; - while (res == CURLM_CALL_MULTI_PERFORM) { + while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = (int)curl_multi_perform(m, &running); if (running <= 0) { if(!current++) { @@ -80,7 +83,7 @@ int test(char *URL) break; } } - if(done) + if ((loop2 <= 0) || (done)) break; if (res != CURLM_OK) { @@ -108,6 +111,12 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } + if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + res = 77; + } + curl_easy_cleanup(curl); curl_multi_cleanup(m); diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 40b45e47d..53439c797 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -21,8 +21,9 @@ static CURLMcode perform(CURLM * multi) int handles, maxfd; CURLMcode code; fd_set fdread, fdwrite, fdexcep; + int loop; - for (;;) { + for (loop=40;loop>0;loop--) { code = curl_multi_perform(multi, &handles); if (handles <= 0) return CURLM_OK; @@ -45,6 +46,11 @@ static CURLMcode perform(CURLM * multi) if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1) return (CURLMcode) ~CURLM_OK; } + if (loop <= 0) { + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + return (CURLMcode) ~CURLM_OK; + } } int test(char *URL) -- cgit v1.2.1 From c818e7064f461c347108ccf291e73925cb6be512 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 21:12:27 +0000 Subject: When aborting, show loop counter values when more than one counter exists. --- tests/libtest/lib504.c | 1 + tests/libtest/lib507.c | 1 + tests/libtest/lib509.c | 1 + tests/libtest/lib525.c | 1 + tests/libtest/lib526.c | 1 + tests/libtest/lib530.c | 1 + tests/libtest/lib533.c | 1 + 7 files changed, 7 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index fed91232c..cba069122 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -88,6 +88,7 @@ int test(char *URL) forever */ } while(--loop1>0); if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); ret = 77; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index e4b1e35a8..9a98da728 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -45,6 +45,7 @@ int test(char *URL) } } if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); i = 77; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 9327d728f..5d385c966 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -255,6 +255,7 @@ int test(char *URL) } if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); i = 77; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index b5b522de1..35c504b97 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -129,6 +129,7 @@ int test(char *URL) } if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); res = 77; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index e521b6021..91d9206e7 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -144,6 +144,7 @@ int test(char *URL) } if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); res = 77; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 6ee346d94..e73f26f36 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -98,6 +98,7 @@ int test(char *URL) } if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); res = 77; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 4403f75ff..b0d63a10e 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -112,6 +112,7 @@ int test(char *URL) } if ((loop1 <= 0) || (loop2 <= 0)) { + fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); res = 77; -- cgit v1.2.1 From 4f6ed683e83fb67388067ab16dee07cfb7368fab Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 22:48:33 +0000 Subject: Compiler warning fix --- tests/libtest/lib504.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index cba069122..8c5700dac 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -43,7 +43,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - int loop2 = 20; + loop2 = 20; fprintf(stderr, "curl_multi_perform()\n"); -- cgit v1.2.1 From ef267ab4491a082cf7a86127ac0937ac1e0c249a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 22:49:33 +0000 Subject: Replace tabs with spaces and Compiler warning fix. --- tests/libtest/lib536.c | 108 ++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 53439c797..2e7874051 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -18,71 +18,71 @@ static CURLMcode perform(CURLM * multi); static CURLMcode perform(CURLM * multi) { - int handles, maxfd; - CURLMcode code; - fd_set fdread, fdwrite, fdexcep; - int loop; - - for (loop=40;loop>0;loop--) { - code = curl_multi_perform(multi, &handles); - if (handles <= 0) - return CURLM_OK; - - switch (code) { - case CURLM_OK: - break; - case CURLM_CALL_MULTI_PERFORM: - continue; - default: - return code; - } - - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcep); - curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); - if (maxfd < 0) - return (CURLMcode) ~CURLM_OK; - if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1) - return (CURLMcode) ~CURLM_OK; - } - if (loop <= 0) { - fprintf(stderr, "ABORTING TEST, since it seems " - "that it would have run forever.\n"); - return (CURLMcode) ~CURLM_OK; - } + int handles, maxfd; + CURLMcode code; + fd_set fdread, fdwrite, fdexcep; + int loop; + + for (loop=40;loop>0;loop--) { + code = curl_multi_perform(multi, &handles); + if (handles <= 0) + return CURLM_OK; + + switch (code) { + case CURLM_OK: + break; + case CURLM_CALL_MULTI_PERFORM: + continue; + default: + return code; + } + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + if (maxfd < 0) + return (CURLMcode) ~CURLM_OK; + if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1) + return (CURLMcode) ~CURLM_OK; + } + + /* We only reach this point if (loop <= 0) */ + fprintf(stderr, "ABORTING TEST, since it seems " + "that it would have run forever.\n"); + return (CURLMcode) ~CURLM_OK; } int test(char *URL) { - CURLM *multi = curl_multi_init(); - CURL *easy = curl_easy_init(); + CURLM *multi = curl_multi_init(); + CURL *easy = curl_easy_init(); - curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1); + curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1); - curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); - curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(easy, CURLOPT_URL, URL); + curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); + curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); + curl_easy_setopt(easy, CURLOPT_URL, URL); - curl_multi_add_handle(multi, easy); - if (perform(multi) != CURLM_OK) - printf("retrieve 1 failed\n"); + curl_multi_add_handle(multi, easy); + if (perform(multi) != CURLM_OK) + printf("retrieve 1 failed\n"); - curl_multi_remove_handle(multi, easy); - curl_easy_reset(easy); + curl_multi_remove_handle(multi, easy); + curl_easy_reset(easy); - curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(easy, CURLOPT_URL, arg2); + curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); + curl_easy_setopt(easy, CURLOPT_URL, arg2); - curl_multi_add_handle(multi, easy); - if (perform(multi) != CURLM_OK) - printf("retrieve 2 failed\n"); + curl_multi_add_handle(multi, easy); + if (perform(multi) != CURLM_OK) + printf("retrieve 2 failed\n"); - curl_multi_remove_handle(multi, easy); - curl_easy_cleanup(easy); - curl_multi_cleanup(multi); + curl_multi_remove_handle(multi, easy); + curl_easy_cleanup(easy); + curl_multi_cleanup(multi); - printf("Finished!\n"); + printf("Finished!\n"); - return 0; + return 0; } -- cgit v1.2.1 From 19e07771d1709fd1e38bde7a4ed34bc104b01884 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Oct 2006 23:35:52 +0000 Subject: Set loop2 counter limit to 60 on this test to avoid a false positive. --- tests/libtest/lib530.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index e73f26f36..e83edb20c 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -24,7 +24,7 @@ int test(char *URL) CURLM *m; int i; int loop1 = 40; - int loop2 = 20; + int loop2 = 60; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -60,7 +60,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 20; + loop2 = 60; while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { res = (int)curl_multi_perform(m, &running); -- cgit v1.2.1 From b9ccecf86e96e173ffe3b4026c84e61e53d3ff68 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 20 Oct 2006 15:39:54 +0000 Subject: Decrease the posibility of aborting a test which actually is not stale by replacing loop counters with timeouts. In this way the main loop of the test will be allowed to run up to 30 seconds on any platform before aborting it. --- tests/libtest/lib504.c | 43 +++++++++++++++++++++++++++++--------- tests/libtest/lib507.c | 56 +++++++++++++++++++++++++++++++++++++++++--------- tests/libtest/lib509.c | 41 ++++++++++++++++++++++++++++-------- tests/libtest/lib525.c | 39 +++++++++++++++++++++++++++-------- tests/libtest/lib526.c | 39 +++++++++++++++++++++++++++-------- tests/libtest/lib530.c | 39 +++++++++++++++++++++++++++-------- tests/libtest/lib533.c | 39 +++++++++++++++++++++++++++-------- tests/libtest/lib536.c | 21 ++++++++++++++++--- 8 files changed, 253 insertions(+), 64 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 8c5700dac..e925097ee 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -3,6 +3,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + /* * Source code in here hugely as reported in bug report 651464 by * Christopher R. Palmer. @@ -20,8 +25,10 @@ int test(char *URL) int running; int max_fd; int rc; - int loop1 = 10; - int loop2 = 20; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -38,19 +45,36 @@ int test(char *URL) if(res && (res != CURLM_CALL_MULTI_PERFORM)) ; /* major failure */ else { + + ml_timedout = FALSE; + ml_start = curlx_tvnow(); + do { struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 20; + + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } fprintf(stderr, "curl_multi_perform()\n"); + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + do { res = curl_multi_perform(m, &running); - } while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)); - if (loop2 <= 0) + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } + } while (res == CURLM_CALL_MULTI_PERFORM); + if (mp_timedout) break; if(!running) { /* This is where this code is expected to reach */ @@ -84,11 +108,10 @@ int test(char *URL) rc = select_test(max_fd+1, &rd, &wr, &exc, &interval); fprintf(stderr, "select returned %d\n", rc); - /* we only allow a certain number of loops to avoid hanging here - forever */ - } while(--loop1>0); - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + } while(1); + 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"); ret = 77; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 9a98da728..b06d65fe2 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -1,5 +1,10 @@ #include "test.h" +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + int test(char *URL) { CURL* curls; @@ -7,8 +12,11 @@ int test(char *URL) int still_running; int i = -1; CURLMsg *msg; - int loop1 = 20; - int loop2 = 40; + CURLMcode res; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; multi = curl_multi_init(); @@ -16,21 +24,41 @@ int test(char *URL) curl_easy_setopt(curls, CURLOPT_URL, URL); curl_multi_add_handle(multi, curls); - while ((--loop1>0) && (CURLM_CALL_MULTI_PERFORM == - curl_multi_perform(multi, &still_running))); + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + do { + res = curl_multi_perform(multi, &still_running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } + } while (res == CURLM_CALL_MULTI_PERFORM); + + ml_timedout = FALSE; + ml_start = curlx_tvnow(); - while ((loop1>0) && (--loop2>0) && (still_running)) { + while ((!ml_timedout) && (!mp_timedout) && (still_running)) { struct timeval timeout; int rc; fd_set fdread; fd_set fdwrite; fd_set fdexcep; int maxfd; + FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); timeout.tv_sec = 1; timeout.tv_usec = 0; + + if (curlx_tvdiff(curlx_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) { @@ -38,14 +66,22 @@ int test(char *URL) break; case 0: default: - loop1 = 20; - while ((--loop1>0) && (CURLM_CALL_MULTI_PERFORM == - curl_multi_perform(multi, &still_running))); + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + do { + res = curl_multi_perform(multi, &still_running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } + } while (res == CURLM_CALL_MULTI_PERFORM); break; } } - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + 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 = 77; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 5d385c966..77d5e1c6b 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -18,6 +18,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + int portnum; /* the HTTPS port number we use */ typedef struct sslctxparm_st { @@ -175,8 +180,10 @@ int test(char *URL) int i = 0; CURLMsg *msg; - int loop1 = 40; - int loop2 = 20; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; if(arg2) { portnum = atoi(arg2); @@ -208,24 +215,39 @@ int test(char *URL) res = curl_multi_add_handle(multi, p.curl); - while ((--loop1>0) && (loop2>0) && (!done)) { + ml_timedout = FALSE; + ml_start = curlx_tvnow(); + + while (!done) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 20; - while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(multi, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } fprintf(stderr, "running=%d res=%d\n",running,res); if (running <= 0) { done = TRUE; break; } } - if ((loop2 <= 0) || (done)) + if (mp_timedout || done) break; if (res != CURLM_OK) { @@ -254,8 +276,9 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + 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 = 77; @@ -268,7 +291,7 @@ int test(char *URL) } } - if ((loop1>0) && (loop2>0)) { + if ((!ml_timedout) && (!mp_timedout)) { fprintf(stderr, "all done\n"); } diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 35c504b97..7ed10dcb7 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -14,6 +14,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + int test(char *URL) { int res = 0; @@ -24,8 +29,10 @@ int test(char *URL) int running; char done=FALSE; CURLM *m; - int loop1 = 40; - int loop2 = 20; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; if (!arg2) { fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); @@ -84,23 +91,38 @@ int test(char *URL) res = (int)curl_multi_add_handle(m, curl); - while ((--loop1>0) && (loop2>0) && (!done)) { + ml_timedout = FALSE; + ml_start = curlx_tvnow(); + + while (!done) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 20; - while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } if (running <= 0) { done = TRUE; break; } } - if ((loop2 <= 0) || (done)) + if (mp_timedout || done) break; if (res != CURLM_OK) { @@ -128,8 +150,9 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + 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 = 77; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 91d9206e7..c09dbb7cd 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -33,6 +33,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + #define NUM_HANDLES 4 int test(char *URL) @@ -44,8 +49,10 @@ int test(char *URL) CURLM *m; int current=0; int i; - int loop1 = 40; - int loop2 = 20; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -67,19 +74,34 @@ int test(char *URL) res = (int)curl_multi_add_handle(m, curl[current]); + ml_timedout = FALSE; + ml_start = curlx_tvnow(); + fprintf(stderr, "Start at URL 0\n"); - while ((--loop1>0) && (loop2>0) && (!done)) { + while (!done) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 20; - while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } if (running <= 0) { #ifdef LIB527 /* NOTE: this code does not remove the handle from the multi handle @@ -115,7 +137,7 @@ int test(char *URL) break; } } - if ((loop2 <= 0) || (done)) + if (mp_timedout || done) break; if (res != CURLM_OK) { @@ -143,8 +165,9 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + 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 = 77; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index e83edb20c..e68273c75 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -13,6 +13,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + #define NUM_HANDLES 4 int test(char *URL) @@ -23,8 +28,10 @@ int test(char *URL) char done=FALSE; CURLM *m; int i; - int loop1 = 40; - int loop2 = 60; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -51,25 +58,40 @@ int test(char *URL) curl_multi_setopt(m, CURLMOPT_PIPELINING, 1); + ml_timedout = FALSE; + ml_start = curlx_tvnow(); + fprintf(stderr, "Start at URL 0\n"); - while ((--loop1>0) && (loop2>0) && (!done)) { + while (!done) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 60; - while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } if (running <= 0) { done = TRUE; /* bail out */ break; } } - if ((loop2 <= 0) || (done)) + if (mp_timedout || done) break; if (res != CURLM_OK) { @@ -97,8 +119,9 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + 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 = 77; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index b0d63a10e..24c36d0d0 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -16,6 +16,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + int test(char *URL) { int res = 0; @@ -24,8 +29,10 @@ int test(char *URL) char done=FALSE; CURLM *m; int current=0; - int loop1 = 40; - int loop2 = 20; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); @@ -44,19 +51,34 @@ int test(char *URL) res = (int)curl_multi_add_handle(m, curl); + ml_timedout = FALSE; + ml_start = curlx_tvnow(); + fprintf(stderr, "Start at URL 0\n"); - while ((--loop1>0) && (loop2>0) && (!done)) { + while (!done) { fd_set rd, wr, exc; int max_fd; struct timeval interval; interval.tv_sec = 1; interval.tv_usec = 0; - loop2 = 20; - while ((--loop2>0) && (res == CURLM_CALL_MULTI_PERFORM)) { + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } if (running <= 0) { if(!current++) { fprintf(stderr, "Advancing to URL 1\n"); @@ -83,7 +105,7 @@ int test(char *URL) break; } } - if ((loop2 <= 0) || (done)) + if (mp_timedout || done) break; if (res != CURLM_OK) { @@ -111,8 +133,9 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; } - if ((loop1 <= 0) || (loop2 <= 0)) { - fprintf(stderr, "loop1: %d loop2: %d \n", loop1, loop2); + 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 = 77; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 2e7874051..4181b829c 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -14,6 +14,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + static CURLMcode perform(CURLM * multi); static CURLMcode perform(CURLM * multi) @@ -21,10 +26,19 @@ static CURLMcode perform(CURLM * multi) int handles, maxfd; CURLMcode code; fd_set fdread, fdwrite, fdexcep; - int loop; + struct timeval mp_start; + char mp_timedout = FALSE; - for (loop=40;loop>0;loop--) { + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + for (;;) { code = curl_multi_perform(multi, &handles); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } if (handles <= 0) return CURLM_OK; @@ -47,7 +61,8 @@ static CURLMcode perform(CURLM * multi) return (CURLMcode) ~CURLM_OK; } - /* We only reach this point if (loop <= 0) */ + /* We only reach this point 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; -- cgit v1.2.1 From d997ff6aa8150e356c90736f735738e81190d1ed Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 20 Oct 2006 15:45:12 +0000 Subject: Oops! Actually set the limit to 30 seconds. --- tests/libtest/lib504.c | 4 ++-- tests/libtest/lib507.c | 4 ++-- tests/libtest/lib509.c | 4 ++-- tests/libtest/lib525.c | 4 ++-- tests/libtest/lib526.c | 4 ++-- tests/libtest/lib530.c | 4 ++-- tests/libtest/lib533.c | 4 ++-- tests/libtest/lib536.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index e925097ee..af7ca4bc4 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -5,8 +5,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 /* * Source code in here hugely as reported in bug report 651464 by diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index b06d65fe2..e13201d1a 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -2,8 +2,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 int test(char *URL) { diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 77d5e1c6b..bdc895195 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -20,8 +20,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 int portnum; /* the HTTPS port number we use */ diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 7ed10dcb7..01f34118a 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -16,8 +16,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 int test(char *URL) { diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index c09dbb7cd..fc1c788af 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -35,8 +35,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 #define NUM_HANDLES 4 diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index e68273c75..88c65767d 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -15,8 +15,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 #define NUM_HANDLES 4 diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 24c36d0d0..bd0cef306 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -18,8 +18,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 int test(char *URL) { diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 4181b829c..ca6c5c6b5 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -16,8 +16,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 45 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 static CURLMcode perform(CURLM * multi); -- cgit v1.2.1 From 33acd6f041ad3f31a985da1cf54668d0e619535d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 21 Oct 2006 10:54:41 +0000 Subject: Compiler warning fix --- tests/libtest/lib536.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index ca6c5c6b5..6ac24b40d 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -62,7 +62,7 @@ static CURLMcode perform(CURLM * multi) } /* We only reach this point if (mp_timedout) */ - fprintf(stderr, "mp_timedout\n"); + 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; -- cgit v1.2.1 From deb81b2ad40862cdf8e9e18274c670117c370861 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 21 Oct 2006 11:40:04 +0000 Subject: Nir Soffer made the tests/libtest/Makefile.am use a proper variable for all the single test applications' link and dependences, so that you easier can override those from the command line when using make. --- tests/libtest/Makefile.am | 132 ++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 64 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index b8f58f331..9e49db677 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -44,136 +44,140 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 +# Dependencies (may need to be overriden) +LDADD = $(LIBDIR)/libcurl.la +DEPENDENCIES = $(LIBDIR)/libcurl.la + lib500_SOURCES = lib500.c $(SUPPORTFILES) -lib500_LDADD = $(LIBDIR)/libcurl.la -lib500_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib500_LDADD = $(LDADD) +lib500_DEPENDENCIES = $(DEPENDENCIES) lib501_SOURCES = lib501.c $(SUPPORTFILES) -lib501_LDADD = $(LIBDIR)/libcurl.la -lib501_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib501_LDADD = $(LDADD) +lib501_DEPENDENCIES = $(DEPENDENCIES) lib502_SOURCES = lib502.c $(SUPPORTFILES) -lib502_LDADD = $(LIBDIR)/libcurl.la -lib502_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib502_LDADD = $(LDADD) +lib502_DEPENDENCIES = $(DEPENDENCIES) lib503_SOURCES = lib503.c $(SUPPORTFILES) -lib503_LDADD = $(LIBDIR)/libcurl.la -lib503_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib503_LDADD = $(LDADD) +lib503_DEPENDENCIES = $(DEPENDENCIES) lib504_SOURCES = lib504.c $(SUPPORTFILES) -lib504_LDADD = $(LIBDIR)/libcurl.la -lib504_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib504_LDADD = $(LDADD) +lib504_DEPENDENCIES = $(DEPENDENCIES) lib505_SOURCES = lib505.c $(SUPPORTFILES) -lib505_LDADD = $(LIBDIR)/libcurl.la -lib505_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib505_LDADD = $(LDADD) +lib505_DEPENDENCIES = $(DEPENDENCIES) lib506_SOURCES = lib506.c $(SUPPORTFILES) -lib506_LDADD = $(LIBDIR)/libcurl.la -lib506_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib506_LDADD = $(LDADD) +lib506_DEPENDENCIES = $(DEPENDENCIES) lib507_SOURCES = lib507.c $(SUPPORTFILES) -lib507_LDADD = $(LIBDIR)/libcurl.la -lib507_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib507_LDADD = $(LDADD) +lib507_DEPENDENCIES = $(DEPENDENCIES) lib508_SOURCES = lib508.c $(SUPPORTFILES) -lib508_LDADD = $(LIBDIR)/libcurl.la -lib508_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib508_LDADD = $(LDADD) +lib508_DEPENDENCIES = $(DEPENDENCIES) lib509_SOURCES = lib509.c $(SUPPORTFILES) -lib509_LDADD = $(LIBDIR)/libcurl.la -lib509_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib509_LDADD = $(LDADD) +lib509_DEPENDENCIES = $(DEPENDENCIES) lib510_SOURCES = lib510.c $(SUPPORTFILES) -lib510_LDADD = $(LIBDIR)/libcurl.la -lib510_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib510_LDADD = $(LDADD) +lib510_DEPENDENCIES = $(DEPENDENCIES) lib511_SOURCES = lib511.c $(SUPPORTFILES) -lib511_LDADD = $(LIBDIR)/libcurl.la -lib511_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib511_LDADD = $(LDADD) +lib511_DEPENDENCIES = $(DEPENDENCIES) lib512_SOURCES = lib512.c $(SUPPORTFILES) -lib512_LDADD = $(LIBDIR)/libcurl.la -lib512_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib512_LDADD = $(LDADD) +lib512_DEPENDENCIES = $(DEPENDENCIES) lib513_SOURCES = lib513.c $(SUPPORTFILES) -lib513_LDADD = $(LIBDIR)/libcurl.la -lib513_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib513_LDADD = $(LDADD) +lib513_DEPENDENCIES = $(DEPENDENCIES) lib514_SOURCES = lib514.c $(SUPPORTFILES) -lib514_LDADD = $(LIBDIR)/libcurl.la -lib514_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib514_LDADD = $(LDADD) +lib514_DEPENDENCIES = $(DEPENDENCIES) lib515_SOURCES = lib515.c $(SUPPORTFILES) -lib515_LDADD = $(LIBDIR)/libcurl.la -lib515_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib515_LDADD = $(LDADD) +lib515_DEPENDENCIES = $(DEPENDENCIES) lib516_SOURCES = lib516.c $(SUPPORTFILES) -lib516_LDADD = $(LIBDIR)/libcurl.la -lib516_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib516_LDADD = $(LDADD) +lib516_DEPENDENCIES = $(DEPENDENCIES) lib517_SOURCES = lib517.c $(SUPPORTFILES) -lib517_LDADD = $(LIBDIR)/libcurl.la -lib517_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib517_LDADD = $(LDADD) +lib517_DEPENDENCIES = $(DEPENDENCIES) lib518_SOURCES = lib518.c $(SUPPORTFILES) -lib518_LDADD = $(LIBDIR)/libcurl.la -lib518_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib518_LDADD = $(LDADD) +lib518_DEPENDENCIES = $(DEPENDENCIES) lib519_SOURCES = lib519.c $(SUPPORTFILES) -lib519_LDADD = $(LIBDIR)/libcurl.la -lib519_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib519_LDADD = $(LDADD) +lib519_DEPENDENCIES = $(DEPENDENCIES) lib520_SOURCES = lib520.c $(SUPPORTFILES) -lib520_LDADD = $(LIBDIR)/libcurl.la -lib520_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib520_LDADD = $(LDADD) +lib520_DEPENDENCIES = $(DEPENDENCIES) lib521_SOURCES = lib521.c $(SUPPORTFILES) -lib521_LDADD = $(LIBDIR)/libcurl.la -lib521_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib521_LDADD = $(LDADD) +lib521_DEPENDENCIES = $(DEPENDENCIES) lib523_SOURCES = lib523.c $(SUPPORTFILES) -lib523_LDADD = $(LIBDIR)/libcurl.la -lib523_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib523_LDADD = $(LDADD) +lib523_DEPENDENCIES = $(DEPENDENCIES) lib524_SOURCES = lib524.c $(SUPPORTFILES) -lib524_LDADD = $(LIBDIR)/libcurl.la -lib524_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib524_LDADD = $(LDADD) +lib524_DEPENDENCIES = $(DEPENDENCIES) lib525_SOURCES = lib525.c $(SUPPORTFILES) -lib525_LDADD = $(LIBDIR)/libcurl.la -lib525_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib525_LDADD = $(LDADD) +lib525_DEPENDENCIES = $(DEPENDENCIES) lib526_SOURCES = lib526.c $(SUPPORTFILES) lib526_CFLAGS = -DLIB526 -lib526_LDADD = $(LIBDIR)/libcurl.la -lib526_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib526_LDADD = $(LDADD) +lib526_DEPENDENCIES = $(DEPENDENCIES) lib527_SOURCES = lib526.c $(SUPPORTFILES) lib527_CFLAGS = -DLIB527 -lib527_LDADD = $(LIBDIR)/libcurl.la -lib527_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib527_LDADD = $(LDADD) +lib527_DEPENDENCIES = $(DEPENDENCIES) lib529_SOURCES = lib525.c $(SUPPORTFILES) lib529_CFLAGS = -DLIB529 -lib529_LDADD = $(LIBDIR)/libcurl.la -lib529_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib529_LDADD = $(LDADD) +lib529_DEPENDENCIES = $(DEPENDENCIES) lib530_SOURCES = lib530.c $(SUPPORTFILES) lib530_CFLAGS = -DLIB530 -lib530_LDADD = $(LIBDIR)/libcurl.la -lib530_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib530_LDADD = $(LDADD) +lib530_DEPENDENCIES = $(DEPENDENCIES) lib532_SOURCES = lib526.c $(SUPPORTFILES) lib532_CFLAGS = -DLIB532 -lib532_LDADD = $(LIBDIR)/libcurl.la -lib532_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib532_LDADD = $(LDADD) +lib532_DEPENDENCIES = $(DEPENDENCIES) lib533_SOURCES = lib533.c $(SUPPORTFILES) -lib533_LDADD = $(LIBDIR)/libcurl.la -lib533_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib533_LDADD = $(LDADD) +lib533_DEPENDENCIES = $(DEPENDENCIES) lib536_SOURCES = lib536.c $(SUPPORTFILES) -lib536_LDADD = $(LIBDIR)/libcurl.la -lib536_DEPENDENCIES = $(LIBDIR)/libcurl.la +lib536_LDADD = $(LDADD) +lib536_DEPENDENCIES = $(DEPENDENCIES) -- cgit v1.2.1 From 90933ac66087ddb751df157669477f60517f1da0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 21 Oct 2006 13:00:51 +0000 Subject: rely on the global LDADD instead of having specific ones for every program --- tests/libtest/Makefile.am | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 9e49db677..f7f901c80 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -49,135 +49,103 @@ LDADD = $(LIBDIR)/libcurl.la DEPENDENCIES = $(LIBDIR)/libcurl.la lib500_SOURCES = lib500.c $(SUPPORTFILES) -lib500_LDADD = $(LDADD) lib500_DEPENDENCIES = $(DEPENDENCIES) lib501_SOURCES = lib501.c $(SUPPORTFILES) -lib501_LDADD = $(LDADD) lib501_DEPENDENCIES = $(DEPENDENCIES) lib502_SOURCES = lib502.c $(SUPPORTFILES) -lib502_LDADD = $(LDADD) lib502_DEPENDENCIES = $(DEPENDENCIES) lib503_SOURCES = lib503.c $(SUPPORTFILES) -lib503_LDADD = $(LDADD) lib503_DEPENDENCIES = $(DEPENDENCIES) lib504_SOURCES = lib504.c $(SUPPORTFILES) -lib504_LDADD = $(LDADD) lib504_DEPENDENCIES = $(DEPENDENCIES) lib505_SOURCES = lib505.c $(SUPPORTFILES) -lib505_LDADD = $(LDADD) lib505_DEPENDENCIES = $(DEPENDENCIES) lib506_SOURCES = lib506.c $(SUPPORTFILES) -lib506_LDADD = $(LDADD) lib506_DEPENDENCIES = $(DEPENDENCIES) lib507_SOURCES = lib507.c $(SUPPORTFILES) -lib507_LDADD = $(LDADD) lib507_DEPENDENCIES = $(DEPENDENCIES) lib508_SOURCES = lib508.c $(SUPPORTFILES) -lib508_LDADD = $(LDADD) lib508_DEPENDENCIES = $(DEPENDENCIES) lib509_SOURCES = lib509.c $(SUPPORTFILES) -lib509_LDADD = $(LDADD) lib509_DEPENDENCIES = $(DEPENDENCIES) lib510_SOURCES = lib510.c $(SUPPORTFILES) -lib510_LDADD = $(LDADD) lib510_DEPENDENCIES = $(DEPENDENCIES) lib511_SOURCES = lib511.c $(SUPPORTFILES) -lib511_LDADD = $(LDADD) lib511_DEPENDENCIES = $(DEPENDENCIES) lib512_SOURCES = lib512.c $(SUPPORTFILES) -lib512_LDADD = $(LDADD) lib512_DEPENDENCIES = $(DEPENDENCIES) lib513_SOURCES = lib513.c $(SUPPORTFILES) -lib513_LDADD = $(LDADD) lib513_DEPENDENCIES = $(DEPENDENCIES) lib514_SOURCES = lib514.c $(SUPPORTFILES) -lib514_LDADD = $(LDADD) lib514_DEPENDENCIES = $(DEPENDENCIES) lib515_SOURCES = lib515.c $(SUPPORTFILES) -lib515_LDADD = $(LDADD) lib515_DEPENDENCIES = $(DEPENDENCIES) lib516_SOURCES = lib516.c $(SUPPORTFILES) -lib516_LDADD = $(LDADD) lib516_DEPENDENCIES = $(DEPENDENCIES) lib517_SOURCES = lib517.c $(SUPPORTFILES) -lib517_LDADD = $(LDADD) lib517_DEPENDENCIES = $(DEPENDENCIES) lib518_SOURCES = lib518.c $(SUPPORTFILES) -lib518_LDADD = $(LDADD) lib518_DEPENDENCIES = $(DEPENDENCIES) lib519_SOURCES = lib519.c $(SUPPORTFILES) -lib519_LDADD = $(LDADD) lib519_DEPENDENCIES = $(DEPENDENCIES) lib520_SOURCES = lib520.c $(SUPPORTFILES) -lib520_LDADD = $(LDADD) lib520_DEPENDENCIES = $(DEPENDENCIES) lib521_SOURCES = lib521.c $(SUPPORTFILES) -lib521_LDADD = $(LDADD) lib521_DEPENDENCIES = $(DEPENDENCIES) lib523_SOURCES = lib523.c $(SUPPORTFILES) -lib523_LDADD = $(LDADD) lib523_DEPENDENCIES = $(DEPENDENCIES) lib524_SOURCES = lib524.c $(SUPPORTFILES) -lib524_LDADD = $(LDADD) lib524_DEPENDENCIES = $(DEPENDENCIES) lib525_SOURCES = lib525.c $(SUPPORTFILES) -lib525_LDADD = $(LDADD) lib525_DEPENDENCIES = $(DEPENDENCIES) lib526_SOURCES = lib526.c $(SUPPORTFILES) lib526_CFLAGS = -DLIB526 -lib526_LDADD = $(LDADD) lib526_DEPENDENCIES = $(DEPENDENCIES) lib527_SOURCES = lib526.c $(SUPPORTFILES) lib527_CFLAGS = -DLIB527 -lib527_LDADD = $(LDADD) lib527_DEPENDENCIES = $(DEPENDENCIES) lib529_SOURCES = lib525.c $(SUPPORTFILES) lib529_CFLAGS = -DLIB529 -lib529_LDADD = $(LDADD) lib529_DEPENDENCIES = $(DEPENDENCIES) lib530_SOURCES = lib530.c $(SUPPORTFILES) lib530_CFLAGS = -DLIB530 -lib530_LDADD = $(LDADD) lib530_DEPENDENCIES = $(DEPENDENCIES) lib532_SOURCES = lib526.c $(SUPPORTFILES) lib532_CFLAGS = -DLIB532 -lib532_LDADD = $(LDADD) lib532_DEPENDENCIES = $(DEPENDENCIES) lib533_SOURCES = lib533.c $(SUPPORTFILES) -lib533_LDADD = $(LDADD) lib533_DEPENDENCIES = $(DEPENDENCIES) lib536_SOURCES = lib536.c $(SUPPORTFILES) -lib536_LDADD = $(LDADD) lib536_DEPENDENCIES = $(DEPENDENCIES) -- cgit v1.2.1 From 9b8b1a68f0b05220582d4a04ae0c454e89058aa4 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 23 Oct 2006 19:15:14 +0000 Subject: 30 seconds isn't long enough for this test on a loaded server. --- tests/libtest/lib504.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index af7ca4bc4..c6c09ea53 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -5,8 +5,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 /* * Source code in here hugely as reported in bug report 651464 by -- cgit v1.2.1 From c54a4301ee8ffec421ccfcb0a35f8261b109886f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 24 Oct 2006 15:51:42 +0000 Subject: Abort test if it seems that it would have run forever. This is just to prevent test hanging and actually is an indication that there's a condition that is not being properly handled at some point in the library. Remove a pair of braces and adjust indentation appropriately. --- tests/libtest/lib503.c | 109 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 37 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 4e7ac82db..e4077a932 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -3,6 +3,11 @@ #include #include +#include "timeval.h" + +#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 + /* * Source code in here hugely as reported in bug report 651460 by * Christopher R. Palmer. @@ -15,6 +20,13 @@ int test(char *URL) { CURL *c; CURLM *m; + int res = 0; + int running; + char done = FALSE; + struct timeval ml_start; + struct timeval mp_start; + char ml_timedout = FALSE; + char mp_timedout = FALSE; curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); @@ -25,60 +37,83 @@ int test(char *URL) curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1); curl_easy_setopt(c, CURLOPT_HEADER, 1); - { - CURLMcode res; - int running; - char done=FALSE; - m = curl_multi_init(); + m = curl_multi_init(); - res = curl_multi_add_handle(m, c); + res = (int)curl_multi_add_handle(m, c); - while(!done) { - fd_set rd, wr, exc; - int max_fd; - struct timeval interval; + ml_timedout = FALSE; + ml_start = curlx_tvnow(); - interval.tv_sec = 1; - interval.tv_usec = 0; + while(!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; - while (res == CURLM_CALL_MULTI_PERFORM) { - res = curl_multi_perform(m, &running); - if (running <= 0) { - done = TRUE; - break; - } - } - if(done) - break; + interval.tv_sec = 1; + interval.tv_usec = 0; - if (res != CURLM_OK) { - fprintf(stderr, "not okay???\n"); + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } + if (running <= 0) { + done = TRUE; break; } + } + if (mp_timedout || done) + break; - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&exc); - max_fd = 0; + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + break; + } - if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) { - fprintf(stderr, "unexpected failured of fdset.\n"); - return 89; - } + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&exc); + max_fd = 0; - if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { - fprintf(stderr, "bad select??\n"); - return 95; - } + if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) { + fprintf(stderr, "unexpected failured of fdset.\n"); + res = 89; + break; + } - res = CURLM_CALL_MULTI_PERFORM; + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + res = 95; + break; } + + res = CURLM_CALL_MULTI_PERFORM; + } + + 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 = 77; } + curl_multi_remove_handle(m, c); curl_easy_cleanup(c); curl_multi_cleanup(m); - return CURLE_OK; + curl_global_cleanup(); + return res; } -- cgit v1.2.1 From 384c8f356087178e4779d99d3e0e7f25331293aa Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 25 Oct 2006 05:59:46 +0000 Subject: Use curl_global_init() and curl_global_cleanup(). Improve cleanup in case of initialization failure. --- tests/libtest/lib500.c | 18 +++++- tests/libtest/lib501.c | 20 ++++++- tests/libtest/lib502.c | 58 ++++++++++++++++-- tests/libtest/lib503.c | 34 ++++++++--- tests/libtest/lib504.c | 150 ++++++++++++++++++++++++++-------------------- tests/libtest/lib505.c | 85 +++++++++++++++----------- tests/libtest/lib506.c | 29 +++++++-- tests/libtest/lib507.c | 32 ++++++++-- tests/libtest/lib508.c | 52 +++++++++------- tests/libtest/lib509.c | 158 ++++++++++++++++++++++++++----------------------- tests/libtest/lib510.c | 60 ++++++++++++------- tests/libtest/lib511.c | 18 +++++- tests/libtest/lib512.c | 2 + tests/libtest/lib513.c | 52 +++++++++------- tests/libtest/lib514.c | 58 ++++++++++-------- tests/libtest/lib515.c | 36 +++++++---- tests/libtest/lib516.c | 34 +++++++---- tests/libtest/lib518.c | 33 ++++++++++- tests/libtest/lib519.c | 18 +++++- tests/libtest/lib520.c | 18 +++++- tests/libtest/lib521.c | 17 +++++- tests/libtest/lib523.c | 17 +++++- tests/libtest/lib524.c | 17 +++++- tests/libtest/lib525.c | 34 ++++++++--- tests/libtest/lib526.c | 37 +++++++++--- tests/libtest/lib530.c | 43 +++++++++++--- tests/libtest/lib533.c | 32 +++++++--- tests/libtest/lib536.c | 23 ++++++- tests/libtest/test.h | 3 + 29 files changed, 833 insertions(+), 355 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 5943b5849..bd4b077d1 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -3,11 +3,27 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index b0ff0a731..c7cf395a9 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -3,12 +3,28 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; (void)URL; /* we don't use this */ + + 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; + } + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); - return res; + curl_global_cleanup(); + + return (int)res; } diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 0a852c998..362e0225a 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -1,5 +1,9 @@ #include "test.h" +#include "timeval.h" + +#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 + /* * Get a single URL without select(). */ @@ -8,25 +12,67 @@ int test(char *URL) { CURL *c; CURLM *m; - CURLMcode res; + int res = 0; 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; + } + + if ((c = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - curl_global_init(CURL_GLOBAL_ALL); - c = curl_easy_init(); curl_easy_setopt(c, CURLOPT_URL, URL); - m = curl_multi_init(); - res = curl_multi_add_handle(m, 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; + } + + 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; + } + + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + while (running) { - res = curl_multi_perform(m, &running); + res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; + } 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; + } + curl_multi_remove_handle(m, c); curl_easy_cleanup(c); curl_multi_cleanup(m); + curl_global_cleanup(); return res; } diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index e4077a932..057625c96 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -28,8 +28,17 @@ int test(char *URL) char ml_timedout = FALSE; char mp_timedout = FALSE; - curl_global_init(CURL_GLOBAL_ALL); - c = curl_easy_init(); + 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; + } + curl_easy_setopt(c, CURLOPT_PROXY, arg2); /* set in first.c */ curl_easy_setopt(c, CURLOPT_URL, URL); curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); @@ -37,10 +46,21 @@ int test(char *URL) curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1); curl_easy_setopt(c, CURLOPT_HEADER, 1); + 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; + } - m = curl_multi_init(); - - res = (int)curl_multi_add_handle(m, c); + 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; + } ml_timedout = FALSE; ml_start = curlx_tvnow(); @@ -106,14 +126,14 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - res = 77; + res = TEST_ERR_RUNS_FOREVER; } curl_multi_remove_handle(m, c); curl_easy_cleanup(c); curl_multi_cleanup(m); - curl_global_cleanup(); + return res; } diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index c6c09ea53..4a1931dd6 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -22,6 +22,7 @@ int test(char *URL) CURLM *m; fd_set rd, wr, exc; CURLMcode res; + char done = FALSE; int running; int max_fd; int rc; @@ -30,8 +31,16 @@ int test(char *URL) char ml_timedout = FALSE; char mp_timedout = FALSE; - curl_global_init(CURL_GLOBAL_ALL); - c = curl_easy_init(); + 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; + } /* the point here being that there must not run anything on the given proxy port */ @@ -39,88 +48,99 @@ int test(char *URL) curl_easy_setopt(c, CURLOPT_URL, URL); curl_easy_setopt(c, CURLOPT_VERBOSE, 1); - m = curl_multi_init(); + 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; + } - res = curl_multi_add_handle(m, c); - if(res && (res != CURLM_CALL_MULTI_PERFORM)) - ; /* major failure */ - else { + 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; + } - ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_timedout = FALSE; + ml_start = curlx_tvnow(); - do { - struct timeval interval; + while (!done) { + struct timeval interval; - interval.tv_sec = 1; - interval.tv_usec = 0; + interval.tv_sec = 1; + interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > - MAIN_LOOP_HANG_TIMEOUT) { - ml_timedout = TRUE; - break; - } + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); - fprintf(stderr, "curl_multi_perform()\n"); + fprintf(stderr, "curl_multi_perform()\n"); - mp_timedout = FALSE; - mp_start = curlx_tvnow(); + res = CURLM_CALL_MULTI_PERFORM; - do { - res = curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) { - mp_timedout = TRUE; - break; - } - } while (res == CURLM_CALL_MULTI_PERFORM); - if (mp_timedout) - break; - if(!running) { - /* This is where this code is expected to reach */ - int numleft; - CURLMsg *msg = curl_multi_info_read(m, &numleft); - fprintf(stderr, "Expected: not running\n"); - if(msg && !numleft) - ret = 100; /* this is where we should be */ - else - ret = 99; /* not correct */ + while (res == CURLM_CALL_MULTI_PERFORM) { + res = (int)curl_multi_perform(m, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; break; } - fprintf(stderr, "running == %d, res == %d\n", running, res); + } + if (mp_timedout) + break; + + if(!running) { + /* This is where this code is expected to reach */ + int numleft; + CURLMsg *msg = curl_multi_info_read(m, &numleft); + fprintf(stderr, "Expected: not running\n"); + if(msg && !numleft) + ret = 100; /* this is where we should be */ + else + ret = 99; /* not correct */ + break; + } + fprintf(stderr, "running == %d, res == %d\n", running, res); - if (res != CURLM_OK) { - ret = 2; - break; - } + if (res != CURLM_OK) { + ret = 2; + break; + } - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&exc); - max_fd = 0; + 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"); - ret = 3; - break; - } - rc = select_test(max_fd+1, &rd, &wr, &exc, &interval); - fprintf(stderr, "select returned %d\n", rc); - - } while(1); - 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"); - ret = 77; + 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"); + ret = 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"); + ret = TEST_ERR_RUNS_FOREVER; } curl_multi_remove_handle(m, c); curl_easy_cleanup(c); curl_multi_cleanup(m); + curl_global_cleanup(); return ret; } diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 7de0bc1e9..85ce38b32 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -42,6 +42,7 @@ int test(char *URL) FILE *hd_src ; int hd ; struct_stat file_info; + struct curl_slist *hl; struct curl_slist *headerlist=NULL; const char *buf_1 = "RNFR 505"; @@ -73,51 +74,69 @@ int test(char *URL) return -2; /* if this happens things are major weird */ } - /* In windows, this will init the winsock stuff */ - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } /* get a curl handle */ - curl = curl_easy_init(); - if(curl) { - struct curl_slist *hl; - /* build a list of commands to pass to libcurl */ - hl = curl_slist_append(headerlist, buf_1); - if(hl) { - headerlist = curl_slist_append(hl, buf_2); - if(hl) - headerlist = hl; - } + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } - /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + /* build a list of commands to pass to libcurl */ - /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + if ((hl = curl_slist_append(headerlist, buf_1)) == NULL) { + fprintf(stderr, "curl_slist_append() failed\n"); + curl_easy_cleanup(curl); + curl_global_cleanup(); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + if ((headerlist = curl_slist_append(hl, buf_2)) == NULL) { + fprintf(stderr, "curl_slist_append() failed\n"); + curl_slist_free_all(hl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + headerlist = hl; - /* specify target */ - curl_easy_setopt(curl,CURLOPT_URL, URL); + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; - /* pass in that last of FTP commands to run after the transfer */ - curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); + /* enable verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; - /* now specify which file to upload */ - curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, URL); - /* and give the size of the upload (optional) */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, - (curl_off_t)file_info.st_size); + /* pass in that last of FTP commands to run after the transfer */ + curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); - /* Now run off and do what you've been told! */ - res = curl_easy_perform(curl); + /* now specify which file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); - /* clean up the FTP commands list */ - curl_slist_free_all (headerlist); + /* and give the size of the upload (optional) */ + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, + (curl_off_t)file_info.st_size); - /* always cleanup */ - curl_easy_cleanup(curl); - } - fclose(hd_src); /* close the local file */ + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + /* clean up the FTP commands list */ + curl_slist_free_all(headerlist); + /* close the local file */ + fclose(hd_src); + + curl_easy_cleanup(curl); curl_global_cleanup(); + return res; } diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index ecf17fa22..862329b72 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -94,9 +94,14 @@ void *fire(void *ptr) CURLcode code; struct curl_slist *headers; struct Tdata *tdata = (struct Tdata*)ptr; - CURL *curl = curl_easy_init(); + CURL *curl; int i=0; + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + return NULL; + } + headers = sethost(NULL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, (void*)headers); @@ -143,11 +148,18 @@ int test(char *URL) user.counter = 0; printf( "GLOBAL_INIT\n" ); - curl_global_init( CURL_GLOBAL_ALL ); + 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" ); - share = curl_share_init(); + 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" ); @@ -171,8 +183,10 @@ int test(char *URL) } if ( CURLSHE_OK != scode ) { + fprintf(stderr, "curl_share_setopt() failed\n"); curl_share_cleanup(share); - return 2; + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; } @@ -196,7 +210,12 @@ int test(char *URL) /* fetch a another one and save cookies */ printf( "*** run %d\n", i ); - curl = curl_easy_init(); + 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 = suburl( URL, i ); headers = sethost( NULL ); diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index e13201d1a..b4ad6fe7d 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -18,11 +18,34 @@ int test(char *URL) char ml_timedout = FALSE; char mp_timedout = FALSE; - multi = curl_multi_init(); + 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; + } + + 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; + } - curls=curl_easy_init(); curl_easy_setopt(curls, CURLOPT_URL, URL); - curl_multi_add_handle(multi, curls); + + if ((res = (int)curl_multi_add_handle(multi, curls)) != CURLM_OK) { + fprintf(stderr, "curl_multi_add_handle() failed, " + "with code %d\n", res); + curl_easy_cleanup(curls); + curl_multi_cleanup(multi); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } mp_timedout = FALSE; mp_start = curlx_tvnow(); @@ -84,7 +107,7 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - i = 77; + i = TEST_ERR_RUNS_FOREVER; } else { msg = curl_multi_info_read(multi, &still_running); @@ -96,6 +119,7 @@ int test(char *URL) curl_multi_cleanup(multi); curl_easy_cleanup(curls); + curl_global_cleanup(); return i; /* return the final return code */ } diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index ddec600b0..dc0efcaa1 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -34,34 +34,44 @@ int test(char *URL) pooh.readptr = data; pooh.sizeleft = strlen(data); - curl = curl_easy_init(); - if(curl) { - /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); - /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); - /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + /* Set the expected POST size */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); - /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); - /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); - /* Perform the request, res will get the return code */ - res = curl_easy_perform(curl); + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); - /* always cleanup */ - curl_easy_cleanup(curl); - } return res; } diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index bdc895195..c6d3113db 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -176,7 +176,9 @@ int test(char *URL) { CURLM* multi; sslctxparm p; - + CURLMcode res; + int running; + char done = FALSE; int i = 0; CURLMsg *msg; @@ -189,9 +191,16 @@ int test(char *URL) portnum = atoi(arg2); } - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - p.curl = curl_easy_init(); + if ((p.curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } p.accessinfoURL = (unsigned char *) strdup(URL); p.accesstype = OBJ_obj2nid(OBJ_txt2obj("AD_DVCS",0)) ; @@ -204,94 +213,97 @@ int test(char *URL) curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYHOST, 1); - fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL); - - { - CURLMcode res; - int running; - char done=FALSE; + if ((multi = curl_multi_init()) == NULL) { + fprintf(stderr, "curl_multi_init() failed\n"); + curl_easy_cleanup(p.curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - multi = curl_multi_init(); + if ((res = curl_multi_add_handle(multi, p.curl)) != CURLM_OK) { + fprintf(stderr, "curl_multi_add_handle() failed, " + "with code %d\n", res); + curl_multi_cleanup(multi); + curl_easy_cleanup(p.curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - res = curl_multi_add_handle(multi, p.curl); + fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL); - ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_timedout = FALSE; + ml_start = curlx_tvnow(); - while (!done) { - fd_set rd, wr, exc; - int max_fd; - struct timeval interval; + while (!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; - interval.tv_sec = 1; - interval.tv_usec = 0; + interval.tv_sec = 1; + interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > - MAIN_LOOP_HANG_TIMEOUT) { - ml_timedout = TRUE; + if (curlx_tvdiff(curlx_tvnow(), ml_start) > + MAIN_LOOP_HANG_TIMEOUT) { + ml_timedout = TRUE; + break; + } + mp_timedout = FALSE; + mp_start = curlx_tvnow(); + + while (res == CURLM_CALL_MULTI_PERFORM) { + res = curl_multi_perform(multi, &running); + if (curlx_tvdiff(curlx_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; break; } - mp_timedout = FALSE; - mp_start = curlx_tvnow(); - - while (res == CURLM_CALL_MULTI_PERFORM) { - res = curl_multi_perform(multi, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) { - mp_timedout = TRUE; - break; - } - fprintf(stderr, "running=%d res=%d\n",running,res); - if (running <= 0) { - done = TRUE; - break; - } - } - if (mp_timedout || done) - break; - - if (res != CURLM_OK) { - fprintf(stderr, "not okay???\n"); - i = 80; + fprintf(stderr, "running=%d res=%d\n",running,res); + if (running <= 0) { + done = TRUE; break; } + } + if (mp_timedout || done) + break; - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&exc); - max_fd = 0; + if (res != CURLM_OK) { + fprintf(stderr, "not okay???\n"); + i = 80; + break; + } - if (curl_multi_fdset(multi, &rd, &wr, &exc, &max_fd) != CURLM_OK) { - fprintf(stderr, "unexpected failured of fdset.\n"); - i = 89; - break; - } + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&exc); + max_fd = 0; - if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { - fprintf(stderr, "bad select??\n"); - i =95; - break; - } - - res = CURLM_CALL_MULTI_PERFORM; + if (curl_multi_fdset(multi, &rd, &wr, &exc, &max_fd) != CURLM_OK) { + fprintf(stderr, "unexpected failured of fdset.\n"); + i = 89; + 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 = 77; - } - else { - msg = curl_multi_info_read(multi, &running); - /* this should now contain a result code from the easy handle, get it */ - if(msg) - i = msg->data.result; + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + i =95; + break; } + + res = CURLM_CALL_MULTI_PERFORM; } - if ((!ml_timedout) && (!mp_timedout)) { + 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, &running); + /* this should now contain a result code from the easy handle, get it */ + if(msg) + i = msg->data.result; fprintf(stderr, "all done\n"); } diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 4dfdbd962..6c1269a86 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -41,42 +41,56 @@ int test(char *URL) struct WriteThis pooh; pooh.counter = 0; - slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - curl = curl_easy_init(); - if(curl) { - /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); + if (slist == NULL) { + fprintf(stderr, "curl_slist_append() failed\n"); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); - /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); - /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); - /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); - /* enforce chunked transfer by setting the header */ - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - /* Perform the request, res will get the return code */ - res = curl_easy_perform(curl); + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); - /* always cleanup */ - curl_easy_cleanup(curl); + /* enforce chunked transfer by setting the header */ + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); - } + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + /* clean up the headers list */ if(slist) - /* clean up the headers list */ curl_slist_free_all(slist); + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + return res; } diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index c0861a053..40d23276f 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -3,12 +3,28 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_FILETIME, 1); curl_easy_setopt(curl, CURLOPT_NOBODY, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index d52baa6d0..f8edbd37d 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -43,6 +43,8 @@ int test(char *URL) } else rc = 4; + + curl_global_cleanup(); } else rc = 5; diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index 3d886dd61..661d6c205 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -14,34 +14,44 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - curl = curl_easy_init(); - if(curl) { - /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1); + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); - /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); - /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, NULL); + /* Set the expected POST size */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1); - /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); - /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, NULL); - /* Perform the request, res will get the return code */ - res = curl_easy_perform(curl); + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); - /* always cleanup */ - curl_easy_cleanup(curl); - } return (int)res; } diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 7100fd8a5..f68dcc09e 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -5,39 +5,49 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - curl = curl_easy_init(); - if(curl) { - /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - /* Based on a bug report by Niels van Tongeren on June 29, 2004: + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - A weird situation occurs when request 1 is a POST request and the request - 2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS, - CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we - set the CURLOPT_NOBODY option to '1'. + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); - */ + /* Based on a bug report by Niels van Tongeren on June 29, 2004: - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3); - curl_easy_setopt(curl, CURLOPT_POST, 1); + A weird situation occurs when request 1 is a POST request and the request + 2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS, + CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we + set the CURLOPT_NOBODY option to '1'. - /* this is where transfer 1 would take place, but skip that and change - options right away instead */ + */ - curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo"); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3); + curl_easy_setopt(curl, CURLOPT_POST, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + /* this is where transfer 1 would take place, but skip that and change + options right away instead */ - /* Now, we should be making a fine HEAD request */ + curl_easy_setopt(curl, CURLOPT_NOBODY, 1); - /* Perform the request 2, res will get the return code */ - res = curl_easy_perform(curl); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a fine HEAD request */ + + /* Perform the request 2, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); - /* always cleanup */ - curl_easy_cleanup(curl); - } return (int)res; } diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index ce075110d..d166c2ab1 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -5,20 +5,30 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - curl = curl_easy_init(); - if(curl) { - /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ - - /* Now, we should be making a zero byte POST request */ - res = curl_easy_perform(curl); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - /* always cleanup */ - curl_easy_cleanup(curl); + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; } + + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a zero byte POST request */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index 6e71fb4bb..6ebc93bf1 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -5,19 +5,29 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - curl = curl_easy_init(); - if(curl) { - /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ - - /* Now, we should be making a zero byte POST request */ - res = curl_easy_perform(curl); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - /* always cleanup */ - curl_easy_cleanup(curl); + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; } + + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Now, we should be making a zero byte POST request */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 1c858ee35..0d8ee18cc 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -42,6 +42,20 @@ static int fd[NUM_OPEN]; +/* + * our_errno() returns the NOT *socket-related* errno (or equivalent) + * on this platform to hide platform specific for the calling function. + */ + +static int our_errno(void) +{ +#ifdef WIN32 + return (int)GetLastError(); +#else + return errno; +#endif +} + static int rlimit(void) { int i; @@ -75,7 +89,8 @@ static int rlimit(void) /* open a dummy descriptor */ fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] == -1) { - fprintf(stderr, "open: failed to open %s\n", DEV_NULL); + fprintf(stderr, "open: failed to open %s " + "with errno %d\n", DEV_NULL, our_errno()); return -4; } @@ -83,7 +98,8 @@ static int rlimit(void) for (i = 1; i < NUM_OPEN; i++) { fd[i] = dup(fd[0]); if (fd[i] == -1) { - fprintf(stderr, "dup: attempt #%i failed\n", i); + fprintf(stderr, "dup: attempt #%d failed " + "with errno %d\n", i, our_errno()); for (i--; i >= 0; i--) close(fd[i]); return -5; @@ -111,11 +127,22 @@ int test(char *URL) /* failure */ return 100; - curl = curl_easy_init(); + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); res = curl_easy_perform(curl); curl_easy_cleanup(curl); + curl_global_cleanup(); /* we never close the file descriptors */ diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index 007703e11..1090b5e9b 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -3,19 +3,35 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed"); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + /* get first page */ res = curl_easy_perform(curl); curl_easy_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe"); + /* get second page */ res = curl_easy_perform(curl); curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index efc2823a1..c6959e684 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -3,11 +3,27 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_FILETIME, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 96630f303..4bfcf4954 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -3,14 +3,29 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_PORT, atoi(arg2)); curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index d0a41c5f5..fd1bfdcc4 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -3,7 +3,19 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_PROXY, arg2); curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_PORT, 19999); @@ -11,7 +23,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index be9f43466..f5fef195c 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -3,13 +3,28 @@ int test(char *URL) { CURLcode res; - CURL *curl = curl_easy_init(); + CURL *curl; + + 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; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 01f34118a..8d837056b 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -49,15 +49,17 @@ int test(char *URL) an example! */ hd_src = fopen(arg2, "rb"); - /* In windows, this will init the winsock stuff */ - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } - /* get a curl handle */ - curl = curl_easy_init(); - if(!curl) { + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); fclose(hd_src); curl_global_cleanup(); - return 100; /* major bad */ + return TEST_ERR_MAJOR_BAD; } /* enable uploading */ @@ -87,9 +89,23 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); - m = curl_multi_init(); + 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; + } - res = (int)curl_multi_add_handle(m, 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(); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } ml_timedout = FALSE; ml_start = curlx_tvnow(); @@ -155,7 +171,7 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - res = 77; + res = TEST_ERR_RUNS_FOREVER; } #ifdef LIB529 diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index fc1c788af..b819bed34 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -48,21 +48,28 @@ int test(char *URL) char done=FALSE; CURLM *m; int current=0; - int i; + int i, j; struct timeval ml_start; struct timeval mp_start; char ml_timedout = FALSE; char mp_timedout = FALSE; - /* In windows, this will init the winsock stuff */ - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } /* 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 100 + i; /* major bad */ + return TEST_ERR_MAJOR_BAD + i; } curl_easy_setopt(curl[i], CURLOPT_URL, URL); @@ -70,9 +77,25 @@ int test(char *URL) curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1); } - m = curl_multi_init(); + 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; + } - res = (int)curl_multi_add_handle(m, curl[current]); + 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 = curlx_tvnow(); @@ -170,7 +193,7 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - res = 77; + res = TEST_ERR_RUNS_FOREVER; } #ifndef LIB527 diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 88c65767d..987296c7a 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -27,23 +27,36 @@ int test(char *URL) int running; char done=FALSE; CURLM *m; - int i; + int i, j; struct timeval ml_start; struct timeval mp_start; char ml_timedout = FALSE; char mp_timedout = FALSE; - /* In windows, this will init the winsock stuff */ - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - m = curl_multi_init(); + if ((m = curl_multi_init()) == NULL) { + fprintf(stderr, "curl_multi_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } /* 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 100 + i; /* major bad */ + return TEST_ERR_MAJOR_BAD + i; } curl_easy_setopt(curl[i], CURLOPT_URL, URL); @@ -53,7 +66,19 @@ int test(char *URL) /* include headers */ curl_easy_setopt(curl[i], CURLOPT_HEADER, 1); - res = (int)curl_multi_add_handle(m, curl[i]); + /* 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; + } } curl_multi_setopt(m, CURLMOPT_PIPELINING, 1); @@ -124,17 +149,17 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - res = 77; + res = TEST_ERR_RUNS_FOREVER; } - /* get NUM_HANDLES easy handles */ + /* cleanup NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { curl_multi_remove_handle(m, curl[i]); curl_easy_cleanup(curl[i]); } curl_multi_cleanup(m); - curl_global_cleanup(); + return res; } diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index bd0cef306..24764bd3c 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -34,22 +34,36 @@ int test(char *URL) char ml_timedout = FALSE; char mp_timedout = FALSE; - /* In windows, this will init the winsock stuff */ - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - curl = curl_easy_init(); - if(!curl) { + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); - return 100; /* major bad */ + return TEST_ERR_MAJOR_BAD; } curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); - m = curl_multi_init(); + 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; + } - res = (int)curl_multi_add_handle(m, 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; + } ml_timedout = FALSE; ml_start = curlx_tvnow(); @@ -138,12 +152,12 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - res = 77; + res = TEST_ERR_RUNS_FOREVER; } curl_easy_cleanup(curl); curl_multi_cleanup(m); - curl_global_cleanup(); + return res; } diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 6ac24b40d..adad23a16 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -70,8 +70,26 @@ static CURLMcode perform(CURLM * multi) int test(char *URL) { - CURLM *multi = curl_multi_init(); - CURL *easy = curl_easy_init(); + CURLM *multi; + CURL *easy; + + 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; + } + + 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; + } curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1); @@ -96,6 +114,7 @@ int test(char *URL) curl_multi_remove_handle(multi, easy); curl_easy_cleanup(easy); curl_multi_cleanup(multi); + curl_global_cleanup(); printf("Finished!\n"); diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 83ec94b65..738976397 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -31,6 +31,9 @@ #define TRUE 1 #endif +#define TEST_ERR_MAJOR_BAD 100 +#define TEST_ERR_RUNS_FOREVER 99 + extern char *arg2; /* set by first.c to the argv[2] or NULL */ int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, -- cgit v1.2.1 From d771fa7c488d57ea950c6c8f1fb9612b0fa8907c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 25 Oct 2006 08:52:00 +0000 Subject: Compiler warning fix --- tests/libtest/lib504.c | 4 ++-- tests/libtest/lib507.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 4a1931dd6..f077ffed3 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -55,7 +55,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - if ((res = (int)curl_multi_add_handle(m, c)) != CURLM_OK) { + if ((res = curl_multi_add_handle(m, c)) != CURLM_OK) { fprintf(stderr, "curl_multi_add_handle() failed, " "with code %d\n", res); curl_multi_cleanup(m); @@ -86,7 +86,7 @@ int test(char *URL) res = CURLM_CALL_MULTI_PERFORM; while (res == CURLM_CALL_MULTI_PERFORM) { - res = (int)curl_multi_perform(m, &running); + res = curl_multi_perform(m, &running); if (curlx_tvdiff(curlx_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index b4ad6fe7d..227691d0b 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -38,7 +38,7 @@ int test(char *URL) curl_easy_setopt(curls, CURLOPT_URL, URL); - if ((res = (int)curl_multi_add_handle(multi, curls)) != CURLM_OK) { + if ((res = curl_multi_add_handle(multi, curls)) != CURLM_OK) { fprintf(stderr, "curl_multi_add_handle() failed, " "with code %d\n", res); curl_easy_cleanup(curls); -- cgit v1.2.1 From b4700f026b732776ba48cc4a941aca4ec42c1bb0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 25 Oct 2006 09:20:44 +0000 Subject: Add project notice and file Id --- tests/libtest/first.c | 10 ++++++++++ tests/libtest/lib500.c | 10 ++++++++++ tests/libtest/lib501.c | 10 ++++++++++ tests/libtest/lib502.c | 10 ++++++++++ tests/libtest/lib503.c | 10 ++++++++++ tests/libtest/lib504.c | 10 ++++++++++ tests/libtest/lib506.c | 10 ++++++++++ tests/libtest/lib507.c | 10 ++++++++++ tests/libtest/lib508.c | 10 ++++++++++ tests/libtest/lib509.c | 10 ++++++++++ tests/libtest/lib510.c | 10 ++++++++++ tests/libtest/lib511.c | 10 ++++++++++ tests/libtest/lib512.c | 10 ++++++++++ tests/libtest/lib513.c | 10 ++++++++++ tests/libtest/lib514.c | 10 ++++++++++ tests/libtest/lib515.c | 10 ++++++++++ tests/libtest/lib516.c | 10 ++++++++++ tests/libtest/lib517.c | 10 ++++++++++ tests/libtest/lib518.c | 10 ++++++++++ tests/libtest/lib519.c | 10 ++++++++++ tests/libtest/lib520.c | 10 ++++++++++ tests/libtest/lib521.c | 10 ++++++++++ tests/libtest/lib523.c | 10 ++++++++++ tests/libtest/lib524.c | 10 ++++++++++ tests/libtest/test.h | 10 ++++++++++ 25 files changed, 250 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 782daca17..745ed9fe5 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #ifdef CURLDEBUG diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index bd4b077d1..9ee164e2c 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index c7cf395a9..a4d78159d 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 362e0225a..207f65ed2 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #include "timeval.h" diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 057625c96..66d2c9813 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #include diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index f077ffed3..5b10022df 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #include diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 862329b72..a090a2ce6 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #include #include diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 227691d0b..8de1a3550 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #include "timeval.h" diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index dc0efcaa1..cc240db5c 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" static char data[]="this is what we post to the silly web server\n"; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index c6d3113db..a21fae4a4 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #ifdef USE_SSLEAY diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 6c1269a86..53797473c 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" static const char *post[]={ diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 40d23276f..7fcdebf93 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index f8edbd37d..1d7d02a6a 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" /* Test case code based on source in a bug report filed by James Bursa on diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index 661d6c205..4cb593cec 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index f68dcc09e..93d576fbd 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index d166c2ab1..6086ecb09 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index 6ebc93bf1..5eaa140e6 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 1a4aefc54..cdcd64be1 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" const char *dates[]={ diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 0d8ee18cc..cb9f395b6 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" #ifdef HAVE_SYS_TYPES_H diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index 1090b5e9b..58f38150d 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index c6959e684..a673007a6 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 4bfcf4954..088534955 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index fd1bfdcc4..6ddfc947f 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index f5fef195c..55f29784c 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include "test.h" int test(char *URL) diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 738976397..fa32d6d88 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,3 +1,13 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #ifdef HAVE_CONFIG_H /* Now include the setup.h file from libcurl's private libdir (the source version, but that might include "config.h" from the build dir so we need -- cgit v1.2.1 From cd3029f36f762c81313a5750bed7a5d80b11ffee Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 26 Oct 2006 09:50:21 +0000 Subject: 30 seconds isn't long enough for this test on a loaded server. --- tests/libtest/lib526.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index b819bed34..2dee9cf63 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -35,8 +35,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 #define NUM_HANDLES 4 -- cgit v1.2.1 From 5b75b423e65f36cb48930f7c43fd872bb67f0df4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 26 Oct 2006 13:55:24 +0000 Subject: Improved rlimit logic: - Take in account RLIM_INFINITY. - Verify that soft limit is actually changed when doing so. - Show errno in case getrlimit or setrlimit fails. - Keep file descriptors open only while runing this test. --- tests/libtest/lib518.c | 116 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 95 insertions(+), 21 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index cb9f395b6..1696651dc 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -66,56 +66,124 @@ static int our_errno(void) #endif } -static int rlimit(void) +static void close_file_descriptors(void) +{ + int i; + + for (i = 0; i < NUM_OPEN; i++) { + close(fd[i]); + fd[i] = -1; + } +} + +static int rlimit(int keep_open) { int i; struct rlimit rl; + char strbuff[81]; + char fmt_d[] = "%d"; + char fmt_ld[] = "%ld"; + char fmt_lld[] = "%lld"; + char *fmt; + + if (sizeof(rl.rlim_max) < sizeof(long)) + fmt = fmt_d; + else if (sizeof(rl.rlim_max) == sizeof(long)) + fmt = fmt_ld; + else + fmt = fmt_lld; fprintf(stderr, "NUM_OPEN: %d\n", NUM_OPEN); fprintf(stderr, "NUM_NEEDED: %d\n", NUM_NEEDED); /* get open file limits */ - if (getrlimit(RLIMIT_NOFILE, &rl) == -1) { - fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE\n"); + if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " + "with errno %d\n", our_errno()); return -1; } /* check that hard limit is high enough */ - if (rl.rlim_max < NUM_NEEDED) { - fprintf(stderr, "warning: RLIMIT_NOFILE hard limit %d < %d\n", - (int)rl.rlim_max, NUM_NEEDED); - return -2; - } +#ifdef RLIM_INFINITY + if (rl.rlim_max != RLIM_INFINITY) +#endif + if ((rl.rlim_max > 0) && (rl.rlim_max < NUM_NEEDED)) { + sprintf(strbuff, fmt, rl.rlim_max); + fprintf(stderr, "warning: RLIMIT_NOFILE hard limit %s < %d\n", + strbuff, NUM_NEEDED); + return -2; + } /* increase soft limit if needed */ - if (rl.rlim_cur < NUM_NEEDED) { - rl.rlim_cur = NUM_NEEDED; - if (setrlimit(RLIMIT_NOFILE, &rl) == -1) { - fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE\n"); - return -3; +#ifdef RLIM_INFINITY + if (rl.rlim_cur != RLIM_INFINITY) +#endif + if ((rl.rlim_cur > 0) && (rl.rlim_cur < NUM_NEEDED)) { + rl.rlim_cur = NUM_NEEDED; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE " + "with errno %d\n", our_errno()); + return -3; + } + /* verify that it has been increased */ + if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " + "with errno %d\n", our_errno()); + return -4; + } + if ((rl.rlim_cur > 0) && (rl.rlim_cur < NUM_NEEDED)) { + sprintf(strbuff, fmt, rl.rlim_cur); + fprintf(stderr, "warning: RLIMIT_NOFILE soft limit %s < %d\n", + strbuff, NUM_NEEDED); + return -5; + } } + +#ifdef RLIM_INFINITY + if (rl.rlim_cur == RLIM_INFINITY) + fprintf(stderr, "SOFT_LIMIT: INFINITY\n"); + else +#endif + { + sprintf(strbuff, fmt, rl.rlim_cur); + fprintf(stderr, "SOFT_LIMIT: %s\n", strbuff); + } + +#ifdef RLIM_INFINITY + if (rl.rlim_max == RLIM_INFINITY) + fprintf(stderr, "HARD_LIMIT: INFINITY\n"); + else +#endif + { + sprintf(strbuff, fmt, rl.rlim_max); + fprintf(stderr, "HARD_LIMIT: %s\n", strbuff); } /* open a dummy descriptor */ fd[0] = open(DEV_NULL, O_RDONLY); - if (fd[0] == -1) { + if (fd[0] < 0) { fprintf(stderr, "open: failed to open %s " "with errno %d\n", DEV_NULL, our_errno()); - return -4; + return -6; } /* create a bunch of file descriptors */ for (i = 1; i < NUM_OPEN; i++) { fd[i] = dup(fd[0]); - if (fd[i] == -1) { + if (fd[i] < 0) { fprintf(stderr, "dup: attempt #%d failed " "with errno %d\n", i, our_errno()); for (i--; i >= 0; i--) close(fd[i]); - return -5; + return -7; } } + /* close file descriptors unless instructed to keep them */ + if (!keep_open) { + close_file_descriptors(); + } + return 0; } @@ -126,36 +194,42 @@ int test(char *URL) if(!strcmp(URL, "check")) { /* used by the test script to ask if we can run this test or not */ - if(rlimit()) { + if(rlimit(FALSE)) { printf("rlimit problems\n"); return 1; } return 0; /* sure, run this! */ } - if(rlimit()) + if(rlimit(TRUE)) /* failure */ return 100; + /* now run the test with NUM_OPEN open file descriptors + and close them all once this test is over */ + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); + close_file_descriptors(); return TEST_ERR_MAJOR_BAD; } if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); + close_file_descriptors(); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + res = curl_easy_perform(curl); + + close_file_descriptors(); curl_easy_cleanup(curl); curl_global_cleanup(); - /* we never close the file descriptors */ - return (int)res; } #else -- cgit v1.2.1 From 125830ab4bfa1142ea7aa0a849336b6351d4f174 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Thu, 26 Oct 2006 14:30:11 +0000 Subject: Use proper 'stat' structure for fstat(). I.e. 'struct _stati64' and '_fstati64()' on Win32. --- tests/libtest/lib525.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 8d837056b..5c85adf32 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -25,7 +25,7 @@ int test(char *URL) CURL *curl; FILE *hd_src ; int hd ; - struct stat file_info; + struct_stat file_info; int running; char done=FALSE; CURLM *m; @@ -118,7 +118,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (curlx_tvdiff(curlx_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -128,7 +128,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (curlx_tvdiff(curlx_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; -- cgit v1.2.1 From 32ad212ac94577f7f6a245a5dc72b42039bd0b42 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 27 Oct 2006 01:58:59 +0000 Subject: 30 seconds isn't long enough for this test on a loaded server. --- tests/libtest/lib525.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 5c85adf32..24a329452 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -16,8 +16,8 @@ #include "timeval.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 int test(char *URL) { -- cgit v1.2.1 From 609044aea2ffa2520b14b810e46e2a256c8db56c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 29 Oct 2006 21:19:23 +0000 Subject: Compiler warning fix --- tests/libtest/lib509.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index a21fae4a4..a911e3654 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -33,6 +33,13 @@ #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +/* + * We use this ZERO_NULL to avoid picky compiler warnings, + * when assigning a NULL pointer to a function pointer var. + */ + +#define ZERO_NULL 0 + int portnum; /* the HTTPS port number we use */ typedef struct sslctxparm_st { @@ -165,7 +172,7 @@ static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) but it still does, see the error handling in the call back */ SSL_CTX_set_verify_depth(ctx,0); - SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,NULL); + SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,ZERO_NULL); #if OPENSSL_VERSION_NUMBER<0x00907000L /* in newer openssl versions we can set a parameter for the call back. */ -- cgit v1.2.1 From afcd9f1b1c403936a423e9b27d267bd4ad9286bd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 30 Oct 2006 17:24:31 +0000 Subject: Address some pitfalls in the rlimit() function check that were preventing execution of this test on many platforms --- tests/libtest/lib518.c | 214 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 145 insertions(+), 69 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 1696651dc..e64ef7d59 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -39,8 +39,9 @@ #error "this test requires FD_SETSIZE" #endif +#define SAFETY_MARGIN 16 #define NUM_OPEN (FD_SETSIZE + 10) -#define NUM_NEEDED (NUM_OPEN + 16) +#define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN) #if defined(WIN32) || defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" @@ -50,7 +51,8 @@ #if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) -static int fd[NUM_OPEN]; +static int *fd = NULL; +static struct rlimit num_open; /* * our_errno() returns the NOT *socket-related* errno (or equivalent) @@ -68,114 +70,185 @@ static int our_errno(void) static void close_file_descriptors(void) { - int i; - - for (i = 0; i < NUM_OPEN; i++) { - close(fd[i]); - fd[i] = -1; - } + for (num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) + close(fd[num_open.rlim_cur]); + free(fd); + fd = NULL; } static int rlimit(int keep_open) { - int i; + char *fmt; struct rlimit rl; char strbuff[81]; - char fmt_d[] = "%d"; - char fmt_ld[] = "%ld"; - char fmt_lld[] = "%lld"; - char *fmt; + char fmt_u[] = "%u"; + char fmt_lu[] = "%lu"; +#ifdef HAVE_LONGLONG + char fmt_llu[] = "%llu"; - if (sizeof(rl.rlim_max) < sizeof(long)) - fmt = fmt_d; - else if (sizeof(rl.rlim_max) == sizeof(long)) - fmt = fmt_ld; + if (sizeof(rl.rlim_max) > sizeof(long)) + fmt = fmt_llu; else - fmt = fmt_lld; +#endif + fmt = (sizeof(rl.rlim_max) < sizeof(long))?fmt_u:fmt_lu; - fprintf(stderr, "NUM_OPEN: %d\n", NUM_OPEN); - fprintf(stderr, "NUM_NEEDED: %d\n", NUM_NEEDED); + /* get initial open file limits */ - /* get open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " "with errno %d\n", our_errno()); return -1; } - /* check that hard limit is high enough */ + /* show initial open file limits */ + #ifdef RLIM_INFINITY - if (rl.rlim_max != RLIM_INFINITY) + if (rl.rlim_cur == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else #endif - if ((rl.rlim_max > 0) && (rl.rlim_max < NUM_NEEDED)) { - sprintf(strbuff, fmt, rl.rlim_max); - fprintf(stderr, "warning: RLIMIT_NOFILE hard limit %s < %d\n", - strbuff, NUM_NEEDED); - return -2; - } + sprintf(strbuff, fmt, rl.rlim_cur); + fprintf(stderr, "initial SOFT_LIMIT: %s\n", strbuff); - /* increase soft limit if needed */ #ifdef RLIM_INFINITY - if (rl.rlim_cur != RLIM_INFINITY) -#endif - if ((rl.rlim_cur > 0) && (rl.rlim_cur < NUM_NEEDED)) { - rl.rlim_cur = NUM_NEEDED; - if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { - fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE " - "with errno %d\n", our_errno()); - return -3; - } - /* verify that it has been increased */ - if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " - "with errno %d\n", our_errno()); - return -4; - } - if ((rl.rlim_cur > 0) && (rl.rlim_cur < NUM_NEEDED)) { - sprintf(strbuff, fmt, rl.rlim_cur); - fprintf(stderr, "warning: RLIMIT_NOFILE soft limit %s < %d\n", - strbuff, NUM_NEEDED); - return -5; - } + if (rl.rlim_max == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else +#endif + sprintf(strbuff, fmt, rl.rlim_max); + fprintf(stderr, "initial HARD_LIMIT: %s\n", strbuff); + + /* show our constants */ + + fprintf(stderr, "test518 FD_SETSIZE: %d\n", FD_SETSIZE); + fprintf(stderr, "test518 NUM_OPEN : %d\n", NUM_OPEN); + fprintf(stderr, "test518 NUM_NEEDED: %d\n", NUM_NEEDED); + + /* increase soft limit up to hard limit if different */ + + if (rl.rlim_cur != rl.rlim_max) { + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE " + "with errno %d\n", our_errno()); + return -2; } + } + + /* get current open file limits */ + + if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " + "with errno %d\n", our_errno()); + return -3; + } + + /* if soft limit has not been increased all the way up to hard + limit, warn about it but continue since it may be high enough */ + + if (rl.rlim_cur != rl.rlim_max) { + fprintf(stderr, "warning: setrlimit: did not raise soft limit " + "up to hard limit\n"); + } + + /* show current open file limits */ #ifdef RLIM_INFINITY if (rl.rlim_cur == RLIM_INFINITY) - fprintf(stderr, "SOFT_LIMIT: INFINITY\n"); + strcpy(strbuff, "INFINITY"); else #endif - { sprintf(strbuff, fmt, rl.rlim_cur); - fprintf(stderr, "SOFT_LIMIT: %s\n", strbuff); - } + fprintf(stderr, "current SOFT_LIMIT: %s\n", strbuff); #ifdef RLIM_INFINITY if (rl.rlim_max == RLIM_INFINITY) - fprintf(stderr, "HARD_LIMIT: INFINITY\n"); + strcpy(strbuff, "INFINITY"); else #endif - { sprintf(strbuff, fmt, rl.rlim_max); - fprintf(stderr, "HARD_LIMIT: %s\n", strbuff); + fprintf(stderr, "current HARD_LIMIT: %s\n", strbuff); + + /* + ** Our extreme test target is to open more than FD_SETSIZE files but + ** it could happen that it would exceed the limit of allowed open + ** files and we would not be able to test libcurl functionality. In + ** this case we will open the maximum allowed minus our safety margin, + ** which will run the test under this stress condition. + */ + + num_open.rlim_cur = FD_SETSIZE; + num_open.rlim_max = NUM_OPEN; + if (num_open.rlim_cur > num_open.rlim_max) + num_open.rlim_max = num_open.rlim_cur; + +#ifdef RLIM_INFINITY + if ((rl.rlim_cur > 0) && (rl.rlim_cur != RLIM_INFINITY)) { +#else + if (rl.rlim_cur > 0) { +#endif + if (num_open.rlim_max > rl.rlim_cur - SAFETY_MARGIN) { + num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; + } } + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + + /* verify that we won't overflow size_t in malloc() */ + + if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { + fprintf(stderr, "is not possible, we would overflow size_t in malloc()\n"); + num_open.rlim_max = ((size_t)-1) / sizeof(*fd); + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + } + + fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); + if (!fd) { + fprintf(stderr, "warning: memory allocation failed " + "with errno %d\n", our_errno()); + return -4; + } + + /* initialize fighting lazy allocation */ + + for (num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) + fd[num_open.rlim_cur] = -1; + + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "opening %s file descriptors\n", strbuff); + /* open a dummy descriptor */ fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] < 0) { fprintf(stderr, "open: failed to open %s " "with errno %d\n", DEV_NULL, our_errno()); - return -6; + free(fd); + fd = NULL; + return -5; } /* create a bunch of file descriptors */ - for (i = 1; i < NUM_OPEN; i++) { - fd[i] = dup(fd[0]); - if (fd[i] < 0) { - fprintf(stderr, "dup: attempt #%d failed " - "with errno %d\n", i, our_errno()); - for (i--; i >= 0; i--) - close(fd[i]); - return -7; + for (num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) { + fd[num_open.rlim_cur] = dup(fd[0]); + if (fd[num_open.rlim_cur] < 0) { + sprintf(strbuff, fmt, num_open.rlim_cur); + fprintf(stderr, "dup: attempt #%s failed " + "with errno %d\n", strbuff, our_errno()); + for (num_open.rlim_cur = 0; + fd[num_open.rlim_cur] >= 0; + num_open.rlim_cur++) + close(fd[num_open.rlim_cur]); + free(fd); + fd = NULL; + return -6; } } @@ -195,15 +268,18 @@ int test(char *URL) if(!strcmp(URL, "check")) { /* used by the test script to ask if we can run this test or not */ if(rlimit(FALSE)) { + fprintf(stderr, "Previous condition prevents running this test\n"); printf("rlimit problems\n"); return 1; } return 0; /* sure, run this! */ } - if(rlimit(TRUE)) + if (rlimit(TRUE)) { /* failure */ - return 100; + fprintf(stderr, "Previous condition aborts this test\n"); + return TEST_ERR_MAJOR_BAD; + } /* now run the test with NUM_OPEN open file descriptors and close them all once this test is over */ -- cgit v1.2.1 From 9b2acca63e6d386cb5ddb248648fec4e856905e7 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 31 Oct 2006 01:24:03 +0000 Subject: Sync comment with code and add three messages more --- tests/libtest/lib518.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index e64ef7d59..875ddc206 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -70,12 +70,14 @@ static int our_errno(void) static void close_file_descriptors(void) { + fprintf(stderr, "closing file descriptors\n"); for (num_open.rlim_cur = 0; num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) close(fd[num_open.rlim_cur]); free(fd); fd = NULL; + fprintf(stderr, "file descriptors closed\n"); } static int rlimit(int keep_open) @@ -252,6 +254,9 @@ static int rlimit(int keep_open) } } + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "%s file descriptors open\n", strbuff); + /* close file descriptors unless instructed to keep them */ if (!keep_open) { close_file_descriptors(); @@ -281,8 +286,8 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - /* now run the test with NUM_OPEN open file descriptors - and close them all once this test is over */ + /* run the test with more than FD_SETSIZE or max allowed open + file descriptors and close them all once the test is over */ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); -- cgit v1.2.1 From 905ca77c9ed0edac993c0f9bd9dac36253d96dd5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 1 Nov 2006 18:33:50 +0000 Subject: test 518 is all about testing libcurl functionality when more than FD_SETSIZE file descriptors are open. This means that if for any reason we are not able to open more than FD_SETSIZE file descriptors then test 518 should not be run. test 537 is all about testing libcurl functionality when the system has nearly exhausted the number of free file descriptors. Test 537 will try to run with very few free file descriptors. --- tests/libtest/Makefile.am | 7 +- tests/libtest/lib518.c | 325 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 276 insertions(+), 56 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index f7f901c80..eb936eb48 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -42,7 +42,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 + lib529 lib530 lib532 lib533 lib536 lib537 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -103,6 +103,7 @@ lib517_SOURCES = lib517.c $(SUPPORTFILES) lib517_DEPENDENCIES = $(DEPENDENCIES) lib518_SOURCES = lib518.c $(SUPPORTFILES) +lib518_CFLAGS = -DLIB518 lib518_DEPENDENCIES = $(DEPENDENCIES) lib519_SOURCES = lib519.c $(SUPPORTFILES) @@ -149,3 +150,7 @@ lib533_DEPENDENCIES = $(DEPENDENCIES) lib536_SOURCES = lib536.c $(SUPPORTFILES) lib536_DEPENDENCIES = $(DEPENDENCIES) +lib537_SOURCES = lib518.c $(SUPPORTFILES) +lib537_CFLAGS = -DLIB537 +lib537_DEPENDENCIES = $(DEPENDENCIES) + diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 875ddc206..bb09f0ffc 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -8,6 +8,10 @@ * $Id$ */ +/* + * This source code is used for lib518 and lib537. + */ + #include "test.h" #ifdef HAVE_SYS_TYPES_H @@ -35,13 +39,21 @@ #include #endif -#ifndef FD_SETSIZE +#if defined(LIB518) && !defined(FD_SETSIZE) #error "this test requires FD_SETSIZE" #endif +#ifdef LIB518 #define SAFETY_MARGIN 16 #define NUM_OPEN (FD_SETSIZE + 10) #define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN) +#endif + +#ifdef LIB537 +#define SAFETY_MARGIN 5 +#endif + +#define MEMCHUNK_NITEMS 32000 #if defined(WIN32) || defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" @@ -53,6 +65,7 @@ static int *fd = NULL; static struct rlimit num_open; +static char msgbuff[256]; /* * our_errno() returns the NOT *socket-related* errno (or equivalent) @@ -68,6 +81,15 @@ static int our_errno(void) #endif } +static void store_errmsg(const char *msg, int err) +{ + if (!err) + snprintf(msgbuff, sizeof(msgbuff), "%s", msg); + else + snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", + msg, err, strerror(err)); +} + static void close_file_descriptors(void) { fprintf(stderr, "closing file descriptors\n"); @@ -82,9 +104,16 @@ static void close_file_descriptors(void) static int rlimit(int keep_open) { +#ifdef LIB537 + int *tmpfd; +#endif + int i; + int *memchunk = NULL; char *fmt; struct rlimit rl; - char strbuff[81]; + char strbuff[256]; + char strbuff1[81]; + char strbuff2[81]; char fmt_u[] = "%u"; char fmt_lu[] = "%lu"; #ifdef HAVE_LONGLONG @@ -99,8 +128,8 @@ static int rlimit(int keep_open) /* get initial open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " - "with errno %d\n", our_errno()); + store_errmsg("getrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); return -1; } @@ -112,7 +141,7 @@ static int rlimit(int keep_open) else #endif sprintf(strbuff, fmt, rl.rlim_cur); - fprintf(stderr, "initial SOFT_LIMIT: %s\n", strbuff); + fprintf(stderr, "initial soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY if (rl.rlim_max == RLIM_INFINITY) @@ -120,21 +149,31 @@ static int rlimit(int keep_open) else #endif sprintf(strbuff, fmt, rl.rlim_max); - fprintf(stderr, "initial HARD_LIMIT: %s\n", strbuff); + fprintf(stderr, "initial hard limit: %s\n", strbuff); +#ifdef LIB518 /* show our constants */ fprintf(stderr, "test518 FD_SETSIZE: %d\n", FD_SETSIZE); fprintf(stderr, "test518 NUM_OPEN : %d\n", NUM_OPEN); fprintf(stderr, "test518 NUM_NEEDED: %d\n", NUM_NEEDED); +#endif - /* increase soft limit up to hard limit if different */ + /* + * if soft limit and hard limit are different we ask the + * system to raise soft limit all the way up to the hard + * limit. Due to some other system limit the soft limit + * might not be raised up to the hard limit. So from this + * point the resulting soft limit is our limit. Trying to + * open more than soft limit file descriptors will fail. + */ if (rl.rlim_cur != rl.rlim_max) { + fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { - fprintf(stderr, "warning: setrlimit: failed to set RLIMIT_NOFILE " - "with errno %d\n", our_errno()); + store_errmsg("setrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); return -2; } } @@ -142,19 +181,11 @@ static int rlimit(int keep_open) /* get current open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - fprintf(stderr, "warning: getrlimit: failed to get RLIMIT_NOFILE " - "with errno %d\n", our_errno()); + store_errmsg("getrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); return -3; } - /* if soft limit has not been increased all the way up to hard - limit, warn about it but continue since it may be high enough */ - - if (rl.rlim_cur != rl.rlim_max) { - fprintf(stderr, "warning: setrlimit: did not raise soft limit " - "up to hard limit\n"); - } - /* show current open file limits */ #ifdef RLIM_INFINITY @@ -163,7 +194,7 @@ static int rlimit(int keep_open) else #endif sprintf(strbuff, fmt, rl.rlim_cur); - fprintf(stderr, "current SOFT_LIMIT: %s\n", strbuff); + fprintf(stderr, "current soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY if (rl.rlim_max == RLIM_INFINITY) @@ -171,51 +202,153 @@ static int rlimit(int keep_open) else #endif sprintf(strbuff, fmt, rl.rlim_max); - fprintf(stderr, "current HARD_LIMIT: %s\n", strbuff); + fprintf(stderr, "current hard limit: %s\n", strbuff); + + /* + * test 518 is all about testing libcurl functionality + * when more than FD_SETSIZE file descriptors are open. + * This means that if for any reason we are not able to + * open more than FD_SETSIZE file descriptors then test + * 518 should not be run. + * + * test 537 is all about testing libcurl functionality + * when the system has nearly exhausted the number of + * free file descriptors. Test 537 will try to run with + * very few free file descriptors. + */ - /* - ** Our extreme test target is to open more than FD_SETSIZE files but - ** it could happen that it would exceed the limit of allowed open - ** files and we would not be able to test libcurl functionality. In - ** this case we will open the maximum allowed minus our safety margin, - ** which will run the test under this stress condition. - */ +#ifdef LIB518 + + /* verify that soft limit is higher than FD_SETSIZE */ num_open.rlim_cur = FD_SETSIZE; + + if ((rl.rlim_cur > 0) && +#ifdef RLIM_INFINITY + (rl.rlim_cur != RLIM_INFINITY) && +#endif + (rl.rlim_cur <= num_open.rlim_cur)) { + sprintf(strbuff2, fmt, rl.rlim_cur); + sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " + "files, soft limit is %s", strbuff1, strbuff2); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + return -4; + } + + /* + * verify that soft limit is higher than NUM_OPEN, + * number of file descriptors we would try to open + */ + + num_open.rlim_cur = NUM_OPEN; + + if ((rl.rlim_cur > 0) && +#ifdef RLIM_INFINITY + (rl.rlim_cur != RLIM_INFINITY) && +#endif + (rl.rlim_cur <= num_open.rlim_cur)) { + sprintf(strbuff2, fmt, rl.rlim_cur); + sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " + "files, soft limit is %s", strbuff1, strbuff2); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + return -5; + } + + /* + * verify that soft limit is higher than NUM_NEEDED, + * number of file descriptors we would try to open + * plus SAFETY_MARGIN to not exhaust file pool + */ + + num_open.rlim_cur = NUM_NEEDED; + + if ((rl.rlim_cur > 0) && +#ifdef RLIM_INFINITY + (rl.rlim_cur != RLIM_INFINITY) && +#endif + (rl.rlim_cur <= num_open.rlim_cur)) { + sprintf(strbuff2, fmt, rl.rlim_cur); + sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " + "files, soft limit is %s", strbuff1, strbuff2); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + return -6; + } + +#endif /* LIB518 */ + + /* + * reserve a chunk of memory before opening file descriptors to + * avoid a low memory condition once the file descriptors are + * open. System conditions that could make the test fail should + * be addressed in the precheck phase. This chunk of memory shall + * be always free()ed before exiting the rlimit() function so + * that it becomes available to the test. + */ + + memchunk = malloc(sizeof(*memchunk) * MEMCHUNK_NITEMS); + if (!memchunk) { + store_errmsg("memchunk, malloc() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + return -7; + } + + /* initialize it to fight lazy allocation */ + + for (i = 0; i < MEMCHUNK_NITEMS; i++) + memchunk[i] = -1; + + /* set the number of file descriptors we will try to open to ... */ + +#ifdef LIB518 + /* NUM_OPEN */ num_open.rlim_max = NUM_OPEN; - if (num_open.rlim_cur > num_open.rlim_max) - num_open.rlim_max = num_open.rlim_cur; +#endif +#ifdef LIB537 #ifdef RLIM_INFINITY if ((rl.rlim_cur > 0) && (rl.rlim_cur != RLIM_INFINITY)) { #else if (rl.rlim_cur > 0) { #endif - if (num_open.rlim_max > rl.rlim_cur - SAFETY_MARGIN) { - num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; - } + /* soft limit minus SAFETY_MARGIN */ + num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; } - - sprintf(strbuff, fmt, num_open.rlim_max); - fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + else { + /* biggest file descriptor array size */ + num_open.rlim_max = ((size_t)-1) / sizeof(*fd); + } +#endif /* LIB537 */ /* verify that we won't overflow size_t in malloc() */ if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { - fprintf(stderr, "is not possible, we would overflow size_t in malloc()\n"); - num_open.rlim_max = ((size_t)-1) / sizeof(*fd); - sprintf(strbuff, fmt, num_open.rlim_max); - fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + sprintf(strbuff1, fmt, num_open.rlim_max); + snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " + "file descriptors, would overflow size_t", strbuff1); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + free(memchunk); + return -8; } + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); if (!fd) { - fprintf(stderr, "warning: memory allocation failed " - "with errno %d\n", our_errno()); - return -4; + store_errmsg("fd, malloc() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + free(memchunk); + return -9; } - /* initialize fighting lazy allocation */ + /* initialize it to fight lazy allocation */ for (num_open.rlim_cur = 0; num_open.rlim_cur < num_open.rlim_max; @@ -223,40 +356,120 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; sprintf(strbuff, fmt, num_open.rlim_max); - fprintf(stderr, "opening %s file descriptors\n", strbuff); + fprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ + fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] < 0) { - fprintf(stderr, "open: failed to open %s " - "with errno %d\n", DEV_NULL, our_errno()); + snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); + store_errmsg(strbuff, our_errno()); + fprintf(stderr, "%s\n", msgbuff); free(fd); fd = NULL; - return -5; + free(memchunk); + return -10; } /* create a bunch of file descriptors */ + +#ifdef LIB518 + for (num_open.rlim_cur = 1; num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) { + fd[num_open.rlim_cur] = dup(fd[0]); + if (fd[num_open.rlim_cur] < 0) { - sprintf(strbuff, fmt, num_open.rlim_cur); - fprintf(stderr, "dup: attempt #%s failed " - "with errno %d\n", strbuff, our_errno()); + + fd[num_open.rlim_cur] = -1; + + sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); + store_errmsg(strbuff, our_errno()); + fprintf(stderr, "%s\n", msgbuff); + + fprintf(stderr, "closing file descriptors\n"); for (num_open.rlim_cur = 0; fd[num_open.rlim_cur] >= 0; num_open.rlim_cur++) close(fd[num_open.rlim_cur]); + fprintf(stderr, "file descriptors closed\n"); free(fd); fd = NULL; - return -6; + free(memchunk); + return -11; + + } + + } + +#endif /* LIB518 */ + +#ifdef LIB537 + + for (num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) { + + fd[num_open.rlim_cur] = dup(fd[0]); + + if (fd[num_open.rlim_cur] < 0) { + + fd[num_open.rlim_cur] = -1; + + sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); + fprintf(stderr, "%s\n", strbuff); + + sprintf(strbuff1, fmt, num_open.rlim_cur + 2); + snprintf(strbuff, sizeof(strbuff), "system does not support opening " + "more than %s files" , strbuff1); + fprintf(stderr, "%s\n", strbuff); + + num_open.rlim_max = num_open.rlim_cur + 2 - SAFETY_MARGIN; + + num_open.rlim_cur -= num_open.rlim_max; + sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff, sizeof(strbuff), "closing %s files", strbuff1); + fprintf(stderr, "%s\n", strbuff); + + for (num_open.rlim_cur = num_open.rlim_max; + fd[num_open.rlim_cur] >= 0; + num_open.rlim_cur++) { + close(fd[num_open.rlim_cur]); + fd[num_open.rlim_cur] = -1; + } + + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); + + tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max)); + if (!tmpfd) { + snprintf(strbuff, sizeof(strbuff), "fd, realloc() failed, " + "errno %d, %s", our_errno(), strerror(our_errno())); + fprintf(stderr, "%s\n", strbuff); + } + else { + fd = tmpfd; + tmpfd = NULL; + } + } + } +#endif /* LIB537 */ + sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); + /* free the chunk of memory we were reserving so that it + becomes becomes available to the test */ + + free(memchunk); + /* close file descriptors unless instructed to keep them */ if (!keep_open) { close_file_descriptors(); @@ -274,7 +487,7 @@ int test(char *URL) /* used by the test script to ask if we can run this test or not */ if(rlimit(FALSE)) { fprintf(stderr, "Previous condition prevents running this test\n"); - printf("rlimit problems\n"); + fprintf(stdout, "rlimit problem: %s\n", msgbuff); return 1; } return 0; /* sure, run this! */ @@ -286,8 +499,10 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - /* run the test with more than FD_SETSIZE or max allowed open - file descriptors and close them all once the test is over */ + fprintf(stderr, "running test...\n"); + + /* run the test with the bunch of open file descriptors + and close them all once the test is over */ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); -- cgit v1.2.1 From 4f4427ff41531d17e3cd48effcbe52a7cc827fed Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 2 Nov 2006 00:34:21 +0000 Subject: check symbol HAVE_UNISTD_H instead of UNISTD_H to include unistd.h --- tests/libtest/lib518.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index bb09f0ffc..62016a279 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -29,7 +29,7 @@ #ifdef HAVE_FCNTL_H #include #endif -#ifdef UNISTD_H +#ifdef HAVE_UNISTD_H #include #endif -- cgit v1.2.1 From fa28531322d268755783198182b47731a20ccf2c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 2 Nov 2006 03:45:07 +0000 Subject: use our internal string functions and replace sprintf with snprintf --- tests/libtest/lib518.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 62016a279..2df2c435f 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -33,6 +33,7 @@ #include #endif +#define _MPRINTF_REPLACE /* use our functions only */ #include #ifdef HAVE_SYS_SELECT_H @@ -140,7 +141,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - sprintf(strbuff, fmt, rl.rlim_cur); + snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); fprintf(stderr, "initial soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY @@ -148,7 +149,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - sprintf(strbuff, fmt, rl.rlim_max); + snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); fprintf(stderr, "initial hard limit: %s\n", strbuff); #ifdef LIB518 @@ -193,7 +194,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - sprintf(strbuff, fmt, rl.rlim_cur); + snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); fprintf(stderr, "current soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY @@ -201,7 +202,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - sprintf(strbuff, fmt, rl.rlim_max); + snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); fprintf(stderr, "current hard limit: %s\n", strbuff); /* @@ -228,8 +229,8 @@ static int rlimit(int keep_open) (rl.rlim_cur != RLIM_INFINITY) && #endif (rl.rlim_cur <= num_open.rlim_cur)) { - sprintf(strbuff2, fmt, rl.rlim_cur); - sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " "files, soft limit is %s", strbuff1, strbuff2); store_errmsg(strbuff, 0); @@ -249,8 +250,8 @@ static int rlimit(int keep_open) (rl.rlim_cur != RLIM_INFINITY) && #endif (rl.rlim_cur <= num_open.rlim_cur)) { - sprintf(strbuff2, fmt, rl.rlim_cur); - sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " "files, soft limit is %s", strbuff1, strbuff2); store_errmsg(strbuff, 0); @@ -271,8 +272,8 @@ static int rlimit(int keep_open) (rl.rlim_cur != RLIM_INFINITY) && #endif (rl.rlim_cur <= num_open.rlim_cur)) { - sprintf(strbuff2, fmt, rl.rlim_cur); - sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " "files, soft limit is %s", strbuff1, strbuff2); store_errmsg(strbuff, 0); @@ -328,7 +329,7 @@ static int rlimit(int keep_open) /* verify that we won't overflow size_t in malloc() */ if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { - sprintf(strbuff1, fmt, num_open.rlim_max); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); store_errmsg(strbuff, 0); @@ -337,7 +338,7 @@ static int rlimit(int keep_open) return -8; } - sprintf(strbuff, fmt, num_open.rlim_max); + snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); @@ -355,7 +356,7 @@ static int rlimit(int keep_open) num_open.rlim_cur++) fd[num_open.rlim_cur] = -1; - sprintf(strbuff, fmt, num_open.rlim_max); + snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); fprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ @@ -385,7 +386,7 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; - sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); store_errmsg(strbuff, our_errno()); fprintf(stderr, "%s\n", msgbuff); @@ -419,11 +420,11 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; - sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); fprintf(stderr, "%s\n", strbuff); - sprintf(strbuff1, fmt, num_open.rlim_cur + 2); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur + 2); snprintf(strbuff, sizeof(strbuff), "system does not support opening " "more than %s files" , strbuff1); fprintf(stderr, "%s\n", strbuff); @@ -431,7 +432,7 @@ static int rlimit(int keep_open) num_open.rlim_max = num_open.rlim_cur + 2 - SAFETY_MARGIN; num_open.rlim_cur -= num_open.rlim_max; - sprintf(strbuff1, fmt, num_open.rlim_cur); + snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff, sizeof(strbuff), "closing %s files", strbuff1); fprintf(stderr, "%s\n", strbuff); @@ -442,7 +443,7 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; } - sprintf(strbuff, fmt, num_open.rlim_max); + snprintf(strbuff, sizeof(strbuff1), fmt, num_open.rlim_max); fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max)); @@ -462,7 +463,7 @@ static int rlimit(int keep_open) #endif /* LIB537 */ - sprintf(strbuff, fmt, num_open.rlim_max); + snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); /* free the chunk of memory we were reserving so that it -- cgit v1.2.1 From e8d21adbaaf829d2980ec9160c7d170227759daa Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 2 Nov 2006 15:47:24 +0000 Subject: code cleanup --- tests/libtest/lib518.c | 95 ++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 62 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 2df2c435f..0edfb3a85 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -32,6 +32,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_LIMITS_H +#include +#endif #define _MPRINTF_REPLACE /* use our functions only */ #include @@ -114,7 +117,9 @@ static int rlimit(int keep_open) struct rlimit rl; char strbuff[256]; char strbuff1[81]; +#ifdef LIB518 char strbuff2[81]; +#endif char fmt_u[] = "%u"; char fmt_lu[] = "%lu"; #ifdef HAVE_LONGLONG @@ -170,6 +175,7 @@ static int rlimit(int keep_open) */ if (rl.rlim_cur != rl.rlim_max) { + fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { @@ -177,33 +183,34 @@ static int rlimit(int keep_open) fprintf(stderr, "%s\n", msgbuff); return -2; } - } - /* get current open file limits */ + /* get current open file limits */ - if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", our_errno()); - fprintf(stderr, "%s\n", msgbuff); - return -3; - } + if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + store_errmsg("getrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + return -3; + } - /* show current open file limits */ + /* show current open file limits */ #ifdef RLIM_INFINITY - if (rl.rlim_cur == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else + if (rl.rlim_cur == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else #endif - snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); - fprintf(stderr, "current soft limit: %s\n", strbuff); + snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + fprintf(stderr, "current soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY - if (rl.rlim_max == RLIM_INFINITY) - strcpy(strbuff, "INFINITY"); - else + if (rl.rlim_max == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else #endif - snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); - fprintf(stderr, "current hard limit: %s\n", strbuff); + snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + fprintf(stderr, "current hard limit: %s\n", strbuff); + + } /* (rl.rlim_cur != rl.rlim_max) */ /* * test 518 is all about testing libcurl functionality @@ -220,45 +227,6 @@ static int rlimit(int keep_open) #ifdef LIB518 - /* verify that soft limit is higher than FD_SETSIZE */ - - num_open.rlim_cur = FD_SETSIZE; - - if ((rl.rlim_cur > 0) && -#ifdef RLIM_INFINITY - (rl.rlim_cur != RLIM_INFINITY) && -#endif - (rl.rlim_cur <= num_open.rlim_cur)) { - snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " - "files, soft limit is %s", strbuff1, strbuff2); - store_errmsg(strbuff, 0); - fprintf(stderr, "%s\n", msgbuff); - return -4; - } - - /* - * verify that soft limit is higher than NUM_OPEN, - * number of file descriptors we would try to open - */ - - num_open.rlim_cur = NUM_OPEN; - - if ((rl.rlim_cur > 0) && -#ifdef RLIM_INFINITY - (rl.rlim_cur != RLIM_INFINITY) && -#endif - (rl.rlim_cur <= num_open.rlim_cur)) { - snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " - "files, soft limit is %s", strbuff1, strbuff2); - store_errmsg(strbuff, 0); - fprintf(stderr, "%s\n", msgbuff); - return -5; - } - /* * verify that soft limit is higher than NUM_NEEDED, * number of file descriptors we would try to open @@ -274,8 +242,8 @@ static int rlimit(int keep_open) (rl.rlim_cur <= num_open.rlim_cur)) { snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "system does not support opening %s " - "files, soft limit is %s", strbuff1, strbuff2); + snprintf(strbuff, sizeof(strbuff), "fd needed (%s) > " + "system limit (%s)", strbuff1, strbuff2); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); return -6; @@ -322,7 +290,7 @@ static int rlimit(int keep_open) } else { /* biggest file descriptor array size */ - num_open.rlim_max = ((size_t)-1) / sizeof(*fd); + num_open.rlim_max = INT_MAX; } #endif /* LIB537 */ @@ -386,9 +354,12 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; + num_open.rlim_max = NUM_NEEDED; + snprintf(strbuff2, sizeof(strbuff2), fmt, num_open.rlim_max); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); - store_errmsg(strbuff, our_errno()); + snprintf(strbuff, sizeof(strbuff), "fd needed (%s) > " + "system limit (%s)", strbuff2, strbuff1); + store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "closing file descriptors\n"); -- cgit v1.2.1 From 2149a095f7ec9bb977c6deac948d9ac32d650389 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 2 Nov 2006 20:50:18 +0000 Subject: update and split test cases 518 and 537 into its own source code file --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib518.c | 211 ++++++------------------ tests/libtest/lib537.c | 399 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 447 insertions(+), 167 deletions(-) create mode 100644 tests/libtest/lib537.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index eb936eb48..aadd9c7ed 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -103,7 +103,6 @@ lib517_SOURCES = lib517.c $(SUPPORTFILES) lib517_DEPENDENCIES = $(DEPENDENCIES) lib518_SOURCES = lib518.c $(SUPPORTFILES) -lib518_CFLAGS = -DLIB518 lib518_DEPENDENCIES = $(DEPENDENCIES) lib519_SOURCES = lib519.c $(SUPPORTFILES) @@ -150,7 +149,6 @@ lib533_DEPENDENCIES = $(DEPENDENCIES) lib536_SOURCES = lib536.c $(SUPPORTFILES) lib536_DEPENDENCIES = $(DEPENDENCIES) -lib537_SOURCES = lib518.c $(SUPPORTFILES) -lib537_CFLAGS = -DLIB537 +lib537_SOURCES = lib537.c $(SUPPORTFILES) lib537_DEPENDENCIES = $(DEPENDENCIES) diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 0edfb3a85..cff412010 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -8,56 +8,31 @@ * $Id$ */ -/* - * This source code is used for lib518 and lib537. - */ - #include "test.h" #ifdef HAVE_SYS_TYPES_H #include #endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_SYS_TIME_H -#include -#endif #ifdef HAVE_SYS_RESOURCE_H #include #endif #ifdef HAVE_FCNTL_H #include #endif -#ifdef HAVE_UNISTD_H -#include -#endif #ifdef HAVE_LIMITS_H #include #endif - -#define _MPRINTF_REPLACE /* use our functions only */ -#include - -#ifdef HAVE_SYS_SELECT_H -#include +#ifdef HAVE_STRING_H +#include #endif -#if defined(LIB518) && !defined(FD_SETSIZE) +#ifndef FD_SETSIZE #error "this test requires FD_SETSIZE" #endif -#ifdef LIB518 -#define SAFETY_MARGIN 16 -#define NUM_OPEN (FD_SETSIZE + 10) -#define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN) -#endif - -#ifdef LIB537 -#define SAFETY_MARGIN 5 -#endif - -#define MEMCHUNK_NITEMS 32000 +#define SAFETY_MARGIN (16) +#define NUM_OPEN (FD_SETSIZE + 10) +#define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN) #if defined(WIN32) || defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" @@ -88,38 +63,31 @@ static int our_errno(void) static void store_errmsg(const char *msg, int err) { if (!err) - snprintf(msgbuff, sizeof(msgbuff), "%s", msg); + sprintf(msgbuff, "%s", msg); else - snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", - msg, err, strerror(err)); + sprintf(msgbuff, "%s, errno %d, %s", msg, err, strerror(err)); } static void close_file_descriptors(void) { - fprintf(stderr, "closing file descriptors\n"); for (num_open.rlim_cur = 0; num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) - close(fd[num_open.rlim_cur]); + if (fd[num_open.rlim_cur] > 0) + close(fd[num_open.rlim_cur]); free(fd); fd = NULL; - fprintf(stderr, "file descriptors closed\n"); } static int rlimit(int keep_open) { -#ifdef LIB537 - int *tmpfd; -#endif - int i; + int nitems, i; int *memchunk = NULL; char *fmt; struct rlimit rl; char strbuff[256]; char strbuff1[81]; -#ifdef LIB518 char strbuff2[81]; -#endif char fmt_u[] = "%u"; char fmt_lu[] = "%lu"; #ifdef HAVE_LONGLONG @@ -146,7 +114,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + sprintf(strbuff, fmt, rl.rlim_cur); fprintf(stderr, "initial soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY @@ -154,16 +122,14 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + sprintf(strbuff, fmt, rl.rlim_max); fprintf(stderr, "initial hard limit: %s\n", strbuff); -#ifdef LIB518 /* show our constants */ fprintf(stderr, "test518 FD_SETSIZE: %d\n", FD_SETSIZE); fprintf(stderr, "test518 NUM_OPEN : %d\n", NUM_OPEN); fprintf(stderr, "test518 NUM_NEEDED: %d\n", NUM_NEEDED); -#endif /* * if soft limit and hard limit are different we ask the @@ -199,7 +165,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_cur); + sprintf(strbuff, fmt, rl.rlim_cur); fprintf(stderr, "current soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY @@ -207,7 +173,7 @@ static int rlimit(int keep_open) strcpy(strbuff, "INFINITY"); else #endif - snprintf(strbuff, sizeof(strbuff), fmt, rl.rlim_max); + sprintf(strbuff, fmt, rl.rlim_max); fprintf(stderr, "current hard limit: %s\n", strbuff); } /* (rl.rlim_cur != rl.rlim_max) */ @@ -218,15 +184,8 @@ static int rlimit(int keep_open) * This means that if for any reason we are not able to * open more than FD_SETSIZE file descriptors then test * 518 should not be run. - * - * test 537 is all about testing libcurl functionality - * when the system has nearly exhausted the number of - * free file descriptors. Test 537 will try to run with - * very few free file descriptors. */ -#ifdef LIB518 - /* * verify that soft limit is higher than NUM_NEEDED, * number of file descriptors we would try to open @@ -240,17 +199,15 @@ static int rlimit(int keep_open) (rl.rlim_cur != RLIM_INFINITY) && #endif (rl.rlim_cur <= num_open.rlim_cur)) { - snprintf(strbuff2, sizeof(strbuff2), fmt, rl.rlim_cur); - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "fd needed (%s) > " - "system limit (%s)", strbuff1, strbuff2); + sprintf(strbuff2, fmt, rl.rlim_cur); + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "fd needed (%s) > system limit (%s)", + strbuff1, strbuff2); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); - return -6; + return -4; } -#endif /* LIB518 */ - /* * reserve a chunk of memory before opening file descriptors to * avoid a low memory condition once the file descriptors are @@ -260,7 +217,12 @@ static int rlimit(int keep_open) * that it becomes available to the test. */ - memchunk = malloc(sizeof(*memchunk) * MEMCHUNK_NITEMS); + nitems = INT_MAX / sizeof(*memchunk); + do { + memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); + if (!memchunk) + nitems /= 2; + } while (nitems && !memchunk); if (!memchunk) { store_errmsg("memchunk, malloc() failed", our_errno()); fprintf(stderr, "%s\n", msgbuff); @@ -269,44 +231,28 @@ static int rlimit(int keep_open) /* initialize it to fight lazy allocation */ - for (i = 0; i < MEMCHUNK_NITEMS; i++) + for (i = 0; i < nitems; i++) memchunk[i] = -1; - /* set the number of file descriptors we will try to open to ... */ + /* set the number of file descriptors we will try to open */ -#ifdef LIB518 - /* NUM_OPEN */ num_open.rlim_max = NUM_OPEN; -#endif - -#ifdef LIB537 -#ifdef RLIM_INFINITY - if ((rl.rlim_cur > 0) && (rl.rlim_cur != RLIM_INFINITY)) { -#else - if (rl.rlim_cur > 0) { -#endif - /* soft limit minus SAFETY_MARGIN */ - num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; - } - else { - /* biggest file descriptor array size */ - num_open.rlim_max = INT_MAX; - } -#endif /* LIB537 */ /* verify that we won't overflow size_t in malloc() */ if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); - snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " - "file descriptors, would overflow size_t", strbuff1); + sprintf(strbuff1, fmt, num_open.rlim_max); + sprintf(strbuff, "unable to allocate an array for %s " + "file descriptors, would overflow size_t", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -8; } - snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + /* allocate array for file descriptors */ + + sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); @@ -324,14 +270,14 @@ static int rlimit(int keep_open) num_open.rlim_cur++) fd[num_open.rlim_cur] = -1; - snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "trying to open %s file descriptors\n", strbuff); /* open a dummy descriptor */ fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] < 0) { - snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); + sprintf(strbuff, "opening of %s failed", DEV_NULL); store_errmsg(strbuff, our_errno()); fprintf(stderr, "%s\n", msgbuff); free(fd); @@ -342,8 +288,6 @@ static int rlimit(int keep_open) /* create a bunch of file descriptors */ -#ifdef LIB518 - for (num_open.rlim_cur = 1; num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) { @@ -355,19 +299,17 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; num_open.rlim_max = NUM_NEEDED; - snprintf(strbuff2, sizeof(strbuff2), fmt, num_open.rlim_max); - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "fd needed (%s) > " - "system limit (%s)", strbuff2, strbuff1); + sprintf(strbuff2, fmt, num_open.rlim_max); + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "fd needed (%s) > system limit (%s)", + strbuff2, strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); - fprintf(stderr, "closing file descriptors\n"); for (num_open.rlim_cur = 0; fd[num_open.rlim_cur] >= 0; num_open.rlim_cur++) close(fd[num_open.rlim_cur]); - fprintf(stderr, "file descriptors closed\n"); free(fd); fd = NULL; free(memchunk); @@ -377,64 +319,7 @@ static int rlimit(int keep_open) } -#endif /* LIB518 */ - -#ifdef LIB537 - - for (num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) { - - fd[num_open.rlim_cur] = dup(fd[0]); - - if (fd[num_open.rlim_cur] < 0) { - - fd[num_open.rlim_cur] = -1; - - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed", strbuff1); - fprintf(stderr, "%s\n", strbuff); - - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur + 2); - snprintf(strbuff, sizeof(strbuff), "system does not support opening " - "more than %s files" , strbuff1); - fprintf(stderr, "%s\n", strbuff); - - num_open.rlim_max = num_open.rlim_cur + 2 - SAFETY_MARGIN; - - num_open.rlim_cur -= num_open.rlim_max; - snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "closing %s files", strbuff1); - fprintf(stderr, "%s\n", strbuff); - - for (num_open.rlim_cur = num_open.rlim_max; - fd[num_open.rlim_cur] >= 0; - num_open.rlim_cur++) { - close(fd[num_open.rlim_cur]); - fd[num_open.rlim_cur] = -1; - } - - snprintf(strbuff, sizeof(strbuff1), fmt, num_open.rlim_max); - fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); - - tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max)); - if (!tmpfd) { - snprintf(strbuff, sizeof(strbuff), "fd, realloc() failed, " - "errno %d, %s", our_errno(), strerror(our_errno())); - fprintf(stderr, "%s\n", strbuff); - } - else { - fd = tmpfd; - tmpfd = NULL; - } - - } - - } - -#endif /* LIB537 */ - - snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); + sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); /* free the chunk of memory we were reserving so that it @@ -458,7 +343,6 @@ int test(char *URL) if(!strcmp(URL, "check")) { /* used by the test script to ask if we can run this test or not */ if(rlimit(FALSE)) { - fprintf(stderr, "Previous condition prevents running this test\n"); fprintf(stdout, "rlimit problem: %s\n", msgbuff); return 1; } @@ -467,12 +351,9 @@ int test(char *URL) if (rlimit(TRUE)) { /* failure */ - fprintf(stderr, "Previous condition aborts this test\n"); return TEST_ERR_MAJOR_BAD; } - fprintf(stderr, "running test...\n"); - /* run the test with the bunch of open file descriptors and close them all once the test is over */ @@ -500,12 +381,14 @@ int test(char *URL) return (int)res; } -#else -/* system lacks getrlimit() and/or setrlimit() */ + +#else /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */ + int test(char *URL) { (void)URL; printf("system lacks necessary system function(s)"); - return 1; + return 1; /* skip test */ } -#endif + +#endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */ diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c new file mode 100644 index 000000000..7f1d7b3e2 --- /dev/null +++ b/tests/libtest/lib537.c @@ -0,0 +1,399 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +/* + * This source code is used for lib518 and lib537. + */ + +#include "test.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_LIMITS_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#define SAFETY_MARGIN (10) + +#if defined(WIN32) || defined(_WIN32) || defined(MSDOS) +#define DEV_NULL "NUL" +#else +#define DEV_NULL "/dev/null" +#endif + +#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) + +static int *fd = NULL; +static struct rlimit num_open; +static char msgbuff[256]; + +/* + * our_errno() returns the NOT *socket-related* errno (or equivalent) + * on this platform to hide platform specific for the calling function. + */ + +static int our_errno(void) +{ +#ifdef WIN32 + return (int)GetLastError(); +#else + return errno; +#endif +} + +static void store_errmsg(const char *msg, int err) +{ + if (!err) + sprintf(msgbuff, "%s", msg); + else + sprintf(msgbuff, "%s, errno %d, %s", msg, err, strerror(err)); +} + +static void close_file_descriptors(void) +{ + for (num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) + if (fd[num_open.rlim_cur] > 0) + close(fd[num_open.rlim_cur]); + free(fd); + fd = NULL; +} + +static int rlimit(int keep_open) +{ + int *tmpfd; + int nitems, i; + int *memchunk = NULL; + char *fmt; + struct rlimit rl; + char strbuff[256]; + char strbuff1[81]; + char fmt_u[] = "%u"; + char fmt_lu[] = "%lu"; +#ifdef HAVE_LONGLONG + char fmt_llu[] = "%llu"; + + if (sizeof(rl.rlim_max) > sizeof(long)) + fmt = fmt_llu; + else +#endif + fmt = (sizeof(rl.rlim_max) < sizeof(long))?fmt_u:fmt_lu; + + /* get initial open file limits */ + + if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + store_errmsg("getrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + return -1; + } + + /* show initial open file limits */ + +#ifdef RLIM_INFINITY + if (rl.rlim_cur == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else +#endif + sprintf(strbuff, fmt, rl.rlim_cur); + fprintf(stderr, "initial soft limit: %s\n", strbuff); + +#ifdef RLIM_INFINITY + if (rl.rlim_max == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else +#endif + sprintf(strbuff, fmt, rl.rlim_max); + fprintf(stderr, "initial hard limit: %s\n", strbuff); + + /* + * if soft limit and hard limit are different we ask the + * system to raise soft limit all the way up to the hard + * limit. Due to some other system limit the soft limit + * might not be raised up to the hard limit. So from this + * point the resulting soft limit is our limit. Trying to + * open more than soft limit file descriptors will fail. + */ + + if (rl.rlim_cur != rl.rlim_max) { + + fprintf(stderr, "raising soft limit up to hard limit\n"); + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + store_errmsg("setrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + return -2; + } + + /* get current open file limits */ + + if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + store_errmsg("getrlimit() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + return -3; + } + + /* show current open file limits */ + +#ifdef RLIM_INFINITY + if (rl.rlim_cur == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else +#endif + sprintf(strbuff, fmt, rl.rlim_cur); + fprintf(stderr, "current soft limit: %s\n", strbuff); + +#ifdef RLIM_INFINITY + if (rl.rlim_max == RLIM_INFINITY) + strcpy(strbuff, "INFINITY"); + else +#endif + sprintf(strbuff, fmt, rl.rlim_max); + fprintf(stderr, "current hard limit: %s\n", strbuff); + + } /* (rl.rlim_cur != rl.rlim_max) */ + + /* + * test 537 is all about testing libcurl functionality + * when the system has nearly exhausted the number of + * free file descriptors. Test 537 will try to run with + * very few free file descriptors. + */ + + /* + * reserve a chunk of memory before opening file descriptors to + * avoid a low memory condition once the file descriptors are + * open. System conditions that could make the test fail should + * be addressed in the precheck phase. This chunk of memory shall + * be always free()ed before exiting the rlimit() function so + * that it becomes available to the test. + */ + + nitems = INT_MAX / sizeof(*memchunk); + do { + memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); + if (!memchunk) + nitems /= 2; + } while (nitems && !memchunk); + if (!memchunk) { + store_errmsg("memchunk, malloc() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + return -7; + } + + /* initialize it to fight lazy allocation */ + + for (i = 0; i < nitems; i++) + memchunk[i] = -1; + + /* set the number of file descriptors we will try to open */ + +#ifdef RLIM_INFINITY + if ((rl.rlim_cur > 0) && (rl.rlim_cur != RLIM_INFINITY)) { +#else + if (rl.rlim_cur > 0) { +#endif + /* soft limit minus SAFETY_MARGIN */ + num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; + } + else { + /* biggest file descriptor array size */ + num_open.rlim_max = INT_MAX / sizeof(*fd); + } + + /* verify that we won't overflow size_t in malloc() */ + + if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { + sprintf(strbuff1, fmt, num_open.rlim_max); + sprintf(strbuff, "unable to allocate an array for %s " + "file descriptors, would overflow size_t", strbuff1); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + free(memchunk); + return -8; + } + + /* allocate array for file descriptors */ + + do { + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); + fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); + if (!fd) { + fprintf(stderr, "fd, malloc() failed\n"); + num_open.rlim_max /= 2; + } + } while (num_open.rlim_max && !fd); + if (!fd) { + store_errmsg("fd, malloc() failed", our_errno()); + fprintf(stderr, "%s\n", msgbuff); + free(memchunk); + return -9; + } + + /* initialize it to fight lazy allocation */ + + for (num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) + fd[num_open.rlim_cur] = -1; + + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "trying to open %s file descriptors\n", strbuff); + + /* open a dummy descriptor */ + + fd[0] = open(DEV_NULL, O_RDONLY); + if (fd[0] < 0) { + sprintf(strbuff, "opening of %s failed", DEV_NULL); + store_errmsg(strbuff, our_errno()); + fprintf(stderr, "%s\n", msgbuff); + free(fd); + fd = NULL; + free(memchunk); + return -10; + } + + /* create a bunch of file descriptors */ + + for (num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) { + + fd[num_open.rlim_cur] = dup(fd[0]); + + if (fd[num_open.rlim_cur] < 0) { + + fd[num_open.rlim_cur] = -1; + + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "dup() attempt %s failed", strbuff1); + fprintf(stderr, "%s\n", strbuff); + + sprintf(strbuff1, fmt, num_open.rlim_cur + 2); + sprintf(strbuff, "system does not support opening " + "more than %s files" , strbuff1); + fprintf(stderr, "%s\n", strbuff); + + num_open.rlim_max = num_open.rlim_cur + 2 - SAFETY_MARGIN; + + num_open.rlim_cur -= num_open.rlim_max; + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "closing %s files", strbuff1); + fprintf(stderr, "%s\n", strbuff); + + for (num_open.rlim_cur = num_open.rlim_max; + fd[num_open.rlim_cur] >= 0; + num_open.rlim_cur++) { + close(fd[num_open.rlim_cur]); + fd[num_open.rlim_cur] = -1; + } + + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); + + tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max)); + if (!tmpfd) { + sprintf(strbuff, "fd, realloc() failed, " + "errno %d, %s", our_errno(), strerror(our_errno())); + fprintf(stderr, "%s\n", strbuff); + } + else { + fd = tmpfd; + tmpfd = NULL; + } + + } + + } + + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "%s file descriptors open\n", strbuff); + + /* free the chunk of memory we were reserving so that it + becomes becomes available to the test */ + + free(memchunk); + + /* close file descriptors unless instructed to keep them */ + if (!keep_open) { + close_file_descriptors(); + } + + return 0; +} + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + if(!strcmp(URL, "check")) { + /* used by the test script to ask if we can run this test or not */ + if(rlimit(FALSE)) { + fprintf(stdout, "rlimit problem: %s\n", msgbuff); + return 1; + } + return 0; /* sure, run this! */ + } + + if (rlimit(TRUE)) { + /* failure */ + return TEST_ERR_MAJOR_BAD; + } + + /* run the test with the bunch of open file descriptors + and close them all once the test is over */ + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + close_file_descriptors(); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + close_file_descriptors(); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + res = curl_easy_perform(curl); + + close_file_descriptors(); + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + +#else /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */ + +int test(char *URL) +{ + (void)URL; + printf("system lacks necessary system function(s)"); + return 1; /* skip test */ +} + +#endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */ -- cgit v1.2.1 From 7f1870da5f5fa114c461bc8d4651961ad0d370f0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 2 Nov 2006 20:56:40 +0000 Subject: remove leftover comment --- tests/libtest/lib537.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 7f1d7b3e2..e22fa9895 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -8,10 +8,6 @@ * $Id$ */ -/* - * This source code is used for lib518 and lib537. - */ - #include "test.h" #ifdef HAVE_SYS_TYPES_H -- cgit v1.2.1 From 426ecfd136ae98b090ebcae92d49e7e9cd3345d5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 3 Nov 2006 01:56:55 +0000 Subject: fix comments and renumber rlimit return codes --- tests/libtest/lib518.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index cff412010..4fc06dfb2 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -188,8 +188,9 @@ static int rlimit(int keep_open) /* * verify that soft limit is higher than NUM_NEEDED, - * number of file descriptors we would try to open - * plus SAFETY_MARGIN to not exhaust file pool + * which is the number of file descriptors we would + * try to open plus SAFETY_MARGIN to not exhaust the + * file descriptor pool */ num_open.rlim_cur = NUM_NEEDED; @@ -226,7 +227,7 @@ static int rlimit(int keep_open) if (!memchunk) { store_errmsg("memchunk, malloc() failed", our_errno()); fprintf(stderr, "%s\n", msgbuff); - return -7; + return -5; } /* initialize it to fight lazy allocation */ @@ -247,7 +248,7 @@ static int rlimit(int keep_open) store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); - return -8; + return -6; } /* allocate array for file descriptors */ @@ -260,7 +261,7 @@ static int rlimit(int keep_open) store_errmsg("fd, malloc() failed", our_errno()); fprintf(stderr, "%s\n", msgbuff); free(memchunk); - return -9; + return -7; } /* initialize it to fight lazy allocation */ @@ -283,7 +284,7 @@ static int rlimit(int keep_open) free(fd); fd = NULL; free(memchunk); - return -10; + return -8; } /* create a bunch of file descriptors */ @@ -313,7 +314,7 @@ static int rlimit(int keep_open) free(fd); fd = NULL; free(memchunk); - return -11; + return -9; } @@ -328,6 +329,7 @@ static int rlimit(int keep_open) free(memchunk); /* close file descriptors unless instructed to keep them */ + if (!keep_open) { close_file_descriptors(); } -- cgit v1.2.1 From 1dee2cd55e1205eed42f72ff236e015f559d0fa8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 3 Nov 2006 01:57:25 +0000 Subject: fix comments and renumber rlimit return codes fix closing of fd's when limit is reached --- tests/libtest/lib537.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index e22fa9895..c9c4dd4f1 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -169,8 +169,11 @@ static int rlimit(int keep_open) /* * test 537 is all about testing libcurl functionality * when the system has nearly exhausted the number of - * free file descriptors. Test 537 will try to run with - * very few free file descriptors. + * available file descriptors. Test 537 will try to run + * with a very small number of file descriptors available. + * This implies that any file descriptor which is open + * when the test runs will have a number in the high range + * of whatever the system supports. */ /* @@ -191,7 +194,7 @@ static int rlimit(int keep_open) if (!memchunk) { store_errmsg("memchunk, malloc() failed", our_errno()); fprintf(stderr, "%s\n", msgbuff); - return -7; + return -4; } /* initialize it to fight lazy allocation */ @@ -210,7 +213,7 @@ static int rlimit(int keep_open) num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN; } else { - /* biggest file descriptor array size */ + /* a huge number of file descriptors */ num_open.rlim_max = INT_MAX / sizeof(*fd); } @@ -223,7 +226,7 @@ static int rlimit(int keep_open) store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); - return -8; + return -5; } /* allocate array for file descriptors */ @@ -241,7 +244,7 @@ static int rlimit(int keep_open) store_errmsg("fd, malloc() failed", our_errno()); fprintf(stderr, "%s\n", msgbuff); free(memchunk); - return -9; + return -6; } /* initialize it to fight lazy allocation */ @@ -264,7 +267,7 @@ static int rlimit(int keep_open) free(fd); fd = NULL; free(memchunk); - return -10; + return -7; } /* create a bunch of file descriptors */ @@ -283,16 +286,15 @@ static int rlimit(int keep_open) sprintf(strbuff, "dup() attempt %s failed", strbuff1); fprintf(stderr, "%s\n", strbuff); - sprintf(strbuff1, fmt, num_open.rlim_cur + 2); - sprintf(strbuff, "system does not support opening " - "more than %s files" , strbuff1); + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "fd system limit seems close to %s", strbuff1); fprintf(stderr, "%s\n", strbuff); - num_open.rlim_max = num_open.rlim_cur + 2 - SAFETY_MARGIN; + num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN; num_open.rlim_cur -= num_open.rlim_max; sprintf(strbuff1, fmt, num_open.rlim_cur); - sprintf(strbuff, "closing %s files", strbuff1); + sprintf(strbuff, "closing %s file descriptors", strbuff1); fprintf(stderr, "%s\n", strbuff); for (num_open.rlim_cur = num_open.rlim_max; @@ -305,17 +307,16 @@ static int rlimit(int keep_open) sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "shrinking array for %s file descriptors\n", strbuff); + /* we don't care if we can't shrink it */ + tmpfd = realloc(fd, sizeof(*fd) * (size_t)(num_open.rlim_max)); - if (!tmpfd) { - sprintf(strbuff, "fd, realloc() failed, " - "errno %d, %s", our_errno(), strerror(our_errno())); - fprintf(stderr, "%s\n", strbuff); - } - else { + if (tmpfd) { fd = tmpfd; tmpfd = NULL; } + break; + } } @@ -329,6 +330,7 @@ static int rlimit(int keep_open) free(memchunk); /* close file descriptors unless instructed to keep them */ + if (!keep_open) { close_file_descriptors(); } -- cgit v1.2.1 From 78081a1652bce9877f464d97e9780f9e296e293b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 3 Nov 2006 10:05:21 +0000 Subject: reduce max size of dinamically allocated arrays to minimize the nasty behaviour some versions of IRIX exhibit of committing suicide on big mallocs instead of just returning a friendly null pointer --- tests/libtest/lib518.c | 20 ++++++++++++++++---- tests/libtest/lib537.c | 22 +++++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 4fc06dfb2..d91625f98 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -202,7 +202,7 @@ static int rlimit(int keep_open) (rl.rlim_cur <= num_open.rlim_cur)) { sprintf(strbuff2, fmt, rl.rlim_cur); sprintf(strbuff1, fmt, num_open.rlim_cur); - sprintf(strbuff, "fd needed (%s) > system limit (%s)", + sprintf(strbuff, "fds needed %s > system limit %s", strbuff1, strbuff2); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); @@ -218,11 +218,19 @@ static int rlimit(int keep_open) * that it becomes available to the test. */ - nitems = INT_MAX / sizeof(*memchunk); + for (nitems = i = 1; nitems <= i; i *= 2) + nitems = i; + if (nitems > 0x7fff) + nitems = 0x40000; do { + num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems; + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); - if (!memchunk) + if (!memchunk) { + fprintf(stderr, "memchunk, malloc() failed\n"); nitems /= 2; + } } while (nitems && !memchunk); if (!memchunk) { store_errmsg("memchunk, malloc() failed", our_errno()); @@ -232,6 +240,8 @@ static int rlimit(int keep_open) /* initialize it to fight lazy allocation */ + fprintf(stderr, "initializing memchunk array\n"); + for (i = 0; i < nitems; i++) memchunk[i] = -1; @@ -266,6 +276,8 @@ static int rlimit(int keep_open) /* initialize it to fight lazy allocation */ + fprintf(stderr, "initializing fd array\n"); + for (num_open.rlim_cur = 0; num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) @@ -302,7 +314,7 @@ static int rlimit(int keep_open) num_open.rlim_max = NUM_NEEDED; sprintf(strbuff2, fmt, num_open.rlim_max); sprintf(strbuff1, fmt, num_open.rlim_cur); - sprintf(strbuff, "fd needed (%s) > system limit (%s)", + sprintf(strbuff, "fds needed %s > system limit %s", strbuff2, strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index c9c4dd4f1..08bf1209c 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -185,11 +185,19 @@ static int rlimit(int keep_open) * that it becomes available to the test. */ - nitems = INT_MAX / sizeof(*memchunk); + for (nitems = i = 1; nitems <= i; i *= 2) + nitems = i; + if (nitems > 0x7fff) + nitems = 0x40000; do { + num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems; + sprintf(strbuff, fmt, num_open.rlim_max); + fprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); - if (!memchunk) + if (!memchunk) { + fprintf(stderr, "memchunk, malloc() failed\n"); nitems /= 2; + } } while (nitems && !memchunk); if (!memchunk) { store_errmsg("memchunk, malloc() failed", our_errno()); @@ -199,6 +207,8 @@ static int rlimit(int keep_open) /* initialize it to fight lazy allocation */ + fprintf(stderr, "initializing memchunk array\n"); + for (i = 0; i < nitems; i++) memchunk[i] = -1; @@ -214,7 +224,11 @@ static int rlimit(int keep_open) } else { /* a huge number of file descriptors */ - num_open.rlim_max = INT_MAX / sizeof(*fd); + for (nitems = i = 1; nitems <= i; i *= 2) + nitems = i; + if (nitems > 0x7fff) + nitems = 0x40000; + num_open.rlim_max = nitems; } /* verify that we won't overflow size_t in malloc() */ @@ -249,6 +263,8 @@ static int rlimit(int keep_open) /* initialize it to fight lazy allocation */ + fprintf(stderr, "initializing fd array\n"); + for (num_open.rlim_cur = 0; num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) -- cgit v1.2.1 From 318a7584f360306ed39ad46c05217a428a978fff Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 3 Nov 2006 14:13:25 +0000 Subject: add a couple more of debugging messages --- tests/libtest/lib518.c | 9 +++++++++ tests/libtest/lib537.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index d91625f98..3f5ac11a6 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -311,7 +311,16 @@ static int rlimit(int keep_open) fd[num_open.rlim_cur] = -1; + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "dup() attempt %s failed", strbuff1); + fprintf(stderr, "%s\n", strbuff); + + sprintf(strbuff1, fmt, num_open.rlim_cur); + sprintf(strbuff, "fds system limit seems close to %s", strbuff1); + fprintf(stderr, "%s\n", strbuff); + num_open.rlim_max = NUM_NEEDED; + sprintf(strbuff2, fmt, num_open.rlim_max); sprintf(strbuff1, fmt, num_open.rlim_cur); sprintf(strbuff, "fds needed %s > system limit %s", diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 08bf1209c..fd030dd10 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -303,7 +303,7 @@ static int rlimit(int keep_open) fprintf(stderr, "%s\n", strbuff); sprintf(strbuff1, fmt, num_open.rlim_cur); - sprintf(strbuff, "fd system limit seems close to %s", strbuff1); + sprintf(strbuff, "fds system limit seems close to %s", strbuff1); fprintf(stderr, "%s\n", strbuff); num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN; -- cgit v1.2.1 From 3bae748256260290a49d6a9a12fe53089854f600 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 18 Jan 2007 18:04:20 +0000 Subject: Added precheck that curl supports the 'openssl' engine in test 307. --- tests/libtest/Makefile.am | 2 ++ tests/libtest/test307.pl | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 tests/libtest/test307.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index aadd9c7ed..6fd685854 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,6 +35,8 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib +EXTRA_DIST = test307.pl + # these files are used in every single test program below SUPPORTFILES = first.c test.h diff --git a/tests/libtest/test307.pl b/tests/libtest/test307.pl new file mode 100755 index 000000000..7e2687b54 --- /dev/null +++ b/tests/libtest/test307.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +# Determine if the given curl executable supports the 'openssl' SSL engine +if ( $#ARGV != 0 ) +{ + print "Usage: $0 curl-executable\n"; + exit 3; +} +if (!open(CURL, "@ARGV[0] -s --engine list|")) +{ + print "Can't get SSL engine list\n"; + exit 2; +} +while( ) +{ + exit 0 if ( /openssl/ ); +} +close CURL; +print "openssl engine not supported\n"; +exit 1; -- cgit v1.2.1 From e09450103bc85392b52e55200ac89b2ffe823acd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 28 Jan 2007 03:51:10 +0000 Subject: Compiler warning fix --- tests/libtest/lib518.c | 2 +- tests/libtest/lib537.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 3f5ac11a6..ffe38961e 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -251,7 +251,7 @@ static int rlimit(int keep_open) /* verify that we won't overflow size_t in malloc() */ - if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { + if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index fd030dd10..ab24b4242 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -233,7 +233,7 @@ static int rlimit(int keep_open) /* verify that we won't overflow size_t in malloc() */ - if (num_open.rlim_max > ((size_t)-1) / sizeof(*fd)) { + if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); -- cgit v1.2.1 From 4d8dcf7b771ce03258577a8faf96146ffd3d2770 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 29 Jan 2007 10:09:06 +0000 Subject: the libtest source codes that use curlx_tv* functions MUST use the lib/timeval.c source code since those functions are not in the API (and might not be accessible) --- tests/libtest/Makefile.am | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 6fd685854..e9ad9454b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -37,6 +37,10 @@ LIBDIR = $(top_builddir)/lib EXTRA_DIST = test307.pl +# *NOTICE* that some test cases use curlx_* functions that are not in the API +# but must be provided by source +TIMEVAL=$(top_srcdir)/lib/timeval.c + # these files are used in every single test program below SUPPORTFILES = first.c test.h @@ -56,13 +60,13 @@ lib500_DEPENDENCIES = $(DEPENDENCIES) lib501_SOURCES = lib501.c $(SUPPORTFILES) lib501_DEPENDENCIES = $(DEPENDENCIES) -lib502_SOURCES = lib502.c $(SUPPORTFILES) +lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TIMEVAL) lib502_DEPENDENCIES = $(DEPENDENCIES) -lib503_SOURCES = lib503.c $(SUPPORTFILES) +lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TIMEVAL) lib503_DEPENDENCIES = $(DEPENDENCIES) -lib504_SOURCES = lib504.c $(SUPPORTFILES) +lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TIMEVAL) lib504_DEPENDENCIES = $(DEPENDENCIES) lib505_SOURCES = lib505.c $(SUPPORTFILES) @@ -71,13 +75,13 @@ lib505_DEPENDENCIES = $(DEPENDENCIES) lib506_SOURCES = lib506.c $(SUPPORTFILES) lib506_DEPENDENCIES = $(DEPENDENCIES) -lib507_SOURCES = lib507.c $(SUPPORTFILES) +lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TIMEVAL) lib507_DEPENDENCIES = $(DEPENDENCIES) lib508_SOURCES = lib508.c $(SUPPORTFILES) lib508_DEPENDENCIES = $(DEPENDENCIES) -lib509_SOURCES = lib509.c $(SUPPORTFILES) +lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TIMEVAL) lib509_DEPENDENCIES = $(DEPENDENCIES) lib510_SOURCES = lib510.c $(SUPPORTFILES) @@ -122,10 +126,10 @@ lib523_DEPENDENCIES = $(DEPENDENCIES) lib524_SOURCES = lib524.c $(SUPPORTFILES) lib524_DEPENDENCIES = $(DEPENDENCIES) -lib525_SOURCES = lib525.c $(SUPPORTFILES) +lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TIMEVAL) lib525_DEPENDENCIES = $(DEPENDENCIES) -lib526_SOURCES = lib526.c $(SUPPORTFILES) +lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) lib526_CFLAGS = -DLIB526 lib526_DEPENDENCIES = $(DEPENDENCIES) @@ -137,7 +141,7 @@ lib529_SOURCES = lib525.c $(SUPPORTFILES) lib529_CFLAGS = -DLIB529 lib529_DEPENDENCIES = $(DEPENDENCIES) -lib530_SOURCES = lib530.c $(SUPPORTFILES) +lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TIMEVAL) lib530_CFLAGS = -DLIB530 lib530_DEPENDENCIES = $(DEPENDENCIES) @@ -145,10 +149,10 @@ lib532_SOURCES = lib526.c $(SUPPORTFILES) lib532_CFLAGS = -DLIB532 lib532_DEPENDENCIES = $(DEPENDENCIES) -lib533_SOURCES = lib533.c $(SUPPORTFILES) +lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TIMEVAL) lib533_DEPENDENCIES = $(DEPENDENCIES) -lib536_SOURCES = lib536.c $(SUPPORTFILES) +lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TIMEVAL) lib536_DEPENDENCIES = $(DEPENDENCIES) lib537_SOURCES = lib537.c $(SUPPORTFILES) -- cgit v1.2.1 From d10e174fd1445844f00b84317bb25f90b304dd5d Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Mon, 29 Jan 2007 20:24:00 +0000 Subject: Some compilers lacks . Include "timeval.h" to simplify the #ifdefs. --- tests/libtest/lib503.c | 5 ++--- tests/libtest/lib504.c | 5 ++--- tests/libtest/lib509.c | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 66d2c9813..efa6723c1 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -10,7 +10,6 @@ #include "test.h" -#include #include #include "timeval.h" @@ -83,7 +82,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (curlx_tvdiff(curlx_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -93,7 +92,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (curlx_tvdiff(curlx_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 5b10022df..775468da0 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -10,7 +10,6 @@ #include "test.h" -#include #include #include "timeval.h" @@ -83,7 +82,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (curlx_tvdiff(curlx_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -97,7 +96,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (curlx_tvdiff(curlx_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index a911e3654..86e169d8d 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -12,7 +12,6 @@ #ifdef USE_SSLEAY -#include #include #include @@ -33,7 +32,7 @@ #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 -/* +/* * We use this ZERO_NULL to avoid picky compiler warnings, * when assigning a NULL pointer to a function pointer var. */ @@ -259,7 +258,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (curlx_tvdiff(curlx_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -269,7 +268,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(multi, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (curlx_tvdiff(curlx_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; -- cgit v1.2.1 From a4b39c6ab8d5cbfa0f674eff54826177076bbe0a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 29 Jan 2007 20:37:02 +0000 Subject: the same source file is re-used for multiple tests and I missed to add the timval.c dependency on some of those --- tests/libtest/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e9ad9454b..61d4cc32e 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -133,11 +133,11 @@ lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) lib526_CFLAGS = -DLIB526 lib526_DEPENDENCIES = $(DEPENDENCIES) -lib527_SOURCES = lib526.c $(SUPPORTFILES) +lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) lib527_CFLAGS = -DLIB527 lib527_DEPENDENCIES = $(DEPENDENCIES) -lib529_SOURCES = lib525.c $(SUPPORTFILES) +lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TIMEVAL) lib529_CFLAGS = -DLIB529 lib529_DEPENDENCIES = $(DEPENDENCIES) @@ -145,7 +145,7 @@ lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TIMEVAL) lib530_CFLAGS = -DLIB530 lib530_DEPENDENCIES = $(DEPENDENCIES) -lib532_SOURCES = lib526.c $(SUPPORTFILES) +lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) lib532_CFLAGS = -DLIB532 lib532_DEPENDENCIES = $(DEPENDENCIES) -- cgit v1.2.1 From bad67830b3bfbd44219ef5f6d467c0ed9dedd063 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 30 Jan 2007 03:48:29 +0000 Subject: skip test on platforms on which we use select() instead of poll() and select() happens to be bound by FD_SETSIZE --- tests/libtest/lib518.c | 27 +++++++++++++++++++++++++++ tests/libtest/lib537.c | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index ffe38961e..47cea8244 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -344,6 +344,33 @@ static int rlimit(int keep_open) sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); +#if !defined(HAVE_POLL_FINE) && \ + !defined(CURL_HAVE_WSAPOLL) && \ + !defined(USE_WINSOCK) && \ + !defined(TPF) + + /* + * when using select() instead of poll() we cannot test + * libcurl functionality with a socket number equal or + * greater than FD_SETSIZE. In any case, macro VERIFY_SOCK + * in lib/select.c enforces this check and protects libcurl + * from a possible crash. The effect of this protection + * is that test 518 will always fail, since the actual + * call to select() never takes place. We skip test 518 + * with an indication that select limit would be exceeded. + */ + + sprintf(strbuff2, fmt, num_open.rlim_max); + sprintf(strbuff, "fds open %s > select limit %d", + strbuff2, FD_SETSIZE); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -10; + +#endif + /* free the chunk of memory we were reserving so that it becomes becomes available to the test */ diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index ab24b4242..ebd100e50 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -340,6 +340,33 @@ static int rlimit(int keep_open) sprintf(strbuff, fmt, num_open.rlim_max); fprintf(stderr, "%s file descriptors open\n", strbuff); +#if !defined(HAVE_POLL_FINE) && \ + !defined(CURL_HAVE_WSAPOLL) && \ + !defined(USE_WINSOCK) && \ + !defined(TPF) + + /* + * when using select() instead of poll() we cannot test + * libcurl functionality with a socket number equal or + * greater than FD_SETSIZE. In any case, macro VERIFY_SOCK + * in lib/select.c enforces this check and protects libcurl + * from a possible crash. The effect of this protection + * is that test 537 will always fail, since the actual + * call to select() never takes place. We skip test 537 + * with an indication that select limit would be exceeded. + */ + + sprintf(strbuff2, fmt, num_open.rlim_max); + sprintf(strbuff, "fds open %s > select limit %d", + strbuff2, FD_SETSIZE); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -8; + +#endif + /* free the chunk of memory we were reserving so that it becomes becomes available to the test */ -- cgit v1.2.1 From d7d5baa0e2e82d36aede94c1e6df83979ec3da66 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 30 Jan 2007 13:21:39 +0000 Subject: fix temp string buffer variable name --- tests/libtest/lib537.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index ebd100e50..6fd9c1097 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -356,9 +356,9 @@ static int rlimit(int keep_open) * with an indication that select limit would be exceeded. */ - sprintf(strbuff2, fmt, num_open.rlim_max); + sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "fds open %s > select limit %d", - strbuff2, FD_SETSIZE); + strbuff1, FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); close_file_descriptors(); -- cgit v1.2.1 From c2639e07388464dd920fe239358458e42658b278 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 31 Jan 2007 15:34:53 +0000 Subject: when using select() instead of poll, skip the test if the number of open file descriptors is greater than FD_SETSIZE minus SAFETY_MARGIN, also skip the test if any of the open file descriptors has a number greater than FD_SETSIZE minus SAFETY_MARGIN. --- tests/libtest/lib518.c | 33 ++++++++++++++++++++++++--------- tests/libtest/lib537.c | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 18 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 47cea8244..368b902ae 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -360,16 +360,31 @@ static int rlimit(int keep_open) * with an indication that select limit would be exceeded. */ - sprintf(strbuff2, fmt, num_open.rlim_max); - sprintf(strbuff, "fds open %s > select limit %d", - strbuff2, FD_SETSIZE); - store_errmsg(strbuff, 0); - fprintf(stderr, "%s\n", msgbuff); - close_file_descriptors(); - free(memchunk); - return -10; + num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; + if (num_open.rlim_max > num_open.rlim_cur) { + sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -10; + } -#endif + num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; + for (rl.rlim_cur = 0; + rl.rlim_cur < num_open.rlim_max; + rl.rlim_cur++) { + if (fd[rl.rlim_cur] > num_open.rlim_cur) { + sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -11; + } + } + +#endif /* using a FD_SETSIZE bound select() */ /* free the chunk of memory we were reserving so that it becomes becomes available to the test */ diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 6fd9c1097..fb2482083 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -26,6 +26,14 @@ #include #endif +#if !defined(HAVE_POLL_FINE) && \ + !defined(CURL_HAVE_WSAPOLL) && \ + !defined(USE_WINSOCK) && \ + !defined(TPF) && \ + !defined(FD_SETSIZE) +#error "this test requires FD_SETSIZE" +#endif + #define SAFETY_MARGIN (10) #if defined(WIN32) || defined(_WIN32) || defined(MSDOS) @@ -356,16 +364,31 @@ static int rlimit(int keep_open) * with an indication that select limit would be exceeded. */ - sprintf(strbuff1, fmt, num_open.rlim_max); - sprintf(strbuff, "fds open %s > select limit %d", - strbuff1, FD_SETSIZE); - store_errmsg(strbuff, 0); - fprintf(stderr, "%s\n", msgbuff); - close_file_descriptors(); - free(memchunk); - return -8; + num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; + if (num_open.rlim_max > num_open.rlim_cur) { + sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -8; + } -#endif + num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; + for (rl.rlim_cur = 0; + rl.rlim_cur < num_open.rlim_max; + rl.rlim_cur++) { + if (fd[rl.rlim_cur] > num_open.rlim_cur) { + sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -9; + } + } + +#endif /* using a FD_SETSIZE bound select() */ /* free the chunk of memory we were reserving so that it becomes becomes available to the test */ -- cgit v1.2.1 From a7748c20246842fa9f964692d05c7e50ed6b5ad0 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Sun, 4 Feb 2007 12:12:02 +0000 Subject: Constify argument to suburl(). Remove trailing space. --- tests/libtest/lib506.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index a090a2ce6..3a3f9e6b9 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -24,7 +24,7 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, void unlock(CURL *handle, curl_lock_data data, void *useptr ); struct curl_slist *sethost(struct curl_slist *headers); void *fire(void *ptr); -char *suburl(char *base, int i); +char *suburl(const char *base, int i); /* struct containing data of a thread */ struct Tdata { @@ -49,13 +49,13 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, switch ( data ) { case CURL_LOCK_DATA_SHARE: - what = "share"; + what = "share"; break; case CURL_LOCK_DATA_DNS: - what = "dns"; + what = "dns"; break; case CURL_LOCK_DATA_COOKIE: - what = "cookie"; + what = "cookie"; break; default: fprintf(stderr, "lock: no such data: %d\n", (int)data); @@ -73,13 +73,13 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr ) (void)handle; switch ( data ) { case CURL_LOCK_DATA_SHARE: - what = "share"; + what = "share"; break; case CURL_LOCK_DATA_DNS: - what = "dns"; + what = "dns"; break; case CURL_LOCK_DATA_COOKIE: - what = "cookie"; + what = "cookie"; break; default: fprintf(stderr, "unlock: no such data: %d\n", (int)data); @@ -135,7 +135,7 @@ void *fire(void *ptr) /* build request url */ -char *suburl(char *base, int i) +char *suburl(const char *base, int i) { return curl_maprintf("%s000%c", base, 48+i); } @@ -156,7 +156,7 @@ int test(char *URL) 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"); @@ -199,12 +199,12 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - + res = 0; /* start treads */ for (i=1; i<=THREADS; i++ ) { - + /* set thread data */ tdata.url = suburl( URL, i ); /* must be curl_free()d */ tdata.share = share; @@ -256,17 +256,17 @@ int test(char *URL) curl_slist_free_all( headers ); curl_free(url); - + /* 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; } -- cgit v1.2.1 From 2f4fe0175b265735fe69f21513f137398743daa4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 9 Feb 2007 01:11:14 +0000 Subject: Some tests were using functions curlx_tvnow and curlx_tvdiff which are not part of the official libcurl API http://curl.haxx.se/lxr/source/lib/README.curlx The documented way of using them would be to use timeval.c as a source code file. The above described method works very well when statically linking libcurl and apps, test programs, but has several drawbacks when you build a true shared libcurl (i.e. Name space clash at linkage stage as functions are defined more than once. Windows makefiles are not capable of handling this system of source-level sharing) So... Now testutil.h and testutil.c define and implement tutil_tvnow and tutil_tvdiff which replace curlx_tvnow and curlx_tvdiff for the libtest programs. Doing this we avoid the above described problems, and the code in the testsuite does not impose the need to keep those functions public in libcurl even when not part of the API. --- tests/libtest/Makefile.am | 31 +++++++++++++++---------------- tests/libtest/lib502.c | 6 +++--- tests/libtest/lib503.c | 10 +++++----- tests/libtest/lib504.c | 10 +++++----- tests/libtest/lib507.c | 14 +++++++------- tests/libtest/lib509.c | 10 +++++----- tests/libtest/lib525.c | 10 +++++----- tests/libtest/lib526.c | 10 +++++----- tests/libtest/lib530.c | 10 +++++----- tests/libtest/lib533.c | 10 +++++----- tests/libtest/lib536.c | 6 +++--- 11 files changed, 63 insertions(+), 64 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 61d4cc32e..61f8f399b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -37,9 +37,8 @@ LIBDIR = $(top_builddir)/lib EXTRA_DIST = test307.pl -# *NOTICE* that some test cases use curlx_* functions that are not in the API -# but must be provided by source -TIMEVAL=$(top_srcdir)/lib/timeval.c +# Source code file used only in some libcurl test programs +TESTUTIL = testutil.c # these files are used in every single test program below SUPPORTFILES = first.c test.h @@ -60,13 +59,13 @@ lib500_DEPENDENCIES = $(DEPENDENCIES) lib501_SOURCES = lib501.c $(SUPPORTFILES) lib501_DEPENDENCIES = $(DEPENDENCIES) -lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TIMEVAL) +lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) lib502_DEPENDENCIES = $(DEPENDENCIES) -lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TIMEVAL) +lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) lib503_DEPENDENCIES = $(DEPENDENCIES) -lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TIMEVAL) +lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) lib504_DEPENDENCIES = $(DEPENDENCIES) lib505_SOURCES = lib505.c $(SUPPORTFILES) @@ -75,13 +74,13 @@ lib505_DEPENDENCIES = $(DEPENDENCIES) lib506_SOURCES = lib506.c $(SUPPORTFILES) lib506_DEPENDENCIES = $(DEPENDENCIES) -lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TIMEVAL) +lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) lib507_DEPENDENCIES = $(DEPENDENCIES) lib508_SOURCES = lib508.c $(SUPPORTFILES) lib508_DEPENDENCIES = $(DEPENDENCIES) -lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TIMEVAL) +lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TESTUTIL) lib509_DEPENDENCIES = $(DEPENDENCIES) lib510_SOURCES = lib510.c $(SUPPORTFILES) @@ -126,33 +125,33 @@ lib523_DEPENDENCIES = $(DEPENDENCIES) lib524_SOURCES = lib524.c $(SUPPORTFILES) lib524_DEPENDENCIES = $(DEPENDENCIES) -lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TIMEVAL) +lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib525_DEPENDENCIES = $(DEPENDENCIES) -lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) +lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib526_CFLAGS = -DLIB526 lib526_DEPENDENCIES = $(DEPENDENCIES) -lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) +lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib527_CFLAGS = -DLIB527 lib527_DEPENDENCIES = $(DEPENDENCIES) -lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TIMEVAL) +lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib529_CFLAGS = -DLIB529 lib529_DEPENDENCIES = $(DEPENDENCIES) -lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TIMEVAL) +lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) lib530_CFLAGS = -DLIB530 lib530_DEPENDENCIES = $(DEPENDENCIES) -lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL) +lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib532_CFLAGS = -DLIB532 lib532_DEPENDENCIES = $(DEPENDENCIES) -lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TIMEVAL) +lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) lib533_DEPENDENCIES = $(DEPENDENCIES) -lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TIMEVAL) +lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) lib536_DEPENDENCIES = $(DEPENDENCIES) lib537_SOURCES = lib537.c $(SUPPORTFILES) diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 207f65ed2..d995b45ec 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -10,7 +10,7 @@ #include "test.h" -#include "timeval.h" +#include "testutil.h" #define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 @@ -57,11 +57,11 @@ int test(char *URL) } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (running) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index efa6723c1..bcf4f57be 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -12,7 +12,7 @@ #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 @@ -72,7 +72,7 @@ int test(char *URL) } ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); while(!done) { fd_set rd, wr, exc; @@ -82,17 +82,17 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 775468da0..499b9e985 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -12,7 +12,7 @@ #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 @@ -74,7 +74,7 @@ int test(char *URL) } ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); while (!done) { struct timeval interval; @@ -82,13 +82,13 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); fprintf(stderr, "curl_multi_perform()\n"); @@ -96,7 +96,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 8de1a3550..d17526463 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -10,7 +10,7 @@ #include "test.h" -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 @@ -58,11 +58,11 @@ int test(char *URL) } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); do { res = curl_multi_perform(multi, &still_running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; @@ -70,7 +70,7 @@ int test(char *URL) } while (res == CURLM_CALL_MULTI_PERFORM); ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); while ((!ml_timedout) && (!mp_timedout) && (still_running)) { struct timeval timeout; @@ -86,7 +86,7 @@ int test(char *URL) timeout.tv_sec = 1; timeout.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -100,10 +100,10 @@ int test(char *URL) case 0: default: mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); do { res = curl_multi_perform(multi, &still_running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 86e169d8d..8f2210f5f 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -27,7 +27,7 @@ #include #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 @@ -248,7 +248,7 @@ int test(char *URL) fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL); ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); while (!done) { fd_set rd, wr, exc; @@ -258,17 +258,17 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (res == CURLM_CALL_MULTI_PERFORM) { res = curl_multi_perform(multi, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 24a329452..ce12b3b84 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -14,7 +14,7 @@ #include #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 @@ -108,7 +108,7 @@ int test(char *URL) } ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); while (!done) { fd_set rd, wr, exc; @@ -118,17 +118,17 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 2dee9cf63..1cfa6d00e 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -33,7 +33,7 @@ #include #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 @@ -98,7 +98,7 @@ int test(char *URL) } ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); fprintf(stderr, "Start at URL 0\n"); @@ -110,17 +110,17 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 987296c7a..96c27b951 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -13,7 +13,7 @@ #include #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 @@ -84,7 +84,7 @@ int test(char *URL) curl_multi_setopt(m, CURLMOPT_PIPELINING, 1); ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); fprintf(stderr, "Start at URL 0\n"); @@ -96,17 +96,17 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 24764bd3c..0cb227529 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -16,7 +16,7 @@ #include #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 @@ -66,7 +66,7 @@ int test(char *URL) } ml_timedout = FALSE; - ml_start = curlx_tvnow(); + ml_start = tutil_tvnow(); fprintf(stderr, "Start at URL 0\n"); @@ -78,17 +78,17 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (curlx_tvdiff(curlx_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; } mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index adad23a16..3f41b00db 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -14,7 +14,7 @@ #include #include -#include "timeval.h" +#include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 @@ -30,11 +30,11 @@ static CURLMcode perform(CURLM * multi) char mp_timedout = FALSE; mp_timedout = FALSE; - mp_start = curlx_tvnow(); + mp_start = tutil_tvnow(); for (;;) { code = curl_multi_perform(multi, &handles); - if (curlx_tvdiff(curlx_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; -- cgit v1.2.1 From 6fcf98f61793e5bc273e857a24b63a58dea2c4c3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 9 Feb 2007 01:17:24 +0000 Subject: Some tests were using functions curlx_tvnow and curlx_tvdiff which are not part of the official libcurl API http://curl.haxx.se/lxr/source/lib/README.curlx The documented way of using them would be to use timeval.c as a source code file. The above described method works very well when statically linking libcurl and apps, test programs, but has several drawbacks when you build a true shared libcurl (i.e. Name space clash at linkage stage as functions are defined more than once. Windows makefiles are not capable of handling this system of source-level sharing) So... Now testutil.h and testutil.c define and implement tutil_tvnow and tutil_tvdiff which replace curlx_tvnow and curlx_tvdiff for the libtest programs. Doing this we avoid the above described problems, and the code in the testsuite does not impose the need to keep those functions public in libcurl even when not part of the API. --- tests/libtest/testutil.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++ tests/libtest/testutil.h | 60 +++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/libtest/testutil.c create mode 100644 tests/libtest/testutil.h (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c new file mode 100644 index 000000000..6acd5a71b --- /dev/null +++ b/tests/libtest/testutil.c @@ -0,0 +1,106 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, Daniel Stenberg, , 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. + * + * $Id$ + ***************************************************************************/ + +#include "testutil.h" + +#ifndef HAVE_GETTIMEOFDAY + +#ifdef WIN32 +#include + +static int gettimeofday(struct timeval *tp, void *nothing) +{ +#ifdef WITHOUT_MM_LIB + SYSTEMTIME st; + time_t tt; + struct tm tmtm; + /* mktime converts local to UTC */ + GetLocalTime (&st); + tmtm.tm_sec = st.wSecond; + tmtm.tm_min = st.wMinute; + tmtm.tm_hour = st.wHour; + tmtm.tm_mday = st.wDay; + tmtm.tm_mon = st.wMonth - 1; + tmtm.tm_year = st.wYear - 1900; + tmtm.tm_isdst = -1; + tt = mktime (&tmtm); + tp->tv_sec = tt; + tp->tv_usec = st.wMilliseconds * 1000; +#else + /** + ** The earlier time calculations using GetLocalTime + ** had a time resolution of 10ms.The timeGetTime, part + ** of multimedia apis offer a better time resolution + ** of 1ms.Need to link against winmm.lib for this + **/ + unsigned long Ticks = 0; + unsigned long Sec =0; + unsigned long Usec = 0; + Ticks = timeGetTime(); + + Sec = Ticks/1000; + Usec = (Ticks - (Sec*1000))*1000; + tp->tv_sec = Sec; + tp->tv_usec = Usec; +#endif /* WITHOUT_MM_LIB */ + (void)nothing; + return 0; +} +#else /* WIN32 */ +/* non-win32 version of Curl_gettimeofday() */ +static int gettimeofday(struct timeval *tp, void *nothing) +{ + (void)nothing; /* we don't support specific time-zones */ + tp->tv_sec = (long)time(NULL); + tp->tv_usec = 0; + return 0; +} +#endif /* WIN32 */ +#endif /* HAVE_GETTIMEOFDAY */ + +/* Return the current time in a timeval struct */ +struct timeval tutil_tvnow(void) +{ + struct timeval now; + (void)gettimeofday(&now, NULL); + return now; +} + +/* + * Make sure that the first argument is the more recent time, as otherwise + * we'll get a weird negative time-diff back... + * + * Returns: the time difference in number of milliseconds. + */ +long tutil_tvdiff(struct timeval newer, struct timeval older) +{ + return (newer.tv_sec-older.tv_sec)*1000+ + (newer.tv_usec-older.tv_usec)/1000; +} + +/* return the number of seconds in the given input timeval struct */ +long tutil_tvlong(struct timeval t1) +{ + return t1.tv_sec; +} + diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h new file mode 100644 index 000000000..31e00ffe5 --- /dev/null +++ b/tests/libtest/testutil.h @@ -0,0 +1,60 @@ +#ifndef __LIBTEST_TESTUTIL_H +#define __LIBTEST_TESTUTIL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, Daniel Stenberg, , 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. + * + * $Id$ + ***************************************************************************/ + +#include "setup.h" + +#ifdef HAVE_SYS_TIME_H +#include +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#else +#ifdef HAVE_TIME_H +#include +#endif +#endif + +#ifndef HAVE_STRUCT_TIMEVAL +struct timeval { + long tv_sec; + long tv_usec; +}; +#endif + +struct timeval tutil_tvnow(void); + +/* + * Make sure that the first argument (t1) is the more recent time and t2 is + * the older time, as otherwise you get a weird negative time-diff back... + * + * Returns: the time difference in number of milliseconds. + */ +long tutil_tvdiff(struct timeval t1, struct timeval t2); + +long tutil_tvlong(struct timeval t1); + + +#endif /* __LIBTEST_TESTUTIL_H */ + -- cgit v1.2.1 From 8c9233f6b2577b6d2a314d83bc2e30fc1dee2cea Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 9 Feb 2007 12:41:57 +0000 Subject: Include both testutil.c and testutil.h, and not just testutil.c, in the list of source files for those tests that use it. Otherwise testutil.h might not be found by the compiler. --- tests/libtest/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 61f8f399b..0509c0796 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -37,8 +37,8 @@ LIBDIR = $(top_builddir)/lib EXTRA_DIST = test307.pl -# Source code file used only in some libcurl test programs -TESTUTIL = testutil.c +# files used only in some libcurl test programs +TESTUTIL = testutil.c testutil.h # these files are used in every single test program below SUPPORTFILES = first.c test.h -- cgit v1.2.1 From 4894ce16fc7af89d876e2f70db4dded7e1663198 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 16 Feb 2007 16:01:19 +0000 Subject: use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling --- tests/libtest/lib518.c | 26 ++++++-------------------- tests/libtest/lib537.c | 26 ++++++-------------------- tests/libtest/test.h | 3 +-- 3 files changed, 13 insertions(+), 42 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 368b902ae..413168c60 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -46,20 +46,6 @@ static int *fd = NULL; static struct rlimit num_open; static char msgbuff[256]; -/* - * our_errno() returns the NOT *socket-related* errno (or equivalent) - * on this platform to hide platform specific for the calling function. - */ - -static int our_errno(void) -{ -#ifdef WIN32 - return (int)GetLastError(); -#else - return errno; -#endif -} - static void store_errmsg(const char *msg, int err) { if (!err) @@ -102,7 +88,7 @@ static int rlimit(int keep_open) /* get initial open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", our_errno()); + store_errmsg("getrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -1; } @@ -145,7 +131,7 @@ static int rlimit(int keep_open) fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("setrlimit() failed", our_errno()); + store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -2; } @@ -153,7 +139,7 @@ static int rlimit(int keep_open) /* get current open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", our_errno()); + store_errmsg("getrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -3; } @@ -233,7 +219,7 @@ static int rlimit(int keep_open) } } while (nitems && !memchunk); if (!memchunk) { - store_errmsg("memchunk, malloc() failed", our_errno()); + store_errmsg("memchunk, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -5; } @@ -268,7 +254,7 @@ static int rlimit(int keep_open) fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); if (!fd) { - store_errmsg("fd, malloc() failed", our_errno()); + store_errmsg("fd, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -7; @@ -291,7 +277,7 @@ static int rlimit(int keep_open) fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] < 0) { sprintf(strbuff, "opening of %s failed", DEV_NULL); - store_errmsg(strbuff, our_errno()); + store_errmsg(strbuff, ERRNO); fprintf(stderr, "%s\n", msgbuff); free(fd); fd = NULL; diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index fb2482083..85635043b 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -48,20 +48,6 @@ static int *fd = NULL; static struct rlimit num_open; static char msgbuff[256]; -/* - * our_errno() returns the NOT *socket-related* errno (or equivalent) - * on this platform to hide platform specific for the calling function. - */ - -static int our_errno(void) -{ -#ifdef WIN32 - return (int)GetLastError(); -#else - return errno; -#endif -} - static void store_errmsg(const char *msg, int err) { if (!err) @@ -104,7 +90,7 @@ static int rlimit(int keep_open) /* get initial open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", our_errno()); + store_errmsg("getrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -1; } @@ -141,7 +127,7 @@ static int rlimit(int keep_open) fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("setrlimit() failed", our_errno()); + store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -2; } @@ -149,7 +135,7 @@ static int rlimit(int keep_open) /* get current open file limits */ if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { - store_errmsg("getrlimit() failed", our_errno()); + store_errmsg("getrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -3; } @@ -208,7 +194,7 @@ static int rlimit(int keep_open) } } while (nitems && !memchunk); if (!memchunk) { - store_errmsg("memchunk, malloc() failed", our_errno()); + store_errmsg("memchunk, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -4; } @@ -263,7 +249,7 @@ static int rlimit(int keep_open) } } while (num_open.rlim_max && !fd); if (!fd) { - store_errmsg("fd, malloc() failed", our_errno()); + store_errmsg("fd, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -6; @@ -286,7 +272,7 @@ static int rlimit(int keep_open) fd[0] = open(DEV_NULL, O_RDONLY); if (fd[0] < 0) { sprintf(strbuff, "opening of %s failed", DEV_NULL); - store_errmsg(strbuff, our_errno()); + store_errmsg(strbuff, ERRNO); fprintf(stderr, "%s\n", msgbuff); free(fd); fd = NULL; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index fa32d6d88..5e298abbd 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -8,18 +8,17 @@ * $Id$ */ -#ifdef HAVE_CONFIG_H /* Now include the setup.h file from libcurl's private libdir (the source version, but that might include "config.h" from the build dir so we need both of them in the include path), so that we get good in-depth knowledge about the system we're building this on */ #include "setup.h" -#endif #include #include #include #include +#include #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From 4dc453c08796da93eaa82a0af36029c265893300 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 16 Feb 2007 19:17:05 +0000 Subject: add debug messages for fopen() failures --- tests/libtest/lib505.c | 8 ++++++++ tests/libtest/lib525.c | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 85ce38b32..098e8f9e0 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -43,6 +43,7 @@ int test(char *URL) int hd ; struct_stat file_info; struct curl_slist *hl; + int error; struct curl_slist *headerlist=NULL; const char *buf_1 = "RNFR 505"; @@ -57,6 +58,9 @@ int test(char *URL) hd = stat(arg2, &file_info); if(hd == -1) { /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "stat() failed with error: %d %s\n", + error, strerror(error)); fprintf(stderr, "WARNING: cannot open file %s\n", arg2); return -1; } @@ -71,6 +75,10 @@ int test(char *URL) an example! */ hd_src = fopen(arg2, "rb"); if(NULL == hd_src) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: %s\n", arg2); return -2; /* if this happens things are major weird */ } diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index ce12b3b84..14e0c0c76 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -25,6 +25,7 @@ int test(char *URL) CURL *curl; FILE *hd_src ; int hd ; + int error; struct_stat file_info; int running; char done=FALSE; @@ -48,6 +49,13 @@ int test(char *URL) fdopen() from the previous descriptor, but hey this is just an example! */ hd_src = fopen(arg2, "rb"); + if(NULL == hd_src) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: %s\n", arg2); + return TEST_ERR_MAJOR_BAD; + } if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); -- cgit v1.2.1 From 789fd0b74aa9170124ab8604d7dfbf39fa589e7a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 17 Feb 2007 11:43:52 +0000 Subject: Replicate the configure tests that determined that timeval was available. --- tests/libtest/testutil.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 31e00ffe5..18bd9e99c 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -25,6 +25,9 @@ #include "setup.h" +#ifdef HAVE_SYS_TYPES_H +#include +#endif #ifdef HAVE_SYS_TIME_H #include #ifdef TIME_WITH_SYS_TIME -- cgit v1.2.1 From 75fca27f8e6ae1147c81c8b8f4e12486a4abb2a4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 19 Feb 2007 04:51:47 +0000 Subject: log a message, stating the need of openssl to run this test --- tests/libtest/lib509.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 8f2210f5f..ad2626204 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -332,10 +332,19 @@ int test(char *URL) return i; } + #else /* USE_SSLEAY */ + int test(char *URL) { (void)URL; - return CURLE_FAILED_INIT; + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + fprintf(stderr, "libcurl lacks openssl support needed for test 509\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; } + #endif /* USE_SSLEAY */ -- cgit v1.2.1 From da8c666e4fae66d58ce8bfb6cf48f91ec47f38c6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 20 Feb 2007 01:09:38 +0000 Subject: add tutil_tvdiff_secs() for completeness --- tests/libtest/testutil.c | 11 +++++++++++ tests/libtest/testutil.h | 7 +++++++ 2 files changed, 18 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 6acd5a71b..dc0211026 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -98,6 +98,17 @@ long tutil_tvdiff(struct timeval newer, struct timeval older) (newer.tv_usec-older.tv_usec)/1000; } +/* + * Same as tutil_tvdiff but with full usec resolution. + * + * Returns: the time difference in seconds with subsecond resolution. + */ +double tutil_tvdiff_secs(struct timeval newer, struct timeval older) +{ + return (double)(newer.tv_sec-older.tv_sec)+ + (double)(newer.tv_usec-older.tv_usec)/1000000.0; +} + /* return the number of seconds in the given input timeval struct */ long tutil_tvlong(struct timeval t1) { diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 18bd9e99c..e248c1ebe 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -56,6 +56,13 @@ struct timeval tutil_tvnow(void); */ long tutil_tvdiff(struct timeval t1, struct timeval t2); +/* + * Same as tutil_tvdiff but with full usec resolution. + * + * Returns: the time difference in seconds with subsecond resolution. + */ +double tutil_tvdiff_secs(struct timeval t1, struct timeval t2); + long tutil_tvlong(struct timeval t1); -- cgit v1.2.1 From 29bb6f65f1ac786b189ca6e860b463c5142bc486 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 20 Feb 2007 12:12:27 +0000 Subject: Move header file inclusion logic and definition of timeval struct for platforms that don't have it to setup_once.h --- tests/libtest/testutil.c | 2 ++ tests/libtest/testutil.h | 20 -------------------- 2 files changed, 2 insertions(+), 20 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index dc0211026..146660c71 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -21,6 +21,8 @@ * $Id$ ***************************************************************************/ +#include "setup.h" + #include "testutil.h" #ifndef HAVE_GETTIMEOFDAY diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index e248c1ebe..6f7839d24 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -25,26 +25,6 @@ #include "setup.h" -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_TIME_H -#include -#ifdef TIME_WITH_SYS_TIME -#include -#endif -#else -#ifdef HAVE_TIME_H -#include -#endif -#endif - -#ifndef HAVE_STRUCT_TIMEVAL -struct timeval { - long tv_sec; - long tv_usec; -}; -#endif struct timeval tutil_tvnow(void); -- cgit v1.2.1 From 69565afab0be081211df57a245a222cbd3e43ed3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Feb 2007 02:51:54 +0000 Subject: Check for stdbool.h at configuration stage, and include it if available. Check for lowercase 'bool' type at configuration stage. If not available provide a suitable replacement with a type definition of 'unsigned char' in setup_once.h Move definitions of TRUE and FALSE to setup_once.h --- tests/libtest/test.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 5e298abbd..c7064f82e 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -12,6 +12,7 @@ version, but that might include "config.h" from the build dir so we need both of them in the include path), so that we get good in-depth knowledge about the system we're building this on */ + #include "setup.h" #include @@ -32,14 +33,6 @@ #include #endif -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - #define TEST_ERR_MAJOR_BAD 100 #define TEST_ERR_RUNS_FOREVER 99 -- cgit v1.2.1 From 53a3abc76b0e92aa3f658d3f8f6e75f18ace7c46 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Mar 2007 04:27:19 +0000 Subject: 30 seconds isn't long enough for this test on a loaded server. --- tests/libtest/lib530.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 96c27b951..193f2920c 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -15,8 +15,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 #define NUM_HANDLES 4 -- cgit v1.2.1 From 40087ce7c065f288c6817c894f02327c6a38c5b8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 10 Mar 2007 00:19:05 +0000 Subject: change max allowed time for this test to complete to 90 seconds --- tests/libtest/lib502.c | 3 ++- tests/libtest/lib503.c | 4 ++-- tests/libtest/lib504.c | 4 ++-- tests/libtest/lib507.c | 4 ++-- tests/libtest/lib509.c | 4 ++-- tests/libtest/lib525.c | 4 ++-- tests/libtest/lib526.c | 4 ++-- tests/libtest/lib530.c | 4 ++-- tests/libtest/lib533.c | 4 ++-- tests/libtest/lib536.c | 4 ++-- 10 files changed, 20 insertions(+), 19 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index d995b45ec..ea53795c0 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -12,7 +12,8 @@ #include "testutil.h" -#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 /* * Get a single URL without select(). diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index bcf4f57be..8294e8ccb 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -14,8 +14,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 /* * Source code in here hugely as reported in bug report 651460 by diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 499b9e985..6bfbe4dde 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -14,8 +14,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 /* * Source code in here hugely as reported in bug report 651464 by diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index d17526463..0137130ce 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -12,8 +12,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 int test(char *URL) { diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index ad2626204..03963b39f 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -29,8 +29,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 /* * We use this ZERO_NULL to avoid picky compiler warnings, diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 14e0c0c76..b60328ba1 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -16,8 +16,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 int test(char *URL) { diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 1cfa6d00e..ba3fff7bd 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -35,8 +35,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 #define NUM_HANDLES 4 diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 193f2920c..e339ab2cf 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -15,8 +15,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 #define NUM_HANDLES 4 diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 0cb227529..ee5f78f28 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -18,8 +18,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 int test(char *URL) { diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 3f41b00db..7ab2aa3f0 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -16,8 +16,8 @@ #include "testutil.h" -#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 static CURLMcode perform(CURLM * multi); -- cgit v1.2.1 From c1f3edbdd1bfd08054e260c780ee8a0e3f90fadf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Mar 2007 22:44:46 +0000 Subject: openssl/bio.h doesn't exist when we build with yassl so avoid trying --- tests/libtest/lib509.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 03963b39f..34749e2d3 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -15,6 +15,10 @@ #include #include +#include + +#ifndef YASSL_VERSION + #include #include #include @@ -25,7 +29,6 @@ #include #include #include -#include #include "testutil.h" @@ -332,7 +335,7 @@ int test(char *URL) return i; } - +#endif /* YASSL_VERSION */ #else /* USE_SSLEAY */ int test(char *URL) -- cgit v1.2.1 From 7bbad0b534f95c83284278aa06e6fa4d28a3c5c1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 3 Apr 2007 02:57:54 +0000 Subject: try not to link with unneeded libs, avoiding global LDADD --- tests/libtest/Makefile.am | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 0509c0796..35709b8ec 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -50,110 +50,143 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 # Dependencies (may need to be overriden) -LDADD = $(LIBDIR)/libcurl.la +LIBTEST_LIBS = $(LIBDIR)/libcurl.la DEPENDENCIES = $(LIBDIR)/libcurl.la lib500_SOURCES = lib500.c $(SUPPORTFILES) lib500_DEPENDENCIES = $(DEPENDENCIES) +lib500_LDADD = $(LIBTEST_LIBS) lib501_SOURCES = lib501.c $(SUPPORTFILES) lib501_DEPENDENCIES = $(DEPENDENCIES) +lib501_LDADD = $(LIBTEST_LIBS) lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) lib502_DEPENDENCIES = $(DEPENDENCIES) +lib502_LDADD = $(LIBTEST_LIBS) lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) lib503_DEPENDENCIES = $(DEPENDENCIES) +lib503_LDADD = $(LIBTEST_LIBS) lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) lib504_DEPENDENCIES = $(DEPENDENCIES) +lib504_LDADD = $(LIBTEST_LIBS) lib505_SOURCES = lib505.c $(SUPPORTFILES) lib505_DEPENDENCIES = $(DEPENDENCIES) +lib505_LDADD = $(LIBTEST_LIBS) lib506_SOURCES = lib506.c $(SUPPORTFILES) lib506_DEPENDENCIES = $(DEPENDENCIES) +lib506_LDADD = $(LIBTEST_LIBS) lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) lib507_DEPENDENCIES = $(DEPENDENCIES) +lib507_LDADD = $(LIBTEST_LIBS) lib508_SOURCES = lib508.c $(SUPPORTFILES) lib508_DEPENDENCIES = $(DEPENDENCIES) +lib508_LDADD = $(LIBTEST_LIBS) lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TESTUTIL) lib509_DEPENDENCIES = $(DEPENDENCIES) +lib509_LDADD = $(LIBTEST_LIBS) lib510_SOURCES = lib510.c $(SUPPORTFILES) lib510_DEPENDENCIES = $(DEPENDENCIES) +lib510_LDADD = $(LIBTEST_LIBS) lib511_SOURCES = lib511.c $(SUPPORTFILES) lib511_DEPENDENCIES = $(DEPENDENCIES) +lib511_LDADD = $(LIBTEST_LIBS) lib512_SOURCES = lib512.c $(SUPPORTFILES) lib512_DEPENDENCIES = $(DEPENDENCIES) +lib512_LDADD = $(LIBTEST_LIBS) lib513_SOURCES = lib513.c $(SUPPORTFILES) lib513_DEPENDENCIES = $(DEPENDENCIES) +lib513_LDADD = $(LIBTEST_LIBS) lib514_SOURCES = lib514.c $(SUPPORTFILES) lib514_DEPENDENCIES = $(DEPENDENCIES) +lib514_LDADD = $(LIBTEST_LIBS) lib515_SOURCES = lib515.c $(SUPPORTFILES) lib515_DEPENDENCIES = $(DEPENDENCIES) +lib515_LDADD = $(LIBTEST_LIBS) lib516_SOURCES = lib516.c $(SUPPORTFILES) lib516_DEPENDENCIES = $(DEPENDENCIES) +lib516_LDADD = $(LIBTEST_LIBS) lib517_SOURCES = lib517.c $(SUPPORTFILES) lib517_DEPENDENCIES = $(DEPENDENCIES) +lib517_LDADD = $(LIBTEST_LIBS) lib518_SOURCES = lib518.c $(SUPPORTFILES) lib518_DEPENDENCIES = $(DEPENDENCIES) +lib518_LDADD = $(LIBTEST_LIBS) lib519_SOURCES = lib519.c $(SUPPORTFILES) lib519_DEPENDENCIES = $(DEPENDENCIES) +lib519_LDADD = $(LIBTEST_LIBS) lib520_SOURCES = lib520.c $(SUPPORTFILES) lib520_DEPENDENCIES = $(DEPENDENCIES) +lib520_LDADD = $(LIBTEST_LIBS) lib521_SOURCES = lib521.c $(SUPPORTFILES) lib521_DEPENDENCIES = $(DEPENDENCIES) +lib521_LDADD = $(LIBTEST_LIBS) lib523_SOURCES = lib523.c $(SUPPORTFILES) lib523_DEPENDENCIES = $(DEPENDENCIES) +lib523_LDADD = $(LIBTEST_LIBS) lib524_SOURCES = lib524.c $(SUPPORTFILES) lib524_DEPENDENCIES = $(DEPENDENCIES) +lib524_LDADD = $(LIBTEST_LIBS) lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib525_DEPENDENCIES = $(DEPENDENCIES) +lib525_LDADD = $(LIBTEST_LIBS) lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib526_CFLAGS = -DLIB526 lib526_DEPENDENCIES = $(DEPENDENCIES) +lib526_LDADD = $(LIBTEST_LIBS) lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib527_CFLAGS = -DLIB527 lib527_DEPENDENCIES = $(DEPENDENCIES) +lib527_LDADD = $(LIBTEST_LIBS) lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib529_CFLAGS = -DLIB529 lib529_DEPENDENCIES = $(DEPENDENCIES) +lib529_LDADD = $(LIBTEST_LIBS) lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) lib530_CFLAGS = -DLIB530 lib530_DEPENDENCIES = $(DEPENDENCIES) +lib530_LDADD = $(LIBTEST_LIBS) lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib532_CFLAGS = -DLIB532 lib532_DEPENDENCIES = $(DEPENDENCIES) +lib532_LDADD = $(LIBTEST_LIBS) lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) lib533_DEPENDENCIES = $(DEPENDENCIES) +lib533_LDADD = $(LIBTEST_LIBS) lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) lib536_DEPENDENCIES = $(DEPENDENCIES) +lib536_LDADD = $(LIBTEST_LIBS) lib537_SOURCES = lib537.c $(SUPPORTFILES) lib537_DEPENDENCIES = $(DEPENDENCIES) +lib537_LDADD = $(LIBTEST_LIBS) -- cgit v1.2.1 From 2886ce96b07f49f77bf9dbb34d8ef475ed09a300 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 3 Apr 2007 18:02:02 +0000 Subject: Verify if the test is limited by an ancient stdio with a 256 open file limit. In this case the test is skipped with a message showing this limitation when the number of open files needed for the test is greater than 256. --- tests/libtest/lib518.c | 35 +++++++++++++++++++++++++++++++++++ tests/libtest/lib537.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 413168c60..2c59ff0a7 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -65,6 +65,29 @@ static void close_file_descriptors(void) fd = NULL; } +static int stdio_limit_256(void) +{ + FILE *fpa[300]; + int i; + int ret = 0; + + for (i = 0; i < 300; i++) { + fpa[i] = NULL; + } + for (i = 0; i < 300; i++) { + fpa[i] = fopen(DEV_NULL, "r"); + if (fpa[i] == NULL) { + ret = -1; + break; + } + } + for (i = 0; i < 300; i++) { + if (fpa[i] != NULL) + fclose(fpa[i]); + } + return ret; +} + static int rlimit(int keep_open) { int nitems, i; @@ -235,6 +258,18 @@ static int rlimit(int keep_open) num_open.rlim_max = NUM_OPEN; + /* verify that we don't have an ancient stdio */ + + if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { + sprintf(strbuff1, fmt, num_open.rlim_max); + sprintf(strbuff, "fds needed %s > stdio limit 256", + strbuff1); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + free(memchunk); + return -12; + } + /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 85635043b..0ddd3a77c 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -67,6 +67,29 @@ static void close_file_descriptors(void) fd = NULL; } +static int stdio_limit_256(void) +{ + FILE *fpa[300]; + int i; + int ret = 0; + + for (i = 0; i < 300; i++) { + fpa[i] = NULL; + } + for (i = 0; i < 300; i++) { + fpa[i] = fopen(DEV_NULL, "r"); + if (fpa[i] == NULL) { + ret = -1; + break; + } + } + for (i = 0; i < 300; i++) { + if (fpa[i] != NULL) + fclose(fpa[i]); + } + return ret; +} + static int rlimit(int keep_open) { int *tmpfd; @@ -225,6 +248,18 @@ static int rlimit(int keep_open) num_open.rlim_max = nitems; } + /* verify that we don't have an ancient stdio */ + + if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { + sprintf(strbuff1, fmt, num_open.rlim_max); + sprintf(strbuff, "fds needed %s > stdio limit 256", + strbuff1); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + free(memchunk); + return -10; + } + /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { -- cgit v1.2.1 From ec8019b2a84e9bf304e78518124ae7fd9557698a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2007 03:19:59 +0000 Subject: test can be allowed to run if fopen() is capable of fopen()ing SAFETY_MARGIN additional files once that we have already open()ed the big bunch of file descriptors. --- tests/libtest/lib518.c | 39 ++++++++++++++++++++------------------- tests/libtest/lib537.c | 39 ++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 38 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 2c59ff0a7..24b7a8732 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -65,23 +65,23 @@ static void close_file_descriptors(void) fd = NULL; } -static int stdio_limit_256(void) +static int fopen_works(void) { - FILE *fpa[300]; + FILE *fpa[SAFETY_MARGIN]; int i; - int ret = 0; + int ret = 1; - for (i = 0; i < 300; i++) { + for (i = 0; i < SAFETY_MARGIN; i++) { fpa[i] = NULL; } - for (i = 0; i < 300; i++) { + for (i = 0; i < SAFETY_MARGIN; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { - ret = -1; + ret = 0; break; } } - for (i = 0; i < 300; i++) { + for (i = 0; i < SAFETY_MARGIN; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } @@ -258,18 +258,6 @@ static int rlimit(int keep_open) num_open.rlim_max = NUM_OPEN; - /* verify that we don't have an ancient stdio */ - - if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { - sprintf(strbuff1, fmt, num_open.rlim_max); - sprintf(strbuff, "fds needed %s > stdio limit 256", - strbuff1); - store_errmsg(strbuff, 0); - fprintf(stderr, "%s\n", msgbuff); - free(memchunk); - return -12; - } - /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { @@ -407,6 +395,19 @@ static int rlimit(int keep_open) #endif /* using a FD_SETSIZE bound select() */ + /* test stdio's capability to fopen() SAFETY_MARGIN additional files */ + + if (!fopen_works()) { + sprintf(strbuff1, fmt, num_open.rlim_max); + sprintf(strbuff, "stdio fopen() fails with %s open() files", + strbuff1); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -12; + } + /* free the chunk of memory we were reserving so that it becomes becomes available to the test */ diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 0ddd3a77c..142686c8f 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -67,23 +67,23 @@ static void close_file_descriptors(void) fd = NULL; } -static int stdio_limit_256(void) +static int fopen_works(void) { - FILE *fpa[300]; + FILE *fpa[SAFETY_MARGIN]; int i; - int ret = 0; + int ret = 1; - for (i = 0; i < 300; i++) { + for (i = 0; i < SAFETY_MARGIN; i++) { fpa[i] = NULL; } - for (i = 0; i < 300; i++) { + for (i = 0; i < SAFETY_MARGIN; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { - ret = -1; + ret = 0; break; } } - for (i = 0; i < 300; i++) { + for (i = 0; i < SAFETY_MARGIN; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } @@ -248,18 +248,6 @@ static int rlimit(int keep_open) num_open.rlim_max = nitems; } - /* verify that we don't have an ancient stdio */ - - if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { - sprintf(strbuff1, fmt, num_open.rlim_max); - sprintf(strbuff, "fds needed %s > stdio limit 256", - strbuff1); - store_errmsg(strbuff, 0); - fprintf(stderr, "%s\n", msgbuff); - free(memchunk); - return -10; - } - /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { @@ -411,6 +399,19 @@ static int rlimit(int keep_open) #endif /* using a FD_SETSIZE bound select() */ + /* test stdio's capability to fopen() SAFETY_MARGIN additional files */ + + if (!fopen_works()) { + sprintf(strbuff1, fmt, num_open.rlim_max); + sprintf(strbuff, "stdio fopen() fails with %s open() files", + strbuff1); + store_errmsg(strbuff, 0); + fprintf(stderr, "%s\n", msgbuff); + close_file_descriptors(); + free(memchunk); + return -10; + } + /* free the chunk of memory we were reserving so that it becomes becomes available to the test */ -- cgit v1.2.1 From a1f72943e96172b4598bf3cb5993c554d1294b8c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2007 05:04:47 +0000 Subject: cleanup --- tests/libtest/lib518.c | 1 - tests/libtest/lib537.c | 2 -- 2 files changed, 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 24b7a8732..30de15ef3 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -354,7 +354,6 @@ static int rlimit(int keep_open) fprintf(stderr, "%s file descriptors open\n", strbuff); #if !defined(HAVE_POLL_FINE) && \ - !defined(CURL_HAVE_WSAPOLL) && \ !defined(USE_WINSOCK) && \ !defined(TPF) diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 142686c8f..29de30818 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -27,7 +27,6 @@ #endif #if !defined(HAVE_POLL_FINE) && \ - !defined(CURL_HAVE_WSAPOLL) && \ !defined(USE_WINSOCK) && \ !defined(TPF) && \ !defined(FD_SETSIZE) @@ -358,7 +357,6 @@ static int rlimit(int keep_open) fprintf(stderr, "%s file descriptors open\n", strbuff); #if !defined(HAVE_POLL_FINE) && \ - !defined(CURL_HAVE_WSAPOLL) && \ !defined(USE_WINSOCK) && \ !defined(TPF) -- cgit v1.2.1 From 8a529bd98764f023680d750d76e138bc644e50a6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2007 06:39:03 +0000 Subject: test can be allowed to run if fopen() is capable of fopen()ing three additional files once that we have already open()ed the big bunch of file descriptors. --- tests/libtest/lib518.c | 8 ++++---- tests/libtest/lib537.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 30de15ef3..1997b2f9e 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -67,21 +67,21 @@ static void close_file_descriptors(void) static int fopen_works(void) { - FILE *fpa[SAFETY_MARGIN]; + FILE *fpa[3]; int i; int ret = 1; - for (i = 0; i < SAFETY_MARGIN; i++) { + for (i = 0; i < 3; i++) { fpa[i] = NULL; } - for (i = 0; i < SAFETY_MARGIN; i++) { + for (i = 0; i < 3; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { ret = 0; break; } } - for (i = 0; i < SAFETY_MARGIN; i++) { + for (i = 0; i < 3; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 29de30818..d59957430 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -68,21 +68,21 @@ static void close_file_descriptors(void) static int fopen_works(void) { - FILE *fpa[SAFETY_MARGIN]; + FILE *fpa[3]; int i; int ret = 1; - for (i = 0; i < SAFETY_MARGIN; i++) { + for (i = 0; i < 3; i++) { fpa[i] = NULL; } - for (i = 0; i < SAFETY_MARGIN; i++) { + for (i = 0; i < 3; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { ret = 0; break; } } - for (i = 0; i < SAFETY_MARGIN; i++) { + for (i = 0; i < 3; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } -- cgit v1.2.1 From 5625e5d5b87cf4037705fc03df9e6c9f4bcdf0a1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2007 08:58:36 +0000 Subject: add debug message and expand comment --- tests/libtest/lib518.c | 13 +++++++++++-- tests/libtest/lib537.c | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 1997b2f9e..b2aa0554c 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -77,6 +77,8 @@ static int fopen_works(void) for (i = 0; i < 3; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { + store_errmsg("fopen() failed", ERRNO); + fprintf(stderr, "%s\n", msgbuff); ret = 0; break; } @@ -394,11 +396,18 @@ static int rlimit(int keep_open) #endif /* using a FD_SETSIZE bound select() */ - /* test stdio's capability to fopen() SAFETY_MARGIN additional files */ + /* + * Old or 'backwards compatible' implementations of stdio do not allow + * handling of streams with an underlying file descriptor number greater + * than 255, even when allowing high numbered file descriptors for sockets. + * At this point we have a big number of file descriptors which have been + * opened using dup(), so lets test the stdio implementation and discover + * if it is capable of fopen()ing some additional files. + */ if (!fopen_works()) { sprintf(strbuff1, fmt, num_open.rlim_max); - sprintf(strbuff, "stdio fopen() fails with %s open() files", + sprintf(strbuff, "stdio fopen() fails with %s fds open()", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index d59957430..eecda4626 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -78,6 +78,8 @@ static int fopen_works(void) for (i = 0; i < 3; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { + store_errmsg("fopen() failed", ERRNO); + fprintf(stderr, "%s\n", msgbuff); ret = 0; break; } @@ -397,11 +399,18 @@ static int rlimit(int keep_open) #endif /* using a FD_SETSIZE bound select() */ - /* test stdio's capability to fopen() SAFETY_MARGIN additional files */ + /* + * Old or 'backwards compatible' implementations of stdio do not allow + * handling of streams with an underlying file descriptor number greater + * than 255, even when allowing high numbered file descriptors for sockets. + * At this point we have a big number of file descriptors which have been + * opened using dup(), so lets test the stdio implementation and discover + * if it is capable of fopen()ing some additional files. + */ if (!fopen_works()) { sprintf(strbuff1, fmt, num_open.rlim_max); - sprintf(strbuff, "stdio fopen() fails with %s open() files", + sprintf(strbuff, "stdio fopen() fails with %s fds open()", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); -- cgit v1.2.1 From a0a79ce8533b7cf722bf1c91f0fd411f456d4568 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 5 Apr 2007 11:05:36 +0000 Subject: unify fopen() failure error message among tests, allowing the testsuite to count them as errors of the same kind --- tests/libtest/lib518.c | 3 ++- tests/libtest/lib537.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index b2aa0554c..756f301d9 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -409,8 +409,9 @@ static int rlimit(int keep_open) sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "stdio fopen() fails with %s fds open()", strbuff1); - store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); + sprintf(strbuff, "stdio fopen() fails with lots of fds open()"); + store_errmsg(strbuff, 0); close_file_descriptors(); free(memchunk); return -12; diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index eecda4626..a074bf994 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -412,8 +412,9 @@ static int rlimit(int keep_open) sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "stdio fopen() fails with %s fds open()", strbuff1); - store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); + sprintf(strbuff, "stdio fopen() fails with lots of fds open()"); + store_errmsg(strbuff, 0); close_file_descriptors(); free(memchunk); return -10; -- cgit v1.2.1 From 6a35841b2edcbd865e914ec33ea0568199a26a8a Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 23 Apr 2007 23:00:38 +0000 Subject: Added tests 610-612 to test more SFTP post-quote commands. --- tests/libtest/test610.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tests/libtest/test610.pl (limited to 'tests/libtest') diff --git a/tests/libtest/test610.pl b/tests/libtest/test610.pl new file mode 100755 index 000000000..5d7c1f6aa --- /dev/null +++ b/tests/libtest/test610.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +# Create and remove directories and check their existence +if ( $#ARGV != 1 ) +{ + print "Usage: $0 mkdir|rmdir|gone path\n"; + exit 1; +} +if ($ARGV[0] eq "mkdir") +{ + mkdir $ARGV[1] || die "$!"; + exit 0; +} +elsif ($ARGV[0] eq "rmdir") +{ + rmdir $ARGV[1] || die "$!"; + exit 0; +} +elsif ($ARGV[0] eq "gone") +{ + ! -e $ARGV[1] || die "Path $ARGV[1] exists"; + exit 0; +} +print "Unsupported command $ARGV[0]\n"; +exit 1; -- cgit v1.2.1 From 5187faeeb97321343cd0a1f3ad9aa10992513e99 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 30 Apr 2007 20:15:33 +0000 Subject: Improved the test harness to allow running test servers on other than the default port numbers, allowing more than one test suite to run simultaneously on the same host. --- tests/libtest/Makefile.am | 2 +- tests/libtest/test75.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 tests/libtest/test75.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 35709b8ec..276ec85eb 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test307.pl +EXTRA_DIST = test75.pl test307.pl test610.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h diff --git a/tests/libtest/test75.pl b/tests/libtest/test75.pl new file mode 100755 index 000000000..01a53ff15 --- /dev/null +++ b/tests/libtest/test75.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl +# Check that the length of a given URL is correct +if ( $#ARGV != 1 ) +{ + print "Usage: $0 string length\n"; + exit 3; +} +if (length(@ARGV[0]) != @ARGV[1]) +{ + print "Given host IP and port not supported\n"; + exit 1; +} +exit 0; -- cgit v1.2.1 From 6c8e6549d0d22716c0138a7e25c85b8cb3f2b0ac Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 2 May 2007 06:02:13 +0000 Subject: Check the return code from curl_multi_add_handle() --- tests/libtest/lib536.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 7ab2aa3f0..6b0a6a223 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -19,8 +19,6 @@ #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 -static CURLMcode perform(CURLM * multi); - static CURLMcode perform(CURLM * multi) { int handles, maxfd; @@ -72,6 +70,7 @@ int test(char *URL) { CURLM *multi; CURL *easy; + int res = 0; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -97,26 +96,34 @@ int test(char *URL) curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); curl_easy_setopt(easy, CURLOPT_URL, URL); - curl_multi_add_handle(multi, easy); - if (perform(multi) != CURLM_OK) - printf("retrieve 1 failed\n"); + 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"); - curl_multi_remove_handle(multi, easy); + curl_multi_remove_handle(multi, easy); + } curl_easy_reset(easy); curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); curl_easy_setopt(easy, CURLOPT_URL, arg2); - curl_multi_add_handle(multi, easy); - if (perform(multi) != CURLM_OK) - printf("retrieve 2 failed\n"); + if (curl_multi_add_handle(multi, easy) != CURLM_OK) { + printf("curl_multi_add_handle() 2 failed\n"); + res = TEST_ERR_MAJOR_BAD; + } else { + if (perform(multi) != CURLM_OK) + printf("retrieve 2 failed\n"); - curl_multi_remove_handle(multi, easy); + curl_multi_remove_handle(multi, easy); + } curl_easy_cleanup(easy); curl_multi_cleanup(multi); curl_global_cleanup(); printf("Finished!\n"); - return 0; + return res; } -- cgit v1.2.1 From b0a4c992e73539b2a895ba2df5b7defd19d2629f Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 14 May 2007 22:03:42 +0000 Subject: Added SFTP directory listing test case 613. --- tests/libtest/Makefile.am | 2 +- tests/libtest/test613.pl | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 tests/libtest/test613.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 276ec85eb..b50b0ea21 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test75.pl test307.pl test610.pl +EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl new file mode 100755 index 000000000..282cf3791 --- /dev/null +++ b/tests/libtest/test613.pl @@ -0,0 +1,84 @@ +#!/usr/bin/env perl +# Prepare a directory with known files and clean up afterwards +use Time::Local; + +if ( $#ARGV < 1 ) +{ + print "Usage: $0 prepare|postprocess dir [logfile]\n"; + exit 1; +} + +# expects an error message on stdout +sub errout { + print $_[0] . "\n"; + exit 1; +} + +if ($ARGV[0] eq "prepare") +{ + my $dirname = $ARGV[1]; + mkdir $dirname || errout "$!"; + chdir $dirname; + + # Create the files in alphabetical order, to increase the chances + # of receiving a consistent set of directory contents regardless + # of whether the server alphabetizes the results or not. + mkdir "asubdir" || errout "$!"; + chmod 0777, "asubdir"; + + open(FILE, ">plainfile.txt") || errout "$!"; + binmode FILE; + print FILE "Test file to support curl test suite\n"; + close(FILE); + utime time, timegm(0,0,12,1,0,100), "plainfile.txt"; + chmod 0666, "plainfile.txt"; + + open(FILE, ">rofile.txt") || errout "$!"; + binmode FILE; + print FILE "Read-only test file to support curl test suite\n"; + close(FILE); + utime time, timegm(0,0,12,31,11,100), "rofile.txt"; + chmod 0444, "rofile.txt"; + + exit 0; +} +elsif ($ARGV[0] eq "postprocess") +{ + my $dirname = $ARGV[1]; + my $logfile = $ARGV[2]; + + # Clean up the test directory + unlink "$dirname/rofile.txt"; + unlink "$dirname/plainfile.txt"; + rmdir "$dirname/asubdir"; + + rmdir $dirname || die "$!"; + + if ($logfile) { + # Process the directory file to remove all information that could + # be inconsistent from one test run to the next (e.g. file date) + # or may be unsupported on some platforms (e.g. Windows) + + my $newfile = $logfile . ".new"; + open(OUT, ">$newfile") || die "$!"; + open(IN, "<$logfile") || die "$!"; + while () { + s/^(.)(..).(..).(..).(.{4}?).{6}?.{6}?(.{12}?)/\1\2?\3?\4?\5 U U\6/; + if ($1 eq "d") { + # Erase inodes, size, mode, time fields for directories + s/^.{14}?(.{12}?).{11}? ... .\d \d\d:\d\d/d????????? N\1 N ??? N NN:NN/; + } + print OUT $_; + } + + close(IN); + close(OUT); + + unlink $logfile; + rename $newfile, $logfile; + } + + exit 0; +} +print "Unsupported command $ARGV[0]\n"; +exit 1; -- cgit v1.2.1 From 09fd3b4935afbc6e2b564ebedb5758fed6acfa12 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 16 May 2007 17:45:53 +0000 Subject: Match file times occurring in the morning. --- tests/libtest/test613.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index 282cf3791..749763d4e 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -60,19 +60,19 @@ elsif ($ARGV[0] eq "postprocess") # or may be unsupported on some platforms (e.g. Windows) my $newfile = $logfile . ".new"; - open(OUT, ">$newfile") || die "$!"; open(IN, "<$logfile") || die "$!"; + open(OUT, ">$newfile") || die "$!"; while () { s/^(.)(..).(..).(..).(.{4}?).{6}?.{6}?(.{12}?)/\1\2?\3?\4?\5 U U\6/; if ($1 eq "d") { # Erase inodes, size, mode, time fields for directories - s/^.{14}?(.{12}?).{11}? ... .\d \d\d:\d\d/d????????? N\1 N ??? N NN:NN/; + s/^.{14}?(.{12}?).{11}? ... .\d .\d:\d\d/d????????? N\1 N ??? N NN:NN/; } print OUT $_; } - close(IN); close(OUT); + close(IN); unlink $logfile; rename $newfile, $logfile; -- cgit v1.2.1 From 5ae21ebde90b299e7617a91b0a59e639414df182 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 14 Jul 2007 22:38:18 +0000 Subject: add support for arg3 as the third argument... --- tests/libtest/first.c | 4 ++++ tests/libtest/test.h | 1 + 2 files changed, 5 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 745ed9fe5..9e585eace 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -35,6 +35,7 @@ int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, } char *arg2=NULL; +char *arg3=NULL; int main(int argc, char **argv) { @@ -67,6 +68,9 @@ int main(int argc, char **argv) if(argc>2) arg2=argv[2]; + if(argc>3) + arg3=argv[3]; + URL = argv[1]; /* provide this to the rest */ fprintf(stderr, "URL: %s\n", URL); diff --git a/tests/libtest/test.h b/tests/libtest/test.h index c7064f82e..fba51a720 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -37,6 +37,7 @@ #define TEST_ERR_RUNS_FOREVER 99 extern char *arg2; /* set by first.c to the argv[2] or NULL */ +extern char *arg3; /* set by first.c to the argv[3] or NULL */ int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv); -- cgit v1.2.1 From 15c821934011bfa0b3d7f3f93d0349adc2ab40e9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 14 Jul 2007 22:39:22 +0000 Subject: Added test case 540 and lib540.c, the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl mailing list on 10 Jul 2007, converted to a test case. --- tests/libtest/Makefile.am | 5 +- tests/libtest/lib540.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib540.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index b50b0ea21..2614ce3f3 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -47,7 +47,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 lib537 + lib529 lib530 lib532 lib533 lib536 lib537 lib540 # Dependencies (may need to be overriden) LIBTEST_LIBS = $(LIBDIR)/libcurl.la @@ -190,3 +190,6 @@ lib537_SOURCES = lib537.c $(SUPPORTFILES) lib537_DEPENDENCIES = $(DEPENDENCIES) lib537_LDADD = $(LIBTEST_LIBS) +lib540_SOURCES = lib540.c $(SUPPORTFILES) +lib540_DEPENDENCIES = $(DEPENDENCIES) +lib540_LDADD = $(LIBTEST_LIBS) diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c new file mode 100644 index 000000000..4b8e141b6 --- /dev/null +++ b/tests/libtest/lib540.c @@ -0,0 +1,119 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl + * mailing list on 10 Jul 2007, converted to a test case. + * + * argv1 = URL + * argv2 = proxy + * argv3 = proxyuser:password + */ + +#include "test.h" + +#define PROXY arg2 +#define PROXYUSERPWD arg3 + +static void init(CURLM *cm, const char* url, const char* userpwd) +{ + CURL *eh = curl_easy_init(); + + curl_easy_setopt(eh, CURLOPT_URL, url); + curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); + curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); + curl_easy_setopt(eh, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + curl_easy_setopt(eh, CURLOPT_VERBOSE, 1); + curl_easy_setopt(eh, CURLOPT_HEADER, 1); + + curl_multi_add_handle(cm, eh); +} + +static int loop(CURLM *cm, const char* url, const char* userpwd) +{ + CURLMsg *msg; + long L; + int M, Q, U = -1; + fd_set R, W, E; + struct timeval T; + + init(cm, url, userpwd); + + while (U) { + while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U)); + + 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 EXIT_FAILURE; + } + + /* 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! */ + + if (curl_multi_timeout(cm, &L)) { + fprintf(stderr, "E: curl_multi_timeout\n"); + return EXIT_FAILURE; + } + + if(L != -1) { + T.tv_sec = L/1000; + T.tv_usec = (L%1000)*1000; + } + else { + T.tv_sec = 5; + T.tv_usec = 0; + } + + if (0 > select(M+1, &R, &W, &E, &T)) { + fprintf(stderr, "E: select\n"); + return EXIT_FAILURE; + } + } + + while ((msg = curl_multi_info_read(cm, &Q))) { + if (msg->msg == CURLMSG_DONE) { + char *url; + CURL *e = msg->easy_handle; + curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url); + fprintf(stderr, "R: %d - %s <%s>\n", + msg->data.result, curl_easy_strerror(msg->data.result), url); + curl_multi_remove_handle(cm, e); + curl_easy_cleanup(e); + } + else { + fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg); + } + } + } + + return 1; +} + +int test(char *URL) +{ + CURLM *cm; + + curl_global_init(CURL_GLOBAL_ALL); + + cm = curl_multi_init(); + loop(cm, URL, PROXYUSERPWD); + + fprintf(stderr, "lib540: now we do the request again\n"); + loop(cm, URL, PROXYUSERPWD); + + curl_multi_cleanup(cm); + + curl_global_cleanup(); + + return EXIT_SUCCESS; +} -- cgit v1.2.1 From 1da3192d2d512dccea708d8f7e0b93c7dbe41e3f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 15 Jul 2007 20:59:43 +0000 Subject: let's just export the whole argc + argv pair globally so that each test tool can take advantage of it however they see fit! --- tests/libtest/first.c | 7 +++++++ tests/libtest/test.h | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 9e585eace..e2e1bfaed 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -36,6 +36,9 @@ int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, char *arg2=NULL; char *arg3=NULL; +int test_argc; +char **test_argv; + int main(int argc, char **argv) { @@ -65,6 +68,10 @@ int main(int argc, char **argv) fprintf(stderr, "Pass URL as argument please\n"); return 1; } + + test_argc = argc; + test_argv = argv; + if(argc>2) arg2=argv[2]; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index fba51a720..5cbdcede4 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -39,6 +39,10 @@ extern char *arg2; /* set by first.c to the argv[2] or NULL */ extern char *arg3; /* set by first.c to the argv[3] or NULL */ +/* argc and argv as passed in to the main() function */ +extern int test_argc; +extern char **test_argv; + int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv); -- cgit v1.2.1 From 1da3d402f619adcb3880ab05a311a609f9e28d60 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 15 Jul 2007 21:00:26 +0000 Subject: convert test case 540 to use a custom Host: header as well --- tests/libtest/lib540.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 4b8e141b6..4d22eb575 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -13,14 +13,17 @@ * argv1 = URL * argv2 = proxy * argv3 = proxyuser:password + * argv4 = host name to use for the custom Host: header */ #include "test.h" #define PROXY arg2 #define PROXYUSERPWD arg3 +#define HOST test_argv[4] -static void init(CURLM *cm, const char* url, const char* userpwd) +static void init(CURLM *cm, const char* url, const char* userpwd, + struct curl_slist *headers) { CURL *eh = curl_easy_init(); @@ -30,11 +33,13 @@ static void init(CURLM *cm, const char* url, const char* userpwd) curl_easy_setopt(eh, CURLOPT_PROXYAUTH, CURLAUTH_ANY); curl_easy_setopt(eh, CURLOPT_VERBOSE, 1); curl_easy_setopt(eh, CURLOPT_HEADER, 1); + curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ curl_multi_add_handle(cm, eh); } -static int loop(CURLM *cm, const char* url, const char* userpwd) +static int loop(CURLM *cm, const char* url, const char* userpwd, + struct curl_slist *headers) { CURLMsg *msg; long L; @@ -42,7 +47,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd) fd_set R, W, E; struct timeval T; - init(cm, url, userpwd); + init(cm, url, userpwd, headers); while (U) { while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U)); @@ -102,18 +107,30 @@ static int loop(CURLM *cm, const char* url, const char* userpwd) int test(char *URL) { CURLM *cm; + struct curl_slist *headers = NULL; + char buffer[246]; /* naively fixed-size */ + + if(test_argc < 4) + return 99; + + sprintf(buffer, "Host: %s", HOST); + + /* now add a custom Host: header */ + headers = curl_slist_append(headers, buffer); curl_global_init(CURL_GLOBAL_ALL); cm = curl_multi_init(); - loop(cm, URL, PROXYUSERPWD); + loop(cm, URL, PROXYUSERPWD, headers); fprintf(stderr, "lib540: now we do the request again\n"); - loop(cm, URL, PROXYUSERPWD); + loop(cm, URL, PROXYUSERPWD, headers); curl_multi_cleanup(cm); curl_global_cleanup(); + curl_slist_free_all(headers); + return EXIT_SUCCESS; } -- cgit v1.2.1 From 989dd9c34abd98ab061c4c29f6697d30111e73f4 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 17 Jul 2007 21:53:38 +0000 Subject: Fixed test cases 613 and 614 by improving the log postprocessor to handle a new directory listing format that newer libssh2's can provide. This is probably NOT sufficient to handle all directory listing formats that server's can provide and should be revisited. --- tests/libtest/test613.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index 749763d4e..778c4a911 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -55,15 +55,25 @@ elsif ($ARGV[0] eq "postprocess") rmdir $dirname || die "$!"; if ($logfile) { - # Process the directory file to remove all information that could - # be inconsistent from one test run to the next (e.g. file date) - # or may be unsupported on some platforms (e.g. Windows) + # Process the directory file to remove all information that + # could be inconsistent from one test run to the next (e.g. + # file date) or may be unsupported on some platforms (e.g. + # Windows). Also, since >7.16.4, the sftp directory listing + # format can be dependent on the server (with a recent + # enough version of libssh2) so this script must also + # canonicalize the format. These are the two formats + # currently supported: + # -r--r--r-- 1 ausername grp 47 Dec 31 2000 rofile.txt + # -r--r--r-- 1 1234 4321 47 Dec 31 2000 rofile.txt + # The "canonical" format is similar to the second (which is + # the one generated with an older libssh2): + # -r-?r-?r-? 1 U U 47 Dec 31 2000 rofile.txt my $newfile = $logfile . ".new"; open(IN, "<$logfile") || die "$!"; open(OUT, ">$newfile") || die "$!"; while () { - s/^(.)(..).(..).(..).(.{4}?).{6}?.{6}?(.{12}?)/\1\2?\3?\4?\5 U U\6/; + s/^(.)(..).(..).(..).\s*(\d+)\s+\S+ \S?.{5}?(\s+\d)+(.{12}?)/\1\2?\3?\4? \5 U U\6\7/; if ($1 eq "d") { # Erase inodes, size, mode, time fields for directories s/^.{14}?(.{12}?).{11}? ... .\d .\d:\d\d/d????????? N\1 N ??? N NN:NN/; -- cgit v1.2.1 From 5ecd56d9646c2adcc70c0369fb6196f62ecc62f4 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 23 Jul 2007 18:51:22 +0000 Subject: Implemented only the parts of Patrick Monnerat's OS/400 patch that renamed some few internal identifiers to avoid conflicts, which could be useful on other platforms. --- tests/libtest/lib506.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 3a3f9e6b9..0a2a0d163 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -19,13 +19,6 @@ const char *HOSTHEADER = "Host: www.host.foo.com"; const char *JAR = "log/jar506"; #define THREADS 2 -void lock(CURL *handle, curl_lock_data data, curl_lock_access access, - void *useptr ); -void unlock(CURL *handle, curl_lock_data data, void *useptr ); -struct curl_slist *sethost(struct curl_slist *headers); -void *fire(void *ptr); -char *suburl(const char *base, int i); - /* struct containing data of a thread */ struct Tdata { CURLSH *share; @@ -38,7 +31,7 @@ struct userdata { }; /* lock callback */ -void lock(CURL *handle, curl_lock_data data, curl_lock_access access, +static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access access, void *useptr ) { const char *what; @@ -66,7 +59,7 @@ void lock(CURL *handle, curl_lock_data data, curl_lock_access access, } /* unlock callback */ -void unlock(CURL *handle, curl_lock_data data, void *useptr ) +static void my_unlock(CURL *handle, curl_lock_data data, void *useptr ) { const char *what; struct userdata *user = (struct userdata *)useptr; @@ -91,7 +84,7 @@ void unlock(CURL *handle, curl_lock_data data, void *useptr ) /* build host entry */ -struct curl_slist *sethost(struct curl_slist *headers) +static struct curl_slist *sethost(struct curl_slist *headers) { (void)headers; return curl_slist_append(NULL, HOSTHEADER ); @@ -99,7 +92,7 @@ struct curl_slist *sethost(struct curl_slist *headers) /* the dummy thread function */ -void *fire(void *ptr) +static void *fire(void *ptr) { CURLcode code; struct curl_slist *headers; @@ -135,7 +128,7 @@ void *fire(void *ptr) /* build request url */ -char *suburl(const char *base, int i) +static char *suburl(const char *base, int i) { return curl_maprintf("%s000%c", base, 48+i); } @@ -173,11 +166,11 @@ int test(char *URL) if ( CURLSHE_OK == scode ) { printf( "CURLSHOPT_LOCKFUNC\n" ); - scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock); + scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock); } if ( CURLSHE_OK == scode ) { printf( "CURLSHOPT_UNLOCKFUNC\n" ); - scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock); + scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock); } if ( CURLSHE_OK == scode ) { printf( "CURLSHOPT_USERDATA\n" ); -- cgit v1.2.1 From 2e60ca382dbe99bd294641dabf7e84a349b080c8 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 7 Aug 2007 00:10:27 +0000 Subject: Fixed some icc compiler warnings. --- tests/libtest/lib540.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 4d22eb575..518afecd6 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -87,16 +87,16 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, while ((msg = curl_multi_info_read(cm, &Q))) { if (msg->msg == CURLMSG_DONE) { - char *url; + char *usedurl; CURL *e = msg->easy_handle; - curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url); - fprintf(stderr, "R: %d - %s <%s>\n", - msg->data.result, curl_easy_strerror(msg->data.result), url); + curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &usedurl); + fprintf(stderr, "R: %d - %s <%s>\n", (int)msg->data.result, + curl_easy_strerror(msg->data.result), usedurl); curl_multi_remove_handle(cm, e); curl_easy_cleanup(e); } else { - fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg); + fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg); } } } -- cgit v1.2.1 From 652e2cf57c20616ef257a483d76832bc30c3b218 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 13 Aug 2007 18:11:37 +0000 Subject: Removed redundant dependency lines --- tests/libtest/Makefile.am | 71 ++--------------------------------------------- 1 file changed, 2 insertions(+), 69 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 2614ce3f3..c511a6e16 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -50,146 +50,79 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 # Dependencies (may need to be overriden) -LIBTEST_LIBS = $(LIBDIR)/libcurl.la +LDADD = $(LIBDIR)/libcurl.la DEPENDENCIES = $(LIBDIR)/libcurl.la + lib500_SOURCES = lib500.c $(SUPPORTFILES) -lib500_DEPENDENCIES = $(DEPENDENCIES) -lib500_LDADD = $(LIBTEST_LIBS) lib501_SOURCES = lib501.c $(SUPPORTFILES) -lib501_DEPENDENCIES = $(DEPENDENCIES) -lib501_LDADD = $(LIBTEST_LIBS) lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) -lib502_DEPENDENCIES = $(DEPENDENCIES) -lib502_LDADD = $(LIBTEST_LIBS) lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) -lib503_DEPENDENCIES = $(DEPENDENCIES) -lib503_LDADD = $(LIBTEST_LIBS) lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) -lib504_DEPENDENCIES = $(DEPENDENCIES) -lib504_LDADD = $(LIBTEST_LIBS) lib505_SOURCES = lib505.c $(SUPPORTFILES) -lib505_DEPENDENCIES = $(DEPENDENCIES) -lib505_LDADD = $(LIBTEST_LIBS) lib506_SOURCES = lib506.c $(SUPPORTFILES) -lib506_DEPENDENCIES = $(DEPENDENCIES) -lib506_LDADD = $(LIBTEST_LIBS) lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) -lib507_DEPENDENCIES = $(DEPENDENCIES) -lib507_LDADD = $(LIBTEST_LIBS) lib508_SOURCES = lib508.c $(SUPPORTFILES) -lib508_DEPENDENCIES = $(DEPENDENCIES) -lib508_LDADD = $(LIBTEST_LIBS) lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TESTUTIL) -lib509_DEPENDENCIES = $(DEPENDENCIES) -lib509_LDADD = $(LIBTEST_LIBS) lib510_SOURCES = lib510.c $(SUPPORTFILES) -lib510_DEPENDENCIES = $(DEPENDENCIES) -lib510_LDADD = $(LIBTEST_LIBS) lib511_SOURCES = lib511.c $(SUPPORTFILES) -lib511_DEPENDENCIES = $(DEPENDENCIES) -lib511_LDADD = $(LIBTEST_LIBS) lib512_SOURCES = lib512.c $(SUPPORTFILES) -lib512_DEPENDENCIES = $(DEPENDENCIES) -lib512_LDADD = $(LIBTEST_LIBS) lib513_SOURCES = lib513.c $(SUPPORTFILES) -lib513_DEPENDENCIES = $(DEPENDENCIES) -lib513_LDADD = $(LIBTEST_LIBS) lib514_SOURCES = lib514.c $(SUPPORTFILES) -lib514_DEPENDENCIES = $(DEPENDENCIES) -lib514_LDADD = $(LIBTEST_LIBS) lib515_SOURCES = lib515.c $(SUPPORTFILES) -lib515_DEPENDENCIES = $(DEPENDENCIES) -lib515_LDADD = $(LIBTEST_LIBS) lib516_SOURCES = lib516.c $(SUPPORTFILES) -lib516_DEPENDENCIES = $(DEPENDENCIES) -lib516_LDADD = $(LIBTEST_LIBS) lib517_SOURCES = lib517.c $(SUPPORTFILES) -lib517_DEPENDENCIES = $(DEPENDENCIES) -lib517_LDADD = $(LIBTEST_LIBS) lib518_SOURCES = lib518.c $(SUPPORTFILES) -lib518_DEPENDENCIES = $(DEPENDENCIES) -lib518_LDADD = $(LIBTEST_LIBS) lib519_SOURCES = lib519.c $(SUPPORTFILES) -lib519_DEPENDENCIES = $(DEPENDENCIES) -lib519_LDADD = $(LIBTEST_LIBS) lib520_SOURCES = lib520.c $(SUPPORTFILES) -lib520_DEPENDENCIES = $(DEPENDENCIES) -lib520_LDADD = $(LIBTEST_LIBS) lib521_SOURCES = lib521.c $(SUPPORTFILES) -lib521_DEPENDENCIES = $(DEPENDENCIES) -lib521_LDADD = $(LIBTEST_LIBS) lib523_SOURCES = lib523.c $(SUPPORTFILES) -lib523_DEPENDENCIES = $(DEPENDENCIES) -lib523_LDADD = $(LIBTEST_LIBS) lib524_SOURCES = lib524.c $(SUPPORTFILES) -lib524_DEPENDENCIES = $(DEPENDENCIES) -lib524_LDADD = $(LIBTEST_LIBS) lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) -lib525_DEPENDENCIES = $(DEPENDENCIES) -lib525_LDADD = $(LIBTEST_LIBS) lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib526_CFLAGS = -DLIB526 -lib526_DEPENDENCIES = $(DEPENDENCIES) -lib526_LDADD = $(LIBTEST_LIBS) lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib527_CFLAGS = -DLIB527 -lib527_DEPENDENCIES = $(DEPENDENCIES) -lib527_LDADD = $(LIBTEST_LIBS) lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib529_CFLAGS = -DLIB529 -lib529_DEPENDENCIES = $(DEPENDENCIES) -lib529_LDADD = $(LIBTEST_LIBS) lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) lib530_CFLAGS = -DLIB530 -lib530_DEPENDENCIES = $(DEPENDENCIES) -lib530_LDADD = $(LIBTEST_LIBS) lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) lib532_CFLAGS = -DLIB532 -lib532_DEPENDENCIES = $(DEPENDENCIES) -lib532_LDADD = $(LIBTEST_LIBS) lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) -lib533_DEPENDENCIES = $(DEPENDENCIES) -lib533_LDADD = $(LIBTEST_LIBS) lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) -lib536_DEPENDENCIES = $(DEPENDENCIES) -lib536_LDADD = $(LIBTEST_LIBS) lib537_SOURCES = lib537.c $(SUPPORTFILES) -lib537_DEPENDENCIES = $(DEPENDENCIES) -lib537_LDADD = $(LIBTEST_LIBS) lib540_SOURCES = lib540.c $(SUPPORTFILES) -lib540_DEPENDENCIES = $(DEPENDENCIES) -lib540_LDADD = $(LIBTEST_LIBS) -- cgit v1.2.1 From 9e88343a1722f49cc4045a25d6587262f84d1077 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 11 Sep 2007 22:23:57 +0000 Subject: Daniel S (12 September 2007) - Bug report #1792649 (http://curl.haxx.se/bug/view.cgi?id=1792649) pointed out a problem with doing an empty upload over FTP on a re-used connection. I added test case 541 to reproduce it and to verify the fix. - I noticed while writing test 541 that the FTP code wrongly did a CWD on the second transfer as it didn't store and remember the "" path from the previous transfer so it would instead CWD to the entry path as stored. This worked, but did a superfluous command. Thus, test case 541 now also verifies this fix. --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib541.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib541.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c511a6e16..dc55afce7 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -47,7 +47,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 lib537 lib540 + lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -126,3 +126,5 @@ lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) lib537_SOURCES = lib537.c $(SUPPORTFILES) lib540_SOURCES = lib540.c $(SUPPORTFILES) + +lib541_SOURCES = lib541.c $(SUPPORTFILES) diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c new file mode 100644 index 000000000..3ab1e2595 --- /dev/null +++ b/tests/libtest/lib541.c @@ -0,0 +1,117 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "setup.h" /* struct_stat etc. */ +#include "test.h" + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +/* + * Two FTP uploads, the second with no content sent. + */ + +int test(char *URL) +{ + CURL *curl; + CURLcode res = CURLE_OK; + FILE *hd_src ; + int hd ; + struct_stat file_info; + int error; + + if (!arg2) { + fprintf(stderr, "Usage: \n"); + return -1; + } + + /* get the file size of the local file */ + hd = stat(arg2, &file_info); + if(hd == -1) { + /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "stat() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "WARNING: cannot open file %s\n", arg2); + return -1; + } + + if(! file_info.st_size) { + fprintf(stderr, "WARNING: file %s has no size!\n", arg2); + return -4; + } + + /* get a FILE * of the same file, could also be made with + fdopen() from the previous descriptor, but hey this is just + an example! */ + hd_src = fopen(arg2, "rb"); + if(NULL == hd_src) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: %s\n", arg2); + return -2; /* if this happens things are major weird */ + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + + /* get a curl handle */ + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + + /* enable uploading */ + curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + + /* enable verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, URL); + + /* now specify which file to upload */ + curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + /* and now upload the exact same again, but without rewinding so it already + is at end of file */ + res = curl_easy_perform(curl); + + /* close the local file */ + fclose(hd_src); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From 9e241864e3e7ffdd2b58f1fd7da87e25c5d57348 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 Sep 2007 10:46:14 +0000 Subject: Extracting the CURLINFO_PRIVATE pointer makes no point since nothing set it. This caused a segfault in some fprintf() implementations. Like on Solaris. --- tests/libtest/lib540.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 518afecd6..c5c48c471 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -87,11 +87,9 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, while ((msg = curl_multi_info_read(cm, &Q))) { if (msg->msg == CURLMSG_DONE) { - char *usedurl; CURL *e = msg->easy_handle; - curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &usedurl); - fprintf(stderr, "R: %d - %s <%s>\n", (int)msg->data.result, - curl_easy_strerror(msg->data.result), usedurl); + 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); } -- cgit v1.2.1 From 26f8de459acf240c181d1b96c523c5d3cf0370a1 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 17 Sep 2007 17:22:46 +0000 Subject: Made the directory postprocessor more forgiving of input directory format --- tests/libtest/test613.pl | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index 778c4a911..19ef7d687 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -58,27 +58,34 @@ elsif ($ARGV[0] eq "postprocess") # Process the directory file to remove all information that # could be inconsistent from one test run to the next (e.g. # file date) or may be unsupported on some platforms (e.g. - # Windows). Also, since >7.16.4, the sftp directory listing + # Windows). Also, since 7.17.0, the sftp directory listing # format can be dependent on the server (with a recent # enough version of libssh2) so this script must also - # canonicalize the format. These are the two formats - # currently supported: - # -r--r--r-- 1 ausername grp 47 Dec 31 2000 rofile.txt + # canonicalize the format. Here are examples of the general + # format supported: + # -r--r--r-- 12 ausername grp 47 Dec 31 2000 rofile.txt # -r--r--r-- 1 1234 4321 47 Dec 31 2000 rofile.txt - # The "canonical" format is similar to the second (which is - # the one generated with an older libssh2): - # -r-?r-?r-? 1 U U 47 Dec 31 2000 rofile.txt + # The "canonical" format is similar to the first (which is + # the one generated on a typical Linux installation): + # -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt my $newfile = $logfile . ".new"; open(IN, "<$logfile") || die "$!"; open(OUT, ">$newfile") || die "$!"; while () { - s/^(.)(..).(..).(..).\s*(\d+)\s+\S+ \S?.{5}?(\s+\d)+(.{12}?)/\1\2?\3?\4? \5 U U\6\7/; + /^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)(.*)$/; if ($1 eq "d") { - # Erase inodes, size, mode, time fields for directories - s/^.{14}?(.{12}?).{11}? ... .\d .\d:\d\d/d????????? N\1 N ??? N NN:NN/; + # Erase all directory metadata except for the name, as it is not + # consistent for across all test systems and filesystems + print OUT "d????????? N U U N ??? N NN:NN$8\n"; + } elsif ($1 eq "-") { + # Erase user and group names, as they are not consistent across + # all test systems + printf OUT "%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8; + } else { + # Unexpected format; just pass it through and let the test fail + print OUT $_; } - print OUT $_; } close(OUT); -- cgit v1.2.1 From a6315359d742bdf967ba3ee1db3e0b7e5a3956fe Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Sep 2007 12:00:01 +0000 Subject: Max Katsev reported that when doing a libcurl FTP request with CURLOPT_NOBODY enabled but not CURLOPT_HEADER, libcurl wouldn't do TYPE before it does SIZE which makes it less useful. I walked over the code and made it do this properly, and added test case 542 to verify it. --- tests/libtest/Makefile.am | 4 ++- tests/libtest/lib542.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib542.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index dc55afce7..395564a6e 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -47,7 +47,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 + lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -128,3 +128,5 @@ lib537_SOURCES = lib537.c $(SUPPORTFILES) lib540_SOURCES = lib540.c $(SUPPORTFILES) lib541_SOURCES = lib541.c $(SUPPORTFILES) + +lib542_SOURCES = lib542.c $(SUPPORTFILES) diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c new file mode 100644 index 000000000..6aee9013f --- /dev/null +++ b/tests/libtest/lib542.c @@ -0,0 +1,74 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "setup.h" /* struct_stat etc. */ +#include "test.h" + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +/* + * FTP get with NOBODY but no HEADER + */ + +int test(char *URL) +{ + CURL *curl; + CURLcode res = CURLE_OK; + FILE *hd_src ; + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + + /* get a curl handle */ + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + + /* enable verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + + /* enable NOBODY */ + curl_easy_setopt(curl, CURLOPT_NOBODY, TRUE) ; + + /* disable HEADER */ + curl_easy_setopt(curl, CURLOPT_HEADER, FALSE) ; + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, URL); + + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From 16b95fc77316fdd3866f7de4ebb5d14bd136ac11 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 27 Sep 2007 01:45:22 +0000 Subject: Enabled a few more gcc warnings with --enable-debug. Renamed a few variables to avoid shadowing global declarations. --- tests/libtest/lib506.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 0a2a0d163..eaf96d2e9 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -31,14 +31,14 @@ struct userdata { }; /* lock callback */ -static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access access, +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)access; + (void)laccess; switch ( data ) { case CURL_LOCK_DATA_SHARE: -- cgit v1.2.1 From 9fc8800b6d906f4c9d9d8d464eea91dd2bc40ad3 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 27 Sep 2007 17:22:10 +0000 Subject: Removed cut-and-paste cruft leading to fclose() of an unopened file --- tests/libtest/lib542.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index 6aee9013f..deb229d19 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -36,11 +36,9 @@ int test(char *URL) { CURL *curl; CURLcode res = CURLE_OK; - FILE *hd_src ; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); - fclose(hd_src); return TEST_ERR_MAJOR_BAD; } @@ -48,7 +46,6 @@ int test(char *URL) if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); - fclose(hd_src); return TEST_ERR_MAJOR_BAD; } -- cgit v1.2.1 From 64db60397b9d71a7b0ba381ee80007681b409866 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 30 Sep 2007 01:01:43 +0000 Subject: Fix comparison between signed and unsigned --- tests/libtest/lib518.c | 3 ++- tests/libtest/lib537.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 756f301d9..a04d2ec82 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -384,7 +384,8 @@ static int rlimit(int keep_open) for (rl.rlim_cur = 0; rl.rlim_cur < num_open.rlim_max; rl.rlim_cur++) { - if (fd[rl.rlim_cur] > num_open.rlim_cur) { + if ((fd[rl.rlim_cur] > 0) && + ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur) { sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index a074bf994..ee7bd9b6b 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -387,7 +387,8 @@ static int rlimit(int keep_open) for (rl.rlim_cur = 0; rl.rlim_cur < num_open.rlim_max; rl.rlim_cur++) { - if (fd[rl.rlim_cur] > num_open.rlim_cur) { + if ((fd[rl.rlim_cur] > 0) && + ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur) { sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); -- cgit v1.2.1 From b108c664ac5535595609ef771eb38c14ae6bb582 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 30 Sep 2007 01:27:39 +0000 Subject: Fix missing right parenthesis --- tests/libtest/lib518.c | 2 +- tests/libtest/lib537.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index a04d2ec82..3b83ae378 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -385,7 +385,7 @@ static int rlimit(int keep_open) rl.rlim_cur < num_open.rlim_max; rl.rlim_cur++) { if ((fd[rl.rlim_cur] > 0) && - ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur) { + ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index ee7bd9b6b..b4b2b7a93 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -388,7 +388,7 @@ static int rlimit(int keep_open) rl.rlim_cur < num_open.rlim_max; rl.rlim_cur++) { if ((fd[rl.rlim_cur] > 0) && - ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur) { + ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); -- cgit v1.2.1 From ec08e2f9f24da5974be1ab222c5703fd9fb3722f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 30 Sep 2007 22:40:24 +0000 Subject: Alex Fishman reported a curl_easy_escape() problem that was made the function do wrong on all input bytes that are >= 0x80 (decimal 128) due to a signed / unsigned mistake in the code. I fixed it and added test case 543 to verify. --- tests/libtest/Makefile.am | 4 +++- tests/libtest/lib543.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib543.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 395564a6e..f0fb24ed0 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -47,7 +47,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 + lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -130,3 +130,5 @@ lib540_SOURCES = lib540.c $(SUPPORTFILES) lib541_SOURCES = lib541.c $(SUPPORTFILES) lib542_SOURCES = lib542.c $(SUPPORTFILES) + +lib543_SOURCES = lib543.c $(SUPPORTFILES) diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c new file mode 100644 index 000000000..2e930d2d6 --- /dev/null +++ b/tests/libtest/lib543.c @@ -0,0 +1,32 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * Based on Alex Fishman's bug report on September 30, 2007 + */ + +#include "setup.h" +#include "test.h" + +int test(char *URL) +{ + unsigned char a[] = {0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1, + 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa, + 0x1d, 0x57, 0xe1}; + + CURL* easy = curl_easy_init(); + char* s = curl_easy_escape(easy, (char*)a, sizeof(a)); + (void)URL; + + printf("%s\n", s); + + curl_free(s); + curl_easy_cleanup(easy); + + return 0; +} -- cgit v1.2.1 From 059707be320e993e7ee047e1e728ce9d6e67e4f7 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 2 Oct 2007 16:05:28 +0000 Subject: Renamed a couple of global variables to avoid shadowing warnings --- tests/libtest/first.c | 8 ++++---- tests/libtest/lib503.c | 2 +- tests/libtest/lib504.c | 2 +- tests/libtest/lib505.c | 12 ++++++------ tests/libtest/lib509.c | 4 ++-- tests/libtest/lib521.c | 2 +- tests/libtest/lib523.c | 2 +- tests/libtest/lib525.c | 8 ++++---- tests/libtest/lib533.c | 2 +- tests/libtest/lib536.c | 2 +- tests/libtest/lib540.c | 4 ++-- tests/libtest/lib541.c | 12 ++++++------ tests/libtest/test.h | 4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index e2e1bfaed..a58755c41 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -34,8 +34,8 @@ int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, return select(num_fds, rd, wr, exc, tv); } -char *arg2=NULL; -char *arg3=NULL; +char *libtest_arg2=NULL; +char *libtest_arg3=NULL; int test_argc; char **test_argv; @@ -73,10 +73,10 @@ int main(int argc, char **argv) test_argv = argv; if(argc>2) - arg2=argv[2]; + libtest_arg2=argv[2]; if(argc>3) - arg3=argv[3]; + libtest_arg3=argv[3]; URL = argv[1]; /* provide this to the rest */ diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 8294e8ccb..327402242 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -48,7 +48,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(c, CURLOPT_PROXY, arg2); /* set in first.c */ + curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ curl_easy_setopt(c, CURLOPT_URL, URL); curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 6bfbe4dde..a6e988657 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -53,7 +53,7 @@ int test(char *URL) /* the point here being that there must not run anything on the given proxy port */ - curl_easy_setopt(c, CURLOPT_PROXY, arg2); + curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(c, CURLOPT_URL, URL); curl_easy_setopt(c, CURLOPT_VERBOSE, 1); diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 098e8f9e0..d2698faa9 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -49,36 +49,36 @@ int test(char *URL) const char *buf_1 = "RNFR 505"; const char *buf_2 = "RNTO 505-forreal"; - if (!arg2) { + if (!libtest_arg2) { fprintf(stderr, "Usage: \n"); return -1; } /* get the file size of the local file */ - hd = stat(arg2, &file_info); + hd = stat(libtest_arg2, &file_info); if(hd == -1) { /* can't open file, bail out */ error = ERRNO; fprintf(stderr, "stat() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "WARNING: cannot open file %s\n", arg2); + fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2); return -1; } if(! file_info.st_size) { - fprintf(stderr, "WARNING: file %s has no size!\n", arg2); + fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2); return -4; } /* get a FILE * of the same file, could also be made with fdopen() from the previous descriptor, but hey this is just an example! */ - hd_src = fopen(arg2, "rb"); + hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "Error opening file: %s\n", arg2); + fprintf(stderr, "Error opening file: %s\n", libtest_arg2); return -2; /* if this happens things are major weird */ } diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 34749e2d3..f4dadce73 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -206,8 +206,8 @@ int test(char *URL) char ml_timedout = FALSE; char mp_timedout = FALSE; - if(arg2) { - portnum = atoi(arg2); + if(libtest_arg2) { + portnum = atoi(libtest_arg2); } if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 088534955..7301e3cd1 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -27,7 +27,7 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_PORT, atoi(arg2)); + curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index 6ddfc947f..c6c8e2e31 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -26,7 +26,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_PROXY, arg2); + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_PORT, 19999); curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index b60328ba1..222f8c278 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -35,25 +35,25 @@ int test(char *URL) char ml_timedout = FALSE; char mp_timedout = FALSE; - if (!arg2) { + if (!libtest_arg2) { fprintf(stderr, "Usage: lib525 [url] [uploadfile]\n"); return -1; } /* get the file size of the local file */ - hd = open(arg2, O_RDONLY) ; + hd = open(libtest_arg2, O_RDONLY) ; fstat(hd, &file_info); close(hd) ; /* get a FILE * of the same file, could also be made with fdopen() from the previous descriptor, but hey this is just an example! */ - hd_src = fopen(arg2, "rb"); + hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "Error opening file: %s\n", arg2); + fprintf(stderr, "Error opening file: %s\n", libtest_arg2); return TEST_ERR_MAJOR_BAD; } diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index ee5f78f28..71c43c2ca 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -102,7 +102,7 @@ int test(char *URL) /* make us re-use the same handle all the time, and try resetting the handle first too */ curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_URL, arg2); + curl_easy_setopt(curl, CURLOPT_URL, libtest_arg2); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 6b0a6a223..29e599fcd 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -108,7 +108,7 @@ int test(char *URL) curl_easy_reset(easy); curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); - curl_easy_setopt(easy, CURLOPT_URL, arg2); + curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2); if (curl_multi_add_handle(multi, easy) != CURLM_OK) { printf("curl_multi_add_handle() 2 failed\n"); diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index c5c48c471..4560eb815 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -18,8 +18,8 @@ #include "test.h" -#define PROXY arg2 -#define PROXYUSERPWD arg3 +#define PROXY libtest_arg2 +#define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] static void init(CURLM *cm, const char* url, const char* userpwd, diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index 3ab1e2595..71d2e38ed 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -41,36 +41,36 @@ int test(char *URL) struct_stat file_info; int error; - if (!arg2) { + if (!libtest_arg2) { fprintf(stderr, "Usage: \n"); return -1; } /* get the file size of the local file */ - hd = stat(arg2, &file_info); + hd = stat(libtest_arg2, &file_info); if(hd == -1) { /* can't open file, bail out */ error = ERRNO; fprintf(stderr, "stat() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "WARNING: cannot open file %s\n", arg2); + fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2); return -1; } if(! file_info.st_size) { - fprintf(stderr, "WARNING: file %s has no size!\n", arg2); + fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2); return -4; } /* get a FILE * of the same file, could also be made with fdopen() from the previous descriptor, but hey this is just an example! */ - hd_src = fopen(arg2, "rb"); + hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; fprintf(stderr, "fopen() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "Error opening file: %s\n", arg2); + fprintf(stderr, "Error opening file: %s\n", libtest_arg2); return -2; /* if this happens things are major weird */ } diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 5cbdcede4..50c3a7959 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -36,8 +36,8 @@ #define TEST_ERR_MAJOR_BAD 100 #define TEST_ERR_RUNS_FOREVER 99 -extern char *arg2; /* set by first.c to the argv[2] or NULL */ -extern char *arg3; /* set by first.c to the argv[3] or NULL */ +extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */ +extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */ /* argc and argv as passed in to the main() function */ extern int test_argc; -- cgit v1.2.1 From 92433e596b7fbfa5c75926705dcfef0080ebf012 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 17 Oct 2007 16:58:32 +0000 Subject: We use this ZERO_NULL to avoid picky compiler warnings, when assigning a NULL pointer to a function pointer var. --- tests/libtest/lib509.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index f4dadce73..5d8edd266 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -35,13 +35,6 @@ #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 -/* - * We use this ZERO_NULL to avoid picky compiler warnings, - * when assigning a NULL pointer to a function pointer var. - */ - -#define ZERO_NULL 0 - int portnum; /* the HTTPS port number we use */ typedef struct sslctxparm_st { -- cgit v1.2.1 From 8e7da9464a847820adff261907885ac5770ac81a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 23 Oct 2007 15:10:48 +0000 Subject: Read callback should return 0 when no more data left --- tests/libtest/lib508.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index cc240db5c..ecbc41912 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -31,7 +31,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) return 1; /* we return 1 byte at a time! */ } - return -1; /* no more data left to deliver */ + return 0; /* no more data left to deliver */ } int test(char *URL) -- cgit v1.2.1 From 0678a51d3b8be8b24e475929fae11b95d2258da4 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Thu, 25 Oct 2007 19:40:05 +0000 Subject: Allow test server to handle binary POSTs. Tests 35, 544 545 added: binary data POSTs. --- tests/libtest/Makefile.am | 8 ++++++- tests/libtest/lib544.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib544.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index f0fb24ed0..3137e9e06 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -47,7 +47,8 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 + lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ + lib544 lib545 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -132,3 +133,8 @@ lib541_SOURCES = lib541.c $(SUPPORTFILES) lib542_SOURCES = lib542.c $(SUPPORTFILES) lib543_SOURCES = lib543.c $(SUPPORTFILES) + +lib544_SOURCES = lib544.c $(SUPPORTFILES) + +lib545_SOURCES = lib544.c $(SUPPORTFILES) +lib545_CFLAGS = -DLIB545 diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c new file mode 100644 index 000000000..bde630d6b --- /dev/null +++ b/tests/libtest/lib544.c @@ -0,0 +1,57 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + + +static char teststring[] = + "This\0 is test binary data with an embedded NUL byte\n"; + + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + 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; + } + + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + +#ifdef LIB545 + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof teststring - 1); +#endif + + curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring); + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + + /* Update the original data to detect non-copy. */ + strcpy(teststring, "FAIL"); + + /* Now, this is a POST request with binary 0 embedded in POST data. */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} -- cgit v1.2.1 From 16897354bcbb2afbc81d0d985a940dbe37cac986 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 1 Nov 2007 00:36:55 +0000 Subject: Added test case 1013 to check that curl-config --protocols matches the protocols listed in curl --version --- tests/libtest/Makefile.am | 2 +- tests/libtest/test1013.pl | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 tests/libtest/test1013.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 3137e9e06..af21d6da3 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl +EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl new file mode 100755 index 000000000..8e5c7368e --- /dev/null +++ b/tests/libtest/test1013.pl @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +# Determine if curl-config --protocols matches the curl --version protocols +if ( $#ARGV != 1 ) +{ + print "Usage: $0 curl-config-script curl-features-file\n"; + exit 3; +} + +my $curl_protocols=""; +open(CURL, "@ARGV[1]") || die "Can't get curl protocols list\n"; +while( ) +{ + $curl_protocols = $_ if ( /Protocols:/ ); +} +close CURL; + +$curl_protocols =~ /Protocols: (.*)$/; +@curl = split / /,$1; +@curl = sort @curl; + +my @curl_config; +open(CURLCONFIG, "sh @ARGV[0] --protocols|") || die "Can't get curl-config protocols list\n"; +while( ) +{ + chomp; + push @curl_config, lc($_); +} +close CURLCONFIG; + +@curl_config = sort @curl_config; + +my $curlproto = join ' ', @curl; +my $curlconfigproto = join ' ', @curl_config; + +my $different = $curlproto ne $curlconfigproto; +if ($different) { + print "Mismatch in protocol lists:\n"; + print "curl: $curlproto\n"; + print "curl-config: $curlconfigproto\n"; +} +exit $different; -- cgit v1.2.1 From 6f33531861c02602446c7d2d30e0aaff271557f4 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 1 Nov 2007 03:09:27 +0000 Subject: Added test case 1014 to compare curl-config --features with curl --version --- tests/libtest/test1013.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 8e5c7368e..6c5a5dcdc 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -1,25 +1,28 @@ #!/usr/bin/env perl # Determine if curl-config --protocols matches the curl --version protocols -if ( $#ARGV != 1 ) +if ( $#ARGV != 2 ) { - print "Usage: $0 curl-config-script curl-features-file\n"; + print "Usage: $0 curl-config-script curl-features-file features|protocols\n"; exit 3; } +my $what=$ARGV[2]; + my $curl_protocols=""; -open(CURL, "@ARGV[1]") || die "Can't get curl protocols list\n"; +open(CURL, "@ARGV[1]") || die "Can't get curl $what list\n"; while( ) { - $curl_protocols = $_ if ( /Protocols:/ ); + $curl_protocols = lc($_) if ( /$what:/i ); } close CURL; -$curl_protocols =~ /Protocols: (.*)$/; +$curl_protocols =~ /\w+: (.*)$/; @curl = split / /,$1; +@curl = grep(!/^Debug|Largefile$/i, @curl); @curl = sort @curl; my @curl_config; -open(CURLCONFIG, "sh @ARGV[0] --protocols|") || die "Can't get curl-config protocols list\n"; +open(CURLCONFIG, "sh @ARGV[0] --$what|") || die "Can't get curl-config $what list\n"; while( ) { chomp; @@ -34,7 +37,7 @@ my $curlconfigproto = join ' ', @curl_config; my $different = $curlproto ne $curlconfigproto; if ($different) { - print "Mismatch in protocol lists:\n"; + print "Mismatch in $what lists:\n"; print "curl: $curlproto\n"; print "curl-config: $curlconfigproto\n"; } -- cgit v1.2.1 From 2f3d52057154d510c0a6188f81aee584adb1f4fe Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 1 Nov 2007 21:20:24 +0000 Subject: Ignore more features that curl-config is not expected to know about --- tests/libtest/test1013.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 6c5a5dcdc..b46e5ae3a 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -8,8 +8,9 @@ if ( $#ARGV != 2 ) my $what=$ARGV[2]; +# Read the output of curl --version my $curl_protocols=""; -open(CURL, "@ARGV[1]") || die "Can't get curl $what list\n"; +open(CURL, "$ARGV[1]") || die "Can't get curl $what list\n"; while( ) { $curl_protocols = lc($_) if ( /$what:/i ); @@ -18,11 +19,14 @@ close CURL; $curl_protocols =~ /\w+: (.*)$/; @curl = split / /,$1; -@curl = grep(!/^Debug|Largefile$/i, @curl); + +# These features are not supported by curl-config +@curl = grep(!/^(Debug|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl); @curl = sort @curl; +# Read the output of curl-config my @curl_config; -open(CURLCONFIG, "sh @ARGV[0] --$what|") || die "Can't get curl-config $what list\n"; +open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config $what list\n"; while( ) { chomp; -- cgit v1.2.1 From c8355c27e996b936ae5940c81cc6d06014b65104 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 5 Nov 2007 20:54:35 +0000 Subject: Sort the directory listing because the server doesn't always do it. --- tests/libtest/test613.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index 19ef7d687..ba9ed32e9 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -69,27 +69,31 @@ elsif ($ARGV[0] eq "postprocess") # the one generated on a typical Linux installation): # -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt - my $newfile = $logfile . ".new"; + my @canondir; open(IN, "<$logfile") || die "$!"; - open(OUT, ">$newfile") || die "$!"; while () { /^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)(.*)$/; if ($1 eq "d") { # Erase all directory metadata except for the name, as it is not # consistent for across all test systems and filesystems - print OUT "d????????? N U U N ??? N NN:NN$8\n"; + push @canondir, "d????????? N U U N ??? N NN:NN$8\n"; } elsif ($1 eq "-") { # Erase user and group names, as they are not consistent across # all test systems - printf OUT "%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8; + my $line = sprintf("%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8); + push @canondir, $line; } else { # Unexpected format; just pass it through and let the test fail - print OUT $_; + push @canondir, $_; } } + close(IN); + @canondir = sort {substr($a,57) cmp substr($b,57)} @canondir; + my $newfile = $logfile . ".new"; + open(OUT, ">$newfile") || die "$!"; + print OUT join('', @canondir); close(OUT); - close(IN); unlink $logfile; rename $newfile, $logfile; -- cgit v1.2.1 From 4e4f33a2970b69d7329ae23f87867febd1fecadf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 5 Dec 2007 11:08:56 +0000 Subject: added test548 which uses the lib547 source file, preparing for test547 which is supposed to repeat the bug report "NTLM proxy authentication with CURLOPT_READDATA seems broken." posted on the curl-library mailing list on dec 3 2007. --- tests/libtest/Makefile.am | 7 ++++- tests/libtest/lib547.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib547.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index af21d6da3..e5f1c8588 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 + lib544 lib545 lib547 lib548 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -138,3 +138,8 @@ lib544_SOURCES = lib544.c $(SUPPORTFILES) lib545_SOURCES = lib544.c $(SUPPORTFILES) lib545_CFLAGS = -DLIB545 + +lib547_SOURCES = lib547.c $(SUPPORTFILES) + +lib548_SOURCES = lib547.c $(SUPPORTFILES) +lib548_CFLAGS = -DLIB548 diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c new file mode 100644 index 000000000..ffd79df6d --- /dev/null +++ b/tests/libtest/lib547.c @@ -0,0 +1,70 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * argv1 = URL + * argv2 = proxy + * argv3 = proxyuser:password + */ + +#include "test.h" + +#define UPLOADTHIS "this is the blurb we want to upload\n" + +static size_t readcallback(void *ptr, + size_t size, + size_t nmemb, + void *stream) +{ + (void)stream; /* unused */ + if(size * nmemb > strlen(UPLOADTHIS)) { + strcpy(ptr, UPLOADTHIS); + return strlen(UPLOADTHIS); + } + return 0; +} + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + 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; + } + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); +#ifdef LIB548 + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); +#else + /* 547 style */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); +#endif + curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); + curl_easy_setopt(curl, CURLOPT_PROXYAUTH, + CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC ); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From 59dc9085d15fc069798eef92e41e4c72838ed990 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 5 Dec 2007 11:10:24 +0000 Subject: fix compiler warning --- tests/libtest/lib547.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index ffd79df6d..0513911d6 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -16,6 +16,7 @@ #define UPLOADTHIS "this is the blurb we want to upload\n" +#ifndef LIB548 static size_t readcallback(void *ptr, size_t size, size_t nmemb, @@ -28,6 +29,7 @@ static size_t readcallback(void *ptr, } return 0; } +#endif int test(char *URL) { -- cgit v1.2.1 From 7d3ea12b625fd07d9d41a68e7cc2cd5322247584 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 5 Dec 2007 21:20:14 +0000 Subject: Spacen Jasset reported a problem with doing POST (with data read with a callback) over a proxy when NTLM is used as auth with the proxy. The bug also concerned Digest and was limited to using callback only. Spacen worked with us to provide a useful patch. I added the test case 547 and 548 to verify two variations of POST over proxy with NTLM. --- tests/libtest/lib547.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 0513911d6..2d4011213 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -20,21 +20,49 @@ static size_t readcallback(void *ptr, size_t size, size_t nmemb, - void *stream) + void *clientp) { - (void)stream; /* unused */ + int *counter = (int *)clientp; + + if(*counter) { + /* only do this once and then require a clearing of this */ + fprintf(stderr, "READ ALREADY DONE!\n"); + return 0; + } + (*counter)++; /* bump */ + if(size * nmemb > strlen(UPLOADTHIS)) { + fprintf(stderr, "READ!\n"); strcpy(ptr, UPLOADTHIS); return strlen(UPLOADTHIS); } + fprintf(stderr, "READ NOT FINE!\n"); return 0; } +static curlioerr ioctlcallback(CURL *handle, + int cmd, + void *clientp) +{ + int *counter = (int *)clientp; + (void)handle; /* unused */ + if(cmd == CURLIOCMD_RESTARTREAD) { + fprintf(stderr, "REWIND!\n"); + *counter = 0; /* clear counter to make the read callback restart */ + } + return CURLIOE_OK; +} + + + #endif int test(char *URL) { CURLcode res; CURL *curl; +#ifndef LIB548 + int counter=0; +#endif if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -51,10 +79,18 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); #ifdef LIB548 + /* set the data to POST with a mere pointer to a zero-terminated string */ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); #else - /* 547 style */ + /* 547 style, which means reading the POST data from a callback */ + curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); + curl_easy_setopt(curl, CURLOPT_READDATA, &counter); + /* TODO: We should be able to do the POST fine without setting the size + and we should do a test to verify that but until we do that we set + the size of the request-body */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); #endif curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); -- cgit v1.2.1 From cc0ce38accd5ed52f64009ad61ed059a48700a87 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 8 Dec 2007 22:53:28 +0000 Subject: add test 549 and 550 --- tests/libtest/Makefile.am | 5 ++++- tests/libtest/lib549.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib549.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e5f1c8588..1f9461fa2 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 + lib544 lib545 lib547 lib548 lib549 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -143,3 +143,6 @@ lib547_SOURCES = lib547.c $(SUPPORTFILES) lib548_SOURCES = lib547.c $(SUPPORTFILES) lib548_CFLAGS = -DLIB548 + +lib549_SOURCES = lib549.c $(SUPPORTFILES) + diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c new file mode 100644 index 000000000..1ffef002b --- /dev/null +++ b/tests/libtest/lib549.c @@ -0,0 +1,48 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * argv1 = URL + * argv2 = proxy + * argv3 = non-zero means ASCII transfer + */ + +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + 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; + } + + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + if(libtest_arg3) + /* enable ascii/text mode */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, TRUE); + + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From 089668ec73d73d451c3b69fe16b2229a932f90c2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 8 Dec 2007 22:53:49 +0000 Subject: correct the comment about size --- tests/libtest/lib547.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 2d4011213..52f1e2039 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -87,9 +87,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); curl_easy_setopt(curl, CURLOPT_READDATA, &counter); - /* TODO: We should be able to do the POST fine without setting the size - and we should do a test to verify that but until we do that we set - the size of the request-body */ + /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); #endif curl_easy_setopt(curl, CURLOPT_POST, 1); -- cgit v1.2.1 From f277124a0f78327f6a973518c073d6a9a458326b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Dec 2007 21:48:52 +0000 Subject: In an attempt to repeat the problem in bug report #1850730 (http://curl.haxx.se/bug/view.cgi?id=1850730) I wrote up test case 552. The test is doing a 70K POST with a read callback and an ioctl callback over a proxy requiring Digest auth. The test case code is more or less identical to the test recipe code provided by Spacen Jasset (who submitted the bug report). --- tests/libtest/Makefile.am | 3 +- tests/libtest/lib552.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib552.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 1f9461fa2..7d9cb64aa 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 + lib544 lib545 lib547 lib548 lib549 lib552 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -146,3 +146,4 @@ lib548_CFLAGS = -DLIB548 lib549_SOURCES = lib549.c $(SUPPORTFILES) +lib552_SOURCES = lib552.c $(SUPPORTFILES) diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c new file mode 100644 index 000000000..a4b8dcda0 --- /dev/null +++ b/tests/libtest/lib552.c @@ -0,0 +1,194 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * argv1 = URL + * argv2 = proxy with embedded user+password + */ + +#include "test.h" + +struct data { + char trace_ascii; /* 1 or 0 */ +}; + +static +void dump(const char *text, + FILE *stream, unsigned char *ptr, size_t size, + char nohex) +{ + size_t i; + size_t c; + + unsigned int width=0x10; + + if(nohex) + /* without the hex output, we can fit more on screen */ + width = 0x40; + + fprintf(stream, "%s, %d bytes (0x%x)\n", text, (int)size, (int)size); + + for(i=0; i=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { + i+=(c+3-width); + break; + } + } + fputc('\n', stream); /* newline */ + } + fflush(stream); +} + +static +int my_trace(CURL *handle, curl_infotype type, + unsigned char *data, size_t size, + void *userp) +{ + struct data *config = (struct data *)userp; + const char *text; + (void)handle; /* prevent compiler warning */ + + switch (type) { + case CURLINFO_TEXT: + fprintf(stderr, "== Info: %s", data); + default: /* in case a new one is introduced to shock us */ + return 0; + + case CURLINFO_HEADER_OUT: + text = "=> Send header"; + break; + case CURLINFO_DATA_OUT: + text = "=> Send data"; + break; + case CURLINFO_SSL_DATA_OUT: + text = "=> Send SSL data"; + break; + case CURLINFO_HEADER_IN: + text = "<= Recv header"; + break; + case CURLINFO_DATA_IN: + text = "<= Recv data"; + break; + case CURLINFO_SSL_DATA_IN: + text = "<= Recv SSL data"; + break; + } + + dump(text, stderr, data, size, config->trace_ascii); + return 0; +} + + +static size_t current_offset = 0; +char data[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) +{ + size_t amount = nmemb * size; /* Total bytes curl wants */ + size_t available = sizeof data - current_offset; /* What we have to give */ + size_t given = amount < available ? amount : available; /* What is given */ + (void)stream; + memcpy(ptr, data + current_offset, given); + current_offset += given; + return given; +} + + +static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) +{ + printf("%.*s", size * nmemb, (char *)ptr); + (void)stream; + return size * nmemb; +} + + +static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp) +{ + (void)clientp; + if (cmd == CURLIOCMD_RESTARTREAD ) { + printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n"); + printf("APPLICATION: ** REWINDING! **\n"); + current_offset = 0; + return CURLIOE_OK; + } + (void)handle; + return CURLIOE_UNKNOWNCMD; +} + + + +int test(char *URL) +{ + CURL *curl; + CURLcode res; + struct data config; + size_t i; + char fill[] = "test data"; + + config.trace_ascii = 1; /* enable ascii tracing */ + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); + /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* setup repeated data string */ + for (i=0; i < sizeof data; ++i) + data[i] = fill[i % sizeof fill]; + + /* Post */ + curl_easy_setopt(curl, CURLOPT_POST, 1); + + /* Setup read callback */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof data); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* Write callback */ + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + + /* Ioctl function */ + curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); + + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */ + curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + + res = curl_easy_perform(curl); + fprintf(stderr, "curl_east_perform = %d\n", res); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} -- cgit v1.2.1 From 88d89b2177f3485723b18c22e9e6700f2bba592e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 4 Jan 2008 15:39:06 +0000 Subject: Fix 'format string' compiler warning --- tests/libtest/lib552.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index a4b8dcda0..8c6e2be37 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -76,7 +76,7 @@ int my_trace(CURL *handle, curl_infotype type, switch (type) { case CURLINFO_TEXT: - fprintf(stderr, "== Info: %s", data); + fprintf(stderr, "== Info: %s", (char *)data); default: /* in case a new one is introduced to shock us */ return 0; @@ -122,7 +122,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) { - printf("%.*s", size * nmemb, (char *)ptr); + printf("%.*s", (int)(size * nmemb), (char *)ptr); (void)stream; return size * nmemb; } @@ -185,7 +185,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); res = curl_easy_perform(curl); - fprintf(stderr, "curl_east_perform = %d\n", res); + fprintf(stderr, "curl_easy_perform = %d\n", (int)res); /* always cleanup */ curl_easy_cleanup(curl); -- cgit v1.2.1 From c522f349fe5c18f51cf658c35cee2ceb8a38fd46 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 16 Jan 2008 22:54:54 +0000 Subject: Added test 553. This test case and code is based on the bug recipe Joe Malicki provided for bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release. --- tests/libtest/Makefile.am | 6 ++-- tests/libtest/lib553.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/lib553.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 7d9cb64aa..a808a673f 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 + lib544 lib545 lib547 lib548 lib549 lib552 lib553 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -147,3 +147,5 @@ lib548_CFLAGS = -DLIB548 lib549_SOURCES = lib549.c $(SUPPORTFILES) lib552_SOURCES = lib552.c $(SUPPORTFILES) + +lib553_SOURCES = lib553.c $(SUPPORTFILES) diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c new file mode 100644 index 000000000..f9c118620 --- /dev/null +++ b/tests/libtest/lib553.c @@ -0,0 +1,74 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * This test case and code is based on the bug recipe Joe Malicki provided for + * bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release. + */ + +#include "test.h" + +#define POSTLEN 40960 + +static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream) +{ + static size_t total=POSTLEN; + static char buf[1024]; + (void)stream; + + memset(buf, 'A', sizeof(buf)); + + size *= nmemb; + if (size > total) + size = total; + + if(size > sizeof(buf)) + size = sizeof(buf); + + memcpy(ptr, buf, size); + total -= size; + return size; +} + +#define NUM_HEADERS 8 +#define SIZE_HEADERS 5000 + +static char buf[SIZE_HEADERS + 100]; +int test(char *URL) +{ + CURL *curl; + CURLcode res; + int i; + struct curl_slist *headerlist=NULL; + + curl_global_init(CURL_GLOBAL_ALL); + curl = curl_easy_init(); + + for (i = 0; i < NUM_HEADERS; i++) { + int len; + len = sprintf(buf, "Header%d: ", i); + memset(&buf[len], 'A', SIZE_HEADERS); + buf[len + SIZE_HEADERS]=0; /* zero terminate */ + headerlist = curl_slist_append(headerlist, buf); + } + headerlist = curl_slist_append(headerlist, "Expect: "); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); + curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, POSTLEN); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, 1); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + + curl_slist_free_all(headerlist); + + return (int)res; +} -- cgit v1.2.1 From 0530b0a5ca5e5a21054d7ba83354a230a76eab5b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 17 Jan 2008 18:57:50 +0000 Subject: Don't abort tests 518 and 537 when unable to raise the open-file soft limit --- tests/libtest/lib518.c | 17 ++++++++++++++++- tests/libtest/lib537.c | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 3b83ae378..22680688b 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -153,12 +153,27 @@ static int rlimit(int keep_open) if (rl.rlim_cur != rl.rlim_max) { +#ifdef OPEN_MAX + if ((rl.rlim_cur > 0) && + (rl.rlim_cur < OPEN_MAX)) { + fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); + rl.rlim_cur = OPEN_MAX; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ + store_errmsg("setrlimit() failed", ERRNO); + fprintf(stderr, "%s\n", msgbuff); + msgbuff[0] = '\0'; + } + } +#endif + fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); - return -2; + msgbuff[0] = '\0'; } /* get current open file limits */ diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index b4b2b7a93..1f5a34221 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -148,12 +148,27 @@ static int rlimit(int keep_open) if (rl.rlim_cur != rl.rlim_max) { +#ifdef OPEN_MAX + if ((rl.rlim_cur > 0) && + (rl.rlim_cur < OPEN_MAX)) { + fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); + rl.rlim_cur = OPEN_MAX; + if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ + store_errmsg("setrlimit() failed", ERRNO); + fprintf(stderr, "%s\n", msgbuff); + msgbuff[0] = '\0'; + } + } +#endif + fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + /* on failure don't abort just issue a warning */ store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); - return -2; + msgbuff[0] = '\0'; } /* get current open file limits */ -- cgit v1.2.1 From daadcfd1de6d6369e0f2c0c1bca528995196ffaf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 19 Jan 2008 10:14:45 +0000 Subject: Dmitry Kurochkin fixed test case 530 (pipelining) --- tests/libtest/lib530.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index e339ab2cf..5d4a9b3ef 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -32,6 +32,7 @@ int test(char *URL) struct timeval mp_start; char ml_timedout = FALSE; char mp_timedout = FALSE; + char target_url[80]; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -58,7 +59,9 @@ int test(char *URL) curl_global_cleanup(); return TEST_ERR_MAJOR_BAD + i; } - curl_easy_setopt(curl[i], CURLOPT_URL, URL); + snprintf(target_url, sizeof(target_url), "%s%04i", URL, i + 1); + target_url[sizeof(target_url) - 1] = '\0'; + curl_easy_setopt(curl[i], CURLOPT_URL, target_url); /* go verbose */ curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1); -- cgit v1.2.1 From a4eddf0d0dfb556f26201cc264a080f38e868f09 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 20 Jan 2008 22:53:56 +0000 Subject: use internal *printf() clones since snprintf() not available on all platforms --- tests/libtest/Makefile.am | 4 +++- tests/libtest/lib530.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a808a673f..a13f2454d 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -30,6 +30,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc # setup.h file INCLUDES = -I$(top_srcdir)/include/curl \ + -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib @@ -39,6 +40,7 @@ EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h +MPRINTF = $(top_srcdir)/lib/mprintf.c $(top_srcdir)/lib/mprintf.h # these files are used in every single test program below SUPPORTFILES = first.c test.h @@ -114,7 +116,7 @@ lib527_CFLAGS = -DLIB527 lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib529_CFLAGS = -DLIB529 -lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) +lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(MPRINTF) lib530_CFLAGS = -DLIB530 lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 5d4a9b3ef..cab4d8300 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -13,6 +13,9 @@ #include #include +#define ENABLE_CURLX_PRINTF +#include "curlx.h" + #include "testutil.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 -- cgit v1.2.1 From 3caeb0a91fbf7dfbae5a42257f225f9a9304256c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 21 Jan 2008 05:35:08 +0000 Subject: undo using internal *printf() clones for test #530 --- tests/libtest/Makefile.am | 4 +--- tests/libtest/lib530.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a13f2454d..a808a673f 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -30,7 +30,6 @@ AUTOMAKE_OPTIONS = foreign nostdinc # setup.h file INCLUDES = -I$(top_srcdir)/include/curl \ - -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib @@ -40,7 +39,6 @@ EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h -MPRINTF = $(top_srcdir)/lib/mprintf.c $(top_srcdir)/lib/mprintf.h # these files are used in every single test program below SUPPORTFILES = first.c test.h @@ -116,7 +114,7 @@ lib527_CFLAGS = -DLIB527 lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) lib529_CFLAGS = -DLIB529 -lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(MPRINTF) +lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) lib530_CFLAGS = -DLIB530 lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index cab4d8300..98eeb5273 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -10,11 +10,15 @@ #include "test.h" +#ifdef HAVE_SYS_TYPES_H #include +#endif +#ifdef HAVE_SYS_STAT_H #include - -#define ENABLE_CURLX_PRINTF -#include "curlx.h" +#endif +#ifdef HAVE_STRING_H +#include +#endif #include "testutil.h" @@ -35,7 +39,7 @@ int test(char *URL) struct timeval mp_start; char ml_timedout = FALSE; char mp_timedout = FALSE; - char target_url[80]; + char target_url[256]; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -62,7 +66,7 @@ int test(char *URL) curl_global_cleanup(); return TEST_ERR_MAJOR_BAD + i; } - snprintf(target_url, sizeof(target_url), "%s%04i", URL, i + 1); + sprintf(target_url, "%s%04i", URL, i + 1); target_url[sizeof(target_url) - 1] = '\0'; curl_easy_setopt(curl[i], CURLOPT_URL, target_url); -- cgit v1.2.1 From 7b9435890d135533e12110fc4f71ebe5dab33945 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 29 Jan 2008 23:10:25 +0000 Subject: add verbose output to test 509 for easier debugging --- tests/libtest/lib509.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 5d8edd266..6650149f9 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -225,6 +225,8 @@ int test(char *URL) curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYHOST, 1); + curl_easy_setopt(p.curl, CURLOPT_VERBOSE, 1); + if ((multi = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); curl_easy_cleanup(p.curl); -- cgit v1.2.1 From ce1649564c3dc5efc0d8958f77d9cbc6fb2f742d Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 8 Feb 2008 01:21:03 +0000 Subject: Added tests 1022 and 1023 to validate output of curl-config --version and --vernum --- tests/libtest/Makefile.am | 2 +- tests/libtest/test1013.pl | 5 +++-- tests/libtest/test1022.pl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100755 tests/libtest/test1022.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a808a673f..65c987d1e 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl +EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index b46e5ae3a..6127df82a 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -1,8 +1,9 @@ #!/usr/bin/env perl -# Determine if curl-config --protocols matches the curl --version protocols +# Determine if curl-config --protocols/--features matches the +# curl --version protocols/features if ( $#ARGV != 2 ) { - print "Usage: $0 curl-config-script curl-features-file features|protocols\n"; + print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n"; exit 3; } diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl new file mode 100755 index 000000000..73bfc5fc3 --- /dev/null +++ b/tests/libtest/test1022.pl @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +# Determine if curl-config --version matches the curl --version +if ( $#ARGV != 2 ) +{ + print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n"; + exit 3; +} + +my $what=$ARGV[2]; + +# Read the output of curl --version +open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n"; +$_ = ; +chomp; +/libcurl\/([\.\d]+(-CVS)?)/; +my $version = $1; +close CURL; + +my $curlconfigversion; + +# Read the output of curl-config --version/--vernum +open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n"; +$_ = ; +chomp; +if ( $what eq "version" ) { + /^libcurl ([\.\d]+(-CVS)?)$/ ; + $curlconfigversion = $1; +} +else { + # Convert hex version to decimal for comparison's sake + /^([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})$/ ; + $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); + + # Strip off the -CVS from the curl version if it's there + $version =~ s/-CVS$//; +} +close CURLCONFIG; + +my $different = $version ne $curlconfigversion; +if ($different || !$version) { + print "Mismatch in --version:\n"; + print "curl: $version\n"; + print "curl-config: $curlconfigversion\n"; + exit 1; +} -- cgit v1.2.1 From 11fae450fafdf65df0088052062fd3b86de805ee Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 13 Feb 2008 21:36:24 +0000 Subject: make this test disabled properly when built with yassl --- tests/libtest/lib509.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 6650149f9..6e5e67139 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -331,11 +331,14 @@ int test(char *URL) return i; } #endif /* YASSL_VERSION */ -#else /* USE_SSLEAY */ +#endif /* USE_SSLEAY */ + +#if !defined(USE_SSLEAY) || defined(YASSL_VERSION) int test(char *URL) { (void)URL; + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; -- cgit v1.2.1 From 55700cb01f4a01b8187f387e1655371e6fe0703a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Feb 2008 08:28:02 +0000 Subject: - We no longer support setting the CURLOPT_URL option from inside a callback such as the CURLOPT_SSL_CTX_FUNCTION one treat that as if it was a Location: following. The patch that introduced this feature was done for 7.11.0, but this code and functionality has been broken since about 7.15.4 (March 2006) with the introduction of non-blocking OpenSSL "connects". It was a hack to begin with and since it doesn't work and hasn't worked correctly for a long time and nobody has even noticed, I consider it a very suitable subject for plain removal. And so it was done. --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib509.c | 351 ---------------------------------------------- 2 files changed, 1 insertion(+), 354 deletions(-) delete mode 100644 tests/libtest/lib509.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 65c987d1e..8a9e3a42e 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -45,7 +45,7 @@ SUPPORTFILES = first.c test.h # These are all libcurl test programs noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ - lib507 lib508 lib509 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ + lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 @@ -73,8 +73,6 @@ lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) lib508_SOURCES = lib508.c $(SUPPORTFILES) -lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TESTUTIL) - lib510_SOURCES = lib510.c $(SUPPORTFILES) lib511_SOURCES = lib511.c $(SUPPORTFILES) diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c deleted file mode 100644 index 6e5e67139..000000000 --- a/tests/libtest/lib509.c +++ /dev/null @@ -1,351 +0,0 @@ -/***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * $Id$ - */ - -#include "test.h" - -#ifdef USE_SSLEAY - -#include - -#include -#include - -#ifndef YASSL_VERSION - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "testutil.h" - -#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 -#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 - -int portnum; /* the HTTPS port number we use */ - -typedef struct sslctxparm_st { - CURL* curl; - int accesstype; - unsigned char * accessinfoURL; -} sslctxparm; - - -static unsigned char *i2s_ASN1_IA5STRING( ASN1_IA5STRING *ia5) -{ - unsigned char *tmp; - if(!ia5 || !ia5->length) - return NULL; - tmp = OPENSSL_malloc(ia5->length + 1); - memcpy(tmp, ia5->data, ia5->length); - tmp[ia5->length] = 0; - return tmp; -} - -/* A conveniance routine to get an access URI. */ - -static unsigned char *my_get_ext(X509 * cert, const int type, - int extensiontype) -{ - int i; - STACK_OF(ACCESS_DESCRIPTION) * accessinfo ; - accessinfo = X509_get_ext_d2i(cert, extensiontype, NULL, NULL) ; - - if (!sk_ACCESS_DESCRIPTION_num(accessinfo)) - return NULL; - - for (i = 0; i < sk_ACCESS_DESCRIPTION_num(accessinfo); i++) { - ACCESS_DESCRIPTION * ad = sk_ACCESS_DESCRIPTION_value(accessinfo, i); - if (OBJ_obj2nid(ad->method) == type) { - if (ad->location->type == GEN_URI) { - return i2s_ASN1_IA5STRING(ad->location->d.ia5); - } - return NULL; - } - } - return NULL; -} - -void * globalparm = NULL; - -char newurl[512]; - -static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg) -{ - sslctxparm * p = (sslctxparm *) arg; - int ok, err; - - fprintf(stderr,"ssl_app_verify_callback sslctxparm=%p ctx=%p\n", - (void *)p, (void*)ctx); - -#if OPENSSL_VERSION_NUMBER<0x00907000L -/* not necessary in openssl 0.9.7 or later */ - - fprintf(stderr,"This version %s of openssl does not support a parm (%p)" - ", getting a global static %p \n", - OPENSSL_VERSION_TEXT, (void *)p, (void *)globalparm); - - p = globalparm; -#endif - -/* The following error should not occur. We test this to avoid segfault. */ - if (!p || !ctx) { - fprintf(stderr,"Internal error in ssl_app_verify_callback " - "sslctxparm=%p ctx=%p\n",(void *)p,(void*)ctx); - return 0; - } - - ok= X509_verify_cert(ctx); - err=X509_STORE_CTX_get_error(ctx); - -/* The following seems to be a problem in 0.9.7/8 openssl versions */ - -#if 1 - if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT || - err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { - fprintf(stderr,"X509_verify_cert: repairing self signed\n") ; - X509_STORE_CTX_set_error(ctx,X509_V_OK); - ok = 1; - } -#endif - - if (ok && ctx->cert) { - unsigned char * accessinfoURL ; - - accessinfoURL = my_get_ext(ctx->cert,p->accesstype ,NID_info_access); - if (accessinfoURL) { - - if (strcmp((char *)p->accessinfoURL, (char *)accessinfoURL)) { - fprintf(stderr, "Setting URL <%s>, was <%s>\n", - (char *)accessinfoURL, (char *)p->accessinfoURL); - OPENSSL_free(p->accessinfoURL); - p->accessinfoURL = accessinfoURL; - - /* We need to be able to deal with a custom port number, but the - URL in the cert uses a static one. We thus need to create a new - URL that uses the currently requested port number which may not - be the one this URL uses! */ - sprintf(newurl, "https://127.0.0.1:%d/509", portnum); - fprintf(stderr, "But *really* Setting URL <%s>\n", newurl); - - curl_easy_setopt(p->curl, CURLOPT_URL, newurl); - } - else - OPENSSL_free(accessinfoURL); - } - } - return(ok); -} - - -static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) -{ - sslctxparm * p = (sslctxparm *) parm; - - SSL_CTX * ctx = (SSL_CTX *) sslctx ; - fprintf(stderr,"sslctxfun start curl=%p ctx=%p parm=%p\n", - (void *)curl,(void *)ctx,(void *)p); - - SSL_CTX_set_quiet_shutdown(ctx,1); - SSL_CTX_set_cipher_list(ctx,"RC4-MD5"); - SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); - -/* one might assume that the cert validaton would not fail when setting this, - but it still does, see the error handling in the call back */ - - SSL_CTX_set_verify_depth(ctx,0); - SSL_CTX_set_verify(ctx,SSL_VERIFY_NONE,ZERO_NULL); - -#if OPENSSL_VERSION_NUMBER<0x00907000L -/* in newer openssl versions we can set a parameter for the call back. */ - fprintf(stderr,"This version %s of openssl does not support a parm," - " setting global one\n", OPENSSL_VERSION_TEXT); - /* this is only done to support 0.9.6 version */ - globalparm = parm; - -/* in 0.9.6 the parm is not taken */ -#endif - SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm); - fprintf(stderr,"sslctxfun end\n"); - - return CURLE_OK ; -} - -int test(char *URL) -{ - CURLM* multi; - sslctxparm p; - CURLMcode res; - int running; - char done = FALSE; - int i = 0; - CURLMsg *msg; - - struct timeval ml_start; - struct timeval mp_start; - char ml_timedout = FALSE; - char mp_timedout = FALSE; - - if(libtest_arg2) { - portnum = atoi(libtest_arg2); - } - - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - fprintf(stderr, "curl_global_init() failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - if ((p.curl = curl_easy_init()) == NULL) { - fprintf(stderr, "curl_easy_init() failed\n"); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - p.accessinfoURL = (unsigned char *) strdup(URL); - p.accesstype = OBJ_obj2nid(OBJ_txt2obj("AD_DVCS",0)) ; - - curl_easy_setopt(p.curl, CURLOPT_URL, p.accessinfoURL); - - curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun) ; - curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p); - - curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_easy_setopt(p.curl, CURLOPT_SSL_VERIFYHOST, 1); - - curl_easy_setopt(p.curl, CURLOPT_VERBOSE, 1); - - if ((multi = curl_multi_init()) == NULL) { - fprintf(stderr, "curl_multi_init() failed\n"); - curl_easy_cleanup(p.curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - if ((res = curl_multi_add_handle(multi, p.curl)) != CURLM_OK) { - fprintf(stderr, "curl_multi_add_handle() failed, " - "with code %d\n", res); - curl_multi_cleanup(multi); - curl_easy_cleanup(p.curl); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL); - - ml_timedout = FALSE; - ml_start = tutil_tvnow(); - - while (!done) { - fd_set rd, wr, exc; - int max_fd; - struct timeval interval; - - 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 = curl_multi_perform(multi, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) { - mp_timedout = TRUE; - break; - } - fprintf(stderr, "running=%d res=%d\n",running,res); - if (running <= 0) { - done = TRUE; - break; - } - } - if (mp_timedout || done) - break; - - if (res != CURLM_OK) { - fprintf(stderr, "not okay???\n"); - i = 80; - break; - } - - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&exc); - max_fd = 0; - - if (curl_multi_fdset(multi, &rd, &wr, &exc, &max_fd) != CURLM_OK) { - fprintf(stderr, "unexpected failured of fdset.\n"); - i = 89; - break; - } - - if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { - fprintf(stderr, "bad select??\n"); - i =95; - break; - } - - res = CURLM_CALL_MULTI_PERFORM; - } - - 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, &running); - /* this should now contain a result code from the easy handle, get it */ - if(msg) - i = msg->data.result; - fprintf(stderr, "all done\n"); - } - - curl_multi_remove_handle(multi, p.curl); - curl_easy_cleanup(p.curl); - curl_multi_cleanup(multi); - - curl_global_cleanup(); - free(p.accessinfoURL); - - return i; -} -#endif /* YASSL_VERSION */ -#endif /* USE_SSLEAY */ - -#if !defined(USE_SSLEAY) || defined(YASSL_VERSION) - -int test(char *URL) -{ - (void)URL; - - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - fprintf(stderr, "curl_global_init() failed\n"); - return TEST_ERR_MAJOR_BAD; - } - fprintf(stderr, "libcurl lacks openssl support needed for test 509\n"); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; -} - -#endif /* USE_SSLEAY */ -- cgit v1.2.1 From b12fef3f3137bc606d283a2e527dd9050edf2b12 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 27 Feb 2008 09:06:15 +0000 Subject: Michal Marek's cleanup of how curl_easy_setopt() is used in examples and test code. Thanks to his curl_easy_setopt() typechecker work... --- tests/libtest/lib506.c | 8 ++++---- tests/libtest/lib552.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index eaf96d2e9..4bec2884f 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -107,10 +107,10 @@ static void *fire(void *ptr) headers = sethost(NULL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, (void*)headers); - curl_easy_setopt(curl, CURLOPT_URL, (void*)tdata->url); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(curl, CURLOPT_URL, tdata->url); printf( "CURLOPT_SHARE\n" ); - curl_easy_setopt(curl, CURLOPT_SHARE, (void*)tdata->share); + curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); printf( "PERFORM\n" ); code = curl_easy_perform(curl); @@ -222,7 +222,7 @@ int test(char *URL) url = suburl( URL, i ); headers = sethost( NULL ); - curl_easy_setopt( curl, CURLOPT_HTTPHEADER, (void*)headers ); + curl_easy_setopt( curl, CURLOPT_HTTPHEADER, headers ); curl_easy_setopt( curl, CURLOPT_URL, url ); printf( "CURLOPT_SHARE\n" ); curl_easy_setopt( curl, CURLOPT_SHARE, share ); diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 8c6e2be37..3cfeffe73 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -67,7 +67,7 @@ void dump(const char *text, static int my_trace(CURL *handle, curl_infotype type, - unsigned char *data, size_t size, + char *data, size_t size, void *userp) { struct data *config = (struct data *)userp; @@ -100,7 +100,7 @@ int my_trace(CURL *handle, curl_infotype type, break; } - dump(text, stderr, data, size, config->trace_ascii); + dump(text, stderr, (unsigned char *)data, size, config->trace_ascii); return 0; } -- cgit v1.2.1 From 040a4443a1d36447535d45953d385a8d70f3b064 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 13 Mar 2008 22:51:39 +0000 Subject: Added tests 622-625 to test SFTP/SCP uploads. Test 625 was an attempt to reproduce the --ftp-create-dirs problem reported by Brian Ulm, but that seems to need a call curl_easy_reset() which this test case doesn't do. --- tests/libtest/test610.pl | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test610.pl b/tests/libtest/test610.pl index 5d7c1f6aa..4b6903a30 100755 --- a/tests/libtest/test610.pl +++ b/tests/libtest/test610.pl @@ -1,24 +1,33 @@ #!/usr/bin/env perl -# Create and remove directories and check their existence -if ( $#ARGV != 1 ) +# Perform simple file and directory manipulation in a portable way +if ( $#ARGV <= 0 ) { - print "Usage: $0 mkdir|rmdir|gone path\n"; + print "Usage: $0 mkdir|rmdir|unlink|move|gone path1 [path2] [more commands...]\n"; exit 1; } -if ($ARGV[0] eq "mkdir") -{ - mkdir $ARGV[1] || die "$!"; - exit 0; -} -elsif ($ARGV[0] eq "rmdir") -{ - rmdir $ARGV[1] || die "$!"; - exit 0; -} -elsif ($ARGV[0] eq "gone") -{ - ! -e $ARGV[1] || die "Path $ARGV[1] exists"; - exit 0; + +use File::Copy; +while(@ARGV) { + my $cmd = shift @ARGV; + my $arg = shift @ARGV; + if ($cmd eq "mkdir") { + mkdir $arg || die "$!"; + } + elsif ($cmd eq "rmdir") { + rmdir $arg || die "$!"; + } + elsif ($cmd eq "rm") { + unlink $arg || die "$!"; + } + elsif ($cmd eq "move") { + my $arg2 = shift @ARGV; + move($arg,$arg2) || die "$!"; + } + elsif ($cmd eq "gone") { + ! -e $arg || die "Path $arg exists"; + } else { + print "Unsupported command $cmd\n"; + exit 1; + } } -print "Unsupported command $ARGV[0]\n"; -exit 1; +exit 0; -- cgit v1.2.1 From 942daece0052301d9990989663b41d8c0d60da34 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Sat, 15 Mar 2008 01:03:23 +0000 Subject: Spell the commands right --- tests/libtest/test610.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test610.pl b/tests/libtest/test610.pl index 4b6903a30..5257171a7 100755 --- a/tests/libtest/test610.pl +++ b/tests/libtest/test610.pl @@ -2,7 +2,7 @@ # Perform simple file and directory manipulation in a portable way if ( $#ARGV <= 0 ) { - print "Usage: $0 mkdir|rmdir|unlink|move|gone path1 [path2] [more commands...]\n"; + print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n"; exit 1; } -- cgit v1.2.1 From 7f7b643c0d2a3eb972e390281fe8ca896e891e5d Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 28 Mar 2008 18:19:11 +0000 Subject: Made the test work on perl 5.00 --- tests/libtest/test1022.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index 73bfc5fc3..5b16de3e0 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -28,7 +28,7 @@ if ( $what eq "version" ) { } else { # Convert hex version to decimal for comparison's sake - /^([[:xdigit:]]{2})([[:xdigit:]]{2})([[:xdigit:]]{2})$/ ; + /^(..)(..)(..)$/ ; $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); # Strip off the -CVS from the curl version if it's there -- cgit v1.2.1 From a2314225e02ea2f3bd49dc8557f2452846e49b19 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 31 Mar 2008 10:02:23 +0000 Subject: - Added CURLFORM_STREAM as a supported option to curl_formadd() to allow an application to provide data for a multipart with the read callback. Note that the size needs to be provided with CURLFORM_CONTENTSLENGTH when the stream option is used. This feature is verified by the new test case 554. This feature was sponsored by Xponaut. --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib554.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib554.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 8a9e3a42e..c6e6910cf 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 lib553 + lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -147,3 +147,5 @@ lib549_SOURCES = lib549.c $(SUPPORTFILES) lib552_SOURCES = lib552.c $(SUPPORTFILES) lib553_SOURCES = lib553.c $(SUPPORTFILES) + +lib554_SOURCES = lib554.c $(SUPPORTFILES) diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c new file mode 100644 index 000000000..f04bc811a --- /dev/null +++ b/tests/libtest/lib554.c @@ -0,0 +1,130 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +static char data[]="this is what we post to the silly web server\n"; + +struct WriteThis { + char *readptr; + size_t sizeleft; +}; + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *)userp; + + if(size*nmemb < 1) + return 0; + + if(pooh->sizeleft) { + *(char *)ptr = pooh->readptr[0]; /* copy one single byte */ + pooh->readptr++; /* advance pointer */ + pooh->sizeleft--; /* less data left */ + return 1; /* we return 1 byte at a time! */ + } + + return 0; /* no more data left to deliver */ +} + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + CURLFORMcode formrc; + + struct curl_httppost *formpost=NULL; + struct curl_httppost *lastptr=NULL; + struct WriteThis pooh; + + pooh.readptr = data; + pooh.sizeleft = strlen(data); + + curl_global_init(CURL_GLOBAL_ALL); + + /* Fill in the file upload field */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile", + CURLFORM_STREAM, &pooh, + CURLFORM_CONTENTSLENGTH, pooh.sizeleft, + CURLFORM_FILENAME, "postit2.c", + CURLFORM_END); + + if(formrc) + printf("curl_formadd(1) = %d\n", formrc); + + /* Fill in the filename field */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "filename", + CURLFORM_COPYCONTENTS, "postit2.c", + CURLFORM_END); + + if(formrc) + printf("curl_formadd(2) = %d\n", formrc); + + /* Fill in a submit field too */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "submit", + CURLFORM_COPYCONTENTS, "send", + CURLFORM_END); + + if(formrc) + printf("curl_formadd(3) = %d\n", formrc); + + 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; + } + + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); + + /* Set the expected POST size */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_READDATA, &pooh); + + /* send a multi-part formpost */ + curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* include headers in the output */ + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + + /* now cleanup the formpost chain */ + curl_formfree(formpost); + + return res; +} -- cgit v1.2.1 From 6fd3ff40323cebc5181a279df124847e2ecc4310 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 7 Apr 2008 15:40:49 +0000 Subject: fix compiler warning: argument is incompatible with corresponding format string conversion --- tests/libtest/lib554.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index f04bc811a..01a5903ea 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -59,7 +59,7 @@ int test(char *URL) CURLFORM_END); if(formrc) - printf("curl_formadd(1) = %d\n", formrc); + printf("curl_formadd(1) = %d\n", (int)formrc); /* Fill in the filename field */ formrc = curl_formadd(&formpost, @@ -69,7 +69,7 @@ int test(char *URL) CURLFORM_END); if(formrc) - printf("curl_formadd(2) = %d\n", formrc); + printf("curl_formadd(2) = %d\n", (int)formrc); /* Fill in a submit field too */ formrc = curl_formadd(&formpost, @@ -79,7 +79,7 @@ int test(char *URL) CURLFORM_END); if(formrc) - printf("curl_formadd(3) = %d\n", formrc); + printf("curl_formadd(3) = %d\n", (int)formrc); if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); -- cgit v1.2.1 From 03310713467b678812067b3edab82b23ed6b1c04 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 16 Apr 2008 21:11:46 +0000 Subject: Added test case 555, a variation of 547 but using multi interface instead of easy. This was reported not working by Penugonda Chenna Reddy in http://curl.haxx.se/mail/lib-2008-04/0046.html but I fail to repeat that problem. --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib555.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib555.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c6e6910cf..47864eb30 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 + lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -144,6 +144,8 @@ lib548_CFLAGS = -DLIB548 lib549_SOURCES = lib549.c $(SUPPORTFILES) +lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) + lib552_SOURCES = lib552.c $(SUPPORTFILES) lib553_SOURCES = lib553.c $(SUPPORTFILES) diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c new file mode 100644 index 000000000..bfc29fce8 --- /dev/null +++ b/tests/libtest/lib555.c @@ -0,0 +1,147 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * This test case is supposed to be identical to 547 except that this uses the + * multi interface and 547 is easy interface. + * + * argv1 = URL + * argv2 = proxy + * argv3 = proxyuser:password + */ + +#include "test.h" +#include "testutil.h" + +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 + +#define UPLOADTHIS "this is the blurb we want to upload\n" + +static size_t readcallback(void *ptr, + size_t size, + size_t nmemb, + void *clientp) +{ + int *counter = (int *)clientp; + + if(*counter) { + /* only do this once and then require a clearing of this */ + fprintf(stderr, "READ ALREADY DONE!\n"); + return 0; + } + (*counter)++; /* bump */ + + if(size * nmemb > strlen(UPLOADTHIS)) { + fprintf(stderr, "READ!\n"); + strcpy(ptr, UPLOADTHIS); + return strlen(UPLOADTHIS); + } + fprintf(stderr, "READ NOT FINE!\n"); + return 0; +} +static curlioerr ioctlcallback(CURL *handle, + int cmd, + void *clientp) +{ + int *counter = (int *)clientp; + (void)handle; /* unused */ + if(cmd == CURLIOCMD_RESTARTREAD) { + fprintf(stderr, "REWIND!\n"); + *counter = 0; /* clear counter to make the read callback restart */ + } + return CURLIOE_OK; +} + + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + int counter=0; + CURLM *m; + 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; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + + /* read the POST data from a callback */ + curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); + curl_easy_setopt(curl, CURLOPT_READDATA, &counter); + /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); + + curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); + curl_easy_setopt(curl, CURLOPT_PROXYAUTH, + 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; + } + + 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(); + + 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; + } + } + + 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; + } + + curl_multi_remove_handle(m, curl); + curl_easy_cleanup(curl); + curl_multi_cleanup(m); + + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From 6c89e1b3114e51ea3c7feae2133c6efdbb9c8b16 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 17 Apr 2008 11:59:46 +0000 Subject: fix compiler warning: enumerated type mixed with another type --- tests/libtest/lib555.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index bfc29fce8..ed12c5a44 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -60,7 +60,7 @@ static curlioerr ioctlcallback(CURL *handle, int test(char *URL) { - CURLcode res; + int res; CURL *curl; int counter=0; CURLM *m; @@ -142,6 +142,6 @@ int test(char *URL) curl_global_cleanup(); - return (int)res; + return res; } -- cgit v1.2.1 From 72c58b0d1d415a2c89c7cf1fbaba00713ca77369 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 18 Apr 2008 17:17:14 +0000 Subject: test 1001 needs a small delay between client part execution and test result file verifications to allow the test server to completely write out all files --- tests/libtest/delay.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 tests/libtest/delay.pl (limited to 'tests/libtest') diff --git a/tests/libtest/delay.pl b/tests/libtest/delay.pl new file mode 100755 index 000000000..219b86812 --- /dev/null +++ b/tests/libtest/delay.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +# sleep for a number of seconds +if ( $#ARGV != 0 ) +{ + print "Usage: $0 seconds\n"; + exit 1; +} +if ( $ARGV[0] =~ /(\d+)/ ) { + sleep $1; + exit 0; +} +else { + print "Usage: $0 seconds\n"; + exit 1; +} + -- cgit v1.2.1 From d3f46eb61b4e405fbcc120df253cd3ac3fe2b155 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 18 Apr 2008 17:25:54 +0000 Subject: test 1001 needs a small delay between client part execution and test result file verifications to allow the test server to completely write out all files --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 47864eb30..fe40e53f9 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl +EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl delay.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h -- cgit v1.2.1 From b8193b63216316c58501474e5ebd3ee14ac9349b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 25 Apr 2008 11:01:26 +0000 Subject: tests/libtest/delay.pl no longer used. The 'delay' attribute of the test harness subsection now provides this functionality. --- tests/libtest/Makefile.am | 2 +- tests/libtest/delay.pl | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100755 tests/libtest/delay.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index fe40e53f9..47864eb30 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,7 +35,7 @@ INCLUDES = -I$(top_srcdir)/include/curl \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl delay.pl +EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h diff --git a/tests/libtest/delay.pl b/tests/libtest/delay.pl deleted file mode 100755 index 219b86812..000000000 --- a/tests/libtest/delay.pl +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env perl -# sleep for a number of seconds -if ( $#ARGV != 0 ) -{ - print "Usage: $0 seconds\n"; - exit 1; -} -if ( $ARGV[0] =~ /(\d+)/ ) { - sleep $1; - exit 0; -} -else { - print "Usage: $0 seconds\n"; - exit 1; -} - -- cgit v1.2.1 From 19479ea0217c93fd2973168084d1bb724eb8a34f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 9 May 2008 16:31:51 +0000 Subject: Internal time differences now use monotonic time source if available. This also implies the removal of the winmm.lib dependency for WIN32. --- tests/libtest/testutil.c | 103 ++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 51 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 146660c71..8ed2b2f08 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,69 +25,70 @@ #include "testutil.h" -#ifndef HAVE_GETTIMEOFDAY +#if defined(WIN32) && !defined(MSDOS) -#ifdef WIN32 -#include - -static int gettimeofday(struct timeval *tp, void *nothing) +struct timeval tutil_tvnow(void) { -#ifdef WITHOUT_MM_LIB - SYSTEMTIME st; - time_t tt; - struct tm tmtm; - /* mktime converts local to UTC */ - GetLocalTime (&st); - tmtm.tm_sec = st.wSecond; - tmtm.tm_min = st.wMinute; - tmtm.tm_hour = st.wHour; - tmtm.tm_mday = st.wDay; - tmtm.tm_mon = st.wMonth - 1; - tmtm.tm_year = st.wYear - 1900; - tmtm.tm_isdst = -1; - tt = mktime (&tmtm); - tp->tv_sec = tt; - tp->tv_usec = st.wMilliseconds * 1000; -#else - /** - ** The earlier time calculations using GetLocalTime - ** had a time resolution of 10ms.The timeGetTime, part - ** of multimedia apis offer a better time resolution - ** of 1ms.Need to link against winmm.lib for this - **/ - unsigned long Ticks = 0; - unsigned long Sec =0; - unsigned long Usec = 0; - Ticks = timeGetTime(); - - Sec = Ticks/1000; - Usec = (Ticks - (Sec*1000))*1000; - tp->tv_sec = Sec; - tp->tv_usec = Usec; -#endif /* WITHOUT_MM_LIB */ - (void)nothing; - return 0; + /* + ** GetTickCount() is available on _all_ Windows versions from W95 up + ** to nowadays. Returns milliseconds elapsed since last system boot, + ** increases monotonically and wraps once 49.7 days have elapsed. + */ + struct timeval now; + DWORD milliseconds = GetTickCount(); + now.tv_sec = milliseconds / 1000; + now.tv_usec = (milliseconds % 1000) * 1000; + return now; } -#else /* WIN32 */ -/* non-win32 version of Curl_gettimeofday() */ -static int gettimeofday(struct timeval *tp, void *nothing) + +#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) + +struct timeval tutil_tvnow(void) { - (void)nothing; /* we don't support specific time-zones */ - tp->tv_sec = (long)time(NULL); - tp->tv_usec = 0; - return 0; + /* + ** clock_gettime() is granted to be increased monotonically when the + ** monotonic clock is queried. Time starting point is unspecified, it + ** could be the system start-up time, the Epoch, or something else, + ** in any case the time starting point does not change once that the + ** system has started up. + */ + struct timeval now; + struct timespec tsnow; + (void)clock_gettime(CLOCK_MONOTONIC, &tsnow) + now.tv_sec = tsnow.tv_sec; + now.tv_usec = tsnow.tv_nsec / 1000; + return now; } -#endif /* WIN32 */ -#endif /* HAVE_GETTIMEOFDAY */ -/* Return the current time in a timeval struct */ +#elif defined(HAVE_GETTIMEOFDAY) + struct timeval tutil_tvnow(void) { + /* + ** gettimeofday() is not granted to be increased monotonically, due to + ** clock drifting and external source time synchronization it can jump + ** forward or backward in time. + */ struct timeval now; (void)gettimeofday(&now, NULL); return now; } +#else + +struct timeval tutil_tvnow(void) +{ + /* + ** time() returns the value of time in seconds since the Epoch. + */ + struct timeval now; + now.tv_sec = (long)time(NULL); + now.tv_usec = 0; + return now; +} + +#endif + /* * Make sure that the first argument is the more recent time, as otherwise * we'll get a weird negative time-diff back... -- cgit v1.2.1 From 60dd765b3dd73bd957bff42a990ba391c843a9ff Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 10 May 2008 23:50:55 +0000 Subject: fix syntax error: missing semicolon --- tests/libtest/testutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 8ed2b2f08..df90cdccb 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -54,7 +54,7 @@ struct timeval tutil_tvnow(void) */ struct timeval now; struct timespec tsnow; - (void)clock_gettime(CLOCK_MONOTONIC, &tsnow) + (void)clock_gettime(CLOCK_MONOTONIC, &tsnow); now.tv_sec = tsnow.tv_sec; now.tv_usec = tsnow.tv_nsec / 1000; return now; -- cgit v1.2.1 From ed80eb5b0f11d70db37e8a3b0406fa906842a962 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 12 May 2008 02:04:21 +0000 Subject: configure script will now define HAVE_CLOCK_GETTIME_MONOTONIC symbol only when function clock_gettime() is available and the monotonic timer is also available. Otherwise, in some cases, librt or libposix4 could be used for linking even when finally not using the clock_gettime() function due to lack of the monotonic clock. --- tests/libtest/testutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index df90cdccb..435b30e09 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -41,7 +41,7 @@ struct timeval tutil_tvnow(void) return now; } -#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) +#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) struct timeval tutil_tvnow(void) { -- cgit v1.2.1 From 7f88e8badbb6359911cb1c2e6df4ec30f09c0fb0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 13 May 2008 21:42:07 +0000 Subject: Added test case 556 that uses curl_easy_send() and curl_easy_recv() --- tests/libtest/Makefile.am | 4 ++- tests/libtest/lib556.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib556.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 47864eb30..ff4532c9c 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 + lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -151,3 +151,5 @@ lib552_SOURCES = lib552.c $(SUPPORTFILES) lib553_SOURCES = lib553.c $(SUPPORTFILES) lib554_SOURCES = lib554.c $(SUPPORTFILES) + +lib556_SOURCES = lib556.c $(SUPPORTFILES) diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c new file mode 100644 index 000000000..12a1188ae --- /dev/null +++ b/tests/libtest/lib556.c @@ -0,0 +1,67 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + 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; + } + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); + + res = curl_easy_perform(curl); + + if(!res) { + /* we are connected, now get a HTTP document the raw way */ + const char *request = "GET /556 HTTP/1.2\r\n" + "Host: ninja\r\n\r\n"; + size_t iolen; + char buf[1024]; + + res = curl_easy_send(curl, request, strlen(request), &iolen); + + if(!res) { + /* we assume that sending always work */ + int total=0; + + do { + /* busy-read like crazy */ + res = curl_easy_recv(curl, buf, 1024, &iolen); + + if(iolen) + /* send received stuff to stdout */ + write(STDOUT_FILENO, buf, iolen); + + total += iolen; + + } while((res == CURLE_AGAIN) && (total < 20)); + } + } + + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From c1dfe2c52969e722a210f7e09f5bb7f346ef27da Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 13 May 2008 21:43:37 +0000 Subject: wait for all 129 bytes --- tests/libtest/lib556.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 12a1188ae..22583a236 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -54,7 +54,7 @@ int test(char *URL) total += iolen; - } while((res == CURLE_AGAIN) && (total < 20)); + } while((res == CURLE_AGAIN) && (total < 129)); } } -- cgit v1.2.1 From d31da176eb622fb386a3b657d17921403f95e45c Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 22 May 2008 21:49:52 +0000 Subject: Made sure to pass longs in to curl_easy_setopt where necessary in the libtest code. --- tests/libtest/lib500.c | 2 +- tests/libtest/lib501.c | 2 +- tests/libtest/lib503.c | 4 ++-- tests/libtest/lib504.c | 2 +- tests/libtest/lib505.c | 4 ++-- tests/libtest/lib506.c | 2 +- tests/libtest/lib508.c | 6 +++--- tests/libtest/lib510.c | 6 +++--- tests/libtest/lib511.c | 6 +++--- tests/libtest/lib512.c | 4 ++-- tests/libtest/lib513.c | 8 ++++---- tests/libtest/lib514.c | 10 +++++----- tests/libtest/lib515.c | 6 +++--- tests/libtest/lib516.c | 4 ++-- tests/libtest/lib518.c | 2 +- tests/libtest/lib519.c | 4 ++-- tests/libtest/lib520.c | 4 ++-- tests/libtest/lib521.c | 2 +- tests/libtest/lib523.c | 4 ++-- tests/libtest/lib524.c | 4 ++-- tests/libtest/lib525.c | 4 ++-- tests/libtest/lib526.c | 4 ++-- tests/libtest/lib530.c | 6 +++--- tests/libtest/lib536.c | 6 +++--- tests/libtest/lib537.c | 2 +- tests/libtest/lib540.c | 6 +++--- tests/libtest/lib541.c | 4 ++-- tests/libtest/lib542.c | 6 +++--- tests/libtest/lib544.c | 6 +++--- tests/libtest/lib547.c | 10 +++++----- tests/libtest/lib549.c | 6 +++--- tests/libtest/lib552.c | 8 ++++---- tests/libtest/lib553.c | 8 ++++---- tests/libtest/lib554.c | 6 +++--- tests/libtest/lib555.c | 8 ++++---- 35 files changed, 88 insertions(+), 88 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 9ee164e2c..d22aecdbc 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -27,7 +27,7 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index a4d78159d..cf2d95724 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -28,7 +28,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 327402242..5eda5996e 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -52,8 +52,8 @@ int test(char *URL) curl_easy_setopt(c, CURLOPT_URL, URL); curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); - curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1); - curl_easy_setopt(c, CURLOPT_HEADER, 1); + curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); + curl_easy_setopt(c, CURLOPT_HEADER, 1L); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index a6e988657..a57a3d157 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -55,7 +55,7 @@ int test(char *URL) proxy port */ curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(c, CURLOPT_URL, URL); - curl_easy_setopt(c, CURLOPT_VERBOSE, 1); + curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index d2698faa9..eec2071c9 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -116,10 +116,10 @@ int test(char *URL) headerlist = hl; /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* specify target */ curl_easy_setopt(curl,CURLOPT_URL, URL); diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 4bec2884f..cadd2ee63 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -106,7 +106,7 @@ static void *fire(void *ptr) } headers = sethost(NULL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_URL, tdata->url); printf( "CURLOPT_SHARE\n" ); diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index ecbc41912..35679d180 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -59,7 +59,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Set the expected POST size */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); @@ -71,10 +71,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 53797473c..d8644c3fa 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -74,7 +74,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); @@ -83,10 +83,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* enforce chunked transfer by setting the header */ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 7fcdebf93..b0f455d59 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -27,9 +27,9 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_FILETIME, 1); - curl_easy_setopt(curl, CURLOPT_NOBODY, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); + curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index 1d7d02a6a..0af95919b 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -26,8 +26,8 @@ int test(char *URL) curl = curl_easy_init(); if(curl) { - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_HEADER, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); curl2 = curl_easy_duphandle(curl); if(curl2) { diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index 4cb593cec..d6f3756b7 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -39,10 +39,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L); /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); @@ -51,10 +51,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_INFILE, NULL); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 93d576fbd..419b8422a 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -39,16 +39,16 @@ int test(char *URL) */ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3); - curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* this is where transfer 1 would take place, but skip that and change options right away instead */ - curl_easy_setopt(curl, CURLOPT_NOBODY, 1); + curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Now, we should be making a fine HEAD request */ diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index 6086ecb09..18df7c938 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -29,9 +29,9 @@ int test(char *URL) /* First set the URL that is about to receive our POST. */ curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Now, we should be making a zero byte POST request */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index 5eaa140e6..8295699e3 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -29,8 +29,8 @@ int test(char *URL) /* First set the URL that is about to receive our POST. */ curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Now, we should be making a zero byte POST request */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 22680688b..41c3fe282 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -483,7 +483,7 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index 58f38150d..ce440485a 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -28,8 +28,8 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed"); - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* get first page */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index a673007a6..46cad415d 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -27,8 +27,8 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_FILETIME, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 7301e3cd1..346ece056 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -29,7 +29,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index c6c8e2e31..9f485ffed 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -28,9 +28,9 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_PORT, 19999); + curl_easy_setopt(curl, CURLOPT_PORT, 19999L); curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index 55f29784c..2fde663ca 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -27,8 +27,8 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 222f8c278..154c209e3 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -71,13 +71,13 @@ int test(char *URL) } /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ curl_easy_setopt(curl,CURLOPT_URL, URL); /* go verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* use active FTP */ curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index ba3fff7bd..8951a7444 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -74,7 +74,7 @@ int test(char *URL) curl_easy_setopt(curl[i], CURLOPT_URL, URL); /* go verbose */ - curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); } if ((m = curl_multi_init()) == NULL) { @@ -142,7 +142,7 @@ int test(char *URL) the handle first too */ curl_easy_reset(curl[0]); curl_easy_setopt(curl[0], CURLOPT_URL, URL); - curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1L); /* re-add it */ res = (int)curl_multi_add_handle(m, curl[0]); diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 98eeb5273..af7d00d02 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -71,10 +71,10 @@ int test(char *URL) curl_easy_setopt(curl[i], CURLOPT_URL, target_url); /* go verbose */ - curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); /* include headers */ - curl_easy_setopt(curl[i], CURLOPT_HEADER, 1); + curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L); /* add handle to multi */ if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) { @@ -91,7 +91,7 @@ int test(char *URL) } } - curl_multi_setopt(m, CURLMOPT_PIPELINING, 1); + curl_multi_setopt(m, CURLMOPT_PIPELINING, 1L); ml_timedout = FALSE; ml_start = tutil_tvnow(); diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 29e599fcd..9e764a97a 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -90,10 +90,10 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1); + curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L); curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); - curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); + curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L); curl_easy_setopt(easy, CURLOPT_URL, URL); if (curl_multi_add_handle(multi, easy) != CURLM_OK) { @@ -107,7 +107,7 @@ int test(char *URL) } curl_easy_reset(easy); - curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1); + curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L); curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2); if (curl_multi_add_handle(multi, easy) != CURLM_OK) { diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 1f5a34221..f3b42e755 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -486,7 +486,7 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 4560eb815..089fcd5cb 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -30,9 +30,9 @@ static void init(CURLM *cm, const char* url, const char* userpwd, curl_easy_setopt(eh, CURLOPT_URL, url); curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); - curl_easy_setopt(eh, CURLOPT_PROXYAUTH, CURLAUTH_ANY); - curl_easy_setopt(eh, CURLOPT_VERBOSE, 1); - curl_easy_setopt(eh, CURLOPT_HEADER, 1); + curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); + curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(eh, CURLOPT_HEADER, 1L); curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ curl_multi_add_handle(cm, eh); diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index 71d2e38ed..a2224ae69 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -89,10 +89,10 @@ int test(char *URL) } /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* specify target */ curl_easy_setopt(curl,CURLOPT_URL, URL); diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index deb229d19..ffd8f361c 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -50,13 +50,13 @@ int test(char *URL) } /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE) ; + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* enable NOBODY */ - curl_easy_setopt(curl, CURLOPT_NOBODY, TRUE) ; + curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); /* disable HEADER */ - curl_easy_setopt(curl, CURLOPT_HEADER, FALSE) ; + curl_easy_setopt(curl, CURLOPT_HEADER, 0L); /* specify target */ curl_easy_setopt(curl,CURLOPT_URL, URL); diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index bde630d6b..f91cef354 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -35,13 +35,13 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); #ifdef LIB545 - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof teststring - 1); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1); #endif curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1); /* include header */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Update the original data to detect non-copy. */ strcpy(teststring, "FAIL"); diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 52f1e2039..85f22fe8e 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -76,8 +76,8 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); #ifdef LIB548 /* set the data to POST with a mere pointer to a zero-terminated string */ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); @@ -88,13 +88,13 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); curl_easy_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); #endif - curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); curl_easy_setopt(curl, CURLOPT_PROXYAUTH, - CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC ); + (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index 1ffef002b..d50835624 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -32,11 +32,11 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE); + curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); if(libtest_arg3) /* enable ascii/text mode */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, TRUE); + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 3cfeffe73..5a0eb1c68 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -158,17 +158,17 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* setup repeated data string */ for (i=0; i < sizeof data; ++i) data[i] = fill[i % sizeof fill]; /* Post */ - curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Setup read callback */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof data); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof data); curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* Write callback */ @@ -182,7 +182,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */ - curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); res = curl_easy_perform(curl); fprintf(stderr, "curl_easy_perform = %d\n", (int)res); diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index f9c118620..7af25e5bb 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -60,10 +60,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); - curl_easy_setopt(curl, CURLOPT_POST, 1); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, POSTLEN); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_HEADER, 1); + curl_easy_setopt(curl, CURLOPT_POST, 1L); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 01a5903ea..792bbbed2 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -96,7 +96,7 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Set the expected POST size */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); @@ -111,10 +111,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index ed12c5a44..ad259e0e6 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -80,8 +80,8 @@ int test(char *URL) } curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_HEADER, TRUE); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* read the POST data from a callback */ curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); @@ -91,11 +91,11 @@ int test(char *URL) /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); - curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); curl_easy_setopt(curl, CURLOPT_PROXYAUTH, - CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC ); + (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); -- cgit v1.2.1 From 930a45e7a93c964ec224bdddb59f97479b7e4a5d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 6 Jun 2008 17:33:35 +0000 Subject: - Added CURLINFO_PRIMARY_IP as a new information retrievable with curl_easy_getinfo. It returns a pointer to a string with the most recently used IP address. Modified test case 500 to also verify this feature. The implementing of this feature was sponsored by Lenny Rachitsky at NeuStar. --- tests/libtest/lib500.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index d22aecdbc..c28f5d0c9 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -14,6 +14,7 @@ int test(char *URL) { CURLcode res; CURL *curl; + char *ipstr=NULL; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -31,7 +32,17 @@ int test(char *URL) res = curl_easy_perform(curl); - curl_easy_cleanup(curl); + if(!res) { + FILE *moo; + res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr); + moo = fopen(libtest_arg2, "wb"); + if(moo) { + fprintf(moo, "IP: %s\n", ipstr); + fclose(moo); + } + } + + curl_easy_cleanup(curl); curl_global_cleanup(); return (int)res; -- cgit v1.2.1 From 0e5da5b8bc8861f4c21521d154c4ef5d3cd96609 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 7 Jul 2008 20:37:07 +0000 Subject: - Scott Barrett provided a test case for a segfault in the FTP code and the fix for it. It occured when you did a FTP transfer using CURLFTPMETHOD_SINGLECWD and then did another one on the same easy handle but switched to CURLFTPMETHOD_NOCWD. Due to the "dir depth" variable not being cleared properly. Scott's test case is now known as test 539 and it verifies the fix. --- tests/libtest/Makefile.am | 5 +++- tests/libtest/lib539.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib539.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index ff4532c9c..52e49b944 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,7 +48,8 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 + lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ + lib539 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -124,6 +125,8 @@ lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) lib537_SOURCES = lib537.c $(SUPPORTFILES) +lib539_SOURCES = lib539.c $(SUPPORTFILES) + lib540_SOURCES = lib540.c $(SUPPORTFILES) lib541_SOURCES = lib541.c $(SUPPORTFILES) diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c new file mode 100644 index 000000000..0e43654ef --- /dev/null +++ b/tests/libtest/lib539.c @@ -0,0 +1,65 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + char *newURL; + struct curl_slist *slist; + + 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; + } + + /* + * Begin with cURL set to use a single CWD to the URL's directory. + */ + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); + + res = curl_easy_perform(curl); + + /* + * Change the FTP_FILEMETHOD option to use full paths rather than a CWD + * command. Alter the URL's path a bit, appending a "./". Use an innocuous + * QUOTE command, after which cURL will CWD to ftp_conn->entrypath and then + * (on the next call to ftp_statemach_act) find a non-zero ftpconn->dirdepth + * even though no directories are stored in the ftpconn->dirs array (after a + * call to freedirs). + */ + newURL = strcat (strcpy ((char*)malloc (strlen (URL) + 3), + URL), + "./"); + slist = curl_slist_append (NULL, "SYST"); + + curl_easy_setopt(curl, CURLOPT_URL, newURL); + curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); + curl_easy_setopt(curl, CURLOPT_QUOTE, slist); + + res = curl_easy_perform(curl); + + curl_slist_free_all(slist); + free(newURL); + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} -- cgit v1.2.1 From 60f0b4fffe3de8eb1a1fc3015c2f6643fdccb57a Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 8 Jul 2008 21:16:18 +0000 Subject: Fixed test 554 to pass the torture test. --- tests/libtest/lib554.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 792bbbed2..fe0c16a66 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -44,11 +44,14 @@ int test(char *URL) struct curl_httppost *lastptr=NULL; struct WriteThis pooh; + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + pooh.readptr = data; pooh.sizeleft = strlen(data); - curl_global_init(CURL_GLOBAL_ALL); - /* Fill in the file upload field */ formrc = curl_formadd(&formpost, &lastptr, @@ -81,13 +84,9 @@ int test(char *URL) if(formrc) printf("curl_formadd(3) = %d\n", (int)formrc); - 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_formfree(formpost); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } -- cgit v1.2.1 From d8f109176c909c3cca72c6b23d557b9a30f0c666 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 10 Jul 2008 07:16:45 +0000 Subject: fallback to gettimeofday when monotonic clock is unavailable at run-time --- tests/libtest/testutil.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 435b30e09..573e6faed 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -54,9 +54,24 @@ struct timeval tutil_tvnow(void) */ struct timeval now; struct timespec tsnow; - (void)clock_gettime(CLOCK_MONOTONIC, &tsnow); - now.tv_sec = tsnow.tv_sec; - now.tv_usec = tsnow.tv_nsec / 1000; + if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) { + now.tv_sec = tsnow.tv_sec; + now.tv_usec = tsnow.tv_nsec / 1000; + } + /* + ** Even when the configure process has truly detected monotonic clock + ** availability, it might happen that it is not actually available at + ** run-time. When this occurs simply fallback to other time source. + */ +#ifdef HAVE_GETTIMEOFDAY + else + (void)gettimeofday(&now, NULL); +#else + else { + now.tv_sec = (long)time(NULL); + now.tv_usec = 0; + } +#endif return now; } -- cgit v1.2.1 From 336992cc54583b4ca949401d93ca3194e226d21e Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 11 Jul 2008 18:23:06 +0000 Subject: Fixed test 553 to pass the torture test. --- tests/libtest/lib552.c | 7 ++++--- tests/libtest/lib553.c | 51 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 23 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 5a0eb1c68..1c6e23455 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -146,10 +146,10 @@ static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp) int test(char *URL) { CURL *curl; - CURLcode res; + CURLcode res = CURLE_OUT_OF_MEMORY; struct data config; size_t i; - char fill[] = "test data"; + static const char fill[] = "test data"; config.trace_ascii = 1; /* enable ascii tracing */ @@ -190,5 +190,6 @@ int test(char *URL) /* always cleanup */ curl_easy_cleanup(curl); } - return 0; + curl_global_cleanup(); + return (int)res; } diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 7af25e5bb..0603b3fd5 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -39,36 +39,47 @@ static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream) #define SIZE_HEADERS 5000 static char buf[SIZE_HEADERS + 100]; + int test(char *URL) { CURL *curl; CURLcode res; int i; - struct curl_slist *headerlist=NULL; + struct curl_slist *headerlist=NULL, *hl; curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); - for (i = 0; i < NUM_HEADERS; i++) { - int len; - len = sprintf(buf, "Header%d: ", i); - memset(&buf[len], 'A', SIZE_HEADERS); - buf[len + SIZE_HEADERS]=0; /* zero terminate */ - headerlist = curl_slist_append(headerlist, buf); + if(curl) { + for (i = 0; i < NUM_HEADERS; i++) { + int len = sprintf(buf, "Header%d: ", i); + memset(&buf[len], 'A', SIZE_HEADERS); + buf[len + SIZE_HEADERS]=0; /* zero terminate */ + hl = curl_slist_append(headerlist, buf); + if (!hl) + goto errout; + headerlist = hl; + } + hl = curl_slist_append(headerlist, "Expect: "); + if (!hl) + goto errout; + headerlist = hl; + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); + curl_easy_setopt(curl, CURLOPT_POST, 1L); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); + res = curl_easy_perform(curl); + +errout: + curl_easy_cleanup(curl); + + curl_slist_free_all(headerlist); } - headerlist = curl_slist_append(headerlist, "Expect: "); - - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); - curl_easy_setopt(curl, CURLOPT_POST, 1L); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); - res = curl_easy_perform(curl); - curl_easy_cleanup(curl); - - curl_slist_free_all(headerlist); + curl_global_cleanup(); return (int)res; } -- cgit v1.2.1 From 1e7125ae7b7e83fc5f86fa6d0ac7038865eacf1f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 15 Jul 2008 05:46:49 +0000 Subject: add comment for include paths --- tests/libtest/Makefile.am | 18 ++++++++++-------- tests/libtest/lib506.c | 2 +- tests/libtest/test.h | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 52e49b944..8efeef13f 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -22,14 +22,16 @@ ########################################################################### AUTOMAKE_OPTIONS = foreign nostdinc -# $(top_srcdir)/include/curl is for the main curl include files, to make it -# easier to include this specific set of curl headers, and NOT the ones -# possibly already installed in the system. -# -I$(top_srcdir)/lib is for the setup.h file, included by test.h -# -I$(top_builddir)/lib is for the config.h file, possibly included by the -# setup.h file - -INCLUDES = -I$(top_srcdir)/include/curl \ +# Specify our include paths here, and do it relative to $(top_srcdir) and +# $(top_builddir), to ensure that these paths which belong to the library +# being currently built and tested are searched before the library which +# might possibly already be installed in the system. +# +# $(top_srcdir)/include is for libcurl's external include files +# $(top_builddir)/lib is for libcurl's generated lib/config.h file +# $(top_srcdir)/lib is for libcurl's lib/setup.h and other "borrowed" files + +INCLUDES = -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index cadd2ee63..0fc59591a 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -13,7 +13,7 @@ #include #include -#include +#include const char *HOSTHEADER = "Host: www.host.foo.com"; const char *JAR = "log/jar506"; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 50c3a7959..ef85c346f 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -15,7 +15,7 @@ #include "setup.h" -#include +#include #include #include #include -- cgit v1.2.1 From 14240e9e109fe6af19438c6531d573f85dbb0b1e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 7 Aug 2008 00:29:08 +0000 Subject: Initial support of curlbuild.h and curlrules.h which allows to have a curl_off_t data type no longer gated to off_t. --- tests/libtest/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 8efeef13f..b24b90014 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -27,12 +27,14 @@ AUTOMAKE_OPTIONS = foreign nostdinc # being currently built and tested are searched before the library which # might possibly already be installed in the system. # +# $(top_builddir)/include is for libcurl's generated curl/curlbuild.h file # $(top_srcdir)/include is for libcurl's external include files # $(top_builddir)/lib is for libcurl's generated lib/config.h file # $(top_srcdir)/lib is for libcurl's lib/setup.h and other "borrowed" files -INCLUDES = -I$(top_srcdir)/include \ - -I$(top_builddir)/lib \ +INCLUDES = -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ -I$(top_srcdir)/lib LIBDIR = $(top_builddir)/lib -- cgit v1.2.1 From 9ee7a014c90772a891a89ef02b0890b867e9ddbc Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 12 Aug 2008 18:32:55 +0000 Subject: Handle short reads --- tests/libtest/lib556.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 22583a236..85fd65699 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -54,7 +54,7 @@ int test(char *URL) total += iolen; - } while((res == CURLE_AGAIN) && (total < 129)); + } while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129)); } } -- cgit v1.2.1 From 2f71461b2953373557bc0fbb0065859ce46378cc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 18 Aug 2008 09:58:08 +0000 Subject: Added test case 557 to verify libcurl's internal curl_m*printf() functions formatting functionality when handling signed and unsigned longs, as well as our curl_off_t data type. --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib557.c | 269 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib557.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index b24b90014..94774c310 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,7 +53,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 + lib539 lib557 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -160,3 +160,5 @@ lib553_SOURCES = lib553.c $(SUPPORTFILES) lib554_SOURCES = lib554.c $(SUPPORTFILES) lib556_SOURCES = lib556.c $(SUPPORTFILES) + +lib557_SOURCES = lib557.c $(SUPPORTFILES) diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c new file mode 100644 index 000000000..8e49dbff3 --- /dev/null +++ b/tests/libtest/lib557.c @@ -0,0 +1,269 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +/* + * The purpose of this test is to minimally exercise libcurl's internal + * curl_m*printf formatting capabilities and handling of some data types. + */ + +#include "test.h" + +int curl_msprintf(char *buffer, const char *format, ...); + + +#if (CURL_SIZEOF_CURL_OFF_T > 4) +# if (CURL_SIZEOF_LONG > 4) +# define MPRNT_SUFFIX_CURL_OFF_T L +# else +# define MPRNT_SUFFIX_CURL_OFF_T LL +# endif +#else +# if (CURL_SIZEOF_LONG > 2) +# define MPRNT_SUFFIX_CURL_OFF_T L +# else +# define MPRNT_SUFFIX_CURL_OFF_T LL +# endif +#endif + +#ifdef CURL_ISOCPP +# define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix +#else +# define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix +#endif +#define MPRNT_OFF_T_C_HELPER1(Val,Suffix) MPRNT_OFF_T_C_HELPER2(Val,Suffix) +#define MPRNT_OFF_T_C(Val) MPRNT_OFF_T_C_HELPER1(Val,MPRNT_SUFFIX_CURL_OFF_T) + + +#define BUFSZ 256 +#define NUM_ULONG_TESTS 4 +#define NUM_SLONG_TESTS 7 +#define NUM_COFFT_TESTS 7 + + +struct unslong_st { + unsigned long num; /* unsigned long */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct siglong_st { + long num; /* signed long */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct curloff_st { + curl_off_t num; /* curl_off_t */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +static struct unslong_st ul_test[NUM_ULONG_TESTS]; +static struct siglong_st sl_test[NUM_SLONG_TESTS]; +static struct curloff_st co_test[NUM_COFFT_TESTS]; + + +static int test_unsigned_long_formatting(void) +{ + int i, j; + int failed = 0; + + ul_test[0].num = 0x0L; + ul_test[0].expected = "0"; + ul_test[1].num = 0x1L; + ul_test[1].expected = "1"; +#if (CURL_SIZEOF_LONG == 2) + ul_test[2].num = 0xFFL; + ul_test[2].expected = "255"; + ul_test[3].num = 0xFFFFL; + ul_test[3].expected = "65535"; +#elif (CURL_SIZEOF_LONG == 4) + ul_test[2].num = 0xFFFFL; + ul_test[2].expected = "65535"; + ul_test[3].num = 0xFFFFFFFFL; + ul_test[3].expected = "4294967295"; +#elif (CURL_SIZEOF_LONG == 8) + ul_test[2].num = 0xFFFFFFFFL; + ul_test[2].expected = "4294967295"; + ul_test[3].num = 0xFFFFFFFFFFFFFFFFL; + ul_test[3].expected = "18446744073709551615"; +#endif + + for(i=0; i Date: Mon, 18 Aug 2008 18:52:13 +0000 Subject: Update test case 557 --- tests/libtest/lib557.c | 635 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 531 insertions(+), 104 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 8e49dbff3..1242e6b9d 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -42,9 +42,9 @@ int curl_msprintf(char *buffer, const char *format, ...); #define BUFSZ 256 -#define NUM_ULONG_TESTS 4 -#define NUM_SLONG_TESTS 7 -#define NUM_COFFT_TESTS 7 +#define ULONG_TESTS_ARRSZ 1 + 100 +#define SLONG_TESTS_ARRSZ 1 + 100 +#define COFFT_TESTS_ARRSZ 1 + 100 struct unslong_st { @@ -68,38 +68,134 @@ struct curloff_st { }; -static struct unslong_st ul_test[NUM_ULONG_TESTS]; -static struct siglong_st sl_test[NUM_SLONG_TESTS]; -static struct curloff_st co_test[NUM_COFFT_TESTS]; +static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; +static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; +static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; static int test_unsigned_long_formatting(void) { int i, j; + int num_ulong_tests; int failed = 0; - ul_test[0].num = 0x0L; - ul_test[0].expected = "0"; - ul_test[1].num = 0x1L; - ul_test[1].expected = "1"; #if (CURL_SIZEOF_LONG == 2) - ul_test[2].num = 0xFFL; - ul_test[2].expected = "255"; - ul_test[3].num = 0xFFFFL; - ul_test[3].expected = "65535"; + + i=1; ul_test[i].num = 0xFFFFUL; ul_test[i].expected = "65535"; + i++; ul_test[i].num = 0xFF00UL; ul_test[i].expected = "65280"; + i++; ul_test[i].num = 0x00FFUL; ul_test[i].expected = "255"; + + i++; ul_test[i].num = 0xF000UL; ul_test[i].expected = "61440"; + i++; ul_test[i].num = 0x0F00UL; ul_test[i].expected = "3840"; + i++; ul_test[i].num = 0x00F0UL; ul_test[i].expected = "240"; + i++; ul_test[i].num = 0x000FUL; ul_test[i].expected = "15"; + + i++; ul_test[i].num = 0xC000UL; ul_test[i].expected = "49152"; + i++; ul_test[i].num = 0x0C00UL; ul_test[i].expected = "3072"; + i++; ul_test[i].num = 0x00C0UL; ul_test[i].expected = "192"; + i++; ul_test[i].num = 0x000CUL; ul_test[i].expected = "12"; + + i++; ul_test[i].num = 0x0001UL; ul_test[i].expected = "1"; + i++; ul_test[i].num = 0x0000UL; ul_test[i].expected = "0"; + + num_ulong_tests = i; + #elif (CURL_SIZEOF_LONG == 4) - ul_test[2].num = 0xFFFFL; - ul_test[2].expected = "65535"; - ul_test[3].num = 0xFFFFFFFFL; - ul_test[3].expected = "4294967295"; + + i=1; ul_test[i].num = 0xFFFFFFFFUL; ul_test[i].expected = "4294967295"; + i++; ul_test[i].num = 0xFFFF0000UL; ul_test[i].expected = "4294901760"; + i++; ul_test[i].num = 0x0000FFFFUL; ul_test[i].expected = "65535"; + + i++; ul_test[i].num = 0xFF000000UL; ul_test[i].expected = "4278190080"; + i++; ul_test[i].num = 0x00FF0000UL; ul_test[i].expected = "16711680"; + i++; ul_test[i].num = 0x0000FF00UL; ul_test[i].expected = "65280"; + i++; ul_test[i].num = 0x000000FFUL; ul_test[i].expected = "255"; + + i++; ul_test[i].num = 0xF0000000UL; ul_test[i].expected = "4026531840"; + i++; ul_test[i].num = 0x0F000000UL; ul_test[i].expected = "251658240"; + i++; ul_test[i].num = 0x00F00000UL; ul_test[i].expected = "15728640"; + i++; ul_test[i].num = 0x000F0000UL; ul_test[i].expected = "983040"; + i++; ul_test[i].num = 0x0000F000UL; ul_test[i].expected = "61440"; + i++; ul_test[i].num = 0x00000F00UL; ul_test[i].expected = "3840"; + i++; ul_test[i].num = 0x000000F0UL; ul_test[i].expected = "240"; + i++; ul_test[i].num = 0x0000000FUL; ul_test[i].expected = "15"; + + i++; ul_test[i].num = 0xC0000000UL; ul_test[i].expected = "3221225472"; + i++; ul_test[i].num = 0x0C000000UL; ul_test[i].expected = "201326592"; + i++; ul_test[i].num = 0x00C00000UL; ul_test[i].expected = "12582912"; + i++; ul_test[i].num = 0x000C0000UL; ul_test[i].expected = "786432"; + i++; ul_test[i].num = 0x0000C000UL; ul_test[i].expected = "49152"; + i++; ul_test[i].num = 0x00000C00UL; ul_test[i].expected = "3072"; + i++; ul_test[i].num = 0x000000C0UL; ul_test[i].expected = "192"; + i++; ul_test[i].num = 0x0000000CUL; ul_test[i].expected = "12"; + + i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1"; + i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0"; + + num_ulong_tests = i; + #elif (CURL_SIZEOF_LONG == 8) - ul_test[2].num = 0xFFFFFFFFL; - ul_test[2].expected = "4294967295"; - ul_test[3].num = 0xFFFFFFFFFFFFFFFFL; - ul_test[3].expected = "18446744073709551615"; + + i=1; ul_test[i].num = 0xFFFFFFFFFFFFFFFFUL; ul_test[i].expected = "18446744073709551615"; + i++; ul_test[i].num = 0xFFFFFFFF00000000UL; ul_test[i].expected = "18446744069414584320"; + i++; ul_test[i].num = 0x00000000FFFFFFFFUL; ul_test[i].expected = "4294967295"; + + i++; ul_test[i].num = 0xFFFF000000000000UL; ul_test[i].expected = "18446462598732840960"; + i++; ul_test[i].num = 0x0000FFFF00000000UL; ul_test[i].expected = "281470681743360"; + i++; ul_test[i].num = 0x00000000FFFF0000UL; ul_test[i].expected = "4294901760"; + i++; ul_test[i].num = 0x000000000000FFFFUL; ul_test[i].expected = "65535"; + + i++; ul_test[i].num = 0xFF00000000000000UL; ul_test[i].expected = "18374686479671623680"; + i++; ul_test[i].num = 0x00FF000000000000UL; ul_test[i].expected = "71776119061217280"; + i++; ul_test[i].num = 0x0000FF0000000000UL; ul_test[i].expected = "280375465082880"; + i++; ul_test[i].num = 0x000000FF00000000UL; ul_test[i].expected = "1095216660480"; + i++; ul_test[i].num = 0x00000000FF000000UL; ul_test[i].expected = "4278190080"; + i++; ul_test[i].num = 0x0000000000FF0000UL; ul_test[i].expected = "16711680"; + i++; ul_test[i].num = 0x000000000000FF00UL; ul_test[i].expected = "65280"; + i++; ul_test[i].num = 0x00000000000000FFUL; ul_test[i].expected = "255"; + + i++; ul_test[i].num = 0xF000000000000000UL; ul_test[i].expected = "17293822569102704640"; + i++; ul_test[i].num = 0x0F00000000000000UL; ul_test[i].expected = "1080863910568919040"; + i++; ul_test[i].num = 0x00F0000000000000UL; ul_test[i].expected = "67553994410557440"; + i++; ul_test[i].num = 0x000F000000000000UL; ul_test[i].expected = "4222124650659840"; + i++; ul_test[i].num = 0x0000F00000000000UL; ul_test[i].expected = "263882790666240"; + i++; ul_test[i].num = 0x00000F0000000000UL; ul_test[i].expected = "16492674416640"; + i++; ul_test[i].num = 0x000000F000000000UL; ul_test[i].expected = "1030792151040"; + i++; ul_test[i].num = 0x0000000F00000000UL; ul_test[i].expected = "64424509440"; + i++; ul_test[i].num = 0x00000000F0000000UL; ul_test[i].expected = "4026531840"; + i++; ul_test[i].num = 0x000000000F000000UL; ul_test[i].expected = "251658240"; + i++; ul_test[i].num = 0x0000000000F00000UL; ul_test[i].expected = "15728640"; + i++; ul_test[i].num = 0x00000000000F0000UL; ul_test[i].expected = "983040"; + i++; ul_test[i].num = 0x000000000000F000UL; ul_test[i].expected = "61440"; + i++; ul_test[i].num = 0x0000000000000F00UL; ul_test[i].expected = "3840"; + i++; ul_test[i].num = 0x00000000000000F0UL; ul_test[i].expected = "240"; + i++; ul_test[i].num = 0x000000000000000FUL; ul_test[i].expected = "15"; + + i++; ul_test[i].num = 0xC000000000000000UL; ul_test[i].expected = "13835058055282163712"; + i++; ul_test[i].num = 0x0C00000000000000UL; ul_test[i].expected = "864691128455135232"; + i++; ul_test[i].num = 0x00C0000000000000UL; ul_test[i].expected = "54043195528445952"; + i++; ul_test[i].num = 0x000C000000000000UL; ul_test[i].expected = "3377699720527872"; + i++; ul_test[i].num = 0x0000C00000000000UL; ul_test[i].expected = "211106232532992"; + i++; ul_test[i].num = 0x00000C0000000000UL; ul_test[i].expected = "13194139533312"; + i++; ul_test[i].num = 0x000000C000000000UL; ul_test[i].expected = "824633720832"; + i++; ul_test[i].num = 0x0000000C00000000UL; ul_test[i].expected = "51539607552"; + i++; ul_test[i].num = 0x00000000C0000000UL; ul_test[i].expected = "3221225472"; + i++; ul_test[i].num = 0x000000000C000000UL; ul_test[i].expected = "201326592"; + i++; ul_test[i].num = 0x0000000000C00000UL; ul_test[i].expected = "12582912"; + i++; ul_test[i].num = 0x00000000000C0000UL; ul_test[i].expected = "786432"; + i++; ul_test[i].num = 0x000000000000C000UL; ul_test[i].expected = "49152"; + i++; ul_test[i].num = 0x0000000000000C00UL; ul_test[i].expected = "3072"; + i++; ul_test[i].num = 0x00000000000000C0UL; ul_test[i].expected = "192"; + i++; ul_test[i].num = 0x000000000000000CUL; ul_test[i].expected = "12"; + + i++; ul_test[i].num = 0x00000001UL; ul_test[i].expected = "1"; + i++; ul_test[i].num = 0x00000000UL; ul_test[i].expected = "0"; + + num_ulong_tests = i; + #endif - for(i=0; i Date: Wed, 20 Aug 2008 23:29:07 +0000 Subject: Simplify condition check --- tests/libtest/lib557.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 1242e6b9d..c70155e95 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -18,20 +18,13 @@ int curl_msprintf(char *buffer, const char *format, ...); -#if (CURL_SIZEOF_CURL_OFF_T > 4) -# if (CURL_SIZEOF_LONG > 4) -# define MPRNT_SUFFIX_CURL_OFF_T L -# else -# define MPRNT_SUFFIX_CURL_OFF_T LL -# endif +#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG) +# define MPRNT_SUFFIX_CURL_OFF_T LL #else -# if (CURL_SIZEOF_LONG > 2) -# define MPRNT_SUFFIX_CURL_OFF_T L -# else -# define MPRNT_SUFFIX_CURL_OFF_T LL -# endif +# define MPRNT_SUFFIX_CURL_OFF_T L #endif + #ifdef CURL_ISOCPP # define MPRNT_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix #else -- cgit v1.2.1 From 95cef39defe9af5b8cdb78fa9d0e543dae0ed5dd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 21 Aug 2008 05:19:40 +0000 Subject: Test case 557 now also verifies signed and unsigned int formatting. --- tests/libtest/lib557.c | 399 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 399 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index c70155e95..57061a759 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -35,11 +35,27 @@ int curl_msprintf(char *buffer, const char *format, ...); #define BUFSZ 256 +#define UINT_TESTS_ARRSZ 1 + 100 +#define SINT_TESTS_ARRSZ 1 + 100 #define ULONG_TESTS_ARRSZ 1 + 100 #define SLONG_TESTS_ARRSZ 1 + 100 #define COFFT_TESTS_ARRSZ 1 + 100 +struct unsint_st { + unsigned int num; /* unsigned int */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct sigint_st { + int num; /* signed int */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + struct unslong_st { unsigned long num; /* unsigned long */ const char *expected; /* expected string */ @@ -61,11 +77,390 @@ struct curloff_st { }; +static struct unsint_st ui_test[UINT_TESTS_ARRSZ]; +static struct sigint_st si_test[SINT_TESTS_ARRSZ]; static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; +static int test_unsigned_int_formatting(void) +{ + int i, j; + int num_uint_tests; + int failed = 0; + +#if (SIZEOF_INT == 2) + + i=1; ui_test[i].num = 0xFFFFU; ui_test[i].expected = "65535"; + i++; ui_test[i].num = 0xFF00U; ui_test[i].expected = "65280"; + i++; ui_test[i].num = 0x00FFU; ui_test[i].expected = "255"; + + i++; ui_test[i].num = 0xF000U; ui_test[i].expected = "61440"; + i++; ui_test[i].num = 0x0F00U; ui_test[i].expected = "3840"; + i++; ui_test[i].num = 0x00F0U; ui_test[i].expected = "240"; + i++; ui_test[i].num = 0x000FU; ui_test[i].expected = "15"; + + i++; ui_test[i].num = 0xC000U; ui_test[i].expected = "49152"; + i++; ui_test[i].num = 0x0C00U; ui_test[i].expected = "3072"; + i++; ui_test[i].num = 0x00C0U; ui_test[i].expected = "192"; + i++; ui_test[i].num = 0x000CU; ui_test[i].expected = "12"; + + i++; ui_test[i].num = 0x0001U; ui_test[i].expected = "1"; + i++; ui_test[i].num = 0x0000U; ui_test[i].expected = "0"; + + num_uint_tests = i; + +#elif (SIZEOF_INT == 4) + + i=1; ui_test[i].num = 0xFFFFFFFFU; ui_test[i].expected = "4294967295"; + i++; ui_test[i].num = 0xFFFF0000U; ui_test[i].expected = "4294901760"; + i++; ui_test[i].num = 0x0000FFFFU; ui_test[i].expected = "65535"; + + i++; ui_test[i].num = 0xFF000000U; ui_test[i].expected = "4278190080"; + i++; ui_test[i].num = 0x00FF0000U; ui_test[i].expected = "16711680"; + i++; ui_test[i].num = 0x0000FF00U; ui_test[i].expected = "65280"; + i++; ui_test[i].num = 0x000000FFU; ui_test[i].expected = "255"; + + i++; ui_test[i].num = 0xF0000000U; ui_test[i].expected = "4026531840"; + i++; ui_test[i].num = 0x0F000000U; ui_test[i].expected = "251658240"; + i++; ui_test[i].num = 0x00F00000U; ui_test[i].expected = "15728640"; + i++; ui_test[i].num = 0x000F0000U; ui_test[i].expected = "983040"; + i++; ui_test[i].num = 0x0000F000U; ui_test[i].expected = "61440"; + i++; ui_test[i].num = 0x00000F00U; ui_test[i].expected = "3840"; + i++; ui_test[i].num = 0x000000F0U; ui_test[i].expected = "240"; + i++; ui_test[i].num = 0x0000000FU; ui_test[i].expected = "15"; + + i++; ui_test[i].num = 0xC0000000U; ui_test[i].expected = "3221225472"; + i++; ui_test[i].num = 0x0C000000U; ui_test[i].expected = "201326592"; + i++; ui_test[i].num = 0x00C00000U; ui_test[i].expected = "12582912"; + i++; ui_test[i].num = 0x000C0000U; ui_test[i].expected = "786432"; + i++; ui_test[i].num = 0x0000C000U; ui_test[i].expected = "49152"; + i++; ui_test[i].num = 0x00000C00U; ui_test[i].expected = "3072"; + i++; ui_test[i].num = 0x000000C0U; ui_test[i].expected = "192"; + i++; ui_test[i].num = 0x0000000CU; ui_test[i].expected = "12"; + + i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1"; + i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0"; + + num_uint_tests = i; + +#elif (SIZEOF_INT == 8) + + i=1; ui_test[i].num = 0xFFFFFFFFFFFFFFFFU; ui_test[i].expected = "18446744073709551615"; + i++; ui_test[i].num = 0xFFFFFFFF00000000U; ui_test[i].expected = "18446744069414584320"; + i++; ui_test[i].num = 0x00000000FFFFFFFFU; ui_test[i].expected = "4294967295"; + + i++; ui_test[i].num = 0xFFFF000000000000U; ui_test[i].expected = "18446462598732840960"; + i++; ui_test[i].num = 0x0000FFFF00000000U; ui_test[i].expected = "281470681743360"; + i++; ui_test[i].num = 0x00000000FFFF0000U; ui_test[i].expected = "4294901760"; + i++; ui_test[i].num = 0x000000000000FFFFU; ui_test[i].expected = "65535"; + + i++; ui_test[i].num = 0xFF00000000000000U; ui_test[i].expected = "18374686479671623680"; + i++; ui_test[i].num = 0x00FF000000000000U; ui_test[i].expected = "71776119061217280"; + i++; ui_test[i].num = 0x0000FF0000000000U; ui_test[i].expected = "280375465082880"; + i++; ui_test[i].num = 0x000000FF00000000U; ui_test[i].expected = "1095216660480"; + i++; ui_test[i].num = 0x00000000FF000000U; ui_test[i].expected = "4278190080"; + i++; ui_test[i].num = 0x0000000000FF0000U; ui_test[i].expected = "16711680"; + i++; ui_test[i].num = 0x000000000000FF00U; ui_test[i].expected = "65280"; + i++; ui_test[i].num = 0x00000000000000FFU; ui_test[i].expected = "255"; + + i++; ui_test[i].num = 0xF000000000000000U; ui_test[i].expected = "17293822569102704640"; + i++; ui_test[i].num = 0x0F00000000000000U; ui_test[i].expected = "1080863910568919040"; + i++; ui_test[i].num = 0x00F0000000000000U; ui_test[i].expected = "67553994410557440"; + i++; ui_test[i].num = 0x000F000000000000U; ui_test[i].expected = "4222124650659840"; + i++; ui_test[i].num = 0x0000F00000000000U; ui_test[i].expected = "263882790666240"; + i++; ui_test[i].num = 0x00000F0000000000U; ui_test[i].expected = "16492674416640"; + i++; ui_test[i].num = 0x000000F000000000U; ui_test[i].expected = "1030792151040"; + i++; ui_test[i].num = 0x0000000F00000000U; ui_test[i].expected = "64424509440"; + i++; ui_test[i].num = 0x00000000F0000000U; ui_test[i].expected = "4026531840"; + i++; ui_test[i].num = 0x000000000F000000U; ui_test[i].expected = "251658240"; + i++; ui_test[i].num = 0x0000000000F00000U; ui_test[i].expected = "15728640"; + i++; ui_test[i].num = 0x00000000000F0000U; ui_test[i].expected = "983040"; + i++; ui_test[i].num = 0x000000000000F000U; ui_test[i].expected = "61440"; + i++; ui_test[i].num = 0x0000000000000F00U; ui_test[i].expected = "3840"; + i++; ui_test[i].num = 0x00000000000000F0U; ui_test[i].expected = "240"; + i++; ui_test[i].num = 0x000000000000000FU; ui_test[i].expected = "15"; + + i++; ui_test[i].num = 0xC000000000000000U; ui_test[i].expected = "13835058055282163712"; + i++; ui_test[i].num = 0x0C00000000000000U; ui_test[i].expected = "864691128455135232"; + i++; ui_test[i].num = 0x00C0000000000000U; ui_test[i].expected = "54043195528445952"; + i++; ui_test[i].num = 0x000C000000000000U; ui_test[i].expected = "3377699720527872"; + i++; ui_test[i].num = 0x0000C00000000000U; ui_test[i].expected = "211106232532992"; + i++; ui_test[i].num = 0x00000C0000000000U; ui_test[i].expected = "13194139533312"; + i++; ui_test[i].num = 0x000000C000000000U; ui_test[i].expected = "824633720832"; + i++; ui_test[i].num = 0x0000000C00000000U; ui_test[i].expected = "51539607552"; + i++; ui_test[i].num = 0x00000000C0000000U; ui_test[i].expected = "3221225472"; + i++; ui_test[i].num = 0x000000000C000000U; ui_test[i].expected = "201326592"; + i++; ui_test[i].num = 0x0000000000C00000U; ui_test[i].expected = "12582912"; + i++; ui_test[i].num = 0x00000000000C0000U; ui_test[i].expected = "786432"; + i++; ui_test[i].num = 0x000000000000C000U; ui_test[i].expected = "49152"; + i++; ui_test[i].num = 0x0000000000000C00U; ui_test[i].expected = "3072"; + i++; ui_test[i].num = 0x00000000000000C0U; ui_test[i].expected = "192"; + i++; ui_test[i].num = 0x000000000000000CU; ui_test[i].expected = "12"; + + i++; ui_test[i].num = 0x00000001U; ui_test[i].expected = "1"; + i++; ui_test[i].num = 0x00000000U; ui_test[i].expected = "0"; + + num_uint_tests = i; + +#endif + + for(i=1; i<=num_uint_tests; i++) { + + for(j=0; j Date: Sun, 24 Aug 2008 17:10:24 +0000 Subject: Fix wrong signed int formatting string directive in test case #557. This error did not cause test failures on systems where sizeof(int) == sizeof(long). --- tests/libtest/lib557.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 57061a759..13148dd84 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -440,7 +440,7 @@ static int test_signed_int_formatting(void) si_test[i].result[j] = 'X'; si_test[i].result[BUFSZ-1] = '\0'; - (void)curl_msprintf(si_test[i].result, "%ld", si_test[i].num); + (void)curl_msprintf(si_test[i].result, "%d", si_test[i].num); if(memcmp(si_test[i].result, si_test[i].expected, -- cgit v1.2.1 From 780f13db30255068772daf06c387ee206d412cd9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Sep 2008 08:15:21 +0000 Subject: Stefan Krause's mail to curl-library at 03 Sep 2008 made me add these two new date strings to get tested too. --- tests/libtest/lib517.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index cdcd64be1..34146d20f 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -33,6 +33,8 @@ const char *dates[]={ "Sat, 11 Sep 2004 21:32:11 +0200", "20040912 15:05:58 -0700", "20040911 +0200", + "Thu, 01-Jan-1970 00:59:59 GMT", + "Thu, 01-Jan-1970 01:00:00 GMT", /* "2094 Nov 6", See ../data/test517 for details */ NULL }; -- cgit v1.2.1 From 974145f61cb78213c07b03f978394ad3307d0491 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 15 Sep 2008 22:35:09 +0000 Subject: Changed the test data file so it passes an XML syntax check --- tests/libtest/lib506.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 0fc59591a..952aa997a 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -54,7 +54,7 @@ static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess, fprintf(stderr, "lock: no such data: %d\n", (int)data); return; } - printf("lock: %-6s <%s>: %d\n", what, user->text, user->counter); + printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter); user->counter++; } @@ -78,7 +78,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr ) fprintf(stderr, "unlock: no such data: %d\n", (int)data); return; } - printf("unlock: %-6s <%s>: %d\n", what, user->text, user->counter); + printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter); user->counter++; } -- cgit v1.2.1 From a6c915aab98a51b69a77a23ebe1ad8eaf0fd251f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 18 Sep 2008 16:21:09 +0000 Subject: fix compiler warning: external declaration in primary source file --- tests/libtest/first.c | 3 --- tests/libtest/test.h | 9 +++++---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index a58755c41..d25c7ad28 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -16,9 +16,6 @@ extern void curl_memdebug(const char *); extern void curl_memlimit(int); #endif -/* test is provided in the test code file */ -int test(char *url); - int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv) { diff --git a/tests/libtest/test.h b/tests/libtest/test.h index ef85c346f..b4541c6c4 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -43,8 +43,9 @@ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */ extern int test_argc; extern char **test_argv; -int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, - struct timeval *tv); +extern int select_test(int num_fds, 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 */ -int test(char *URL); /* the actual test function provided by each individual - libXXX.c file */ -- cgit v1.2.1 From 8b2bfa4212c3e534b695a74bcf9df29255d2bb00 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 18 Sep 2008 19:02:40 +0000 Subject: fix compiler warning: external definition with no prior declaration --- tests/libtest/lib517.c | 2 +- tests/libtest/lib552.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 34146d20f..20fba6fbd 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -10,7 +10,7 @@ #include "test.h" -const char *dates[]={ +static const char *dates[]={ "Sun, 06 Nov 1994 08:49:37 GMT", "Sunday, 06-Nov-94 08:49:37 GMT", "Sun Nov 6 08:49:37 1994", diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 1c6e23455..ab097da3e 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -106,15 +106,15 @@ int my_trace(CURL *handle, curl_infotype type, static size_t current_offset = 0; -char data[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ +static char databuf[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - size_t available = sizeof data - current_offset; /* What we have to give */ + size_t available = sizeof(databuf) - current_offset; /* What we have to give */ size_t given = amount < available ? amount : available; /* What is given */ (void)stream; - memcpy(ptr, data + current_offset, given); + memcpy(ptr, databuf + current_offset, given); current_offset += given; return given; } @@ -161,14 +161,14 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* setup repeated data string */ - for (i=0; i < sizeof data; ++i) - data[i] = fill[i % sizeof fill]; + for (i=0; i < sizeof(databuf); ++i) + databuf[i] = fill[i % sizeof fill]; /* Post */ curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Setup read callback */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof data); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* Write callback */ -- cgit v1.2.1 From f7ef60c13f948ba41dcf76db3dbaaf29657ac4e2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 18 Sep 2008 19:17:28 +0000 Subject: fix compiler warning: external definition with no prior declaration --- tests/libtest/lib506.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 952aa997a..260fec194 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -15,8 +15,8 @@ #include -const char *HOSTHEADER = "Host: www.host.foo.com"; -const char *JAR = "log/jar506"; +static const char *HOSTHEADER = "Host: www.host.foo.com"; +static const char *JAR = "log/jar506"; #define THREADS 2 /* struct containing data of a thread */ -- cgit v1.2.1 From 7beb473a3dffbd5757b14a99866033ae1391dbd9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 20 Sep 2008 04:26:55 +0000 Subject: include "memdebug.h" --- tests/libtest/first.c | 5 ++--- tests/libtest/lib500.c | 2 ++ tests/libtest/lib501.c | 2 ++ tests/libtest/lib502.c | 1 + tests/libtest/lib503.c | 1 + tests/libtest/lib504.c | 1 + tests/libtest/lib505.c | 2 ++ tests/libtest/lib506.c | 2 ++ tests/libtest/lib507.c | 1 + tests/libtest/lib508.c | 2 ++ tests/libtest/lib510.c | 2 ++ tests/libtest/lib511.c | 2 ++ tests/libtest/lib512.c | 2 ++ tests/libtest/lib513.c | 2 ++ tests/libtest/lib514.c | 2 ++ tests/libtest/lib515.c | 2 ++ tests/libtest/lib516.c | 2 ++ tests/libtest/lib517.c | 2 ++ tests/libtest/lib518.c | 2 ++ tests/libtest/lib519.c | 2 ++ tests/libtest/lib520.c | 2 ++ tests/libtest/lib521.c | 2 ++ tests/libtest/lib523.c | 2 ++ tests/libtest/lib524.c | 2 ++ tests/libtest/lib525.c | 1 + tests/libtest/lib526.c | 1 + tests/libtest/lib530.c | 1 + tests/libtest/lib533.c | 1 + tests/libtest/lib536.c | 1 + tests/libtest/lib537.c | 2 ++ tests/libtest/lib539.c | 2 ++ tests/libtest/lib540.c | 2 ++ tests/libtest/lib541.c | 2 ++ tests/libtest/lib542.c | 2 ++ tests/libtest/lib543.c | 2 ++ tests/libtest/lib544.c | 1 + tests/libtest/lib547.c | 2 ++ tests/libtest/lib549.c | 2 ++ tests/libtest/lib552.c | 2 ++ tests/libtest/lib553.c | 2 ++ tests/libtest/lib554.c | 2 ++ tests/libtest/lib555.c | 1 + tests/libtest/lib556.c | 2 ++ tests/libtest/lib557.c | 2 ++ tests/libtest/testutil.c | 1 + 45 files changed, 78 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index d25c7ad28..9b06f74bc 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -11,9 +11,8 @@ #include "test.h" #ifdef CURLDEBUG -/* provide a proto for this debug function */ -extern void curl_memdebug(const char *); -extern void curl_memlimit(int); +# define MEMDEBUG_NODEFINES +# include "memdebug.h" #endif int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index c28f5d0c9..14a8e7aeb 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index cf2d95724..ff2bbb5b9 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index ea53795c0..85c300fbe 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -11,6 +11,7 @@ #include "test.h" #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 5eda5996e..11f1150c0 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -13,6 +13,7 @@ #include #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index a57a3d157..fece016b8 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -13,6 +13,7 @@ #include #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index eec2071c9..ceccd6b28 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -28,6 +28,8 @@ #include #endif +#include "memdebug.h" + /* * This example shows an FTP upload, with a rename of the file just after * a successful upload. diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 260fec194..34c774e5d 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -15,6 +15,8 @@ #include +#include "memdebug.h" + static const char *HOSTHEADER = "Host: www.host.foo.com"; static const char *JAR = "log/jar506"; #define THREADS 2 diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 0137130ce..b2fd09888 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -11,6 +11,7 @@ #include "test.h" #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 35679d180..a709b80be 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + static char data[]="this is what we post to the silly web server\n"; struct WriteThis { diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index d8644c3fa..43ead0936 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + static const char *post[]={ "one", "two", diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index b0f455d59..0f9993db1 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index 0af95919b..14072f45c 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + /* Test case code based on source in a bug report filed by James Bursa on 28 Apr 2004 */ diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index d6f3756b7..e49724ca6 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { (void)ptr; diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 419b8422a..06f975f34 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURL *curl; diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index 18df7c938..c85f2bed1 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURL *curl; diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index 8295699e3..b3c63f4b5 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURL *curl; diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 20fba6fbd..86539fb73 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + static const char *dates[]={ "Sun, 06 Nov 1994 08:49:37 GMT", "Sunday, 06-Nov-94 08:49:37 GMT", diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 41c3fe282..a1b914916 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -26,6 +26,8 @@ #include #endif +#include "memdebug.h" + #ifndef FD_SETSIZE #error "this test requires FD_SETSIZE" #endif diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index ce440485a..70ada8a15 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index 46cad415d..1d63881c3 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 346ece056..60fe4d95d 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index 9f485ffed..c6011fc57 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index 2fde663ca..c8b07834a 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 154c209e3..c503d1618 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -15,6 +15,7 @@ #include #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 8951a7444..b4d891337 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -34,6 +34,7 @@ #include #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index af7d00d02..d738277f2 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -21,6 +21,7 @@ #endif #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 71c43c2ca..92b371a81 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -17,6 +17,7 @@ #include #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 9e764a97a..016b7e922 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -15,6 +15,7 @@ #include #include "testutil.h" +#include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index f3b42e755..7bb8c1436 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -26,6 +26,8 @@ #include #endif +#include "memdebug.h" + #if !defined(HAVE_POLL_FINE) && \ !defined(USE_WINSOCK) && \ !defined(TPF) && \ diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index 0e43654ef..c99344421 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 089fcd5cb..cfaa1622d 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -18,6 +18,8 @@ #include "test.h" +#include "memdebug.h" + #define PROXY libtest_arg2 #define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index a2224ae69..ada389cf1 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -28,6 +28,8 @@ #include #endif +#include "memdebug.h" + /* * Two FTP uploads, the second with no content sent. */ diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index ffd8f361c..1d45405bb 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -28,6 +28,8 @@ #include #endif +#include "memdebug.h" + /* * FTP get with NOBODY but no HEADER */ diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 2e930d2d6..662883529 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -13,6 +13,8 @@ #include "setup.h" #include "test.h" +#include "memdebug.h" + int test(char *URL) { unsigned char a[] = {0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1, diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index f91cef354..756291972 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -10,6 +10,7 @@ #include "test.h" +#include "memdebug.h" static char teststring[] = "This\0 is test binary data with an embedded NUL byte\n"; diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 85f22fe8e..8a1070f70 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -14,6 +14,8 @@ #include "test.h" +#include "memdebug.h" + #define UPLOADTHIS "this is the blurb we want to upload\n" #ifndef LIB548 diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index d50835624..e196aba56 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -14,6 +14,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index ab097da3e..ff2b8c986 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -13,6 +13,8 @@ #include "test.h" +#include "memdebug.h" + struct data { char trace_ascii; /* 1 or 0 */ }; diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 0603b3fd5..b9372b347 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -13,6 +13,8 @@ #include "test.h" +#include "memdebug.h" + #define POSTLEN 40960 static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index fe0c16a66..2999aea08 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + static char data[]="this is what we post to the silly web server\n"; struct WriteThis { diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index ad259e0e6..33a1a26c7 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -17,6 +17,7 @@ #include "test.h" #include "testutil.h" +#include "memdebug.h" #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 85fd65699..0e3949da3 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -10,6 +10,8 @@ #include "test.h" +#include "memdebug.h" + int test(char *URL) { CURLcode res; diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 13148dd84..cb54ec708 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -15,6 +15,8 @@ #include "test.h" +#include "memdebug.h" + int curl_msprintf(char *buffer, const char *format, ...); diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 573e6faed..a70652626 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -24,6 +24,7 @@ #include "setup.h" #include "testutil.h" +#include "memdebug.h" #if defined(WIN32) && !defined(MSDOS) -- cgit v1.2.1 From 7c9631081d98784bd664d9401977e640939930ac Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 21 Sep 2008 03:48:25 +0000 Subject: fix compiler warning: external declaration in primary source file --- tests/libtest/lib557.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index cb54ec708..124cd7c2b 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -15,9 +15,9 @@ #include "test.h" -#include "memdebug.h" +#include -int curl_msprintf(char *buffer, const char *format, ...); +#include "memdebug.h" #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG) -- cgit v1.2.1 From abe61b99261902d58ec72742ea932c580b458d26 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 22 Sep 2008 17:20:29 +0000 Subject: Fixed test 539 to handle an out of memory condition that shows up now that memdebug.h is included in the test programs. --- tests/libtest/lib539.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index c99344421..eda78fcf4 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -35,7 +35,7 @@ int test(char *URL) */ curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); + curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); @@ -47,13 +47,24 @@ int test(char *URL) * even though no directories are stored in the ftpconn->dirs array (after a * call to freedirs). */ - newURL = strcat (strcpy ((char*)malloc (strlen (URL) + 3), - URL), - "./"); + newURL = malloc(strlen(URL) + 3); + if (newURL == NULL) { + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + newURL = strcat(strcpy(newURL, URL), "./"); + slist = curl_slist_append (NULL, "SYST"); + if (slist == NULL) { + free(newURL); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } curl_easy_setopt(curl, CURLOPT_URL, newURL); - curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); + curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); curl_easy_setopt(curl, CURLOPT_QUOTE, slist); res = curl_easy_perform(curl); -- cgit v1.2.1 From 88513d2d1ad60767b2d4e41a0e3a7b42894ff973 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 1 Oct 2008 17:34:24 +0000 Subject: Fixed some compiler warnings with gcc --- tests/libtest/lib553.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index b9372b347..0a6fdcbdb 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -45,7 +45,7 @@ static char buf[SIZE_HEADERS + 100]; int test(char *URL) { CURL *curl; - CURLcode res; + CURLcode res = CURLE_FAILED_INIT; int i; struct curl_slist *headerlist=NULL, *hl; -- cgit v1.2.1 From 6db8f534450d50ff70c3d5a46ac32ccfbac4da46 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 26 Oct 2008 03:03:29 +0000 Subject: test #558 verifies loop operation using malloc() and free() --- tests/libtest/Makefile.am | 4 +- tests/libtest/lib558.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib558.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 94774c310..0801b4ef9 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,7 +53,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 + lib539 lib557 lib558 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -162,3 +162,5 @@ lib554_SOURCES = lib554.c $(SUPPORTFILES) lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) + +lib558_SOURCES = lib558.c $(SUPPORTFILES) diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c new file mode 100644 index 000000000..d5d1d146a --- /dev/null +++ b/tests/libtest/lib558.c @@ -0,0 +1,127 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + + + +#include "test.h" + +#include "memdebug.h" + +#define TABLE_SIZE 10 + + +struct element_st { + int idx; + int dummy; +}; + + +struct root_st { + struct element_st **table; + int size; +}; + + +static +struct root_st * new_root(void) +{ + struct root_st *r; + + r = malloc(sizeof(struct root_st)); + if(r != NULL) + printf("malloc of root struct OK\n"); + else { + printf("malloc of root struct failed\n"); + return NULL; + } + + r->size = TABLE_SIZE; + r->table = malloc(r->size * sizeof(struct element_st *)); + if(r->table != NULL) + printf("malloc of pointer table OK\n"); + else { + printf("malloc of pointer table failed\n"); + free(r); + return NULL; + } + + return r; +} + + +static +struct element_st * new_element(int idx) +{ + struct element_st *e; + + e = malloc(sizeof(struct element_st)); + if(e != NULL) + printf("malloc of pointed element (idx %d) OK\n", idx); + else { + printf("malloc of pointed element (idx %d) failed\n", idx); + return NULL; + } + + e->idx = e->dummy = idx; + + return e; +} + + +int test(char *URL) +{ + struct root_st *root; + int error; + int i; + (void)URL; /* not used */ + + root = new_root(); + if(!root) + return TEST_ERR_MAJOR_BAD; + + printf("initializing table...\n"); + for (i = 0; i < root->size; ++i) { + root->table[i] = NULL; + } + printf("table initialized OK\n"); + + printf("filling pointer table...\n"); + error = 0; + for (i = 0; i < root->size; ++i) { + root->table[i] = new_element(i); + if(!root->table[i]) { + error = 1; + break; + } + } + if(error) { + printf("pointer table filling failed\n"); + return TEST_ERR_MAJOR_BAD; + } + else + printf("pointer table filling OK\n"); + + printf("freeing pointers in table...\n"); + for (i = 0; i < root->size; ++i) { + if(root->table[i]) + free(root->table[i]); + } + printf("freeing pointers in table OK\n"); + + printf("freeing table...\n"); + free(root->table); + printf("freeing table OK\n"); + + printf("freeing root struct...\n"); + free(root); + printf("freeing root struct OK\n"); + + return 0; /* OK */ +} -- cgit v1.2.1 From dc289aa4fa4ea381237be28372b4eaf5c87a86de Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 26 Oct 2008 21:40:20 +0000 Subject: convert test #558 into something more interesting, attempting now to minimally exercise some internal hash routines. --- tests/libtest/lib558.c | 155 ++++++++++++++++++++----------------------------- 1 file changed, 63 insertions(+), 92 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index d5d1d146a..bf4f9149f 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -8,120 +8,91 @@ * $Id$ */ - - #include "test.h" -#include "memdebug.h" - -#define TABLE_SIZE 10 +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#define ENABLE_CURLX_PRINTF +#include "curlx.h" -struct element_st { - int idx; - int dummy; -}; - - -struct root_st { - struct element_st **table; - int size; -}; +#include "hash.h" +#include "hostip.h" +#include "memory.h" +#include "memdebug.h" -static -struct root_st * new_root(void) +int test(char *URL) { - struct root_st *r; - - r = malloc(sizeof(struct root_st)); - if(r != NULL) - printf("malloc of root struct OK\n"); - else { - printf("malloc of root struct failed\n"); - return NULL; - } + CURL *easyh; + struct curl_hash *hp; + char *data_key; + struct Curl_dns_entry *data_node; + struct Curl_dns_entry *nodep; + size_t key_len; + + (void)URL; /* not used */ - r->size = TABLE_SIZE; - r->table = malloc(r->size * sizeof(struct element_st *)); - if(r->table != NULL) - printf("malloc of pointer table OK\n"); - else { - printf("malloc of pointer table failed\n"); - free(r); - return NULL; + easyh = curl_easy_init(); + if(!easyh) { + printf("easy handle init failed\n"); + return TEST_ERR_MAJOR_BAD; } + printf("easy handle init OK\n"); - return r; -} - - -static -struct element_st * new_element(int idx) -{ - struct element_st *e; - - e = malloc(sizeof(struct element_st)); - if(e != NULL) - printf("malloc of pointed element (idx %d) OK\n", idx); - else { - printf("malloc of pointed element (idx %d) failed\n", idx); - return NULL; + printf("creating hash...\n"); + hp = Curl_mk_dnscache(); + if(!hp) { + printf("hash creation failed\n"); + return TEST_ERR_MAJOR_BAD; } + printf("hash creation OK\n"); - e->idx = e->dummy = idx; + /**/ - return e; -} - - -int test(char *URL) -{ - struct root_st *root; - int error; - int i; - (void)URL; /* not used */ - - root = new_root(); - if(!root) + data_key = aprintf("%s:%d", "dummy", 0); + if(!data_key) { + printf("data key creation failed\n"); return TEST_ERR_MAJOR_BAD; - - printf("initializing table...\n"); - for (i = 0; i < root->size; ++i) { - root->table[i] = NULL; } - printf("table initialized OK\n"); - - printf("filling pointer table...\n"); - error = 0; - for (i = 0; i < root->size; ++i) { - root->table[i] = new_element(i); - if(!root->table[i]) { - error = 1; - break; - } + key_len = strlen(data_key); + + data_node = calloc(1, sizeof(struct Curl_dns_entry)); + if(!data_node) { + printf("data node creation failed\n"); + return TEST_ERR_MAJOR_BAD; } - if(error) { - printf("pointer table filling failed\n"); + + data_node->addr = Curl_ip2addr(INADDR_ANY, "dummy", 0); + if(!data_node->addr) { + printf("actual data creation failed\n"); return TEST_ERR_MAJOR_BAD; } - else - printf("pointer table filling OK\n"); - printf("freeing pointers in table...\n"); - for (i = 0; i < root->size; ++i) { - if(root->table[i]) - free(root->table[i]); + nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); + if(!nodep) { + printf("insertion into hash failed\n"); + return TEST_ERR_MAJOR_BAD; } - printf("freeing pointers in table OK\n"); - printf("freeing table...\n"); - free(root->table); - printf("freeing table OK\n"); + free(data_key); - printf("freeing root struct...\n"); - free(root); - printf("freeing root struct OK\n"); + /**/ + + printf("destroying hash...\n"); + Curl_hash_destroy(hp); + printf("hash destruction OK\n"); + + printf("destroying easy handle...\n"); + curl_easy_cleanup(easyh); + printf("easy handle destruction OK\n"); + + curl_global_cleanup(); return 0; /* OK */ } + -- cgit v1.2.1 From 39e5fa6ae86c0df6c59da8c732ea8f5db35257fd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 27 Oct 2008 03:00:47 +0000 Subject: avoid using Curl_ip2addr(), simply build up a fake Curl_addrinfo --- tests/libtest/lib558.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index bf4f9149f..9dabbb718 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -26,6 +26,35 @@ #include "memory.h" #include "memdebug.h" + +static Curl_addrinfo *fake_ai(void) +{ + Curl_addrinfo *ai; + int ss_size; + + ss_size = sizeof (struct sockaddr_in); + + if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL) + return NULL; + + if((ai->ai_canonname = strdup("dummy")) == NULL) { + free(ai); + return NULL; + } + + if((ai->ai_addr = calloc(1, ss_size)) == NULL) { + free(ai->ai_canonname); + free(ai); + return NULL; + } + + ai->ai_family = AF_INET; + ai->ai_addrlen = ss_size; + + return ai; +} + + int test(char *URL) { CURL *easyh; @@ -67,7 +96,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - data_node->addr = Curl_ip2addr(INADDR_ANY, "dummy", 0); + data_node->addr = fake_ai(); if(!data_node->addr) { printf("actual data creation failed\n"); return TEST_ERR_MAJOR_BAD; -- cgit v1.2.1 From 1498de83d601abcfa79c1e0f36d61dfc6a6a785f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 27 Oct 2008 08:20:36 +0000 Subject: For tracing purposes log a fake call to getaddrinfo when allocating/building the fake Curl_addrinfo. --- tests/libtest/lib558.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 9dabbb718..41f8c8678 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -51,6 +51,13 @@ static Curl_addrinfo *fake_ai(void) ai->ai_family = AF_INET; ai->ai_addrlen = ss_size; +#if defined(ENABLE_IPV6) && defined(CURLDEBUG) + /* For tracing purposes log a fake call to getaddrinfo */ + if(logfile) + fprintf(logfile, "ADDR %s:%d getaddrinfo() = %p\n", + __FILE__, __LINE__, (void *)ai); +#endif + return ai; } -- cgit v1.2.1 From 310d842b70ad967e001e841d5d83280f7bba4e23 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 27 Oct 2008 14:02:50 +0000 Subject: Skip test #558 when libcurl is built with hidden symbols --- tests/libtest/lib558.c | 56 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 41f8c8678..f51243d21 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -27,6 +27,18 @@ #include "memdebug.h" +/* + * This hacky test bypasses the library external API, + * using internal only libcurl functions. So don't be + * surprised if we cannot run it when the library has + * been built with hidden symbols, exporting only the + * ones in the public API. + */ + + +#if !defined(CURL_HIDDEN_SYMBOLS) + + static Curl_addrinfo *fake_ai(void) { Curl_addrinfo *ai; @@ -71,47 +83,50 @@ int test(char *URL) struct Curl_dns_entry *nodep; size_t key_len; - (void)URL; /* not used */ + if(!strcmp(URL, "check")) { + /* test harness script verifying if this test can run */ + return 0; /* sure, run this! */ + } easyh = curl_easy_init(); if(!easyh) { - printf("easy handle init failed\n"); + fprintf(stdout, "easy handle init failed\n"); return TEST_ERR_MAJOR_BAD; } - printf("easy handle init OK\n"); + fprintf(stdout, "easy handle init OK\n"); - printf("creating hash...\n"); + fprintf(stdout, "creating hash...\n"); hp = Curl_mk_dnscache(); if(!hp) { - printf("hash creation failed\n"); + fprintf(stdout, "hash creation failed\n"); return TEST_ERR_MAJOR_BAD; } - printf("hash creation OK\n"); + fprintf(stdout, "hash creation OK\n"); /**/ data_key = aprintf("%s:%d", "dummy", 0); if(!data_key) { - printf("data key creation failed\n"); + fprintf(stdout, "data key creation failed\n"); return TEST_ERR_MAJOR_BAD; } key_len = strlen(data_key); data_node = calloc(1, sizeof(struct Curl_dns_entry)); if(!data_node) { - printf("data node creation failed\n"); + fprintf(stdout, "data node creation failed\n"); return TEST_ERR_MAJOR_BAD; } data_node->addr = fake_ai(); if(!data_node->addr) { - printf("actual data creation failed\n"); + fprintf(stdout, "actual data creation failed\n"); return TEST_ERR_MAJOR_BAD; } nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); if(!nodep) { - printf("insertion into hash failed\n"); + fprintf(stdout, "insertion into hash failed\n"); return TEST_ERR_MAJOR_BAD; } @@ -119,16 +134,29 @@ int test(char *URL) /**/ - printf("destroying hash...\n"); + fprintf(stdout, "destroying hash...\n"); Curl_hash_destroy(hp); - printf("hash destruction OK\n"); + fprintf(stdout, "hash destruction OK\n"); - printf("destroying easy handle...\n"); + fprintf(stdout, "destroying easy handle...\n"); curl_easy_cleanup(easyh); - printf("easy handle destruction OK\n"); + fprintf(stdout, "easy handle destruction OK\n"); curl_global_cleanup(); return 0; /* OK */ } + +#else /* !defined(CURL_HIDDEN_SYMBOLS) */ + + +int test(char *URL) +{ + (void)URL; + fprintf(stdout, "libcurl built with hidden symbols"); + return 1; /* skip test */ +} + + +#endif /* !defined(CURL_HIDDEN_SYMBOLS) */ -- cgit v1.2.1 From 92f3b3895eed05d12aeae75e9ee174698550378a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 27 Oct 2008 20:01:58 +0000 Subject: test #558 tests internal hash create/destroy test #559 tests internal hash create/add/destroy --- tests/libtest/Makefile.am | 6 ++++- tests/libtest/lib558.c | 69 +++++++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 33 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 0801b4ef9..ce700bd58 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,7 +53,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 + lib539 lib557 lib558 lib559 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -164,3 +164,7 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) lib558_SOURCES = lib558.c $(SUPPORTFILES) +lib526_CFLAGS = -DLIB558 + +lib559_SOURCES = lib558.c $(SUPPORTFILES) +lib526_CFLAGS = -DLIB559 diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index f51243d21..f1095d45e 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -26,6 +26,7 @@ #include "memory.h" #include "memdebug.h" +/* This source file is used for test # 558 and 559 */ /* * This hacky test bypasses the library external API, @@ -38,7 +39,7 @@ #if !defined(CURL_HIDDEN_SYMBOLS) - +#ifdef LIB559 static Curl_addrinfo *fake_ai(void) { Curl_addrinfo *ai; @@ -72,16 +73,13 @@ static Curl_addrinfo *fake_ai(void) return ai; } +#endif /* LIB559 */ int test(char *URL) { CURL *easyh; struct curl_hash *hp; - char *data_key; - struct Curl_dns_entry *data_node; - struct Curl_dns_entry *nodep; - size_t key_len; if(!strcmp(URL, "check")) { /* test harness script verifying if this test can run */ @@ -104,34 +102,41 @@ int test(char *URL) fprintf(stdout, "hash creation OK\n"); /**/ - - data_key = aprintf("%s:%d", "dummy", 0); - if(!data_key) { - fprintf(stdout, "data key creation failed\n"); - return TEST_ERR_MAJOR_BAD; - } - key_len = strlen(data_key); - - data_node = calloc(1, sizeof(struct Curl_dns_entry)); - if(!data_node) { - fprintf(stdout, "data node creation failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - data_node->addr = fake_ai(); - if(!data_node->addr) { - fprintf(stdout, "actual data creation failed\n"); - return TEST_ERR_MAJOR_BAD; +#ifdef LIB559 + { + char *data_key; + struct Curl_dns_entry *data_node; + struct Curl_dns_entry *nodep; + size_t key_len; + + data_key = aprintf("%s:%d", "dummy", 0); + if(!data_key) { + fprintf(stdout, "data key creation failed\n"); + return TEST_ERR_MAJOR_BAD; + } + key_len = strlen(data_key); + + data_node = calloc(1, sizeof(struct Curl_dns_entry)); + if(!data_node) { + fprintf(stdout, "data node creation failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + data_node->addr = fake_ai(); + if(!data_node->addr) { + fprintf(stdout, "actual data creation failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); + if(!nodep) { + fprintf(stdout, "insertion into hash failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + free(data_key); } - - nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); - if(!nodep) { - fprintf(stdout, "insertion into hash failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - free(data_key); - +#endif /* LIB559 */ /**/ fprintf(stdout, "destroying hash...\n"); -- cgit v1.2.1 From b17ca44f0b33bed6c97ddbc112b023e50b9b4663 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 28 Oct 2008 00:35:08 +0000 Subject: fix test # 558 and 559 CFLAGS --- tests/libtest/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index ce700bd58..c5aefd475 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -164,7 +164,7 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) lib558_SOURCES = lib558.c $(SUPPORTFILES) -lib526_CFLAGS = -DLIB558 +lib558_CFLAGS = -DLIB558 lib559_SOURCES = lib558.c $(SUPPORTFILES) -lib526_CFLAGS = -DLIB559 +lib559_CFLAGS = -DLIB559 -- cgit v1.2.1 From 0ce97f77e02acd2de15970270834a7011ce6cb38 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 30 Oct 2008 13:45:25 +0000 Subject: Use our Curl_addrinfo definition even when an addrinfo struct is available. Use a wrapper function to call system's getaddrinfo(). --- tests/libtest/lib558.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index f1095d45e..00c0a490a 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -10,11 +10,17 @@ #include "test.h" +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif #ifdef HAVE_NETDB_H -#include +# include #endif #ifdef HAVE_ARPA_INET_H -#include +# include #endif #define ENABLE_CURLX_PRINTF @@ -64,13 +70,6 @@ static Curl_addrinfo *fake_ai(void) ai->ai_family = AF_INET; ai->ai_addrlen = ss_size; -#if defined(ENABLE_IPV6) && defined(CURLDEBUG) - /* For tracing purposes log a fake call to getaddrinfo */ - if(logfile) - fprintf(logfile, "ADDR %s:%d getaddrinfo() = %p\n", - __FILE__, __LINE__, (void *)ai); -#endif - return ai; } #endif /* LIB559 */ -- cgit v1.2.1 From 02fc7bb5f6cce2ddbd40504b2828e888d48f2303 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 31 Oct 2008 14:46:48 +0000 Subject: fix OOM handling --- tests/libtest/lib558.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 00c0a490a..ceb42b1ee 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -77,8 +77,9 @@ static Curl_addrinfo *fake_ai(void) int test(char *URL) { - CURL *easyh; - struct curl_hash *hp; + CURL *easyh = NULL; + struct curl_hash *hp = NULL; + int result = 0; if(!strcmp(URL, "check")) { /* test harness script verifying if this test can run */ @@ -88,7 +89,8 @@ int test(char *URL) easyh = curl_easy_init(); if(!easyh) { fprintf(stdout, "easy handle init failed\n"); - return TEST_ERR_MAJOR_BAD; + result = TEST_ERR_MAJOR_BAD; + goto cleanup; } fprintf(stdout, "easy handle init OK\n"); @@ -96,7 +98,8 @@ int test(char *URL) hp = Curl_mk_dnscache(); if(!hp) { fprintf(stdout, "hash creation failed\n"); - return TEST_ERR_MAJOR_BAD; + result = TEST_ERR_MAJOR_BAD; + goto cleanup; } fprintf(stdout, "hash creation OK\n"); @@ -111,26 +114,36 @@ int test(char *URL) data_key = aprintf("%s:%d", "dummy", 0); if(!data_key) { fprintf(stdout, "data key creation failed\n"); - return TEST_ERR_MAJOR_BAD; + result = TEST_ERR_MAJOR_BAD; + goto cleanup; } key_len = strlen(data_key); data_node = calloc(1, sizeof(struct Curl_dns_entry)); if(!data_node) { fprintf(stdout, "data node creation failed\n"); - return TEST_ERR_MAJOR_BAD; + result = TEST_ERR_MAJOR_BAD; + free(data_key); + goto cleanup; } data_node->addr = fake_ai(); if(!data_node->addr) { fprintf(stdout, "actual data creation failed\n"); - return TEST_ERR_MAJOR_BAD; + result = TEST_ERR_MAJOR_BAD; + free(data_node); + free(data_key); + goto cleanup; } nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); if(!nodep) { fprintf(stdout, "insertion into hash failed\n"); - return TEST_ERR_MAJOR_BAD; + result = TEST_ERR_MAJOR_BAD; + Curl_freeaddrinfo(data_node->addr); + free(data_node); + free(data_key); + goto cleanup; } free(data_key); @@ -138,6 +151,8 @@ int test(char *URL) #endif /* LIB559 */ /**/ +cleanup: + fprintf(stdout, "destroying hash...\n"); Curl_hash_destroy(hp); fprintf(stdout, "hash destruction OK\n"); -- cgit v1.2.1 From 95a849efc2e37de5d45fbdadd04f00ff794e1307 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 7 Nov 2008 12:22:43 +0000 Subject: terminate with appropriate exit code --- tests/libtest/lib558.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index ceb42b1ee..6036fb2a8 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -163,7 +163,7 @@ cleanup: curl_global_cleanup(); - return 0; /* OK */ + return result; } -- cgit v1.2.1 From d07d1a6ef85d6e42d3e376935cdede698c968556 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 11 Nov 2008 21:59:25 +0000 Subject: Added test case 560: This test was added after the HTTPS-using-multi-interface with OpenSSL regression of 7.19.1 to hopefully prevent this embarassing mistake from appearing again... Unfortunately the bug wasn't triggered by this test, which presumably is because the connect to a local server is too fast/different compared to the real/distant servers we saw the bug happen with. --- tests/libtest/Makefile.am | 4 ++- tests/libtest/lib560.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib560.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c5aefd475..ed2c18dbf 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,7 +53,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 + lib539 lib557 lib558 lib559 lib560 # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la @@ -168,3 +168,5 @@ lib558_CFLAGS = -DLIB558 lib559_SOURCES = lib558.c $(SUPPORTFILES) lib559_CFLAGS = -DLIB559 + +lib560_SOURCES = lib560.c $(SUPPORTFILES) diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c new file mode 100644 index 000000000..e9d51c4d1 --- /dev/null +++ b/tests/libtest/lib560.c @@ -0,0 +1,92 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + */ +#include "test.h" + +/* + * Simply download a HTTPS file! + * + * This test was added after the HTTPS-using-multi-interface with OpenSSL + * regression of 7.19.1 to hopefully prevent this embarassing mistake from + * appearing again... Unfortunately the bug wasn't triggered by this test, + * which presumably is because the connect to a local server is too + * fast/different compared to the real/distant servers we saw the bug happen + * with. + */ +int test(char *URL) +{ + CURL *http_handle; + CURLM *multi_handle; + + int still_running; /* keep number of running handles */ + + http_handle = curl_easy_init(); + + /* set options */ + curl_easy_setopt(http_handle, CURLOPT_URL, URL); + curl_easy_setopt(http_handle, CURLOPT_HEADER, 1L); + curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L); + + /* init a multi stack */ + multi_handle = curl_multi_init(); + + /* add the individual transfers */ + curl_multi_add_handle(multi_handle, http_handle); + + /* we start some action by calling perform right away */ + while(CURLM_CALL_MULTI_PERFORM == + curl_multi_perform(multi_handle, &still_running)); + + while(still_running) { + struct timeval timeout; + int rc; /* select() return code */ + + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd; + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + /* set a suitable timeout to play around with */ + timeout.tv_sec = 1; + 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 */ + while(CURLM_CALL_MULTI_PERFORM == + curl_multi_perform(multi_handle, &still_running)); + break; + } + } + + curl_multi_cleanup(multi_handle); + + curl_easy_cleanup(http_handle); + + return 0; +} -- cgit v1.2.1 From b2ed1e2607532ce56f06bd8d2eaff98df981f321 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 12 Nov 2008 22:26:06 +0000 Subject: Fixed an OOM problem with test 560 --- tests/libtest/lib560.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index e9d51c4d1..d2de7bfb4 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -28,6 +28,8 @@ int test(char *URL) int still_running; /* keep number of running handles */ http_handle = curl_easy_init(); + if (!http_handle) + return TEST_ERR_MAJOR_BAD; /* set options */ curl_easy_setopt(http_handle, CURLOPT_URL, URL); @@ -37,6 +39,10 @@ int test(char *URL) /* init a multi stack */ multi_handle = curl_multi_init(); + if (!multi_handle) { + curl_easy_cleanup(http_handle); + return TEST_ERR_MAJOR_BAD; + } /* add the individual transfers */ curl_multi_add_handle(multi_handle, http_handle); -- cgit v1.2.1 From 6bb9ef8de4273e0f5f5e499eb61a972b3644f70f Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 21 Jan 2009 04:30:05 +0000 Subject: Call setlocale() for libtest tests to test the effects of locale-induced libc changes on libcurl. --- tests/libtest/first.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 9b06f74bc..032704ca0 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -10,6 +10,10 @@ #include "test.h" +#ifdef HAVE_LOCALE_H +#include /* for setlocale() */ +#endif + #ifdef CURLDEBUG # define MEMDEBUG_NODEFINES # include "memdebug.h" @@ -60,6 +64,16 @@ int main(int argc, char **argv) curl_free(env); } #endif + + /* + * Setup proper locale from environment. This is needed to enable locale- + * specific behaviour by the C library in order to test for undesired side + * effects that could cause in libcurl. + */ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + if(argc< 2 ) { fprintf(stderr, "Pass URL as argument please\n"); return 1; -- cgit v1.2.1 From b85154f13fa5bf25d7da2fa4eaa05fb683ba3aa3 Mon Sep 17 00:00:00 2001 From: Benoit Neil Date: Mon, 6 Apr 2009 21:05:44 +0000 Subject: Added tests (exes) targets, refactor a few things. PS: Once again, sorry if the added files have executable perms on Linux. --- tests/libtest/CMakeLists.txt | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/libtest/CMakeLists.txt (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt new file mode 100644 index 000000000..b0bf77187 --- /dev/null +++ b/tests/libtest/CMakeLists.txt @@ -0,0 +1,76 @@ + +MACRO(SETUP_TEST TEST_NAME) # ARGN are the files in the test + ADD_EXECUTABLE( ${TEST_NAME} ${ARGN} ) + STRING(TOUPPER TEST_NAME UPPER_TEST_NAME) + + INCLUDE_DIRECTORIES( + ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h" + ${CURL_BINARY_DIR}/lib # To be able to reach "config.h" + ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h" + ) + + SETUP_CURL_DEPENDENCIES(${TEST_NAME}) + TARGET_LINK_LIBRARIES( ${TEST_NAME} libcurl ) + + ADD_DEFINITIONS( "-D${UPPER_TEST_NAME}" ) + + # Add the postfix to the executable since it is not added automatically as for modules and shared libraries + SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") + + IF(MSVC) + IF(NOT BUILD_RELEASE_DEBUG_DIRS) + # Ugly workaround to remove the "/debug" or "/release" in each output + SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES PREFIX "../") + ENDIF() + ENDIF() + +ENDMACRO() + + + +# files used only in some libcurl test programs +SET(TESTUTIL testutil.c testutil.h) + +# these files are used in every single test program below +SET(SUPPORTFILES first.c test.h) + +# These are all libcurl test programs +SET(noinst_PROGRAMS + lib500 lib501 lib502 lib503 lib504 lib505 lib506 + lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 + lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 #lib527 + #lib529 + lib530 + #lib532 + lib533 lib536 lib537 lib540 lib541 lib542 lib543 + lib544 + #lib545 + lib547 + #lib548 + lib549 lib552 lib553 lib554 lib555 lib556 + lib539 lib557 lib558 + #lib559 + lib560 +) + +SET(noinst_PROGRAMS_USE_TESTUTIL + lib502 lib503 lib504 + lib507 + lib525 lib526 #lib527 + #lib529 + lib530 + #lib532 + lib533 lib536 + lib555 +) + + +FOREACH(TEST_NAME ${noinst_PROGRAMS}) + SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES}) + LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL) + IF(NOT ${USES_TESTUTIL} EQUAL -1) + LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil + ENDIF() + SETUP_TEST(${TEST_NAME} ${SOURCE}) +ENDFOREACH() + -- cgit v1.2.1 From e9dd0998706a0ce099826b982bbb1671909fe026 Mon Sep 17 00:00:00 2001 From: Benoit Neil Date: Tue, 7 Apr 2009 21:59:15 +0000 Subject: Added missing tests in CMake, added Makefile.inc for tests (+ use in CMake scripts), and fixed a missing define under windows in a test source file. --- tests/libtest/CMakeLists.txt | 128 ++++++++++++++++++++++++++++--------------- tests/libtest/Makefile.am | 127 +----------------------------------------- tests/libtest/Makefile.inc | 125 ++++++++++++++++++++++++++++++++++++++++++ tests/libtest/lib556.c | 12 +++- 4 files changed, 223 insertions(+), 169 deletions(-) create mode 100644 tests/libtest/Makefile.inc (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index b0bf77187..247d63c3b 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -27,50 +27,92 @@ MACRO(SETUP_TEST TEST_NAME) # ARGN are the files in the test ENDMACRO() - -# files used only in some libcurl test programs -SET(TESTUTIL testutil.c testutil.h) - -# these files are used in every single test program below -SET(SUPPORTFILES first.c test.h) - -# These are all libcurl test programs -SET(noinst_PROGRAMS - lib500 lib501 lib502 lib503 lib504 lib505 lib506 - lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 - lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 #lib527 - #lib529 - lib530 - #lib532 - lib533 lib536 lib537 lib540 lib541 lib542 lib543 - lib544 - #lib545 - lib547 - #lib548 - lib549 lib552 lib553 lib554 lib555 lib556 - lib539 lib557 lib558 - #lib559 - lib560 -) - -SET(noinst_PROGRAMS_USE_TESTUTIL - lib502 lib503 lib504 - lib507 - lib525 lib526 #lib527 - #lib529 - lib530 - #lib532 - lib533 lib536 - lib555 -) - +TRANSFORM_MAKEFILE_INC("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") +INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) FOREACH(TEST_NAME ${noinst_PROGRAMS}) - SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES}) - LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL) - IF(NOT ${USES_TESTUTIL} EQUAL -1) - LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil - ENDIF() - SETUP_TEST(${TEST_NAME} ${SOURCE}) + SETUP_TEST(${TEST_NAME} ${${TEST_NAME}_SOURCES}) ENDFOREACH() + +# # files used only in some libcurl test programs +# SET(TESTUTIL testutil.c testutil.h) + +# # these files are used in every single test program below +# SET(SUPPORTFILES first.c test.h) + +# # These are all libcurl test programs +# SET(noinst_PROGRAMS + # lib500 lib501 lib502 lib503 lib504 lib505 lib506 + # lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 + # lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 + # #lib527 + # #lib529 + # lib530 + # #lib532 + # lib533 lib536 lib537 lib540 lib541 lib542 lib543 + # lib544 + # #lib545 + # lib547 + # #lib548 + # lib549 lib552 lib553 lib554 lib555 lib556 + # lib539 lib557 lib558 + # #lib559 + # lib560 +# ) + +# SET(noinst_PROGRAMS_USE_TESTUTIL + # lib502 lib503 lib504 + # lib507 + # lib525 lib526 lib527 + # lib529 + # lib530 + # lib532 + # lib533 lib536 + # lib555 +# ) + +# MACRO(ADD_TESTUTIL_IF_NECESSARY TEST_NAME) + # LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL) + # IF(NOT ${USES_TESTUTIL} EQUAL -1) + # LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil + # ENDIF() +# ENDMACRO() + +# # General case +# FOREACH(TEST_NAME ${noinst_PROGRAMS}) + # SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES}) + # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) + # SETUP_TEST(${TEST_NAME} ${SOURCE}) +# ENDFOREACH() + +# # Special cases +# SET(TEST_NAME lib527) +# SET(SOURCE "lib526.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) + +# SET(TEST_NAME lib529) +# SET(SOURCE "lib525.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) + +# SET(TEST_NAME lib532) +# SET(SOURCE "lib526.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) + +# SET(TEST_NAME lib545) +# SET(SOURCE "lib544.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) + +# SET(TEST_NAME lib548) +# SET(SOURCE "lib547.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) + +# SET(TEST_NAME lib559) +# SET(SOURCE "lib558.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index ed2c18dbf..21d89808f 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -41,132 +41,9 @@ LIBDIR = $(top_builddir)/lib EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl -# files used only in some libcurl test programs -TESTUTIL = testutil.c testutil.h - -# these files are used in every single test program below -SUPPORTFILES = first.c test.h - -# These are all libcurl test programs -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ - lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ - lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ - lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 - # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la DEPENDENCIES = $(LIBDIR)/libcurl.la - -lib500_SOURCES = lib500.c $(SUPPORTFILES) - -lib501_SOURCES = lib501.c $(SUPPORTFILES) - -lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) - -lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) - -lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) - -lib505_SOURCES = lib505.c $(SUPPORTFILES) - -lib506_SOURCES = lib506.c $(SUPPORTFILES) - -lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) - -lib508_SOURCES = lib508.c $(SUPPORTFILES) - -lib510_SOURCES = lib510.c $(SUPPORTFILES) - -lib511_SOURCES = lib511.c $(SUPPORTFILES) - -lib512_SOURCES = lib512.c $(SUPPORTFILES) - -lib513_SOURCES = lib513.c $(SUPPORTFILES) - -lib514_SOURCES = lib514.c $(SUPPORTFILES) - -lib515_SOURCES = lib515.c $(SUPPORTFILES) - -lib516_SOURCES = lib516.c $(SUPPORTFILES) - -lib517_SOURCES = lib517.c $(SUPPORTFILES) - -lib518_SOURCES = lib518.c $(SUPPORTFILES) - -lib519_SOURCES = lib519.c $(SUPPORTFILES) - -lib520_SOURCES = lib520.c $(SUPPORTFILES) - -lib521_SOURCES = lib521.c $(SUPPORTFILES) - -lib523_SOURCES = lib523.c $(SUPPORTFILES) - -lib524_SOURCES = lib524.c $(SUPPORTFILES) - -lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) - -lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) -lib526_CFLAGS = -DLIB526 - -lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) -lib527_CFLAGS = -DLIB527 - -lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) -lib529_CFLAGS = -DLIB529 - -lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) -lib530_CFLAGS = -DLIB530 - -lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) -lib532_CFLAGS = -DLIB532 - -lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) - -lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) - -lib537_SOURCES = lib537.c $(SUPPORTFILES) - -lib539_SOURCES = lib539.c $(SUPPORTFILES) - -lib540_SOURCES = lib540.c $(SUPPORTFILES) - -lib541_SOURCES = lib541.c $(SUPPORTFILES) - -lib542_SOURCES = lib542.c $(SUPPORTFILES) - -lib543_SOURCES = lib543.c $(SUPPORTFILES) - -lib544_SOURCES = lib544.c $(SUPPORTFILES) - -lib545_SOURCES = lib544.c $(SUPPORTFILES) -lib545_CFLAGS = -DLIB545 - -lib547_SOURCES = lib547.c $(SUPPORTFILES) - -lib548_SOURCES = lib547.c $(SUPPORTFILES) -lib548_CFLAGS = -DLIB548 - -lib549_SOURCES = lib549.c $(SUPPORTFILES) - -lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) - -lib552_SOURCES = lib552.c $(SUPPORTFILES) - -lib553_SOURCES = lib553.c $(SUPPORTFILES) - -lib554_SOURCES = lib554.c $(SUPPORTFILES) - -lib556_SOURCES = lib556.c $(SUPPORTFILES) - -lib557_SOURCES = lib557.c $(SUPPORTFILES) - -lib558_SOURCES = lib558.c $(SUPPORTFILES) -lib558_CFLAGS = -DLIB558 - -lib559_SOURCES = lib558.c $(SUPPORTFILES) -lib559_CFLAGS = -DLIB559 - -lib560_SOURCES = lib560.c $(SUPPORTFILES) +# Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) +include Makefile.inc diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc new file mode 100644 index 000000000..6b1965f80 --- /dev/null +++ b/tests/libtest/Makefile.inc @@ -0,0 +1,125 @@ +# files used only in some libcurl test programs +TESTUTIL = testutil.c testutil.h + +# these files are used in every single test program below +SUPPORTFILES = first.c test.h + +# These are all libcurl test programs +noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ + lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ + lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ + lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ + lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ + lib539 lib557 lib558 lib559 lib560 + + +lib500_SOURCES = lib500.c $(SUPPORTFILES) + +lib501_SOURCES = lib501.c $(SUPPORTFILES) + +lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) + +lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) + +lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) + +lib505_SOURCES = lib505.c $(SUPPORTFILES) + +lib506_SOURCES = lib506.c $(SUPPORTFILES) + +lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) + +lib508_SOURCES = lib508.c $(SUPPORTFILES) + +lib510_SOURCES = lib510.c $(SUPPORTFILES) + +lib511_SOURCES = lib511.c $(SUPPORTFILES) + +lib512_SOURCES = lib512.c $(SUPPORTFILES) + +lib513_SOURCES = lib513.c $(SUPPORTFILES) + +lib514_SOURCES = lib514.c $(SUPPORTFILES) + +lib515_SOURCES = lib515.c $(SUPPORTFILES) + +lib516_SOURCES = lib516.c $(SUPPORTFILES) + +lib517_SOURCES = lib517.c $(SUPPORTFILES) + +lib518_SOURCES = lib518.c $(SUPPORTFILES) + +lib519_SOURCES = lib519.c $(SUPPORTFILES) + +lib520_SOURCES = lib520.c $(SUPPORTFILES) + +lib521_SOURCES = lib521.c $(SUPPORTFILES) + +lib523_SOURCES = lib523.c $(SUPPORTFILES) + +lib524_SOURCES = lib524.c $(SUPPORTFILES) + +lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) + +lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) +lib526_CFLAGS = -DLIB526 + +lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) +lib527_CFLAGS = -DLIB527 + +lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) +lib529_CFLAGS = -DLIB529 + +lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) +lib530_CFLAGS = -DLIB530 + +lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) +lib532_CFLAGS = -DLIB532 + +lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) + +lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) + +lib537_SOURCES = lib537.c $(SUPPORTFILES) + +lib539_SOURCES = lib539.c $(SUPPORTFILES) + +lib540_SOURCES = lib540.c $(SUPPORTFILES) + +lib541_SOURCES = lib541.c $(SUPPORTFILES) + +lib542_SOURCES = lib542.c $(SUPPORTFILES) + +lib543_SOURCES = lib543.c $(SUPPORTFILES) + +lib544_SOURCES = lib544.c $(SUPPORTFILES) + +lib545_SOURCES = lib544.c $(SUPPORTFILES) +lib545_CFLAGS = -DLIB545 + +lib547_SOURCES = lib547.c $(SUPPORTFILES) + +lib548_SOURCES = lib547.c $(SUPPORTFILES) +lib548_CFLAGS = -DLIB548 + +lib549_SOURCES = lib549.c $(SUPPORTFILES) + +lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) + +lib552_SOURCES = lib552.c $(SUPPORTFILES) + +lib553_SOURCES = lib553.c $(SUPPORTFILES) + +lib554_SOURCES = lib554.c $(SUPPORTFILES) + +lib556_SOURCES = lib556.c $(SUPPORTFILES) + +lib557_SOURCES = lib557.c $(SUPPORTFILES) + +lib558_SOURCES = lib558.c $(SUPPORTFILES) +lib558_CFLAGS = -DLIB558 + +lib559_SOURCES = lib558.c $(SUPPORTFILES) +lib559_CFLAGS = -DLIB559 + +lib560_SOURCES = lib560.c $(SUPPORTFILES) diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 0e3949da3..579321ed9 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -12,6 +12,17 @@ #include "memdebug.h" +/* For Windows, mainly (may be moved in a config file?) */ +#ifndef STDIN_FILENO + #define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO + #define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO + #define STDERR_FILENO 2 +#endif + int test(char *URL) { CURLcode res; @@ -53,7 +64,6 @@ int test(char *URL) if(iolen) /* send received stuff to stdout */ write(STDOUT_FILENO, buf, iolen); - total += iolen; } while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129)); -- cgit v1.2.1 From c4fba310d2d36c607af3173fac8aa17523d0c7a4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 7 Apr 2009 22:07:07 +0000 Subject: and include the .inc files in the release tarballs... --- tests/libtest/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 21d89808f..770abf6ca 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -39,7 +39,8 @@ INCLUDES = -I$(top_builddir)/include \ LIBDIR = $(top_builddir)/lib -EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl test1022.pl +EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ +test1022.pl Makefile.inc # Dependencies (may need to be overriden) LDADD = $(LIBDIR)/libcurl.la -- cgit v1.2.1 From 25f626cc52561547034bc070b92b81606b9ba473 Mon Sep 17 00:00:00 2001 From: Benoit Neil Date: Wed, 8 Apr 2009 11:42:45 +0000 Subject: Fixed compile defines in CMake scripts --- tests/libtest/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 247d63c3b..7b9f383b0 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -1,7 +1,7 @@ -MACRO(SETUP_TEST TEST_NAME) # ARGN are the files in the test +FUNCTION(SETUP_TEST TEST_NAME) # ARGN are the files in the test ADD_EXECUTABLE( ${TEST_NAME} ${ARGN} ) - STRING(TOUPPER TEST_NAME UPPER_TEST_NAME) + STRING(TOUPPER ${TEST_NAME} UPPER_TEST_NAME) INCLUDE_DIRECTORIES( ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h" @@ -12,8 +12,8 @@ MACRO(SETUP_TEST TEST_NAME) # ARGN are the files in the test SETUP_CURL_DEPENDENCIES(${TEST_NAME}) TARGET_LINK_LIBRARIES( ${TEST_NAME} libcurl ) - ADD_DEFINITIONS( "-D${UPPER_TEST_NAME}" ) - + SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME}) + # Add the postfix to the executable since it is not added automatically as for modules and shared libraries SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") @@ -21,10 +21,11 @@ MACRO(SETUP_TEST TEST_NAME) # ARGN are the files in the test IF(NOT BUILD_RELEASE_DEBUG_DIRS) # Ugly workaround to remove the "/debug" or "/release" in each output SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES PREFIX "../") + SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES IMPORT_PREFIX "../") ENDIF() ENDIF() -ENDMACRO() +ENDFUNCTION() TRANSFORM_MAKEFILE_INC("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") -- cgit v1.2.1 From e5f1480a384729e9423ed0f2591a5cf02e9b943f Mon Sep 17 00:00:00 2001 From: Benoit Neil Date: Wed, 8 Apr 2009 23:48:07 +0000 Subject: (Minor update) Added labal prefixes to tests targets --- tests/libtest/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 7b9f383b0..4d55cfe05 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -1,3 +1,4 @@ +SET(TARGET_LABEL_PREFIX "Test ") FUNCTION(SETUP_TEST TEST_NAME) # ARGN are the files in the test ADD_EXECUTABLE( ${TEST_NAME} ${ARGN} ) @@ -13,6 +14,7 @@ FUNCTION(SETUP_TEST TEST_NAME) # ARGN are the files in the test TARGET_LINK_LIBRARIES( ${TEST_NAME} libcurl ) SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME}) + SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}") # Add the postfix to the executable since it is not added automatically as for modules and shared libraries SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") -- cgit v1.2.1 From 63fad159e84d5ea86ddb28dc1c1aad8459d98554 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 9 Apr 2009 01:24:41 +0000 Subject: Skip test #558 and #559 also when using a Win32 DLL --- tests/libtest/lib558.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 6036fb2a8..eebf6dfa5 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -42,8 +42,16 @@ * ones in the public API. */ +#if defined(CURL_HIDDEN_SYMBOLS) +# define SKIP_TEST 1 +#elif defined(WIN32) && !defined(CURL_STATICLIB) +# define SKIP_TEST 1 +#else +# undef SKIP_TEST +#endif + -#if !defined(CURL_HIDDEN_SYMBOLS) +#if !defined(SKIP_TEST) #ifdef LIB559 static Curl_addrinfo *fake_ai(void) @@ -167,7 +175,7 @@ cleanup: } -#else /* !defined(CURL_HIDDEN_SYMBOLS) */ +#else /* !defined(SKIP_TEST) */ int test(char *URL) @@ -178,4 +186,4 @@ int test(char *URL) } -#endif /* !defined(CURL_HIDDEN_SYMBOLS) */ +#endif /* !defined(SKIP_TEST) */ -- cgit v1.2.1 From c621546bd608d5f836d165c2a33ff3d37e2e21e5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 13 Apr 2009 07:18:39 +0000 Subject: fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value --- tests/libtest/lib556.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 579321ed9..cb57f763b 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -55,7 +55,7 @@ int test(char *URL) if(!res) { /* we assume that sending always work */ - int total=0; + size_t total=0; do { /* busy-read like crazy */ -- cgit v1.2.1 From c382c550e7d8ad54d2c35b0fea9d0eef09ff3a25 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 14 Apr 2009 12:53:53 +0000 Subject: fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value --- tests/libtest/lib543.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 662883529..852645695 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -22,7 +22,8 @@ int test(char *URL) 0x1d, 0x57, 0xe1}; CURL* easy = curl_easy_init(); - char* s = curl_easy_escape(easy, (char*)a, sizeof(a)); + int asize = (int)sizeof(a); + char* s = curl_easy_escape(easy, (char*)a, asize); (void)URL; printf("%s\n", s); -- cgit v1.2.1 From 33a3753c3f41d546ebf3350685eb7201d25783f4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 21 Apr 2009 11:46:16 +0000 Subject: libcurl's memory.h renamed to curl_memory.h --- tests/libtest/lib558.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index eebf6dfa5..253e043e1 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -29,7 +29,7 @@ #include "hash.h" #include "hostip.h" -#include "memory.h" +#include "curl_memory.h" #include "memdebug.h" /* This source file is used for test # 558 and 559 */ -- cgit v1.2.1 From 6b95c4e358f3bcaf60471353c54c5c32d596a536 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 30 Apr 2009 09:02:39 +0000 Subject: - I was going to fix issue #59 in KNOWN_BUGS If the CURLOPT_PORT option is used on an FTP URL like "ftp://example.com/file;type=A" the ";type=A" is stripped off. I added test case 562 to verify, only to find out that I couldn't repeat this bug so I hereby consider it not a bug anymore! --- tests/libtest/Makefile.inc | 4 ++- tests/libtest/lib562.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib562.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 6b1965f80..37724cacb 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -10,7 +10,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 + lib539 lib557 lib558 lib559 lib560 lib562 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -123,3 +123,5 @@ lib559_SOURCES = lib558.c $(SUPPORTFILES) lib559_CFLAGS = -DLIB559 lib560_SOURCES = lib560.c $(SUPPORTFILES) + +lib562_SOURCES = lib562.c $(SUPPORTFILES) diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c new file mode 100644 index 000000000..b11ff1646 --- /dev/null +++ b/tests/libtest/lib562.c @@ -0,0 +1,74 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "setup.h" /* struct_stat etc. */ +#include "test.h" + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "memdebug.h" + +/* + * From "KNOWN_BUGS" April 2009: + + 59. If the CURLOPT_PORT option is used on an FTP URL like + "ftp://example.com/file;type=A" the ";type=A" is stripped off. + + */ + +int test(char *URL) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + /* get a curl handle */ + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* enable verbose */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* set port number */ + curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) ); + + /* specify target */ + curl_easy_setopt(curl,CURLOPT_URL, URL); + + /* Now run off and do what you've been told! */ + res = curl_easy_perform(curl); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From 5a91746b80fd41b9915574d8514f1d40e9cfd1b6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 1 May 2009 12:39:40 +0000 Subject: David McCreedy's "TPF-platform specific changes to various files" patch --- tests/libtest/test.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index b4541c6c4..c66fd61d7 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -33,6 +33,10 @@ #include #endif +#ifdef TPF +# include "select.h" +#endif + #define TEST_ERR_MAJOR_BAD 100 #define TEST_ERR_RUNS_FOREVER 99 -- cgit v1.2.1 From c5c03ac5563961cbcbcb2a1cc3e8963d0c49e154 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 8 May 2009 02:14:50 +0000 Subject: Fixes for non-ASCII platforms by David McCreedy --- tests/libtest/lib506.c | 2 +- tests/libtest/lib508.c | 5 +++++ tests/libtest/lib510.c | 5 +++++ tests/libtest/lib544.c | 7 +++++++ tests/libtest/lib547.c | 9 ++++++++- tests/libtest/lib552.c | 5 +++++ tests/libtest/lib553.c | 4 ++++ tests/libtest/lib554.c | 23 ++++++++++++++++++++++- tests/libtest/lib555.c | 7 +++++++ tests/libtest/lib556.c | 14 +++++++++++++- 10 files changed, 77 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 34c774e5d..823e05d3e 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -132,7 +132,7 @@ static void *fire(void *ptr) /* build request url */ static char *suburl(const char *base, int i) { - return curl_maprintf("%s000%c", base, 48+i); + return curl_maprintf("%s%.4d", base, i); } diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index a709b80be..6de7e7bcd 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -63,6 +63,11 @@ int test(char *URL) /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + /* Set the expected POST size */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 43ead0936..c890f9d45 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -78,6 +78,11 @@ int test(char *URL) /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 756291972..b17e64af2 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -13,7 +13,14 @@ #include "memdebug.h" static char teststring[] = +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61" + "\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d" + "\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a"; +#else "This\0 is test binary data with an embedded NUL byte\n"; +#endif int test(char *URL) diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 8a1070f70..a8f73eb5f 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -16,7 +16,14 @@ #include "memdebug.h" -#define UPLOADTHIS "this is the blurb we want to upload\n" +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ +# define UPLOADTHIS "\x74\x68\x69\x73\x20\x69\x73\x20\x74\x68\x65\x20\x62" \ + "\x6c\x75\x72\x62\x20\x77\x65\x20\x77\x61\x6e\x74\x20" \ + "\x74\x6f\x20\x75\x70\x6c\x6f\x61\x64\x0a" +#else +# define UPLOADTHIS "this is the blurb we want to upload\n" +#endif #ifndef LIB548 static size_t readcallback(void *ptr, diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index ff2b8c986..ce7ca1676 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -169,6 +169,11 @@ int test(char *URL) /* Post */ curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + /* Setup read callback */ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 0a6fdcbdb..7af9e4e42 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -70,6 +70,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_URL, URL); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_HEADER, 1L); diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 2999aea08..0a7c35d54 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -12,7 +12,15 @@ #include "memdebug.h" -static char data[]="this is what we post to the silly web server\n"; +static char data[]= +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x74\x68\x69\x73\x20\x69\x73\x20\x77\x68\x61\x74\x20\x77\x65\x20\x70" + "\x6f\x73\x74\x20\x74\x6f\x20\x74\x68\x65\x20\x73\x69\x6c\x6c\x79\x20" + "\x77\x65\x62\x20\x73\x65\x72\x76\x65\x72\x0a"; +#else + "this is what we post to the silly web server\n"; +#endif struct WriteThis { char *readptr; @@ -70,7 +78,14 @@ int test(char *URL) formrc = curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "filename", +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape + sequences for non-ASCII platforms */ + CURLFORM_COPYCONTENTS, + "\x70\x6f\x73\x74\x69\x74\x32\x2e\x63", +#else CURLFORM_COPYCONTENTS, "postit2.c", +#endif CURLFORM_END); if(formrc) @@ -80,7 +95,13 @@ int test(char *URL) formrc = curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape + sequences for non-ASCII platforms */ + CURLFORM_COPYCONTENTS, "\x73\x65\x6e\x64", +#else CURLFORM_COPYCONTENTS, "send", +#endif CURLFORM_END); if(formrc) diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 33a1a26c7..0b9d27ae0 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -93,6 +93,10 @@ int test(char *URL) curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); curl_easy_setopt(curl, CURLOPT_POST, 1L); +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII. */ + curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); curl_easy_setopt(curl, CURLOPT_PROXYAUTH, @@ -124,6 +128,9 @@ int test(char *URL) mp_timedout = TRUE; break; } +#ifdef TPF + sleep(1); /* avoid ctl-10 dump */ +#endif if (running <= 0) { fprintf(stderr, "nothing left running.\n"); break; diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index cb57f763b..1466e40c0 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -46,8 +46,16 @@ int test(char *URL) if(!res) { /* we are connected, now get a HTTP document the raw way */ - const char *request = "GET /556 HTTP/1.2\r\n" + const char *request = +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e" + "\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a" + "\x0d\x0a"; +#else + "GET /556 HTTP/1.2\r\n" "Host: ninja\r\n\r\n"; +#endif size_t iolen; char buf[1024]; @@ -61,6 +69,10 @@ int test(char *URL) /* busy-read like crazy */ res = curl_easy_recv(curl, buf, 1024, &iolen); +#ifdef TPF + sleep(1); /* avoid ctl-10 dump */ +#endif + if(iolen) /* send received stuff to stdout */ write(STDOUT_FILENO, buf, iolen); -- cgit v1.2.1 From e6e6c6e635b72502a1bfc24cd407a82f9ecd82e2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 11 May 2009 11:43:55 +0000 Subject: Added test 564 as DISABLED. It is for testing FTP over a SOCK4 proxy using the multi interface, which currently doesn't work because of how the data connection is not waiting for connect before it tries to do proxy magic. --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib564.c | 144 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib564.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 37724cacb..328b5dd16 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -10,7 +10,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 lib562 + lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -125,3 +125,5 @@ lib559_CFLAGS = -DLIB559 lib560_SOURCES = lib560.c $(SUPPORTFILES) lib562_SOURCES = lib562.c $(SUPPORTFILES) + +lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c new file mode 100644 index 000000000..6a1f74621 --- /dev/null +++ b/tests/libtest/lib564.c @@ -0,0 +1,144 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +/* used for test case 533, 534 and 535 */ + +#include "test.h" + +#include +#include +#include + +#include "testutil.h" +#include "memdebug.h" + +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 + +int test(char *URL) +{ + int res = 0; + CURL *curl; + int running; + char done=FALSE; + CURLM *m; + 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; + } + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); + + 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; + } + + 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; + } + + ml_timedout = FALSE; + ml_start = tutil_tvnow(); + + fprintf(stderr, "Start at URL 0\n"); + + while (!done) { + fd_set rd, wr, exc; + int max_fd; + struct timeval interval; + + 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; + } + + 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; + } + + if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { + fprintf(stderr, "bad select??\n"); + res = 195; + break; + } + + res = CURLM_CALL_MULTI_PERFORM; + } + + 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; + } + + curl_easy_cleanup(curl); + curl_multi_cleanup(m); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From 90cd2a47535e7420747e1f47491a1d372767e109 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 15 May 2009 10:16:33 +0000 Subject: fix compiler warning: unused variable --- tests/libtest/lib564.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index 6a1f74621..e04a5aba1 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -8,8 +8,6 @@ * $Id$ */ -/* used for test case 533, 534 and 535 */ - #include "test.h" #include @@ -29,7 +27,6 @@ int test(char *URL) int running; char done=FALSE; CURLM *m; - int current=0; struct timeval ml_start; struct timeval mp_start; char ml_timedout = FALSE; -- cgit v1.2.1 From cd5e6743f744503f357b0877d6b5bad96ae53d1f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 30 May 2009 15:56:42 +0000 Subject: Delegate c-ares linking magic on libtool and auto-makefiles when using the uninstalled c-ares libtool archive built from the CVS embedded tree. --- tests/libtest/Makefile.am | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 770abf6ca..228ae6b49 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -42,9 +42,15 @@ LIBDIR = $(top_builddir)/lib EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc +if USE_EMBEDDED_ARES +EMBEDDEDARES = $(top_builddir)/ares/libcares.la +else +EMBEDDEDARES = +endif + # Dependencies (may need to be overriden) -LDADD = $(LIBDIR)/libcurl.la -DEPENDENCIES = $(LIBDIR)/libcurl.la +LDADD = $(LIBDIR)/libcurl.la $(EMBEDDEDARES) +DEPENDENCIES = $(LIBDIR)/libcurl.la $(EMBEDDEDARES) # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) include Makefile.inc -- cgit v1.2.1 From 13fdb9d8a56deff52eb16bce6b78e6710a42958a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 4 Jun 2009 04:13:39 +0000 Subject: c-ares embbeded builds header include paths fully defined in makefiles --- tests/libtest/Makefile.am | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 228ae6b49..a4ce4b14e 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -31,11 +31,22 @@ AUTOMAKE_OPTIONS = foreign nostdinc # $(top_srcdir)/include is for libcurl's external include files # $(top_builddir)/lib is for libcurl's generated lib/config.h file # $(top_srcdir)/lib is for libcurl's lib/setup.h and other "borrowed" files +# $(top_builddir)/ares is for in-tree c-ares's generated ares_build.h file +# $(top_srcdir)/ares is for in-tree c-ares's external include files +if USE_EMBEDDED_ARES +INCLUDES = -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_builddir)/ares \ + -I$(top_srcdir)/ares +else INCLUDES = -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib +endif LIBDIR = $(top_builddir)/lib -- cgit v1.2.1 From 8d581f7fe404eaad2defdeeeae456eb8463bbc56 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 6 Jun 2009 13:20:39 +0000 Subject: Revert delegating c-ares linking magic on libtool and auto-makefiles when using the uninstalled c-ares libtool archive built from the CVS embedded tree. This embedded c-ares linking is again handled from the configure script. --- tests/libtest/Makefile.am | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a4ce4b14e..c5b8762cf 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -48,20 +48,12 @@ INCLUDES = -I$(top_builddir)/include \ -I$(top_srcdir)/lib endif -LIBDIR = $(top_builddir)/lib - EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc -if USE_EMBEDDED_ARES -EMBEDDEDARES = $(top_builddir)/ares/libcares.la -else -EMBEDDEDARES = -endif - # Dependencies (may need to be overriden) -LDADD = $(LIBDIR)/libcurl.la $(EMBEDDEDARES) -DEPENDENCIES = $(LIBDIR)/libcurl.la $(EMBEDDEDARES) +LDADD = $(top_builddir)/lib/libcurl.la +DEPENDENCIES = $(top_builddir)/lib/libcurl.la # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) include Makefile.inc -- cgit v1.2.1 From 744dceaffe4f79293b6bdd9eefe64ca83c701876 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 9 Jun 2009 17:29:16 +0000 Subject: ENH: lower case cmake functions and remove tabs and re-indent cmake code --- tests/libtest/CMakeLists.txt | 122 ++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 59 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 4d55cfe05..08edbd0c9 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -1,41 +1,45 @@ -SET(TARGET_LABEL_PREFIX "Test ") +set(TARGET_LABEL_PREFIX "Test ") -FUNCTION(SETUP_TEST TEST_NAME) # ARGN are the files in the test - ADD_EXECUTABLE( ${TEST_NAME} ${ARGN} ) - STRING(TOUPPER ${TEST_NAME} UPPER_TEST_NAME) +function(SETUP_TEST TEST_NAME) # ARGN are the files in the test + add_executable( ${TEST_NAME} ${ARGN} ) + string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME) - INCLUDE_DIRECTORIES( - ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h" - ${CURL_BINARY_DIR}/lib # To be able to reach "config.h" - ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h" - ) + include_directories( + ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h" + ${CURL_BINARY_DIR}/lib # To be able to reach "config.h" + ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h" + ) - SETUP_CURL_DEPENDENCIES(${TEST_NAME}) - TARGET_LINK_LIBRARIES( ${TEST_NAME} libcurl ) + setup_curl_dependencies(${TEST_NAME}) + target_link_libraries( ${TEST_NAME} libcurl ) - SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME}) - SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}") + set_target_properties(${TEST_NAME} + PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME}) + set_target_properties(${TEST_NAME} + PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}") - # Add the postfix to the executable since it is not added automatically as for modules and shared libraries - SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") + # Add the postfix to the executable since it is + # not added automatically as for modules and shared libraries + set_target_properties(${TEST_NAME} + PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") - IF(MSVC) - IF(NOT BUILD_RELEASE_DEBUG_DIRS) - # Ugly workaround to remove the "/debug" or "/release" in each output - SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES PREFIX "../") - SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES IMPORT_PREFIX "../") - ENDIF() - ENDIF() + if(MSVC) + if(NOT BUILD_RELEASE_DEBUG_DIRS) + # Ugly workaround to remove the "/debug" or "/release" in each output + set_target_properties(${TEST_NAME} PROPERTIES PREFIX "../") + set_target_properties(${TEST_NAME} PROPERTIES IMPORT_PREFIX "../") + endif() + endif() -ENDFUNCTION() +endfunction() -TRANSFORM_MAKEFILE_INC("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") -INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) +transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") +include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) -FOREACH(TEST_NAME ${noinst_PROGRAMS}) - SETUP_TEST(${TEST_NAME} ${${TEST_NAME}_SOURCES}) -ENDFOREACH() +foreach(TEST_NAME ${noinst_PROGRAMS}) + setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES}) +endforeach() # # files used only in some libcurl test programs @@ -46,47 +50,47 @@ ENDFOREACH() # # These are all libcurl test programs # SET(noinst_PROGRAMS - # lib500 lib501 lib502 lib503 lib504 lib505 lib506 - # lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 - # lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 - # #lib527 - # #lib529 - # lib530 - # #lib532 - # lib533 lib536 lib537 lib540 lib541 lib542 lib543 - # lib544 - # #lib545 - # lib547 - # #lib548 - # lib549 lib552 lib553 lib554 lib555 lib556 - # lib539 lib557 lib558 - # #lib559 - # lib560 +# lib500 lib501 lib502 lib503 lib504 lib505 lib506 +# lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 +# lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 +# #lib527 +# #lib529 +# lib530 +# #lib532 +# lib533 lib536 lib537 lib540 lib541 lib542 lib543 +# lib544 +# #lib545 +# lib547 +# #lib548 +# lib549 lib552 lib553 lib554 lib555 lib556 +# lib539 lib557 lib558 +# #lib559 +# lib560 # ) # SET(noinst_PROGRAMS_USE_TESTUTIL - # lib502 lib503 lib504 - # lib507 - # lib525 lib526 lib527 - # lib529 - # lib530 - # lib532 - # lib533 lib536 - # lib555 +# lib502 lib503 lib504 +# lib507 +# lib525 lib526 lib527 +# lib529 +# lib530 +# lib532 +# lib533 lib536 +# lib555 # ) # MACRO(ADD_TESTUTIL_IF_NECESSARY TEST_NAME) - # LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL) - # IF(NOT ${USES_TESTUTIL} EQUAL -1) - # LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil - # ENDIF() +# LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL) +# IF(NOT ${USES_TESTUTIL} EQUAL -1) +# LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil +# ENDIF() # ENDMACRO() # # General case # FOREACH(TEST_NAME ${noinst_PROGRAMS}) - # SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES}) - # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) - # SETUP_TEST(${TEST_NAME} ${SOURCE}) +# SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES}) +# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) +# SETUP_TEST(${TEST_NAME} ${SOURCE}) # ENDFOREACH() # # Special cases -- cgit v1.2.1 From 1d97f13462897cacb8f8897fb0db07b663fd8645 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 10 Jun 2009 04:06:06 +0000 Subject: TrackMemory is another feature not supported by curl-config --- tests/libtest/test1013.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 6127df82a..8ab1a8c95 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -22,7 +22,7 @@ $curl_protocols =~ /\w+: (.*)$/; @curl = split / /,$1; # These features are not supported by curl-config -@curl = grep(!/^(Debug|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl); +@curl = grep(!/^(Debug|TrackMemory|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl); @curl = sort @curl; # Read the output of curl-config -- cgit v1.2.1 From f671d0513ccc9cdcd7516c732c719b2f31a9578e Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Tue, 14 Jul 2009 13:25:14 +0000 Subject: renamed generated config.h to curl_config.h in order to avoid clashes when libcurl is used with other projects which also have a config.h. --- tests/libtest/CMakeLists.txt | 2 +- tests/libtest/Makefile.am | 2 +- tests/libtest/test.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 08edbd0c9..74d841e01 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -6,7 +6,7 @@ function(SETUP_TEST TEST_NAME) # ARGN are the files in the test include_directories( ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h" - ${CURL_BINARY_DIR}/lib # To be able to reach "config.h" + ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h" ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h" ) diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c5b8762cf..68b446c12 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -29,7 +29,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc # # $(top_builddir)/include is for libcurl's generated curl/curlbuild.h file # $(top_srcdir)/include is for libcurl's external include files -# $(top_builddir)/lib is for libcurl's generated lib/config.h file +# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file # $(top_srcdir)/lib is for libcurl's lib/setup.h and other "borrowed" files # $(top_builddir)/ares is for in-tree c-ares's generated ares_build.h file # $(top_srcdir)/ares is for in-tree c-ares's external include files diff --git a/tests/libtest/test.h b/tests/libtest/test.h index c66fd61d7..66416b42a 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -9,9 +9,9 @@ */ /* Now include the setup.h file from libcurl's private libdir (the source - version, but that might include "config.h" from the build dir so we need - both of them in the include path), so that we get good in-depth knowledge - about the system we're building this on */ + version, but that might include "curl_config.h" from the build dir so we + need both of them in the include path), so that we get good in-depth + knowledge about the system we're building this on */ #include "setup.h" -- cgit v1.2.1 From a8ea1e9ef4ec959cfe95193318a05688f4610841 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 14 Jul 2009 19:03:31 +0000 Subject: ENH: add optional support for c-ares --- tests/libtest/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 74d841e01..f0ee8cd2b 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -9,7 +9,9 @@ function(SETUP_TEST TEST_NAME) # ARGN are the files in the test ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h" ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h" ) - + if(CURL_USE_ARES) + include_directories(${CARES_INCLUDE_DIR}) + endif() setup_curl_dependencies(${TEST_NAME}) target_link_libraries( ${TEST_NAME} libcurl ) -- cgit v1.2.1 From 9cff716925d8501992a10f09a53d4ad3ed3d919f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 22 Jul 2009 22:08:01 +0000 Subject: don't set READDATA since it isn't used and only confuses readers --- tests/libtest/lib554.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 0a7c35d54..4b62e927d 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -126,9 +126,6 @@ int test(char *URL) /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); - /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_READDATA, &pooh); - /* send a multi-part formpost */ curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); -- cgit v1.2.1 From be2fcbcbf12680cabf0d27493c91abf06c84c62a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 12 Aug 2009 11:18:55 +0000 Subject: Added a range of new fun date strings to try. This set of dates come from a mail posted to the http-state mailing list, from Adam Barth, and is said to be the set of date formats the Chrome browser code is tested against: http://www.ietf.org/mail-archive/web/http-state/current/msg00129.html libcurl parses most of them identically, but not all of them. --- tests/libtest/lib517.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 86539fb73..5f8971f8c 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -38,6 +38,61 @@ static const char *dates[]={ "Thu, 01-Jan-1970 00:59:59 GMT", "Thu, 01-Jan-1970 01:00:00 GMT", /* "2094 Nov 6", See ../data/test517 for details */ + "Sat, 15-Apr-17 21:01:22 GMT", + "Thu, 19-Apr-2007 16:00:00 GMT", + "Wed, 25 Apr 2007 21:02:13 GMT", + "Thu, 19/Apr\\2007 16:00:00 GMT", + "Fri, 1 Jan 2010 01:01:50 GMT", + "Wednesday, 1-Jan-2003 00:00:00 GMT", + ", 1-Jan-2003 00:00:00 GMT", + " 1-Jan-2003 00:00:00 GMT", + "1-Jan-2003 00:00:00 GMT", + "Wed,18-Apr-07 22:50:12 GMT", + "WillyWonka , 18-Apr-07 22:50:12 GMT", + "WillyWonka , 18-Apr-07 22:50:12", + "WillyWonka , 18-apr-07 22:50:12", + "Mon, 18-Apr-1977 22:50:13 GMT", + "Mon, 18-Apr-77 22:50:13 GMT", + "\"Sat, 15-Apr-17\\\"21:01:22\\\"GMT\"", + "Partyday, 18- April-07 22:50:12", + "Partyday, 18 - Apri-07 22:50:12", + "Wednes, 1-Januar-2003 00:00:00 GMT", + "Sat, 15-Apr-17 21:01:22", + "Sat, 15-Apr-17 21:01:22 GMT-2", + "Sat, 15-Apr-17 21:01:22 GMT BLAH", + "Sat, 15-Apr-17 21:01:22 GMT-0400", + "Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", + "Sat, 15-Apr-17 21:01:22 DST", + "Sat, 15-Apr-17 21:01:22 -0400", + "Sat, 15-Apr-17 21:01:22 (hello there)", + "Sat, 15-Apr-17 21:01:22 11:22:33", + "Sat, 15-Apr-17 ::00 21:01:22", + "Sat, 15-Apr-17 boink:z 21:01:22", + "Sat, 15-Apr-17 91:22:33 21:01:22", + "Thu Apr 18 22:50:12 2007 GMT", + "22:50:12 Thu Apr 18 2007 GMT", + "Thu 22:50:12 Apr 18 2007 GMT", + "Thu Apr 22:50:12 18 2007 GMT", + "Thu Apr 18 22:50:12 2007 GMT", + "Thu Apr 18 2007 22:50:12 GMT", + "Thu Apr 18 2007 GMT 22:50:12", + "Sat, 15-Apr-17 21:01:22 GMT", + "15-Sat, Apr-17 21:01:22 GMT", + "15-Sat, Apr 21:01:22 GMT 17", + "15-Sat, Apr 21:01:22 GMT 2017", + "15 Apr 21:01:22 2017", + "15 17 Apr 21:01:22", + "Apr 15 17 21:01:22", + "Apr 15 21:01:22 17", + "2017 April 15 21:01:22", + "15 April 2017 21:01:22", + "98 April 17 21:01:22", + "Thu, 012-Aug-2008 20:49:07 GMT", + "Thu, 12-Aug-31841 20:49:07 GMT", + "Thu, 12-Aug-9999999999 20:49:07 GMT", + "Thu, 999999999999-Aug-2007 20:49:07 GMT", + "Thu, 12-Aug-2007 20:61:99999999999 GMT", + "IAintNoDateFool", NULL }; -- cgit v1.2.1 From 1d92cf1dabd1669832f9dd50c82a9fd2719e19b3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Aug 2009 18:15:38 +0000 Subject: disable the tests that differ between 32 and 64 bit --- tests/libtest/lib517.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 5f8971f8c..d07e74602 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -88,8 +88,13 @@ static const char *dates[]={ "15 April 2017 21:01:22", "98 April 17 21:01:22", "Thu, 012-Aug-2008 20:49:07 GMT", +#if 0 + /* leaving out these strings since they differ between 32 and 64 bit + archs and the test suite has no good way to support two different outputs + like that */ "Thu, 12-Aug-31841 20:49:07 GMT", "Thu, 12-Aug-9999999999 20:49:07 GMT", +#endif "Thu, 999999999999-Aug-2007 20:49:07 GMT", "Thu, 12-Aug-2007 20:61:99999999999 GMT", "IAintNoDateFool", -- cgit v1.2.1 From 640e49976f34d766124cb6988dc4849c4acab6d0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 10 Oct 2009 12:29:32 +0000 Subject: Fix compiler warning: loop without body --- tests/libtest/lib540.c | 6 +++++- tests/libtest/lib560.c | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index cfaa1622d..1ba705a9c 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -44,6 +44,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, struct curl_slist *headers) { CURLMsg *msg; + CURLMcode code; long L; int M, Q, U = -1; fd_set R, W, E; @@ -52,7 +53,10 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, init(cm, url, userpwd, headers); while (U) { - while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U)); + + do { + code = curl_multi_perform(cm, &U); + } while (code == CURLM_CALL_MULTI_PERFORM); if (U) { FD_ZERO(&R); diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index d2de7bfb4..3e34cf788 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -24,6 +24,7 @@ int test(char *URL) { CURL *http_handle; CURLM *multi_handle; + CURLMcode code; int still_running; /* keep number of running handles */ @@ -48,8 +49,9 @@ int test(char *URL) curl_multi_add_handle(multi_handle, http_handle); /* we start some action by calling perform right away */ - while(CURLM_CALL_MULTI_PERFORM == - curl_multi_perform(multi_handle, &still_running)); + do { + code = curl_multi_perform(multi_handle, &still_running); + } while(code == CURLM_CALL_MULTI_PERFORM); while(still_running) { struct timeval timeout; @@ -84,8 +86,9 @@ int test(char *URL) case 0: default: /* timeout or readable/writable sockets */ - while(CURLM_CALL_MULTI_PERFORM == - curl_multi_perform(multi_handle, &still_running)); + do { + code = curl_multi_perform(multi_handle, &still_running); + } while(code == CURLM_CALL_MULTI_PERFORM); break; } } -- cgit v1.2.1 From d68f215f037febf1850ad6a169d4a69bd9d132a1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 30 Oct 2009 22:24:48 +0000 Subject: - "Tom" posted a bug report that mentioned how libcurl did wrong when doing a POST using a read callback, with Digest authentication and "Transfer-Encoding: chunked" enforced. I would then cause the first request to be wrongly sent and then basically hang until the server closed the connection. I fixed the problem and added test case 565 to verify it. --- tests/libtest/Makefile.inc | 5 ++++- tests/libtest/lib510.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 328b5dd16..aa7e9bd01 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -10,7 +10,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 lib562 lib564 + lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -127,3 +127,6 @@ lib560_SOURCES = lib560.c $(SUPPORTFILES) lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) + +lib565_SOURCES = lib510.c $(SUPPORTFILES) +lib565_CFLAGS = -DLIB565 diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index c890f9d45..e13acf4ec 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -49,7 +49,6 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; struct curl_slist *slist = NULL; - struct WriteThis pooh; pooh.counter = 0; @@ -98,6 +97,11 @@ int test(char *URL) /* enforce chunked transfer by setting the header */ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); +#ifdef LIB565 + curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + curl_easy_setopt(curl, CURLOPT_USERPWD, "foo:bar"); +#endif + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); -- cgit v1.2.1 From 2c0b65d37b62e4a089d1816197126f5a3f36a09a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 30 Oct 2009 22:38:21 +0000 Subject: Added test case 566 in an attempt to repeat bug 2884561 (http://curl.haxx.se/bug/view.cgi?id=2884561) but it seems to work for me... --- tests/libtest/Makefile.inc | 5 +++-- tests/libtest/lib566.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/lib566.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index aa7e9bd01..087758d73 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -10,8 +10,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 - + lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -130,3 +129,5 @@ lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) lib565_SOURCES = lib510.c $(SUPPORTFILES) lib565_CFLAGS = -DLIB565 + +lib566_SOURCES = lib566.c $(SUPPORTFILES) diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c new file mode 100644 index 000000000..143a67b71 --- /dev/null +++ b/tests/libtest/lib566.c @@ -0,0 +1,54 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include "memdebug.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + long content_length; + + 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; + } + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + + res = curl_easy_perform(curl); + + if(!res) { + FILE *moo; + res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, + &content_length); + moo = fopen(libtest_arg2, "wb"); + if(moo) { + fprintf(moo, "CL: %ld\n", content_length); + fclose(moo); + } + } + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From 223d84810435d1fa3937e46488f6a4763de06972 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 31 Oct 2009 18:51:50 +0000 Subject: - Gabriel Kuri reported a problem with CURLINFO_CONTENT_LENGTH_DOWNLOAD if the download was 0 bytes, as libcurl would then return the size as unknown (-1) and not 0. I wrote a fix and test case 566 to verify it. --- tests/libtest/lib566.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c index 143a67b71..e2cbe7769 100644 --- a/tests/libtest/lib566.c +++ b/tests/libtest/lib566.c @@ -17,7 +17,7 @@ int test(char *URL) CURLcode res; CURL *curl; - long content_length; + double content_length = 3; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -41,7 +41,7 @@ int test(char *URL) &content_length); moo = fopen(libtest_arg2, "wb"); if(moo) { - fprintf(moo, "CL: %ld\n", content_length); + fprintf(moo, "CL: %.0f\n", content_length); fclose(moo); } } -- cgit v1.2.1 From 55e68ba3338b02d9a52dfe6343054e61a944a895 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 5 Nov 2009 15:04:03 +0000 Subject: I removed leading 'curl' path on the 'curlbuild.h' include statement in curl.h, adjusting auto-makefiles include path, to enhance portability to OS's without an orthogonal directory tree structure such as OS/400. --- tests/libtest/Makefile.am | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 68b446c12..81a0606be 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -27,7 +27,8 @@ AUTOMAKE_OPTIONS = foreign nostdinc # being currently built and tested are searched before the library which # might possibly already be installed in the system. # -# $(top_builddir)/include is for libcurl's generated curl/curlbuild.h file +# $(top_builddir)/include/curl for generated curlbuild.h included from curl.h +# $(top_builddir)/include for generated curlbuild.h included from lib/setup.h # $(top_srcdir)/include is for libcurl's external include files # $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file # $(top_srcdir)/lib is for libcurl's lib/setup.h and other "borrowed" files @@ -35,16 +36,18 @@ AUTOMAKE_OPTIONS = foreign nostdinc # $(top_srcdir)/ares is for in-tree c-ares's external include files if USE_EMBEDDED_ARES -INCLUDES = -I$(top_builddir)/include \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/lib \ - -I$(top_srcdir)/lib \ - -I$(top_builddir)/ares \ +INCLUDES = -I$(top_builddir)/include/curl \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_builddir)/ares \ -I$(top_srcdir)/ares else -INCLUDES = -I$(top_builddir)/include \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/lib \ +INCLUDES = -I$(top_builddir)/include/curl \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ -I$(top_srcdir)/lib endif -- cgit v1.2.1 From 6259bcd51f057a7389bf41a1c653c1e5387c6999 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 28 Jan 2010 04:58:03 +0000 Subject: Chris Conroy provided first RTSP tests --- tests/libtest/Makefile.inc | 14 ++++- tests/libtest/lib567.c | 54 ++++++++++++++++++ tests/libtest/lib568.c | 135 +++++++++++++++++++++++++++++++++++++++++++ tests/libtest/lib569.c | 107 ++++++++++++++++++++++++++++++++++ tests/libtest/lib570.c | 87 ++++++++++++++++++++++++++++ tests/libtest/lib571.c | 139 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 535 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib567.c create mode 100644 tests/libtest/lib568.c create mode 100644 tests/libtest/lib569.c create mode 100644 tests/libtest/lib570.c create mode 100644 tests/libtest/lib571.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 087758d73..5a5a0ea8e 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -10,7 +10,8 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 + lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ + lib568 lib569 lib570 lib571 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -131,3 +132,14 @@ lib565_SOURCES = lib510.c $(SUPPORTFILES) lib565_CFLAGS = -DLIB565 lib566_SOURCES = lib566.c $(SUPPORTFILES) + +lib567_SOURCES = lib567.c $(SUPPORTFILES) + +lib568_SOURCES = lib568.c $(SUPPORTFILES) + +lib569_SOURCES = lib569.c $(SUPPORTFILES) + +lib570_SOURCES = lib570.c $(SUPPORTFILES) + +lib571_SOURCES = lib571.c $(SUPPORTFILES) + diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c new file mode 100644 index 000000000..e04873b11 --- /dev/null +++ b/tests/libtest/lib567.c @@ -0,0 +1,54 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" +#include "memdebug.h" + +/* + * Test a simple OPTIONS request with a custom header + */ +int test(char *URL) +{ + CURLcode res; + CURL *curl; + struct curl_slist *custom_headers=NULL; + + 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; + } + + /* Dump data to stdout for protocol verification */ + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + curl_easy_setopt(curl, CURLOPT_USERAGENT, "test567"); + + custom_headers = curl_slist_append(custom_headers, "Test-Number: 567"); + curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); + + res = curl_easy_perform(curl); + + curl_slist_free_all(custom_headers); + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c new file mode 100644 index 000000000..5e59a9cae --- /dev/null +++ b/tests/libtest/lib568.c @@ -0,0 +1,135 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include +#include +#include +#include + +#include + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +/* + * Test the Client->Server ANNOUNCE functionality (PUT style) + */ +int test(char *URL) +{ + CURLcode res; + CURL *curl; + int sdp; + FILE *sdpf; + struct stat file_info; + char *stream_uri; + int request=1; + struct curl_slist *custom_headers=NULL; + + 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; + } + + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + sdp = open("log/file568.txt", O_RDONLY); + fstat(sdp, &file_info); + sdpf = fdopen(sdp, "rb"); + if(sdpf == NULL) { + close(sdp); + fprintf(stderr, "can't open log/file568.txt\n"); + return TEST_ERR_MAJOR_BAD; + } + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); + + curl_easy_setopt(curl, CURLOPT_READDATA, sdpf); + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + + /* Do the ANNOUNCE */ + res = curl_easy_perform(curl); + if(res) { + fclose(sdpf); + close(sdp); + return res; + } + + curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L); + fclose(sdpf); + close(sdp); + + /* Make sure we can do a normal request now */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + res = curl_easy_perform(curl); + if(res) + return res; + + /* Now do a POST style one */ + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + custom_headers = curl_slist_append(custom_headers, + "Content-Type: posty goodness"); + + curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, + "postyfield=postystuff&project=curl\n"); + + res = curl_easy_perform(curl); + if(res) + return res; + + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); + curl_easy_setopt(curl, CURLOPT_RTSPHEADER, NULL); + curl_slist_free_all(custom_headers); + + /* Make sure we can do a normal request now */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + res = curl_easy_perform(curl); + if(res) + return res; + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} + diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c new file mode 100644 index 000000000..6f276d350 --- /dev/null +++ b/tests/libtest/lib569.c @@ -0,0 +1,107 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +/* + * Test Session ID capture + */ +int test(char *URL) +{ + CURLcode res; + CURL *curl; + char *stream_uri; + char *rtsp_session_id; + int request=1; + int i; + FILE *idfile; + + idfile = fopen(libtest_arg2, "w"); + if(idfile == NULL) { + fprintf(stderr, "couldn't open the Session ID File\n"); + return TEST_ERR_MAJOR_BAD; + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(idfile); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(idfile); + return TEST_ERR_MAJOR_BAD; + } + + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + res = curl_easy_perform(curl); + if(res != CURLE_BAD_FUNCTION_ARGUMENT) { + fprintf(stderr, "This should have failed. " + "Cannot setup without a Transport: header"); + fclose(idfile); + return TEST_ERR_MAJOR_BAD; + } + + /* Go through the various Session IDs */ + for(i = 0; i < 3; i++) { + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "Fake/NotReal/JustATest;foo=baz"); + res = curl_easy_perform(curl); + if(res) { + fclose(idfile); + return res; + } + + curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id); + fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); + rtsp_session_id = NULL; + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); + curl_easy_perform(curl); + + /* Clear for the next go-round */ + curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); + } + + fclose(idfile); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c new file mode 100644 index 000000000..69a0168e0 --- /dev/null +++ b/tests/libtest/lib570.c @@ -0,0 +1,87 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + int request=1; + char *stream_uri; + + 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; + } + + curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + res = curl_easy_perform(curl); + if(res != CURLE_RTSP_CSEQ_ERROR) { + fprintf(stderr, "Failed to detect CSeq mismatch"); + return res; + } + + curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); + curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "RAW/RAW/UDP;unicast;client_port=3056-3057"); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + res = curl_easy_perform(curl); + if(res) + return res; + + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + res = curl_easy_perform(curl); + if(res != CURLE_RTSP_SESSION_ERROR) { + fprintf(stderr, "Failed to detect a Session ID mismatch"); + } + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c new file mode 100644 index 000000000..f530deadc --- /dev/null +++ b/tests/libtest/lib571.c @@ -0,0 +1,139 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#include +#include +#include +#include + +#include + +#include "memdebug.h" + +#define RTP_DATA_SIZE 12 +static const char *RTP_DATA = "$_1234\n\0asdf"; + +static int rtp_packet_count = 0; + +static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { + char *data = (char *)ptr; + int channel = (int)data[0]; + int message_size = (int)(size * nmemb - 3); + int i; + (void)stream; + + printf("RTP: message size %d, channel %d\n", message_size, channel); + + data += 3; + for(i = 0; i < message_size; i+= RTP_DATA_SIZE) { + if(message_size - i > RTP_DATA_SIZE) { + if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) { + printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i); + } + } else { + if (memcmp(RTP_DATA, data + i, message_size - i) != 0) { + printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n", + message_size - i, data + i); + } + } + } + + rtp_packet_count++; + fprintf(stderr, "packet count is %d\n", rtp_packet_count); + + return size * nmemb; +} + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + char *stream_uri; + int request=1; + FILE *protofile; + + protofile = fopen(libtest_arg2, "w"); + if(protofile == NULL) { + fprintf(stderr, "Couldn't open the protocol dump file\n"); + return TEST_ERR_MAJOR_BAD; + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(protofile); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + fclose(protofile); + return TEST_ERR_MAJOR_BAD; + } + curl_easy_setopt(curl, CURLOPT_URL, URL); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + + curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, protofile); + + curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1"); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + res = curl_easy_perform(curl); + + /* This PLAY starts the interleave */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + res = curl_easy_perform(curl); + + /* The DESCRIBE request will try to consume data after the Content */ + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + + res = curl_easy_perform(curl); + + stream_uri = suburl(URL, request++); + curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + free(stream_uri); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + res = curl_easy_perform(curl); + + fprintf(stderr, "PLAY COMPLETE\n"); + + /* Use Receive to get the rest of the data */ + while(!res && rtp_packet_count < 13) { + fprintf(stderr, "LOOPY LOOP!\n"); + curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE); + res = curl_easy_perform(curl); + } + + curl_easy_cleanup(curl); + curl_global_cleanup(); + fclose(protofile); + + return (int)res; +} + -- cgit v1.2.1 From eff18763a1fdc37a45321dfc95f7bbfcec89777f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 28 Jan 2010 10:27:09 +0000 Subject: portability fix --- tests/libtest/lib568.c | 17 +++++++++-------- tests/libtest/lib569.c | 2 +- tests/libtest/lib571.c | 10 ++++++---- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 5e59a9cae..c9406b0ec 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -10,10 +10,12 @@ #include "test.h" -#include -#include -#include +#ifdef HAVE_SYS_STAT_H #include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif #include @@ -34,7 +36,7 @@ int test(char *URL) CURL *curl; int sdp; FILE *sdpf; - struct stat file_info; + struct_stat file_info; char *stream_uri; int request=1; struct curl_slist *custom_headers=NULL; @@ -61,9 +63,10 @@ int test(char *URL) sdp = open("log/file568.txt", O_RDONLY); fstat(sdp, &file_info); - sdpf = fdopen(sdp, "rb"); + close(sdp); + + sdpf = fopen("log/file568.txt", "rb"); if(sdpf == NULL) { - close(sdp); fprintf(stderr, "can't open log/file568.txt\n"); return TEST_ERR_MAJOR_BAD; } @@ -77,13 +80,11 @@ int test(char *URL) res = curl_easy_perform(curl); if(res) { fclose(sdpf); - close(sdp); return res; } curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L); fclose(sdpf); - close(sdp); /* Make sure we can do a normal request now */ stream_uri = suburl(URL, request++); diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 6f276d350..9c5d803b9 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -33,7 +33,7 @@ int test(char *URL) int i; FILE *idfile; - idfile = fopen(libtest_arg2, "w"); + idfile = fopen(libtest_arg2, "wb"); if(idfile == NULL) { fprintf(stderr, "couldn't open the Session ID File\n"); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index f530deadc..4e9f38708 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -10,10 +10,12 @@ #include "test.h" -#include -#include -#include +#ifdef HAVE_SYS_STAT_H #include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif #include @@ -67,7 +69,7 @@ int test(char *URL) int request=1; FILE *protofile; - protofile = fopen(libtest_arg2, "w"); + protofile = fopen(libtest_arg2, "wb"); if(protofile == NULL) { fprintf(stderr, "Couldn't open the protocol dump file\n"); return TEST_ERR_MAJOR_BAD; -- cgit v1.2.1 From ea7219465094d72bb7211a5d71ecd0a201f9ca53 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 1 Feb 2010 22:14:22 +0000 Subject: Conroy added a check to the coded message size since the docs stipulate that each call will contain a full protocol packet. --- tests/libtest/lib571.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 4e9f38708..7fa85b2ab 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -28,14 +28,19 @@ static int rtp_packet_count = 0; static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { char *data = (char *)ptr; - int channel = (int)data[0]; - int message_size = (int)(size * nmemb - 3); + int channel = (int)data[1]; + int message_size = (int)(size * nmemb - 4); + unsigned short coded_size = ntohs(*((unsigned short*)(&data[2]))); int i; (void)stream; printf("RTP: message size %d, channel %d\n", message_size, channel); + if((unsigned short) message_size != coded_size) { + printf("RTP embedded size (%hu) does not match the write size (%d).\n", + coded_size, message_size); + } - data += 3; + data += 4; for(i = 0; i < message_size; i+= RTP_DATA_SIZE) { if(message_size - i > RTP_DATA_SIZE) { if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) { -- cgit v1.2.1 From 9f6c4daa27323603368907d31ed6a4c6e1aa9179 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 2 Feb 2010 07:01:21 +0000 Subject: include headers --- tests/libtest/lib571.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 7fa85b2ab..f69151467 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -10,11 +10,23 @@ #include "test.h" +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif #ifdef HAVE_SYS_STAT_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif #include -- cgit v1.2.1 From bafba6946cae049b066d48b473d8ab8b9bd0cb33 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 2 Feb 2010 12:36:16 +0000 Subject: remove setup.h inclusion which is already done from test.h inclusion --- tests/libtest/lib505.c | 1 - tests/libtest/lib541.c | 1 - tests/libtest/lib542.c | 1 - tests/libtest/lib543.c | 1 - tests/libtest/lib562.c | 1 - 5 files changed, 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index ceccd6b28..2d2858af1 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -8,7 +8,6 @@ * $Id$ */ -#include "setup.h" /* struct_stat etc. */ #include "test.h" #ifdef HAVE_SYS_SOCKET_H diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index ada389cf1..b895a25a9 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -8,7 +8,6 @@ * $Id$ */ -#include "setup.h" /* struct_stat etc. */ #include "test.h" #ifdef HAVE_SYS_SOCKET_H diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index 1d45405bb..9f755c9af 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -8,7 +8,6 @@ * $Id$ */ -#include "setup.h" /* struct_stat etc. */ #include "test.h" #ifdef HAVE_SYS_SOCKET_H diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 852645695..0f97bab8d 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -10,7 +10,6 @@ * Based on Alex Fishman's bug report on September 30, 2007 */ -#include "setup.h" #include "test.h" #include "memdebug.h" diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index b11ff1646..ffb0ce5f2 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -8,7 +8,6 @@ * $Id$ */ -#include "setup.h" /* struct_stat etc. */ #include "test.h" #ifdef HAVE_SYS_SOCKET_H -- cgit v1.2.1 From 232d17ec6486c79c2daa6a8f613d2e3fd94ae2fc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 2 Feb 2010 12:39:10 +0000 Subject: avoid possibility of using obsoleted stuff --- tests/libtest/test.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 66416b42a..202ca7ba4 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -13,6 +13,8 @@ need both of them in the include path), so that we get good in-depth knowledge about the system we're building this on */ +#define CURL_NO_OLDIES + #include "setup.h" #include -- cgit v1.2.1 From 381a4d6efec42db823cbd5946514c275bca7d2d1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 3 Feb 2010 06:49:27 +0000 Subject: Fix portability issue related with unaligned memory access --- tests/libtest/lib571.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index f69151467..a1cd032ab 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -33,6 +33,11 @@ #include "memdebug.h" +#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1]))) + +#define RTP_PKT_LENGTH(p) ((((int)((unsigned char)((p)[2]))) << 8) | \ + ((int)((unsigned char)((p)[3])))) + #define RTP_DATA_SIZE 12 static const char *RTP_DATA = "$_1234\n\0asdf"; @@ -40,16 +45,18 @@ static int rtp_packet_count = 0; static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { char *data = (char *)ptr; - int channel = (int)data[1]; - int message_size = (int)(size * nmemb - 4); - unsigned short coded_size = ntohs(*((unsigned short*)(&data[2]))); + int channel = RTP_PKT_CHANNEL(data); + int message_size = (int)(size * nmemb) - 4; + int coded_size = RTP_PKT_LENGTH(data); + size_t failure = (size * nmemb) ? 0 : 1; int i; (void)stream; printf("RTP: message size %d, channel %d\n", message_size, channel); - if((unsigned short) message_size != coded_size) { - printf("RTP embedded size (%hu) does not match the write size (%d).\n", - coded_size, message_size); + if(message_size != coded_size) { + printf("RTP embedded size (%d) does not match the write size (%d).\n", + coded_size, message_size); + return failure; } data += 4; @@ -57,11 +64,13 @@ static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { if(message_size - i > RTP_DATA_SIZE) { if(memcmp(RTP_DATA, data + i, RTP_DATA_SIZE) != 0) { printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i); + return failure; } } else { if (memcmp(RTP_DATA, data + i, message_size - i) != 0) { printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n", message_size - i, data + i); + return failure; } } } -- cgit v1.2.1 From a9a5a8e45cf81bc3d0585ad6dd7144a4bd3a68d9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 4 Feb 2010 14:41:01 +0000 Subject: Modified test case 557 to additionally verify libcurl's internal curl_m*printf() functions formatting functionality when handling signed and unsigned shorts. --- tests/libtest/lib557.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 304 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 124cd7c2b..c9400a60c 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -37,6 +37,8 @@ #define BUFSZ 256 +#define USHORT_TESTS_ARRSZ 1 + 100 +#define SSHORT_TESTS_ARRSZ 1 + 100 #define UINT_TESTS_ARRSZ 1 + 100 #define SINT_TESTS_ARRSZ 1 + 100 #define ULONG_TESTS_ARRSZ 1 + 100 @@ -44,6 +46,20 @@ #define COFFT_TESTS_ARRSZ 1 + 100 +struct unsshort_st { + unsigned short num; /* unsigned short */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + +struct sigshort_st { + short num; /* signed short */ + const char *expected; /* expected string */ + char result[BUFSZ]; /* result string */ +}; + + struct unsint_st { unsigned int num; /* unsigned int */ const char *expected; /* expected string */ @@ -79,11 +95,290 @@ struct curloff_st { }; -static struct unsint_st ui_test[UINT_TESTS_ARRSZ]; -static struct sigint_st si_test[SINT_TESTS_ARRSZ]; -static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; -static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; -static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; +static struct unsshort_st us_test[USHORT_TESTS_ARRSZ]; +static struct sigshort_st ss_test[SSHORT_TESTS_ARRSZ]; +static struct unsint_st ui_test[UINT_TESTS_ARRSZ]; +static struct sigint_st si_test[SINT_TESTS_ARRSZ]; +static struct unslong_st ul_test[ULONG_TESTS_ARRSZ]; +static struct siglong_st sl_test[SLONG_TESTS_ARRSZ]; +static struct curloff_st co_test[COFFT_TESTS_ARRSZ]; + + +static int test_unsigned_short_formatting(void) +{ + int i, j; + int num_ushort_tests; + int failed = 0; + +#if (SIZEOF_SHORT == 1) + + i=1; us_test[i].num = 0xFFU; us_test[i].expected = "256"; + i++; us_test[i].num = 0xF0U; us_test[i].expected = "240"; + i++; us_test[i].num = 0x0FU; us_test[i].expected = "15"; + + i++; us_test[i].num = 0xE0U; us_test[i].expected = "224"; + i++; us_test[i].num = 0x0EU; us_test[i].expected = "14"; + + i++; us_test[i].num = 0xC0U; us_test[i].expected = "192"; + i++; us_test[i].num = 0x0CU; us_test[i].expected = "12"; + + i++; us_test[i].num = 0x01U; us_test[i].expected = "1"; + i++; us_test[i].num = 0x00U; us_test[i].expected = "0"; + + num_ushort_tests = i; + +#elif (SIZEOF_SHORT == 2) + + i=1; us_test[i].num = 0xFFFFU; us_test[i].expected = "65535"; + i++; us_test[i].num = 0xFF00U; us_test[i].expected = "65280"; + i++; us_test[i].num = 0x00FFU; us_test[i].expected = "255"; + + i++; us_test[i].num = 0xF000U; us_test[i].expected = "61440"; + i++; us_test[i].num = 0x0F00U; us_test[i].expected = "3840"; + i++; us_test[i].num = 0x00F0U; us_test[i].expected = "240"; + i++; us_test[i].num = 0x000FU; us_test[i].expected = "15"; + + i++; us_test[i].num = 0xC000U; us_test[i].expected = "49152"; + i++; us_test[i].num = 0x0C00U; us_test[i].expected = "3072"; + i++; us_test[i].num = 0x00C0U; us_test[i].expected = "192"; + i++; us_test[i].num = 0x000CU; us_test[i].expected = "12"; + + i++; us_test[i].num = 0x0001U; us_test[i].expected = "1"; + i++; us_test[i].num = 0x0000U; us_test[i].expected = "0"; + + num_ushort_tests = i; + +#elif (SIZEOF_SHORT == 4) + + i=1; us_test[i].num = 0xFFFFFFFFU; us_test[i].expected = "4294967295"; + i++; us_test[i].num = 0xFFFF0000U; us_test[i].expected = "4294901760"; + i++; us_test[i].num = 0x0000FFFFU; us_test[i].expected = "65535"; + + i++; us_test[i].num = 0xFF000000U; us_test[i].expected = "4278190080"; + i++; us_test[i].num = 0x00FF0000U; us_test[i].expected = "16711680"; + i++; us_test[i].num = 0x0000FF00U; us_test[i].expected = "65280"; + i++; us_test[i].num = 0x000000FFU; us_test[i].expected = "255"; + + i++; us_test[i].num = 0xF0000000U; us_test[i].expected = "4026531840"; + i++; us_test[i].num = 0x0F000000U; us_test[i].expected = "251658240"; + i++; us_test[i].num = 0x00F00000U; us_test[i].expected = "15728640"; + i++; us_test[i].num = 0x000F0000U; us_test[i].expected = "983040"; + i++; us_test[i].num = 0x0000F000U; us_test[i].expected = "61440"; + i++; us_test[i].num = 0x00000F00U; us_test[i].expected = "3840"; + i++; us_test[i].num = 0x000000F0U; us_test[i].expected = "240"; + i++; us_test[i].num = 0x0000000FU; us_test[i].expected = "15"; + + i++; us_test[i].num = 0xC0000000U; us_test[i].expected = "3221225472"; + i++; us_test[i].num = 0x0C000000U; us_test[i].expected = "201326592"; + i++; us_test[i].num = 0x00C00000U; us_test[i].expected = "12582912"; + i++; us_test[i].num = 0x000C0000U; us_test[i].expected = "786432"; + i++; us_test[i].num = 0x0000C000U; us_test[i].expected = "49152"; + i++; us_test[i].num = 0x00000C00U; us_test[i].expected = "3072"; + i++; us_test[i].num = 0x000000C0U; us_test[i].expected = "192"; + i++; us_test[i].num = 0x0000000CU; us_test[i].expected = "12"; + + i++; us_test[i].num = 0x00000001U; us_test[i].expected = "1"; + i++; us_test[i].num = 0x00000000U; us_test[i].expected = "0"; + + num_ushort_tests = i; + +#endif + + for(i=1; i<=num_ushort_tests; i++) { + + for(j=0; j Date: Thu, 4 Feb 2010 14:50:58 +0000 Subject: Fix variable initialization --- tests/libtest/lib557.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index c9400a60c..d09b567f2 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -219,7 +219,7 @@ static int test_signed_short_formatting(void) #if (SIZEOF_SHORT == 1) - i++; ss_test[i].num = 0x7F; ss_test[i].expected = "127"; + i=1; ss_test[i].num = 0x7F; ss_test[i].expected = "127"; i++; ss_test[i].num = 0x70; ss_test[i].expected = "112"; i++; ss_test[i].num = 0x07; ss_test[i].expected = "7"; -- cgit v1.2.1 From cad9c3f55fad5da988144dc83ad76a8544a071a2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 5 Feb 2010 18:07:19 +0000 Subject: Addes OOM handling for curl_easy_setopt() calls in test --- tests/libtest/lib500.c | 6 ++- tests/libtest/lib501.c | 4 +- tests/libtest/lib502.c | 12 ++++-- tests/libtest/lib503.c | 22 ++++++----- tests/libtest/lib504.c | 46 ++++++++++++----------- tests/libtest/lib505.c | 14 ++++--- tests/libtest/lib506.c | 10 +++-- tests/libtest/lib507.c | 22 +++++++---- tests/libtest/lib508.c | 18 +++++---- tests/libtest/lib510.c | 22 ++++++----- tests/libtest/lib511.c | 10 +++-- tests/libtest/lib513.c | 16 ++++---- tests/libtest/lib514.c | 16 ++++---- tests/libtest/lib515.c | 12 +++--- tests/libtest/lib516.c | 10 +++-- tests/libtest/lib518.c | 6 ++- tests/libtest/lib519.c | 12 +++--- tests/libtest/lib520.c | 8 ++-- tests/libtest/lib521.c | 10 +++-- tests/libtest/lib523.c | 12 +++--- tests/libtest/lib524.c | 8 ++-- tests/libtest/lib525.c | 28 ++++++++------ tests/libtest/lib526.c | 36 ++++++++++++++---- tests/libtest/lib530.c | 42 +++++++++++++++++++-- tests/libtest/lib533.c | 19 ++++++---- tests/libtest/lib536.c | 13 ++++--- tests/libtest/lib537.c | 6 ++- tests/libtest/lib539.c | 21 ++++++----- tests/libtest/lib540.c | 81 ++++++++++++++++++++++++++++----------- tests/libtest/lib541.c | 10 +++-- tests/libtest/lib542.c | 10 +++-- tests/libtest/lib543.c | 15 ++++++-- tests/libtest/lib544.c | 12 +++--- tests/libtest/lib547.c | 28 +++++++------- tests/libtest/lib549.c | 15 +++++--- tests/libtest/lib552.c | 62 ++++++++++++++++-------------- tests/libtest/lib553.c | 68 +++++++++++++++++++-------------- tests/libtest/lib554.c | 16 ++++---- tests/libtest/lib555.c | 37 +++++++++--------- tests/libtest/lib556.c | 5 ++- tests/libtest/lib560.c | 18 +++++---- tests/libtest/lib562.c | 8 ++-- tests/libtest/lib564.c | 15 +++++--- tests/libtest/lib566.c | 6 ++- tests/libtest/lib567.c | 19 ++++++---- tests/libtest/lib568.c | 100 +++++++++++++++++++++++++++++++------------------ tests/libtest/lib569.c | 57 ++++++++++++++++------------ tests/libtest/lib570.c | 54 ++++++++++++++++---------- tests/libtest/lib571.c | 67 +++++++++++++++++++++++---------- tests/libtest/test.h | 3 ++ 50 files changed, 736 insertions(+), 431 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 14a8e7aeb..c0cc9dee5 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -29,8 +29,8 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); @@ -44,6 +44,8 @@ int test(char *URL) } } +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index ff2bbb5b9..8963fbb39 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -30,10 +30,12 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 85c300fbe..0a0a819b0 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -23,7 +23,7 @@ int test(char *URL) { CURL *c; - CURLM *m; + CURLM *m = NULL; int res = 0; int running=1; struct timeval mp_start; @@ -40,7 +40,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(c, CURLOPT_URL, URL); + test_setopt(c, CURLOPT_URL, URL); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); @@ -81,9 +81,13 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } - curl_multi_remove_handle(m, c); +test_cleanup: + + if(m) { + curl_multi_remove_handle(m, c); + curl_multi_cleanup(m); + } curl_easy_cleanup(c); - curl_multi_cleanup(m); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 11f1150c0..3e8f3dc55 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -29,7 +29,7 @@ int test(char *URL) { CURL *c; - CURLM *m; + CURLM *m = NULL; int res = 0; int running; char done = FALSE; @@ -49,12 +49,12 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ - curl_easy_setopt(c, CURLOPT_URL, URL); - curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); - curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); - curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); - curl_easy_setopt(c, CURLOPT_HEADER, 1L); + 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"); @@ -139,9 +139,13 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } - curl_multi_remove_handle(m, c); +test_cleanup: + + if(m) { + curl_multi_remove_handle(m, c); + curl_multi_cleanup(m); + } curl_easy_cleanup(c); - curl_multi_cleanup(m); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index fece016b8..5eedb9ecc 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -28,10 +28,10 @@ int test(char *URL) { CURL *c; - int ret=0; - CURLM *m; + int res = 0; + CURLM *m = NULL; fd_set rd, wr, exc; - CURLMcode res; + CURLMcode ret; char done = FALSE; int running; int max_fd; @@ -54,9 +54,9 @@ int test(char *URL) /* the point here being that there must not run anything on the given proxy port */ - curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(c, CURLOPT_URL, URL); - curl_easy_setopt(c, CURLOPT_VERBOSE, 1L); + 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"); @@ -65,9 +65,9 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - if ((res = curl_multi_add_handle(m, c)) != CURLM_OK) { + if ((ret = curl_multi_add_handle(m, c)) != CURLM_OK) { fprintf(stderr, "curl_multi_add_handle() failed, " - "with code %d\n", res); + "with code %d\n", ret); curl_multi_cleanup(m); curl_easy_cleanup(c); curl_global_cleanup(); @@ -93,10 +93,10 @@ int test(char *URL) fprintf(stderr, "curl_multi_perform()\n"); - res = CURLM_CALL_MULTI_PERFORM; + ret = CURLM_CALL_MULTI_PERFORM; - while (res == CURLM_CALL_MULTI_PERFORM) { - res = curl_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; @@ -112,15 +112,15 @@ int test(char *URL) CURLMsg *msg = curl_multi_info_read(m, &numleft); fprintf(stderr, "Expected: not running\n"); if(msg && !numleft) - ret = 100; /* this is where we should be */ + res = 100; /* this is where we should be */ else - ret = 99; /* not correct */ + res = 99; /* not correct */ break; } - fprintf(stderr, "running == %d, res == %d\n", running, res); + fprintf(stderr, "running == %d, ret == %d\n", running, ret); - if (res != CURLM_OK) { - ret = 2; + if (ret != CURLM_OK) { + res = 2; break; } @@ -132,7 +132,7 @@ int test(char *URL) 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"); - ret = 3; + res = 3; break; } rc = select_test(max_fd+1, &rd, &wr, &exc, &interval); @@ -144,14 +144,18 @@ int test(char *URL) if (mp_timedout) fprintf(stderr, "mp_timedout\n"); fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); - ret = TEST_ERR_RUNS_FOREVER; + res = TEST_ERR_RUNS_FOREVER; } - curl_multi_remove_handle(m, c); +test_cleanup: + + if(m) { + curl_multi_remove_handle(m, c); + curl_multi_cleanup(m); + } curl_easy_cleanup(c); - curl_multi_cleanup(m); curl_global_cleanup(); - return ret; + return res; } diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 2d2858af1..b1c679990 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -117,27 +117,29 @@ int test(char *URL) headerlist = hl; /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + test_setopt(curl, CURLOPT_UPLOAD, 1L); /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* specify target */ - curl_easy_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl,CURLOPT_URL, URL); /* pass in that last of FTP commands to run after the transfer */ - curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist); + test_setopt(curl, CURLOPT_POSTQUOTE, headerlist); /* now specify which file to upload */ - curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + test_setopt(curl, CURLOPT_INFILE, hd_src); /* and give the size of the upload (optional) */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); +test_cleanup: + /* clean up the FTP commands list */ curl_slist_free_all(headerlist); diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 823e05d3e..99cf915d3 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -224,12 +224,12 @@ int test(char *URL) url = suburl( URL, i ); headers = sethost( NULL ); - curl_easy_setopt( curl, CURLOPT_HTTPHEADER, headers ); - curl_easy_setopt( curl, CURLOPT_URL, url ); + test_setopt( curl, CURLOPT_HTTPHEADER, headers ); + test_setopt( curl, CURLOPT_URL, url ); printf( "CURLOPT_SHARE\n" ); - curl_easy_setopt( curl, CURLOPT_SHARE, share ); + test_setopt( curl, CURLOPT_SHARE, share ); printf( "CURLOPT_COOKIEJAR\n" ); - curl_easy_setopt( curl, CURLOPT_COOKIEJAR, JAR ); + test_setopt( curl, CURLOPT_COOKIEJAR, JAR ); printf( "PERFORM\n" ); curl_easy_perform( curl ); @@ -245,6 +245,8 @@ int test(char *URL) printf( "SHARE_CLEANUP failed, correct\n" ); } +test_cleanup: + /* clean up last handle */ printf( "CLEANUP\n" ); curl_easy_cleanup( curl ); diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index b2fd09888..252775840 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -22,8 +22,9 @@ int test(char *URL) CURLM* multi; int still_running; int i = -1; + int res = 0; CURLMsg *msg; - CURLMcode res; + CURLMcode ret; struct timeval ml_start; struct timeval mp_start; char ml_timedout = FALSE; @@ -47,11 +48,11 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curls, CURLOPT_URL, URL); + test_setopt(curls, CURLOPT_URL, URL); - if ((res = curl_multi_add_handle(multi, curls)) != CURLM_OK) { + if ((ret = curl_multi_add_handle(multi, curls)) != CURLM_OK) { fprintf(stderr, "curl_multi_add_handle() failed, " - "with code %d\n", res); + "with code %d\n", ret); curl_easy_cleanup(curls); curl_multi_cleanup(multi); curl_global_cleanup(); @@ -62,13 +63,13 @@ int test(char *URL) mp_start = tutil_tvnow(); do { - res = curl_multi_perform(multi, &still_running); + ret = curl_multi_perform(multi, &still_running); if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; } - } while (res == CURLM_CALL_MULTI_PERFORM); + } while (ret == CURLM_CALL_MULTI_PERFORM); ml_timedout = FALSE; ml_start = tutil_tvnow(); @@ -103,13 +104,13 @@ int test(char *URL) mp_timedout = FALSE; mp_start = tutil_tvnow(); do { - res = curl_multi_perform(multi, &still_running); + ret = curl_multi_perform(multi, &still_running); if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; } - } while (res == CURLM_CALL_MULTI_PERFORM); + } while (ret == CURLM_CALL_MULTI_PERFORM); break; } } @@ -128,9 +129,14 @@ int test(char *URL) i = msg->data.result; } +test_cleanup: + curl_multi_cleanup(multi); curl_easy_cleanup(curls); curl_global_cleanup(); + if(res) + i = res; + return i; /* return the final return code */ } diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 6de7e7bcd..f392e414d 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -58,34 +58,36 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POST, 1L); #ifdef CURL_DOES_CONVERSIONS /* Convert the POST data to ASCII */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); #endif /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + test_setopt(curl, CURLOPT_INFILE, &pooh); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index e13acf4ec..bb0a11f25 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -72,39 +72,41 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POST, 1L); #ifdef CURL_DOES_CONVERSIONS /* Convert the POST data to ASCII */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); #endif /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + test_setopt(curl, CURLOPT_INFILE, &pooh); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); /* enforce chunked transfer by setting the header */ - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); + test_setopt(curl, CURLOPT_HTTPHEADER, slist); #ifdef LIB565 - curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - curl_easy_setopt(curl, CURLOPT_USERPWD, "foo:bar"); + test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + test_setopt(curl, CURLOPT_USERPWD, "foo:bar"); #endif /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); +test_cleanup: + /* clean up the headers list */ if(slist) curl_slist_free_all(slist); diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 0f9993db1..0e2f3df10 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -28,13 +28,15 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); - curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_FILETIME, 1L); + test_setopt(curl, CURLOPT_NOBODY, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index e49724ca6..602456310 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -38,29 +38,31 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POST, 1L); /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L); /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, NULL); + test_setopt(curl, CURLOPT_INFILE, NULL); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 06f975f34..6a5733e99 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -29,7 +29,7 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Based on a bug report by Niels van Tongeren on June 29, 2004: @@ -40,23 +40,25 @@ int test(char *URL) */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "moo"); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L); - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POSTFIELDS, "moo"); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L); + test_setopt(curl, CURLOPT_POST, 1L); /* this is where transfer 1 would take place, but skip that and change options right away instead */ - curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); + test_setopt(curl, CURLOPT_NOBODY, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Now, we should be making a fine HEAD request */ /* Perform the request 2, res will get the return code */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index c85f2bed1..56ee68ead 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -29,15 +29,17 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_POSTFIELDS, NULL); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Now, we should be making a zero byte POST request */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index b3c63f4b5..8721583cf 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -29,14 +29,16 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HTTPPOST, NULL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HTTPPOST, NULL); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Now, we should be making a zero byte POST request */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index a1b914916..d8310d92d 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -484,11 +484,13 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); +test_cleanup: + close_file_descriptors(); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index 70ada8a15..66013498b 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -28,19 +28,21 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_USERPWD, "monster:underbed"); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_USERPWD, "monster:underbed"); + test_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* get first page */ res = curl_easy_perform(curl); - curl_easy_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe"); + test_setopt(curl, CURLOPT_USERPWD, "anothermonster:inwardrobe"); /* get second page */ res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index 1d63881c3..57355a58f 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -28,12 +28,14 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_FILETIME, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 60fe4d95d..a51b4e83c 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -28,13 +28,15 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); - curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); + test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); + test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index c6011fc57..1dcfcd9c1 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -28,14 +28,16 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_PORT, 19999L); - curl_easy_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_PORT, 19999L); + test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); + test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index c8b07834a..0b3ec5845 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -28,12 +28,14 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_UPLOAD, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index c503d1618..41a519e7e 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -30,7 +30,7 @@ int test(char *URL) struct_stat file_info; int running; char done=FALSE; - CURLM *m; + CURLM *m = NULL; struct timeval ml_start; struct timeval mp_start; char ml_timedout = FALSE; @@ -72,19 +72,19 @@ int test(char *URL) } /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + test_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ - curl_easy_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl,CURLOPT_URL, URL); /* go verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* use active FTP */ - curl_easy_setopt(curl, CURLOPT_FTPPORT, "-"); + test_setopt(curl, CURLOPT_FTPPORT, "-"); /* now specify which file to upload */ - curl_easy_setopt(curl, CURLOPT_READDATA, hd_src); + test_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 @@ -95,7 +95,7 @@ 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. */ - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); if ((m = curl_multi_init()) == NULL) { @@ -183,16 +183,22 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } +test_cleanup: + #ifdef LIB529 /* test 529 */ - curl_multi_remove_handle(m, curl); - curl_multi_cleanup(m); + if(m) { + curl_multi_remove_handle(m, curl); + curl_multi_cleanup(m); + } curl_easy_cleanup(curl); #else /* test 525 */ - curl_multi_remove_handle(m, curl); + if(m) + curl_multi_remove_handle(m, curl); curl_easy_cleanup(curl); - curl_multi_cleanup(m); + if(m) + curl_multi_cleanup(m); #endif fclose(hd_src); /* close the local file */ diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index b4d891337..600ed65e5 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -47,7 +47,7 @@ int test(char *URL) CURL *curl[NUM_HANDLES]; int running; char done=FALSE; - CURLM *m; + CURLM *m = NULL; int current=0; int i, j; struct timeval ml_start; @@ -72,10 +72,28 @@ int test(char *URL) curl_global_cleanup(); return TEST_ERR_MAJOR_BAD + i; } - curl_easy_setopt(curl[i], CURLOPT_URL, URL); + 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; + } /* go verbose */ - curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); + 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; + } } if ((m = curl_multi_init()) == NULL) { @@ -142,8 +160,8 @@ int test(char *URL) /* make us re-use the same handle all the time, and try resetting the handle first too */ curl_easy_reset(curl[0]); - curl_easy_setopt(curl[0], CURLOPT_URL, URL); - curl_easy_setopt(curl[0], CURLOPT_VERBOSE, 1L); + 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]); @@ -197,16 +215,20 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } +test_cleanup: + #ifndef LIB527 /* get NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { #ifdef LIB526 - curl_multi_remove_handle(m, curl[i]); + if(m) + curl_multi_remove_handle(m, curl[i]); #endif curl_easy_cleanup(curl[i]); } #endif - curl_multi_cleanup(m); + if(m) + curl_multi_cleanup(m); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index d738277f2..ef2218834 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -69,13 +69,47 @@ int test(char *URL) } sprintf(target_url, "%s%04i", URL, i + 1); target_url[sizeof(target_url) - 1] = '\0'; - curl_easy_setopt(curl[i], CURLOPT_URL, target_url); + + 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; + } /* go verbose */ - curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); + 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; + } /* include headers */ - curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L); + 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; + } /* add handle to multi */ if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) { @@ -163,6 +197,8 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } +test_cleanup: + /* cleanup NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { curl_multi_remove_handle(m, curl[i]); diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 92b371a81..810b075e5 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -28,7 +28,7 @@ int test(char *URL) CURL *curl; int running; char done=FALSE; - CURLM *m; + CURLM *m = NULL; int current=0; struct timeval ml_start; struct timeval mp_start; @@ -46,9 +46,9 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_VERBOSE, 1); + test_setopt(curl, CURLOPT_FAILONERROR, 1); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); @@ -103,9 +103,9 @@ int test(char *URL) /* make us re-use the same handle all the time, and try resetting the handle first too */ curl_easy_reset(curl); - curl_easy_setopt(curl, CURLOPT_URL, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + 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); @@ -156,8 +156,11 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } +test_cleanup: + curl_easy_cleanup(curl); - curl_multi_cleanup(m); + if(m) + curl_multi_cleanup(m); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 016b7e922..06d863ca9 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -93,9 +93,9 @@ int test(char *URL) curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1L); - curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); - curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L); - curl_easy_setopt(easy, CURLOPT_URL, URL); + test_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite); + test_setopt(easy, CURLOPT_FAILONERROR, 1L); + test_setopt(easy, CURLOPT_URL, URL); if (curl_multi_add_handle(multi, easy) != CURLM_OK) { printf("curl_multi_add_handle() failed\n"); @@ -108,8 +108,8 @@ int test(char *URL) } curl_easy_reset(easy); - curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1L); - curl_easy_setopt(easy, CURLOPT_URL, libtest_arg2); + test_setopt(easy, CURLOPT_FAILONERROR, 1L); + test_setopt(easy, CURLOPT_URL, libtest_arg2); if (curl_multi_add_handle(multi, easy) != CURLM_OK) { printf("curl_multi_add_handle() 2 failed\n"); @@ -120,6 +120,9 @@ int test(char *URL) curl_multi_remove_handle(multi, easy); } + +test_cleanup: + curl_easy_cleanup(easy); curl_multi_cleanup(multi); curl_global_cleanup(); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 7bb8c1436..791448a86 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -487,11 +487,13 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); +test_cleanup: + close_file_descriptors(); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index eda78fcf4..f7df40854 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -16,8 +16,8 @@ int test(char *URL) { CURLcode res; CURL *curl; - char *newURL; - struct curl_slist *slist; + char *newURL = NULL; + struct curl_slist *slist = NULL; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -33,9 +33,9 @@ int test(char *URL) /* * Begin with cURL set to use a single CWD to the URL's directory. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); @@ -63,14 +63,17 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, newURL); - curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); - curl_easy_setopt(curl, CURLOPT_QUOTE, slist); + test_setopt(curl, CURLOPT_URL, newURL); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); + test_setopt(curl, CURLOPT_QUOTE, slist); res = curl_easy_perform(curl); +test_cleanup: + curl_slist_free_all(slist); - free(newURL); + if(newURL) + free(newURL); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 1ba705a9c..5fcf7bc9d 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -24,20 +24,39 @@ #define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] -static void init(CURLM *cm, const char* url, const char* userpwd, +static int init(CURLM *cm, const char* url, const char* userpwd, struct curl_slist *headers) { - CURL *eh = curl_easy_init(); + CURL *eh; + int res; - curl_easy_setopt(eh, CURLOPT_URL, url); - curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); - curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); - curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); - curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(eh, CURLOPT_HEADER, 1L); - curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ + if ((eh = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + return 1; /* failure */ + } + + 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 */ + } - curl_multi_add_handle(cm, eh); + return 0; /* success */ } static int loop(CURLM *cm, const char* url, const char* userpwd, @@ -50,7 +69,8 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, fd_set R, W, E; struct timeval T; - init(cm, url, userpwd, headers); + if(init(cm, url, userpwd, headers)) + return 1; /* failure */ while (U) { @@ -65,7 +85,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, if (curl_multi_fdset(cm, &R, &W, &E, &M)) { fprintf(stderr, "E: curl_multi_fdset\n"); - return EXIT_FAILURE; + return 1; /* failure */ } /* In a real-world program you OF COURSE check the return that maxfd is @@ -73,7 +93,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, if (curl_multi_timeout(cm, &L)) { fprintf(stderr, "E: curl_multi_timeout\n"); - return EXIT_FAILURE; + return 1; /* failure */ } if(L != -1) { @@ -87,7 +107,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, if (0 > select(M+1, &R, &W, &E, &T)) { fprintf(stderr, "E: select\n"); - return EXIT_FAILURE; + return 1; /* failure */ } } @@ -105,14 +125,15 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, } } - return 1; + return 0; /* success */ } int test(char *URL) { - CURLM *cm; + CURLM *cm = NULL; struct curl_slist *headers = NULL; char buffer[246]; /* naively fixed-size */ + int res; if(test_argc < 4) return 99; @@ -121,14 +142,32 @@ int test(char *URL) /* now add a custom Host: header */ headers = curl_slist_append(headers, buffer); + if(!headers) { + fprintf(stderr, "curl_slist_append() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - curl_global_init(CURL_GLOBAL_ALL); + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + curl_slist_free_all(headers); + return TEST_ERR_MAJOR_BAD; + } + + if ((cm = curl_multi_init()) == NULL) { + fprintf(stderr, "curl_multi_init() failed\n"); + curl_slist_free_all(headers); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - cm = curl_multi_init(); - loop(cm, URL, PROXYUSERPWD, headers); + res = loop(cm, URL, PROXYUSERPWD, headers); + if(res) + goto test_cleanup; fprintf(stderr, "lib540: now we do the request again\n"); - loop(cm, URL, PROXYUSERPWD, headers); + res = loop(cm, URL, PROXYUSERPWD, headers); + +test_cleanup: curl_multi_cleanup(cm); @@ -136,5 +175,5 @@ int test(char *URL) curl_slist_free_all(headers); - return EXIT_SUCCESS; + return res; } diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index b895a25a9..9305a936c 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -90,16 +90,16 @@ int test(char *URL) } /* enable uploading */ - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); + test_setopt(curl, CURLOPT_UPLOAD, 1L); /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* specify target */ - curl_easy_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl,CURLOPT_URL, URL); /* now specify which file to upload */ - curl_easy_setopt(curl, CURLOPT_INFILE, hd_src); + test_setopt(curl, CURLOPT_INFILE, hd_src); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); @@ -108,6 +108,8 @@ int test(char *URL) is at end of file */ res = curl_easy_perform(curl); +test_cleanup: + /* close the local file */ fclose(hd_src); diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index 9f755c9af..585c18b3c 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -51,20 +51,22 @@ int test(char *URL) } /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* enable NOBODY */ - curl_easy_setopt(curl, CURLOPT_NOBODY, 1L); + test_setopt(curl, CURLOPT_NOBODY, 1L); /* disable HEADER */ - curl_easy_setopt(curl, CURLOPT_HEADER, 0L); + test_setopt(curl, CURLOPT_HEADER, 0L); /* specify target */ - curl_easy_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl,CURLOPT_URL, URL); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 0f97bab8d..88387a198 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -20,11 +20,20 @@ int test(char *URL) 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa, 0x1d, 0x57, 0xe1}; - CURL* easy = curl_easy_init(); - int asize = (int)sizeof(a); - char* s = curl_easy_escape(easy, (char*)a, asize); + CURL *easy; + int asize; + char *s; (void)URL; + if ((easy = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + asize = (int)sizeof(a); + + s = curl_easy_escape(easy, (char*)a, asize); + printf("%s\n", s); curl_free(s); diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index b17e64af2..3229fdad3 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -40,16 +40,16 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); #ifdef LIB545 - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1); #endif - curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring); + test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */ + test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */ /* Update the original data to detect non-copy. */ strcpy(teststring, "FAIL"); @@ -57,6 +57,8 @@ int test(char *URL) /* Now, this is a POST request with binary 0 embedded in POST data. */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index a8f73eb5f..ba81b49c4 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -84,29 +84,31 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); #ifdef LIB548 /* set the data to POST with a mere pointer to a zero-terminated string */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); + test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS); #else /* 547 style, which means reading the POST data from a callback */ - curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); - curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); - curl_easy_setopt(curl, CURLOPT_READDATA, &counter); + test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + test_setopt(curl, CURLOPT_IOCTLDATA, &counter); + test_setopt(curl, CURLOPT_READFUNCTION, readcallback); + test_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); #endif - curl_easy_setopt(curl, CURLOPT_POST, 1L); - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); - curl_easy_setopt(curl, CURLOPT_PROXYAUTH, + test_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); + test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); + test_setopt(curl, CURLOPT_PROXYAUTH, (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index e196aba56..4a3ee7bec 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -32,16 +32,19 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - if(libtest_arg3) + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_PROXY_TRANSFER_MODE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + if(libtest_arg3) { /* enable ascii/text mode */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + } res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index ce7ca1676..530c5df06 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -155,48 +155,52 @@ int test(char *URL) config.trace_ascii = 1; /* enable ascii tracing */ - curl = curl_easy_init(); - if(curl) { - curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); - curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); - /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + if((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + test_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + test_setopt(curl, CURLOPT_DEBUGDATA, &config); + /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); - /* setup repeated data string */ - for (i=0; i < sizeof(databuf); ++i) - databuf[i] = fill[i % sizeof fill]; + /* setup repeated data string */ + for (i=0; i < sizeof(databuf); ++i) + databuf[i] = fill[i % sizeof fill]; - /* Post */ - curl_easy_setopt(curl, CURLOPT_POST, 1L); + /* Post */ + test_setopt(curl, CURLOPT_POST, 1L); #ifdef CURL_DOES_CONVERSIONS - /* Convert the POST data to ASCII */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + /* Convert the POST data to ASCII */ + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); #endif - /* Setup read callback */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + /* Setup read callback */ + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf)); + test_setopt(curl, CURLOPT_READFUNCTION, read_callback); - /* Write callback */ - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + /* Write callback */ + test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); - /* Ioctl function */ - curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); + /* Ioctl function */ + test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); - /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */ - curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); + /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */ + test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); - res = curl_easy_perform(curl); - fprintf(stderr, "curl_easy_perform = %d\n", (int)res); + res = curl_easy_perform(curl); + fprintf(stderr, "curl_easy_perform = %d\n", (int)res); - /* always cleanup */ - curl_easy_cleanup(curl); - } +test_cleanup: + + curl_easy_cleanup(curl); curl_global_cleanup(); return (int)res; } diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 7af9e4e42..c5644a04d 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -49,42 +49,52 @@ int test(char *URL) int i; struct curl_slist *headerlist=NULL, *hl; - curl_global_init(CURL_GLOBAL_ALL); - curl = curl_easy_init(); - - if(curl) { - for (i = 0; i < NUM_HEADERS; i++) { - int len = sprintf(buf, "Header%d: ", i); - memset(&buf[len], 'A', SIZE_HEADERS); - buf[len + SIZE_HEADERS]=0; /* zero terminate */ - hl = curl_slist_append(headerlist, buf); - if (!hl) - goto errout; - headerlist = hl; - } - hl = curl_slist_append(headerlist, "Expect: "); + 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; + } + + for (i = 0; i < NUM_HEADERS; i++) { + int len = sprintf(buf, "Header%d: ", i); + memset(&buf[len], 'A', SIZE_HEADERS); + buf[len + SIZE_HEADERS]=0; /* zero terminate */ + hl = curl_slist_append(headerlist, buf); if (!hl) - goto errout; + goto test_cleanup; headerlist = hl; + } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); - curl_easy_setopt(curl, CURLOPT_POST, 1L); + hl = curl_slist_append(headerlist, "Expect: "); + if (!hl) + goto test_cleanup; + headerlist = hl; + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HTTPHEADER, headerlist); + test_setopt(curl, CURLOPT_POST, 1L); #ifdef CURL_DOES_CONVERSIONS - /* Convert the POST data to ASCII */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + /* Convert the POST data to ASCII */ + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); #endif - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); - res = curl_easy_perform(curl); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)POSTLEN); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_READFUNCTION, myreadfunc); -errout: - curl_easy_cleanup(curl); + res = curl_easy_perform(curl); + +test_cleanup: + + curl_easy_cleanup(curl); + + curl_slist_free_all(headerlist); - curl_slist_free_all(headerlist); - } curl_global_cleanup(); return (int)res; diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 4b62e927d..5a78c52cb 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -115,29 +115,31 @@ int test(char *URL) } /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POST, 1L); /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft); /* we want to use our own read function */ - curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + test_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* send a multi-part formpost */ - curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + test_setopt(curl, CURLOPT_HTTPPOST, formpost); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* include headers in the output */ - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); +test_cleanup: + /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 0b9d27ae0..e5628a6d5 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -64,7 +64,7 @@ int test(char *URL) int res; CURL *curl; int counter=0; - CURLM *m; + CURLM *m = NULL; int running=1; struct timeval mp_start; char mp_timedout = FALSE; @@ -80,26 +80,26 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); /* read the POST data from a callback */ - curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); - curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); - curl_easy_setopt(curl, CURLOPT_READDATA, &counter); + test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + test_setopt(curl, CURLOPT_IOCTLDATA, &counter); + test_setopt(curl, CURLOPT_READFUNCTION, readcallback); + test_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POST, 1L); #ifdef CURL_DOES_CONVERSIONS /* Convert the POST data to ASCII. */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); #endif - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); - curl_easy_setopt(curl, CURLOPT_PROXYAUTH, + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); + test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); + test_setopt(curl, CURLOPT_PROXYAUTH, (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); if ((m = curl_multi_init()) == NULL) { @@ -144,10 +144,13 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } - curl_multi_remove_handle(m, curl); - curl_easy_cleanup(curl); - curl_multi_cleanup(m); +test_cleanup: + if(m) { + curl_multi_remove_handle(m, curl); + curl_multi_cleanup(m); + } + curl_easy_cleanup(curl); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 1466e40c0..26ae30ccd 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -39,8 +39,8 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); res = curl_easy_perform(curl); @@ -82,6 +82,7 @@ int test(char *URL) } } +test_cleanup: curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 3e34cf788..f553cc785 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -23,8 +23,9 @@ int test(char *URL) { CURL *http_handle; - CURLM *multi_handle; + CURLM *multi_handle = NULL; CURLMcode code; + int res; int still_running; /* keep number of running handles */ @@ -33,10 +34,10 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; /* set options */ - curl_easy_setopt(http_handle, CURLOPT_URL, URL); - curl_easy_setopt(http_handle, CURLOPT_HEADER, 1L); - curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYPEER, 0L); - curl_easy_setopt(http_handle, CURLOPT_SSL_VERIFYHOST, 0L); + 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); /* init a multi stack */ multi_handle = curl_multi_init(); @@ -93,9 +94,12 @@ int test(char *URL) } } - curl_multi_cleanup(multi_handle); +test_cleanup: + + if(multi_handle) + curl_multi_cleanup(multi_handle); curl_easy_cleanup(http_handle); - return 0; + return res; } diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index ffb0ce5f2..7f84a9aad 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -55,17 +55,19 @@ int test(char *URL) } /* enable verbose */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); /* set port number */ - curl_easy_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) ); + test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) ); /* specify target */ - curl_easy_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl,CURLOPT_URL, URL); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index e04a5aba1..827e08dda 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -26,7 +26,7 @@ int test(char *URL) CURL *curl; int running; char done=FALSE; - CURLM *m; + CURLM *m = NULL; struct timeval ml_start; struct timeval mp_start; char ml_timedout = FALSE; @@ -43,10 +43,10 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); + 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); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); @@ -133,8 +133,11 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } +test_cleanup: + curl_easy_cleanup(curl); - curl_multi_cleanup(m); + if(m) + curl_multi_cleanup(m); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c index e2cbe7769..03ad1ec75 100644 --- a/tests/libtest/lib566.c +++ b/tests/libtest/lib566.c @@ -30,8 +30,8 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); res = curl_easy_perform(curl); @@ -46,6 +46,8 @@ int test(char *URL) } } +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c index e04873b11..feae2cecf 100644 --- a/tests/libtest/lib567.c +++ b/tests/libtest/lib567.c @@ -32,20 +32,23 @@ int test(char *URL) } /* Dump data to stdout for protocol verification */ - curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); - curl_easy_setopt(curl, CURLOPT_USERAGENT, "test567"); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, URL); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + test_setopt(curl, CURLOPT_USERAGENT, "test567"); custom_headers = curl_slist_append(custom_headers, "Test-Number: 567"); - curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); + test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); res = curl_easy_perform(curl); - curl_slist_free_all(custom_headers); +test_cleanup: + + if(custom_headers) + curl_slist_free_all(custom_headers); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index c9406b0ec..0e7e3fea4 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -35,9 +35,9 @@ int test(char *URL) CURLcode res; CURL *curl; int sdp; - FILE *sdpf; + FILE *sdpf = NULL; struct_stat file_info; - char *stream_uri; + char *stream_uri = NULL; int request=1; struct curl_slist *custom_headers=NULL; @@ -52,14 +52,18 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; sdp = open("log/file568.txt", O_RDONLY); fstat(sdp, &file_info); @@ -68,65 +72,89 @@ int test(char *URL) sdpf = fopen("log/file568.txt", "rb"); if(sdpf == NULL) { fprintf(stderr, "can't open log/file568.txt\n"); - return TEST_ERR_MAJOR_BAD; + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; } - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); - curl_easy_setopt(curl, CURLOPT_READDATA, sdpf); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + test_setopt(curl, CURLOPT_READDATA, sdpf); + test_setopt(curl, CURLOPT_UPLOAD, 1L); + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); /* Do the ANNOUNCE */ res = curl_easy_perform(curl); - if(res) { - fclose(sdpf); - return res; - } + if(res) + goto test_cleanup; - curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L); + test_setopt(curl, CURLOPT_UPLOAD, 0L); fclose(sdpf); + sdpf = NULL; /* Make sure we can do a normal request now */ - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); res = curl_easy_perform(curl); if(res) - return res; + goto test_cleanup; /* Now do a POST style one */ - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; custom_headers = curl_slist_append(custom_headers, "Content-Type: posty goodness"); - - curl_easy_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, - "postyfield=postystuff&project=curl\n"); + if(!custom_headers) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); + test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n"); res = curl_easy_perform(curl); if(res) - return res; + goto test_cleanup; - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL); - curl_easy_setopt(curl, CURLOPT_RTSPHEADER, NULL); + test_setopt(curl, CURLOPT_POSTFIELDS, NULL); + test_setopt(curl, CURLOPT_RTSPHEADER, NULL); curl_slist_free_all(custom_headers); + custom_headers = NULL; /* Make sure we can do a normal request now */ - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); res = curl_easy_perform(curl); - if(res) - return res; + +test_cleanup: + + if(sdpf) + fclose(sdpf); + + if(stream_uri) + free(stream_uri); + + if(custom_headers) + curl_slist_free_all(custom_headers); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 9c5d803b9..d5af4514e 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -31,7 +31,7 @@ int test(char *URL) char *rtsp_session_id; int request=1; int i; - FILE *idfile; + FILE *idfile = NULL; idfile = fopen(libtest_arg2, "wb"); if(idfile == NULL) { @@ -52,52 +52,63 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); res = curl_easy_perform(curl); if(res != CURLE_BAD_FUNCTION_ARGUMENT) { fprintf(stderr, "This should have failed. " "Cannot setup without a Transport: header"); - fclose(idfile); - return TEST_ERR_MAJOR_BAD; + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; } /* Go through the various Session IDs */ for(i = 0; i < 3; i++) { - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, - "Fake/NotReal/JustATest;foo=baz"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz"); res = curl_easy_perform(curl); - if(res) { - fclose(idfile); - return res; - } + if(res) + goto test_cleanup; curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id); fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); rtsp_session_id = NULL; - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); - curl_easy_perform(curl); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); + res = curl_easy_perform(curl); /* Clear for the next go-round */ - curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); + test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); } - fclose(idfile); +test_cleanup: + + if(idfile) + fclose(idfile); + + if(stream_uri) + free(stream_uri); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 69a0168e0..f044f85e2 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -25,7 +25,7 @@ int test(char *URL) CURLcode res; CURL *curl; int request=1; - char *stream_uri; + char *stream_uri = NULL; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -38,47 +38,63 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; res = curl_easy_perform(curl); if(res != CURLE_RTSP_CSEQ_ERROR) { fprintf(stderr, "Failed to detect CSeq mismatch"); - return res; + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; } - curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); - curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, - "RAW/RAW/UDP;unicast;client_port=3056-3057"); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "RAW/RAW/UDP;unicast;client_port=3056-3057"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; res = curl_easy_perform(curl); if(res) - return res; + goto test_cleanup; + + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; res = curl_easy_perform(curl); if(res != CURLE_RTSP_SESSION_ERROR) { fprintf(stderr, "Failed to detect a Session ID mismatch"); } +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index a1cd032ab..a264eddbd 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -91,7 +91,7 @@ int test(char *URL) { CURLcode res; CURL *curl; - char *stream_uri; + char *stream_uri = NULL; int request=1; FILE *protofile; @@ -113,54 +113,81 @@ int test(char *URL) fclose(protofile); return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; - curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, protofile); + test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); + test_setopt(curl, CURLOPT_TIMEOUT, 3); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_WRITEDATA, protofile); + + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, "RTP/AVP/TCP;interleaved=0-1"); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); res = curl_easy_perform(curl); + if(res) + goto test_cleanup; /* This PLAY starts the interleave */ - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + stream_uri = NULL; + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + res = curl_easy_perform(curl); + if(res) + goto test_cleanup; /* The DESCRIBE request will try to consume data after the Content */ - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); + stream_uri = NULL; + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); res = curl_easy_perform(curl); + if(res) + goto test_cleanup; stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + stream_uri = NULL; + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); + res = curl_easy_perform(curl); + if(res) + goto test_cleanup; fprintf(stderr, "PLAY COMPLETE\n"); /* Use Receive to get the rest of the data */ while(!res && rtp_packet_count < 13) { fprintf(stderr, "LOOPY LOOP!\n"); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_RECEIVE); res = curl_easy_perform(curl); } +test_cleanup: + + fclose(protofile); + curl_easy_cleanup(curl); curl_global_cleanup(); - fclose(protofile); return (int)res; } diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 202ca7ba4..3a01a07dc 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -42,6 +42,9 @@ #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 + extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */ -- cgit v1.2.1 From e3009f2950b2f6b778a6e0daf4466d6ec9132ed2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 5 Feb 2010 19:19:34 +0000 Subject: fix compiler warning --- tests/libtest/lib526.c | 2 +- tests/libtest/lib530.c | 2 +- tests/libtest/lib568.c | 2 +- tests/libtest/lib569.c | 6 +++--- tests/libtest/lib570.c | 6 +++--- tests/libtest/lib571.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 600ed65e5..c68e19b6d 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -215,7 +215,7 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } -test_cleanup: +/* test_cleanup: */ #ifndef LIB527 /* get NUM_HANDLES easy handles */ diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index ef2218834..3b0bd001c 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -197,7 +197,7 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } -test_cleanup: +/* test_cleanup: */ /* cleanup NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 0e7e3fea4..3443c406a 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -32,7 +32,7 @@ static char *suburl(const char *base, int i) */ int test(char *URL) { - CURLcode res; + int res; CURL *curl; int sdp; FILE *sdpf = NULL; diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index d5af4514e..815ca3a71 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -25,7 +25,7 @@ static char *suburl(const char *base, int i) */ int test(char *URL) { - CURLcode res; + int res; CURL *curl; char *stream_uri; char *rtsp_session_id; @@ -60,7 +60,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); res = curl_easy_perform(curl); - if(res != CURLE_BAD_FUNCTION_ARGUMENT) { + if(res != (int)CURLE_BAD_FUNCTION_ARGUMENT) { fprintf(stderr, "This should have failed. " "Cannot setup without a Transport: header"); res = TEST_ERR_MAJOR_BAD; @@ -113,6 +113,6 @@ test_cleanup: curl_easy_cleanup(curl); curl_global_cleanup(); - return (int)res; + return res; } diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index f044f85e2..4f40a0276 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -22,7 +22,7 @@ static char *suburl(const char *base, int i) int test(char *URL) { - CURLcode res; + int res; CURL *curl; int request=1; char *stream_uri = NULL; @@ -55,7 +55,7 @@ int test(char *URL) stream_uri = NULL; res = curl_easy_perform(curl); - if(res != CURLE_RTSP_CSEQ_ERROR) { + if(res != (int)CURLE_RTSP_CSEQ_ERROR) { fprintf(stderr, "Failed to detect CSeq mismatch"); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -98,6 +98,6 @@ test_cleanup: curl_easy_cleanup(curl); curl_global_cleanup(); - return (int)res; + return res; } diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index a264eddbd..b91a6fa8b 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -89,7 +89,7 @@ static char *suburl(const char *base, int i) int test(char *URL) { - CURLcode res; + int res; CURL *curl; char *stream_uri = NULL; int request=1; @@ -189,6 +189,6 @@ test_cleanup: curl_easy_cleanup(curl); curl_global_cleanup(); - return (int)res; + return res; } -- cgit v1.2.1 From 880452d2edbeb3b42fd2c8794b045b3cc640a255 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 5 Feb 2010 19:24:22 +0000 Subject: fix compiler warning --- tests/libtest/lib526.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index c68e19b6d..89fddbc51 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -215,7 +215,9 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } -/* test_cleanup: */ +#ifdef LIB532 +test_cleanup: +#endif #ifndef LIB527 /* get NUM_HANDLES easy handles */ -- cgit v1.2.1 From 2c2464a68211fb788b21de50a51798baa57423be Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 5 Feb 2010 20:52:00 +0000 Subject: fix compiler warning --- tests/libtest/lib569.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 815ca3a71..9b345b065 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -27,7 +27,7 @@ int test(char *URL) { int res; CURL *curl; - char *stream_uri; + char *stream_uri = NULL; char *rtsp_session_id; int request=1; int i; -- cgit v1.2.1 From 0f4a91afdedc4b1f7b02f8b015fde1889d80c104 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 6 Feb 2010 13:21:45 +0000 Subject: OOM handling fix --- tests/libtest/lib570.c | 3 +++ tests/libtest/lib571.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 4f40a0276..8cfc0b88b 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -95,6 +95,9 @@ int test(char *URL) test_cleanup: + if(stream_uri) + free(stream_uri); + curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index b91a6fa8b..24c507545 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -93,7 +93,7 @@ int test(char *URL) CURL *curl; char *stream_uri = NULL; int request=1; - FILE *protofile; + FILE *protofile = NULL; protofile = fopen(libtest_arg2, "wb"); if(protofile == NULL) { @@ -109,8 +109,8 @@ int test(char *URL) if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); - curl_global_cleanup(); fclose(protofile); + curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } test_setopt(curl, CURLOPT_URL, URL); @@ -163,7 +163,10 @@ int test(char *URL) if(res) goto test_cleanup; - stream_uri = suburl(URL, request++); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); stream_uri = NULL; @@ -184,7 +187,11 @@ int test(char *URL) test_cleanup: - fclose(protofile); + if(stream_uri) + free(stream_uri); + + if(protofile) + fclose(protofile); curl_easy_cleanup(curl); curl_global_cleanup(); -- cgit v1.2.1 From a07bc79117971b96ebf3188c0a34a73ee0a3609b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 14 Feb 2010 19:40:18 +0000 Subject: removed trailing whitespace --- tests/libtest/CMakeLists.txt | 4 ++-- tests/libtest/Makefile.am | 4 ++-- tests/libtest/lib502.c | 2 +- tests/libtest/lib507.c | 6 +++--- tests/libtest/lib518.c | 8 ++++---- tests/libtest/lib526.c | 4 ++-- tests/libtest/lib530.c | 4 ++-- tests/libtest/lib533.c | 4 ++-- tests/libtest/lib536.c | 2 +- tests/libtest/lib537.c | 8 ++++---- tests/libtest/lib556.c | 2 +- tests/libtest/lib558.c | 2 +- tests/libtest/test1013.pl | 2 +- tests/libtest/test1022.pl | 2 +- tests/libtest/test307.pl | 2 +- tests/libtest/test610.pl | 2 +- tests/libtest/test613.pl | 2 +- tests/libtest/test75.pl | 2 +- 18 files changed, 31 insertions(+), 31 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index f0ee8cd2b..653e5315d 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -20,9 +20,9 @@ function(SETUP_TEST TEST_NAME) # ARGN are the files in the test set_target_properties(${TEST_NAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}") - # Add the postfix to the executable since it is + # Add the postfix to the executable since it is # not added automatically as for modules and shared libraries - set_target_properties(${TEST_NAME} + set_target_properties(${TEST_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") if(MSVC) diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 81a0606be..9c041d7f2 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -48,7 +48,7 @@ INCLUDES = -I$(top_builddir)/include/curl \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ - -I$(top_srcdir)/lib + -I$(top_srcdir)/lib endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 0a0a819b0..d1c734cc7 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -63,7 +63,7 @@ int test(char *URL) while (running) { res = (int)curl_multi_perform(m, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 252775840..306ba2da3 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -64,7 +64,7 @@ int test(char *URL) do { ret = curl_multi_perform(multi, &still_running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; @@ -88,7 +88,7 @@ int test(char *URL) timeout.tv_sec = 1; timeout.tv_usec = 0; - if (tutil_tvdiff(tutil_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -105,7 +105,7 @@ int test(char *URL) mp_start = tutil_tvnow(); do { ret = curl_multi_perform(multi, &still_running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index d8310d92d..9d1ae96ac 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -216,7 +216,7 @@ static int rlimit(int keep_open) /* * verify that soft limit is higher than NUM_NEEDED, - * which is the number of file descriptors we would + * which is the number of file descriptors we would * try to open plus SAFETY_MARGIN to not exhaust the * file descriptor pool */ @@ -329,8 +329,8 @@ static int rlimit(int keep_open) /* create a bunch of file descriptors */ - for (num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; + for (num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) { fd[num_open.rlim_cur] = dup(fd[0]); @@ -468,7 +468,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - /* run the test with the bunch of open file descriptors + /* run the test with the bunch of open file descriptors and close them all once the test is over */ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 89fddbc51..65fa2fd3a 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -129,7 +129,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (tutil_tvdiff(tutil_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -139,7 +139,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 3b0bd001c..01f35f765 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -141,7 +141,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (tutil_tvdiff(tutil_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -151,7 +151,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 810b075e5..42dfb1a41 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -79,7 +79,7 @@ int test(char *URL) interval.tv_sec = 1; interval.tv_usec = 0; - if (tutil_tvdiff(tutil_tvnow(), ml_start) > + if (tutil_tvdiff(tutil_tvnow(), ml_start) > MAIN_LOOP_HANG_TIMEOUT) { ml_timedout = TRUE; break; @@ -89,7 +89,7 @@ int test(char *URL) while (res == CURLM_CALL_MULTI_PERFORM) { res = (int)curl_multi_perform(m, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 06d863ca9..2300ce109 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -33,7 +33,7 @@ static CURLMcode perform(CURLM * multi) for (;;) { code = curl_multi_perform(multi, &handles); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > + if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { mp_timedout = TRUE; break; diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 791448a86..b15cb8ac1 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -204,7 +204,7 @@ static int rlimit(int keep_open) /* * test 537 is all about testing libcurl functionality * when the system has nearly exhausted the number of - * available file descriptors. Test 537 will try to run + * available file descriptors. Test 537 will try to run * with a very small number of file descriptors available. * This implies that any file descriptor which is open * when the test runs will have a number in the high range @@ -323,8 +323,8 @@ static int rlimit(int keep_open) /* create a bunch of file descriptors */ - for (num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; + for (num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur++) { fd[num_open.rlim_cur] = dup(fd[0]); @@ -471,7 +471,7 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - /* run the test with the bunch of open file descriptors + /* run the test with the bunch of open file descriptors and close them all once the test is over */ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 26ae30ccd..583723d22 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -46,7 +46,7 @@ int test(char *URL) if(!res) { /* we are connected, now get a HTTP document the raw way */ - const char *request = + const char *request = #ifdef CURL_DOES_CONVERSIONS /* ASCII representation with escape sequences for non-ASCII platforms */ "\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e" diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 253e043e1..7ed991dd3 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -88,7 +88,7 @@ int test(char *URL) CURL *easyh = NULL; struct curl_hash *hp = NULL; int result = 0; - + if(!strcmp(URL, "check")) { /* test harness script verifying if this test can run */ return 0; /* sure, run this! */ diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 8ab1a8c95..33127da4a 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -1,7 +1,7 @@ #!/usr/bin/env perl # Determine if curl-config --protocols/--features matches the # curl --version protocols/features -if ( $#ARGV != 2 ) +if ( $#ARGV != 2 ) { print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n"; exit 3; diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index 5b16de3e0..94b3cb04f 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # Determine if curl-config --version matches the curl --version -if ( $#ARGV != 2 ) +if ( $#ARGV != 2 ) { print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n"; exit 3; diff --git a/tests/libtest/test307.pl b/tests/libtest/test307.pl index 7e2687b54..b8e3214fc 100755 --- a/tests/libtest/test307.pl +++ b/tests/libtest/test307.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # Determine if the given curl executable supports the 'openssl' SSL engine -if ( $#ARGV != 0 ) +if ( $#ARGV != 0 ) { print "Usage: $0 curl-executable\n"; exit 3; diff --git a/tests/libtest/test610.pl b/tests/libtest/test610.pl index 5257171a7..c9542ca51 100755 --- a/tests/libtest/test610.pl +++ b/tests/libtest/test610.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # Perform simple file and directory manipulation in a portable way -if ( $#ARGV <= 0 ) +if ( $#ARGV <= 0 ) { print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n"; exit 1; diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index ba9ed32e9..dc3b1fb2e 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -2,7 +2,7 @@ # Prepare a directory with known files and clean up afterwards use Time::Local; -if ( $#ARGV < 1 ) +if ( $#ARGV < 1 ) { print "Usage: $0 prepare|postprocess dir [logfile]\n"; exit 1; diff --git a/tests/libtest/test75.pl b/tests/libtest/test75.pl index 01a53ff15..4d14b1e12 100755 --- a/tests/libtest/test75.pl +++ b/tests/libtest/test75.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # Check that the length of a given URL is correct -if ( $#ARGV != 1 ) +if ( $#ARGV != 1 ) { print "Usage: $0 string length\n"; exit 3; -- cgit v1.2.1 From 46b112bcd439f4413925a7300d66a3e6f148765e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 16 Feb 2010 13:32:45 +0000 Subject: replaced tabs with spaces --- tests/libtest/test1013.pl | 10 ++-- tests/libtest/test1022.pl | 26 ++++---- tests/libtest/test307.pl | 8 +-- tests/libtest/test610.pl | 46 +++++++------- tests/libtest/test613.pl | 148 +++++++++++++++++++++++----------------------- tests/libtest/test75.pl | 8 +-- 6 files changed, 123 insertions(+), 123 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 33127da4a..99ad524eb 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -3,8 +3,8 @@ # curl --version protocols/features if ( $#ARGV != 2 ) { - print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n"; - exit 3; + print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n"; + exit 3; } my $what=$ARGV[2]; @@ -42,8 +42,8 @@ my $curlconfigproto = join ' ', @curl_config; my $different = $curlproto ne $curlconfigproto; if ($different) { - print "Mismatch in $what lists:\n"; - print "curl: $curlproto\n"; - print "curl-config: $curlconfigproto\n"; + print "Mismatch in $what lists:\n"; + print "curl: $curlproto\n"; + print "curl-config: $curlconfigproto\n"; } exit $different; diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index 94b3cb04f..fad024e19 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -2,8 +2,8 @@ # Determine if curl-config --version matches the curl --version if ( $#ARGV != 2 ) { - print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n"; - exit 3; + print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n"; + exit 3; } my $what=$ARGV[2]; @@ -23,23 +23,23 @@ open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what l $_ = ; chomp; if ( $what eq "version" ) { - /^libcurl ([\.\d]+(-CVS)?)$/ ; - $curlconfigversion = $1; + /^libcurl ([\.\d]+(-CVS)?)$/ ; + $curlconfigversion = $1; } else { - # Convert hex version to decimal for comparison's sake - /^(..)(..)(..)$/ ; - $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); + # Convert hex version to decimal for comparison's sake + /^(..)(..)(..)$/ ; + $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); - # Strip off the -CVS from the curl version if it's there - $version =~ s/-CVS$//; + # Strip off the -CVS from the curl version if it's there + $version =~ s/-CVS$//; } close CURLCONFIG; my $different = $version ne $curlconfigversion; if ($different || !$version) { - print "Mismatch in --version:\n"; - print "curl: $version\n"; - print "curl-config: $curlconfigversion\n"; - exit 1; + print "Mismatch in --version:\n"; + print "curl: $version\n"; + print "curl-config: $curlconfigversion\n"; + exit 1; } diff --git a/tests/libtest/test307.pl b/tests/libtest/test307.pl index b8e3214fc..469af3c21 100755 --- a/tests/libtest/test307.pl +++ b/tests/libtest/test307.pl @@ -2,13 +2,13 @@ # Determine if the given curl executable supports the 'openssl' SSL engine if ( $#ARGV != 0 ) { - print "Usage: $0 curl-executable\n"; - exit 3; + print "Usage: $0 curl-executable\n"; + exit 3; } if (!open(CURL, "@ARGV[0] -s --engine list|")) { - print "Can't get SSL engine list\n"; - exit 2; + print "Can't get SSL engine list\n"; + exit 2; } while( ) { diff --git a/tests/libtest/test610.pl b/tests/libtest/test610.pl index c9542ca51..a900d94b4 100755 --- a/tests/libtest/test610.pl +++ b/tests/libtest/test610.pl @@ -2,32 +2,32 @@ # Perform simple file and directory manipulation in a portable way if ( $#ARGV <= 0 ) { - print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n"; - exit 1; + print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n"; + exit 1; } use File::Copy; while(@ARGV) { - my $cmd = shift @ARGV; - my $arg = shift @ARGV; - if ($cmd eq "mkdir") { - mkdir $arg || die "$!"; - } - elsif ($cmd eq "rmdir") { - rmdir $arg || die "$!"; - } - elsif ($cmd eq "rm") { - unlink $arg || die "$!"; - } - elsif ($cmd eq "move") { - my $arg2 = shift @ARGV; - move($arg,$arg2) || die "$!"; - } - elsif ($cmd eq "gone") { - ! -e $arg || die "Path $arg exists"; - } else { - print "Unsupported command $cmd\n"; - exit 1; - } + my $cmd = shift @ARGV; + my $arg = shift @ARGV; + if ($cmd eq "mkdir") { + mkdir $arg || die "$!"; + } + elsif ($cmd eq "rmdir") { + rmdir $arg || die "$!"; + } + elsif ($cmd eq "rm") { + unlink $arg || die "$!"; + } + elsif ($cmd eq "move") { + my $arg2 = shift @ARGV; + move($arg,$arg2) || die "$!"; + } + elsif ($cmd eq "gone") { + ! -e $arg || die "Path $arg exists"; + } else { + print "Unsupported command $cmd\n"; + exit 1; + } } exit 0; diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index dc3b1fb2e..b4caaae07 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -4,102 +4,102 @@ use Time::Local; if ( $#ARGV < 1 ) { - print "Usage: $0 prepare|postprocess dir [logfile]\n"; - exit 1; + print "Usage: $0 prepare|postprocess dir [logfile]\n"; + exit 1; } # expects an error message on stdout sub errout { - print $_[0] . "\n"; - exit 1; + print $_[0] . "\n"; + exit 1; } if ($ARGV[0] eq "prepare") { - my $dirname = $ARGV[1]; - mkdir $dirname || errout "$!"; - chdir $dirname; + my $dirname = $ARGV[1]; + mkdir $dirname || errout "$!"; + chdir $dirname; - # Create the files in alphabetical order, to increase the chances - # of receiving a consistent set of directory contents regardless - # of whether the server alphabetizes the results or not. - mkdir "asubdir" || errout "$!"; - chmod 0777, "asubdir"; + # Create the files in alphabetical order, to increase the chances + # of receiving a consistent set of directory contents regardless + # of whether the server alphabetizes the results or not. + mkdir "asubdir" || errout "$!"; + chmod 0777, "asubdir"; - open(FILE, ">plainfile.txt") || errout "$!"; - binmode FILE; - print FILE "Test file to support curl test suite\n"; - close(FILE); - utime time, timegm(0,0,12,1,0,100), "plainfile.txt"; - chmod 0666, "plainfile.txt"; + open(FILE, ">plainfile.txt") || errout "$!"; + binmode FILE; + print FILE "Test file to support curl test suite\n"; + close(FILE); + utime time, timegm(0,0,12,1,0,100), "plainfile.txt"; + chmod 0666, "plainfile.txt"; - open(FILE, ">rofile.txt") || errout "$!"; - binmode FILE; - print FILE "Read-only test file to support curl test suite\n"; - close(FILE); - utime time, timegm(0,0,12,31,11,100), "rofile.txt"; - chmod 0444, "rofile.txt"; + open(FILE, ">rofile.txt") || errout "$!"; + binmode FILE; + print FILE "Read-only test file to support curl test suite\n"; + close(FILE); + utime time, timegm(0,0,12,31,11,100), "rofile.txt"; + chmod 0444, "rofile.txt"; - exit 0; + exit 0; } elsif ($ARGV[0] eq "postprocess") { - my $dirname = $ARGV[1]; - my $logfile = $ARGV[2]; + my $dirname = $ARGV[1]; + my $logfile = $ARGV[2]; - # Clean up the test directory - unlink "$dirname/rofile.txt"; - unlink "$dirname/plainfile.txt"; - rmdir "$dirname/asubdir"; + # Clean up the test directory + unlink "$dirname/rofile.txt"; + unlink "$dirname/plainfile.txt"; + rmdir "$dirname/asubdir"; - rmdir $dirname || die "$!"; + rmdir $dirname || die "$!"; - if ($logfile) { - # Process the directory file to remove all information that - # could be inconsistent from one test run to the next (e.g. - # file date) or may be unsupported on some platforms (e.g. - # Windows). Also, since 7.17.0, the sftp directory listing - # format can be dependent on the server (with a recent - # enough version of libssh2) so this script must also - # canonicalize the format. Here are examples of the general - # format supported: - # -r--r--r-- 12 ausername grp 47 Dec 31 2000 rofile.txt - # -r--r--r-- 1 1234 4321 47 Dec 31 2000 rofile.txt - # The "canonical" format is similar to the first (which is - # the one generated on a typical Linux installation): - # -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt + if ($logfile) { + # Process the directory file to remove all information that + # could be inconsistent from one test run to the next (e.g. + # file date) or may be unsupported on some platforms (e.g. + # Windows). Also, since 7.17.0, the sftp directory listing + # format can be dependent on the server (with a recent + # enough version of libssh2) so this script must also + # canonicalize the format. Here are examples of the general + # format supported: + # -r--r--r-- 12 ausername grp 47 Dec 31 2000 rofile.txt + # -r--r--r-- 1 1234 4321 47 Dec 31 2000 rofile.txt + # The "canonical" format is similar to the first (which is + # the one generated on a typical Linux installation): + # -r-?r-?r-? 12 U U 47 Dec 31 2000 rofile.txt - my @canondir; - open(IN, "<$logfile") || die "$!"; - while () { - /^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)(.*)$/; - if ($1 eq "d") { - # Erase all directory metadata except for the name, as it is not - # consistent for across all test systems and filesystems - push @canondir, "d????????? N U U N ??? N NN:NN$8\n"; - } elsif ($1 eq "-") { - # Erase user and group names, as they are not consistent across - # all test systems - my $line = sprintf("%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8); - push @canondir, $line; - } else { - # Unexpected format; just pass it through and let the test fail - push @canondir, $_; - } - } - close(IN); + my @canondir; + open(IN, "<$logfile") || die "$!"; + while () { + /^(.)(..).(..).(..).\s*(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+\s+\S+\s+\S+)(.*)$/; + if ($1 eq "d") { + # Erase all directory metadata except for the name, as it is not + # consistent for across all test systems and filesystems + push @canondir, "d????????? N U U N ??? N NN:NN$8\n"; + } elsif ($1 eq "-") { + # Erase user and group names, as they are not consistent across + # all test systems + my $line = sprintf("%s%s?%s?%s?%5d U U %15d %s%s\n", $1,$2,$3,$4,$5,$6,$7,$8); + push @canondir, $line; + } else { + # Unexpected format; just pass it through and let the test fail + push @canondir, $_; + } + } + close(IN); - @canondir = sort {substr($a,57) cmp substr($b,57)} @canondir; - my $newfile = $logfile . ".new"; - open(OUT, ">$newfile") || die "$!"; - print OUT join('', @canondir); - close(OUT); + @canondir = sort {substr($a,57) cmp substr($b,57)} @canondir; + my $newfile = $logfile . ".new"; + open(OUT, ">$newfile") || die "$!"; + print OUT join('', @canondir); + close(OUT); - unlink $logfile; - rename $newfile, $logfile; - } + unlink $logfile; + rename $newfile, $logfile; + } - exit 0; + exit 0; } print "Unsupported command $ARGV[0]\n"; exit 1; diff --git a/tests/libtest/test75.pl b/tests/libtest/test75.pl index 4d14b1e12..31cdfb8cc 100755 --- a/tests/libtest/test75.pl +++ b/tests/libtest/test75.pl @@ -2,12 +2,12 @@ # Check that the length of a given URL is correct if ( $#ARGV != 1 ) { - print "Usage: $0 string length\n"; - exit 3; + print "Usage: $0 string length\n"; + exit 3; } if (length(@ARGV[0]) != @ARGV[1]) { - print "Given host IP and port not supported\n"; - exit 1; + print "Given host IP and port not supported\n"; + exit 1; } exit 0; -- cgit v1.2.1 From b33ddd615aad0459a9022b1c932e1831a0dbc965 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 23 Mar 2010 12:43:42 +0100 Subject: ignore more files generated when tests run in the source tree --- tests/libtest/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/libtest/.gitignore (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore new file mode 100644 index 000000000..3311a821e --- /dev/null +++ b/tests/libtest/.gitignore @@ -0,0 +1,2 @@ +lib5[0-9][0-9] + -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- tests/libtest/Makefile.am | 1 - tests/libtest/first.c | 1 - tests/libtest/lib500.c | 1 - tests/libtest/lib501.c | 1 - tests/libtest/lib502.c | 1 - tests/libtest/lib503.c | 1 - tests/libtest/lib504.c | 1 - tests/libtest/lib505.c | 1 - tests/libtest/lib506.c | 1 - tests/libtest/lib507.c | 1 - tests/libtest/lib508.c | 1 - tests/libtest/lib510.c | 1 - tests/libtest/lib511.c | 1 - tests/libtest/lib512.c | 1 - tests/libtest/lib513.c | 1 - tests/libtest/lib514.c | 1 - tests/libtest/lib515.c | 1 - tests/libtest/lib516.c | 1 - tests/libtest/lib517.c | 1 - tests/libtest/lib518.c | 1 - tests/libtest/lib519.c | 1 - tests/libtest/lib520.c | 1 - tests/libtest/lib521.c | 1 - tests/libtest/lib523.c | 1 - tests/libtest/lib524.c | 1 - tests/libtest/lib525.c | 1 - tests/libtest/lib526.c | 1 - tests/libtest/lib530.c | 1 - tests/libtest/lib533.c | 1 - tests/libtest/lib536.c | 1 - tests/libtest/lib537.c | 1 - tests/libtest/lib539.c | 1 - tests/libtest/lib540.c | 1 - tests/libtest/lib541.c | 1 - tests/libtest/lib542.c | 1 - tests/libtest/lib543.c | 1 - tests/libtest/lib544.c | 1 - tests/libtest/lib547.c | 1 - tests/libtest/lib549.c | 1 - tests/libtest/lib552.c | 1 - tests/libtest/lib553.c | 1 - tests/libtest/lib554.c | 1 - tests/libtest/lib555.c | 1 - tests/libtest/lib556.c | 1 - tests/libtest/lib557.c | 1 - tests/libtest/lib558.c | 1 - tests/libtest/lib560.c | 1 - tests/libtest/lib562.c | 1 - tests/libtest/lib564.c | 1 - tests/libtest/lib566.c | 1 - tests/libtest/lib567.c | 1 - tests/libtest/lib568.c | 1 - tests/libtest/lib569.c | 1 - tests/libtest/lib570.c | 1 - tests/libtest/lib571.c | 1 - tests/libtest/test.h | 1 - tests/libtest/testutil.c | 1 - tests/libtest/testutil.h | 1 - 58 files changed, 58 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 9c041d7f2..70b0f12a4 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -18,7 +18,6 @@ # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY # KIND, either express or implied. # -# $Id$ ########################################################################### AUTOMAKE_OPTIONS = foreign nostdinc diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 032704ca0..770f9d527 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index c0cc9dee5..dc6967cbe 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index 8963fbb39..770cf8f74 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index d1c734cc7..f6be5aaf7 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 3e8f3dc55..2301186af 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 5eedb9ecc..418da2f8c 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index b1c679990..9dfae8405 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 99cf915d3..9209056dd 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 306ba2da3..9707c9b07 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index f392e414d..0fa5eb9d2 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index bb0a11f25..f3f8cdbc0 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 0e2f3df10..dea97c5e2 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index 14072f45c..9f59f7baf 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index 602456310..c85006e1d 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 6a5733e99..283f89e4b 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index 56ee68ead..2660ae369 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index 8721583cf..b796dbbb7 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index d07e74602..3f7b064ab 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 9d1ae96ac..9e683d956 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index 66013498b..f885c5de6 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index 57355a58f..a0e124489 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index a51b4e83c..a4ae5558a 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index 1dcfcd9c1..a1ac4a4e9 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index 0b3ec5845..ee520628b 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 41a519e7e..d2542577b 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 65fa2fd3a..0418b6ba2 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ /* diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 01f35f765..abefc92d3 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 42dfb1a41..89ac7bf89 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ /* used for test case 533, 534 and 535 */ diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 2300ce109..04bc6965d 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index b15cb8ac1..842dbab77 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index f7df40854..9909d01d1 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 5fcf7bc9d..bf4cd5225 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl * mailing list on 10 Jul 2007, converted to a test case. diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index 9305a936c..c060b8ac7 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index 585c18b3c..ef7b483b4 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 88387a198..8f14f8411 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * Based on Alex Fishman's bug report on September 30, 2007 */ diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 3229fdad3..6bc899cc5 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index ba81b49c4..4ef303726 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * argv1 = URL * argv2 = proxy diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index 4a3ee7bec..9fd18b225 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * argv1 = URL * argv2 = proxy diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 530c5df06..eeecf6f91 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * argv1 = URL * argv2 = proxy with embedded user+password diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index c5644a04d..8694daf67 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * This test case and code is based on the bug recipe Joe Malicki provided for * bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release. diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 5a78c52cb..d7c68241a 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index e5628a6d5..55b3f13ed 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * This test case is supposed to be identical to 547 except that this uses the * multi interface and 547 is easy interface. diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 583723d22..78d123baa 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index d09b567f2..48ccaf38e 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ /* diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 7ed991dd3..56f2a2612 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index f553cc785..ce6809d39 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * */ #include "test.h" diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index 7f84a9aad..d78ecce25 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index 827e08dda..d33f23042 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c index 03ad1ec75..889f15b3a 100644 --- a/tests/libtest/lib566.c +++ b/tests/libtest/lib566.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c index feae2cecf..e1df0c1e4 100644 --- a/tests/libtest/lib567.c +++ b/tests/libtest/lib567.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 3443c406a..1f16664cb 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 9b345b065..b5182d64c 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 8cfc0b88b..9fe2eceaa 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 24c507545..2892211aa 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include "test.h" diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 3a01a07dc..2a3671181 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ /* Now include the setup.h file from libcurl's private libdir (the source diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index a70652626..63393c589 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -18,7 +18,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 6f7839d24..6a322e3cb 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -20,7 +20,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From 50b51161c9ae3833489d2bf42b43fced46ab5587 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:30:34 +0100 Subject: s/CVS/DEV/ in the version string for repo versions --- tests/libtest/test1022.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index fad024e19..a3f318abb 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -12,7 +12,7 @@ my $what=$ARGV[2]; open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n"; $_ = ; chomp; -/libcurl\/([\.\d]+(-CVS)?)/; +/libcurl\/([\.\d]+(-DEV)?)/; my $version = $1; close CURL; -- cgit v1.2.1 From 1ac168e576d8e78b58640e1e997249717529b482 Mon Sep 17 00:00:00 2001 From: Chris Conroy Date: Wed, 24 Mar 2010 01:35:03 -0400 Subject: Fix RTSP GET_PARAMETER empty and non-empty operation. Test coverage included. Thanks to Massimo Callegari for the bug report --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib572.c | 177 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib572.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 5a5a0ea8e..4dc8615a7 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -11,7 +11,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 + lib568 lib569 lib570 lib571 lib572 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -143,3 +143,5 @@ lib570_SOURCES = lib570.c $(SUPPORTFILES) lib571_SOURCES = lib571.c $(SUPPORTFILES) +lib572_SOURCES = lib572.c $(SUPPORTFILES) + diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c new file mode 100644 index 000000000..8286487ea --- /dev/null +++ b/tests/libtest/lib572.c @@ -0,0 +1,177 @@ + +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include "test.h" + +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif + +#include + +#include "memdebug.h" + +/* build request url */ +static char *suburl(const char *base, int i) +{ + return curl_maprintf("%s%.4d", base, i); +} + +/* + * Test GET_PARAMETER: PUT, HEARTBEAT, and POST + */ +int test(char *URL) +{ + int res; + CURL *curl; + int params; + FILE *paramsf = NULL; + struct_stat file_info; + char *stream_uri = NULL; + int request=1; + struct curl_slist *custom_headers=NULL; + + 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; + } + + + test_setopt(curl, CURLOPT_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + test_setopt(curl, CURLOPT_URL, URL); + + /* SETUP */ + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); + free(stream_uri); + stream_uri = NULL; + + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); + res = curl_easy_perform(curl); + fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); + if(res) + goto test_cleanup; + + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); + free(stream_uri); + stream_uri = NULL; + fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); + + /* PUT style GET_PARAMETERS */ + params = open("log/file572.txt", O_RDONLY); + fstat(params, &file_info); + close(params); + + paramsf = fopen("log/file572.txt", "rb"); + if(paramsf == NULL) { + fprintf(stderr, "can't open log/file572.txt\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER); + + test_setopt(curl, CURLOPT_READDATA, paramsf); + test_setopt(curl, CURLOPT_UPLOAD, 1L); + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + + fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); + res = curl_easy_perform(curl); + if(res) + goto test_cleanup; + + test_setopt(curl, CURLOPT_UPLOAD, 0L); + fclose(paramsf); + paramsf = NULL; + fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); + + /* Heartbeat GET_PARAMETERS */ + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); + free(stream_uri); + stream_uri = NULL; + + fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); + res = curl_easy_perform(curl); + if(res) + goto test_cleanup; + + /* POST GET_PARAMETERS */ + + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); + free(stream_uri); + stream_uri = NULL; + + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER); + test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n"); + + res = curl_easy_perform(curl); + if(res) + goto test_cleanup; + + test_setopt(curl, CURLOPT_POSTFIELDS, NULL); + + /* Make sure we can do a normal request now */ + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); + free(stream_uri); + stream_uri = NULL; + + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + res = curl_easy_perform(curl); + +test_cleanup: + + if(paramsf) + fclose(paramsf); + + if(stream_uri) + free(stream_uri); + + if(custom_headers) + curl_slist_free_all(custom_headers); + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} + -- cgit v1.2.1 From 8aa68b4cadaa00759547f9de0cff7fb37ffe5ca3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 13:27:49 +0100 Subject: remove trace of CVS --- tests/libtest/lib572.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 8286487ea..b3e48e3a4 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -5,8 +5,6 @@ * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| - * - * $Id$ */ #include "test.h" -- cgit v1.2.1 From c869ae74478638a90414b392d5418d26e0b36de5 Mon Sep 17 00:00:00 2001 From: Chris Conroy Date: Wed, 24 Mar 2010 09:21:33 -0400 Subject: remove debug printfs --- tests/libtest/lib572.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index b3e48e3a4..18e74d4db 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -69,9 +69,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles"); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); res = curl_easy_perform(curl); - fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); if(res) goto test_cleanup; @@ -82,7 +80,6 @@ int test(char *URL) test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); stream_uri = NULL; - fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); /* PUT style GET_PARAMETERS */ params = open("log/file572.txt", O_RDONLY); @@ -101,7 +98,6 @@ int test(char *URL) test_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); - fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); res = curl_easy_perform(curl); if(res) goto test_cleanup; @@ -109,7 +105,6 @@ int test(char *URL) test_setopt(curl, CURLOPT_UPLOAD, 0L); fclose(paramsf); paramsf = NULL; - fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); /* Heartbeat GET_PARAMETERS */ if((stream_uri = suburl(URL, request++)) == NULL) { @@ -120,7 +115,6 @@ int test(char *URL) free(stream_uri); stream_uri = NULL; - fprintf(stderr, "CPC: %s:%d\n", __FILE__, __LINE__); res = curl_easy_perform(curl); if(res) goto test_cleanup; -- cgit v1.2.1 From a1a66c7cd636a5960beaad30e961928ad27d9f5b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 Mar 2010 10:38:17 +0100 Subject: s/CVS/DEV in the version string from the git repo --- tests/libtest/test1022.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index a3f318abb..60eee384c 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -23,7 +23,7 @@ open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what l $_ = ; chomp; if ( $what eq "version" ) { - /^libcurl ([\.\d]+(-CVS)?)$/ ; + /^libcurl ([\.\d]+(-DEV)?)$/ ; $curlconfigversion = $1; } else { @@ -31,8 +31,8 @@ else { /^(..)(..)(..)$/ ; $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); - # Strip off the -CVS from the curl version if it's there - $version =~ s/-CVS$//; + # Strip off the -DEV from the curl version if it's there + $version =~ s/-DEV$//; } close CURLCONFIG; -- cgit v1.2.1 From 05de2cf18094ddfb461b70bd5e6af4b6098c408c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 25 Mar 2010 23:22:03 +0100 Subject: remove all .cvsignore files --- tests/libtest/.cvsignore | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 tests/libtest/.cvsignore (limited to 'tests/libtest') diff --git a/tests/libtest/.cvsignore b/tests/libtest/.cvsignore deleted file mode 100644 index 50dcefd47..000000000 --- a/tests/libtest/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.libs -.deps -Makefile -Makefile.in -lib5[0-9][0-9] -- cgit v1.2.1 From 643ae2ca8b5ae66de22f8cadc54e8625e84a4dd2 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 30 Mar 2010 11:40:34 -0700 Subject: Allow test 538 to run even when proxy support is disabled --- tests/libtest/lib504.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 418da2f8c..b8091f66a 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -51,9 +51,10 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - /* the point here being that there must not run anything on the given + /* The point here is that there must not be anything running on the given proxy port */ - test_setopt(c, CURLOPT_PROXY, libtest_arg2); + if (libtest_arg2) + test_setopt(c, CURLOPT_PROXY, libtest_arg2); test_setopt(c, CURLOPT_URL, URL); test_setopt(c, CURLOPT_VERBOSE, 1L); -- cgit v1.2.1 From 8c6793d79a6604b10479630d1846fc9f56e1d525 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 30 Mar 2010 12:52:44 -0700 Subject: Call curl_global_cleanup() in test 560 to avoid a memory leak --- tests/libtest/lib560.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index ce6809d39..87e854555 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -99,6 +99,7 @@ test_cleanup: curl_multi_cleanup(multi_handle); curl_easy_cleanup(http_handle); + curl_global_cleanup(); return res; } -- cgit v1.2.1 From f38510f4b59edad8ae6e8f1535ea3ffcd31fa5d4 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 6 Apr 2010 22:51:05 -0700 Subject: Eliminated an unlikely race condition in some tests. Based on a patch from the FreeBSD ports by Peter Pentchev. --- tests/libtest/lib505.c | 31 +++++++++++++++---------------- tests/libtest/lib525.c | 20 ++++++++++++-------- tests/libtest/lib541.c | 31 +++++++++++++++---------------- 3 files changed, 42 insertions(+), 40 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 9dfae8405..5af7ac0bb 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -54,34 +54,33 @@ int test(char *URL) return -1; } + hd_src = fopen(libtest_arg2, "rb"); + if(NULL == hd_src) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: %s\n", libtest_arg2); + return -2; /* if this happens things are major weird */ + } + /* get the file size of the local file */ - hd = stat(libtest_arg2, &file_info); + hd = fstat(fileno(hd_src), &file_info); if(hd == -1) { /* can't open file, bail out */ error = ERRNO; - fprintf(stderr, "stat() failed with error: %d %s\n", + fprintf(stderr, "fstat() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); return -1; } if(! file_info.st_size) { - fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2); + fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2); + fclose(hd_src); return -4; } - /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just - an example! */ - hd_src = fopen(libtest_arg2, "rb"); - if(NULL == hd_src) { - error = ERRNO; - fprintf(stderr, "fopen() failed with error: %d %s\n", - error, strerror(error)); - fprintf(stderr, "Error opening file: %s\n", libtest_arg2); - return -2; /* if this happens things are major weird */ - } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index d2542577b..ade637012 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -40,14 +40,6 @@ int test(char *URL) return -1; } - /* get the file size of the local file */ - hd = open(libtest_arg2, O_RDONLY) ; - fstat(hd, &file_info); - close(hd) ; - - /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just - an example! */ hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; @@ -57,6 +49,18 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } + /* get the file size of the local file */ + hd = fstat(fileno(hd_src), &file_info); + if(hd == -1) { + /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "fstat() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); + return -1; + } + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index c060b8ac7..2fc85b97d 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -46,34 +46,33 @@ int test(char *URL) return -1; } + hd_src = fopen(libtest_arg2, "rb"); + if(NULL == hd_src) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: %s\n", libtest_arg2); + return -2; /* if this happens things are major weird */ + } + /* get the file size of the local file */ - hd = stat(libtest_arg2, &file_info); + hd = fstat(fileno(hd_src), &file_info); if(hd == -1) { /* can't open file, bail out */ error = ERRNO; - fprintf(stderr, "stat() failed with error: %d %s\n", + fprintf(stderr, "fstat() failed with error: %d %s\n", error, strerror(error)); - fprintf(stderr, "WARNING: cannot open file %s\n", libtest_arg2); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); return -1; } if(! file_info.st_size) { - fprintf(stderr, "WARNING: file %s has no size!\n", libtest_arg2); + fprintf(stderr, "ERROR: file %s has zero size!\n", libtest_arg2); + fclose(hd_src); return -4; } - /* get a FILE * of the same file, could also be made with - fdopen() from the previous descriptor, but hey this is just - an example! */ - hd_src = fopen(libtest_arg2, "rb"); - if(NULL == hd_src) { - error = ERRNO; - fprintf(stderr, "fopen() failed with error: %d %s\n", - error, strerror(error)); - fprintf(stderr, "Error opening file: %s\n", libtest_arg2); - return -2; /* if this happens things are major weird */ - } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); -- cgit v1.2.1 From d487ade72c5f31703ce097e8460e0225fad80348 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sat, 24 Apr 2010 12:14:21 +0200 Subject: test536: do not fail with threaded DNS resolver Also tweaked comments in certain examples using curl_multi_fdset(). --- tests/libtest/lib536.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 04bc6965d..e0c19f661 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -21,7 +21,7 @@ static CURLMcode perform(CURLM * multi) { - int handles, maxfd; + int handles; CURLMcode code; fd_set fdread, fdwrite, fdexcep; struct timeval mp_start; @@ -31,6 +31,9 @@ static CURLMcode perform(CURLM * multi) 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) { @@ -53,9 +56,14 @@ static CURLMcode perform(CURLM * multi) FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); - if (maxfd < 0) - return (CURLMcode) ~CURLM_OK; - if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1) + + /* 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. */ + + if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) return (CURLMcode) ~CURLM_OK; } -- cgit v1.2.1 From adaf87530dc561314a2261fa6d26c38ce999876f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 7 May 2010 23:49:29 +0200 Subject: multi interface: missed storing connection time Dirk Manske reported a regression. When connecting with the multi interface, there were situations where libcurl wouldn't store connect time correctly as it used to (and is documented to) do. Using his fine sample program we could repeat it, and I wrote up test case 573 using that code. The problem does not easily show itself using the local test suite though. The fix, also as suggested by Dirk, is a bit on the ugly side as it adds yet another call to Curl_verboseconnect() and setting the TIMER_CONNECT time. That situation is subject for some closer inspection in the future. --- tests/libtest/Makefile.inc | 3 +- tests/libtest/lib573.c | 102 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib573.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 4dc8615a7..58d5d9226 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -11,7 +11,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 lib572 + lib568 lib569 lib570 lib571 lib572 lib573 lib500_SOURCES = lib500.c $(SUPPORTFILES) @@ -145,3 +145,4 @@ lib571_SOURCES = lib571.c $(SUPPORTFILES) lib572_SOURCES = lib572.c $(SUPPORTFILES) +lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c new file mode 100644 index 000000000..e08b6df46 --- /dev/null +++ b/tests/libtest/lib573.c @@ -0,0 +1,102 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include "testutil.h" +#include "memdebug.h" + +#define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 +#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 + +/* + * Get a single URL without select(). + */ + +int test(char *URL) +{ + CURL *c; + CURLM *m = NULL; + int res = 0; + int running=1; + long connect_time = 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; + } + + if ((c = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + test_setopt(c, CURLOPT_HEADER, 1L); + test_setopt(c, CURLOPT_URL, URL); + + 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; + } + + 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; + } + + 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; + } + } + + 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; + } + + curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time); + if (connect_time==0) { + fprintf(stderr, "connect time is 0\n"); + res = TEST_ERR_MAJOR_BAD; + } + +test_cleanup: + + if(m) { + curl_multi_remove_handle(m, c); + curl_multi_cleanup(m); + } + curl_easy_cleanup(c); + curl_global_cleanup(); + + return res; +} + -- cgit v1.2.1 From 0825cd80a62c21725fb3615f1fdd3aa6cc5f0f34 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 12 May 2010 15:33:22 +0200 Subject: FTP: WILDCARDMATCH/CHUNKING/FNMATCH added --- tests/libtest/Makefile.inc | 9 ++ tests/libtest/lib574.c | 56 ++++++++++++ tests/libtest/lib575.c | 109 +++++++++++++++++++++++ tests/libtest/lib576.c | 107 ++++++++++++++++++++++ tests/libtest/lib577.c | 217 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 498 insertions(+) create mode 100644 tests/libtest/lib574.c create mode 100644 tests/libtest/lib575.c create mode 100644 tests/libtest/lib576.c create mode 100644 tests/libtest/lib577.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 58d5d9226..814c01e6c 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -8,6 +8,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ + lib574 lib575 lib576 lib577 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ @@ -124,6 +125,14 @@ lib559_CFLAGS = -DLIB559 lib560_SOURCES = lib560.c $(SUPPORTFILES) +lib574_SOURCES = lib574.c $(SUPPORTFILES) + +lib575_SOURCES = lib575.c $(SUPPORTFILES) + +lib576_SOURCES = lib576.c $(SUPPORTFILES) + +lib577_SOURCES = lib577.c $(SUPPORTFILES) + lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c new file mode 100644 index 000000000..69b2979a8 --- /dev/null +++ b/tests/libtest/lib574.c @@ -0,0 +1,56 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include "memdebug.h" + +static int new_fnmatch(const char *pattern, const char *string) +{ + (void)pattern; + (void)string; + return CURL_FNMATCHFUNC_MATCH; +} + +int test(char *URL) +{ + int res; + CURL *curl; + + 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; + } + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); + test_setopt(curl, CURLOPT_FNMATCH_FUNCTION, new_fnmatch); + + res = curl_easy_perform(curl); + if(res) { + fprintf(stderr, "curl_easy_perform() failed %d\n", res); + goto test_cleanup; + } + res = curl_easy_perform(curl); + if(res) { + fprintf(stderr, "curl_easy_perform() failed %d\n", res); + goto test_cleanup; + } + +test_cleanup: + curl_easy_cleanup(curl); + curl_global_cleanup(); + return res; +} diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c new file mode 100644 index 000000000..3bf15ea26 --- /dev/null +++ b/tests/libtest/lib575.c @@ -0,0 +1,109 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include +#include +#include + +#include "testutil.h" +#include "memdebug.h" + +/* 3x download! + * 1. normal + * 2. dup handle + * 3. with multi interface + */ + +int test(char *URL) +{ + CURLMcode m; + CURL *handle = NULL, *duphandle; + 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; + } + + handle = curl_easy_init(); + if(!handle) { + res = CURLE_OUT_OF_MEMORY; + goto test_cleanup; + } + + test_setopt(handle, CURLOPT_URL, URL); + test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L); + test_setopt(handle, CURLOPT_VERBOSE, 1L); + + res = curl_easy_perform(handle); + if(res) + goto test_cleanup; + + res = curl_easy_perform(handle); + if(res) + goto test_cleanup; + + duphandle = curl_easy_duphandle(handle); + if(!duphandle) + goto test_cleanup; + curl_easy_cleanup(handle); + handle = duphandle; + + mhandle = curl_multi_init(); + if(!mhandle) { + fprintf(stderr, "curl_multi_init() failed\n"); + goto test_cleanup; + } + + curl_multi_add_handle(mhandle, handle); + + while(CURLM_CALL_MULTI_PERFORM == + curl_multi_perform(mhandle, &still_running)); + + while(still_running) { + struct timeval timeout; + int rc; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int max_fdset = -1; + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + timeout.tv_sec = 3; + timeout.tv_usec = 0; + + m = curl_multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &max_fdset); + rc = select(max_fdset + 1, &fdread, &fdwrite, &fdexcep, &timeout); + if(rc == -1) { + fprintf(stderr, "select() error\n"); + goto test_cleanup; + } + else if(rc == 0) { + fprintf(stderr, "select() timeout!\n"); + goto test_cleanup; + } + else { + while(CURLM_CALL_MULTI_PERFORM == + curl_multi_perform(mhandle, &still_running)); + } + } + +test_cleanup: + if(mhandle) + curl_multi_cleanup(mhandle); + if(handle) + curl_easy_cleanup(handle); + curl_global_cleanup(); + return res; +} diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c new file mode 100644 index 000000000..7f2c7ae37 --- /dev/null +++ b/tests/libtest/lib576.c @@ -0,0 +1,107 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" +#include "testutil.h" +#include "memdebug.h" + +typedef struct { + int remains; + int print_content; +} chunk_data_t; + +long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains); +long chunk_end(void *ptr); + +long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) +{ + chunk_data_t *ch_d = ptr; + ch_d->remains = remains; + + printf("=============================================================\n"); + printf("Remains: %d\n", remains); + printf("Filename: %s\n", finfo->filename); + if(finfo->strings.perm) { + printf("Permissions: %s", finfo->strings.perm); + if(finfo->flags & CURLFINFOFLAG_KNOWN_PERM) + printf(" (parsed => %o)", finfo->perm); + printf("\n"); + } + printf("Size: %lldB\n", (long long int)finfo->size); + if(finfo->strings.user) + printf("User: %s\n", finfo->strings.user); + if(finfo->strings.group) + printf("Group: %s\n", finfo->strings.group); + if(finfo->strings.time) + printf("Time: %s\n", finfo->strings.time); + printf("Filetype: "); + switch(finfo->filetype) { + case CURLFILETYPE_FILE: + printf("regular file\n"); + break; + case CURLFILETYPE_DIRECTORY: + printf("directory\n"); + break; + case CURLFILETYPE_SYMLINK: + printf("symlink\n"); + printf("Target: %s\n", finfo->strings.target); + break; + default: + printf("other type\n"); + break; + } + if(finfo->filetype == CURLFILETYPE_FILE) { + ch_d->print_content = 1; + printf("Content:\n-------------------------------------------------------------\n"); + } + if(strcmp(finfo->filename, "someothertext.txt") == 0) { + printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n"); + return CURL_CHUNK_BGN_FUNC_SKIP; + } + return CURL_CHUNK_BGN_FUNC_OK; +} + +long chunk_end(void *ptr) +{ + chunk_data_t *ch_d = ptr; + if(ch_d->print_content) { + ch_d->print_content = 0; + printf("-------------------------------------------------------------\n"); + } + if(ch_d->remains == 1) + printf("=============================================================\n"); + return CURL_CHUNK_END_FUNC_OK; +} + +int test(char *URL) +{ + CURL *handle = NULL; + CURLcode res = 0; + chunk_data_t chunk_data = {0,0}; + curl_global_init(CURL_GLOBAL_ALL); + handle = curl_easy_init(); + if(!handle) { + res = CURLE_OUT_OF_MEMORY; + goto test_cleanup; + } + + test_setopt(handle, CURLOPT_URL, URL); + test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L); + test_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, chunk_bgn); + test_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, chunk_end); + test_setopt(handle, CURLOPT_CHUNK_DATA, &chunk_data); + + res = curl_easy_perform(handle); + +test_cleanup: + if(handle) + curl_easy_cleanup(handle); + curl_global_cleanup(); + return res; +} diff --git a/tests/libtest/lib577.c b/tests/libtest/lib577.c new file mode 100644 index 000000000..8b434f8fb --- /dev/null +++ b/tests/libtest/lib577.c @@ -0,0 +1,217 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include "memdebug.h" + +#include "curl_fnmatch.h" + +#define MATCH CURL_FNMATCH_MATCH +#define NOMATCH CURL_FNMATCH_NOMATCH +#define ERROR CURL_FNMATCH_FAIL + +#define MAX_PATTERN_L 100 +#define MAX_STRING_L 100 + +struct testcase { + char pattern[MAX_PATTERN_L]; + char string[MAX_STRING_L]; + int result; +}; + +static const struct testcase tests[] = { + /* brackets syntax */ + { "\\[", "[", MATCH }, + { "[", "[", ERROR }, + { "[]", "[]", ERROR }, + { "[][]", "[", MATCH }, + { "[][]", "]", MATCH }, + { "[[]", "[", MATCH }, + { "[[[]", "[", MATCH }, + { "[[[[]", "[", MATCH }, + { "[[[[]", "[", MATCH }, + + { "[][[]", "]", MATCH }, + { "[][[[]", "[", MATCH }, + { "[[]", "]", NOMATCH }, + + { "[a-z]", "a", MATCH }, + { "[a-z]", "A", NOMATCH }, + { "?[a-z]", "?Z", NOMATCH }, + { "[A-Z]", "C", MATCH }, + { "[A-Z]", "c", NOMATCH }, + { "[0-9]", "7", MATCH }, + { "[7-8]", "7", MATCH }, + { "[7-]", "7", MATCH }, + { "[7-]", "-", MATCH }, + { "[7-]", "[", NOMATCH }, + { "[a-bA-F]", "F", MATCH }, + { "[a-bA-B9]", "9", MATCH }, + { "[a-bA-B98]", "8", MATCH }, + { "[a-bA-B98]", "C", NOMATCH }, + { "[a-bA-Z9]", "F", MATCH }, + { "[a-bA-Z9]ero*", "Zero chance.", MATCH }, + { "S[a-][x]opho*", "Saxophone", MATCH }, + { "S[a-][x]opho*", "SaXophone", NOMATCH }, + { "S[a-][x]*.txt", "S-x.txt", MATCH }, + { "[\\a-\\b]", "a", MATCH }, + { "[\\a-\\b]", "b", MATCH }, + { "[?*[][?*[][?*[]", "?*[", MATCH }, + { "[][?*-]", "]", MATCH }, + { "[][?*-]", "[", MATCH }, + { "[][?*-]", "?", MATCH }, + { "[][?*-]", "*", MATCH }, + { "[][?*-]", "-", MATCH }, + { "[]?*-]", "-", MATCH }, + { "?/b/c", "a/b/c", MATCH }, + { "^_{}~", "^_{}~", MATCH }, + { "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH }, + { "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH }, + { ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH }, + + /* negate */ + { "[!a]", "b", MATCH }, + { "[!a]", "a", NOMATCH }, + { "[^a]", "b", MATCH }, + { "[^a]", "a", NOMATCH }, + { "[^a-z0-9A-Z]", "a", NOMATCH }, + { "[^a-z0-9A-Z]", "-", MATCH }, + { "curl[!a-z]lib", "curl lib", MATCH }, + { "curl[! ]lib", "curl lib", NOMATCH }, + { "[! ][ ]", " ", NOMATCH }, + { "[! ][ ]", "a ", MATCH }, + { "*[^a].t?t", "a.txt", NOMATCH }, + { "*[^a].t?t", "ba.txt", NOMATCH }, + { "*[^a].t?t", "ab.txt", MATCH }, + { "[!?*[]", "?", NOMATCH }, + { "[!!]", "!", NOMATCH }, + { "[!!]", "x", MATCH }, + + { "[[:alpha:]]", "a", MATCH }, + { "[[:alpha:]]", "9", NOMATCH }, + { "[[:alnum:]]", "a", MATCH }, + { "[[:alnum:]]", "[", NOMATCH }, + { "[[:alnum:]]", "]", NOMATCH }, + { "[[:alnum:]]", "9", MATCH }, + { "[[:digit:]]", "9", MATCH }, + { "[[:xdigit:]]", "9", MATCH }, + { "[[:xdigit:]]", "F", MATCH }, + { "[[:xdigit:]]", "G", NOMATCH }, + { "[[:upper:]]", "U", MATCH }, + { "[[:upper:]]", "u", NOMATCH }, + { "[[:lower:]]", "l", MATCH }, + { "[[:lower:]]", "L", NOMATCH }, + { "[[:print:]]", "L", MATCH }, + { "[[:print:]]", {'\10'}, NOMATCH }, + { "[[:print:]]", {'\10'}, NOMATCH }, + { "[[:space:]]", " ", MATCH }, + { "[[:space:]]", "x", NOMATCH }, + { "[[:graph:]]", " ", NOMATCH }, + { "[[:graph:]]", "x", MATCH }, + { "[[:blank:]]", {'\t'}, MATCH }, + { "[[:blank:]]", {' '}, MATCH }, + { "[[:blank:]]", {'\r'}, NOMATCH }, + { "[^[:blank:]]", {'\t'}, NOMATCH }, + { "[^[:print:]]", {'\10'}, MATCH }, + { "[[:lower:]][[:lower:]]", "ll", MATCH }, + + { "Curl[[:blank:]];-)", "Curl ;-)", MATCH }, + { "*[[:blank:]]*", " ", MATCH }, + { "*[[:blank:]]*", "", NOMATCH }, + { "*[[:blank:]]*", "hi, im_Pavel", MATCH }, + + /* common using */ + { "filename.dat", "filename.dat", MATCH }, + { "*curl*", "lets use curl!!", MATCH }, + { "filename.txt", "filename.dat", NOMATCH }, + { "*.txt", "text.txt", MATCH }, + { "*.txt", "a.txt", MATCH }, + { "*.txt", ".txt", MATCH }, + { "*.txt", "txt", NOMATCH }, + { "??.txt", "99.txt", MATCH }, + { "??.txt", "a99.txt", NOMATCH }, + { "?.???", "a.txt", MATCH }, + { "*.???", "somefile.dat", MATCH }, + { "*.???", "photo.jpeg", NOMATCH }, + { ".*", ".htaccess", MATCH }, + { ".*", ".", MATCH }, + { ".*", "..", MATCH }, + + /* many stars => one star */ + { "**.txt", "text.txt", MATCH }, + { "***.txt", "t.txt", MATCH }, + { "****.txt", ".txt", MATCH }, + + /* empty string or pattern */ + { "", "", MATCH } , + { "", "hello", NOMATCH }, + { "file", "", NOMATCH }, + { "?", "", NOMATCH }, + { "*", "", MATCH }, + { "x", "", NOMATCH }, + + /* backslash */ + { "\\", "\\", ERROR }, + { "\\\\", "\\", MATCH }, + { "\\\\", "\\\\", NOMATCH }, + { "\\?", "?", MATCH }, + { "\\*", "*", MATCH }, + { "?.txt", "?.txt", MATCH }, + { "*.txt", "*.txt", MATCH }, + { "\\?.txt", "?.txt", MATCH }, + { "\\*.txt", "*.txt", MATCH }, + { "\\?.txt", "x.txt", NOMATCH }, + { "\\*.txt", "x.txt", NOMATCH }, + { "\\*\\\\.txt", "*\\.txt", MATCH }, + { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, + { "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH }, + { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, + { "*\\?*\\**", "cc?c*c", MATCH }, + { "*\\?*\\**curl*", "cc?c*curl", MATCH }, + { "*\\?*\\**", "cc?cc", NOMATCH }, + { "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH }, + { "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH }, + { "[\\a\\b]c", "ac", MATCH }, + { "[\\a\\b]c", "bc", MATCH }, + { "[\\a\\b]d", "bc", NOMATCH }, + { "[a-bA-B\\?]", "?", MATCH }, + { "cu[a-ab-b\\r]l", "curl", MATCH }, + { "[\\a-z]", "c", MATCH }, + + { "?*?*?.*?*", "abc.c", MATCH }, + { "?*?*?.*?*", "abcc", NOMATCH }, + { "?*?*?.*?*", "abc.", NOMATCH }, + { "?*?*?.*?*", "abc.c++", MATCH }, + { "?*?*?.*?*", "abcdef.c++", MATCH }, + { "?*?*?.?", "abcdef.c", MATCH }, + { "?*?*?.?", "abcdef.cd", NOMATCH }, + + { "Lindmätarv", "Lindmätarv", MATCH }, + + { "", "", MATCH } +}; + + +int test(char *URL) +{ + int testnum = sizeof(tests) / sizeof(struct testcase); + int i, rc; + (void)URL; /* not used */ + printf("===========================\n"); + for(i = 0; i < testnum; i++) { + rc = Curl_fnmatch(tests[i].pattern, tests[i].string); + if(rc != tests[i].result) { + printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n", + tests[i].pattern, tests[i].string, tests[i].result, rc); + } + } + printf("===========================\n"); + return 0; +} -- cgit v1.2.1 From 43b816538fbbac07ca7ccc2dc647c972c3ee072a Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 14 May 2010 14:42:58 -0700 Subject: Fixed test 577 to work when --enable-hidden-symbols is configured --- tests/libtest/lib577.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib577.c b/tests/libtest/lib577.c index 8b434f8fb..ac995c3fc 100644 --- a/tests/libtest/lib577.c +++ b/tests/libtest/lib577.c @@ -9,6 +9,25 @@ #include "test.h" +/* + * This hacky test bypasses the library external API, + * using internal only libcurl functions. So don't be + * surprised if we cannot run it when the library has + * been built with hidden symbols, exporting only the + * ones in the public API. + */ + +#if defined(CURL_HIDDEN_SYMBOLS) +# define SKIP_TEST 1 +#elif defined(WIN32) && !defined(CURL_STATICLIB) +# define SKIP_TEST 1 +#else +# undef SKIP_TEST +#endif + + +#if !defined(SKIP_TEST) + #include "memdebug.h" #include "curl_fnmatch.h" @@ -204,6 +223,12 @@ int test(char *URL) int testnum = sizeof(tests) / sizeof(struct testcase); int i, rc; (void)URL; /* not used */ + + if(!strcmp(URL, "check")) { + /* test harness script verifying if this test can run */ + return 0; /* sure, run this! */ + } + printf("===========================\n"); for(i = 0; i < testnum; i++) { rc = Curl_fnmatch(tests[i].pattern, tests[i].string); @@ -215,3 +240,16 @@ int test(char *URL) printf("===========================\n"); return 0; } + +#else /* !defined(SKIP_TEST) */ + + +int test(char *URL) +{ + (void)URL; + fprintf(stdout, "libcurl built with hidden symbols"); + return 1; /* skip test */ +} + + +#endif /* !defined(SKIP_TEST) */ -- cgit v1.2.1 From 2ffe834bffa893efcd8942736ab14e311a0087b3 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sun, 16 May 2010 02:49:08 +0200 Subject: ftp wildcard: a new option CURLOPT_FNMATCH_DATA --- tests/libtest/lib577.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib577.c b/tests/libtest/lib577.c index ac995c3fc..fdab361e2 100644 --- a/tests/libtest/lib577.c +++ b/tests/libtest/lib577.c @@ -231,7 +231,7 @@ int test(char *URL) printf("===========================\n"); for(i = 0; i < testnum; i++) { - rc = Curl_fnmatch(tests[i].pattern, tests[i].string); + rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string); if(rc != tests[i].result) { printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n", tests[i].pattern, tests[i].string, tests[i].result, rc); -- cgit v1.2.1 From 22f3b01478246687386bfcaa97e07272c8868bf3 Mon Sep 17 00:00:00 2001 From: Tor Arntsen Date: Thu, 20 May 2010 16:33:29 +0200 Subject: Test 573: Use correct type for CURLINFO_CONNECT_TIME curl_easy_getinfo() called with a pointer to long instead of double would sigbus on RISC processors (e.g. MIPS) due to wrong alignment of pointer address. --- tests/libtest/lib573.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index e08b6df46..db5889e34 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -25,7 +25,7 @@ int test(char *URL) CURLM *m = NULL; int res = 0; int running=1; - long connect_time = 0; + double connect_time = 0.0; struct timeval mp_start; char mp_timedout = FALSE; @@ -83,8 +83,8 @@ int test(char *URL) } curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time); - if (connect_time==0) { - fprintf(stderr, "connect time is 0\n"); + if (connect_time==0.0) { + fprintf(stderr, "connect time is 0.0\n"); res = TEST_ERR_MAJOR_BAD; } -- cgit v1.2.1 From eadeb5bd9a6657c77477f58f3c0caa2de116d80e Mon Sep 17 00:00:00 2001 From: Tor Arntsen Date: Thu, 27 May 2010 20:20:08 +0200 Subject: lib573: do not compare double for exact match --- tests/libtest/lib573.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index db5889e34..5edb1814a 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -83,8 +83,8 @@ int test(char *URL) } curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time); - if (connect_time==0.0) { - fprintf(stderr, "connect time is 0.0\n"); + if (connect_time <= 0.0) { + fprintf(stderr, "connect time is <=0.0\n"); res = TEST_ERR_MAJOR_BAD; } -- cgit v1.2.1 From 75743b009b5fb15dc018b571effb43b81c84e248 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 28 May 2010 00:50:11 +0200 Subject: lib577: avoid redefinition of ERROR --- tests/libtest/lib577.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib577.c b/tests/libtest/lib577.c index fdab361e2..bd52c6251 100644 --- a/tests/libtest/lib577.c +++ b/tests/libtest/lib577.c @@ -34,7 +34,7 @@ #define MATCH CURL_FNMATCH_MATCH #define NOMATCH CURL_FNMATCH_NOMATCH -#define ERROR CURL_FNMATCH_FAIL +#define RE_ERR CURL_FNMATCH_FAIL #define MAX_PATTERN_L 100 #define MAX_STRING_L 100 @@ -48,8 +48,8 @@ struct testcase { static const struct testcase tests[] = { /* brackets syntax */ { "\\[", "[", MATCH }, - { "[", "[", ERROR }, - { "[]", "[]", ERROR }, + { "[", "[", RE_ERR }, + { "[]", "[]", RE_ERR }, { "[][]", "[", MATCH }, { "[][]", "]", MATCH }, { "[[]", "[", MATCH }, @@ -177,7 +177,7 @@ static const struct testcase tests[] = { { "x", "", NOMATCH }, /* backslash */ - { "\\", "\\", ERROR }, + { "\\", "\\", RE_ERR }, { "\\\\", "\\", MATCH }, { "\\\\", "\\\\", NOMATCH }, { "\\?", "?", MATCH }, -- cgit v1.2.1 From 35955179c6c3935e9b876090e29bb90c5740838f Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sat, 29 May 2010 12:26:17 +0200 Subject: CURL_LLONG_MAX: avoid constant overflow ... when (CURL_SIZEOF_CURL_OFF_T == 4) --- tests/libtest/lib576.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 7f2c7ae37..10857f6b7 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -33,7 +33,7 @@ long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) printf(" (parsed => %o)", finfo->perm); printf("\n"); } - printf("Size: %lldB\n", (long long int)finfo->size); + printf("Size: %ldB\n", (long)finfo->size); if(finfo->strings.user) printf("User: %s\n", finfo->strings.user); if(finfo->strings.group) -- cgit v1.2.1 From a324fa7b97657bbd52d7358dd800472f3beb10e1 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 31 May 2010 16:51:36 +0200 Subject: fix compiler warning: variable was set but never used --- tests/libtest/lib575.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index 3bf15ea26..49a379e80 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -84,6 +84,10 @@ int test(char *URL) timeout.tv_usec = 0; m = curl_multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &max_fdset); + if(m != CURLM_OK) { + fprintf(stderr, "curl_multi_fdset() error\n"); + goto test_cleanup; + } rc = select(max_fdset + 1, &fdread, &fdwrite, &fdexcep, &timeout); if(rc == -1) { fprintf(stderr, "select() error\n"); -- cgit v1.2.1 From 12043e3c9c39335982764557cba4684bb5ffa5d3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 31 May 2010 16:58:24 +0200 Subject: fix compiler warning: external declaration in primary source file --- tests/libtest/lib576.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 10857f6b7..821eb61ac 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -16,9 +16,12 @@ typedef struct { int print_content; } chunk_data_t; +static long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains); +static long chunk_end(void *ptr); +static long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) { chunk_data_t *ch_d = ptr; @@ -67,6 +70,7 @@ long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) return CURL_CHUNK_BGN_FUNC_OK; } +static long chunk_end(void *ptr) { chunk_data_t *ch_d = ptr; @@ -82,7 +86,7 @@ long chunk_end(void *ptr) int test(char *URL) { CURL *handle = NULL; - CURLcode res = 0; + CURLcode res = CURLE_OK; chunk_data_t chunk_data = {0,0}; curl_global_init(CURL_GLOBAL_ALL); handle = curl_easy_init(); -- cgit v1.2.1 From d63bdba0977a3d680138a89d46015d1ef690f5cd Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Thu, 17 Jun 2010 17:07:15 +0200 Subject: test575: do not fail with threaded DNS resolver --- tests/libtest/lib575.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index 49a379e80..521720e95 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -71,7 +71,7 @@ int test(char *URL) curl_multi_perform(mhandle, &still_running)); while(still_running) { - struct timeval timeout; + static struct timeval timeout = /* 100 ms */ { 0, 100000L }; int rc; fd_set fdread; fd_set fdwrite; @@ -80,23 +80,19 @@ int test(char *URL) FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); - timeout.tv_sec = 3; - timeout.tv_usec = 0; 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 if(rc == 0) { - fprintf(stderr, "select() timeout!\n"); - goto test_cleanup; - } else { while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(mhandle, &still_running)); -- cgit v1.2.1 From b5c3feda1788301bea7f1dd4f9bb240d13862bd0 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 30 Jul 2010 00:47:49 +0200 Subject: NTLM tests: boost coverage by forcing the hostname A shared library tests/libtest/.libs/lihostname.so is preloaded in NTLM test-cases to override the system implementation of gethostname(). It makes it possible to test the NTLM authentication for exact match, and this way test the implementation of MD4 and DES. If LD_PRELOAD doesn't work, a debug build willl also workk as debug builds are now made to prefer a specific environment variable and will then return that content as host name instead of the actual one. Kamil wrote the bulk of this, Daniel Stenberg polished it. --- tests/libtest/.gitignore | 2 +- tests/libtest/Makefile.am | 10 ++++++++++ tests/libtest/Makefile.inc | 4 +++- tests/libtest/chkhostname.c | 26 ++++++++++++++++++++++++++ tests/libtest/hostname.c | 32 ++++++++++++++++++++++++++++++++ tests/libtest/sethostname.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/chkhostname.c create mode 100644 tests/libtest/hostname.c create mode 100644 tests/libtest/sethostname.c (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 3311a821e..cabcb671c 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,2 +1,2 @@ +chkhostname lib5[0-9][0-9] - diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 70b0f12a4..2a0e3eaa4 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,6 +53,16 @@ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc +if STATICLIB +# this means no shared option is enabled so we can disable the LD_PRELOAD +# attempt +libhostname_la_CFLAGS = -DDISABLE_PRELOAD +endif + +# we force our own host name, in order to make some tests machine independent +lib_LTLIBRARIES = libhostname.la +libhostname_la_SOURCES = sethostname.c + # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la DEPENDENCIES = $(top_builddir)/lib/libcurl.la diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 814c01e6c..28ed6831c 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -12,7 +12,9 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 lib572 lib573 + lib568 lib569 lib570 lib571 lib572 lib573 chkhostname + +chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c lib500_SOURCES = lib500.c $(SUPPORTFILES) diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c new file mode 100644 index 000000000..686eb471a --- /dev/null +++ b/tests/libtest/chkhostname.c @@ -0,0 +1,26 @@ +#include "curl_gethostname.h" + +#include + +#define HOSTNAME_MAX 1024 + +int main(int argc, char *argv[]) +{ + char buff[HOSTNAME_MAX]; + if (argc != 2) { + printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]); + return 1; + } + + if (Curl_gethostname(buff, HOSTNAME_MAX)) { + printf("Curl_gethostname() failed\n"); + return 1; + } + + /* compare the name returned by Curl_gethostname() with the expected one */ + if(strncmp(buff, argv[1], HOSTNAME_MAX)) { + printf("got unexpected host name back, LD_PRELOAD failed\n"); + return 1; + } + return 0; +} diff --git a/tests/libtest/hostname.c b/tests/libtest/hostname.c new file mode 100644 index 000000000..ca7fccaf8 --- /dev/null +++ b/tests/libtest/hostname.c @@ -0,0 +1,32 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include +#include + +#define HOSTNAME "curlhost" +#define HOSTNAME_LEN sizeof(HOSTNAME) + +/* + * we force our own host name, in order to make some tests machine independent + */ +int gethostname(char *name, size_t namelen) { + char buff[HOSTNAME_LEN + /* terminating zero */ 1]; + size_t max = (namelen < HOSTNAME_LEN) + ? namelen + : HOSTNAME_LEN; + + if(!name || !namelen) + return -1; + + strcpy(buff, HOSTNAME); + buff[max - 1] = '\0'; + strcpy(name, buff); + return 0; +}; diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c new file mode 100644 index 000000000..667f689ae --- /dev/null +++ b/tests/libtest/sethostname.c @@ -0,0 +1,28 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include +#include +#include + +#define GETHOSTNAME_ENV_VAR "CURL_GETHOSTNAME" + +/* + * we force our own host name, in order to make some tests machine independent + */ +int gethostname(char *name, size_t namelen) { + const char *force_hostname = getenv(GETHOSTNAME_ENV_VAR); + if(force_hostname) { + strncpy(name, force_hostname, namelen); + return 0; + } + + /* LD_PRELOAD used, but no hostname set, we'll just return a failure */ + return -1; +}; -- cgit v1.2.1 From 04eff9beb9b116f7b6c17743de35e4f5504aa0ef Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 30 Jul 2010 22:26:19 +0200 Subject: sethostname: ISO C does not allow extra `;' outside of a function --- tests/libtest/sethostname.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index 667f689ae..4facfc66c 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -25,4 +25,4 @@ int gethostname(char *name, size_t namelen) { /* LD_PRELOAD used, but no hostname set, we'll just return a failure */ return -1; -}; +} -- cgit v1.2.1 From d296dd4ee87426bc6982255d7a966fd8c4b7e989 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 30 Jul 2010 22:32:57 +0200 Subject: sethostname: avoid including unistd.h to duck for warnings --- tests/libtest/sethostname.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index 4facfc66c..33fa90da6 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -9,14 +9,18 @@ #include #include -#include #define GETHOSTNAME_ENV_VAR "CURL_GETHOSTNAME" /* * we force our own host name, in order to make some tests machine independent + * + * Since some systems think this prototype doesn't match the system provided + * function, we AVOID including unistd.h or other headers that may include the + * original prototype! */ -int gethostname(char *name, size_t namelen) { +int gethostname(char *name, size_t namelen) +{ const char *force_hostname = getenv(GETHOSTNAME_ENV_VAR); if(force_hostname) { strncpy(name, force_hostname, namelen); -- cgit v1.2.1 From 687df5c8c39c370a59999b9afc0917d808d978b7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 2 Aug 2010 22:51:24 +0200 Subject: sethostname: provide local prototype for gethostname This is only to avoid warnings on some systems. --- tests/libtest/sethostname.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index 33fa90da6..d050f18d6 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -17,8 +17,10 @@ * * Since some systems think this prototype doesn't match the system provided * function, we AVOID including unistd.h or other headers that may include the - * original prototype! + * original prototype! We provide our own instead (to avoid warnings). */ +int gethostname(char *name, size_t namelen); + int gethostname(char *name, size_t namelen) { const char *force_hostname = getenv(GETHOSTNAME_ENV_VAR); -- cgit v1.2.1 From 1cbe66fbc8e7d6c174c1919a905b768b9c48e1f8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Aug 2010 18:54:45 +0200 Subject: build: remove unused file --- tests/libtest/hostname.c | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 tests/libtest/hostname.c (limited to 'tests/libtest') diff --git a/tests/libtest/hostname.c b/tests/libtest/hostname.c deleted file mode 100644 index ca7fccaf8..000000000 --- a/tests/libtest/hostname.c +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - */ - -#include -#include - -#define HOSTNAME "curlhost" -#define HOSTNAME_LEN sizeof(HOSTNAME) - -/* - * we force our own host name, in order to make some tests machine independent - */ -int gethostname(char *name, size_t namelen) { - char buff[HOSTNAME_LEN + /* terminating zero */ 1]; - size_t max = (namelen < HOSTNAME_LEN) - ? namelen - : HOSTNAME_LEN; - - if(!name || !namelen) - return -1; - - strcpy(buff, HOSTNAME); - buff[max - 1] = '\0'; - strcpy(name, buff); - return 0; -}; -- cgit v1.2.1 From 59bad26bb27ba82c78f5e40ea19209fe2bb9cb3e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 6 Aug 2010 18:40:13 +0200 Subject: build: ensure that libhostname doesn't get installed --- tests/libtest/Makefile.am | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 2a0e3eaa4..e6a580054 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,19 +53,27 @@ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc -if STATICLIB -# this means no shared option is enabled so we can disable the LD_PRELOAD -# attempt -libhostname_la_CFLAGS = -DDISABLE_PRELOAD -endif - -# we force our own host name, in order to make some tests machine independent -lib_LTLIBRARIES = libhostname.la -libhostname_la_SOURCES = sethostname.c - # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la DEPENDENCIES = $(top_builddir)/lib/libcurl.la -# Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) +# Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, +# noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) include Makefile.inc + +# Preloading of libhostname allows host name overriding, +# this is used to make some tests machine independent. + +noinst_LTLIBRARIES = libhostname.la + +if NO_UNDEFINED +# The -no-undefined flag is crucial to build fine on some platforms +UNDEF = -no-undefined +endif + +libhostname_la_SOURCES = sethostname.c + +libhostname_la_LIBADD = +libhostname_la_DEPENDENCIES = +libhostname_la_LDFLAGS = -module -avoid-version $(UNDEF) -rpath /nowhere + -- cgit v1.2.1 From 7d342c723c5ae8e9312210936287810741f40bc5 Mon Sep 17 00:00:00 2001 From: "U-D5B1PQ1J\\Administrador" Date: Sat, 7 Aug 2010 14:33:14 +0200 Subject: build: allow NTLM tests to run on more build configurations --- tests/libtest/chkhostname.c | 4 ++-- tests/libtest/sethostname.c | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c index 686eb471a..72c8b6a1f 100644 --- a/tests/libtest/chkhostname.c +++ b/tests/libtest/chkhostname.c @@ -1,6 +1,6 @@ -#include "curl_gethostname.h" +#include "setup.h" -#include +#include "curl_gethostname.h" #define HOSTNAME_MAX 1024 diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index d050f18d6..9d9fae00b 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -7,25 +7,20 @@ * */ -#include -#include - -#define GETHOSTNAME_ENV_VAR "CURL_GETHOSTNAME" +#include "setup.h" /* * we force our own host name, in order to make some tests machine independent - * - * Since some systems think this prototype doesn't match the system provided - * function, we AVOID including unistd.h or other headers that may include the - * original prototype! We provide our own instead (to avoid warnings). */ -int gethostname(char *name, size_t namelen); -int gethostname(char *name, size_t namelen) +int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen); + +int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen) { - const char *force_hostname = getenv(GETHOSTNAME_ENV_VAR); + const char *force_hostname = getenv("CURL_GETHOSTNAME"); if(force_hostname) { strncpy(name, force_hostname, namelen); + name[namelen-1] = '\0'; return 0; } -- cgit v1.2.1 From af4eae77acd6d5d353c583b2616903b7c865daea Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 7 Aug 2010 17:39:36 +0200 Subject: build: chkhostname build adjustments followup --- tests/libtest/Makefile.inc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 28ed6831c..f5a5ddeb4 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -15,6 +15,9 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib568 lib569 lib570 lib571 lib572 lib573 chkhostname chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c +chkhostname_LDADD = +chkhostname_DEPENDENCIES = +chkhostname_CFLAGS = $(AM_CFLAGS) lib500_SOURCES = lib500.c $(SUPPORTFILES) -- cgit v1.2.1 From c49e9683b85ba9d12cbb6eebc4ab2c8dba68fbdc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 8 Aug 2010 02:58:19 +0200 Subject: build: libhostname linkage adjustments followup --- tests/libtest/Makefile.am | 2 +- tests/libtest/sethostname.c | 4 ++-- tests/libtest/sethostname.h | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/libtest/sethostname.h (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e6a580054..0603c03e1 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -71,7 +71,7 @@ if NO_UNDEFINED UNDEF = -no-undefined endif -libhostname_la_SOURCES = sethostname.c +libhostname_la_SOURCES = sethostname.c sethostname.h libhostname_la_LIBADD = libhostname_la_DEPENDENCIES = diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index 9d9fae00b..3dabb8231 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -9,12 +9,12 @@ #include "setup.h" +#include "sethostname.h" + /* * we force our own host name, in order to make some tests machine independent */ -int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen); - int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen) { const char *force_hostname = getenv("CURL_GETHOSTNAME"); diff --git a/tests/libtest/sethostname.h b/tests/libtest/sethostname.h new file mode 100644 index 000000000..458a8f0cf --- /dev/null +++ b/tests/libtest/sethostname.h @@ -0,0 +1,25 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#if (defined(WIN32) || defined(__SYMBIAN32__)) && !defined(CURL_STATICLIB) +# if defined(BUILDING_LIBCURL) +# define LIBHOSTNAME_EXTERN __declspec(dllexport) +# else +# define LIBHOSTNAME_EXTERN __declspec(dllimport) +# endif +#else +# ifdef CURL_HIDDEN_SYMBOLS +# define LIBHOSTNAME_EXTERN CURL_EXTERN_SYMBOL +# else +# define LIBHOSTNAME_EXTERN +# endif +#endif + +LIBHOSTNAME_EXTERN int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen); + -- cgit v1.2.1 From 50a1d5ee1c127d76ea3316f86d53accb66bc0b22 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 9 Aug 2010 05:45:11 +0200 Subject: build: libhostname and chkhostname linkage adjustments followup --- tests/libtest/Makefile.inc | 2 +- tests/libtest/sethostname.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index f5a5ddeb4..ce230c12a 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -15,7 +15,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib568 lib569 lib570 lib571 lib572 lib573 chkhostname chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c -chkhostname_LDADD = +chkhostname_LDADD = @CURL_NETWORK_LIBS@ chkhostname_DEPENDENCIES = chkhostname_CFLAGS = $(AM_CFLAGS) diff --git a/tests/libtest/sethostname.h b/tests/libtest/sethostname.h index 458a8f0cf..83034a536 100644 --- a/tests/libtest/sethostname.h +++ b/tests/libtest/sethostname.h @@ -21,5 +21,12 @@ # endif #endif -LIBHOSTNAME_EXTERN int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen); +#ifdef USE_WINSOCK +# define FUNCALLCONV __stdcall +#else +# define FUNCALLCONV +#endif + +LIBHOSTNAME_EXTERN int FUNCALLCONV + gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen); -- cgit v1.2.1 From b24e87250241c97c23f7c71c0ab9de74e793b8cc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 9 Aug 2010 09:33:53 +0200 Subject: build: don't build libhostname unless shared libcurl is built --- tests/libtest/Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 0603c03e1..2ba7b0a32 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -64,7 +64,11 @@ include Makefile.inc # Preloading of libhostname allows host name overriding, # this is used to make some tests machine independent. +if BUILD_LIBHOSTNAME noinst_LTLIBRARIES = libhostname.la +else +noinst_LTLIBRARIES = +endif if NO_UNDEFINED # The -no-undefined flag is crucial to build fine on some platforms -- cgit v1.2.1 From 6b490ed33c3ffc4ac96719df7f8c5df46476579a Mon Sep 17 00:00:00 2001 From: Julien Chaffraix Date: Mon, 16 Aug 2010 22:54:19 +0200 Subject: progress: callback for POSTs less than MAX_INITIAL_POST_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a call to Curl_pgrsSetUploadSize in this case valided by a test case. Reported by: Никита Дорохин. Bug: http://curl.haxx.se/mail/lib-2010-04/0173.html --- tests/libtest/Makefile.inc | 4 ++- tests/libtest/lib578.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib578.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index ce230c12a..a0d73b8ef 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -8,7 +8,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib574 lib575 lib576 lib577 \ + lib574 lib575 lib576 lib577 lib578 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ @@ -160,3 +160,5 @@ lib571_SOURCES = lib571.c $(SUPPORTFILES) lib572_SOURCES = lib572.c $(SUPPORTFILES) lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) + +lib578_SOURCES = lib578.c $(SUPPORTFILES) diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c new file mode 100644 index 000000000..2efb003ae --- /dev/null +++ b/tests/libtest/lib578.c @@ -0,0 +1,90 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include "memdebug.h" + +/* The size of data should be kept below MAX_INITIAL_POST_SIZE! */ +static char data[]="this is a short string.\n"; + +static size_t data_size = sizeof(data) / sizeof(char); + +static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +{ + FILE *moo = fopen(libtest_arg2, "wb"); + + (void)clientp; /* UNUSED */ + (void)dltotal; /* UNUSED */ + (void)dlnow; /* UNUSED */ + + if(moo) { + if ((size_t)ultotal == data_size && (size_t)ulnow == data_size) + fprintf(moo, "PASSED, UL data matched data size\n"); + else + fprintf(moo, "Progress callback called with UL %f out of %f\n", ulnow, ultotal); + fclose(moo); + } + return 0; +} + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + 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; + } + + /* First set the URL that is about to receive our POST. */ + test_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + test_setopt(curl, CURLOPT_POST, 1L); + +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + + /* Set the expected POST size */ + test_setopt(curl, CURLOPT_POSTFIELDSIZE, data_size); + test_setopt(curl, CURLOPT_POSTFIELDS, data); + + /* we want to use our own progress function */ + test_setopt(curl, CURLOPT_NOPROGRESS, 0L); + test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + + /* pointer to pass to our read function */ + + /* get verbose debug output please */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* include headers in the output */ + test_setopt(curl, CURLOPT_HEADER, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + +test_cleanup: + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From 70baf46d8ddfc07b488d17cf0f5d8e23cf7de14e Mon Sep 17 00:00:00 2001 From: Julien Chaffraix Date: Thu, 19 Aug 2010 00:27:04 +0200 Subject: test: added test 579 to verify progress callback for chunked post The 66 bytes checked are those 38 bytes with the chunked encoding headers added: 8+8+10+35+5 = 66 The three-letter words become 8 bytes on the wire because they are sent like: "3\r\none\r\n" ... and there's the trailing 5 bytes write after the four lines since the final chunk is sent (which is "0\r\n\r\n"). --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib579.c | 149 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib579.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index a0d73b8ef..a0f1c0ecb 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -8,7 +8,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib574 lib575 lib576 lib577 lib578 \ + lib574 lib575 lib576 lib577 lib578 lib579 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ @@ -162,3 +162,5 @@ lib572_SOURCES = lib572.c $(SUPPORTFILES) lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) lib578_SOURCES = lib578.c $(SUPPORTFILES) + +lib579_SOURCES = lib579.c $(SUPPORTFILES) diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c new file mode 100644 index 000000000..01e91d8f0 --- /dev/null +++ b/tests/libtest/lib579.c @@ -0,0 +1,149 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include "memdebug.h" + +static const char *post[]={ + "one", + "two", + "three", + "and a final longer crap: four", + NULL +}; + + +struct WriteThis { + int counter; +}; + +static int progress_callback(void *clientp, double dltotal, double dlnow, + double ultotal, double ulnow) +{ + FILE *moo; + (void)clientp; /* UNUSED */ + (void)dltotal; /* UNUSED */ + (void)dlnow; /* UNUSED */ + static int prev_ultotal = -1; + static int prev_ulnow = -1; + + /* to avoid depending on timing, which will cause this progress function to + get called a different number of times depending on circumstances, we + only log these lines if the numbers are different from the previous + invoke */ + if((prev_ultotal != (int)ultotal) || + (prev_ulnow != (int)ulnow)) { + + moo = fopen(libtest_arg2, "ab"); + if(moo) { + fprintf(moo, "Progress callback called with UL %d out of %d\n", + (int)ulnow, (int)ultotal); + fclose(moo); + } + prev_ulnow = (int) ulnow; + prev_ultotal = (int) ultotal; + } + return 0; +} + +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *)userp; + const char *data; + + if(size*nmemb < 1) + return 0; + + data = post[pooh->counter]; + + if(data) { + size_t len = strlen(data); + memcpy(ptr, data, len); + pooh->counter++; /* advance pointer */ + return len; + } + return 0; /* no more data left to deliver */ +} + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + struct curl_slist *slist = NULL; + struct WriteThis pooh; + pooh.counter = 0; + + 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; + } + + slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); + if (slist == NULL) { + fprintf(stderr, "curl_slist_append() failed\n"); + curl_easy_cleanup(curl); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* First set the URL that is about to receive our POST. */ + test_setopt(curl, CURLOPT_URL, URL); + + /* Now specify we want to POST data */ + test_setopt(curl, CURLOPT_POST, 1L); + +#ifdef CURL_DOES_CONVERSIONS + /* Convert the POST data to ASCII */ + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); +#endif + + /* we want to use our own read function */ + test_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pointer to pass to our read function */ + test_setopt(curl, CURLOPT_INFILE, &pooh); + + /* get verbose debug output please */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* include headers in the output */ + test_setopt(curl, CURLOPT_HEADER, 1L); + + /* enforce chunked transfer by setting the header */ + test_setopt(curl, CURLOPT_HTTPHEADER, slist); + + test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + test_setopt(curl, CURLOPT_USERPWD, "foo:bar"); + + /* we want to use our own progress function */ + test_setopt(curl, CURLOPT_NOPROGRESS, 0L); + test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + +test_cleanup: + + /* clean up the headers list */ + if(slist) + curl_slist_free_all(slist); + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From ebbe694e78cb351c239c936375cc4439afe0a929 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 18 Aug 2010 22:16:46 -0700 Subject: Removed a C99ism & made an array const --- tests/libtest/lib579.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index 01e91d8f0..2b80ab0b6 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -11,7 +11,7 @@ #include "memdebug.h" -static const char *post[]={ +static const char * const post[]={ "one", "two", "three", @@ -28,11 +28,11 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { FILE *moo; + static int prev_ultotal = -1; + static int prev_ulnow = -1; (void)clientp; /* UNUSED */ (void)dltotal; /* UNUSED */ (void)dlnow; /* UNUSED */ - static int prev_ultotal = -1; - static int prev_ulnow = -1; /* to avoid depending on timing, which will cause this progress function to get called a different number of times depending on circumstances, we -- cgit v1.2.1 From 8e2f16e66f507ffd7a61b41e3052527b91883182 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Sat, 11 Sep 2010 17:04:05 -0700 Subject: Link curl and the test apps with -lrt explicitly when necessary When curl calls a function from that library then it needs to explicitly link to the library instead of piggybacking on libcurl's own dependency. Without this, GNU ld with the --no-add-needed flag fails when linking (which Fedora now does by default). Reported by: Quanah Gibson-Mount Bug: http://curl.haxx.se/mail/lib-2010-09/0085.html --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 2ba7b0a32..9c0d59507 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -54,7 +54,7 @@ EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc # Dependencies (may need to be overriden) -LDADD = $(top_builddir)/lib/libcurl.la +LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ DEPENDENCIES = $(top_builddir)/lib/libcurl.la # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, -- cgit v1.2.1 From 4d58f97f604bfef5b2cb7538f9bbc925c141622f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 27 Sep 2010 16:54:02 +0200 Subject: parsedate: allow time specified without seconds The date format in RFC822 allows that the seconds part of HH:MM:SS is left out, but this function didn't allow it. This change also includes a modified test case that makes sure that this now works. Reported by: Matt Ford Bug: http://curl.haxx.se/bug/view.cgi?id=3076529 --- tests/libtest/lib517.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 3f7b064ab..38a65d30b 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -97,6 +97,8 @@ static const char *dates[]={ "Thu, 999999999999-Aug-2007 20:49:07 GMT", "Thu, 12-Aug-2007 20:61:99999999999 GMT", "IAintNoDateFool", + "Thu Apr 18 22:50 2007 GMT", /* without seconds */ + NULL }; -- cgit v1.2.1 From cc8791329435e3e992dff7488e5649e655f2fd54 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Nov 2010 22:27:33 +0100 Subject: test: added test 580 - verifies symbols-in-versions The new perl script mk580.pl generates a C table in a fresh source file named lib580.c and if that compiles fine we know that the file docs/libcurl/symbols-in-versions at least doesn't include any symbols that are misspelled. An additional feature would be to somehow scan curl/curl.h and compare with symbols-in-versions to see if there are symbols missing. --- tests/libtest/Makefile.inc | 7 ++++++- tests/libtest/mk580.pl | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/mk580.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index a0f1c0ecb..39d59fd3a 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -12,7 +12,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 lib572 lib573 chkhostname + lib568 lib569 lib570 lib571 lib572 lib573 chkhostname lib580 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -164,3 +164,8 @@ lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) + +lib580_SOURCES = lib580.c $(SUPPORTFILES) + +lib580.c: mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions + $(PERL) mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions > $@ diff --git a/tests/libtest/mk580.pl b/tests/libtest/mk580.pl new file mode 100644 index 000000000..8dc6d57b8 --- /dev/null +++ b/tests/libtest/mk580.pl @@ -0,0 +1,18 @@ +open(S, '<', $ARGV[0]); + +print <) { + my @a=split(/ +/); + chomp $a[0]; + chomp $a[3]; + if($a[0] && !$a[3]) { + printf("%s,\n", $a[0]); + } +} +print "};\n"; +close(S); -- cgit v1.2.1 From 36420330de12d36f189554d4af4f0cfdef27b1a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Nov 2010 23:34:37 +0100 Subject: ignore: lib580.c is generated by mk580.pl --- tests/libtest/.gitignore | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index cabcb671c..672fc9f5b 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,2 +1,3 @@ chkhostname lib5[0-9][0-9] +lib580.c -- cgit v1.2.1 From 282b41c69b1a01b1974d0ca287e89ed420c52289 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 2 Nov 2010 23:17:36 -0700 Subject: Added mk580.pl to the tar ball --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 9c0d59507..36d225a6b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -51,7 +51,7 @@ INCLUDES = -I$(top_builddir)/include/curl \ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ -test1022.pl Makefile.inc +test1022.pl mk580.pl Makefile.inc # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ -- cgit v1.2.1 From 96945c98d5ac5759ed012504ddf5344727660d53 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 3 Nov 2010 19:03:02 -0700 Subject: Allow building test 580 out of tree --- tests/libtest/Makefile.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 39d59fd3a..ce7f4e6c5 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -167,5 +167,5 @@ lib579_SOURCES = lib579.c $(SUPPORTFILES) lib580_SOURCES = lib580.c $(SUPPORTFILES) -lib580.c: mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions - $(PERL) mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions > $@ +lib580.c: $(top_srcdir)/tests/libtest/mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions + $(PERL) $(top_srcdir)/tests/libtest/mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions > $@ -- cgit v1.2.1 From 1786950759a0429bde29822c3c879fdbf305f24d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Nov 2010 11:19:21 +0100 Subject: test: remove test 580 Test 580 is removed again for two reasons: 1) Some compilers aren't satisfied by just a data variable called 'test' when first.o wants a function called 'test'. The Solaris compiler says "ld: warning: symbol `test' has differing types:" while the AIX compiler downright rejects it. 2) Test case 1119 that was added after this test is way more complete and cover everything test 580 does and more without introducing the same problems. --- tests/libtest/.gitignore | 2 +- tests/libtest/Makefile.am | 2 +- tests/libtest/Makefile.inc | 7 +------ tests/libtest/mk580.pl | 18 ------------------ 4 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 tests/libtest/mk580.pl (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 672fc9f5b..82560206e 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,3 +1,3 @@ chkhostname lib5[0-9][0-9] -lib580.c + diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 36d225a6b..9c0d59507 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -51,7 +51,7 @@ INCLUDES = -I$(top_builddir)/include/curl \ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ -test1022.pl mk580.pl Makefile.inc +test1022.pl Makefile.inc # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index ce7f4e6c5..a0f1c0ecb 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -12,7 +12,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ - lib568 lib569 lib570 lib571 lib572 lib573 chkhostname lib580 + lib568 lib569 lib570 lib571 lib572 lib573 chkhostname chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -164,8 +164,3 @@ lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) - -lib580_SOURCES = lib580.c $(SUPPORTFILES) - -lib580.c: $(top_srcdir)/tests/libtest/mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions - $(PERL) $(top_srcdir)/tests/libtest/mk580.pl $(top_srcdir)/docs/libcurl/symbols-in-versions > $@ diff --git a/tests/libtest/mk580.pl b/tests/libtest/mk580.pl deleted file mode 100644 index 8dc6d57b8..000000000 --- a/tests/libtest/mk580.pl +++ /dev/null @@ -1,18 +0,0 @@ -open(S, '<', $ARGV[0]); - -print <) { - my @a=split(/ +/); - chomp $a[0]; - chomp $a[3]; - if($a[0] && !$a[3]) { - printf("%s,\n", $a[0]); - } -} -print "};\n"; -close(S); -- cgit v1.2.1 From 5db0a412ff6972e51ccddaf1e8d6a27c8de4990f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 28 Nov 2010 23:11:14 +0100 Subject: atoi: remove atoi usage --- tests/libtest/first.c | 5 ++++- tests/libtest/lib521.c | 2 +- tests/libtest/lib562.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 770f9d527..a0e713f48 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -59,7 +59,10 @@ int main(int argc, char **argv) /* this enables the fail-on-alloc-number-N functionality */ env = curl_getenv("CURL_MEMLIMIT"); if(env) { - curl_memlimit(atoi(env)); + char *endptr; + long num = strtol(env, &endptr, 10); + if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) + curl_memlimit(num); curl_free(env); } #endif diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index a4ae5558a..9e79cb41e 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -28,7 +28,7 @@ int test(char *URL) } test_setopt(curl, CURLOPT_URL, URL); - test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2)); + test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10)); test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy"); test_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index d78ecce25..acdd79aab 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -57,7 +57,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); /* set port number */ - test_setopt(curl, CURLOPT_PORT, atoi(libtest_arg2) ); + test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10)); /* specify target */ test_setopt(curl,CURLOPT_URL, URL); -- cgit v1.2.1 From 35e1d6538a8767526b9cae66134441b146503a21 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 1 Jan 2011 17:33:42 +0100 Subject: unittest: framework for unit-testing This is the first approach at doing fairly clean and easy to write and debug unit tests. --- tests/libtest/Makefile.inc | 1 + tests/libtest/first.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index a0f1c0ecb..2354ecc60 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -164,3 +164,4 @@ lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) + diff --git a/tests/libtest/first.c b/tests/libtest/first.c index a0e713f48..53b372ba5 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -37,7 +37,7 @@ char *libtest_arg2=NULL; char *libtest_arg3=NULL; int test_argc; char **test_argv; - +int unitfail; /* for unittests */ int main(int argc, char **argv) { -- cgit v1.2.1 From dbcaa0065719acc0383307f13d02d3d0c9b5c635 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Jan 2011 12:06:50 +0100 Subject: HTTP: memory leak on multiple Location: The HTTP parser allocated memory on each received Location: header without properly freeing old data. Starting now, the code only considers the first Location: header and will blissfully ignore subsequent ones. Bug: http://curl.haxx.se/bug/view.cgi?id=3165129 Reported by: Martin Lemke --- tests/libtest/lib507.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 9707c9b07..012d8f454 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -48,6 +48,7 @@ int test(char *URL) } test_setopt(curls, CURLOPT_URL, URL); + test_setopt(curls, CURLOPT_HEADER, 1L); if ((ret = curl_multi_add_handle(multi, curls)) != CURLM_OK) { fprintf(stderr, "curl_multi_add_handle() failed, " -- cgit v1.2.1 From fb199cd29d0ce275f9b9b28b1ebf6af3e0887950 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 4 Mar 2011 14:32:58 -0800 Subject: Converted tests 558 & 559 to use the unit test framework as 1305 Test 558 was just a subset of 559 which is something that can be easily added later. --- tests/libtest/CMakeLists.txt | 8 +- tests/libtest/Makefile.inc | 8 +- tests/libtest/lib558.c | 188 ------------------------------------------- 3 files changed, 2 insertions(+), 202 deletions(-) delete mode 100644 tests/libtest/lib558.c (limited to 'tests/libtest') diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index 653e5315d..896686bd8 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -65,8 +65,7 @@ endforeach() # lib547 # #lib548 # lib549 lib552 lib553 lib554 lib555 lib556 -# lib539 lib557 lib558 -# #lib559 +# lib539 lib557 # lib560 # ) @@ -120,8 +119,3 @@ endforeach() # SET(SOURCE "lib547.c" ${SUPPORTFILES}) # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) # SETUP_TEST(${TEST_NAME} ${SOURCE}) - -# SET(TEST_NAME lib559) -# SET(SOURCE "lib558.c" ${SUPPORTFILES}) -# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME}) -# SETUP_TEST(${TEST_NAME} ${SOURCE}) diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 2354ecc60..322feeac4 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -11,7 +11,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib574 lib575 lib576 lib577 lib578 lib579 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ - lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \ + lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 \ lib568 lib569 lib570 lib571 lib572 lib573 chkhostname chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c @@ -122,12 +122,6 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) -lib558_SOURCES = lib558.c $(SUPPORTFILES) -lib558_CFLAGS = -DLIB558 - -lib559_SOURCES = lib558.c $(SUPPORTFILES) -lib559_CFLAGS = -DLIB559 - lib560_SOURCES = lib560.c $(SUPPORTFILES) lib574_SOURCES = lib574.c $(SUPPORTFILES) diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c deleted file mode 100644 index 56f2a2612..000000000 --- a/tests/libtest/lib558.c +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - */ - -#include "test.h" - -#ifdef HAVE_SYS_SOCKET_H -# include -#endif -#ifdef HAVE_NETINET_IN_H -# include -#endif -#ifdef HAVE_NETDB_H -# include -#endif -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#define ENABLE_CURLX_PRINTF -#include "curlx.h" - -#include "hash.h" -#include "hostip.h" - -#include "curl_memory.h" -#include "memdebug.h" - -/* This source file is used for test # 558 and 559 */ - -/* - * This hacky test bypasses the library external API, - * using internal only libcurl functions. So don't be - * surprised if we cannot run it when the library has - * been built with hidden symbols, exporting only the - * ones in the public API. - */ - -#if defined(CURL_HIDDEN_SYMBOLS) -# define SKIP_TEST 1 -#elif defined(WIN32) && !defined(CURL_STATICLIB) -# define SKIP_TEST 1 -#else -# undef SKIP_TEST -#endif - - -#if !defined(SKIP_TEST) - -#ifdef LIB559 -static Curl_addrinfo *fake_ai(void) -{ - Curl_addrinfo *ai; - int ss_size; - - ss_size = sizeof (struct sockaddr_in); - - if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL) - return NULL; - - if((ai->ai_canonname = strdup("dummy")) == NULL) { - free(ai); - return NULL; - } - - if((ai->ai_addr = calloc(1, ss_size)) == NULL) { - free(ai->ai_canonname); - free(ai); - return NULL; - } - - ai->ai_family = AF_INET; - ai->ai_addrlen = ss_size; - - return ai; -} -#endif /* LIB559 */ - - -int test(char *URL) -{ - CURL *easyh = NULL; - struct curl_hash *hp = NULL; - int result = 0; - - if(!strcmp(URL, "check")) { - /* test harness script verifying if this test can run */ - return 0; /* sure, run this! */ - } - - easyh = curl_easy_init(); - if(!easyh) { - fprintf(stdout, "easy handle init failed\n"); - result = TEST_ERR_MAJOR_BAD; - goto cleanup; - } - fprintf(stdout, "easy handle init OK\n"); - - fprintf(stdout, "creating hash...\n"); - hp = Curl_mk_dnscache(); - if(!hp) { - fprintf(stdout, "hash creation failed\n"); - result = TEST_ERR_MAJOR_BAD; - goto cleanup; - } - fprintf(stdout, "hash creation OK\n"); - - /**/ -#ifdef LIB559 - { - char *data_key; - struct Curl_dns_entry *data_node; - struct Curl_dns_entry *nodep; - size_t key_len; - - data_key = aprintf("%s:%d", "dummy", 0); - if(!data_key) { - fprintf(stdout, "data key creation failed\n"); - result = TEST_ERR_MAJOR_BAD; - goto cleanup; - } - key_len = strlen(data_key); - - data_node = calloc(1, sizeof(struct Curl_dns_entry)); - if(!data_node) { - fprintf(stdout, "data node creation failed\n"); - result = TEST_ERR_MAJOR_BAD; - free(data_key); - goto cleanup; - } - - data_node->addr = fake_ai(); - if(!data_node->addr) { - fprintf(stdout, "actual data creation failed\n"); - result = TEST_ERR_MAJOR_BAD; - free(data_node); - free(data_key); - goto cleanup; - } - - nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); - if(!nodep) { - fprintf(stdout, "insertion into hash failed\n"); - result = TEST_ERR_MAJOR_BAD; - Curl_freeaddrinfo(data_node->addr); - free(data_node); - free(data_key); - goto cleanup; - } - - free(data_key); - } -#endif /* LIB559 */ - /**/ - -cleanup: - - fprintf(stdout, "destroying hash...\n"); - Curl_hash_destroy(hp); - fprintf(stdout, "hash destruction OK\n"); - - fprintf(stdout, "destroying easy handle...\n"); - curl_easy_cleanup(easyh); - fprintf(stdout, "easy handle destruction OK\n"); - - curl_global_cleanup(); - - return result; -} - - -#else /* !defined(SKIP_TEST) */ - - -int test(char *URL) -{ - (void)URL; - fprintf(stdout, "libcurl built with hidden symbols"); - return 1; /* skip test */ -} - - -#endif /* !defined(SKIP_TEST) */ -- cgit v1.2.1 From c60a6153be81956b8bd9fcec46fc12ee3b7ca38a Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 4 Mar 2011 15:56:40 -0800 Subject: Moved test 577 into the unit test framework as test 1307 --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib577.c | 255 --------------------------------------------- 2 files changed, 1 insertion(+), 258 deletions(-) delete mode 100644 tests/libtest/lib577.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 322feeac4..5fb9fad6f 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -8,7 +8,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib574 lib575 lib576 lib577 lib578 lib579 \ + lib574 lib575 lib576 lib578 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 \ @@ -130,8 +130,6 @@ lib575_SOURCES = lib575.c $(SUPPORTFILES) lib576_SOURCES = lib576.c $(SUPPORTFILES) -lib577_SOURCES = lib577.c $(SUPPORTFILES) - lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib577.c b/tests/libtest/lib577.c deleted file mode 100644 index bd52c6251..000000000 --- a/tests/libtest/lib577.c +++ /dev/null @@ -1,255 +0,0 @@ -/***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - */ - -#include "test.h" - -/* - * This hacky test bypasses the library external API, - * using internal only libcurl functions. So don't be - * surprised if we cannot run it when the library has - * been built with hidden symbols, exporting only the - * ones in the public API. - */ - -#if defined(CURL_HIDDEN_SYMBOLS) -# define SKIP_TEST 1 -#elif defined(WIN32) && !defined(CURL_STATICLIB) -# define SKIP_TEST 1 -#else -# undef SKIP_TEST -#endif - - -#if !defined(SKIP_TEST) - -#include "memdebug.h" - -#include "curl_fnmatch.h" - -#define MATCH CURL_FNMATCH_MATCH -#define NOMATCH CURL_FNMATCH_NOMATCH -#define RE_ERR CURL_FNMATCH_FAIL - -#define MAX_PATTERN_L 100 -#define MAX_STRING_L 100 - -struct testcase { - char pattern[MAX_PATTERN_L]; - char string[MAX_STRING_L]; - int result; -}; - -static const struct testcase tests[] = { - /* brackets syntax */ - { "\\[", "[", MATCH }, - { "[", "[", RE_ERR }, - { "[]", "[]", RE_ERR }, - { "[][]", "[", MATCH }, - { "[][]", "]", MATCH }, - { "[[]", "[", MATCH }, - { "[[[]", "[", MATCH }, - { "[[[[]", "[", MATCH }, - { "[[[[]", "[", MATCH }, - - { "[][[]", "]", MATCH }, - { "[][[[]", "[", MATCH }, - { "[[]", "]", NOMATCH }, - - { "[a-z]", "a", MATCH }, - { "[a-z]", "A", NOMATCH }, - { "?[a-z]", "?Z", NOMATCH }, - { "[A-Z]", "C", MATCH }, - { "[A-Z]", "c", NOMATCH }, - { "[0-9]", "7", MATCH }, - { "[7-8]", "7", MATCH }, - { "[7-]", "7", MATCH }, - { "[7-]", "-", MATCH }, - { "[7-]", "[", NOMATCH }, - { "[a-bA-F]", "F", MATCH }, - { "[a-bA-B9]", "9", MATCH }, - { "[a-bA-B98]", "8", MATCH }, - { "[a-bA-B98]", "C", NOMATCH }, - { "[a-bA-Z9]", "F", MATCH }, - { "[a-bA-Z9]ero*", "Zero chance.", MATCH }, - { "S[a-][x]opho*", "Saxophone", MATCH }, - { "S[a-][x]opho*", "SaXophone", NOMATCH }, - { "S[a-][x]*.txt", "S-x.txt", MATCH }, - { "[\\a-\\b]", "a", MATCH }, - { "[\\a-\\b]", "b", MATCH }, - { "[?*[][?*[][?*[]", "?*[", MATCH }, - { "[][?*-]", "]", MATCH }, - { "[][?*-]", "[", MATCH }, - { "[][?*-]", "?", MATCH }, - { "[][?*-]", "*", MATCH }, - { "[][?*-]", "-", MATCH }, - { "[]?*-]", "-", MATCH }, - { "?/b/c", "a/b/c", MATCH }, - { "^_{}~", "^_{}~", MATCH }, - { "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH }, - { "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH }, - { ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH }, - - /* negate */ - { "[!a]", "b", MATCH }, - { "[!a]", "a", NOMATCH }, - { "[^a]", "b", MATCH }, - { "[^a]", "a", NOMATCH }, - { "[^a-z0-9A-Z]", "a", NOMATCH }, - { "[^a-z0-9A-Z]", "-", MATCH }, - { "curl[!a-z]lib", "curl lib", MATCH }, - { "curl[! ]lib", "curl lib", NOMATCH }, - { "[! ][ ]", " ", NOMATCH }, - { "[! ][ ]", "a ", MATCH }, - { "*[^a].t?t", "a.txt", NOMATCH }, - { "*[^a].t?t", "ba.txt", NOMATCH }, - { "*[^a].t?t", "ab.txt", MATCH }, - { "[!?*[]", "?", NOMATCH }, - { "[!!]", "!", NOMATCH }, - { "[!!]", "x", MATCH }, - - { "[[:alpha:]]", "a", MATCH }, - { "[[:alpha:]]", "9", NOMATCH }, - { "[[:alnum:]]", "a", MATCH }, - { "[[:alnum:]]", "[", NOMATCH }, - { "[[:alnum:]]", "]", NOMATCH }, - { "[[:alnum:]]", "9", MATCH }, - { "[[:digit:]]", "9", MATCH }, - { "[[:xdigit:]]", "9", MATCH }, - { "[[:xdigit:]]", "F", MATCH }, - { "[[:xdigit:]]", "G", NOMATCH }, - { "[[:upper:]]", "U", MATCH }, - { "[[:upper:]]", "u", NOMATCH }, - { "[[:lower:]]", "l", MATCH }, - { "[[:lower:]]", "L", NOMATCH }, - { "[[:print:]]", "L", MATCH }, - { "[[:print:]]", {'\10'}, NOMATCH }, - { "[[:print:]]", {'\10'}, NOMATCH }, - { "[[:space:]]", " ", MATCH }, - { "[[:space:]]", "x", NOMATCH }, - { "[[:graph:]]", " ", NOMATCH }, - { "[[:graph:]]", "x", MATCH }, - { "[[:blank:]]", {'\t'}, MATCH }, - { "[[:blank:]]", {' '}, MATCH }, - { "[[:blank:]]", {'\r'}, NOMATCH }, - { "[^[:blank:]]", {'\t'}, NOMATCH }, - { "[^[:print:]]", {'\10'}, MATCH }, - { "[[:lower:]][[:lower:]]", "ll", MATCH }, - - { "Curl[[:blank:]];-)", "Curl ;-)", MATCH }, - { "*[[:blank:]]*", " ", MATCH }, - { "*[[:blank:]]*", "", NOMATCH }, - { "*[[:blank:]]*", "hi, im_Pavel", MATCH }, - - /* common using */ - { "filename.dat", "filename.dat", MATCH }, - { "*curl*", "lets use curl!!", MATCH }, - { "filename.txt", "filename.dat", NOMATCH }, - { "*.txt", "text.txt", MATCH }, - { "*.txt", "a.txt", MATCH }, - { "*.txt", ".txt", MATCH }, - { "*.txt", "txt", NOMATCH }, - { "??.txt", "99.txt", MATCH }, - { "??.txt", "a99.txt", NOMATCH }, - { "?.???", "a.txt", MATCH }, - { "*.???", "somefile.dat", MATCH }, - { "*.???", "photo.jpeg", NOMATCH }, - { ".*", ".htaccess", MATCH }, - { ".*", ".", MATCH }, - { ".*", "..", MATCH }, - - /* many stars => one star */ - { "**.txt", "text.txt", MATCH }, - { "***.txt", "t.txt", MATCH }, - { "****.txt", ".txt", MATCH }, - - /* empty string or pattern */ - { "", "", MATCH } , - { "", "hello", NOMATCH }, - { "file", "", NOMATCH }, - { "?", "", NOMATCH }, - { "*", "", MATCH }, - { "x", "", NOMATCH }, - - /* backslash */ - { "\\", "\\", RE_ERR }, - { "\\\\", "\\", MATCH }, - { "\\\\", "\\\\", NOMATCH }, - { "\\?", "?", MATCH }, - { "\\*", "*", MATCH }, - { "?.txt", "?.txt", MATCH }, - { "*.txt", "*.txt", MATCH }, - { "\\?.txt", "?.txt", MATCH }, - { "\\*.txt", "*.txt", MATCH }, - { "\\?.txt", "x.txt", NOMATCH }, - { "\\*.txt", "x.txt", NOMATCH }, - { "\\*\\\\.txt", "*\\.txt", MATCH }, - { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, - { "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH }, - { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, - { "*\\?*\\**", "cc?c*c", MATCH }, - { "*\\?*\\**curl*", "cc?c*curl", MATCH }, - { "*\\?*\\**", "cc?cc", NOMATCH }, - { "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH }, - { "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH }, - { "[\\a\\b]c", "ac", MATCH }, - { "[\\a\\b]c", "bc", MATCH }, - { "[\\a\\b]d", "bc", NOMATCH }, - { "[a-bA-B\\?]", "?", MATCH }, - { "cu[a-ab-b\\r]l", "curl", MATCH }, - { "[\\a-z]", "c", MATCH }, - - { "?*?*?.*?*", "abc.c", MATCH }, - { "?*?*?.*?*", "abcc", NOMATCH }, - { "?*?*?.*?*", "abc.", NOMATCH }, - { "?*?*?.*?*", "abc.c++", MATCH }, - { "?*?*?.*?*", "abcdef.c++", MATCH }, - { "?*?*?.?", "abcdef.c", MATCH }, - { "?*?*?.?", "abcdef.cd", NOMATCH }, - - { "Lindmätarv", "Lindmätarv", MATCH }, - - { "", "", MATCH } -}; - - -int test(char *URL) -{ - int testnum = sizeof(tests) / sizeof(struct testcase); - int i, rc; - (void)URL; /* not used */ - - if(!strcmp(URL, "check")) { - /* test harness script verifying if this test can run */ - return 0; /* sure, run this! */ - } - - printf("===========================\n"); - for(i = 0; i < testnum; i++) { - rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string); - if(rc != tests[i].result) { - printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n", - tests[i].pattern, tests[i].string, tests[i].result, rc); - } - } - printf("===========================\n"); - return 0; -} - -#else /* !defined(SKIP_TEST) */ - - -int test(char *URL) -{ - (void)URL; - fprintf(stdout, "libcurl built with hidden symbols"); - return 1; /* skip test */ -} - - -#endif /* !defined(SKIP_TEST) */ -- cgit v1.2.1 From 0e74e1d8d83d50ba1d411903ae2dbba13a71bdeb Mon Sep 17 00:00:00 2001 From: Henry Ludemann Date: Tue, 8 Mar 2011 00:19:49 +0100 Subject: sftp-multi: test 582 added Add test 582 for uploading a file using sftp and the multi interface. (Patch and test slightly tweaked by Daniel Stenberg) Initially marked as disabled until it is fixed in the source. --- tests/libtest/Makefile.inc | 4 +++- tests/libtest/test.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 5fb9fad6f..c68f5af52 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -12,7 +12,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ 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 chkhostname + lib568 lib569 lib570 lib571 lib572 lib573 lib582 chkhostname chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -157,3 +157,5 @@ lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) +lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) + diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 2a3671181..d5a099e25 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -44,6 +44,9 @@ #define test_setopt(A,B,C) \ if((res = curl_easy_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup +#define test_multi_setopt(A,B,C) \ + if((res = curl_multi_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup + extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */ -- cgit v1.2.1 From 3d3735d9a199dfe5c8e02e60695ef9ff7a1a7f1a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 8 Mar 2011 08:21:03 +0100 Subject: lib582: used for test 582 Accidentally not included in commit 0e74e1d8d83 --- tests/libtest/lib582.c | 360 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 tests/libtest/lib582.c (limited to 'tests/libtest') diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c new file mode 100644 index 000000000..804641e3a --- /dev/null +++ b/tests/libtest/lib582.c @@ -0,0 +1,360 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "test.h" + +#include +#include +#include + +#include "testutil.h" +#include "memdebug.h" + +#define MAIN_LOOP_HANG_TIMEOUT 10 * 1000 + +struct Sockets +{ + curl_socket_t* sockets; + int count; +}; + +struct ReadWriteSockets +{ + struct Sockets read, write; +}; + +/** + * Remove a file descriptor from a sockets array. + */ +static void removeFd(struct Sockets* sockets, curl_socket_t fd) +{ + int i; + + fprintf(stderr, "Remove socket fd %d\n", (int) fd); + + 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)); + --sockets->count; + } + } +} + +/** + * Add a file descriptor to a sockets array. + */ +static void addFd(struct Sockets* sockets, curl_socket_t fd) +{ + /** + * To ensure we only have each file descriptor once, we remove it then add + * it again. + */ + fprintf(stderr, "Add socket fd %d\n", (int) fd); + removeFd(sockets, fd); + sockets->sockets = realloc(sockets->sockets, + sizeof(curl_socket_t) * (sockets->count + 1)); + sockets->sockets[sockets->count] = fd; + ++sockets->count; +} + +/** + * Callback invoked by curl to poll reading / writing of a socket. + */ +static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, + void *userp, void *socketp) +{ + struct ReadWriteSockets* sockets = userp; + + (void)easy; /* unused */ + (void)socketp; /* unused */ + + if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) + addFd(&sockets->read, s); + else + removeFd(&sockets->read, s); + + if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) + addFd(&sockets->write, s); + else + removeFd(&sockets->write, s); + + return 0; +} + +/** + * Callback invoked by curl to set a timeout. + */ +static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) +{ + struct timeval* timeout = userp; + + (void)multi; /* unused */ + if (timeout_ms != -1) { + gettimeofday(timeout, 0); + timeout->tv_usec += timeout_ms * 1000; + } + else { + timeout->tv_sec = -1; + } + return 0; +} + +/** + * Check for curl completion. + */ +static int checkForCompletion(CURLM* curl, int* success) +{ + int numMessages; + CURLMsg* message; + int result = 0; + *success = 0; + while ((message = curl_multi_info_read(curl, &numMessages)) != 0) { + if (message->msg == CURLMSG_DONE) { + result = 1; + if (message->data.result == CURLE_OK) + *success = 1; + else + *success = 0; + } + else { + fprintf(stderr, "Got an unexpected message from curl: %i\n", + message->msg); + result = 1; + *success = 0; + } + } + return result; +} + +static int getMicroSecondTimeout(struct timeval* timeout) +{ + struct timeval now; + int result; + + gettimeofday(&now, 0); + result = (timeout->tv_sec - now.tv_sec) * 1000000 + + timeout->tv_usec - now.tv_usec; + if (result < 0) + result = 0; + + return result; +} + +/** + * Update a fd_set with all of the sockets in use. + */ +static void updateFdSet(struct Sockets* sockets, fd_set* fdset, int* maxFd) +{ + int i; + for (i = 0; i < sockets->count; ++i) { + FD_SET(sockets->sockets[i], fdset); + if (*maxFd < sockets->sockets[i] + 1) { + *maxFd = sockets->sockets[i] + 1; + } + } +} + +static void notifyCurl(CURL* 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) + { + fprintf(stderr, "Curl error on %s: %i (%s)\n", + info, result, curl_multi_strerror(result)); + } +} + +/** + * Invoke curl when a file descriptor is set. + */ +static void checkFdSet(CURL* 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)) + { + notifyCurl(curl, sockets->sockets[i], evBitmask, name); + } + } +} + +int test(char *URL) +{ + int res = 0; + CURL *curl; + FILE *hd_src ; + 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 timeval timeout = {-1, 0}; + int success = 0; + + if (!libtest_arg3) { + fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n"); + return -1; + } + + hd_src = fopen(libtest_arg2, "rb"); + if(NULL == hd_src) { + error = ERRNO; + 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; + } + + /* get the file size of the local file */ + hd = fstat(fileno(hd_src), &file_info); + if(hd == -1) { + /* can't open file, bail out */ + error = ERRNO; + fprintf(stderr, "fstat() failed with error: %d %s\n", + error, strerror(error)); + fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2); + fclose(hd_src); + return -1; + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + fclose(hd_src); + return TEST_ERR_MAJOR_BAD; + } + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + fclose(hd_src); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + /* enable uploading */ + test_setopt(curl, CURLOPT_UPLOAD, 1L); + + /* specify target */ + test_setopt(curl,CURLOPT_URL, URL); + + /* go verbose */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* now specify which file to upload */ + test_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"); + + 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; + } + 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; + } + + ml_timedout = FALSE; + ml_start = tutil_tvnow(); + + while (!checkForCompletion(m, &success)) + { + fd_set readSet, writeSet; + int 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); + updateFdSet(&sockets.write, &writeSet, &maxFd); + + if (timeout.tv_sec != -1) + { + int usTimeout = getMicroSecondTimeout(&timeout); + tv.tv_sec = usTimeout / 1000000; + tv.tv_usec = usTimeout % 1000000; + } + else if (maxFd <= 0) + { + tv.tv_sec = 0; + tv.tv_usec = 100000; + } + + select_test(maxFd, &readSet, &writeSet, NULL, &tv); + + /* Check the sockets for reading / writing */ + checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read"); + checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write"); + + if (timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) + { + /* Curl's timer has elapsed. */ + notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout"); + } + } + + if (!success) + { + 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); + curl_easy_cleanup(curl); + if(m) + curl_multi_cleanup(m); + + fclose(hd_src); /* close the local file */ + if (sockets.read.sockets != 0) + free(sockets.read.sockets); + if (sockets.write.sockets != 0) + free(sockets.write.sockets); + + curl_global_cleanup(); + return res; +} -- cgit v1.2.1 From 1aeb635cdd296c16acb375a4a83a78f13166ccab Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Mar 2011 11:48:02 +0100 Subject: sources: update source headers All C and H files now (should) feature the proper project curl source code header, which includes basic info, a copyright statement and some basic disclaimers. --- tests/libtest/chkhostname.c | 21 +++++++++++++++++++++ tests/libtest/first.c | 18 +++++++++++++++--- tests/libtest/lib500.c | 18 +++++++++++++++--- tests/libtest/lib501.c | 18 +++++++++++++++--- tests/libtest/lib502.c | 18 +++++++++++++++--- tests/libtest/lib503.c | 18 +++++++++++++++--- tests/libtest/lib504.c | 18 +++++++++++++++--- tests/libtest/lib505.c | 18 +++++++++++++++--- tests/libtest/lib506.c | 18 +++++++++++++++--- tests/libtest/lib507.c | 18 +++++++++++++++--- tests/libtest/lib508.c | 18 +++++++++++++++--- tests/libtest/lib510.c | 18 +++++++++++++++--- tests/libtest/lib511.c | 18 +++++++++++++++--- tests/libtest/lib512.c | 18 +++++++++++++++--- tests/libtest/lib513.c | 18 +++++++++++++++--- tests/libtest/lib514.c | 18 +++++++++++++++--- tests/libtest/lib515.c | 18 +++++++++++++++--- tests/libtest/lib516.c | 18 +++++++++++++++--- tests/libtest/lib517.c | 18 +++++++++++++++--- tests/libtest/lib518.c | 18 +++++++++++++++--- tests/libtest/lib519.c | 18 +++++++++++++++--- tests/libtest/lib520.c | 18 +++++++++++++++--- tests/libtest/lib521.c | 18 +++++++++++++++--- tests/libtest/lib523.c | 18 +++++++++++++++--- tests/libtest/lib524.c | 18 +++++++++++++++--- tests/libtest/lib525.c | 18 +++++++++++++++--- tests/libtest/lib526.c | 18 +++++++++++++++--- tests/libtest/lib530.c | 18 +++++++++++++++--- tests/libtest/lib533.c | 18 +++++++++++++++--- tests/libtest/lib536.c | 18 +++++++++++++++--- tests/libtest/lib537.c | 18 +++++++++++++++--- tests/libtest/lib539.c | 30 +++++++++++++++++++++--------- tests/libtest/lib540.c | 17 +++++++++++++++-- tests/libtest/lib541.c | 18 +++++++++++++++--- tests/libtest/lib542.c | 18 +++++++++++++++--- tests/libtest/lib543.c | 18 +++++++++++++++--- tests/libtest/lib544.c | 18 +++++++++++++++--- tests/libtest/lib547.c | 17 +++++++++++++++-- tests/libtest/lib549.c | 17 +++++++++++++++-- tests/libtest/lib552.c | 17 +++++++++++++++-- tests/libtest/lib553.c | 18 ++++++++++++++++-- tests/libtest/lib554.c | 18 +++++++++++++++--- tests/libtest/lib555.c | 18 ++++++++++++++++-- tests/libtest/lib556.c | 18 +++++++++++++++--- tests/libtest/lib557.c | 17 +++++++++++++++-- tests/libtest/lib560.c | 16 ++++++++++++++-- tests/libtest/lib562.c | 17 +++++++++++++++-- tests/libtest/lib564.c | 17 +++++++++++++++-- tests/libtest/lib566.c | 17 +++++++++++++++-- tests/libtest/lib567.c | 17 +++++++++++++++-- tests/libtest/lib568.c | 17 +++++++++++++++-- tests/libtest/lib569.c | 17 +++++++++++++++-- tests/libtest/lib570.c | 17 +++++++++++++++-- tests/libtest/lib571.c | 17 +++++++++++++++-- tests/libtest/lib572.c | 19 ++++++++++++++++--- tests/libtest/lib573.c | 17 +++++++++++++++-- tests/libtest/lib574.c | 17 +++++++++++++++-- tests/libtest/lib575.c | 17 +++++++++++++++-- tests/libtest/lib576.c | 17 +++++++++++++++-- tests/libtest/lib578.c | 17 +++++++++++++++-- tests/libtest/lib579.c | 17 +++++++++++++++-- tests/libtest/lib582.c | 18 +++++++++++++++--- tests/libtest/sethostname.c | 17 +++++++++++++++-- tests/libtest/sethostname.h | 17 +++++++++++++++-- tests/libtest/test.h | 17 +++++++++++++++-- 65 files changed, 989 insertions(+), 173 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c index 72c8b6a1f..58930467f 100644 --- a/tests/libtest/chkhostname.c +++ b/tests/libtest/chkhostname.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "setup.h" #include "curl_gethostname.h" diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 53b372ba5..a6f8e3cc2 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_LOCALE_H diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index dc6967cbe..b88bfd8bc 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index 770cf8f74..26275f977 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index f6be5aaf7..9ade12afb 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "testutil.h" diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 2301186af..d6ef58a00 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index b8091f66a..55ad5ff31 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 5af7ac0bb..0a255d673 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_SYS_SOCKET_H diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 9209056dd..6476b9546 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 #include diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 012d8f454..a52fabec1 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "testutil.h" diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 0fa5eb9d2..1aca064e9 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index f3f8cdbc0..779164ad5 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index dea97c5e2..6be2d2f76 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index 9f59f7baf..19da18b4f 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index c85006e1d..c013ac258 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 283f89e4b..953e90dff 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index 2660ae369..4e96c4a8d 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index b796dbbb7..a9590948d 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 38a65d30b..9e0a91f16 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 9e683d956..c483d7ade 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_SYS_TYPES_H diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index f885c5de6..b720c8fee 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index a0e124489..9ffaa4f92 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index 9e79cb41e..93c306864 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index a1ac4a4e9..0fdc83db6 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index ee520628b..6f56df9b0 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index ade637012..2765897fd 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 0418b6ba2..27b87bdd8 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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. + * + ***************************************************************************/ /* * This code sets up multiple easy handles that transfer a single file from * the same URL, in a serial manner after each other. Due to the connection diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index abefc92d3..2ec67f61b 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_SYS_TYPES_H diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 89ac7bf89..62ce2cdb9 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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. + * + ***************************************************************************/ /* used for test case 533, 534 and 535 */ #include "test.h" diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index e0c19f661..6e3e7571c 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 842dbab77..97119129b 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_SYS_TYPES_H diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index 9909d01d1..923893fb2 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -1,12 +1,24 @@ -/***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - */ - +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index bf4cd5225..32d2342d5 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -1,12 +1,25 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * This is the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl + * 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 the 'proxyauth.c' test app posted by Shmulik Regev on the libcurl * mailing list on 10 Jul 2007, converted to a test case. * * argv1 = URL diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index 2fc85b97d..6af7bc5cf 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_SYS_SOCKET_H diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index ef7b483b4..efe8ea24e 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" #ifdef HAVE_SYS_SOCKET_H diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 8f14f8411..08d9c4544 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -1,13 +1,25 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * Based on Alex Fishman's bug report on September 30, 2007 - */ + * 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. + * + ***************************************************************************/ +/* Based on Alex Fishman's bug report on September 30, 2007 */ #include "test.h" diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 6bc899cc5..b766187f2 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 4ef303726..c82bc3f23 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -1,12 +1,25 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * argv1 = URL + * 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. + * + ***************************************************************************/ +/* argv1 = URL * argv2 = proxy * argv3 = proxyuser:password */ diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index 9fd18b225..a1568c88f 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -1,12 +1,25 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * argv1 = URL + * 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. + * + ***************************************************************************/ +/* argv1 = URL * argv2 = proxy * argv3 = non-zero means ASCII transfer */ diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index eeecf6f91..fb8b14bc2 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -1,12 +1,25 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * argv1 = URL + * 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. + * + ***************************************************************************/ +/* argv1 = URL * argv2 = proxy with embedded user+password */ diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 8694daf67..cb1cefd5e 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -1,12 +1,26 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * This test case and code is based on the bug recipe Joe Malicki provided for + * 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 test case and code is based on the bug recipe Joe Malicki provided for * bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release. */ diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index d7c68241a..d510268e7 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 55b3f13ed..c67501521 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -1,12 +1,26 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * This test case is supposed to be identical to 547 except that this uses the + * 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 test case is supposed to be identical to 547 except that this uses the * multi interface and 547 is easy interface. * * argv1 = URL diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 78d123baa..da29a4678 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 48ccaf38e..dc3bcae86 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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. + * + ***************************************************************************/ /* * The purpose of this test is to minimally exercise libcurl's internal diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 87e854555..081ad738f 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" /* diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index acdd79aab..657a2d3cd 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index d33f23042..c4495f517 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c index 889f15b3a..4aa6d98e9 100644 --- a/tests/libtest/lib566.c +++ b/tests/libtest/lib566.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c index e1df0c1e4..7466e7475 100644 --- a/tests/libtest/lib567.c +++ b/tests/libtest/lib567.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "memdebug.h" diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 1f16664cb..df0cd88d1 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index b5182d64c..366e4c344 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 9fe2eceaa..29d30dbef 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 2892211aa..1b2bf7b74 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 18e74d4db..b54877cd4 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -1,11 +1,24 @@ - -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| - */ + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 5edb1814a..466185844 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c index 69b2979a8..8c5781609 100644 --- a/tests/libtest/lib574.c +++ b/tests/libtest/lib574.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index 521720e95..bb075dc1f 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 821eb61ac..48841b59d 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "testutil.h" diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c index 2efb003ae..51ead8722 100644 --- a/tests/libtest/lib578.c +++ b/tests/libtest/lib578.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index 2b80ab0b6..ad8ba7e97 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 804641e3a..fe777aced 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index 3dabb8231..daf94f95c 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "setup.h" diff --git a/tests/libtest/sethostname.h b/tests/libtest/sethostname.h index 83034a536..e2633dd7f 100644 --- a/tests/libtest/sethostname.h +++ b/tests/libtest/sethostname.h @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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. + * + ***************************************************************************/ #if (defined(WIN32) || defined(__SYMBIAN32__)) && !defined(CURL_STATICLIB) # if defined(BUILDING_LIBCURL) diff --git a/tests/libtest/test.h b/tests/libtest/test.h index d5a099e25..e9638a240 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -1,11 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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. + * + ***************************************************************************/ /* Now include the setup.h file from libcurl's private libdir (the source version, but that might include "curl_config.h" from the build dir so we -- cgit v1.2.1 From 7612ca2a7e9f0230ab4166e8b0a5abb2557d242c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 12 Mar 2011 23:01:16 +0100 Subject: test582: improved info messages --- tests/libtest/lib582.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index fe777aced..7f87f1d15 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -28,7 +28,7 @@ #include "testutil.h" #include "memdebug.h" -#define MAIN_LOOP_HANG_TIMEOUT 10 * 1000 +#define MAIN_LOOP_HANG_TIMEOUT 4 * 1000 struct Sockets { @@ -44,11 +44,12 @@ struct ReadWriteSockets /** * Remove a file descriptor from a sockets array. */ -static void removeFd(struct Sockets* sockets, curl_socket_t fd) +static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention) { int i; - fprintf(stderr, "Remove socket fd %d\n", (int) fd); + if(mention) + fprintf(stderr, "Remove socket fd %d\n", (int) fd); for (i = 0; i < sockets->count; ++i) { if (sockets->sockets[i] == fd) { @@ -62,14 +63,14 @@ static void removeFd(struct Sockets* sockets, curl_socket_t fd) /** * Add a file descriptor to a sockets array. */ -static void addFd(struct Sockets* sockets, curl_socket_t fd) +static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what) { /** * To ensure we only have each file descriptor once, we remove it then add * it again. */ - fprintf(stderr, "Add socket fd %d\n", (int) fd); - removeFd(sockets, fd); + 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)); sockets->sockets[sockets->count] = fd; @@ -88,14 +89,15 @@ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, (void)socketp; /* unused */ if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) - addFd(&sockets->read, s); - else - removeFd(&sockets->read, s); + addFd(&sockets->read, s, "read"); if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) - addFd(&sockets->write, s); - else - removeFd(&sockets->write, s); + addFd(&sockets->write, s, "write"); + + if(action == CURL_POLL_REMOVE) { + removeFd(&sockets->read, s, 1); + removeFd(&sockets->write, s, 0); + } return 0; } @@ -241,6 +243,7 @@ int test(char *URL) fclose(hd_src); return -1; } + 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"); @@ -358,8 +361,10 @@ test_cleanup: if(m) curl_multi_remove_handle(m, curl); curl_easy_cleanup(curl); - if(m) + if(m) { + fprintf(stderr, "Now multi-cleanup!\n"); curl_multi_cleanup(m); + } fclose(hd_src); /* close the local file */ if (sockets.read.sockets != 0) -- cgit v1.2.1 From 0718b7e31ecb429ce3de7a98e725750b518f489a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 13 Mar 2011 00:18:04 +0100 Subject: test583: verify early SSH multi remove handle This test case is meant to verify that the logic in commit 60172a0446bbe3f8b actually works. This test failed for me before that change and it works after it. --- tests/libtest/Makefile.inc | 17 ++++++----- tests/libtest/lib583.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 tests/libtest/lib583.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index c68f5af52..a210cbfe3 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -5,14 +5,14 @@ TESTUTIL = testutil.c testutil.h SUPPORTFILES = first.c test.h # These are all libcurl test programs -noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ - lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ - lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib574 lib575 lib576 lib578 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 chkhostname +noinst_PROGRAMS = chkhostname \ + lib500 lib501 lib502 lib503 lib504 lib505 lib506 lib507 lib508 lib510 \ + lib511 lib512 lib513 lib514 lib515 lib516 lib517 lib518 lib519 lib520 \ + lib521 lib523 lib524 lib525 lib526 lib527 lib574 lib575 lib576 lib578 \ + 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 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -159,3 +159,4 @@ lib579_SOURCES = lib579.c $(SUPPORTFILES) lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) +lib583_SOURCES = lib583.c $(SUPPORTFILES) diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c new file mode 100644 index 000000000..d01d98f1f --- /dev/null +++ b/tests/libtest/lib583.c @@ -0,0 +1,73 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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. + * + ***************************************************************************/ +/* + * This test case is based on the sample code provided by Saqib Ali + * http://curl.haxx.se/mail/lib-2011-03/0066.html + */ + +#include "test.h" + +#include +#include + +int test(char *URL) +{ + CURLMcode retVal; + int stillRunning, retValcm; + CURLM* multiHandle; + CURL* curl; + int res; + + curl_global_init(CURL_GLOBAL_ALL); + + multiHandle = curl_multi_init(); + curl = curl_easy_init(); + + 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"); + + curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + curl_easy_setopt(curl, CURLOPT_URL, URL); + curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)5); + + 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_remove_handle()!\n"); + retVal = curl_multi_remove_handle(multiHandle, curl); + if (retVal == CURLM_OK) + fprintf(stderr, "curl_multi_remove_handle() was successful!\n"); + else + fprintf(stderr, "curl_multi_remove_handle() failed\n"); + +test_cleanup: + + curl_easy_cleanup(curl); + curl_multi_cleanup(multiHandle); + + return res; +} -- cgit v1.2.1 From 5a433a033ffc8b489a8edc14c4505d0c47a63df6 Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Tue, 15 Mar 2011 12:21:58 +0100 Subject: Removed unused var. --- tests/libtest/lib583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index d01d98f1f..f1270e1d3 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -32,7 +32,7 @@ int test(char *URL) { CURLMcode retVal; - int stillRunning, retValcm; + int stillRunning; CURLM* multiHandle; CURL* curl; int res; -- cgit v1.2.1 From 14e8b13a45c4ba3f95d9717f6e84f67367e41ab7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 15 Mar 2011 18:37:35 +0100 Subject: lib582: use curl_socket_t for portability --- tests/libtest/lib582.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 7f87f1d15..b367550cc 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -81,7 +81,7 @@ static void addFd(struct Sockets* sockets, curl_socket_t fd, const char *what) * Callback invoked by curl to poll reading / writing of a socket. */ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, - void *userp, void *socketp) + void *userp, void *socketp) { struct ReadWriteSockets* sockets = userp; @@ -164,7 +164,8 @@ static int getMicroSecondTimeout(struct timeval* timeout) /** * Update a fd_set with all of the sockets in use. */ -static void updateFdSet(struct Sockets* sockets, fd_set* fdset, int* maxFd) +static void updateFdSet(struct Sockets* sockets, fd_set* fdset, + curl_socket_t *maxFd) { int i; for (i = 0; i < sockets->count; ++i) { @@ -191,7 +192,7 @@ 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) + int evBitmask, const char* name) { int i; for (i = 0; i < sockets->count; ++i) @@ -306,7 +307,7 @@ int test(char *URL) while (!checkForCompletion(m, &success)) { fd_set readSet, writeSet; - int maxFd = 0; + curl_socket_t maxFd = 0; struct timeval tv = {10, 0}; if (tutil_tvdiff(tutil_tvnow(), ml_start) > -- cgit v1.2.1 From 82ecc85d9ed0fc05931fb6d6893eda567a3c443f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 18 Apr 2011 09:03:12 +0200 Subject: curl-config: fix --version curl-config --version didn't output the correct version string (bug introduced in commit 0355e33b5f7b234cf3), and unfortunately the test case 1022 that was supposed to check for this was broken. This change fixes the test to detect this problem and it fixes the output. Bug: http://curl.haxx.se/bug/view.cgi?id=3288727 --- tests/libtest/test1022.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index 60eee384c..7fac00e7a 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -22,14 +22,23 @@ my $curlconfigversion; open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n"; $_ = ; chomp; +my $filever=$_; if ( $what eq "version" ) { - /^libcurl ([\.\d]+(-DEV)?)$/ ; - $curlconfigversion = $1; + if($filever =~ /^libcurl ([\.\d]+(-DEV)?)$/) { + $curlconfigversion = $1; + } + else { + $curlconfigversion = "illegal value"; + } } else { # Convert hex version to decimal for comparison's sake - /^(..)(..)(..)$/ ; - $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); + if($filever =~ /^(..)(..)(..)$/) { + $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); + } + else { + $curlconfigversion = "illegal value"; + } # Strip off the -DEV from the curl version if it's there $version =~ s/-DEV$//; -- cgit v1.2.1 From 1b6df743f6335107ee1a09c34ddcd6ab0dc02266 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 20 Apr 2011 14:11:12 -0700 Subject: Fixed test 1022 when using daily snapshots --- tests/libtest/test1022.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index 7fac00e7a..bd777a5e8 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -12,7 +12,7 @@ my $what=$ARGV[2]; open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n"; $_ = ; chomp; -/libcurl\/([\.\d]+(-DEV)?)/; +/libcurl\/([\.\d]+((-DEV)|(-\d+))?)/; my $version = $1; close CURL; @@ -24,7 +24,7 @@ $_ = ; chomp; my $filever=$_; if ( $what eq "version" ) { - if($filever =~ /^libcurl ([\.\d]+(-DEV)?)$/) { + if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) { $curlconfigversion = $1; } else { -- cgit v1.2.1 From d8373cb9929e4453aba44d9d146ad107e72fc153 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 21 Apr 2011 14:47:35 -0700 Subject: Fixed test 1023 when using daily snapshots --- tests/libtest/test1022.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1022.pl b/tests/libtest/test1022.pl index bd777a5e8..377808c73 100755 --- a/tests/libtest/test1022.pl +++ b/tests/libtest/test1022.pl @@ -31,7 +31,7 @@ if ( $what eq "version" ) { $curlconfigversion = "illegal value"; } } -else { +else { # "vernum" case # Convert hex version to decimal for comparison's sake if($filever =~ /^(..)(..)(..)$/) { $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3); @@ -41,7 +41,7 @@ else { } # Strip off the -DEV from the curl version if it's there - $version =~ s/-DEV$//; + $version =~ s/-\w*$//; } close CURLCONFIG; -- cgit v1.2.1 From 873d70a6d8863346f4b70001b5a3d6d161086171 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 May 2011 21:48:14 +0200 Subject: tests: verify OPEN/CLOSESOCKETFUNCTION Test 585 and 586 were added. Using a modified lib500.c --- tests/libtest/Makefile.inc | 5 ++++- tests/libtest/lib500.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'tests/libtest') 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) { -- cgit v1.2.1 From b57853450802dd3d9a7bce9fb75dc644e912fdad Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 May 2011 22:28:28 +0200 Subject: tests: verify OPEN/CLOSESOCKETFUNCTION Test 585: Fix opensocket return type, and avoid function name clash. --- tests/libtest/lib500.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 166bb85ab..bca5c2310 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -27,9 +27,9 @@ int counter; -static int opensocket(void *clientp, - curlsocktype purpose, - struct curl_sockaddr *addr) +static curl_socket_t tst_opensocket(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *addr) { (void)clientp; (void)purpose; @@ -37,7 +37,7 @@ static int opensocket(void *clientp, return socket(addr->family, addr->socktype, addr->protocol); } -static int closesocket(void *clientp, curl_socket_t sock) +static int tst_closesocket(void *clientp, curl_socket_t sock) { (void)clientp; printf("[CLOSE] counter: %d\n", counter--); @@ -46,8 +46,8 @@ static int closesocket(void *clientp, curl_socket_t sock) static void setupcallbacks(CURL *curl) { - curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); - curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); + curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, tst_opensocket); + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, tst_closesocket); counter = 0; } -- cgit v1.2.1 From de70ddb7490e2cb816649ab0f055413a6df3e2ae Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 24 May 2011 17:24:59 +0200 Subject: compiler warning: fix Fix compiler warning: argument is incompatible with corresponding format string conversion --- tests/libtest/lib582.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index b367550cc..3797e87bb 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -129,7 +129,7 @@ static int checkForCompletion(CURLM* curl, int* success) CURLMsg* message; int result = 0; *success = 0; - while ((message = curl_multi_info_read(curl, &numMessages)) != 0) { + while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) { if (message->msg == CURLMSG_DONE) { result = 1; if (message->data.result == CURLE_OK) @@ -139,7 +139,7 @@ static int checkForCompletion(CURLM* curl, int* success) } else { fprintf(stderr, "Got an unexpected message from curl: %i\n", - message->msg); + (int)message->msg); result = 1; *success = 0; } -- cgit v1.2.1 From 2ea31b0e6f7c0709b4767ed1babeff6b92000282 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 24 May 2011 17:29:50 +0200 Subject: compiler warning: fix Fix compiler warning: external definition with no prior declaration --- tests/libtest/lib500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index bca5c2310..8ebeb1292 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -25,7 +25,7 @@ #ifdef LIB585 -int counter; +static int counter; static curl_socket_t tst_opensocket(void *clientp, curlsocktype purpose, -- cgit v1.2.1 From 9f390a356ea464183cc11ef44c48968ccdcd36ac Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 25 May 2011 20:22:46 +0200 Subject: unit tests: build adjustment Also define UNITTESTS macro when building unit test sources. Fixing compiler warning: external definition with no prior declaration --- tests/libtest/first.c | 3 +++ tests/libtest/test.h | 3 +++ 2 files changed, 6 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index a6f8e3cc2..205d3943f 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -49,7 +49,10 @@ char *libtest_arg2=NULL; char *libtest_arg3=NULL; int test_argc; char **test_argv; + +#ifdef UNITTESTS int unitfail; /* for unittests */ +#endif int main(int argc, char **argv) { diff --git a/tests/libtest/test.h b/tests/libtest/test.h index e9638a240..33d7bed83 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -73,3 +73,6 @@ extern int select_test(int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, extern int test(char *URL); /* the actual test function provided by each individual libXXX.c file */ +#ifdef UNITTESTS +extern int unitfail; +#endif -- cgit v1.2.1 From 5d39dea3b3a355d691c819706ad67f2806b21e9f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 26 May 2011 12:40:04 +0200 Subject: compiler warning: fix Fix compiler warning: variable was set but never used Fix compiler warning: clobber ignored --- tests/libtest/Makefile.inc | 35 +++++++++++++++++++---------------- tests/libtest/lib503.c | 1 + tests/libtest/lib504.c | 1 + tests/libtest/lib507.c | 1 + tests/libtest/lib525.c | 1 + tests/libtest/lib526.c | 1 + tests/libtest/lib530.c | 1 + tests/libtest/lib533.c | 1 + tests/libtest/lib536.c | 1 + tests/libtest/lib540.c | 1 + tests/libtest/lib560.c | 2 ++ tests/libtest/lib564.c | 1 + tests/libtest/lib575.c | 1 + tests/libtest/lib582.c | 1 + 14 files changed, 33 insertions(+), 16 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 06cda1e92..d8cda570f 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -1,6 +1,9 @@ # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h +# files used only in some libcurl test programs +WARNLESS = $(top_srcdir)/lib/warnless.c $(top_srcdir)/lib/warnless.h + # these files are used in every single test program below SUPPORTFILES = first.c test.h @@ -25,15 +28,15 @@ lib501_SOURCES = lib501.c $(SUPPORTFILES) lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) -lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) +lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) +lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib505_SOURCES = lib505.c $(SUPPORTFILES) lib506_SOURCES = lib506.c $(SUPPORTFILES) -lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) +lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib508_SOURCES = lib508.c $(SUPPORTFILES) @@ -65,32 +68,32 @@ lib523_SOURCES = lib523.c $(SUPPORTFILES) lib524_SOURCES = lib524.c $(SUPPORTFILES) -lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) +lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) +lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib526_CFLAGS = -DLIB526 -lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) +lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib527_CFLAGS = -DLIB527 -lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) +lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib529_CFLAGS = -DLIB529 -lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) +lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib530_CFLAGS = -DLIB530 -lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) +lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib532_CFLAGS = -DLIB532 -lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) +lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) +lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib537_SOURCES = lib537.c $(SUPPORTFILES) lib539_SOURCES = lib539.c $(SUPPORTFILES) -lib540_SOURCES = lib540.c $(SUPPORTFILES) +lib540_SOURCES = lib540.c $(SUPPORTFILES) $(WARNLESS) lib541_SOURCES = lib541.c $(SUPPORTFILES) @@ -122,17 +125,17 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) -lib560_SOURCES = lib560.c $(SUPPORTFILES) +lib560_SOURCES = lib560.c $(SUPPORTFILES) $(WARNLESS) lib574_SOURCES = lib574.c $(SUPPORTFILES) -lib575_SOURCES = lib575.c $(SUPPORTFILES) +lib575_SOURCES = lib575.c $(SUPPORTFILES) $(WARNLESS) lib576_SOURCES = lib576.c $(SUPPORTFILES) lib562_SOURCES = lib562.c $(SUPPORTFILES) -lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) +lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib565_SOURCES = lib510.c $(SUPPORTFILES) lib565_CFLAGS = -DLIB565 @@ -157,7 +160,7 @@ lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) -lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) +lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib583_SOURCES = lib583.c $(SUPPORTFILES) diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index d6ef58a00..25a641548 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -24,6 +24,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 55ad5ff31..f45ac256b 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -24,6 +24,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index a52fabec1..c5a009d8c 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -22,6 +22,7 @@ #include "test.h" #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 2765897fd..f034050eb 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -26,6 +26,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 27b87bdd8..a0085ec3c 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -45,6 +45,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 2ec67f61b..add64ea31 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -32,6 +32,7 @@ #endif #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 62ce2cdb9..606eba75c 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -28,6 +28,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 6e3e7571c..dca880cea 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -26,6 +26,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 32d2342d5..55457dd46 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -30,6 +30,7 @@ #include "test.h" +#include "warnless.h" #include "memdebug.h" #define PROXY libtest_arg2 diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 081ad738f..e375be535 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -21,6 +21,8 @@ ***************************************************************************/ #include "test.h" +#include "warnless.h" + /* * Simply download a HTTPS file! * diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index c4495f517..d831d21e1 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -27,6 +27,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index bb075dc1f..4d0b16576 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -27,6 +27,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" /* 3x download! diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 3797e87bb..3b7f1afee 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -26,6 +26,7 @@ #include #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 4 * 1000 -- cgit v1.2.1 From 685359d4c3881acdb4f11285bd77d56a867e09c9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 1 Jun 2011 14:43:25 +0200 Subject: makefile: avoid preprocessor definition usage when linking --- tests/libtest/Makefile.inc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index d8cda570f..98e33c1f1 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -71,19 +71,19 @@ lib524_SOURCES = lib524.c $(SUPPORTFILES) lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib526_CFLAGS = -DLIB526 +lib526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB526 lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib527_CFLAGS = -DLIB527 +lib527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB527 lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib529_CFLAGS = -DLIB529 +lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529 lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib530_CFLAGS = -DLIB530 +lib530_CPPFLAGS = $(AM_CPPFLAGS) -DLIB530 lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib532_CFLAGS = -DLIB532 +lib532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB532 lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) @@ -104,12 +104,12 @@ lib543_SOURCES = lib543.c $(SUPPORTFILES) lib544_SOURCES = lib544.c $(SUPPORTFILES) lib545_SOURCES = lib544.c $(SUPPORTFILES) -lib545_CFLAGS = -DLIB545 +lib545_CPPFLAGS = $(AM_CPPFLAGS) -DLIB545 lib547_SOURCES = lib547.c $(SUPPORTFILES) lib548_SOURCES = lib547.c $(SUPPORTFILES) -lib548_CFLAGS = -DLIB548 +lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548 lib549_SOURCES = lib549.c $(SUPPORTFILES) @@ -138,7 +138,7 @@ lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib565_SOURCES = lib510.c $(SUPPORTFILES) -lib565_CFLAGS = -DLIB565 +lib565_CPPFLAGS = $(AM_CPPFLAGS) -DLIB565 lib566_SOURCES = lib566.c $(SUPPORTFILES) @@ -165,4 +165,4 @@ lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib583_SOURCES = lib583.c $(SUPPORTFILES) lib585_SOURCES = lib500.c $(SUPPORTFILES) -lib585_CFLAGS = -DLIB585 +lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 -- cgit v1.2.1 From 950fb3efcc929d3f5a26852c4f64ccd038ce43a0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 11 Jun 2011 23:01:09 +0200 Subject: write: add return code checks when used These were just warnings in test code but it still makes it nicer to not generate them. --- tests/libtest/lib556.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index da29a4678..67da87f40 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -84,9 +84,11 @@ int test(char *URL) sleep(1); /* avoid ctl-10 dump */ #endif - if(iolen) + if(iolen) { /* send received stuff to stdout */ - write(STDOUT_FILENO, buf, iolen); + if(!write(STDOUT_FILENO, buf, iolen)) + break; + } total += iolen; } while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129)); -- cgit v1.2.1 From f851f768578dc096c561d57ba07ffd1004d504c0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 17 Jun 2011 22:21:36 +0200 Subject: CURLFORM_STREAM: acknowledge CURLFORM_FILENAME The CURLFORM_STREAM is documented to only insert a file name (and thus look like a file upload) in the part if CURLFORM_FILENAME is set, but in reality it always inserted a filename="" and if CURLFORM_FILENAME wasn't set, it would insert insert rubbish (or possibly crash). This is now fixed to work as documented, and test 554 has been extended to verify this. Reported by: Sascha Swiercy Bug: http://curl.haxx.se/mail/lib-2011-06/0070.html --- tests/libtest/lib554.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index d510268e7..ed8d13f05 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -64,6 +64,7 @@ int test(char *URL) struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; struct WriteThis pooh; + struct WriteThis pooh2; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -85,6 +86,23 @@ int test(char *URL) if(formrc) printf("curl_formadd(1) = %d\n", (int)formrc); + /* Now add the same data with another name and make it not look like + a file upload but still using the callback */ + + pooh2.readptr = data; + pooh2.sizeleft = strlen(data); + + /* Fill in the file upload field */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "callbackdata", + CURLFORM_STREAM, &pooh2, + CURLFORM_CONTENTSLENGTH, pooh2.sizeleft, + CURLFORM_END); + + if(formrc) + printf("curl_formadd(1) = %d\n", (int)formrc); + /* Fill in the filename field */ formrc = curl_formadd(&formpost, &lastptr, -- cgit v1.2.1 From 57d51be60c0bb299a30ae5b4c66d9a7113e7586b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 21 Jun 2011 23:18:05 +0200 Subject: parsedate: detect more invalid dates better --- tests/libtest/lib517.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 9e0a91f16..8502e9521 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -110,7 +110,11 @@ static const char *dates[]={ "Thu, 12-Aug-2007 20:61:99999999999 GMT", "IAintNoDateFool", "Thu Apr 18 22:50 2007 GMT", /* without seconds */ - + "20110623 12:34:56", + "20110632 12:34:56", + "20110623 56:34:56", + "20111323 12:34:56", + "20110623 12:34:79", NULL }; -- cgit v1.2.1 From 43ce5580a85498185af29b96fa0891b96fca3a2f Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 23 Jun 2011 21:20:29 -0700 Subject: Added a leap second test to test517 --- tests/libtest/lib517.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 8502e9521..ba49ec41e 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -23,7 +23,7 @@ #include "memdebug.h" -static const char *dates[]={ +static const char * const dates[]={ "Sun, 06 Nov 1994 08:49:37 GMT", "Sunday, 06-Nov-94 08:49:37 GMT", "Sun Nov 6 08:49:37 1994", @@ -115,6 +115,7 @@ static const char *dates[]={ "20110623 56:34:56", "20111323 12:34:56", "20110623 12:34:79", + "Wed, 31 Dec 2008 23:59:60 GMT", /* leap second */ NULL }; -- cgit v1.2.1 From fb48e2050b558c908c7740d1c4f20fd17fdf7fe6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 26 Jun 2011 23:12:08 +0200 Subject: libtests: stop checking for CURLM_CALL_MULTI_PERFORM CURLM_CALL_MULTI_PERFORM stopped being a valid return code from curl_multi_perform back in 7.20.0. All the libcurl tests are ajusted to this and no longer check for this return code. Makes them simpler. --- tests/libtest/lib503.c | 22 ++++++++--------- tests/libtest/lib504.c | 14 ++++------- tests/libtest/lib507.c | 30 ++++++++++------------- tests/libtest/lib525.c | 20 +++++++--------- tests/libtest/lib526.c | 65 +++++++++++++++++++++++--------------------------- tests/libtest/lib530.c | 20 +++++++--------- tests/libtest/lib533.c | 59 ++++++++++++++++++++++----------------------- tests/libtest/lib536.c | 2 -- tests/libtest/lib540.c | 4 +--- tests/libtest/lib560.c | 8 ++----- tests/libtest/lib564.c | 22 +++++++---------- tests/libtest/lib575.c | 6 ++--- tests/libtest/lib582.c | 9 +++---- 13 files changed, 117 insertions(+), 164 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 25a641548..53f8f807b 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -103,18 +103,17 @@ int test(char *URL) 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; - } + 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; @@ -140,7 +139,6 @@ int test(char *URL) break; } - res = CURLM_CALL_MULTI_PERFORM; } if (ml_timedout || mp_timedout) { diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index f45ac256b..e83c66167 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -106,15 +106,11 @@ int test(char *URL) fprintf(stderr, "curl_multi_perform()\n"); - ret = CURLM_CALL_MULTI_PERFORM; - - 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; - } + 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; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index c5a009d8c..e4a1b241b 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -75,14 +75,10 @@ int test(char *URL) 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); + ret = curl_multi_perform(multi, &still_running); + if (tutil_tvdiff(tutil_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) + mp_timedout = TRUE; ml_timedout = FALSE; ml_start = tutil_tvnow(); @@ -116,20 +112,18 @@ int test(char *URL) 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); + ret = curl_multi_perform(multi, &still_running); + if (tutil_tvdiff(tutil_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) + mp_timedout = TRUE; break; } } if (ml_timedout || mp_timedout) { - if (ml_timedout) fprintf(stderr, "ml_timedout\n"); - if (mp_timedout) fprintf(stderr, "mp_timedout\n"); + 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; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index f034050eb..4a79cecc2 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -151,20 +151,16 @@ int test(char *URL) 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; - } + res = (int)curl_multi_perform(m, &running); + if (tutil_tvdiff(tutil_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; } - if (mp_timedout || done) + if (running <= 0) { + done = TRUE; break; + } if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index a0085ec3c..e73eab029 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -149,50 +149,47 @@ int test(char *URL) 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) { + 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) { #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]); #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]); + /* 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); + /* 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]); + /* re-add it */ + res = (int)curl_multi_add_handle(m, curl[0]); #else - res = (int)curl_multi_add_handle(m, curl[current]); + res = (int)curl_multi_add_handle(m, curl[current]); #endif - if(res) { - fprintf(stderr, "add handle failed: %d.\n", res); - res = 243; - break; - } + if(res) { + fprintf(stderr, "add handle failed: %d.\n", res); + res = 243; + break; } - else - done = TRUE; /* bail out */ + } + else { + done = TRUE; /* bail out */ break; } } - if (mp_timedout || done) - break; if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); @@ -215,8 +212,6 @@ int test(char *URL) res = 195; break; } - - res = CURLM_CALL_MULTI_PERFORM; } if (ml_timedout || mp_timedout) { diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index add64ea31..6ad946f2d 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -161,20 +161,16 @@ int test(char *URL) 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; - } + res = (int)curl_multi_perform(m, &running); + if (tutil_tvdiff(tutil_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; } - if (mp_timedout || done) + if (running <= 0) { + done = TRUE; /* bail out */ break; + } if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 606eba75c..5b6d8bf73 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -99,41 +99,38 @@ int test(char *URL) 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; - } + 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 */ + } + else { + done = TRUE; /* bail out */ break; } } - if (mp_timedout || done) - break; if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index dca880cea..7e81351c9 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -59,8 +59,6 @@ static CURLMcode perform(CURLM * multi) switch (code) { case CURLM_OK: break; - case CURLM_CALL_MULTI_PERFORM: - continue; default: return code; } diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 55457dd46..6647ab399 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -87,9 +87,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, while (U) { - do { - code = curl_multi_perform(cm, &U); - } while (code == CURLM_CALL_MULTI_PERFORM); + code = curl_multi_perform(cm, &U); if (U) { FD_ZERO(&R); diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index e375be535..851d5d193 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -63,9 +63,7 @@ int test(char *URL) curl_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); + code = curl_multi_perform(multi_handle, &still_running); while(still_running) { struct timeval timeout; @@ -100,9 +98,7 @@ int test(char *URL) case 0: default: /* timeout or readable/writable sockets */ - do { - code = curl_multi_perform(multi_handle, &still_running); - } while(code == CURLM_CALL_MULTI_PERFORM); + code = curl_multi_perform(multi_handle, &still_running); break; } } diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index d831d21e1..96504bd3d 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -98,20 +98,16 @@ int test(char *URL) 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; - } + res = (int)curl_multi_perform(m, &running); + if (tutil_tvdiff(tutil_tvnow(), mp_start) > + MULTI_PERFORM_HANG_TIMEOUT) { + mp_timedout = TRUE; + break; } - if (mp_timedout || done) + if (running <= 0) { + done = TRUE; /* bail out */ break; + } if (res != CURLM_OK) { fprintf(stderr, "not okay???\n"); @@ -134,8 +130,6 @@ int test(char *URL) res = 195; break; } - - res = CURLM_CALL_MULTI_PERFORM; } if (ml_timedout || mp_timedout) { diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index 4d0b16576..bb84b1a1c 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -81,8 +81,7 @@ int test(char *URL) curl_multi_add_handle(mhandle, handle); - while(CURLM_CALL_MULTI_PERFORM == - curl_multi_perform(mhandle, &still_running)); + curl_multi_perform(mhandle, &still_running); while(still_running) { static struct timeval timeout = /* 100 ms */ { 0, 100000L }; @@ -108,8 +107,7 @@ int test(char *URL) goto test_cleanup; } else { - while(CURLM_CALL_MULTI_PERFORM == - curl_multi_perform(mhandle, &still_running)); + curl_multi_perform(mhandle, &still_running); } } diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 3b7f1afee..2f8fcd992 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -182,8 +182,7 @@ static void notifyCurl(CURL* curl, curl_socket_t s, int evBitmask, { 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)); } @@ -196,10 +195,8 @@ static void checkFdSet(CURL* 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); } } -- cgit v1.2.1 From ef2176109fca302ed89193716b62c3a7113552a3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 24 Jul 2011 04:39:43 +0200 Subject: errno.h inclusion conditionally done in setup_once.h --- tests/libtest/lib506.c | 1 - tests/libtest/test.h | 1 - 2 files changed, 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 6476b9546..f9d2efd08 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -22,7 +22,6 @@ #include "test.h" #include #include -#include #include diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 33d7bed83..046b5504e 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -33,7 +33,6 @@ #include #include #include -#include #ifdef HAVE_SYS_SOCKET_H #include -- cgit v1.2.1 From 78bbd0eecff23203dd8a1aa2dd76143af9a90b7b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 26 Jul 2011 19:42:16 +0200 Subject: fix compiler warning --- tests/libtest/lib540.c | 3 +-- tests/libtest/lib560.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 6647ab399..8fb409f07 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -76,7 +76,6 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, struct curl_slist *headers) { CURLMsg *msg; - CURLMcode code; long L; int M, Q, U = -1; fd_set R, W, E; @@ -87,7 +86,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, while (U) { - code = curl_multi_perform(cm, &U); + (void) curl_multi_perform(cm, &U); if (U) { FD_ZERO(&R); diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 851d5d193..a91d863ab 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -37,7 +37,6 @@ int test(char *URL) { CURL *http_handle; CURLM *multi_handle = NULL; - CURLMcode code; int res; int still_running; /* keep number of running handles */ @@ -63,7 +62,7 @@ int test(char *URL) curl_multi_add_handle(multi_handle, http_handle); /* we start some action by calling perform right away */ - code = curl_multi_perform(multi_handle, &still_running); + (void) curl_multi_perform(multi_handle, &still_running); while(still_running) { struct timeval timeout; @@ -98,7 +97,7 @@ int test(char *URL) case 0: default: /* timeout or readable/writable sockets */ - code = curl_multi_perform(multi_handle, &still_running); + (void) curl_multi_perform(multi_handle, &still_running); break; } } -- cgit v1.2.1 From 45d883d88df76af778ce7024912d3fdd08d13859 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Aug 2011 10:21:03 +0200 Subject: CURLFORM_BUFFER: insert filename as documented A regression where CURLFORM_BUFFER stopped to properly insert the file name part in the formpart. Bug introduced in commit f851f768578dc096. Added CURLFORM_BUFFER use to test 554 to verify this. Bug: http://curl.haxx.se/mail/lib-2011-07/0176.html Reported by: Henry Ludemann --- tests/libtest/lib554.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index ed8d13f05..8e71c8899 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -136,6 +136,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); -- cgit v1.2.1 From aaab5fa299e13c0c3abba929cb187a8ec3b006f9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 20 Aug 2011 17:26:02 +0200 Subject: MemoryTracking: adjust initialization calling Calling of curl_memdebug() was still done with a pending free() --- tests/libtest/first.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 205d3943f..3785fd997 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -54,24 +54,25 @@ char **test_argv; 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 +81,17 @@ int main(int argc, char **argv) curl_memlimit(num); curl_free(env); } +} +#else +# define memory_tracking_init(x) #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 -- cgit v1.2.1 From 838dd8f594dad1b13e89917ac5aa59794c44921d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 21 Aug 2011 06:10:52 +0200 Subject: MemoryTracking: adjust initialization calling - followup Fix macro definition --- tests/libtest/first.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 3785fd997..f35528f71 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -83,7 +83,7 @@ static void memory_tracking_init(void) } } #else -# define memory_tracking_init(x) +# define memory_tracking_init() #endif int main(int argc, char **argv) -- cgit v1.2.1 From 3445fa2e3f28b359a3acd2a884f4e119b11e0a57 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 26 Aug 2011 11:10:58 +0200 Subject: tests: break busy loops in tests 502, 555, and 573 --- tests/libtest/lib502.c | 23 +++++++++++++++++++++-- tests/libtest/lib555.c | 23 +++++++++++++++++++++-- tests/libtest/lib573.c | 23 +++++++++++++++++++++-- 3 files changed, 63 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 9ade12afb..9040b2be3 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -73,6 +73,10 @@ int test(char *URL) mp_start = tutil_tvnow(); while (running) { + static struct timeval timeout = /* 100 ms */ { 0, 100000L }; + fd_set fdread, fdwrite, fdexcep; + int maxfd = -1; + res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { @@ -83,11 +87,26 @@ int test(char *URL) fprintf(stderr, "nothing left running.\n"); break; } + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + curl_multi_fdset(m, &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. */ + + if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) { + res = ~CURLM_OK; + break; + } } if (mp_timedout) { - if (mp_timedout) fprintf(stderr, "mp_timedout\n"); - fprintf(stderr, "ABORTING TEST, since it seems " + fprintf(stderr, "mp_timedout\nABORTING TEST, since it seems " "that it would have run forever.\n"); res = TEST_ERR_RUNS_FOREVER; } diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index c67501521..1e73a5a2e 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -135,6 +135,10 @@ int test(char *URL) mp_start = tutil_tvnow(); while (running) { + static struct timeval timeout = /* 100 ms */ { 0, 100000L }; + fd_set fdread, fdwrite, fdexcep; + int maxfd = -1; + res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { @@ -148,11 +152,26 @@ int test(char *URL) fprintf(stderr, "nothing left running.\n"); break; } + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + curl_multi_fdset(m, &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. */ + + if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) { + res = ~CURLM_OK; + break; + } } if (mp_timedout) { - if (mp_timedout) fprintf(stderr, "mp_timedout\n"); - fprintf(stderr, "ABORTING TEST, since it seems " + fprintf(stderr, "mp_timedout\nABORTING TEST, since it seems " "that it would have run forever.\n"); res = TEST_ERR_RUNS_FOREVER; } diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 466185844..b5fafe16e 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -76,6 +76,10 @@ int test(char *URL) mp_start = tutil_tvnow(); while (running) { + static struct timeval timeout = /* 100 ms */ { 0, 100000L }; + fd_set fdread, fdwrite, fdexcep; + int maxfd = -1; + res = (int)curl_multi_perform(m, &running); if (tutil_tvdiff(tutil_tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { @@ -86,11 +90,26 @@ int test(char *URL) fprintf(stderr, "nothing left running.\n"); break; } + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + curl_multi_fdset(m, &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. */ + + if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) { + res = ~CURLM_OK; + break; + } } if (mp_timedout) { - if (mp_timedout) fprintf(stderr, "mp_timedout\n"); - fprintf(stderr, "ABORTING TEST, since it seems " + fprintf(stderr, "mp_timedout\nABORTING TEST, since it seems " "that it would have run forever.\n"); res = TEST_ERR_RUNS_FOREVER; } -- cgit v1.2.1 From 6b75d2c2df7209919a70a29a4479625b62fb3c28 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Sep 2011 16:06:10 +0200 Subject: fix a bunch of MSVC compiler warnings --- tests/libtest/first.c | 2 +- tests/libtest/lib500.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index f35528f71..d6b486003 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -83,7 +83,7 @@ static void memory_tracking_init(void) } } #else -# define memory_tracking_init() +# define memory_tracking_init() Curl_nop_stmt #endif int main(int argc, char **argv) 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 -- cgit v1.2.1 From c8ba8740b9c3e7a5054c2d7ba5689778aa26618b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 6 Sep 2011 17:47:54 +0200 Subject: test suite: libtest header inclusion cleanup Added missing memoryTracking to test cases 560 and 583. If this triggers leak detection on these, it only means that previously it was going unnoticed. --- tests/libtest/lib502.c | 1 + tests/libtest/lib503.c | 2 -- tests/libtest/lib504.c | 2 -- tests/libtest/lib505.c | 6 ------ tests/libtest/lib506.c | 2 -- tests/libtest/lib518.c | 7 +------ tests/libtest/lib525.c | 2 -- tests/libtest/lib526.c | 2 -- tests/libtest/lib530.c | 10 ---------- tests/libtest/lib533.c | 2 -- tests/libtest/lib536.c | 2 -- tests/libtest/lib537.c | 7 +------ tests/libtest/lib541.c | 13 ------------- tests/libtest/lib542.c | 13 ------------- tests/libtest/lib555.c | 1 + tests/libtest/lib560.c | 1 + tests/libtest/lib562.c | 14 -------------- tests/libtest/lib564.c | 3 --- tests/libtest/lib566.c | 1 - tests/libtest/lib567.c | 2 +- tests/libtest/lib568.c | 1 - tests/libtest/lib569.c | 1 - tests/libtest/lib570.c | 1 - tests/libtest/lib571.c | 4 ---- tests/libtest/lib572.c | 1 - tests/libtest/lib573.c | 2 +- tests/libtest/lib574.c | 1 - tests/libtest/lib575.c | 3 --- tests/libtest/lib576.c | 2 +- tests/libtest/lib578.c | 1 - tests/libtest/lib579.c | 1 - tests/libtest/lib582.c | 2 -- tests/libtest/lib583.c | 5 ++++- 33 files changed, 12 insertions(+), 106 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 9040b2be3..e8bfe4744 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -22,6 +22,7 @@ #include "test.h" #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 53f8f807b..763318827 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "test.h" -#include - #include "testutil.h" #include "warnless.h" #include "memdebug.h" diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index e83c66167..70aec38cc 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "test.h" -#include - #include "testutil.h" #include "warnless.h" #include "memdebug.h" 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 #endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif #ifdef HAVE_FCNTL_H #include #endif diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index f9d2efd08..4477eaa50 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -20,8 +20,6 @@ * ***************************************************************************/ #include "test.h" -#include -#include #include 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 -#endif #ifdef HAVE_SYS_RESOURCE_H #include #endif @@ -33,10 +30,8 @@ #ifdef HAVE_LIMITS_H #include #endif -#ifdef HAVE_STRING_H -#include -#endif +#include "warnless.h" #include "memdebug.h" #ifndef FD_SETSIZE diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 4a79cecc2..5814b030e 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "test.h" -#include -#include #include #include "testutil.h" diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index e73eab029..6e16be11b 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -40,8 +40,6 @@ #include "test.h" -#include -#include #include #include "testutil.h" diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 6ad946f2d..03c4a62fa 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -21,16 +21,6 @@ ***************************************************************************/ #include "test.h" -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif - #include "testutil.h" #include "warnless.h" #include "memdebug.h" diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 5b6d8bf73..487e01824 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -23,8 +23,6 @@ #include "test.h" -#include -#include #include #include "testutil.h" diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 7e81351c9..4813145d0 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "test.h" -#include -#include #include #include "testutil.h" 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 -#endif #ifdef HAVE_SYS_RESOURCE_H #include #endif @@ -33,10 +30,8 @@ #ifdef HAVE_LIMITS_H #include #endif -#ifdef HAVE_STRING_H -#include -#endif +#include "warnless.h" #include "memdebug.h" #if !defined(HAVE_POLL_FINE) && \ 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 -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif #ifdef HAVE_FCNTL_H #include #endif -#ifdef HAVE_UNISTD_H -#include -#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 -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif #ifdef HAVE_FCNTL_H #include #endif -#ifdef HAVE_UNISTD_H -#include -#endif - #include "memdebug.h" /* diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 1e73a5a2e..b077927ac 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -30,6 +30,7 @@ #include "test.h" #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000 diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index a91d863ab..cba9aa000 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -22,6 +22,7 @@ #include "test.h" #include "warnless.h" +#include "memdebug.h" /* * Simply download a HTTPS file! 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 -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif #ifdef HAVE_FCNTL_H #include #endif -#ifdef HAVE_UNISTD_H -#include -#endif - #include "memdebug.h" /* diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index 96504bd3d..9bb3c7404 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -19,11 +19,8 @@ * KIND, either express or implied. * ***************************************************************************/ - #include "test.h" -#include -#include #include #include "testutil.h" 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 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 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 -#endif #ifdef HAVE_NETINET_IN_H # include #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 b5fafe16e..1d8602e1f 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -19,10 +19,10 @@ * KIND, either express or implied. * ***************************************************************************/ - #include "test.h" #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define MAIN_LOOP_HANG_TIMEOUT 90 * 1000 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 bb84b1a1c..144d11ce4 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -19,11 +19,8 @@ * KIND, either express or implied. * ***************************************************************************/ - #include "test.h" -#include -#include #include #include "testutil.h" 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 2f8fcd992..a2c78ddd0 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "test.h" -#include -#include #include #include "testutil.h" diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index f1270e1d3..57c9365bc 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -26,9 +26,12 @@ #include "test.h" -#include #include +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + int test(char *URL) { CURLMcode retVal; -- cgit v1.2.1 From f764da8afbda7d2c343b47d091609dc5853ac05a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 6 Sep 2011 17:56:39 +0200 Subject: test case 583: ensure that test failures don't go unnoticed --- tests/libtest/lib583.c | 68 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 18 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index 57c9365bc..fca22d65b 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -34,43 +34,75 @@ int test(char *URL) { - CURLMcode retVal; int stillRunning; CURLM* multiHandle; CURL* curl; + int res1 = 0; int res; - curl_global_init(CURL_GLOBAL_ALL); + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } - multiHandle = curl_multi_init(); - curl = curl_easy_init(); + if((multiHandle = curl_multi_init()) == NULL) { + fprintf(stderr, "curl_multi_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + + if((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + curl_multi_cleanup(multiHandle); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } 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"); - curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + test_setopt(curl, CURLOPT_UPLOAD, 1); + test_setopt(curl, CURLOPT_VERBOSE, 1); + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_INFILESIZE, (long)5); - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)5); + if((res = (int)curl_multi_add_handle(multiHandle, curl)) != CURLM_OK) { + fprintf(stderr, "curl_multi_add_handle() failed, " + "with code %d\n", res); + curl_easy_cleanup(curl); + curl_multi_cleanup(multiHandle); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } - curl_multi_add_handle(multiHandle, curl); - retVal = curl_multi_perform(multiHandle, &stillRunning); - if (retVal != CURLM_OK) - fprintf(stderr, "curl_multi_perform() failed!n"); + /* this tests if removing an easy handle immediately after multi + perform has been called succeeds or not. Logged afterwards */ + + res1 = (int) curl_multi_perform(multiHandle, &stillRunning); + res = (int) curl_multi_remove_handle(multiHandle, curl); - 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"); + if(res1) + fprintf(stderr, "curl_multi_perform() failed, " + "with code %d\n", res1); else - fprintf(stderr, "curl_multi_remove_handle() failed\n"); + fprintf(stderr, "curl_multi_perform() succeeded\n"); + + if(res) + fprintf(stderr, "curl_multi_remove_handle() failed, " + "with code %d\n", res); + else + fprintf(stderr, "curl_multi_remove_handle() succeeded\n"); test_cleanup: curl_easy_cleanup(curl); curl_multi_cleanup(multiHandle); + curl_global_cleanup(); - return res; + if(res) + return res; + else + return res1; } -- cgit v1.2.1 From 774ad4e31d2b7a3e0bb62ac8bbce42f9fe01a2a4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 6 Sep 2011 18:11:11 +0200 Subject: test suite: libtest header inclusion cleanup - follow-up Adjust tests/libtest/Makefile.inc and remove a couple of unused headers from tests/libtest/lib583.c --- tests/libtest/Makefile.inc | 10 +++++----- tests/libtest/lib583.c | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 98e33c1f1..a6f83134c 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -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,7 +89,7 @@ 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) @@ -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) @@ -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) diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index fca22d65b..f6ac06fae 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -28,8 +28,6 @@ #include -#include "testutil.h" -#include "warnless.h" #include "memdebug.h" int test(char *URL) -- cgit v1.2.1 From 653904769492d02317b7ec6274f49938d4a58585 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 6 Sep 2011 19:59:42 +0200 Subject: test case 583: ensure that test failures don't go unnoticed - follow-up --- tests/libtest/lib583.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index f6ac06fae..6fac67d07 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -76,17 +76,18 @@ int test(char *URL) } /* this tests if removing an easy handle immediately after multi - perform has been called succeeds or not. Logged afterwards */ - - res1 = (int) curl_multi_perform(multiHandle, &stillRunning); - res = (int) curl_multi_remove_handle(multiHandle, curl); + perform has been called succeeds or not. */ + fprintf(stderr, "curl_multi_perform()...\n"); + res1 = (int) curl_multi_perform(multiHandle, &stillRunning); if(res1) fprintf(stderr, "curl_multi_perform() failed, " "with code %d\n", res1); else 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); -- cgit v1.2.1 From 28d09cb0f5e553c783c596efea014a6a14b41a65 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 8 Sep 2011 01:22:47 +0200 Subject: lib582.c: fix segfault triggered when torture testing test case 582 --- tests/libtest/lib582.c | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index a2c78ddd0..91c005ed9 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -31,8 +31,9 @@ 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 @@ -52,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; } } @@ -70,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; } @@ -175,8 +198,8 @@ 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); @@ -189,8 +212,8 @@ 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) { @@ -211,7 +234,7 @@ int test(char *URL) 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; @@ -364,9 +387,9 @@ test_cleanup: } fclose(hd_src); /* close the local file */ - if (sockets.read.sockets != 0) + if (sockets.read.sockets) free(sockets.read.sockets); - if (sockets.write.sockets != 0) + if (sockets.write.sockets) free(sockets.write.sockets); curl_global_cleanup(); -- cgit v1.2.1 From 5793bc370c794a10e6ed014cb535a47672842ae6 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Date: Tue, 20 Sep 2011 17:43:54 +0200 Subject: SSL session sharing support added With locking, plus test, plus documentation --- tests/libtest/lib586.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 tests/libtest/lib586.c (limited to 'tests/libtest') 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, , 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 + +#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; +} + -- cgit v1.2.1 From 17f48fe87979f159e2d8769d678641c60f4c0eed Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 7 Oct 2011 20:50:57 +0200 Subject: libcurl: some OOM handling fixes --- tests/libtest/lib540.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 8fb409f07..467e87dc4 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -49,23 +49,45 @@ static int init(CURLM *cm, const char* url, const char* userpwd, } res = curl_easy_setopt(eh, CURLOPT_URL, url); - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + return 1; + } res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + return 1; + } res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + return 1; + } res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + return 1; + } res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + return 1; + } res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + return 1; + } res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ - if(res) return 1; + if(res) { + curl_easy_cleanup(eh); + 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); + curl_easy_cleanup(eh); return 1; /* failure */ } @@ -80,13 +102,16 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, int M, Q, U = -1; fd_set R, W, E; struct timeval T; + CURLMcode rc; if(init(cm, url, userpwd, headers)) return 1; /* failure */ while (U) { - (void) curl_multi_perform(cm, &U); + rc = curl_multi_perform(cm, &U); + if(rc == CURLM_OUT_OF_MEMORY) + return 1; /* failure */ if (U) { FD_ZERO(&R); -- cgit v1.2.1 From a84b8a39224d0c668d80fed561bc89b4144edbb4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 10 Oct 2011 12:27:17 +0200 Subject: lib540.c: OOM handling fixes making test 540 pass torture testing --- tests/libtest/lib540.c | 77 +++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 467e87dc4..e864947c9 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -37,61 +37,60 @@ #define PROXYUSERPWD libtest_arg3 #define HOST test_argv[4] +CURL *eh = NULL; + static int init(CURLM *cm, const char* url, const char* userpwd, struct curl_slist *headers) { - CURL *eh; int res; if ((eh = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); - return 1; /* failure */ + goto init_failed; } res = curl_easy_setopt(eh, CURLOPT_URL, url); - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; + res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; + res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; + res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; + res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; + res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; + res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ - if(res) { - curl_easy_cleanup(eh); - return 1; - } + if(res) + goto init_failed; if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) { - fprintf(stderr, "curl_multi_add_handle() failed, " - "with code %d\n", res); - curl_easy_cleanup(eh); - return 1; /* failure */ + fprintf(stderr, "curl_multi_add_handle() failed, with code %d\n", res); + goto init_failed; } return 0; /* success */ + +init_failed: + if(eh) { + curl_easy_cleanup(eh); + eh = NULL; + } + + return 1; /* failure */ } static int loop(CURLM *cm, const char* url, const char* userpwd, @@ -153,6 +152,7 @@ static int loop(CURLM *cm, const char* url, const char* userpwd, curl_easy_strerror(msg->data.result)); curl_multi_remove_handle(cm, e); curl_easy_cleanup(e); + eh = NULL; } else { fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg); @@ -204,7 +204,14 @@ int test(char *URL) test_cleanup: - curl_multi_cleanup(cm); + if(cm && eh) + curl_multi_remove_handle(cm, eh); + + if(eh) + curl_easy_cleanup(eh); + + if(cm) + curl_multi_cleanup(cm); curl_global_cleanup(); -- cgit v1.2.1 From 840eff44f2bea71acaa2a227998a97d01aacdc1f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 16 Oct 2011 01:07:29 +0200 Subject: formdata: ack read callback abort When doing a multipart formpost with a read callback, and that callback returns CURL_READFUNC_ABORT, that return code must be properly propagated back and handled accordingly. Previously it would be handled as a zero byte read which would cause a hang! Added test case 587 to verify. It uses the lib554.c source code with a small ifdef. Reported by: Anton Bychkov Bug: http://curl.haxx.se/mail/lib-2011-10/0097.html --- tests/libtest/Makefile.inc | 5 ++++- tests/libtest/lib554.c | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index a6f83134c..30883d227 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@ @@ -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/lib554.c b/tests/libtest/lib554.c index 8e71c8899..ba42bc482 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -42,6 +42,14 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { struct WriteThis *pooh = (struct WriteThis *)userp; +#ifdef LIB587 + (void)ptr; + (void)size; + (void)nmemb; + (void)userp; + return CURL_READFUNC_ABORT; +#else + if(size*nmemb < 1) return 0; @@ -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) -- cgit v1.2.1 From cf0f6729e78dce46c14c3e20b7be2195577a7af9 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Wed, 19 Oct 2011 21:18:52 -0700 Subject: Silenced a compiler warning about an unused variable --- tests/libtest/lib554.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index ba42bc482..d20429d91 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -40,8 +40,6 @@ struct WriteThis { static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { - struct WriteThis *pooh = (struct WriteThis *)userp; - #ifdef LIB587 (void)ptr; (void)size; @@ -50,6 +48,8 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) return CURL_READFUNC_ABORT; #else + struct WriteThis *pooh = (struct WriteThis *)userp; + if(size*nmemb < 1) return 0; -- cgit v1.2.1 From 629d2e34508838069db83e1082ce9e7f2c7b8ff8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 21 Oct 2011 16:26:18 +0200 Subject: multi tests: OOM handling fixes Additionally, improved error checking and logging. --- tests/libtest/Makefile.inc | 6 +- tests/libtest/first.c | 20 ++- tests/libtest/lib502.c | 100 +++++--------- tests/libtest/lib503.c | 124 +++++------------ tests/libtest/lib504.c | 118 +++++----------- tests/libtest/lib507.c | 117 +++++----------- tests/libtest/lib525.c | 163 ++++++++-------------- tests/libtest/lib526.c | 200 ++++++++++----------------- tests/libtest/lib530.c | 167 +++++----------------- tests/libtest/lib533.c | 126 +++++------------ tests/libtest/lib536.c | 149 ++++++++++---------- tests/libtest/lib540.c | 150 +++++++++++--------- tests/libtest/lib555.c | 124 +++++++---------- tests/libtest/lib560.c | 74 +++++----- tests/libtest/lib564.c | 117 +++++----------- tests/libtest/lib573.c | 100 +++++--------- tests/libtest/lib575.c | 82 ++++++----- tests/libtest/lib582.c | 120 ++++++---------- tests/libtest/lib583.c | 79 ++++------- tests/libtest/test.h | 337 ++++++++++++++++++++++++++++++++++++++++++++- 20 files changed, 1086 insertions(+), 1387 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 30883d227..86b3b29ab 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -93,7 +93,7 @@ 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) @@ -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) diff --git a/tests/libtest/first.c b/tests/libtest/first.c index d6b486003..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,6 +56,8 @@ 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 diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index e8bfe4744..554583ae2 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -25,8 +25,7 @@ #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,90 +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(); + multi_add_handle(m, c); - while (running) { - static struct timeval timeout = /* 100 ms */ { 0, 100000L }; + for(;;) { + struct timeval timeout; fd_set fdread, fdwrite, fdexcep; - int maxfd = -1; - - 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; - } + int maxfd = -99; + + timeout.tv_sec = 0; + timeout.tv_usec = 100000L; /* 100 ms */ + + multi_perform(m, &running); + + abort_on_test_timeout(); + + if(!running) + break; /* done */ FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); - curl_multi_fdset(m, &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. */ - - if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) { - res = ~CURLM_OK; - break; - } - } - if (mp_timedout) { - fprintf(stderr, "mp_timedout\nABORTING TEST, since it seems " - "that it would have run forever.\n"); - res = TEST_ERR_RUNS_FOREVER; + 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 763318827..f3f96aaa5 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -25,8 +25,7 @@ #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 @@ -38,121 +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(); - - 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. */ - } + 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 70aec38cc..358fc98dc 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -25,8 +25,7 @@ #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 @@ -37,81 +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 = curl_multi_perform(m, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) { - mp_timedout = TRUE; - break; - } - if (mp_timedout) - break; + multi_perform(m, &running); + + abort_on_test_timeout(); if(!running) { /* This is where this code is expected to reach */ @@ -119,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/lib507.c b/tests/libtest/lib507.c index e4a1b241b..87c21defb 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -25,71 +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); - ret = curl_multi_perform(multi, &still_running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) - mp_timedout = TRUE; + 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); @@ -97,47 +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(); - ret = curl_multi_perform(multi, &still_running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) - mp_timedout = TRUE; - 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/lib525.c b/tests/libtest/lib525.c index 5814b030e..ca128cb9c 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -27,37 +27,39 @@ #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 */ @@ -65,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 @@ -109,110 +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(); - - 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 (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 6e16be11b..9db04dba7 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -46,8 +46,7 @@ #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 @@ -56,109 +55,51 @@ 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; - } - } - - 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; + easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); } - 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; - } + multi_init(m); - 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(); - - 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]); + curl[current] = NULL; #endif if(++current < NUM_HANDLES) { fprintf(stderr, "Advancing to URL %d\n", current); @@ -169,74 +110,75 @@ int test(char *URL) /* 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); + easy_setopt(curl[0], CURLOPT_URL, URL); + /* go verbose */ + easy_setopt(curl[0], CURLOPT_VERBOSE, 1L); /* re-add it */ - res = (int)curl_multi_add_handle(m, curl[0]); + 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; + break; /* done */ } } - if (res != CURLM_OK) { - fprintf(stderr, "not okay???\n"); - break; - } - 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. */ + + 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 03c4a62fa..ad84ff8a5 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -25,8 +25,7 @@ #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 @@ -35,169 +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(); - - 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 (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 487e01824..fdc18a1eb 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -29,81 +29,45 @@ #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(); - - 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) { if(!current++) { fprintf(stderr, "Advancing to URL 1\n"); /* remove the handle we use */ @@ -112,62 +76,36 @@ int test(char *URL) /* 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); + easy_setopt(curl, CURLOPT_URL, libtest_arg2); + easy_setopt(curl, CURLOPT_VERBOSE, 1L); + easy_setopt(curl, CURLOPT_FAILONERROR, 1L); /* 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; + multi_add_handle(m, curl); } - } - - 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(); } 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 4813145d0..e3ae402b7 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -27,118 +27,111 @@ #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; - 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/lib540.c b/tests/libtest/lib540.c index e864947c9..21d14872b 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -30,105 +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] -CURL *eh = NULL; +#define NUM_HANDLES 2 + +CURL *eh[NUM_HANDLES]; -static int init(CURLM *cm, const char* url, const char* userpwd, +static int init(int num, CURLM *cm, const char* url, const char* userpwd, struct curl_slist *headers) { - int res; + int res = 0; - if ((eh = curl_easy_init()) == NULL) { - fprintf(stderr, "curl_easy_init() failed\n"); + res_easy_init(eh[num]); + if(res) goto init_failed; - } - res = curl_easy_setopt(eh, CURLOPT_URL, url); + res_easy_setopt(eh[num], CURLOPT_URL, url); if(res) goto init_failed; - res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY); + res_easy_setopt(eh[num], CURLOPT_PROXY, PROXY); if(res) goto init_failed; - res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd); + res_easy_setopt(eh[num], CURLOPT_PROXYUSERPWD, userpwd); if(res) goto init_failed; - res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); + res_easy_setopt(eh[num], CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); if(res) goto init_failed; - res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L); + res_easy_setopt(eh[num], CURLOPT_VERBOSE, 1L); if(res) goto init_failed; - res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L); + res_easy_setopt(eh[num], CURLOPT_HEADER, 1L); if(res) goto init_failed; - res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */ + res_easy_setopt(eh[num], CURLOPT_HTTPHEADER, headers); /* custom Host: */ if(res) goto init_failed; - if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) { - fprintf(stderr, "curl_multi_add_handle() failed, with code %d\n", res); + res_multi_add_handle(cm, eh[num]); + if(res) goto init_failed; - } return 0; /* success */ init_failed: - if(eh) { - curl_easy_cleanup(eh); - eh = NULL; - } - return 1; /* failure */ + 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; long L; - int M, Q, U = -1; + int Q, U = -1; fd_set R, W, E; struct timeval T; - CURLMcode rc; + 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) { - rc = curl_multi_perform(cm, &U); - if(rc == CURLM_OUT_OF_MEMORY) - return 1; /* failure */ + 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; @@ -139,25 +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); - eh = NULL; + 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 */ @@ -168,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; @@ -182,37 +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); -test_cleanup: + res = loop(1, cm, URL, PROXYUSERPWD, headers); - if(cm && eh) - curl_multi_remove_handle(cm, eh); +test_cleanup: - if(eh) - curl_easy_cleanup(eh); + /* proper cleanup sequence - type PB */ - if(cm) - curl_multi_cleanup(cm); + 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/lib555.c b/tests/libtest/lib555.c index b077927ac..49a81bf57 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -33,7 +33,7 @@ #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" @@ -75,114 +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) { - static struct timeval timeout = /* 100 ms */ { 0, 100000L }; + struct timeval timeout; fd_set fdread, fdwrite, fdexcep; - int maxfd = -1; - - res = (int)curl_multi_perform(m, &running); - if (tutil_tvdiff(tutil_tvnow(), mp_start) > - MULTI_PERFORM_HANG_TIMEOUT) { - mp_timedout = TRUE; - break; - } + 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(!running) + break; /* done */ FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); - curl_multi_fdset(m, &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. */ - - if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) { - res = ~CURLM_OK; - break; - } - } - if (mp_timedout) { - fprintf(stderr, "mp_timedout\nABORTING TEST, since it seems " - "that it would have run forever.\n"); - res = TEST_ERR_RUNS_FOREVER; + 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 cba9aa000..e8be1c7bd 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -21,9 +21,12 @@ ***************************************************************************/ #include "test.h" +#include "testutil.h" #include "warnless.h" #include "memdebug.h" +#define TEST_HANG_TIMEOUT 60 * 1000 + /* * Simply download a HTTPS file! * @@ -36,43 +39,44 @@ */ int test(char *URL) { - CURL *http_handle; + CURL *http_handle = NULL; CURLM *multi_handle = NULL; - 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 */ - (void) curl_multi_perform(multi_handle, &still_running); + 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); @@ -83,31 +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 */ - (void) curl_multi_perform(multi_handle, &still_running); - 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/lib564.c b/tests/libtest/lib564.c index 9bb3c7404..ed00e1bf6 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -27,121 +27,66 @@ #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); - ml_timedout = FALSE; - ml_start = tutil_tvnow(); + multi_init(m); + + 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(); - - 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 (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; - } - - if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) { - fprintf(stderr, "bad select??\n"); - res = 195; - 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"); - 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: + /* 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/lib573.c b/tests/libtest/lib573.c index 1d8602e1f..943f6e8c8 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -25,8 +25,7 @@ #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,84 +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) { - static struct timeval timeout = /* 100 ms */ { 0, 100000L }; + struct timeval timeout; fd_set fdread, fdwrite, fdexcep; - int maxfd = -1; - - 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; - } + int maxfd = -99; + + timeout.tv_sec = 0; + timeout.tv_usec = 100000L; /* 100 ms */ + + multi_perform(m, &running); + + abort_on_test_timeout(); + + if(!running) + break; /* done */ FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); - curl_multi_fdset(m, &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. */ - - if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1) { - res = ~CURLM_OK; - break; - } - } - if (mp_timedout) { - fprintf(stderr, "mp_timedout\nABORTING TEST, since it seems " - "that it would have run forever.\n"); - res = TEST_ERR_RUNS_FOREVER; + 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); @@ -122,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/lib575.c b/tests/libtest/lib575.c index 144d11ce4..942df68c5 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -27,6 +27,8 @@ #include "warnless.h" #include "memdebug.h" +#define TEST_HANG_TIMEOUT 60 * 1000 + /* 3x download! * 1. normal * 2. dup handle @@ -35,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) @@ -70,49 +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); - 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 { - 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/lib582.c b/tests/libtest/lib582.c index 91c005ed9..25b70609c 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -27,7 +27,7 @@ #include "warnless.h" #include "memdebug.h" -#define MAIN_LOOP_HANG_TIMEOUT 4 * 1000 +#define TEST_HANG_TIMEOUT 60 * 1000 struct Sockets { @@ -226,30 +226,30 @@ static void checkFdSet(CURLM *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 = {{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 */ @@ -257,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)) { @@ -329,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); @@ -363,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) @@ -370,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(); - fclose(hd_src); /* close the local file */ - if (sockets.read.sockets) + /* close the local file */ + fclose(hd_src); + + /* free local memory */ + if(sockets.read.sockets) free(sockets.read.sockets); - if (sockets.write.sockets) + 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 6fac67d07..ad5a5cea7 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -33,58 +33,36 @@ int test(char *URL) { int stillRunning; - CURLM* multiHandle; - CURL* curl; - int res1 = 0; - int res; - - if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - fprintf(stderr, "curl_global_init() failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - if((multiHandle = curl_multi_init()) == NULL) { - fprintf(stderr, "curl_multi_init() failed\n"); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - if((curl = curl_easy_init()) == NULL) { - fprintf(stderr, "curl_easy_init() failed\n"); - curl_multi_cleanup(multiHandle); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } - - 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"); - - test_setopt(curl, CURLOPT_UPLOAD, 1); - test_setopt(curl, CURLOPT_VERBOSE, 1); - - test_setopt(curl, CURLOPT_URL, URL); - test_setopt(curl, CURLOPT_INFILESIZE, (long)5); - - if((res = (int)curl_multi_add_handle(multiHandle, curl)) != CURLM_OK) { - fprintf(stderr, "curl_multi_add_handle() failed, " - "with code %d\n", res); - curl_easy_cleanup(curl); - curl_multi_cleanup(multiHandle); - curl_global_cleanup(); - return TEST_ERR_MAJOR_BAD; - } + CURLM* multiHandle = NULL; + CURL* curl = NULL; + int res = 0; + + global_init(CURL_GLOBAL_ALL); + + multi_init(multiHandle); + + easy_init(curl); + + 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"); + + easy_setopt(curl, CURLOPT_UPLOAD, 1L); + easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + easy_setopt(curl, CURLOPT_URL, URL); + easy_setopt(curl, CURLOPT_INFILESIZE, (long)5); + + multi_add_handle(multiHandle, curl); /* this tests if removing an easy handle immediately after multi perform has been called succeeds or not. */ fprintf(stderr, "curl_multi_perform()...\n"); - res1 = (int) curl_multi_perform(multiHandle, &stillRunning); - if(res1) - fprintf(stderr, "curl_multi_perform() failed, " - "with code %d\n", res1); - else - fprintf(stderr, "curl_multi_perform() succeeded\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); @@ -96,12 +74,11 @@ int test(char *URL) test_cleanup: + /* undocumented cleanup sequence - type UB */ + curl_easy_cleanup(curl); curl_multi_cleanup(multiHandle); curl_global_cleanup(); - if(res) - return res; - else - return res1; + return res; } diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 046b5504e..81c435d1f 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -50,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 @@ -66,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 */ @@ -75,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__)) + +/* ---------------------------------------------------------------- */ -- cgit v1.2.1 From 51e5a2bf3fc4b555e118ecede183d7e3d8e4fb88 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 26 Oct 2011 18:46:32 +0200 Subject: multi tests: OOM handling fixes - commit 629d2e34 follow-up --- tests/libtest/lib540.c | 2 ++ tests/libtest/test.h | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 21d14872b..a47f1dee6 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -136,6 +136,8 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd, if(res) return res; + /* At this point, L is guaranteed to be greater or equal than -1. */ + if(L != -1) { T.tv_sec = L/1000; T.tv_usec = (L%1000)*1000; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 81c435d1f..34b8c9f3e 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -95,6 +95,7 @@ extern int unitfail; #define TEST_ERR_USAGE 118 #define TEST_ERR_FOPEN 117 #define TEST_ERR_FSTAT 116 +#define TEST_ERR_BAD_TIMEOUT 115 /* ** Macros for test source code readability/maintainability. @@ -301,14 +302,20 @@ extern int unitfail; /* ---------------------------------------------------------------- */ -#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; \ - } \ +#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; \ + } \ + else if(*((B)) < -1L) { \ + fprintf(stderr, "%s:%d curl_multi_timeout() succeeded, " \ + "but returned invalid timeout value (%ld)\n", \ + (Y), (Z), (long)*((B))); \ + res = TEST_ERR_BAD_TIMEOUT; \ + } \ } WHILE_FALSE #define res_multi_timeout(A,B) \ -- cgit v1.2.1 From 692f344118c42a68cfb2f0b4c8feffb8ef6947c8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 26 Oct 2011 18:55:35 +0200 Subject: test 589: active FTP upload using multi timeout and EPRT disabled server --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib589.c | 110 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib589.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 86b3b29ab..5cfabf487 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 lib587 + lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib587 lib589 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -169,3 +169,5 @@ lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 lib587_SOURCES = lib554.c $(SUPPORTFILES) lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 + +lib589_SOURCES = lib589.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) diff --git a/tests/libtest/lib589.c b/tests/libtest/lib589.c new file mode 100644 index 000000000..4d6fff0d3 --- /dev/null +++ b/tests/libtest/lib589.c @@ -0,0 +1,110 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 60 * 1000 + +int test(char *URL) +{ + CURL *easy = NULL; + CURLM *multi = NULL; + int res = 0; + int running; + int msgs_left; + CURLMsg *msg; + + start_test_timing(); + + global_init(CURL_GLOBAL_ALL); + + easy_init(easy); + + easy_setopt(easy, CURLOPT_URL, URL); + easy_setopt(easy, CURLOPT_VERBOSE, 1L); + easy_setopt(easy, CURLOPT_UPLOAD, 1L); + easy_setopt(easy, CURLOPT_FTPPORT, "-"); + + multi_init(multi); + + multi_add_handle(multi, easy); + + for(;;) { + struct timeval interval; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + long timeout = -99; + int maxfd = -99; + + multi_perform(multi, &running); + + abort_on_test_timeout(); + + if(!running) + break; /* done */ + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + + /* At this point, maxfd is guaranteed to be greater or equal than -1. */ + + multi_timeout(multi, &timeout); + + /* At this point, timeout is guaranteed to be greater or equal than -1. */ + + if(timeout != -1L) { + interval.tv_sec = timeout/1000; + interval.tv_usec = (timeout%1000)*1000; + } + else { + interval.tv_sec = 5; + interval.tv_usec = 0; + } + + select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); + + abort_on_test_timeout(); + } + + msg = curl_multi_info_read(multi, &msgs_left); + if(msg) + res = msg->data.result; + +test_cleanup: + + /* undocumented cleanup sequence - type UA */ + + curl_multi_cleanup(multi); + curl_easy_cleanup(easy); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From 8ccf7bf8d702108aabea152424f2c753467b0101 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 27 Oct 2011 22:00:23 +0200 Subject: lib589.c: add CURLOPT_READDATA missing stuff --- tests/libtest/lib589.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib589.c b/tests/libtest/lib589.c index 4d6fff0d3..9ce36ed15 100644 --- a/tests/libtest/lib589.c +++ b/tests/libtest/lib589.c @@ -37,16 +37,41 @@ int test(char *URL) int running; int msgs_left; CURLMsg *msg; + FILE *upload = NULL; + int error; start_test_timing(); - global_init(CURL_GLOBAL_ALL); + upload = fopen(libtest_arg2, "rb"); + if(!upload) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d (%s)\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2); + return TEST_ERR_FOPEN; + } + + res_global_init(CURL_GLOBAL_ALL); + if(res) { + fclose(upload); + return res; + } easy_init(easy); - easy_setopt(easy, CURLOPT_URL, URL); + /* go verbose */ easy_setopt(easy, CURLOPT_VERBOSE, 1L); + + /* specify target */ + easy_setopt(easy, CURLOPT_URL, URL); + + /* enable uploading */ easy_setopt(easy, CURLOPT_UPLOAD, 1L); + + /* data pointer for the file read function */ + easy_setopt(easy, CURLOPT_READDATA, upload); + + /* use active mode FTP */ easy_setopt(easy, CURLOPT_FTPPORT, "-"); multi_init(multi); @@ -85,8 +110,8 @@ int test(char *URL) interval.tv_usec = (timeout%1000)*1000; } else { - interval.tv_sec = 5; - interval.tv_usec = 0; + interval.tv_sec = 0; + interval.tv_usec = 100000L; /* 100 ms */ } select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); @@ -106,5 +131,8 @@ test_cleanup: curl_easy_cleanup(easy); curl_global_cleanup(); + /* close the local file */ + fclose(upload); + return res; } -- cgit v1.2.1 From 2c09d21fdf16818d406db471de6e0db5d40b4ba2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 6 Nov 2011 17:28:28 +0100 Subject: test 590: verify the bug fix in 4851dafcf1 This test is created to verify Rene Bernhardt's patch which makes sure libcurl properly _not_ deals with Negotiate if not asked to even if the proxy says it can serve it. --- tests/libtest/Makefile.inc | 5 +++- tests/libtest/lib590.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib590.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 5cfabf487..86e5e9999 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -15,7 +15,8 @@ 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 lib587 lib589 + lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib587 lib589 \ + lib590 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -171,3 +172,5 @@ lib587_SOURCES = lib554.c $(SUPPORTFILES) lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 lib589_SOURCES = lib589.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) + +lib590_SOURCES = lib590.c $(SUPPORTFILES) diff --git a/tests/libtest/lib590.c b/tests/libtest/lib590.c new file mode 100644 index 000000000..75c90d53f --- /dev/null +++ b/tests/libtest/lib590.c @@ -0,0 +1,71 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" + +/* + Based on a bug report recipe by Rene Bernhardt in + http://curl.haxx.se/mail/lib-2011-10/0323.html + + It is reproducible by the following steps: + + - Use a proxy that offers NTLM and Negotiate ( CURLOPT_PROXY and + CURLOPT_PROXYPORT ) + - Tell libcurl NOT to use Negotiate CURL_EASY_SETOPT(CURLOPT_PROXYAUTH, + CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM ) + - Start the request +*/ + +#include "memdebug.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + 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; + } + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_PROXYAUTH, + CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM); + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ + test_setopt(curl, CURLOPT_PROXYUSERPWD, "me:password"); + + res = curl_easy_perform(curl); + + test_cleanup: + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From 082e8a3b03d2c47d237994675bface127ab23c29 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 11 Nov 2011 19:46:44 +0100 Subject: Active mode FTP test cases with server not establishing data connection 591 -> FTP multi PORT and 425 on upload 592 -> FTP multi PORT and 421 on upload 593 -> FTP multi PORT upload, no data conn and no transient neg. reply 594 -> FTP multi PORT upload, no data conn and no positive prelim. reply 1206 -> FTP PORT and 425 on download 1207 -> FTP PORT and 421 on download 1208 -> FTP PORT download, no data conn and no transient negative reply 1209 -> FTP PORT download, no data conn and no positive preliminary reply --- tests/libtest/Makefile.inc | 8 +-- tests/libtest/lib589.c | 138 ------------------------------------------- tests/libtest/lib591.c | 143 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 142 deletions(-) delete mode 100644 tests/libtest/lib589.c create mode 100644 tests/libtest/lib591.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 86e5e9999..4a7f78cf2 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -15,8 +15,8 @@ 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 lib587 lib589 \ - lib590 + lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib587 lib590 \ + lib591 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -171,6 +171,6 @@ lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 lib587_SOURCES = lib554.c $(SUPPORTFILES) lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 -lib589_SOURCES = lib589.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) - lib590_SOURCES = lib590.c $(SUPPORTFILES) + +lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) diff --git a/tests/libtest/lib589.c b/tests/libtest/lib589.c deleted file mode 100644 index 9ce36ed15..000000000 --- a/tests/libtest/lib589.c +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 - -#include "testutil.h" -#include "warnless.h" -#include "memdebug.h" - -#define TEST_HANG_TIMEOUT 60 * 1000 - -int test(char *URL) -{ - CURL *easy = NULL; - CURLM *multi = NULL; - int res = 0; - int running; - int msgs_left; - CURLMsg *msg; - FILE *upload = NULL; - int error; - - start_test_timing(); - - upload = fopen(libtest_arg2, "rb"); - if(!upload) { - error = ERRNO; - fprintf(stderr, "fopen() failed with error: %d (%s)\n", - error, strerror(error)); - fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2); - return TEST_ERR_FOPEN; - } - - res_global_init(CURL_GLOBAL_ALL); - if(res) { - fclose(upload); - return res; - } - - easy_init(easy); - - /* go verbose */ - easy_setopt(easy, CURLOPT_VERBOSE, 1L); - - /* specify target */ - easy_setopt(easy, CURLOPT_URL, URL); - - /* enable uploading */ - easy_setopt(easy, CURLOPT_UPLOAD, 1L); - - /* data pointer for the file read function */ - easy_setopt(easy, CURLOPT_READDATA, upload); - - /* use active mode FTP */ - easy_setopt(easy, CURLOPT_FTPPORT, "-"); - - multi_init(multi); - - multi_add_handle(multi, easy); - - for(;;) { - struct timeval interval; - fd_set fdread; - fd_set fdwrite; - fd_set fdexcep; - long timeout = -99; - int maxfd = -99; - - multi_perform(multi, &running); - - abort_on_test_timeout(); - - if(!running) - break; /* done */ - - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcep); - - multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); - - /* At this point, maxfd is guaranteed to be greater or equal than -1. */ - - multi_timeout(multi, &timeout); - - /* At this point, timeout is guaranteed to be greater or equal than -1. */ - - if(timeout != -1L) { - interval.tv_sec = timeout/1000; - interval.tv_usec = (timeout%1000)*1000; - } - else { - interval.tv_sec = 0; - interval.tv_usec = 100000L; /* 100 ms */ - } - - select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); - - abort_on_test_timeout(); - } - - msg = curl_multi_info_read(multi, &msgs_left); - if(msg) - res = msg->data.result; - -test_cleanup: - - /* undocumented cleanup sequence - type UA */ - - curl_multi_cleanup(multi); - curl_easy_cleanup(easy); - curl_global_cleanup(); - - /* close the local file */ - fclose(upload); - - return res; -} diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c new file mode 100644 index 000000000..101f2db26 --- /dev/null +++ b/tests/libtest/lib591.c @@ -0,0 +1,143 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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" + +/* lib591 is used for test cases 591, 592, 593 and 594 */ + +#include + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 60 * 1000 + +int test(char *URL) +{ + CURL *easy = NULL; + CURLM *multi = NULL; + int res = 0; + int running; + int msgs_left; + CURLMsg *msg; + FILE *upload = NULL; + int error; + + start_test_timing(); + + upload = fopen(libtest_arg3, "rb"); + if(!upload) { + error = ERRNO; + fprintf(stderr, "fopen() failed with error: %d (%s)\n", + error, strerror(error)); + fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3); + return TEST_ERR_FOPEN; + } + + res_global_init(CURL_GLOBAL_ALL); + if(res) { + fclose(upload); + return res; + } + + easy_init(easy); + + /* go verbose */ + easy_setopt(easy, CURLOPT_VERBOSE, 1L); + + /* specify target */ + easy_setopt(easy, CURLOPT_URL, URL); + + /* enable uploading */ + easy_setopt(easy, CURLOPT_UPLOAD, 1L); + + /* data pointer for the file read function */ + easy_setopt(easy, CURLOPT_READDATA, upload); + + /* use active mode FTP */ + easy_setopt(easy, CURLOPT_FTPPORT, "-"); + + /* server connection timeout */ + easy_setopt(easy, CURLOPT_CONNECTTIMEOUT, strtol(libtest_arg2, NULL, 10)); + + multi_init(multi); + + multi_add_handle(multi, easy); + + for(;;) { + struct timeval interval; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + long timeout = -99; + int maxfd = -99; + + multi_perform(multi, &running); + + abort_on_test_timeout(); + + if(!running) + break; /* done */ + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + + /* At this point, maxfd is guaranteed to be greater or equal than -1. */ + + multi_timeout(multi, &timeout); + + /* At this point, timeout is guaranteed to be greater or equal than -1. */ + + if(timeout != -1L) { + interval.tv_sec = timeout/1000; + interval.tv_usec = (timeout%1000)*1000; + } + else { + interval.tv_sec = 0; + interval.tv_usec = 100000L; /* 100 ms */ + } + + select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); + + abort_on_test_timeout(); + } + + msg = curl_multi_info_read(multi, &msgs_left); + if(msg) + res = msg->data.result; + +test_cleanup: + + /* undocumented cleanup sequence - type UA */ + + curl_multi_cleanup(multi); + curl_easy_cleanup(easy); + curl_global_cleanup(); + + /* close the local file */ + fclose(upload); + + return res; +} -- cgit v1.2.1 From 97b73fec7a961d34a378c41b49542fc2cf5782c9 Mon Sep 17 00:00:00 2001 From: Alejandro Alvarez Ayllon Date: Thu, 17 Nov 2011 23:33:42 +0100 Subject: libtest build: add the missing lib586 --- tests/libtest/Makefile.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 4a7f78cf2..1693ee7c0 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -15,8 +15,8 @@ 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 lib587 lib590 \ - lib591 + lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib586 lib587 \ + lib590 lib591 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -168,6 +168,8 @@ lib583_SOURCES = lib583.c $(SUPPORTFILES) lib585_SOURCES = lib500.c $(SUPPORTFILES) lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 +lib586_SOURCES = lib586.c $(SUPPORTFILES) + lib587_SOURCES = lib554.c $(SUPPORTFILES) lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 -- cgit v1.2.1 From c482e946f7ae003ce54ee05b5cca6d6ce8172f14 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 24 Nov 2011 18:18:42 +0100 Subject: lib573.c: fix double data type variable comparison with zero --- tests/libtest/lib573.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 943f6e8c8..50aedfa6c 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -38,6 +38,12 @@ int test(char *URL) int res = 0; int running = 1; double connect_time = 0.0; + double dbl_epsilon; + + dbl_epsilon = 1.0; + do { + dbl_epsilon /= 2.0; + } while ((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0); start_test_timing(); @@ -81,8 +87,8 @@ int test(char *URL) } curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time); - if (connect_time <= 0.0) { - fprintf(stderr, "connect time is <=0.0\n"); + if (connect_time < dbl_epsilon) { + fprintf(stderr, "connect time is < epsilon\n"); res = TEST_ERR_MAJOR_BAD; } -- cgit v1.2.1 From 97d7a9260e4f2f335b3632180877c25e0efdc8e3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 25 Nov 2011 13:51:55 +0100 Subject: tvdiff_secs(): sub-zero time difference adjustment Skip a floating point addition operation when integral part of time difference is zero. This avoids potential floating point addition rounding problems while preserving decimal part value. --- tests/libtest/testutil.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 63393c589..4ee488e71 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -123,8 +123,11 @@ long tutil_tvdiff(struct timeval newer, struct timeval older) */ double tutil_tvdiff_secs(struct timeval newer, struct timeval older) { - return (double)(newer.tv_sec-older.tv_sec)+ - (double)(newer.tv_usec-older.tv_usec)/1000000.0; + if(newer.tv_sec != older.tv_sec) + return (double)(newer.tv_sec-older.tv_sec)+ + (double)(newer.tv_usec-older.tv_usec)/1000000.0; + else + return (double)(newer.tv_usec-older.tv_usec)/1000000.0; } /* return the number of seconds in the given input timeval struct */ -- cgit v1.2.1 From 5971d401d4fd184aedd3b439251a898ecdacb96e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 4 Dec 2011 23:10:12 +0100 Subject: test: verify the opensocket callback for FTP test 595: for passive FTP test 596: for active FTP --- tests/libtest/lib500.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 51680fc31..812fb0dd5 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -76,6 +76,9 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_HEADER, 1L); + if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp")) + test_setopt(curl, CURLOPT_FTPPORT, "-"); + setupcallbacks(curl); res = curl_easy_perform(curl); -- cgit v1.2.1 From 2b24dd870e81512542f238cb1b124cecb942a34f Mon Sep 17 00:00:00 2001 From: Gokhan Sengun Date: Tue, 6 Dec 2011 23:41:24 +0100 Subject: multi interface: fix block when CONNECT_ONLY option is used --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib597.c | 145 +++++++++++++++++++++++++++++++++++++++++++++ tests/libtest/test.h | 25 ++++++++ 3 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib597.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 1693ee7c0..e37e63b9e 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -16,7 +16,7 @@ noinst_PROGRAMS = chkhostname \ 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 lib586 lib587 \ - lib590 lib591 + lib590 lib591 lib597 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -176,3 +176,5 @@ lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 lib590_SOURCES = lib590.c $(SUPPORTFILES) lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) + +lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c new file mode 100644 index 000000000..6a5ee4f8f --- /dev/null +++ b/tests/libtest/lib597.c @@ -0,0 +1,145 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 5 * 1000 + +/* + * Test case for below scenario: + * - Connect to an FTP server using CONNECT_ONLY option + * - transfer some files with re-using the connection (omitted in test case) + * - Disconnect from FTP server with sending QUIT command + * + * The test case originated for verifying CONNECT_ONLY option shall not + * block after protocol connect is done, but it returns the message + * with function curl_multi_info_read(). + */ + +enum { + CONNECT_ONLY_PHASE = 0, + QUIT_PHASE, + LAST_PHASE +}; + +int test(char *URL) +{ + CURL *easy = NULL; + CURLM *multi = NULL; + int res = 0; + int running; + int msgs_left; + int phase; + CURLMsg *msg; + + start_test_timing(); + + res_global_init(CURL_GLOBAL_ALL); + if(res) { + return res; + } + + easy_init(easy); + + multi_init(multi); + + for (phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) { + /* go verbose */ + easy_setopt(easy, CURLOPT_VERBOSE, 1L); + + /* specify target */ + easy_setopt(easy, CURLOPT_URL, URL); + + /* enable 'CONNECT_ONLY' option when in connect phase */ + if (phase == CONNECT_ONLY_PHASE) + easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L); + + /* enable 'NOBODY' option to send 'QUIT' command in quit phase */ + if (phase == QUIT_PHASE) { + easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L); + easy_setopt(easy, CURLOPT_NOBODY, 1L); + easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L); + } + + multi_add_handle(multi, easy); + + for(;;) { + struct timeval interval; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + long timeout = -99; + int maxfd = -99; + + multi_perform(multi, &running); + + abort_on_test_timeout(); + + if(!running) + break; /* done */ + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + + /* At this point, maxfd is guaranteed to be greater or equal than -1. */ + + multi_timeout(multi, &timeout); + + /* At this point, timeout is guaranteed to be greater or equal than -1. */ + + if(timeout != -1L) { + interval.tv_sec = timeout/1000; + interval.tv_usec = (timeout%1000)*1000; + } + else { + interval.tv_sec = TEST_HANG_TIMEOUT/1000+1; + interval.tv_usec = 0; + } + + select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); + + abort_on_test_timeout(); + } + + msg = curl_multi_info_read(multi, &msgs_left); + if(msg) + res = msg->data.result; + + multi_remove_handle(multi, easy); + } + +test_cleanup: + + /* undocumented cleanup sequence - type UA */ + + curl_multi_cleanup(multi); + curl_easy_cleanup(easy); + curl_global_cleanup(); + + return res; +} diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 34b8c9f3e..861a571a5 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -242,6 +242,31 @@ extern int unitfail; /* ---------------------------------------------------------------- */ +#define exe_multi_remove_handle(A,B,Y,Z) do { \ + CURLMcode ec; \ + if((ec = curl_multi_remove_handle((A),(B))) != CURLM_OK) { \ + fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ + res = (int)ec; \ + } \ +} WHILE_FALSE + +#define res_multi_remove_handle(A,B) \ + exe_multi_remove_handle((A),(B),(__FILE__),(__LINE__)) + +#define chk_multi_remove_handle(A,B,Y,Z) do { \ + exe_multi_remove_handle((A),(B),(Y),(Z)); \ + if(res) \ + goto test_cleanup; \ +} WHILE_FALSE + + +#define multi_remove_handle(A,B) \ + chk_multi_remove_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) { \ -- cgit v1.2.1 From e9040f2954bc1423a4b2e47883294dce088a12d5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 Dec 2011 15:41:43 +0100 Subject: lib500: verify timers relative each other As commit ce896875f8 fixed a timer that accidentally had been moved in code and then returned a bad timer, the lib500.c code (used in test 500 and some others) now verifies 5 timers against each other to verify that they have the correct relative values. We cannot compare against absolute values as the timings will vary a lot. --- tests/libtest/lib500.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 812fb0dd5..109312b37 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -88,7 +88,38 @@ int test(char *URL) res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr); moo = fopen(libtest_arg2, "wb"); if(moo) { + double time_namelookup; + double time_connect; + double time_pretransfer; + double time_starttransfer; + double time_total; fprintf(moo, "IP: %s\n", ipstr); + curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); + curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); + curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); + curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, + &time_starttransfer); + curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); + + /* since the timing will always vary we only compare relative differences + between these 5 times */ + if(time_namelookup >= time_connect) { + fprintf(moo, "namelookup vs connect: %f %f\n", + time_namelookup, time_connect); + } + if(time_connect >= time_pretransfer) { + fprintf(moo, "connect vs pretransfer: %f %f\n", + time_connect, time_pretransfer); + } + if(time_pretransfer >= time_starttransfer) { + fprintf(moo, "pretransfer vs starttransfer: %f %f\n", + time_pretransfer, time_starttransfer); + } + if(time_starttransfer >= time_total) { + fprintf(moo, "starttransfer vs total: %f %f\n", + time_starttransfer, time_total); + } + fclose(moo); } } -- cgit v1.2.1 From c834213ad52c52431e9ca597862dc81839cabe84 Mon Sep 17 00:00:00 2001 From: Gokhan Sengun Date: Mon, 19 Dec 2011 14:35:20 +0100 Subject: FTP: perform active connections non-blocking 1- Two new error codes are introduced. CURLE_FTP_ACCEPT_FAILED to be set whenever ACCEPTing fails because of FTP server connected. CURLE_FTP_ACCEPT_TIMEOUT to be set whenever ACCEPTing timeouts. Neither of these errors are considered fatal and control connection remains OK because it could just be a firewall blocking server to connect to the client. 2- One new setopt option was introduced. CURLOPT_ACCEPTTIMEOUT_MS It sets the maximum amount of time FTP client is going to wait for a server to connect. Internal default accept timeout is 60 seconds. --- tests/libtest/lib591.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c index 101f2db26..8a55e2cd1 100644 --- a/tests/libtest/lib591.c +++ b/tests/libtest/lib591.c @@ -77,7 +77,8 @@ int test(char *URL) easy_setopt(easy, CURLOPT_FTPPORT, "-"); /* server connection timeout */ - easy_setopt(easy, CURLOPT_CONNECTTIMEOUT, strtol(libtest_arg2, NULL, 10)); + easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS, + strtol(libtest_arg2, NULL, 10)*1000); multi_init(multi); -- cgit v1.2.1 From ed0364343dc2472fdc6a390bb00c3e20152e8e6f Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 30 Dec 2011 03:36:18 +0100 Subject: removed trailing whitespace --- tests/libtest/first.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 57e6ddd79..253acb21d 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -38,7 +38,7 @@ int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, return -1; } #ifdef USE_WINSOCK - /* + /* * 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. -- cgit v1.2.1 From a752850acc4fda72a36fdc53d5d5b7c6da5693c0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 17 Jan 2012 21:32:05 +0100 Subject: tests: testtrace.[ch] provides debug callback for libtest usage Allows tests from the libtest subdir to generate log traces similar to those of curl with --tracetime and --trace-ascii options but with output going to stderr. --- tests/libtest/testtrace.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++ tests/libtest/testtrace.h | 37 ++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 tests/libtest/testtrace.c create mode 100644 tests/libtest/testtrace.h (limited to 'tests/libtest') diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c new file mode 100644 index 000000000..9c082394e --- /dev/null +++ b/tests/libtest/testtrace.c @@ -0,0 +1,141 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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 "testutil.h" +#include "testtrace.h" +#include "memdebug.h" + +struct libtest_trace_cfg libtest_debug_config; + +static time_t epoch_offset; /* for test time tracing */ +static int known_offset; /* for test time tracing */ + +static +void libtest_debug_dump(const char *timebuf, const char *text, FILE *stream, + const unsigned char *ptr, size_t size, int nohex) +{ + size_t i; + size_t c; + + unsigned int width = 0x10; + + if(nohex) + /* without the hex output, we can fit more on screen */ + width = 0x40; + + fprintf(stream, "%s%s, %d bytes (0x%x)\n", timebuf, text, + (int)size, (int)size); + + for(i = 0; i < size; i += width) { + + fprintf(stream, "%04x: ", (int)i); + + if(!nohex) { + /* hex not disabled, show it */ + for(c = 0; c < width; c++) + if(i+c < size) + fprintf(stream, "%02x ", ptr[i+c]); + else + fputs(" ", stream); + } + + for(c = 0; (c < width) && (i+c < size); c++) { + /* check for 0D0A; if found, skip past and start a new line of output */ + if(nohex && + (i+c+1 < size) && (ptr[i+c] == 0x0D) && (ptr[i+c+1] == 0x0A)) { + i += (c+2-width); + break; + } + fprintf(stream, "%c", ((ptr[i+c] >= 0x20) && (ptr[i+c] < 0x80)) ? + ptr[i+c] : '.'); + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if(nohex && + (i+c+2 < size) && (ptr[i+c+1] == 0x0D) && (ptr[i+c+2] == 0x0A)) { + i += (c+3-width); + break; + } + } + fputc('\n', stream); /* newline */ + } + fflush(stream); +} + +int libtest_debug_cb(CURL *handle, curl_infotype type, + unsigned char *data, size_t size, + void *userp) +{ + + struct libtest_trace_cfg *trace_cfg = userp; + const char *text; + struct timeval tv; + struct tm *now; + char timebuf[20]; + time_t secs; + + (void)handle; + + timebuf[0] = '\0'; + + if(trace_cfg->tracetime) { + tv = tutil_tvnow(); + if(!known_offset) { + epoch_offset = time(NULL) - tv.tv_sec; + known_offset = 1; + } + secs = epoch_offset + tv.tv_sec; + now = localtime(&secs); /* not thread safe but we don't care */ + snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ", + now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec); + } + + switch (type) { + case CURLINFO_TEXT: + fprintf(stderr, "%s== Info: %s", timebuf, data); + default: /* in case a new one is introduced to shock us */ + return 0; + + case CURLINFO_HEADER_OUT: + text = "=> Send header"; + break; + case CURLINFO_DATA_OUT: + text = "=> Send data"; + break; + case CURLINFO_SSL_DATA_OUT: + text = "=> Send SSL data"; + break; + case CURLINFO_HEADER_IN: + text = "<= Recv header"; + break; + case CURLINFO_DATA_IN: + text = "<= Recv data"; + break; + case CURLINFO_SSL_DATA_IN: + text = "<= Recv SSL data"; + break; + } + + libtest_debug_dump(timebuf, text, stderr, data, size, trace_cfg->nohex); + return 0; +} + diff --git a/tests/libtest/testtrace.h b/tests/libtest/testtrace.h new file mode 100644 index 000000000..73d2489a4 --- /dev/null +++ b/tests/libtest/testtrace.h @@ -0,0 +1,37 @@ +#ifndef HEADER_LIBTEST_TESTTRACE_H +#define HEADER_LIBTEST_TESTTRACE_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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. + * + ***************************************************************************/ + +struct libtest_trace_cfg { + int tracetime; /* 0 represents FALSE, anything else TRUE */ + int nohex; /* 0 represents FALSE, anything else TRUE */ +}; + +extern struct libtest_trace_cfg libtest_debug_config; + +int libtest_debug_cb(CURL *handle, curl_infotype type, + unsigned char *data, size_t size, + void *userp); + +#endif /* HEADER_LIBTEST_TESTTRACE_H */ + -- cgit v1.2.1 From 24526d0c0f4209eb77c807afdb15da301c7d021b Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 17 Jan 2012 21:33:17 +0100 Subject: tests: enable time tracing on tests 500, 573 and 585 --- tests/libtest/Makefile.inc | 9 ++++++--- tests/libtest/lib500.c | 9 ++++++++- tests/libtest/lib573.c | 9 ++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index e37e63b9e..0ff588809 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -1,6 +1,9 @@ # files used only in some libcurl test programs TESTUTIL = testutil.c testutil.h +# files used only in some libcurl test programs +TSTTRACE = testtrace.c testtrace.h + # files used only in some libcurl test programs WARNLESS = $(top_srcdir)/lib/warnless.c $(top_srcdir)/lib/warnless.h @@ -23,7 +26,7 @@ chkhostname_LDADD = @CURL_NETWORK_LIBS@ chkhostname_DEPENDENCIES = chkhostname_CFLAGS = $(AM_CFLAGS) -lib500_SOURCES = lib500.c $(SUPPORTFILES) +lib500_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) lib501_SOURCES = lib501.c $(SUPPORTFILES) @@ -155,7 +158,7 @@ lib571_SOURCES = lib571.c $(SUPPORTFILES) lib572_SOURCES = lib572.c $(SUPPORTFILES) -lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE) lib578_SOURCES = lib578.c $(SUPPORTFILES) @@ -165,7 +168,7 @@ lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib583_SOURCES = lib583.c $(SUPPORTFILES) -lib585_SOURCES = lib500.c $(SUPPORTFILES) +lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 lib586_SOURCES = lib586.c $(SUPPORTFILES) diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 109312b37..dda1d7f42 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -21,6 +21,7 @@ ***************************************************************************/ #include "test.h" +#include "testtrace.h" #include "memdebug.h" #ifdef LIB585 @@ -76,6 +77,12 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_HEADER, 1L); + libtest_debug_config.nohex = 1; + libtest_debug_config.tracetime = 1; + test_setopt(curl, CURLOPT_DEBUGDATA, &libtest_debug_config); + test_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp")) test_setopt(curl, CURLOPT_FTPPORT, "-"); diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 50aedfa6c..b49d26a5d 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -21,6 +21,7 @@ ***************************************************************************/ #include "test.h" +#include "testtrace.h" #include "testutil.h" #include "warnless.h" #include "memdebug.h" @@ -54,6 +55,12 @@ int test(char *URL) easy_setopt(c, CURLOPT_HEADER, 1L); easy_setopt(c, CURLOPT_URL, URL); + libtest_debug_config.nohex = 1; + libtest_debug_config.tracetime = 1; + easy_setopt(c, CURLOPT_DEBUGDATA, &libtest_debug_config); + easy_setopt(c, CURLOPT_DEBUGFUNCTION, libtest_debug_cb); + easy_setopt(c, CURLOPT_VERBOSE, 1L); + multi_init(m); multi_add_handle(m, c); -- cgit v1.2.1 From a7e8f4aabcb7f5b46e0dd94a9645c5cd2744f9da Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Jan 2012 22:54:57 +0100 Subject: testtrace.c: fix compiler warning --- tests/libtest/testtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c index 9c082394e..5cb5fec5e 100644 --- a/tests/libtest/testtrace.c +++ b/tests/libtest/testtrace.c @@ -111,7 +111,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type, switch (type) { case CURLINFO_TEXT: - fprintf(stderr, "%s== Info: %s", timebuf, data); + fprintf(stderr, "%s== Info: %s", &timebuf[0], data); default: /* in case a new one is introduced to shock us */ return 0; -- cgit v1.2.1 From ea055407fa45c4247042e7370d463364f03c3136 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 6 Feb 2012 22:59:49 +0100 Subject: curl_easy_reset: reset the referer string When CURLOPT_REFERER has been used, curl_easy_reset() did not properly clear it. Verified with the new test 598 Bug: http://curl.haxx.se/bug/view.cgi?id=3481551 Reported by: Michael Day --- tests/libtest/Makefile.inc | 4 ++- tests/libtest/lib598.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib598.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 0ff588809..b13c97e47 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -19,7 +19,7 @@ noinst_PROGRAMS = chkhostname \ 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 lib586 lib587 \ - lib590 lib591 lib597 + lib590 lib591 lib597 lib598 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -181,3 +181,5 @@ lib590_SOURCES = lib590.c $(SUPPORTFILES) lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) + +lib598_SOURCES = lib598.c $(SUPPORTFILES) diff --git a/tests/libtest/lib598.c b/tests/libtest/lib598.c new file mode 100644 index 000000000..8d46c6887 --- /dev/null +++ b/tests/libtest/lib598.c @@ -0,0 +1,66 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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 "memdebug.h" + +int test(char *URL) +{ + CURLcode res; + CURL *curl; + + 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; + } + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_REFERER, "http://example.com/the-moo"); + test_setopt(curl, CURLOPT_USERAGENT, "the-moo agent next generation"); + test_setopt(curl, CURLOPT_COOKIE, "name=moo"); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + res = curl_easy_perform(curl); + + curl_easy_reset(curl); + + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + res = curl_easy_perform(curl); + +test_cleanup: + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From c6825b7a6b5e8798bc861b3d280430e8149e7298 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 20 Mar 2012 18:28:24 +0100 Subject: fix several compiler warnings --- tests/libtest/testtrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c index 5cb5fec5e..b13c54e30 100644 --- a/tests/libtest/testtrace.c +++ b/tests/libtest/testtrace.c @@ -91,11 +91,13 @@ int libtest_debug_cb(CURL *handle, curl_infotype type, struct timeval tv; struct tm *now; char timebuf[20]; + char *timestr; time_t secs; (void)handle; timebuf[0] = '\0'; + timestr = &timebuf[0]; if(trace_cfg->tracetime) { tv = tutil_tvnow(); @@ -111,7 +113,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type, switch (type) { case CURLINFO_TEXT: - fprintf(stderr, "%s== Info: %s", &timebuf[0], data); + fprintf(stderr, "%s== Info: %s", timestr, data); default: /* in case a new one is introduced to shock us */ return 0; -- cgit v1.2.1 From 3c80309c276b8ceac13ab1a4824d216805d45afe Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Mar 2012 02:40:19 +0100 Subject: fix several compiler warnings --- tests/libtest/Makefile.inc | 4 ++-- tests/libtest/lib552.c | 6 ++++-- tests/libtest/lib571.c | 7 +++++-- tests/libtest/testtrace.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index b13c97e47..e24d74226 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -119,7 +119,7 @@ lib549_SOURCES = lib549.c $(SUPPORTFILES) lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib552_SOURCES = lib552.c $(SUPPORTFILES) +lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS) lib553_SOURCES = lib553.c $(SUPPORTFILES) @@ -154,7 +154,7 @@ lib569_SOURCES = lib569.c $(SUPPORTFILES) lib570_SOURCES = lib570.c $(SUPPORTFILES) -lib571_SOURCES = lib571.c $(SUPPORTFILES) +lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS) lib572_SOURCES = lib572.c $(SUPPORTFILES) diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index fb8b14bc2..2cc942ad4 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,6 +25,7 @@ #include "test.h" +#include "warnless.h" #include "memdebug.h" struct data { @@ -136,7 +137,8 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) { - printf("%.*s", (int)(size * nmemb), (char *)ptr); + int amount = curlx_uztosi(size * nmemb); + printf("%.*s", amount, (char *)ptr); (void)stream; return size * nmemb; } diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index c5f7240d0..ba0aa1ce4 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,6 +39,7 @@ #include +#include "warnless.h" #include "memdebug.h" #define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1]))) @@ -54,12 +55,14 @@ static int rtp_packet_count = 0; static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { char *data = (char *)ptr; int channel = RTP_PKT_CHANNEL(data); - int message_size = (int)(size * nmemb) - 4; + int message_size; int coded_size = RTP_PKT_LENGTH(data); size_t failure = (size * nmemb) ? 0 : 1; int i; (void)stream; + message_size = curlx_uztosi(size * nmemb) - 4; + printf("RTP: message size %d, channel %d\n", message_size, channel); if(message_size != coded_size) { printf("RTP embedded size (%d) does not match the write size (%d).\n", diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c index b13c54e30..64602e065 100644 --- a/tests/libtest/testtrace.c +++ b/tests/libtest/testtrace.c @@ -113,7 +113,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type, switch (type) { case CURLINFO_TEXT: - fprintf(stderr, "%s== Info: %s", timestr, data); + fprintf(stderr, "%s== Info: %s", timestr, (char *)data); default: /* in case a new one is introduced to shock us */ return 0; -- cgit v1.2.1 From 3aab542e77546b344649edeae85157d93989faa5 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Mar 2012 04:58:38 +0100 Subject: test #598: OOM handling fixes --- tests/libtest/lib598.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib598.c b/tests/libtest/lib598.c index 8d46c6887..e9c1ad776 100644 --- a/tests/libtest/lib598.c +++ b/tests/libtest/lib598.c @@ -47,6 +47,10 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); + if(res) { + fprintf(stderr, "retrieve 1 failed\n"); + goto test_cleanup; + } curl_easy_reset(curl); @@ -55,6 +59,8 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); + if(res) + fprintf(stderr, "retrieve 2 failed\n"); test_cleanup: -- cgit v1.2.1 From c44d45db86b880df5facd6b560491e03530f876e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 23 Mar 2012 23:42:37 +0100 Subject: HTTP: reset expected DL/UL sizes on redirects With FOLLOWLOCATION enabled. When a 3xx page is downloaded and the download size was known (like with a Content-Length header), but the subsequent URL (transfered after the 3xx page) was chunked encoded, then the previous "known download size" would linger and cause the progress meter to get incorrect information, ie the former value would remain being sent in. This could easily result in downloads that were WAY larger than "expected" and would cause >100% outputs with the curl command line tool. Test case 599 was created and it was used to repeat the bug and then verify the fix. Bug: http://curl.haxx.se/bug/view.cgi?id=3510057 Reported by: Michael Wallner --- tests/libtest/Makefile.inc | 4 ++- tests/libtest/lib599.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib599.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index e24d74226..4b79b93fe 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -19,7 +19,7 @@ noinst_PROGRAMS = chkhostname \ 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 lib586 lib587 \ - lib590 lib591 lib597 lib598 + lib590 lib591 lib597 lib598 lib599 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -183,3 +183,5 @@ lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib598_SOURCES = lib598.c $(SUPPORTFILES) + +lib599_SOURCES = lib599.c $(SUPPORTFILES) diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c new file mode 100644 index 000000000..354e88704 --- /dev/null +++ b/tests/libtest/lib599.c @@ -0,0 +1,88 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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 "memdebug.h" + +static double dl; + +static int progress_callback(void *clientp, double dltotal, + double dlnow, double ultotal, double ulnow) +{ + (void)clientp; + (void)ulnow; + (void)ultotal; + + dl = dltotal; + + if((dltotal > 0.0) && (dlnow > dltotal)) { + /* this should not happen with test case 599 */ + printf("%.0f > %.0f !!\n", dltotal, dlnow); + return -1; + } + + return 0; +} + +int test(char *URL) +{ + CURL *curl; + CURLcode res=CURLE_OK; + + 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; + } + + /* First set the URL that is about to receive our POST. */ + test_setopt(curl, CURLOPT_URL, URL); + + /* we want to use our own progress function */ + test_setopt(curl, CURLOPT_NOPROGRESS, 0L); + test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + + /* get verbose debug output please */ + test_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* follow redirects */ + test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + + /* include headers in the output */ + test_setopt(curl, CURLOPT_HEADER, 1L); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + +test_cleanup: + + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From e7661d198f6f4c1873b6fecf5981725f804156a9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2012 17:22:46 +0200 Subject: lib599.c: fix compiler warning --- tests/libtest/lib599.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c index 354e88704..6b092677a 100644 --- a/tests/libtest/lib599.c +++ b/tests/libtest/lib599.c @@ -23,8 +23,6 @@ #include "memdebug.h" -static double dl; - static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { @@ -32,8 +30,6 @@ static int progress_callback(void *clientp, double dltotal, (void)ulnow; (void)ultotal; - dl = dltotal; - if((dltotal > 0.0) && (dlnow > dltotal)) { /* this should not happen with test case 599 */ printf("%.0f > %.0f !!\n", dltotal, dlnow); -- cgit v1.2.1 From 21423497efe36c70615d0a54e040f76043823345 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 9 Apr 2012 21:24:16 +0200 Subject: configure: Windows cross-compilation fixes BUILDING_LIBCURL and CURL_STATICLIB are no longer defined in curl_config.h, configure will generate appropriate conditionals so that mentioned symbols get defined and used in Makefiles at compilation time --- tests/libtest/Makefile.am | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 9c0d59507..be667ee22 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. +# Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -57,6 +57,11 @@ test1022.pl Makefile.inc LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ DEPENDENCIES = $(top_builddir)/lib/libcurl.la +# Mostly for Windows build targets, when using static libcurl +if USE_CPPFLAG_CURL_STATICLIB +AM_CPPFLAGS = -DCURL_STATICLIB +endif + # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, # noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) include Makefile.inc -- cgit v1.2.1 From bbfe1182098b2451b1f457b37c2b53fe89e537e8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 10 Apr 2012 17:29:37 +0200 Subject: libtests: build adjustment Undefine CURL_HIDDEN_SYMBOLS libcurl private preprocessor macro that might leak from lib/setup.h into source files where this should not be defined. --- tests/libtest/chkhostname.c | 4 +++- tests/libtest/sethostname.c | 5 +++-- tests/libtest/test.h | 4 +++- tests/libtest/testutil.c | 5 +++-- tests/libtest/testutil.h | 10 +++++----- 5 files changed, 17 insertions(+), 11 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c index 58930467f..bf0dbfda2 100644 --- a/tests/libtest/chkhostname.c +++ b/tests/libtest/chkhostname.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -21,6 +21,8 @@ ***************************************************************************/ #include "setup.h" +#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ + #include "curl_gethostname.h" #define HOSTNAME_MAX 1024 diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index daf94f95c..d5d5cf9e2 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,9 +19,10 @@ * KIND, either express or implied. * ***************************************************************************/ - #include "setup.h" +#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ + #include "sethostname.h" /* diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 861a571a5..119debd68 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -29,6 +29,8 @@ #include "setup.h" +#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ + #include #include #include diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 4ee488e71..fc79e5c63 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,9 +19,10 @@ * KIND, either express or implied. * ***************************************************************************/ - #include "setup.h" +#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ + #include "testutil.h" #include "memdebug.h" diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 6a322e3cb..455b5d53f 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -1,5 +1,5 @@ -#ifndef __LIBTEST_TESTUTIL_H -#define __LIBTEST_TESTUTIL_H +#ifndef HEADER_CURL_LIBTEST_TESTUTIL_H +#define HEADER_CURL_LIBTEST_TESTUTIL_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -21,9 +21,9 @@ * KIND, either express or implied. * ***************************************************************************/ - #include "setup.h" +#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ struct timeval tutil_tvnow(void); @@ -45,5 +45,5 @@ double tutil_tvdiff_secs(struct timeval t1, struct timeval t2); long tutil_tvlong(struct timeval t1); -#endif /* __LIBTEST_TESTUTIL_H */ +#endif /* HEADER_CURL_LIBTEST_TESTUTIL_H */ -- cgit v1.2.1 From a144bb8b767b1c9ae40a0e7853db88ed67c9e8c3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 11 Apr 2012 19:28:40 +0200 Subject: build adjustments: functionally revert commits 4d3fb91f and bbfe1182 Undefining CURL_HIDDEN_SYMBOLS in source files isn't the proper fix. --- tests/libtest/chkhostname.c | 2 -- tests/libtest/sethostname.c | 2 -- tests/libtest/test.h | 2 -- tests/libtest/testutil.c | 2 -- tests/libtest/testutil.h | 2 -- 5 files changed, 10 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c index bf0dbfda2..a18c92e8f 100644 --- a/tests/libtest/chkhostname.c +++ b/tests/libtest/chkhostname.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "setup.h" -#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ - #include "curl_gethostname.h" #define HOSTNAME_MAX 1024 diff --git a/tests/libtest/sethostname.c b/tests/libtest/sethostname.c index d5d5cf9e2..f131fe9fb 100644 --- a/tests/libtest/sethostname.c +++ b/tests/libtest/sethostname.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "setup.h" -#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ - #include "sethostname.h" /* diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 119debd68..ffa4be166 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -29,8 +29,6 @@ #include "setup.h" -#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ - #include #include #include diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index fc79e5c63..3ad18c987 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "setup.h" -#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ - #include "testutil.h" #include "memdebug.h" diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 455b5d53f..0c6be2fc4 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -23,8 +23,6 @@ ***************************************************************************/ #include "setup.h" -#undef CURL_HIDDEN_SYMBOLS /* libcurl internal use only */ - struct timeval tutil_tvnow(void); /* -- cgit v1.2.1 From 9e24b9c7afbcb81120af4cf3f6cdee49a06d8224 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 11 Apr 2012 19:33:54 +0200 Subject: build adjustments: CURL_HIDDEN_SYMBOLS no longer defined in config files configure script now provides conditional definitions for Makefile.am that result in CURL_HIDDEN_SYMBOLS being defined by resulting makefiles when appropriate. Additionally, configure script option for symbol hiding control is now named --enable-symbol-hiding --disable-symbol-hiding. While still valid, old option name --enable-hidden-symbols --disable-hidden-symbols will be deprecated in some future release. --- tests/libtest/Makefile.am | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index be667ee22..e4538b750 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,6 +53,8 @@ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc +CFLAG_SYMBOL_HIDING = @CFLAG_SYMBOL_HIDING@ + # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ DEPENDENCIES = $(top_builddir)/lib/libcurl.la @@ -86,3 +88,10 @@ libhostname_la_LIBADD = libhostname_la_DEPENDENCIES = libhostname_la_LDFLAGS = -module -avoid-version $(UNDEF) -rpath /nowhere +if DOING_SYMBOL_HIDING +libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_HIDDEN_SYMBOLS +libhostname_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_SYMBOL_HIDING) +else +libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) +libhostname_la_CFLAGS = $(AM_CFLAGS) +endif -- cgit v1.2.1 From 3833765ba5f77e74ce1d82d761b1c45ca2b32fbb Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 17 Apr 2012 12:42:14 +0200 Subject: build adjustments: commit 9e24b9c7 follow-up --- tests/libtest/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index e4538b750..6170453a0 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -53,7 +53,7 @@ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ test1022.pl Makefile.inc -CFLAG_SYMBOL_HIDING = @CFLAG_SYMBOL_HIDING@ +CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@ # Dependencies (may need to be overriden) LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ @@ -88,9 +88,9 @@ libhostname_la_LIBADD = libhostname_la_DEPENDENCIES = libhostname_la_LDFLAGS = -module -avoid-version $(UNDEF) -rpath /nowhere -if DOING_SYMBOL_HIDING +if DOING_CURL_SYMBOL_HIDING libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_HIDDEN_SYMBOLS -libhostname_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_SYMBOL_HIDING) +libhostname_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_CURL_SYMBOL_HIDING) else libhostname_la_CPPFLAGS = $(AM_CPPFLAGS) libhostname_la_CFLAGS = $(AM_CFLAGS) -- cgit v1.2.1 From ce8a321dd0c1f06dea1b8edf7b1b76e9672caaeb Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Apr 2012 21:03:20 +0200 Subject: Some explicit conversion to 'long' of curl_easy_setopt() third argument Explicit conversion to 'long' of curl_easy_setopt() third argument for options CURLOPT_HTTPAUTH and CURLOPT_PROXYAUTH given that this is how its bitmasks are docummented to be used. --- tests/libtest/lib510.c | 4 ++-- tests/libtest/lib579.c | 4 ++-- tests/libtest/lib590.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index 779164ad5..8278631c1 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -109,7 +109,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_HTTPHEADER, slist); #ifdef LIB565 - test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); test_setopt(curl, CURLOPT_USERPWD, "foo:bar"); #endif diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index 56193a181..c5cf603bb 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -137,7 +137,7 @@ int test(char *URL) /* enforce chunked transfer by setting the header */ test_setopt(curl, CURLOPT_HTTPHEADER, slist); - test_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); + test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); test_setopt(curl, CURLOPT_USERPWD, "foo:bar"); /* we want to use our own progress function */ diff --git a/tests/libtest/lib590.c b/tests/libtest/lib590.c index 75c90d53f..68603c65e 100644 --- a/tests/libtest/lib590.c +++ b/tests/libtest/lib590.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -55,7 +55,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_HEADER, 1L); test_setopt(curl, CURLOPT_PROXYAUTH, - CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM); + (long) (CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM)); test_setopt(curl, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ test_setopt(curl, CURLOPT_PROXYUSERPWD, "me:password"); -- cgit v1.2.1 From a03100c3577e7843fbe9a4cfcf0f3cdcb4fa34da Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 27 May 2012 23:43:23 +0200 Subject: test1013.pl: filter out Metalink Since it isn't a feature supported by curl-config we can't compare that with the --version output --- tests/libtest/test1013.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 99ad524eb..9ea7de02d 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -22,7 +22,7 @@ $curl_protocols =~ /\w+: (.*)$/; @curl = split / /,$1; # These features are not supported by curl-config -@curl = grep(!/^(Debug|TrackMemory|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl); +@curl = grep(!/^(Debug|TrackMemory|Metalink|Largefile|CharConv|GSS-Negotiate|SPNEGO)$/i, @curl); @curl = sort @curl; # Read the output of curl-config -- cgit v1.2.1 From 2b56e4c1bb31dc69517156a1c70a264a6f6e91e4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 5 Jun 2012 20:19:27 +0200 Subject: tests 1334 to 1363 revisited. Add a postcheck section to verify unintended file creation. Remove needless checks in verify section. Renumbering where appropriate. --- tests/libtest/Makefile.am | 2 +- tests/libtest/notexists.pl | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 tests/libtest/notexists.pl (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 6170453a0..7b8d8fc04 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -51,7 +51,7 @@ INCLUDES = -I$(top_builddir)/include/curl \ endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ -test1022.pl Makefile.inc +test1022.pl Makefile.inc notexists.pl CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@ diff --git a/tests/libtest/notexists.pl b/tests/libtest/notexists.pl new file mode 100755 index 000000000..31b9851ec --- /dev/null +++ b/tests/libtest/notexists.pl @@ -0,0 +1,15 @@ +#!/usr/bin/env perl +# Check that given arguments do not exist on filesystem. +my $code = 0; +if ($#ARGV < 0) { + print "Usage: $0 file1 [fileN]\n"; + exit 2; +} +while (@ARGV) { + my $fname = shift @ARGV; + if (-e $fname) { + print "Found '$fname' when not supposed to exist.\n"; + $code = 1; + } +} +exit $code; -- cgit v1.2.1 From 2e48139fbf44283a07f02978095d50bdcb112b9f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 7 Jun 2012 23:08:35 +0200 Subject: lib554.c: use curl_formadd() properly The length/size options take longs so make sure to pass on such types. Reported by: Neil Bowers Bug: http://curl.haxx.se/mail/lib-2012-06/0001.html --- tests/libtest/lib554.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index d20429d91..0596f3ef1 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -88,7 +88,7 @@ int test(char *URL) &lastptr, CURLFORM_COPYNAME, "sendfile", CURLFORM_STREAM, &pooh, - CURLFORM_CONTENTSLENGTH, pooh.sizeleft, + CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft, CURLFORM_FILENAME, "postit2.c", CURLFORM_END); @@ -106,7 +106,7 @@ int test(char *URL) &lastptr, CURLFORM_COPYNAME, "callbackdata", CURLFORM_STREAM, &pooh2, - CURLFORM_CONTENTSLENGTH, pooh2.sizeleft, + CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft, CURLFORM_END); if(formrc) @@ -149,7 +149,7 @@ int test(char *URL) CURLFORM_COPYNAME, "somename", CURLFORM_BUFFER, "somefile.txt", CURLFORM_BUFFERPTR, "blah blah", - CURLFORM_BUFFERLENGTH, 9, + CURLFORM_BUFFERLENGTH, (long)9, CURLFORM_END); if(formrc) -- cgit v1.2.1 From dd707b746fcb14e4336175be2946ed9c082e6dc7 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 28 Jun 2012 17:14:41 +0200 Subject: lib582.c: fix conversion warning --- tests/libtest/lib582.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 25b70609c..641b9b6df 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -172,7 +172,7 @@ static int checkForCompletion(CURLM* curl, int* success) static int getMicroSecondTimeout(struct timeval* timeout) { struct timeval now; - int result; + ssize_t result; gettimeofday(&now, 0); result = (timeout->tv_sec - now.tv_sec) * 1000000 + @@ -180,7 +180,7 @@ static int getMicroSecondTimeout(struct timeval* timeout) if (result < 0) result = 0; - return result; + return curlx_sztosi(result); } /** -- cgit v1.2.1 From c5de48b56c5c8dc8500ec1b5eb60755b1e0a273b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 5 Jul 2012 09:32:41 +0200 Subject: lib503: enable verbose to ease debugging this --- tests/libtest/lib503.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index f3f96aaa5..50277f7d3 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -54,6 +54,7 @@ int test(char *URL) easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); easy_setopt(c, CURLOPT_HEADER, 1L); + easy_setopt(c, CURLOPT_VERBOSE, 1L); multi_init(m); -- cgit v1.2.1 From 5d80017fd6c498764cbbfe86496d62db675a37e8 Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Fri, 20 Jul 2012 15:39:28 +0200 Subject: Fixed CR issue with Win32 version on MSYS. --- tests/libtest/test1013.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 9ea7de02d..2f67717c5 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -14,7 +14,7 @@ my $curl_protocols=""; open(CURL, "$ARGV[1]") || die "Can't get curl $what list\n"; while( ) { - $curl_protocols = lc($_) if ( /$what:/i ); + $curl_protocols = lc($_ =~ s/\r//) if ( /$what:/i ); } close CURL; -- cgit v1.2.1 From 0f15ed1617b0798c0469103a8b431f5d5ce9b01c Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Fri, 20 Jul 2012 17:22:10 +0200 Subject: Fixed CR issue with Win32 version on MSYS. Previous fix didnt work on Linux ... --- tests/libtest/test1013.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/test1013.pl b/tests/libtest/test1013.pl index 2f67717c5..15e121415 100755 --- a/tests/libtest/test1013.pl +++ b/tests/libtest/test1013.pl @@ -14,10 +14,11 @@ my $curl_protocols=""; open(CURL, "$ARGV[1]") || die "Can't get curl $what list\n"; while( ) { - $curl_protocols = lc($_ =~ s/\r//) if ( /$what:/i ); + $curl_protocols = lc($_) if ( /$what:/i ); } close CURL; +$curl_protocols =~ s/\r//; $curl_protocols =~ /\w+: (.*)$/; @curl = split / /,$1; -- cgit v1.2.1 From 24c43e9d34615236489bde4797ce50de4bb56a84 Mon Sep 17 00:00:00 2001 From: Joe Mason Date: Thu, 19 Jul 2012 13:58:10 -0400 Subject: Add tests of auth retries --- tests/libtest/.gitignore | 2 +- tests/libtest/Makefile.inc | 4 +- tests/libtest/libauthretry.c | 153 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/libauthretry.c (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 82560206e..7f8b619af 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,3 +1,3 @@ chkhostname lib5[0-9][0-9] - +libauthretry diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 4b79b93fe..4b3edc11e 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -19,7 +19,7 @@ noinst_PROGRAMS = chkhostname \ 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 lib586 lib587 \ - lib590 lib591 lib597 lib598 lib599 + lib590 lib591 lib597 lib598 lib599 libauthretry chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -185,3 +185,5 @@ lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib598_SOURCES = lib598.c $(SUPPORTFILES) lib599_SOURCES = lib599.c $(SUPPORTFILES) + +libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c new file mode 100644 index 000000000..6403c839b --- /dev/null +++ b/tests/libtest/libauthretry.c @@ -0,0 +1,153 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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. + * + ***************************************************************************/ +/* argv1 = URL + * argv2 = main auth type + * argv3 = second auth type + */ + +#include "test.h" + +#include "memdebug.h" + +static int send_request(CURL *curl, const char *url, int seq, long auth_scheme, const char *userpwd) +{ + CURLcode res; + char* full_url = malloc(strlen(url) + 4 + 1); + if (!full_url) { + fprintf(stderr, "Not enough memory for full url\n"); + res = CURLE_OUT_OF_MEMORY; + goto test_cleanup; + } + + sprintf(full_url, "%s%04d", url, seq); + fprintf(stderr, "Sending new request %d to %s with credential %s (auth %d)\n", seq, full_url, userpwd, auth_scheme); + test_setopt(curl, CURLOPT_URL, full_url); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_HTTPGET, 1L); + test_setopt(curl, CURLOPT_USERPWD, userpwd); + test_setopt(curl, CURLOPT_HTTPAUTH, auth_scheme); + + res = curl_easy_perform(curl); + +test_cleanup: + free(full_url); + return res; +} + +static int send_wrong_password(CURL *curl, const char *url, int seq, long auth_scheme) +{ + return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass"); +} + +static int send_right_password(CURL *curl, const char *url, int seq, long auth_scheme) +{ + return send_request(curl, url, seq, auth_scheme, "testuser:testpass"); +} + +static long parse_auth_name(const char *arg) +{ + if (!arg) + return CURLAUTH_NONE; + if (strcasecmp(arg, "basic") == 0) + return CURLAUTH_BASIC; + if (strcasecmp(arg, "digest") == 0) + return CURLAUTH_DIGEST; + if (strcasecmp(arg, "ntlm") == 0) + return CURLAUTH_NTLM; + return CURLAUTH_NONE; +} + +int test(char *url) +{ + CURLcode res; + CURL *curl = NULL; + bool curl_is_init = FALSE; + + long main_auth_scheme = parse_auth_name(libtest_arg2); + long fallback_auth_scheme = parse_auth_name(libtest_arg3); + + if (main_auth_scheme == CURLAUTH_NONE || + fallback_auth_scheme == CURLAUTH_NONE) { + fprintf(stderr, "auth schemes not found on commandline\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + curl_is_init = TRUE; + + /* Send wrong password, then right password */ + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + + res = send_wrong_password(curl, url, 100, main_auth_scheme); + if (res != CURLE_OK) + goto test_cleanup; + curl_easy_reset(curl); + res = send_right_password(curl, url, 200, fallback_auth_scheme); + if (res != CURLE_OK) + goto test_cleanup; + curl_easy_reset(curl); + + curl_easy_cleanup(curl); + + /* Send wrong password twice, then right password */ + + if ((curl = curl_easy_init()) == NULL) { + fprintf(stderr, "curl_easy_init() failed\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + + res = send_wrong_password(curl, url, 300, main_auth_scheme); + if (res != CURLE_OK) + goto test_cleanup; + curl_easy_reset(curl); + + res = send_wrong_password(curl, url, 400, fallback_auth_scheme); + if (res != CURLE_OK) + goto test_cleanup; + curl_easy_reset(curl); + res = send_right_password(curl, url, 500, fallback_auth_scheme); + if (res != CURLE_OK) + goto test_cleanup; + curl_easy_reset(curl); + +test_cleanup: + + if (curl) + curl_easy_cleanup(curl); + if (curl_is_init) + curl_global_cleanup(); + + return (int)res; +} + -- cgit v1.2.1 From 69f5fe070dd0f20a5c4591c70d8d42bc0b8f02dc Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Mon, 6 Aug 2012 11:45:06 +0200 Subject: Fixed compiler warning - argument is type long. --- tests/libtest/libauthretry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c index 6403c839b..900e85fa4 100644 --- a/tests/libtest/libauthretry.c +++ b/tests/libtest/libauthretry.c @@ -39,7 +39,7 @@ static int send_request(CURL *curl, const char *url, int seq, long auth_scheme, } sprintf(full_url, "%s%04d", url, seq); - fprintf(stderr, "Sending new request %d to %s with credential %s (auth %d)\n", seq, full_url, userpwd, auth_scheme); + fprintf(stderr, "Sending new request %d to %s with credential %s (auth %ld)\n", seq, full_url, userpwd, auth_scheme); test_setopt(curl, CURLOPT_URL, full_url); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_HEADER, 1L); -- cgit v1.2.1 From 3b7d31c1eddc52431d8944aae6c7ab8aa7e29570 Mon Sep 17 00:00:00 2001 From: Joe Mason Date: Wed, 8 Aug 2012 18:15:04 -0400 Subject: NTLM: verify multiple connections work Add test2032 to test that NTLM does not switch connections in the middle of the handshake --- tests/libtest/.gitignore | 1 + tests/libtest/Makefile.inc | 4 +- tests/libtest/libntlmconnect.c | 246 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/libntlmconnect.c (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 7f8b619af..0a19470ab 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,3 +1,4 @@ chkhostname lib5[0-9][0-9] libauthretry +libntlmconnect diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 4b3edc11e..01594b8c9 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -19,7 +19,7 @@ noinst_PROGRAMS = chkhostname \ 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 lib586 lib587 \ - lib590 lib591 lib597 lib598 lib599 libauthretry + lib590 lib591 lib597 lib598 lib599 libauthretry libntlmconnect chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -187,3 +187,5 @@ lib598_SOURCES = lib598.c $(SUPPORTFILES) lib599_SOURCES = lib599.c $(SUPPORTFILES) libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) + +libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c new file mode 100644 index 000000000..8486f3c31 --- /dev/null +++ b/tests/libtest/libntlmconnect.c @@ -0,0 +1,246 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2012, Daniel Stenberg, , 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 +#include "testutil.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 5 * 1000 +#define MAX_EASY_HANDLES 3 + +CURL *easy[MAX_EASY_HANDLES]; +curl_socket_t sockets[MAX_EASY_HANDLES]; +int res = 0; + +static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) +{ + int idx = ((CURL **) data) - easy; + curl_socket_t sock; + + char *output = malloc(size * nmemb + 1); + memcpy(output, ptr, size * nmemb); + output[size * nmemb] = '\0'; + fprintf(stdout, "%s", output); + free(output); + + res = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &sock); + if (CURLE_OK != res) { + fprintf(stderr, "Error reading CURLINFO_LASTSOCKET\n"); + return 0; + } + /* sock will only be set for NTLM requests; for others it is -1 */ + if (sock != -1) { + if (sockets[idx] == -1) { + /* Data was written for this request before the socket was detected by + multi_fdset. Record the socket now. */ + sockets[idx] = sock; + } + else if (sock != sockets[idx]) { + fprintf(stderr, "Handle %d started on socket %d and moved to %d\n", idx, + sockets[idx], sock); + res = TEST_ERR_MAJOR_BAD; + return 0; + } + } + return size * nmemb; +} + +enum HandleState { + ReadyForNewHandle, + NeedSocketForNewHandle, + NoMoreHandles +}; + +int test(char *url) +{ + CURLM *multi = NULL; + int running; + int i, j; + int num_handles = 0; + enum HandleState state = ReadyForNewHandle; + char* full_url = malloc(strlen(url) + 4 + 1); + + start_test_timing(); + + if (!full_url) { + fprintf(stderr, "Not enough memory for full url\n"); + return CURLE_OUT_OF_MEMORY; + } + + for (i = 0; i < MAX_EASY_HANDLES; ++i) { + easy[i] = NULL; + sockets[i] = -1; + } + + res = 0; + res_global_init(CURL_GLOBAL_ALL); + if(res) { + return res; + } + + multi_init(multi); + + for(;;) { + struct timeval interval; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + long timeout = -99; + curl_socket_t maxfd = -99; + bool found_new_socket = FALSE; + + /* Start a new handle if we aren't at the max */ + if (state == ReadyForNewHandle) { + easy_init(easy[num_handles]); + + if (num_handles % 3 == 2) { + sprintf(full_url, "%s0200", url); + easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM); + } else { + sprintf(full_url, "%s0100", url); + easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + } + easy_setopt(easy[num_handles], CURLOPT_FRESH_CONNECT, 1L); + easy_setopt(easy[num_handles], CURLOPT_URL, full_url); + easy_setopt(easy[num_handles], CURLOPT_VERBOSE, 1L); + easy_setopt(easy[num_handles], CURLOPT_HTTPGET, 1L); + easy_setopt(easy[num_handles], CURLOPT_USERPWD, "testuser:testpass"); + easy_setopt(easy[num_handles], CURLOPT_WRITEFUNCTION, callback); + easy_setopt(easy[num_handles], CURLOPT_WRITEDATA, easy + num_handles); + easy_setopt(easy[num_handles], CURLOPT_HEADER, 1L); + + multi_add_handle(multi, easy[num_handles]); + num_handles += 1; + state = NeedSocketForNewHandle; + } + + multi_perform(multi, &running); + if (0 != res) + break; + + abort_on_test_timeout(); + + if(!running && state == NoMoreHandles) + break; /* done */ + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + + /* At this point, maxfd is guaranteed to be greater or equal than -1. */ + + /* Any socket which is new in fdread is associated with the new handle */ + for (i = 0; i <= maxfd; ++i) { + bool socket_exists = FALSE; + if (!FD_ISSET(i, &fdread)) { + continue; + } + + /* Check if this socket was already detected for an earlier handle (or + for this handle, num_handles-1, in the callback */ + for (j = 0; j < num_handles; ++j) { + if (sockets[j] == i) { + socket_exists = TRUE; + break; + } + } + if (socket_exists) { + continue; + } + + if (found_new_socket || state != NeedSocketForNewHandle) { + fprintf(stderr, "Unexpected new socket\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + + /* Now we know the socket is for the most recent handle, num_handles-1 */ + if (sockets[num_handles-1] != -1) { + /* A socket for this handle was already detected in the callback; if it + matched socket_exists should be true and we would never get here */ + assert(i != sockets[num_handles-1]); + fprintf(stderr, "Handle %d wrote to socket %d then detected on %d\n", + num_handles-1, sockets[num_handles-1], i); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + else { + sockets[num_handles-1] = i; + found_new_socket = TRUE; + /* continue to make sure there's only one new handle */ + } + } + + if (state == NeedSocketForNewHandle) { + if (found_new_socket) { + fprintf(stderr, "Warning: socket did not open immediately for new " + "handle (trying again)\n"); + continue; + } + state = num_handles < MAX_EASY_HANDLES ? ReadyForNewHandle + : NoMoreHandles; + } + + multi_timeout(multi, &timeout); + + /* At this point, timeout is guaranteed to be greater or equal than -1. */ + + if(timeout != -1L) { + interval.tv_sec = timeout/1000; + interval.tv_usec = (timeout%1000)*1000; + } + else { + interval.tv_sec = TEST_HANG_TIMEOUT/1000+1; + interval.tv_usec = 0; + } + + select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); + + abort_on_test_timeout(); + } + +test_cleanup: + + for (i = 0; i < MAX_EASY_HANDLES; ++i) { + if (easy[i]) { + if (multi) { + curl_multi_remove_handle(multi, easy[i]); + } + curl_easy_cleanup(easy[i]); + } + } + + if (multi) { + curl_multi_cleanup(multi); + } + + curl_global_cleanup(); + + if (full_url) { + free(full_url); + } + + return res; +} -- cgit v1.2.1 From 7735141e73a56810daf4b0727fb932f69386ce45 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 31 Aug 2012 23:23:40 +0200 Subject: test2032: bail out after last transfer The test would hang and get aborted with a "ABORTING TEST, since it seems that it would have run forever." until I prevented that from happening. I also fixed the data file which got broken CRLF line endings when I sucked down the path from Joe's repo == my fault. Removed #37 from KNOWN_BUGS as this fix and test case verifies exactly this. --- tests/libtest/libntlmconnect.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 8486f3c31..0ef8fc03f 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -207,6 +207,9 @@ int test(char *url) /* At this point, timeout is guaranteed to be greater or equal than -1. */ + fprintf(stderr, "%s:%d num_handles %d timeout %ld\n", + __FILE__, __LINE__, num_handles, timeout); + if(timeout != -1L) { interval.tv_sec = timeout/1000; interval.tv_usec = (timeout%1000)*1000; @@ -214,6 +217,13 @@ int test(char *url) else { interval.tv_sec = TEST_HANG_TIMEOUT/1000+1; interval.tv_usec = 0; + + /* if there's no timeout and we get here on the last handle, we may + already have read the last part of the stream so waiting makes no + sense */ + if(num_handles == 3) { + break; + } } select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &interval); -- cgit v1.2.1 From 40153716a31b6cf4e2d3abd27e986724472b4599 Mon Sep 17 00:00:00 2001 From: Joe Mason Date: Fri, 31 Aug 2012 19:11:17 -0400 Subject: Use MAX_EASY_HANDLES instead of hardcoding the number of handles twice --- tests/libtest/libntlmconnect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 0ef8fc03f..2450e8187 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -221,7 +221,7 @@ int test(char *url) /* if there's no timeout and we get here on the last handle, we may already have read the last part of the stream so waiting makes no sense */ - if(num_handles == 3) { + if(num_handles == MAX_EASY_HANDLES) { break; } } -- cgit v1.2.1 From 09d9dd8873258749924f8656803761fc8fbfeaec Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sat, 1 Sep 2012 23:27:11 +0200 Subject: Unit test for curl_multi_wait() --- tests/libtest/.gitignore | 1 + tests/libtest/Makefile.inc | 5 ++- tests/libtest/lib1500.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib1500.c (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 0a19470ab..80be891d6 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,4 +1,5 @@ chkhostname lib5[0-9][0-9] +lib1500 libauthretry libntlmconnect diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 01594b8c9..fa0c69cb5 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -19,7 +19,8 @@ noinst_PROGRAMS = chkhostname \ 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 lib586 lib587 \ - lib590 lib591 lib597 lib598 lib599 libauthretry libntlmconnect + lib590 lib591 lib597 lib598 lib599 libauthretry libntlmconnect \ + lib1500 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -186,6 +187,8 @@ lib598_SOURCES = lib598.c $(SUPPORTFILES) lib599_SOURCES = lib599.c $(SUPPORTFILES) +lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) + libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c new file mode 100644 index 000000000..c36545c52 --- /dev/null +++ b/tests/libtest/lib1500.c @@ -0,0 +1,89 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , 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 "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 60 * 1000 + +int test(char *URL) +{ + CURL* curls = NULL; + CURLM* multi = NULL; + int still_running; + int i = -1; + int res = 0; + CURLMsg *msg; + + start_test_timing(); + + global_init(CURL_GLOBAL_ALL); + + multi_init(multi); + + easy_init(curls); + + easy_setopt(curls, CURLOPT_URL, URL); + easy_setopt(curls, CURLOPT_HEADER, 1L); + + multi_add_handle(multi, curls); + + multi_perform(multi, &still_running); + + abort_on_test_timeout(); + + while(still_running) { + res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT); + if (res != CURLM_OK) { + printf("curl_multi_wait() returned %d\n", res); + res = -1; + goto test_cleanup; + } + + 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(); + + if(res) + i = res; + + return i; /* return the final return code */ +} -- cgit v1.2.1 From ef753b710b95f1f94a7c55f5d481615e30879aa6 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Tue, 11 Sep 2012 11:02:09 +0200 Subject: libntlmconnect.c: Fixed warning: comparison of signed/unsigned integer Windows does not use -1 to represent invalid sockets and the SOCKET type is unsigned. --- tests/libtest/libntlmconnect.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 2450e8187..0cfbdfe50 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -28,6 +28,12 @@ #define TEST_HANG_TIMEOUT 5 * 1000 #define MAX_EASY_HANDLES 3 +/* On Windows INVALID_SOCKET represents an invalid socket, not -1: + http://msdn.microsoft.com/en-us/library/windows/desktop/ms740516.aspx */ +#ifndef INVALID_SOCKET +#define INVALID_SOCKET -1 +#endif + CURL *easy[MAX_EASY_HANDLES]; curl_socket_t sockets[MAX_EASY_HANDLES]; int res = 0; @@ -49,8 +55,8 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) return 0; } /* sock will only be set for NTLM requests; for others it is -1 */ - if (sock != -1) { - if (sockets[idx] == -1) { + if (sock != INVALID_SOCKET) { + if (sockets[idx] == INVALID_SOCKET) { /* Data was written for this request before the socket was detected by multi_fdset. Record the socket now. */ sockets[idx] = sock; @@ -106,7 +112,7 @@ int test(char *url) fd_set fdwrite; fd_set fdexcep; long timeout = -99; - curl_socket_t maxfd = -99; + curl_socket_t curfd, maxfd = INVALID_SOCKET; bool found_new_socket = FALSE; /* Start a new handle if we aren't at the max */ @@ -152,16 +158,16 @@ int test(char *url) /* At this point, maxfd is guaranteed to be greater or equal than -1. */ /* Any socket which is new in fdread is associated with the new handle */ - for (i = 0; i <= maxfd; ++i) { + for (curfd = 0; curfd <= maxfd; ++curfd) { bool socket_exists = FALSE; - if (!FD_ISSET(i, &fdread)) { + if (!FD_ISSET(curfd, &fdread)) { continue; } /* Check if this socket was already detected for an earlier handle (or for this handle, num_handles-1, in the callback */ for (j = 0; j < num_handles; ++j) { - if (sockets[j] == i) { + if (sockets[j] == curfd) { socket_exists = TRUE; break; } @@ -177,17 +183,17 @@ int test(char *url) } /* Now we know the socket is for the most recent handle, num_handles-1 */ - if (sockets[num_handles-1] != -1) { + if (sockets[num_handles-1] != INVALID_SOCKET) { /* A socket for this handle was already detected in the callback; if it matched socket_exists should be true and we would never get here */ - assert(i != sockets[num_handles-1]); + assert(curfd != sockets[num_handles-1]); fprintf(stderr, "Handle %d wrote to socket %d then detected on %d\n", - num_handles-1, sockets[num_handles-1], i); + num_handles-1, sockets[num_handles-1], curfd); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; } else { - sockets[num_handles-1] = i; + sockets[num_handles-1] = curfd; found_new_socket = TRUE; /* continue to make sure there's only one new handle */ } -- cgit v1.2.1 From f9da9a0edbb982a125f050fb47f21880bc6cec6b Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Tue, 11 Sep 2012 12:19:05 +0200 Subject: libntlmconnect.c: Fixed warning: curl_easy_getinfo expects long pointer Fixed tests/libtest/libntlmconnect.c:52: warning: call to '_curl_easy_getinfo_err_long' declared with attribute warning: curl_easy_getinfo expects a pointer to long for this info --- tests/libtest/libntlmconnect.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 0cfbdfe50..61b40ec31 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -42,6 +42,7 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) { int idx = ((CURL **) data) - easy; curl_socket_t sock; + long lastsock; char *output = malloc(size * nmemb + 1); memcpy(output, ptr, size * nmemb); @@ -49,11 +50,17 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) fprintf(stdout, "%s", output); free(output); - res = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &sock); + res = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &lastsock); if (CURLE_OK != res) { fprintf(stderr, "Error reading CURLINFO_LASTSOCKET\n"); return 0; } + if (lastsock == -1) { + sock = INVALID_SOCKET; + } + else { + sock = (curl_socket_t)lastsocket; + } /* sock will only be set for NTLM requests; for others it is -1 */ if (sock != INVALID_SOCKET) { if (sockets[idx] == INVALID_SOCKET) { -- cgit v1.2.1 From c8846c09079a564ed1f24714acbf52b398b9cce1 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Tue, 11 Sep 2012 12:58:08 +0200 Subject: libntlmconnect.c: Fixed typo and conversion --- tests/libtest/libntlmconnect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 61b40ec31..b31a928af 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -59,7 +59,7 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) sock = INVALID_SOCKET; } else { - sock = (curl_socket_t)lastsocket; + sock = (curl_socket_t)lastsock; } /* sock will only be set for NTLM requests; for others it is -1 */ if (sock != INVALID_SOCKET) { @@ -160,7 +160,7 @@ int test(char *url) FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); - multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd); + multi_fdset(multi, &fdread, &fdwrite, &fdexcep, (int *)&maxfd); /* At this point, maxfd is guaranteed to be greater or equal than -1. */ -- cgit v1.2.1 From b78944146a0670b74be00e189f468adfc5fca5b7 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sat, 15 Sep 2012 10:38:52 -0700 Subject: curl_multi_wait: Add parameter to return number of active sockets Minor change to recently introduced function. BC breaking, but since curl_multi_wait() doesn't exist in any releases that should be fine. --- tests/libtest/lib1500.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c index c36545c52..784bdb2a2 100644 --- a/tests/libtest/lib1500.c +++ b/tests/libtest/lib1500.c @@ -54,12 +54,18 @@ int test(char *URL) abort_on_test_timeout(); while(still_running) { - res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT); + int num; + res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num); if (res != CURLM_OK) { printf("curl_multi_wait() returned %d\n", res); res = -1; goto test_cleanup; } + if (num != 1) { + printf("curl_multi_wait() returned on %d handle(s), expected 1\n", num); + res = -1; + goto test_cleanup; + } abort_on_test_timeout(); -- cgit v1.2.1 From b2954e66e87be7414a4508f8167ca531e653bea8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 4 Nov 2012 18:22:48 +0100 Subject: FTP: prevent the multi interface from blocking As pointed out in Bug report #3579064, curl_multi_perform() would wrongly use a blocking mechanism internally for some commands which could lead to for example a very long block if the LIST response never showed. The solution was to make sure to properly continue to use the multi interface non-blocking state machine. The new test 1501 verifies the fix. Bug: http://curl.haxx.se/bug/view.cgi?id=3579064 Reported by: Guido Berhoerster --- tests/libtest/.gitignore | 2 +- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib1501.c | 126 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 tests/libtest/lib1501.c (limited to 'tests/libtest') diff --git a/tests/libtest/.gitignore b/tests/libtest/.gitignore index 80be891d6..28e83c08d 100644 --- a/tests/libtest/.gitignore +++ b/tests/libtest/.gitignore @@ -1,5 +1,5 @@ chkhostname lib5[0-9][0-9] -lib1500 +lib150[0-9] libauthretry libntlmconnect diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index fa0c69cb5..e0ebcb4c7 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -20,7 +20,7 @@ noinst_PROGRAMS = chkhostname \ lib556 lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 lib568 \ lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib586 lib587 \ lib590 lib591 lib597 lib598 lib599 libauthretry libntlmconnect \ - lib1500 + lib1500 lib1501 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -189,6 +189,8 @@ lib599_SOURCES = lib599.c $(SUPPORTFILES) lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) +lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) + libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib1501.c b/tests/libtest/lib1501.c new file mode 100644 index 000000000..8d1a40571 --- /dev/null +++ b/tests/libtest/lib1501.c @@ -0,0 +1,126 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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 + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +#define TEST_HANG_TIMEOUT 30 * 1000 + +/* 500 milliseconds allowed. An extreme number but lets be really conservative + to allow old and slow machines to run this test too */ +#define MAX_BLOCKED_TIME_US 500000 + +/* return the number of microseconds between two time stamps */ +static int elapsed(struct timeval *before, + struct timeval *after) +{ + ssize_t result; + + result = (after->tv_sec - before->tv_sec) * 1000000 + + after->tv_usec - before->tv_usec; + if (result < 0) + result = 0; + + return curlx_sztosi(result); +} + + +int test(char *URL) +{ + CURL *handle = NULL; + CURLM *mhandle = NULL; + int res = 0; + int still_running = 0; + + start_test_timing(); + + global_init(CURL_GLOBAL_ALL); + + easy_init(handle); + + easy_setopt(handle, CURLOPT_URL, URL); + easy_setopt(handle, CURLOPT_VERBOSE, 1L); + + multi_init(mhandle); + + multi_add_handle(mhandle, handle); + + multi_perform(mhandle, &still_running); + + abort_on_test_timeout(); + + while(still_running) { + struct timeval timeout; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd = -99; + struct timeval before; + struct timeval after; + int e; + + timeout.tv_sec = 0; + timeout.tv_usec = 100000L; /* 100 ms */ + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + 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(); + + fprintf(stderr, "ping\n"); + gettimeofday(&before, 0); + + multi_perform(mhandle, &still_running); + + abort_on_test_timeout(); + + gettimeofday(&after, 0); + e = elapsed(&before, &after); + fprintf(stderr, "pong = %d\n", e); + + if(e > MAX_BLOCKED_TIME_US) { + res = 100; + break; + } + } + +test_cleanup: + + /* undocumented cleanup sequence - type UA */ + + curl_multi_cleanup(mhandle); + curl_easy_cleanup(handle); + curl_global_cleanup(); + + return res; +} -- cgit v1.2.1 From f99430d89ecccf2a899a743d6c856102e967e32a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Nov 2012 22:02:56 +0100 Subject: libauthretry.c: shorten lines to fit within 80 cols --- tests/libtest/libauthretry.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c index 900e85fa4..78b2775f9 100644 --- a/tests/libtest/libauthretry.c +++ b/tests/libtest/libauthretry.c @@ -28,7 +28,8 @@ #include "memdebug.h" -static int send_request(CURL *curl, const char *url, int seq, long auth_scheme, const char *userpwd) +static int send_request(CURL *curl, const char *url, int seq, + long auth_scheme, const char *userpwd) { CURLcode res; char* full_url = malloc(strlen(url) + 4 + 1); @@ -39,7 +40,8 @@ static int send_request(CURL *curl, const char *url, int seq, long auth_scheme, } sprintf(full_url, "%s%04d", url, seq); - fprintf(stderr, "Sending new request %d to %s with credential %s (auth %ld)\n", seq, full_url, userpwd, auth_scheme); + fprintf(stderr, "Sending new request %d to %s with credential %s " + "(auth %ld)\n", seq, full_url, userpwd, auth_scheme); test_setopt(curl, CURLOPT_URL, full_url); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_HEADER, 1L); @@ -50,16 +52,18 @@ static int send_request(CURL *curl, const char *url, int seq, long auth_scheme, res = curl_easy_perform(curl); test_cleanup: - free(full_url); + free(full_url); return res; } -static int send_wrong_password(CURL *curl, const char *url, int seq, long auth_scheme) +static int send_wrong_password(CURL *curl, const char *url, int seq, + long auth_scheme) { return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass"); } -static int send_right_password(CURL *curl, const char *url, int seq, long auth_scheme) +static int send_right_password(CURL *curl, const char *url, int seq, + long auth_scheme) { return send_request(curl, url, seq, auth_scheme, "testuser:testpass"); } @@ -87,7 +91,7 @@ int test(char *url) long fallback_auth_scheme = parse_auth_name(libtest_arg3); if (main_auth_scheme == CURLAUTH_NONE || - fallback_auth_scheme == CURLAUTH_NONE) { + fallback_auth_scheme == CURLAUTH_NONE) { fprintf(stderr, "auth schemes not found on commandline\n"); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; -- cgit v1.2.1 From 550e403f0023e1ca6c50a658e2d994e7f89d576b Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 10 Oct 2012 10:05:02 +0200 Subject: uniformly use AM_CPPFLAGS, avoid deprecated INCLUDES Since automake 1.12.4, the warnings are issued on running automake: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS') Avoid INCLUDES and roll these flags into AM_CPPFLAGS. Compile tested on: Ubuntu 10.04 (automake 1:1.11.1-1) Ubuntu 12.04 (automake 1:1.11.3-1ubuntu2) Arch Linux (automake 1.12.4) --- tests/libtest/Makefile.am | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 7b8d8fc04..bc9f532ae 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -35,19 +35,19 @@ AUTOMAKE_OPTIONS = foreign nostdinc # $(top_srcdir)/ares is for in-tree c-ares's external include files if USE_EMBEDDED_ARES -INCLUDES = -I$(top_builddir)/include/curl \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/lib \ - -I$(top_srcdir)/lib \ - -I$(top_builddir)/ares \ - -I$(top_srcdir)/ares +AM_CPPFLAGS = -I$(top_builddir)/include/curl \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_builddir)/ares \ + -I$(top_srcdir)/ares else -INCLUDES = -I$(top_builddir)/include/curl \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/lib \ - -I$(top_srcdir)/lib +AM_CPPFLAGS = -I$(top_builddir)/include/curl \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib endif EXTRA_DIST = test75.pl test307.pl test610.pl test613.pl test1013.pl \ -- cgit v1.2.1 From 6d1b493f3d456bfec1cc71c45199337314f999b0 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Thu, 8 Nov 2012 16:36:55 +0100 Subject: Fix compilation of lib1501 --- tests/libtest/Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index e0ebcb4c7..3cbc45aad 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -189,7 +189,7 @@ lib599_SOURCES = lib599.c $(SUPPORTFILES) lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) -lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) +lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) -- cgit v1.2.1 From 7c0cbcf2f617b4a2a50d4242ad468dae01e9ce13 Mon Sep 17 00:00:00 2001 From: Sergei Nikulov Date: Fri, 9 Nov 2012 17:29:02 +0400 Subject: fixed Visual Studio 2010 compilation --- tests/libtest/lib1501.c | 4 ++-- tests/libtest/lib582.c | 5 ++--- tests/libtest/libauthretry.c | 8 ++++---- tests/libtest/testtrace.c | 3 +++ 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib1501.c b/tests/libtest/lib1501.c index 8d1a40571..01a382e82 100644 --- a/tests/libtest/lib1501.c +++ b/tests/libtest/lib1501.c @@ -98,13 +98,13 @@ int test(char *URL) abort_on_test_timeout(); fprintf(stderr, "ping\n"); - gettimeofday(&before, 0); + before = tutil_tvnow(); multi_perform(mhandle, &still_running); abort_on_test_timeout(); - gettimeofday(&after, 0); + after = tutil_tvnow(); e = elapsed(&before, &after); fprintf(stderr, "pong = %d\n", e); diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 641b9b6df..952efb4ed 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -133,7 +133,7 @@ static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) (void)multi; /* unused */ if (timeout_ms != -1) { - gettimeofday(timeout, 0); + *timeout = tutil_tvnow(); timeout->tv_usec += timeout_ms * 1000; } else { @@ -173,8 +173,7 @@ static int getMicroSecondTimeout(struct timeval* timeout) { struct timeval now; ssize_t result; - - gettimeofday(&now, 0); + now = tutil_tvnow(); result = (timeout->tv_sec - now.tv_sec) * 1000000 + timeout->tv_usec - now.tv_usec; if (result < 0) diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c index 78b2775f9..b7d36fe1a 100644 --- a/tests/libtest/libauthretry.c +++ b/tests/libtest/libauthretry.c @@ -25,7 +25,7 @@ */ #include "test.h" - +#include "strequal.h" #include "memdebug.h" static int send_request(CURL *curl, const char *url, int seq, @@ -72,11 +72,11 @@ static long parse_auth_name(const char *arg) { if (!arg) return CURLAUTH_NONE; - if (strcasecmp(arg, "basic") == 0) + if (strequal(arg, "basic") == 0) return CURLAUTH_BASIC; - if (strcasecmp(arg, "digest") == 0) + if (strequal(arg, "digest") == 0) return CURLAUTH_DIGEST; - if (strcasecmp(arg, "ntlm") == 0) + if (strequal(arg, "ntlm") == 0) return CURLAUTH_NTLM; return CURLAUTH_NONE; } diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c index 64602e065..c977d2105 100644 --- a/tests/libtest/testtrace.c +++ b/tests/libtest/testtrace.c @@ -22,6 +22,9 @@ #include "test.h" +#define _MPRINTF_REPLACE /* use our functions only */ +#include + #include "testutil.h" #include "testtrace.h" #include "memdebug.h" -- cgit v1.2.1 From 32afaaef9342c5d599db295fe06c06f0678ed75d Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 16 Nov 2012 19:22:12 +0100 Subject: Fix the libauthretry changes from 7c0cbcf2f61 They broke the NTLM tests from 2023 to 2031. --- tests/libtest/libauthretry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c index b7d36fe1a..0b0816eab 100644 --- a/tests/libtest/libauthretry.c +++ b/tests/libtest/libauthretry.c @@ -72,11 +72,11 @@ static long parse_auth_name(const char *arg) { if (!arg) return CURLAUTH_NONE; - if (strequal(arg, "basic") == 0) + if (strequal(arg, "basic")) return CURLAUTH_BASIC; - if (strequal(arg, "digest") == 0) + if (strequal(arg, "digest")) return CURLAUTH_DIGEST; - if (strequal(arg, "ntlm") == 0) + if (strequal(arg, "ntlm")) return CURLAUTH_NTLM; return CURLAUTH_NONE; } -- cgit v1.2.1 From 409f2a041f752ef635354e1dc7b2759fcd7088d6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 18 Nov 2012 16:17:37 +0100 Subject: fixed memory leak: CURLOPT_RESOLVE with multi interface DNS cache entries populated with CURLOPT_RESOLVE were not properly freed again when done using the multi interface. Test case 1502 added to verify. Bug: http://curl.haxx.se/bug/view.cgi?id=3575448 Reported by: Alex Gruz --- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib1502.c | 138 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 tests/libtest/lib1502.c (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 3cbc45aad..b568e190e 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -20,7 +20,7 @@ noinst_PROGRAMS = chkhostname \ lib556 lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 lib568 \ lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585 lib586 lib587 \ lib590 lib591 lib597 lib598 lib599 libauthretry libntlmconnect \ - lib1500 lib1501 + lib1500 lib1501 lib1502 chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c chkhostname_LDADD = @CURL_NETWORK_LIBS@ @@ -191,6 +191,8 @@ lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1502_SOURCES = lib1502.c $(SUPPORTFILES) + libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib1502.c b/tests/libtest/lib1502.c new file mode 100644 index 000000000..ec1058826 --- /dev/null +++ b/tests/libtest/lib1502.c @@ -0,0 +1,138 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2012, Daniel Stenberg, , 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. + * + ***************************************************************************/ +/* + * Test case converted from bug report #3575448, identifying a memory leak in + * the CURLOPT_RESOLVE handling with the multi interface. + */ + +#include "test.h" + +#include +#include + +/* somewhat unix-specific */ +#include +#include + +int test(char *URL) +{ + CURL *ehandle; + CURLM *multi_handle; + char redirect[160]; + CURLcode result = CURLE_NOT_BUILT_IN; + int still_running; /* keep number of running handles */ + + CURLMsg *msg; /* for picking up messages with the transfer status */ + int msgs_left; /* how many messages are left */ + + /* DNS cache injection */ + struct curl_slist *dns_cache_list; + + sprintf(redirect, "google.com:%s:%s", libtest_arg2, libtest_arg3); + + fprintf(stderr, "Redirect: %s\n", redirect); + + dns_cache_list = curl_slist_append(NULL, redirect); + + /* Allocate one CURL handle per transfer */ + ehandle = curl_easy_init(); + + /* set the options (I left out a few, you'll get the point anyway) */ + curl_easy_setopt(ehandle, CURLOPT_URL, URL); + curl_easy_setopt(ehandle, CURLOPT_HEADER, 1L); + + curl_easy_setopt(ehandle, CURLOPT_RESOLVE, dns_cache_list); + + /* init a multi stack */ + multi_handle = curl_multi_init(); + + /* add the individual transfers */ + curl_multi_add_handle(multi_handle, ehandle); + + /* we start some action by calling perform right away */ + curl_multi_perform(multi_handle, &still_running); + + do { + struct timeval timeout; + int rc; /* select() return code */ + + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd = -1; + + long curl_timeo = -1; + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + /* set a suitable timeout to play around with */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + curl_multi_timeout(multi_handle, &curl_timeo); + if(curl_timeo >= 0) { + timeout.tv_sec = curl_timeo / 1000; + if(timeout.tv_sec > 1) + timeout.tv_sec = 1; + else + timeout.tv_usec = (curl_timeo % 1000) * 1000; + } + + /* 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. 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. */ + + rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); + + switch(rc) { + case -1: + /* select error */ + break; + case 0: /* timeout */ + default: /* action */ + curl_multi_perform(multi_handle, &still_running); + break; + } + } while(still_running); + + /* See how the transfers went */ + while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) { + if (msg->msg == CURLMSG_DONE) + result = msg->data.result; + } + + curl_multi_cleanup(multi_handle); + + /* Free the CURL handles */ + curl_easy_cleanup(ehandle); + + curl_slist_free_all(dns_cache_list); + + return (int)result; +} -- cgit v1.2.1 From 32be348af26352bec0051adcc2f1a718361d9214 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 15 Oct 2012 21:42:33 +0200 Subject: test2032: spurious failure caused by premature termination Bug: http://curl.haxx.se/mail/lib-2012-11/0095.html --- tests/libtest/libntlmconnect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index b31a928af..cef33069a 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -207,7 +207,7 @@ int test(char *url) } if (state == NeedSocketForNewHandle) { - if (found_new_socket) { + if(!found_new_socket) { fprintf(stderr, "Warning: socket did not open immediately for new " "handle (trying again)\n"); continue; @@ -234,7 +234,7 @@ int test(char *url) /* if there's no timeout and we get here on the last handle, we may already have read the last part of the stream so waiting makes no sense */ - if(num_handles == MAX_EASY_HANDLES) { + if(!running && num_handles == MAX_EASY_HANDLES) { break; } } -- cgit v1.2.1 From 52af6e69f079f28c137849e783f41d80768bc1be Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 18 Nov 2012 22:42:04 +0100 Subject: Get test 2032 working when using valgrind If curl_multi_fdset() sets maxfd to -1, the socket detection loop is skipped and thus !found_new_socket is no cause for alarm. --- tests/libtest/libntlmconnect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index cef33069a..fd64e5f84 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -207,7 +207,7 @@ int test(char *url) } if (state == NeedSocketForNewHandle) { - if(!found_new_socket) { + if(maxfd != -1 && !found_new_socket) { fprintf(stderr, "Warning: socket did not open immediately for new " "handle (trying again)\n"); continue; -- cgit v1.2.1 From 79954a1b07c6fc8ed4cf9d48c6383521b184c818 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 26 Nov 2012 16:23:02 +0100 Subject: avoid mixing of enumerated type with another type --- tests/libtest/libauthretry.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c index 0b0816eab..95761325a 100644 --- a/tests/libtest/libauthretry.c +++ b/tests/libtest/libauthretry.c @@ -28,8 +28,8 @@ #include "strequal.h" #include "memdebug.h" -static int send_request(CURL *curl, const char *url, int seq, - long auth_scheme, const char *userpwd) +static CURLcode send_request(CURL *curl, const char *url, int seq, + long auth_scheme, const char *userpwd) { CURLcode res; char* full_url = malloc(strlen(url) + 4 + 1); @@ -56,14 +56,14 @@ test_cleanup: return res; } -static int send_wrong_password(CURL *curl, const char *url, int seq, - long auth_scheme) +static CURLcode send_wrong_password(CURL *curl, const char *url, int seq, + long auth_scheme) { return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass"); } -static int send_right_password(CURL *curl, const char *url, int seq, - long auth_scheme) +static CURLcode send_right_password(CURL *curl, const char *url, int seq, + long auth_scheme) { return send_request(curl, url, seq, auth_scheme, "testuser:testpass"); } @@ -85,7 +85,6 @@ int test(char *url) { CURLcode res; CURL *curl = NULL; - bool curl_is_init = FALSE; long main_auth_scheme = parse_auth_name(libtest_arg2); long fallback_auth_scheme = parse_auth_name(libtest_arg3); @@ -93,29 +92,27 @@ int test(char *url) if (main_auth_scheme == CURLAUTH_NONE || fallback_auth_scheme == CURLAUTH_NONE) { fprintf(stderr, "auth schemes not found on commandline\n"); - res = TEST_ERR_MAJOR_BAD; - goto test_cleanup; + return TEST_ERR_MAJOR_BAD; } if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); - res = TEST_ERR_MAJOR_BAD; - goto test_cleanup; + return TEST_ERR_MAJOR_BAD; } - curl_is_init = TRUE; /* Send wrong password, then right password */ if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); - res = TEST_ERR_MAJOR_BAD; - goto test_cleanup; + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; } res = send_wrong_password(curl, url, 100, main_auth_scheme); if (res != CURLE_OK) goto test_cleanup; curl_easy_reset(curl); + res = send_right_password(curl, url, 200, fallback_auth_scheme); if (res != CURLE_OK) goto test_cleanup; @@ -127,8 +124,8 @@ int test(char *url) if ((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); - res = TEST_ERR_MAJOR_BAD; - goto test_cleanup; + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; } res = send_wrong_password(curl, url, 300, main_auth_scheme); @@ -140,6 +137,7 @@ int test(char *url) if (res != CURLE_OK) goto test_cleanup; curl_easy_reset(curl); + res = send_right_password(curl, url, 500, fallback_auth_scheme); if (res != CURLE_OK) goto test_cleanup; @@ -147,10 +145,8 @@ int test(char *url) test_cleanup: - if (curl) - curl_easy_cleanup(curl); - if (curl_is_init) - curl_global_cleanup(); + curl_easy_cleanup(curl); + curl_global_cleanup(); return (int)res; } -- cgit v1.2.1 From 16a8281f716234b86daf1737f9ab3fab66043e82 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 28 Nov 2012 18:31:23 +0100 Subject: build: avoid linkage of directly unused libraries --- tests/libtest/Makefile.am | 2 +- tests/libtest/Makefile.inc | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index bc9f532ae..c50f68c64 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -56,7 +56,7 @@ test1022.pl Makefile.inc notexists.pl CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@ # Dependencies (may need to be overriden) -LDADD = $(top_builddir)/lib/libcurl.la @CURL_LIBS@ +LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@ DEPENDENCIES = $(top_builddir)/lib/libcurl.la # Mostly for Windows build targets, when using static libcurl diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index b568e190e..df7a24d3c 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -28,20 +28,25 @@ chkhostname_DEPENDENCIES = chkhostname_CFLAGS = $(AM_CFLAGS) lib500_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) +lib500_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib501_SOURCES = lib501.c $(SUPPORTFILES) lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib502_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib503_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib504_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib505_SOURCES = lib505.c $(SUPPORTFILES) lib506_SOURCES = lib506.c $(SUPPORTFILES) lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib507_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib508_SOURCES = lib508.c $(SUPPORTFILES) @@ -74,31 +79,40 @@ lib523_SOURCES = lib523.c $(SUPPORTFILES) lib524_SOURCES = lib524.c $(SUPPORTFILES) lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib525_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib526_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB526 lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib527_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB527 lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib529_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529 lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib530_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib530_CPPFLAGS = $(AM_CPPFLAGS) -DLIB530 lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib532_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB532 lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib533_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib536_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS) lib539_SOURCES = lib539.c $(SUPPORTFILES) lib540_SOURCES = lib540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib540_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib541_SOURCES = lib541.c $(SUPPORTFILES) @@ -119,6 +133,7 @@ lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548 lib549_SOURCES = lib549.c $(SUPPORTFILES) lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib555_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS) @@ -131,16 +146,19 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) lib560_SOURCES = lib560.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib560_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib574_SOURCES = lib574.c $(SUPPORTFILES) lib575_SOURCES = lib575.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib575_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib576_SOURCES = lib576.c $(SUPPORTFILES) lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib564_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib565_SOURCES = lib510.c $(SUPPORTFILES) lib565_CPPFLAGS = $(AM_CPPFLAGS) -DLIB565 @@ -160,16 +178,19 @@ lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS) lib572_SOURCES = lib572.c $(SUPPORTFILES) lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE) +lib573_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib582_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib583_SOURCES = lib583.c $(SUPPORTFILES) lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) +lib585_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 lib586_SOURCES = lib586.c $(SUPPORTFILES) @@ -180,19 +201,24 @@ lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 lib590_SOURCES = lib590.c $(SUPPORTFILES) lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib591_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib597_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib598_SOURCES = lib598.c $(SUPPORTFILES) lib599_SOURCES = lib599.c $(SUPPORTFILES) lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) +lib1500_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1501_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ lib1502_SOURCES = lib1502.c $(SUPPORTFILES) libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) +libntlmconnect_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ -- cgit v1.2.1 From 4abf4fbaac170baca0b64063144e544805e0de11 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 28 Nov 2012 20:51:13 +0100 Subject: build: fix Windows build targets damaged since commit 550e403f00 --- tests/libtest/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index c50f68c64..66c183dde 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -61,7 +61,7 @@ DEPENDENCIES = $(top_builddir)/lib/libcurl.la # Mostly for Windows build targets, when using static libcurl if USE_CPPFLAG_CURL_STATICLIB -AM_CPPFLAGS = -DCURL_STATICLIB +AM_CPPFLAGS += -DCURL_STATICLIB endif # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, -- cgit v1.2.1 From 91b57cd6e560ab2b38169465b42741135c44f382 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 30 Nov 2012 14:34:48 +0100 Subject: build: prevent global LIBS from influencing libtest build targets --- tests/libtest/Makefile.am | 14 ++++++++++++- tests/libtest/Makefile.inc | 52 +++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 27 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 66c183dde..a9d0b9031 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -55,8 +55,20 @@ test1022.pl Makefile.inc notexists.pl CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@ +# Prevent global LIBS from influencing libtest build targets +BLANK_AT_MAKETIME = @BLANK_AT_MAKETIME@ +LIBS = $(BLANK_AT_MAKETIME) + +if USE_EXPLICIT_LIB_DEPS +SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@ +TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@ +else +SUPPORTFILES_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@ +TESTUTIL_LIBS = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +endif + # Dependencies (may need to be overriden) -LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_LIBS@ +LDADD = $(SUPPORTFILES_LIBS) DEPENDENCIES = $(top_builddir)/lib/libcurl.la # Mostly for Windows build targets, when using static libcurl diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index df7a24d3c..881622a90 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -28,25 +28,25 @@ chkhostname_DEPENDENCIES = chkhostname_CFLAGS = $(AM_CFLAGS) lib500_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) -lib500_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib500_LDADD = $(TESTUTIL_LIBS) lib501_SOURCES = lib501.c $(SUPPORTFILES) lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib502_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib502_LDADD = $(TESTUTIL_LIBS) lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib503_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib503_LDADD = $(TESTUTIL_LIBS) lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib504_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib504_LDADD = $(TESTUTIL_LIBS) lib505_SOURCES = lib505.c $(SUPPORTFILES) lib506_SOURCES = lib506.c $(SUPPORTFILES) lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib507_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib507_LDADD = $(TESTUTIL_LIBS) lib508_SOURCES = lib508.c $(SUPPORTFILES) @@ -79,40 +79,40 @@ lib523_SOURCES = lib523.c $(SUPPORTFILES) lib524_SOURCES = lib524.c $(SUPPORTFILES) lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib525_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib525_LDADD = $(TESTUTIL_LIBS) lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib526_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib526_LDADD = $(TESTUTIL_LIBS) lib526_CPPFLAGS = $(AM_CPPFLAGS) -DLIB526 lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib527_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib527_LDADD = $(TESTUTIL_LIBS) lib527_CPPFLAGS = $(AM_CPPFLAGS) -DLIB527 lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib529_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib529_LDADD = $(TESTUTIL_LIBS) lib529_CPPFLAGS = $(AM_CPPFLAGS) -DLIB529 lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib530_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib530_LDADD = $(TESTUTIL_LIBS) lib530_CPPFLAGS = $(AM_CPPFLAGS) -DLIB530 lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib532_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib532_LDADD = $(TESTUTIL_LIBS) lib532_CPPFLAGS = $(AM_CPPFLAGS) -DLIB532 lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib533_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib533_LDADD = $(TESTUTIL_LIBS) lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib536_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib536_LDADD = $(TESTUTIL_LIBS) lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS) lib539_SOURCES = lib539.c $(SUPPORTFILES) lib540_SOURCES = lib540.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib540_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib540_LDADD = $(TESTUTIL_LIBS) lib541_SOURCES = lib541.c $(SUPPORTFILES) @@ -133,7 +133,7 @@ lib548_CPPFLAGS = $(AM_CPPFLAGS) -DLIB548 lib549_SOURCES = lib549.c $(SUPPORTFILES) lib555_SOURCES = lib555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib555_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib555_LDADD = $(TESTUTIL_LIBS) lib552_SOURCES = lib552.c $(SUPPORTFILES) $(WARNLESS) @@ -146,19 +146,19 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES) lib557_SOURCES = lib557.c $(SUPPORTFILES) lib560_SOURCES = lib560.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib560_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib560_LDADD = $(TESTUTIL_LIBS) lib574_SOURCES = lib574.c $(SUPPORTFILES) lib575_SOURCES = lib575.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib575_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib575_LDADD = $(TESTUTIL_LIBS) lib576_SOURCES = lib576.c $(SUPPORTFILES) lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib564_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib564_LDADD = $(TESTUTIL_LIBS) lib565_SOURCES = lib510.c $(SUPPORTFILES) lib565_CPPFLAGS = $(AM_CPPFLAGS) -DLIB565 @@ -178,19 +178,19 @@ lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS) lib572_SOURCES = lib572.c $(SUPPORTFILES) lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE) -lib573_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib573_LDADD = $(TESTUTIL_LIBS) lib578_SOURCES = lib578.c $(SUPPORTFILES) lib579_SOURCES = lib579.c $(SUPPORTFILES) lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib582_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib582_LDADD = $(TESTUTIL_LIBS) lib583_SOURCES = lib583.c $(SUPPORTFILES) lib585_SOURCES = lib500.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE) -lib585_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib585_LDADD = $(TESTUTIL_LIBS) lib585_CPPFLAGS = $(AM_CPPFLAGS) -DLIB585 lib586_SOURCES = lib586.c $(SUPPORTFILES) @@ -201,24 +201,24 @@ lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587 lib590_SOURCES = lib590.c $(SUPPORTFILES) lib591_SOURCES = lib591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib591_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib591_LDADD = $(TESTUTIL_LIBS) lib597_SOURCES = lib597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib597_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib597_LDADD = $(TESTUTIL_LIBS) lib598_SOURCES = lib598.c $(SUPPORTFILES) lib599_SOURCES = lib599.c $(SUPPORTFILES) lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) -lib1500_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib1500_LDADD = $(TESTUTIL_LIBS) lib1501_SOURCES = lib1501.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) -lib1501_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +lib1501_LDADD = $(TESTUTIL_LIBS) lib1502_SOURCES = lib1502.c $(SUPPORTFILES) libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) -libntlmconnect_LDADD = $(top_builddir)/lib/libcurl.la @CURL_NETWORK_AND_TIME_LIBS@ +libntlmconnect_LDADD = $(TESTUTIL_LIBS) -- cgit v1.2.1 From b908376bef462644e204b50f7a8c3df5871883bf Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 4 Dec 2012 23:30:05 +0100 Subject: build: explain current role of LIBS in our Makefile.am files BLANK_AT_MAKETIME may be used in our Makefile.am files to blank LIBS variable used in generated makefile at makefile processing time. Doing this functionally prevents LIBS from being used for all link targets in given makefile. --- tests/libtest/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a9d0b9031..df13df111 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -55,8 +55,7 @@ test1022.pl Makefile.inc notexists.pl CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@ -# Prevent global LIBS from influencing libtest build targets -BLANK_AT_MAKETIME = @BLANK_AT_MAKETIME@ +# Prevent LIBS from being used for all link targets LIBS = $(BLANK_AT_MAKETIME) if USE_EXPLICIT_LIB_DEPS -- cgit v1.2.1 From 60edbf65b6d1bfd264e10a72cd35fb81bfad7b8d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 5 Dec 2012 17:28:32 +0100 Subject: libtest: fix some compiler warnings --- tests/libtest/Makefile.inc | 2 +- tests/libtest/lib1502.c | 9 +++++++-- tests/libtest/lib540.c | 11 ++++++++--- tests/libtest/lib591.c | 11 ++++++++--- tests/libtest/lib597.c | 11 ++++++++--- tests/libtest/libntlmconnect.c | 18 ++++++++++++------ 6 files changed, 44 insertions(+), 18 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 881622a90..c773d2b73 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -220,5 +220,5 @@ lib1502_SOURCES = lib1502.c $(SUPPORTFILES) libauthretry_SOURCES = libauthretry.c $(SUPPORTFILES) -libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) +libntlmconnect_SOURCES = libntlmconnect.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) libntlmconnect_LDADD = $(TESTUTIL_LIBS) diff --git a/tests/libtest/lib1502.c b/tests/libtest/lib1502.c index ec1058826..bb008f17c 100644 --- a/tests/libtest/lib1502.c +++ b/tests/libtest/lib1502.c @@ -26,6 +26,10 @@ #include "test.h" +#ifdef HAVE_LIMITS_H +#include +#endif + #include #include @@ -92,11 +96,12 @@ int test(char *URL) curl_multi_timeout(multi_handle, &curl_timeo); if(curl_timeo >= 0) { - timeout.tv_sec = curl_timeo / 1000; + int itimeout = (curl_timeo > (long)INT_MAX) ? INT_MAX : (int)curl_timeo; + timeout.tv_sec = itimeout / 1000; if(timeout.tv_sec > 1) timeout.tv_sec = 1; else - timeout.tv_usec = (curl_timeo % 1000) * 1000; + timeout.tv_usec = (itimeout % 1000) * 1000; } /* get file descriptors from the transfers */ diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index a47f1dee6..ac0ebe60b 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -30,6 +30,10 @@ #include "test.h" +#ifdef HAVE_LIMITS_H +#include +#endif + #include "testutil.h" #include "warnless.h" #include "memdebug.h" @@ -139,8 +143,9 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd, /* At this point, L is guaranteed to be greater or equal than -1. */ if(L != -1) { - T.tv_sec = L/1000; - T.tv_usec = (L%1000)*1000; + int itimeout = (L > (long)INT_MAX) ? INT_MAX : (int)L; + T.tv_sec = itimeout/1000; + T.tv_usec = (itimeout%1000)*1000; } else { T.tv_sec = 5; diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c index 8a55e2cd1..5cd4644e3 100644 --- a/tests/libtest/lib591.c +++ b/tests/libtest/lib591.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,10 @@ /* lib591 is used for test cases 591, 592, 593 and 594 */ +#ifdef HAVE_LIMITS_H +#include +#endif + #include #include "testutil.h" @@ -112,8 +116,9 @@ int test(char *URL) /* At this point, timeout is guaranteed to be greater or equal than -1. */ if(timeout != -1L) { - interval.tv_sec = timeout/1000; - interval.tv_usec = (timeout%1000)*1000; + int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; + interval.tv_sec = itimeout/1000; + interval.tv_usec = (itimeout%1000)*1000; } else { interval.tv_sec = 0; diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index 6a5ee4f8f..a27cefd5b 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -21,6 +21,10 @@ ***************************************************************************/ #include "test.h" +#ifdef HAVE_LIMITS_H +#include +#endif + #include "testutil.h" #include "warnless.h" #include "memdebug.h" @@ -113,8 +117,9 @@ int test(char *URL) /* At this point, timeout is guaranteed to be greater or equal than -1. */ if(timeout != -1L) { - interval.tv_sec = timeout/1000; - interval.tv_usec = (timeout%1000)*1000; + int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; + interval.tv_sec = itimeout/1000; + interval.tv_usec = (itimeout%1000)*1000; } else { interval.tv_sec = TEST_HANG_TIMEOUT/1000+1; diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index fd64e5f84..66d09e936 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -21,8 +21,13 @@ ***************************************************************************/ #include "test.h" +#ifdef HAVE_LIMITS_H +#include +#endif #include + #include "testutil.h" +#include "warnless.h" #include "memdebug.h" #define TEST_HANG_TIMEOUT 5 * 1000 @@ -40,7 +45,7 @@ int res = 0; static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) { - int idx = ((CURL **) data) - easy; + ssize_t idx = ((CURL **) data) - easy; curl_socket_t sock; long lastsock; @@ -69,8 +74,8 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) sockets[idx] = sock; } else if (sock != sockets[idx]) { - fprintf(stderr, "Handle %d started on socket %d and moved to %d\n", idx, - sockets[idx], sock); + fprintf(stderr, "Handle %d started on socket %d and moved to %d\n", + curlx_sztosi(idx), (int)sockets[idx], (int)sock); res = TEST_ERR_MAJOR_BAD; return 0; } @@ -195,7 +200,7 @@ int test(char *url) matched socket_exists should be true and we would never get here */ assert(curfd != sockets[num_handles-1]); fprintf(stderr, "Handle %d wrote to socket %d then detected on %d\n", - num_handles-1, sockets[num_handles-1], curfd); + num_handles-1, (int)sockets[num_handles-1], (int)curfd); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; } @@ -224,8 +229,9 @@ int test(char *url) __FILE__, __LINE__, num_handles, timeout); if(timeout != -1L) { - interval.tv_sec = timeout/1000; - interval.tv_usec = (timeout%1000)*1000; + int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; + interval.tv_sec = itimeout/1000; + interval.tv_usec = (itimeout%1000)*1000; } else { interval.tv_sec = TEST_HANG_TIMEOUT/1000+1; -- cgit v1.2.1 From 144650d6404a63fbce13037562a44a8ea030f615 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 2 Dec 2012 11:17:12 +0100 Subject: lib556: enable VERBOSE to ease debugging on failures --- tests/libtest/lib556.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 67da87f40..98062209f 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -52,6 +52,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); + test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); -- cgit v1.2.1