tests: make a few lib15?? tests pass the OOM torture tests
This commit is contained in:
parent
d735d3e803
commit
9873fd5317
@ -32,13 +32,13 @@
|
|||||||
int test(char *URL)
|
int test(char *URL)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
CURL *curl[NUM_HANDLES];
|
CURL *curl[NUM_HANDLES] = {0};
|
||||||
int running;
|
int running;
|
||||||
CURLM *m = NULL;
|
CURLM *m = NULL;
|
||||||
int i;
|
int i;
|
||||||
char target_url[256];
|
char target_url[256];
|
||||||
char dnsentry[256];
|
char dnsentry[256];
|
||||||
struct curl_slist *slist = NULL;
|
struct curl_slist *slist = NULL, *slist2;
|
||||||
char *port = libtest_arg3;
|
char *port = libtest_arg3;
|
||||||
char *address = libtest_arg2;
|
char *address = libtest_arg2;
|
||||||
|
|
||||||
@ -48,12 +48,14 @@ int test(char *URL)
|
|||||||
for(i=0; i < NUM_HANDLES; i++) {
|
for(i=0; i < NUM_HANDLES; i++) {
|
||||||
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
|
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
|
||||||
printf("%s\n", dnsentry);
|
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();
|
start_test_timing();
|
||||||
|
|
||||||
global_init(CURL_GLOBAL_ALL);
|
global_init(CURL_GLOBAL_ALL);
|
||||||
|
@ -63,21 +63,18 @@ static long tvdiff(struct timeval newer, struct timeval older)
|
|||||||
|
|
||||||
int test(char *URL)
|
int test(char *URL)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
int res = 0;
|
||||||
CURLM *mcurl;
|
CURL *curl = NULL;
|
||||||
|
CURLM *mcurl = NULL;
|
||||||
int still_running = 1;
|
int still_running = 1;
|
||||||
struct timeval mp_start;
|
struct timeval mp_start;
|
||||||
struct curl_slist* rcpt_list = NULL;
|
struct curl_slist* rcpt_list = NULL;
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
|
||||||
curl = curl_easy_init();
|
easy_init(curl);
|
||||||
if(!curl)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
mcurl = curl_multi_init();
|
multi_init(mcurl);
|
||||||
if(!mcurl)
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
|
rcpt_list = curl_slist_append(rcpt_list, RECIPIENT);
|
||||||
/* more addresses can be added here
|
/* 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_FROM, MAILFROM);
|
||||||
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
|
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||||
curl_multi_add_handle(mcurl, curl);
|
multi_add_handle(mcurl, curl);
|
||||||
|
|
||||||
mp_start = tvnow();
|
mp_start = tvnow();
|
||||||
|
|
||||||
@ -157,12 +154,15 @@ int test(char *URL)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_cleanup:
|
||||||
|
|
||||||
curl_slist_free_all(rcpt_list);
|
curl_slist_free_all(rcpt_list);
|
||||||
curl_multi_remove_handle(mcurl, curl);
|
curl_multi_remove_handle(mcurl, curl);
|
||||||
curl_multi_cleanup(mcurl);
|
curl_multi_cleanup(mcurl);
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
return 0;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ int test(char *URL)
|
|||||||
int i;
|
int i;
|
||||||
char target_url[256];
|
char target_url[256];
|
||||||
char dnsentry[256];
|
char dnsentry[256];
|
||||||
struct curl_slist *slist = NULL;
|
struct curl_slist *slist = NULL, *slist2;
|
||||||
char *port = libtest_arg3;
|
char *port = libtest_arg3;
|
||||||
char *address = libtest_arg2;
|
char *address = libtest_arg2;
|
||||||
|
|
||||||
@ -46,7 +46,12 @@ int test(char *URL)
|
|||||||
for(i=0; i < NUM_URLS; i++) {
|
for(i=0; i < NUM_URLS; i++) {
|
||||||
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
|
sprintf(dnsentry, "server%d.example.com:%s:%s", i + 1, port, address);
|
||||||
printf("%s\n", dnsentry);
|
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();
|
start_test_timing();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user