aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/libtest/lib500.c18
-rw-r--r--tests/libtest/lib501.c20
-rw-r--r--tests/libtest/lib502.c58
-rw-r--r--tests/libtest/lib503.c34
-rw-r--r--tests/libtest/lib504.c150
-rw-r--r--tests/libtest/lib505.c85
-rw-r--r--tests/libtest/lib506.c29
-rw-r--r--tests/libtest/lib507.c32
-rw-r--r--tests/libtest/lib508.c52
-rw-r--r--tests/libtest/lib509.c158
-rw-r--r--tests/libtest/lib510.c60
-rw-r--r--tests/libtest/lib511.c18
-rw-r--r--tests/libtest/lib512.c2
-rw-r--r--tests/libtest/lib513.c52
-rw-r--r--tests/libtest/lib514.c58
-rw-r--r--tests/libtest/lib515.c36
-rw-r--r--tests/libtest/lib516.c34
-rw-r--r--tests/libtest/lib518.c33
-rw-r--r--tests/libtest/lib519.c18
-rw-r--r--tests/libtest/lib520.c18
-rw-r--r--tests/libtest/lib521.c17
-rw-r--r--tests/libtest/lib523.c17
-rw-r--r--tests/libtest/lib524.c17
-rw-r--r--tests/libtest/lib525.c34
-rw-r--r--tests/libtest/lib526.c37
-rw-r--r--tests/libtest/lib530.c43
-rw-r--r--tests/libtest/lib533.c32
-rw-r--r--tests/libtest/lib536.c23
-rw-r--r--tests/libtest/test.h3
29 files changed, 833 insertions, 355 deletions
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,