aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2014-01-29 00:31:00 +0100
committerDan Fandrich <dan@coneharvesters.com>2014-01-29 00:40:33 +0100
commit9873fd5317615168a0871058e8fd4668adc199b5 (patch)
treefed96d371e0acbe8fc8663e9eced599862678f31 /tests/libtest
parentd735d3e803bca23d782ab0791896a6b29fcd9eb2 (diff)
tests: make a few lib15?? tests pass the OOM torture tests
Diffstat (limited to 'tests/libtest')
-rw-r--r--tests/libtest/lib1506.c14
-rw-r--r--tests/libtest/lib1507.c20
-rw-r--r--tests/libtest/lib1510.c9
3 files changed, 25 insertions, 18 deletions
diff --git a/tests/libtest/lib1506.c b/tests/libtest/lib1506.c
index 008a9cae1..ca1cdc96f 100644
--- a/tests/libtest/lib1506.c
+++ b/tests/libtest/lib1506.c
@@ -32,13 +32,13 @@
int test(char *URL)
{
int res = 0;
- CURL *curl[NUM_HANDLES];
+ CURL *curl[NUM_HANDLES] = {0};
int running;
CURLM *m = NULL;
int i;
char target_url[256];
char dnsentry[256];
- struct curl_slist *slist = NULL;
+ struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
@@ -48,12 +48,14 @@ int test(char *URL)
for(i=0; i < NUM_HANDLES; i++) {
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
printf("%s\n", dnsentry);
- slist = curl_slist_append(slist, dnsentry);
+ slist2 = curl_slist_append(slist, dnsentry);
+ if(!slist2) {
+ fprintf(stderr, "curl_slist_append() failed\n");
+ goto test_cleanup;
+ }
+ slist = slist2;
}
- for(i=0; i < NUM_HANDLES; i++)
- curl[i] = NULL;
-
start_test_timing();
global_init(CURL_GLOBAL_ALL);
diff --git a/tests/libtest/lib1507.c b/tests/libtest/lib1507.c
index dec0c3bcf..5bb61b3b4 100644
--- a/tests/libtest/lib1507.c
+++ b/tests/libtest/lib1507.c
@@ -63,21 +63,18 @@ static long tvdiff(struct timeval newer, struct timeval older)
int test(char *URL)
{
- CURL *curl;
- CURLM *mcurl;
+ int res = 0;
+ CURL *curl = NULL;
+ CURLM *mcurl = NULL;
int still_running = 1;
struct timeval mp_start;
struct curl_slist* rcpt_list = NULL;
curl_global_init(CURL_GLOBAL_DEFAULT);
- curl = curl_easy_init();
- if(!curl)
- return 1;
+ easy_init(curl);
- mcurl = curl_multi_init();
- if(!mcurl)
- return 2;
+ multi_init(mcurl);
rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
/* more addresses can be added here
@@ -94,7 +91,7 @@ int test(char *URL)
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_multi_add_handle(mcurl, curl);
+ multi_add_handle(mcurl, curl);
mp_start = tvnow();
@@ -157,12 +154,15 @@ int test(char *URL)
}
}
+test_cleanup:
+
curl_slist_free_all(rcpt_list);
curl_multi_remove_handle(mcurl, curl);
curl_multi_cleanup(mcurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
- return 0;
+
+ return res;
}
diff --git a/tests/libtest/lib1510.c b/tests/libtest/lib1510.c
index 1bcf2165a..d19a7b5f0 100644
--- a/tests/libtest/lib1510.c
+++ b/tests/libtest/lib1510.c
@@ -36,7 +36,7 @@ int test(char *URL)
int i;
char target_url[256];
char dnsentry[256];
- struct curl_slist *slist = NULL;
+ struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
@@ -46,7 +46,12 @@ int test(char *URL)
for(i=0; i < NUM_URLS; i++) {
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
printf("%s\n", dnsentry);
- slist = curl_slist_append(slist, dnsentry);
+ slist2 = curl_slist_append(slist, dnsentry);
+ if(!slist2) {
+ fprintf(stderr, "curl_slist_append() failed\n");
+ goto test_cleanup;
+ }
+ slist = slist2;
}
start_test_timing();