aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-14 09:22:12 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-14 09:22:12 +0000
commite2e593a036c992f2d38e060e14b52c4a8862ca2d (patch)
tree69ce3c089381d03bd4f66792b2c994ddc0a13980 /tests
parent9ce0a7b49d4f004b7d55833a35feabbc8c27726f (diff)
clean up properly on failure to enable easier libcurl leak detection
Diffstat (limited to 'tests')
-rw-r--r--tests/libtest/lib503.c2
-rw-r--r--tests/libtest/lib504.c82
-rw-r--r--tests/libtest/lib505.c9
-rw-r--r--tests/libtest/lib506.c16
-rw-r--r--tests/libtest/lib507.c7
5 files changed, 65 insertions, 51 deletions
diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c
index e2bd42145..59cf4e655 100644
--- a/tests/libtest/lib503.c
+++ b/tests/libtest/lib503.c
@@ -54,7 +54,7 @@ int test(char *URL)
if (res != CURLM_OK) {
fprintf(stderr, "not okay???\n");
- return 80;
+ break;
}
FD_ZERO(&rd);
diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c
index 5f2c6acfc..df2e3ff2c 100644
--- a/tests/libtest/lib504.c
+++ b/tests/libtest/lib504.c
@@ -35,53 +35,55 @@ int test(char *URL)
res = curl_multi_add_handle(m, c);
if(res && (res != CURLM_CALL_MULTI_PERFORM))
- return 1; /* major failure */
- do {
- struct timeval interval;
+ ; /* major failure */
+ else {
+ do {
+ struct timeval interval;
- interval.tv_sec = 1;
- interval.tv_usec = 0;
+ interval.tv_sec = 1;
+ interval.tv_usec = 0;
- fprintf(stderr, "curl_multi_perform()\n");
+ fprintf(stderr, "curl_multi_perform()\n");
- do {
- res = curl_multi_perform(m, &running);
- } while (res == CURLM_CALL_MULTI_PERFORM);
- if(!running) {
- /* This is where this code is expected to reach */
- int numleft;
- CURLMsg *msg = curl_multi_info_read(m, &numleft);
- fprintf(stderr, "Expected: not running\n");
- if(msg && !numleft)
- ret = 100; /* this is where we should be */
- else
- ret = 99; /* not correct */
- break;
- }
- fprintf(stderr, "running == %d, res == %d\n", running, res);
+ do {
+ res = curl_multi_perform(m, &running);
+ } while (res == CURLM_CALL_MULTI_PERFORM);
+ if(!running) {
+ /* This is where this code is expected to reach */
+ int numleft;
+ CURLMsg *msg = curl_multi_info_read(m, &numleft);
+ fprintf(stderr, "Expected: not running\n");
+ if(msg && !numleft)
+ ret = 100; /* this is where we should be */
+ else
+ ret = 99; /* not correct */
+ break;
+ }
+ fprintf(stderr, "running == %d, res == %d\n", running, res);
- if (res != CURLM_OK) {
- ret = 2;
- break;
- }
+ if (res != CURLM_OK) {
+ ret = 2;
+ break;
+ }
- FD_ZERO(&rd);
- FD_ZERO(&wr);
- FD_ZERO(&exc);
- max_fd = 0;
+ FD_ZERO(&rd);
+ FD_ZERO(&wr);
+ FD_ZERO(&exc);
+ max_fd = 0;
- fprintf(stderr, "curl_multi_fdset()\n");
- if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
- fprintf(stderr, "unexpected failured of fdset.\n");
- ret = 3;
- break;
- }
- rc = select(max_fd+1, &rd, &wr, &exc, &interval);
- fprintf(stderr, "select returned %d\n", rc);
+ fprintf(stderr, "curl_multi_fdset()\n");
+ if (curl_multi_fdset(m, &rd, &wr, &exc, &max_fd) != CURLM_OK) {
+ fprintf(stderr, "unexpected failured of fdset.\n");
+ ret = 3;
+ break;
+ }
+ rc = select(max_fd+1, &rd, &wr, &exc, &interval);
+ fprintf(stderr, "select returned %d\n", rc);
- /* we only allow a certain number of loops to avoid hanging here
- forever */
- } while(rc && (--loop>0));
+ /* we only allow a certain number of loops to avoid hanging here
+ forever */
+ } while(rc && (--loop>0));
+ }
curl_multi_remove_handle(m, c);
curl_easy_cleanup(c);
diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c
index 131df7856..62c7b6880 100644
--- a/tests/libtest/lib505.c
+++ b/tests/libtest/lib505.c
@@ -72,9 +72,14 @@ int test(char *URL)
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
+ struct curl_slist *hl;
/* build a list of commands to pass to libcurl */
- headerlist = curl_slist_append(headerlist, buf_1);
- headerlist = curl_slist_append(headerlist, buf_2);
+ hl = curl_slist_append(headerlist, buf_1);
+ if(hl) {
+ headerlist = curl_slist_append(hl, buf_2);
+ if(hl)
+ headerlist = hl;
+ }
/* enable uploading */
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c
index 22f5d0698..52a4094a2 100644
--- a/tests/libtest/lib506.c
+++ b/tests/libtest/lib506.c
@@ -148,13 +148,19 @@ int test(char *URL)
/* prepare share */
printf( "SHARE_INIT\n" );
share = curl_share_init();
- curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock);
- curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock);
- curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
+ scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, lock);
+ scode += curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, unlock);
+ scode += curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
printf( "CURL_LOCK_DATA_COOKIE\n" );
- curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
+ scode += curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
printf( "CURL_LOCK_DATA_DNS\n" );
- curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
+ scode += curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
+
+ if(scode) {
+ curl_share_cleanup(share);
+ return 2;
+ }
+
res = 0;
diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c
index f45169496..b16c23368 100644
--- a/tests/libtest/lib507.c
+++ b/tests/libtest/lib507.c
@@ -39,9 +39,10 @@ int test(char *URL)
}
}
msg = curl_multi_info_read(multi, &still_running);
- /* this should now contain a result code from the easy handle,
- get it */
- i = msg->data.result;
+ if(msg)
+ /* this should now contain a result code from the easy handle,
+ get it */
+ i = msg->data.result;
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);