summaryrefslogtreecommitdiff
path: root/tests/libtest
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-05 18:07:19 +0000
committerYang Tse <yangsita@gmail.com>2010-02-05 18:07:19 +0000
commitcad9c3f55fad5da988144dc83ad76a8544a071a2 (patch)
tree9231f49bc11dfdb69b4cac9af3b1dd473d1507ad /tests/libtest
parent12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff)
downloadcurl-cad9c3f55fad5da988144dc83ad76a8544a071a2.tar.gz
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest')
-rw-r--r--tests/libtest/lib500.c6
-rw-r--r--tests/libtest/lib501.c4
-rw-r--r--tests/libtest/lib502.c12
-rw-r--r--tests/libtest/lib503.c22
-rw-r--r--tests/libtest/lib504.c46
-rw-r--r--tests/libtest/lib505.c14
-rw-r--r--tests/libtest/lib506.c10
-rw-r--r--tests/libtest/lib507.c22
-rw-r--r--tests/libtest/lib508.c18
-rw-r--r--tests/libtest/lib510.c22
-rw-r--r--tests/libtest/lib511.c10
-rw-r--r--tests/libtest/lib513.c16
-rw-r--r--tests/libtest/lib514.c16
-rw-r--r--tests/libtest/lib515.c12
-rw-r--r--tests/libtest/lib516.c10
-rw-r--r--tests/libtest/lib518.c6
-rw-r--r--tests/libtest/lib519.c12
-rw-r--r--tests/libtest/lib520.c8
-rw-r--r--tests/libtest/lib521.c10
-rw-r--r--tests/libtest/lib523.c12
-rw-r--r--tests/libtest/lib524.c8
-rw-r--r--tests/libtest/lib525.c28
-rw-r--r--tests/libtest/lib526.c36
-rw-r--r--tests/libtest/lib530.c42
-rw-r--r--tests/libtest/lib533.c19
-rw-r--r--tests/libtest/lib536.c13
-rw-r--r--tests/libtest/lib537.c6
-rw-r--r--tests/libtest/lib539.c21
-rw-r--r--tests/libtest/lib540.c81
-rw-r--r--tests/libtest/lib541.c10
-rw-r--r--tests/libtest/lib542.c10
-rw-r--r--tests/libtest/lib543.c15
-rw-r--r--tests/libtest/lib544.c12
-rw-r--r--tests/libtest/lib547.c28
-rw-r--r--tests/libtest/lib549.c15
-rw-r--r--tests/libtest/lib552.c62
-rw-r--r--tests/libtest/lib553.c68
-rw-r--r--tests/libtest/lib554.c16
-rw-r--r--tests/libtest/lib555.c37
-rw-r--r--tests/libtest/lib556.c5
-rw-r--r--tests/libtest/lib560.c18
-rw-r--r--tests/libtest/lib562.c8
-rw-r--r--tests/libtest/lib564.c15
-rw-r--r--tests/libtest/lib566.c6
-rw-r--r--tests/libtest/lib567.c19
-rw-r--r--tests/libtest/lib568.c100
-rw-r--r--tests/libtest/lib569.c57
-rw-r--r--tests/libtest/lib570.c54
-rw-r--r--tests/libtest/lib571.c67
-rw-r--r--tests/libtest/test.h3
50 files changed, 736 insertions, 431 deletions
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 */