1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

tests/libtest: follow our code style guidelines better

... checksrc of all test code is pending.
This commit is contained in:
Daniel Stenberg 2016-04-03 11:57:34 +02:00
parent c7e4266a2e
commit 365322b8bc
71 changed files with 675 additions and 654 deletions

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char buff[HOSTNAME_MAX]; char buff[HOSTNAME_MAX];
if (argc != 2) { if(argc != 2) {
printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]); printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]);
return 1; return 1;
} }
if (Curl_gethostname(buff, HOSTNAME_MAX)) { if(Curl_gethostname(buff, HOSTNAME_MAX)) {
printf("Curl_gethostname() failed\n"); printf("Curl_gethostname() failed\n");
return 1; return 1;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -56,7 +56,7 @@ int test(char *URL)
while(still_running) { while(still_running) {
int num; int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num); res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if (res != CURLM_OK) { if(res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res); printf("curl_multi_wait() returned %d\n", res);
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -41,7 +41,7 @@ static int elapsed(struct timeval *before,
result = (after->tv_sec - before->tv_sec) * 1000000 + result = (after->tv_sec - before->tv_sec) * 1000000 +
after->tv_usec - before->tv_usec; after->tv_usec - before->tv_usec;
if (result < 0) if(result < 0)
result = 0; result = 0;
return curlx_sztosi(result); return curlx_sztosi(result);

View File

@ -46,7 +46,8 @@ int test(char *URL)
/* Create fake DNS entries for serverX.example.com for all handles */ /* Create fake DNS entries for serverX.example.com for all handles */
for(i=0; i < NUM_HANDLES; i++) { for(i=0; i < NUM_HANDLES; i++) {
snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, port, address); snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s",
i + 1, port, address);
printf("%s\n", dnsentry); printf("%s\n", dnsentry);
slist2 = curl_slist_append(slist, dnsentry); slist2 = curl_slist_append(slist, dnsentry);
if(!slist2) { if(!slist2) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -137,7 +137,7 @@ int test(char *URL)
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
if (tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { if(tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) {
fprintf(stderr, "ABORTING TEST, since it seems " fprintf(stderr, "ABORTING TEST, since it seems "
"that it would have run forever.\n"); "that it would have run forever.\n");
break; break;

View File

@ -44,7 +44,8 @@ int test(char *URL)
/* Create fake DNS entries for serverX.example.com for all handles */ /* Create fake DNS entries for serverX.example.com for all handles */
for(i=0; i < NUM_URLS; i++) { for(i=0; i < NUM_URLS; i++) {
snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, port, address); snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
port, address);
printf("%s\n", dnsentry); printf("%s\n", dnsentry);
slist2 = curl_slist_append(slist, dnsentry); slist2 = curl_slist_append(slist, dnsentry);
if(!slist2) { if(!slist2) {

View File

@ -49,7 +49,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
snprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s", port, address); snprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s",
port, address);
printf("%s\n", dnsentry); printf("%s\n", dnsentry);
slist = curl_slist_append(slist, dnsentry); slist = curl_slist_append(slist, dnsentry);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -39,7 +39,8 @@
#define sleep(s) Sleep(s * 1000) #define sleep(s) Sleep(s * 1000)
#endif #endif
static int debug_callback(CURL *curl, curl_infotype info, char *msg, size_t len, void *ptr) static int debug_callback(CURL *curl, curl_infotype info, char *msg,
size_t len, void *ptr)
{ {
(void)curl; (void)curl;
(void)ptr; (void)ptr;
@ -121,7 +122,8 @@ int test(char *URL)
int i; int i;
int count = 2; int count = 2;
snprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s", port, address); snprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s",
port, address);
start_test_timing(); start_test_timing();
@ -130,7 +132,8 @@ int test(char *URL)
for(i = 1; i <= count; i++) { for(i = 1; i <= count; i++) {
char target_url[256]; char target_url[256];
snprintf(target_url, sizeof(target_url), "http://testserver.example.com:%s/%s%04d", port, path, i); snprintf(target_url, sizeof(target_url),
"http://testserver.example.com:%s/%s%04d", port, path, i);
/* second request must succeed like the first one */ /* second request must succeed like the first one */
if((res = do_one_request(multi, target_url, dns_entry))) if((res = do_one_request(multi, target_url, dns_entry)))

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al. * Copyright (C) 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
@ -35,7 +35,7 @@ static char data [] = "Hello Cloud!\n";
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t amount = nmemb * size; /* Total bytes curl wants */ size_t amount = nmemb * size; /* Total bytes curl wants */
if (amount < strlen(data)) { if(amount < strlen(data)) {
return strlen(data); return strlen(data);
} }
(void)stream; (void)stream;
@ -64,7 +64,7 @@ int test(char *URL)
hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
if (!hhl) { if(!hhl) {
goto test_cleanup; goto test_cleanup;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al. * Copyright (C) 1998 - 2016, Vijay Panghal, <vpanghal@maginatics.com>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -34,7 +34,7 @@ static char data [] = "Hello Cloud!\n";
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t amount = nmemb * size; /* Total bytes curl wants */ size_t amount = nmemb * size; /* Total bytes curl wants */
if (amount < strlen(data)) { if(amount < strlen(data)) {
return strlen(data); return strlen(data);
} }
(void)stream; (void)stream;
@ -62,11 +62,11 @@ int test(char *URL)
hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
phl = curl_slist_append(phl, "User-Agent: Proxy Agent"); phl = curl_slist_append(phl, "User-Agent: Proxy Agent");
if (!hhl || !phl) { if(!hhl || !phl) {
goto test_cleanup; goto test_cleanup;
} }
tmp = curl_slist_append(phl, "Expect:"); tmp = curl_slist_append(phl, "Expect:");
if (!tmp) { if(!tmp) {
goto test_cleanup; goto test_cleanup;
} }
phl = tmp; phl = tmp;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al. * Copyright (C) 1998 - 2016, Vijay Panghal, <vpanghal@maginatics.com>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -34,7 +34,7 @@ static char data [] = "Hello Cloud!\n";
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t amount = nmemb * size; /* Total bytes curl wants */ size_t amount = nmemb * size; /* Total bytes curl wants */
if (amount < strlen(data)) { if(amount < strlen(data)) {
return strlen(data); return strlen(data);
} }
(void)stream; (void)stream;
@ -62,11 +62,11 @@ int test(char *URL)
} }
hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
if (!hhl) { if(!hhl) {
goto test_cleanup; goto test_cleanup;
} }
tmp = curl_slist_append(hhl, "Expect: 100-continue"); tmp = curl_slist_append(hhl, "Expect: 100-continue");
if (!tmp) { if(!tmp) {
goto test_cleanup; goto test_cleanup;
} }
hhl = tmp; hhl = tmp;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -46,7 +46,7 @@ int test(char *URL)
hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
phl = curl_slist_append(phl, "Proxy-User-Agent: Http Agent2"); phl = curl_slist_append(phl, "Proxy-User-Agent: Http Agent2");
if (!hhl) { if(!hhl) {
goto test_cleanup; goto test_cleanup;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -49,7 +49,8 @@ int test(char *URL)
/* set the options (I left out a few, you'll get the point anyway) */ /* set the options (I left out a few, you'll get the point anyway) */
curl_easy_setopt(easy, CURLOPT_URL, URL); curl_easy_setopt(easy, CURLOPT_URL, URL);
curl_easy_setopt(easy, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)testDataSize); curl_easy_setopt(easy, CURLOPT_POSTFIELDSIZE_LARGE,
(curl_off_t)testDataSize);
curl_easy_setopt(easy, CURLOPT_POSTFIELDS, testData); curl_easy_setopt(easy, CURLOPT_POSTFIELDS, testData);
/* we start some action by calling perform right away */ /* we start some action by calling perform right away */
@ -87,8 +88,7 @@ int test(char *URL)
/* get file descriptors from the transfers */ /* get file descriptors from the transfers */
mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
if(mc != CURLM_OK) if(mc != CURLM_OK) {
{
fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc);
break; break;
} }
@ -127,8 +127,8 @@ int test(char *URL)
} while(still_running); } while(still_running);
/* See how the transfers went */ /* See how the transfers went */
while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) { while((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
if (msg->msg == CURLMSG_DONE) { if(msg->msg == CURLMSG_DONE) {
printf("HTTP transfer completed with status %d\n", msg->data.result); printf("HTTP transfer completed with status %d\n", msg->data.result);
break; break;
} }

View File

@ -192,12 +192,12 @@ int test(char *URL)
abort_on_test_timeout(); abort_on_test_timeout();
/* See how the transfers went */ /* See how the transfers went */
while ((msg = curl_multi_info_read(m, &msgs_left))) { while((msg = curl_multi_info_read(m, &msgs_left))) {
if (msg->msg == CURLMSG_DONE) { if(msg->msg == CURLMSG_DONE) {
int i, found = 0; int i, found = 0;
/* Find out which handle this message is about */ /* Find out which handle this message is about */
for (i = 0; i < num_handles; i++) { for(i = 0; i < num_handles; i++) {
found = (msg->easy_handle == handles[i]); found = (msg->easy_handle == handles[i]);
if(found) if(found)
break; break;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -63,12 +63,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
char *ipstr=NULL; char *ipstr=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -92,42 +92,42 @@ int test(char *URL)
if(!res) { if(!res) {
res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr); res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr);
if (libtest_arg2) { if(libtest_arg2) {
FILE *moo = fopen(libtest_arg2, "wb"); FILE *moo = fopen(libtest_arg2, "wb");
if(moo) { if(moo) {
double time_namelookup; double time_namelookup;
double time_connect; double time_connect;
double time_pretransfer; double time_pretransfer;
double time_starttransfer; double time_starttransfer;
double time_total; double time_total;
fprintf(moo, "IP: %s\n", ipstr); fprintf(moo, "IP: %s\n", ipstr);
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup);
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect);
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer);
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME,
&time_starttransfer); &time_starttransfer);
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total);
/* since the timing will always vary we only compare relative differences /* since the timing will always vary we only compare relative
between these 5 times */ differences between these 5 times */
if(time_namelookup > time_connect) { if(time_namelookup > time_connect) {
fprintf(moo, "namelookup vs connect: %f %f\n", fprintf(moo, "namelookup vs connect: %f %f\n",
time_namelookup, time_connect); time_namelookup, time_connect);
} }
if(time_connect > time_pretransfer) { if(time_connect > time_pretransfer) {
fprintf(moo, "connect vs pretransfer: %f %f\n", fprintf(moo, "connect vs pretransfer: %f %f\n",
time_connect, time_pretransfer); time_connect, time_pretransfer);
} }
if(time_pretransfer > time_starttransfer) { if(time_pretransfer > time_starttransfer) {
fprintf(moo, "pretransfer vs starttransfer: %f %f\n", fprintf(moo, "pretransfer vs starttransfer: %f %f\n",
time_pretransfer, time_starttransfer); time_pretransfer, time_starttransfer);
} }
if(time_starttransfer > time_total) { if(time_starttransfer > time_total) {
fprintf(moo, "starttransfer vs total: %f %f\n", fprintf(moo, "starttransfer vs total: %f %f\n",
time_starttransfer, time_total); time_starttransfer, time_total);
} }
fclose(moo); fclose(moo);
} }
} }
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -30,12 +30,12 @@ int test(char *URL)
(void)URL; /* we don't use this */ (void)URL; /* we don't use this */
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -50,7 +50,7 @@ int test(char *URL)
/* The point here is that there must not be anything running on the given /* The point here is that there must not be anything running on the given
proxy port */ proxy port */
if (libtest_arg2) if(libtest_arg2)
easy_setopt(c, CURLOPT_PROXY, libtest_arg2); easy_setopt(c, CURLOPT_PROXY, libtest_arg2);
easy_setopt(c, CURLOPT_URL, URL); easy_setopt(c, CURLOPT_URL, URL);
easy_setopt(c, CURLOPT_VERBOSE, 1L); easy_setopt(c, CURLOPT_VERBOSE, 1L);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -38,8 +38,8 @@ int test(char *URL)
{ {
CURL *curl; CURL *curl;
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
FILE *hd_src ; FILE *hd_src;
int hd ; int hd;
struct_stat file_info; struct_stat file_info;
struct curl_slist *hl; struct curl_slist *hl;
int error; int error;
@ -48,7 +48,7 @@ int test(char *URL)
const char *buf_1 = "RNFR 505"; const char *buf_1 = "RNFR 505";
const char *buf_2 = "RNTO 505-forreal"; const char *buf_2 = "RNTO 505-forreal";
if (!libtest_arg2) { if(!libtest_arg2) {
fprintf(stderr, "Usage: <url> <file-to-upload>\n"); fprintf(stderr, "Usage: <url> <file-to-upload>\n");
return TEST_ERR_USAGE; return TEST_ERR_USAGE;
} }
@ -56,7 +56,7 @@ int test(char *URL)
hd_src = fopen(libtest_arg2, "rb"); hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) { if(NULL == hd_src) {
error = ERRNO; error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d %s\n", fprintf(stderr, "fopen failed with error: %d %s\n",
error, strerror(error)); error, strerror(error));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2); fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */ return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */
@ -80,14 +80,15 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src); fclose(hd_src);
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* get a curl handle */ /* get a curl handle */
if ((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
fclose(hd_src); fclose(hd_src);
@ -96,14 +97,16 @@ int test(char *URL)
/* build a list of commands to pass to libcurl */ /* build a list of commands to pass to libcurl */
if ((hl = curl_slist_append(headerlist, buf_1)) == NULL) { hl = curl_slist_append(headerlist, buf_1);
if(!hl) {
fprintf(stderr, "curl_slist_append() failed\n"); fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();
fclose(hd_src); fclose(hd_src);
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((headerlist = curl_slist_append(hl, buf_2)) == NULL) { headerlist = curl_slist_append(hl, buf_2);
if(!headerlist) {
fprintf(stderr, "curl_slist_append() failed\n"); fprintf(stderr, "curl_slist_append() failed\n");
curl_slist_free_all(hl); curl_slist_free_all(hl);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
@ -120,7 +123,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */ /* specify target */
test_setopt(curl,CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
/* pass in that last of FTP commands to run after the transfer */ /* pass in that last of FTP commands to run after the transfer */
test_setopt(curl, CURLOPT_POSTQUOTE, headerlist); test_setopt(curl, CURLOPT_POSTQUOTE, headerlist);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -40,8 +40,8 @@ struct userdata {
int lock[3]; int lock[3];
/* lock callback */ /* lock callback */
static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess, static void my_lock(CURL *handle, curl_lock_data data,
void *useptr ) curl_lock_access laccess, void *useptr)
{ {
const char *what; const char *what;
struct userdata *user = (struct userdata *)useptr; struct userdata *user = (struct userdata *)useptr;
@ -50,7 +50,7 @@ static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess,
(void)handle; (void)handle;
(void)laccess; (void)laccess;
switch ( data ) { switch (data) {
case CURL_LOCK_DATA_SHARE: case CURL_LOCK_DATA_SHARE:
what = "share"; what = "share";
locknum = 0; locknum = 0;
@ -86,7 +86,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr )
struct userdata *user = (struct userdata *)useptr; struct userdata *user = (struct userdata *)useptr;
int locknum; int locknum;
(void)handle; (void)handle;
switch ( data ) { switch (data) {
case CURL_LOCK_DATA_SHARE: case CURL_LOCK_DATA_SHARE:
what = "share"; what = "share";
locknum = 0; locknum = 0;
@ -120,7 +120,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr )
static struct curl_slist *sethost(struct curl_slist *headers) static struct curl_slist *sethost(struct curl_slist *headers)
{ {
(void)headers; (void)headers;
return curl_slist_append(NULL, HOSTHEADER ); return curl_slist_append(NULL, HOSTHEADER);
} }
@ -133,7 +133,8 @@ static void *fire(void *ptr)
CURL *curl; CURL *curl;
int i=0; int i=0;
if ((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
return NULL; return NULL;
} }
@ -142,17 +143,17 @@ static void *fire(void *ptr)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, tdata->url); curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
printf( "CURLOPT_SHARE\n" ); printf("CURLOPT_SHARE\n");
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
printf( "PERFORM\n" ); printf("PERFORM\n");
code = curl_easy_perform(curl); code = curl_easy_perform(curl);
if( code != CURLE_OK ) { if(code) {
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n", fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
tdata->url, i, (int)code); tdata->url, i, (int)code);
} }
printf( "CLEANUP\n" ); printf("CLEANUP\n");
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_slist_free_all(headers); curl_slist_free_all(headers);
@ -186,42 +187,42 @@ int test(char *URL)
user.text = (char *)"Pigs in space"; user.text = (char *)"Pigs in space";
user.counter = 0; user.counter = 0;
printf( "GLOBAL_INIT\n" ); printf("GLOBAL_INIT\n");
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* prepare share */ /* prepare share */
printf( "SHARE_INIT\n" ); printf("SHARE_INIT\n");
if ((share = curl_share_init()) == NULL) { if((share = curl_share_init()) == NULL) {
fprintf(stderr, "curl_share_init() failed\n"); fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode) {
printf( "CURLSHOPT_LOCKFUNC\n" ); printf("CURLSHOPT_LOCKFUNC\n");
scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock); scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode) {
printf( "CURLSHOPT_UNLOCKFUNC\n" ); printf("CURLSHOPT_UNLOCKFUNC\n");
scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock); scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode) {
printf( "CURLSHOPT_USERDATA\n" ); printf("CURLSHOPT_USERDATA\n");
scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user); scode = curl_share_setopt(share, CURLSHOPT_USERDATA, &user);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode) {
printf( "CURL_LOCK_DATA_COOKIE\n" ); printf("CURL_LOCK_DATA_COOKIE\n");
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode) {
printf( "CURL_LOCK_DATA_DNS\n" ); printf("CURL_LOCK_DATA_DNS\n");
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
} }
if ( CURLSHE_OK != scode ) { if(CURLSHE_OK != scode) {
fprintf(stderr, "curl_share_setopt() failed\n"); fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
@ -229,149 +230,145 @@ int test(char *URL)
} }
/* initial cookie manipulation */ /* initial cookie manipulation */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
printf( "CURLOPT_SHARE\n" ); printf("CURLOPT_SHARE\n");
test_setopt( curl, CURLOPT_SHARE, share ); test_setopt(curl, CURLOPT_SHARE, share);
printf( "CURLOPT_COOKIELIST injected_and_clobbered\n" ); printf("CURLOPT_COOKIELIST injected_and_clobbered\n");
test_setopt( curl, CURLOPT_COOKIELIST, test_setopt(curl, CURLOPT_COOKIELIST,
"Set-Cookie: injected_and_clobbered=yes; " "Set-Cookie: injected_and_clobbered=yes; "
"domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030" ); "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030");
printf( "CURLOPT_COOKIELIST ALL\n" ); printf("CURLOPT_COOKIELIST ALL\n");
test_setopt( curl, CURLOPT_COOKIELIST, "ALL" ); test_setopt(curl, CURLOPT_COOKIELIST, "ALL");
printf( "CURLOPT_COOKIELIST session\n" ); printf("CURLOPT_COOKIELIST session\n");
test_setopt( curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants" ); test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants");
printf( "CURLOPT_COOKIELIST injected\n" ); printf("CURLOPT_COOKIELIST injected\n");
test_setopt( curl, CURLOPT_COOKIELIST, test_setopt(curl, CURLOPT_COOKIELIST,
"Set-Cookie: injected=yes; domain=host.foo.com; " "Set-Cookie: injected=yes; domain=host.foo.com; "
"expires=Sat Feb 2 11:56:27 GMT 2030" ); "expires=Sat Feb 2 11:56:27 GMT 2030");
printf( "CURLOPT_COOKIELIST SESS\n" ); printf("CURLOPT_COOKIELIST SESS\n");
test_setopt( curl, CURLOPT_COOKIELIST, "SESS" ); test_setopt(curl, CURLOPT_COOKIELIST, "SESS");
printf( "CLEANUP\n" ); printf("CLEANUP\n");
curl_easy_cleanup( curl ); curl_easy_cleanup(curl);
res = 0; res = 0;
/* start treads */ /* start treads */
for (i=1; i<=THREADS; i++ ) { for(i=1; i<=THREADS; i++) {
/* set thread data */ /* set thread data */
tdata.url = suburl( URL, i ); /* must be curl_free()d */ tdata.url = suburl(URL, i); /* must be curl_free()d */
tdata.share = share; tdata.share = share;
/* simulate thread, direct call of "thread" function */ /* simulate thread, direct call of "thread" function */
printf( "*** run %d\n",i ); printf("*** run %d\n",i);
fire( &tdata ); fire(&tdata);
curl_free( tdata.url );
curl_free(tdata.url);
} }
/* fetch a another one and save cookies */ /* fetch a another one and save cookies */
printf( "*** run %d\n", i ); printf("*** run %d\n", i);
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
url = suburl( URL, i ); url = suburl(URL, i);
headers = sethost( NULL ); headers = sethost(NULL);
test_setopt( curl, CURLOPT_HTTPHEADER, headers ); test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt( curl, CURLOPT_URL, url ); test_setopt(curl, CURLOPT_URL, url);
printf( "CURLOPT_SHARE\n" ); printf("CURLOPT_SHARE\n");
test_setopt( curl, CURLOPT_SHARE, share ); test_setopt(curl, CURLOPT_SHARE, share);
printf( "CURLOPT_COOKIEJAR\n" ); printf("CURLOPT_COOKIEJAR\n");
test_setopt( curl, CURLOPT_COOKIEJAR, JAR ); test_setopt(curl, CURLOPT_COOKIEJAR, JAR);
printf( "CURLOPT_COOKIELIST FLUSH\n" ); printf("CURLOPT_COOKIELIST FLUSH\n");
test_setopt( curl, CURLOPT_COOKIELIST, "FLUSH" ); test_setopt(curl, CURLOPT_COOKIELIST, "FLUSH");
printf( "PERFORM\n" ); printf("PERFORM\n");
curl_easy_perform( curl ); curl_easy_perform(curl);
printf( "CLEANUP\n" ); printf("CLEANUP\n");
curl_easy_cleanup( curl ); curl_easy_cleanup(curl);
curl_free(url); curl_free(url);
curl_slist_free_all( headers ); curl_slist_free_all(headers);
/* load cookies */ /* load cookies */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
url = suburl( URL, i ); url = suburl(URL, i);
headers = sethost( NULL ); headers = sethost(NULL);
test_setopt( curl, CURLOPT_HTTPHEADER, headers ); test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt( curl, CURLOPT_URL, url ); test_setopt(curl, CURLOPT_URL, url);
printf( "CURLOPT_SHARE\n" ); printf("CURLOPT_SHARE\n");
test_setopt( curl, CURLOPT_SHARE, share ); test_setopt(curl, CURLOPT_SHARE, share);
printf( "CURLOPT_COOKIELIST ALL\n" ); printf("CURLOPT_COOKIELIST ALL\n");
test_setopt( curl, CURLOPT_COOKIELIST, "ALL" ); test_setopt(curl, CURLOPT_COOKIELIST, "ALL");
printf( "CURLOPT_COOKIEJAR\n" ); printf("CURLOPT_COOKIEJAR\n");
test_setopt( curl, CURLOPT_COOKIEFILE, JAR ); test_setopt(curl, CURLOPT_COOKIEFILE, JAR);
printf( "CURLOPT_COOKIELIST RELOAD\n" ); printf("CURLOPT_COOKIELIST RELOAD\n");
test_setopt( curl, CURLOPT_COOKIELIST, "RELOAD" ); test_setopt(curl, CURLOPT_COOKIELIST, "RELOAD");
code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if ( code != CURLE_OK ) if(code != CURLE_OK) {
{
fprintf(stderr, "curl_easy_getinfo() failed\n"); fprintf(stderr, "curl_easy_getinfo() failed\n");
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
printf("loaded cookies:\n"); printf("loaded cookies:\n");
if ( !cookies ) if(!cookies) {
{
fprintf(stderr, " reloading cookies from '%s' failed\n", JAR); fprintf(stderr, " reloading cookies from '%s' failed\n", JAR);
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
printf("-----------------\n"); printf("-----------------\n");
next_cookie = cookies; next_cookie = cookies;
while ( next_cookie ) while(next_cookie) {
{ printf(" %s\n", next_cookie->data);
printf( " %s\n", next_cookie->data );
next_cookie = next_cookie->next; next_cookie = next_cookie->next;
} }
printf("-----------------\n"); printf("-----------------\n");
curl_slist_free_all( cookies ); curl_slist_free_all(cookies);
/* try to free share, expect to fail because share is in use*/ /* try to free share, expect to fail because share is in use*/
printf( "try SHARE_CLEANUP...\n" ); printf("try SHARE_CLEANUP...\n");
scode = curl_share_cleanup( share ); scode = curl_share_cleanup(share);
if ( scode==CURLSHE_OK ) if(scode==CURLSHE_OK ) {
{
fprintf(stderr, "curl_share_cleanup succeed but error expected\n"); fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL; share = NULL;
} else { }
printf( "SHARE_CLEANUP failed, correct\n" ); else {
printf("SHARE_CLEANUP failed, correct\n");
} }
test_cleanup: test_cleanup:
/* clean up last handle */ /* clean up last handle */
printf( "CLEANUP\n" ); printf("CLEANUP\n");
curl_easy_cleanup( curl ); curl_easy_cleanup(curl);
curl_slist_free_all( headers ); curl_slist_free_all(headers);
curl_free(url); curl_free(url);
/* free share */ /* free share */
printf( "SHARE_CLEANUP\n" ); printf("SHARE_CLEANUP\n");
scode = curl_share_cleanup( share ); scode = curl_share_cleanup(share);
if ( scode!=CURLSHE_OK ) if(scode!=CURLSHE_OK )
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode); (int)scode);
printf( "GLOBAL_CLEANUP\n" ); printf("GLOBAL_CLEANUP\n");
curl_global_cleanup(); curl_global_cleanup();
return res; return res;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -57,12 +57,12 @@ int test(char *URL)
pooh.readptr = data; pooh.readptr = data;
pooh.sizeleft = strlen(data); pooh.sizeleft = strlen(data);
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -117,12 +117,12 @@ int test(char *URL)
custom_realloc, custom_realloc,
custom_strdup, custom_strdup,
custom_calloc); custom_calloc);
if (res != CURLE_OK) { if(res != CURLE_OK) {
fprintf(stderr, "curl_global_init_mem() failed\n"); fprintf(stderr, "curl_global_init_mem() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -63,19 +63,19 @@ int test(char *URL)
struct WriteThis pooh; struct WriteThis pooh;
pooh.counter = 0; pooh.counter = 0;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
if (slist == NULL) { if(slist == NULL) {
fprintf(stderr, "curl_slist_append() failed\n"); fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -37,12 +37,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -56,18 +56,19 @@ static char msgbuff[256];
static void store_errmsg(const char *msg, int err) static void store_errmsg(const char *msg, int err)
{ {
if (!err) if(!err)
snprintf(msgbuff, sizeof(msgbuff), "%s", msg); snprintf(msgbuff, sizeof(msgbuff), "%s", msg);
else else
snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, err, strerror(err)); snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg,
err, strerror(err));
} }
static void close_file_descriptors(void) static void close_file_descriptors(void)
{ {
for (num_open.rlim_cur = 0; for(num_open.rlim_cur = 0;
num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) num_open.rlim_cur++)
if (fd[num_open.rlim_cur] > 0) if(fd[num_open.rlim_cur] > 0)
close(fd[num_open.rlim_cur]); close(fd[num_open.rlim_cur]);
free(fd); free(fd);
fd = NULL; fd = NULL;
@ -79,20 +80,20 @@ static int fopen_works(void)
int i; int i;
int ret = 1; int ret = 1;
for (i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
fpa[i] = NULL; fpa[i] = NULL;
} }
for (i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
fpa[i] = fopen(DEV_NULL, "r"); fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
if (fpa[i] == NULL) { if(fpa[i] == NULL) {
store_errmsg("fopen() failed", ERRNO); store_errmsg("fopen failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
ret = 0; ret = 0;
break; break;
} }
} }
for (i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
if (fpa[i] != NULL) if(fpa[i] != NULL)
fclose(fpa[i]); fclose(fpa[i]);
} }
return ret; return ret;
@ -112,7 +113,7 @@ static int rlimit(int keep_open)
#ifdef HAVE_LONGLONG #ifdef HAVE_LONGLONG
char fmt_llu[] = "%llu"; char fmt_llu[] = "%llu";
if (sizeof(rl.rlim_max) > sizeof(long)) if(sizeof(rl.rlim_max) > sizeof(long))
fmt = fmt_llu; fmt = fmt_llu;
else else
#endif #endif
@ -120,7 +121,7 @@ static int rlimit(int keep_open)
/* get initial open file limits */ /* get initial open file limits */
if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
store_errmsg("getrlimit() failed", ERRNO); store_errmsg("getrlimit() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
return -1; return -1;
@ -129,7 +130,7 @@ static int rlimit(int keep_open)
/* show initial open file limits */ /* show initial open file limits */
#ifdef RLIM_INFINITY #ifdef RLIM_INFINITY
if (rl.rlim_cur == RLIM_INFINITY) if(rl.rlim_cur == RLIM_INFINITY)
strcpy(strbuff, "INFINITY"); strcpy(strbuff, "INFINITY");
else else
#endif #endif
@ -137,7 +138,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "initial soft limit: %s\n", strbuff); fprintf(stderr, "initial soft limit: %s\n", strbuff);
#ifdef RLIM_INFINITY #ifdef RLIM_INFINITY
if (rl.rlim_max == RLIM_INFINITY) if(rl.rlim_max == RLIM_INFINITY)
strcpy(strbuff, "INFINITY"); strcpy(strbuff, "INFINITY");
else else
#endif #endif
@ -159,14 +160,14 @@ static int rlimit(int keep_open)
* open more than soft limit file descriptors will fail. * open more than soft limit file descriptors will fail.
*/ */
if (rl.rlim_cur != rl.rlim_max) { if(rl.rlim_cur != rl.rlim_max) {
#ifdef OPEN_MAX #ifdef OPEN_MAX
if ((rl.rlim_cur > 0) && if((rl.rlim_cur > 0) &&
(rl.rlim_cur < OPEN_MAX)) { (rl.rlim_cur < OPEN_MAX)) {
fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); fprintf(stderr, "raising soft limit up to OPEN_MAX\n");
rl.rlim_cur = OPEN_MAX; rl.rlim_cur = OPEN_MAX;
if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
/* on failure don't abort just issue a warning */ /* on failure don't abort just issue a warning */
store_errmsg("setrlimit() failed", ERRNO); store_errmsg("setrlimit() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
@ -177,7 +178,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "raising soft limit up to hard limit\n"); fprintf(stderr, "raising soft limit up to hard limit\n");
rl.rlim_cur = rl.rlim_max; rl.rlim_cur = rl.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
/* on failure don't abort just issue a warning */ /* on failure don't abort just issue a warning */
store_errmsg("setrlimit() failed", ERRNO); store_errmsg("setrlimit() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
@ -186,7 +187,7 @@ static int rlimit(int keep_open)
/* get current open file limits */ /* get current open file limits */
if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
store_errmsg("getrlimit() failed", ERRNO); store_errmsg("getrlimit() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
return -3; return -3;
@ -195,7 +196,7 @@ static int rlimit(int keep_open)
/* show current open file limits */ /* show current open file limits */
#ifdef RLIM_INFINITY #ifdef RLIM_INFINITY
if (rl.rlim_cur == RLIM_INFINITY) if(rl.rlim_cur == RLIM_INFINITY)
strcpy(strbuff, "INFINITY"); strcpy(strbuff, "INFINITY");
else else
#endif #endif
@ -203,7 +204,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "current soft limit: %s\n", strbuff); fprintf(stderr, "current soft limit: %s\n", strbuff);
#ifdef RLIM_INFINITY #ifdef RLIM_INFINITY
if (rl.rlim_max == RLIM_INFINITY) if(rl.rlim_max == RLIM_INFINITY)
strcpy(strbuff, "INFINITY"); strcpy(strbuff, "INFINITY");
else else
#endif #endif
@ -229,7 +230,7 @@ static int rlimit(int keep_open)
num_open.rlim_cur = NUM_NEEDED; num_open.rlim_cur = NUM_NEEDED;
if ((rl.rlim_cur > 0) && if((rl.rlim_cur > 0) &&
#ifdef RLIM_INFINITY #ifdef RLIM_INFINITY
(rl.rlim_cur != RLIM_INFINITY) && (rl.rlim_cur != RLIM_INFINITY) &&
#endif #endif
@ -252,21 +253,21 @@ static int rlimit(int keep_open)
* that it becomes available to the test. * that it becomes available to the test.
*/ */
for (nitems = i = 1; nitems <= i; i *= 2) for(nitems = i = 1; nitems <= i; i *= 2)
nitems = i; nitems = i;
if (nitems > 0x7fff) if(nitems > 0x7fff)
nitems = 0x40000; nitems = 0x40000;
do { do {
num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems; num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems;
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
fprintf(stderr, "allocating memchunk %s byte array\n", strbuff); fprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
if (!memchunk) { if(!memchunk) {
fprintf(stderr, "memchunk, malloc() failed\n"); fprintf(stderr, "memchunk, malloc() failed\n");
nitems /= 2; nitems /= 2;
} }
} while (nitems && !memchunk); } while(nitems && !memchunk);
if (!memchunk) { if(!memchunk) {
store_errmsg("memchunk, malloc() failed", ERRNO); store_errmsg("memchunk, malloc() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
return -5; return -5;
@ -276,7 +277,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "initializing memchunk array\n"); fprintf(stderr, "initializing memchunk array\n");
for (i = 0; i < nitems; i++) for(i = 0; i < nitems; i++)
memchunk[i] = -1; memchunk[i] = -1;
/* set the number of file descriptors we will try to open */ /* set the number of file descriptors we will try to open */
@ -285,7 +286,7 @@ static int rlimit(int keep_open)
/* verify that we won't overflow size_t in malloc() */ /* verify that we won't overflow size_t in malloc() */
if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) {
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s "
"file descriptors, would overflow size_t", strbuff1); "file descriptors, would overflow size_t", strbuff1);
@ -301,7 +302,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); fprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max));
if (!fd) { if(!fd) {
store_errmsg("fd, malloc() failed", ERRNO); store_errmsg("fd, malloc() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
free(memchunk); free(memchunk);
@ -312,9 +313,9 @@ static int rlimit(int keep_open)
fprintf(stderr, "initializing fd array\n"); fprintf(stderr, "initializing fd array\n");
for (num_open.rlim_cur = 0; for(num_open.rlim_cur = 0;
num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) num_open.rlim_cur++)
fd[num_open.rlim_cur] = -1; fd[num_open.rlim_cur] = -1;
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
@ -323,7 +324,7 @@ static int rlimit(int keep_open)
/* open a dummy descriptor */ /* open a dummy descriptor */
fd[0] = open(DEV_NULL, O_RDONLY); fd[0] = open(DEV_NULL, O_RDONLY);
if (fd[0] < 0) { if(fd[0] < 0) {
snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
store_errmsg(strbuff, ERRNO); store_errmsg(strbuff, ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
@ -335,13 +336,13 @@ static int rlimit(int keep_open)
/* create a bunch of file descriptors */ /* create a bunch of file descriptors */
for (num_open.rlim_cur = 1; for(num_open.rlim_cur = 1;
num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) { num_open.rlim_cur++) {
fd[num_open.rlim_cur] = dup(fd[0]); fd[num_open.rlim_cur] = dup(fd[0]);
if (fd[num_open.rlim_cur] < 0) { if(fd[num_open.rlim_cur] < 0) {
fd[num_open.rlim_cur] = -1; fd[num_open.rlim_cur] = -1;
@ -350,7 +351,8 @@ static int rlimit(int keep_open)
fprintf(stderr, "%s\n", strbuff); fprintf(stderr, "%s\n", strbuff);
snprintf(strbuff1, sizeof(strbuff), fmt, num_open.rlim_cur); snprintf(strbuff1, sizeof(strbuff), fmt, num_open.rlim_cur);
snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s",
strbuff1);
fprintf(stderr, "%s\n", strbuff); fprintf(stderr, "%s\n", strbuff);
num_open.rlim_max = NUM_NEEDED; num_open.rlim_max = NUM_NEEDED;
@ -362,9 +364,9 @@ static int rlimit(int keep_open)
store_errmsg(strbuff, 0); store_errmsg(strbuff, 0);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
for (num_open.rlim_cur = 0; for(num_open.rlim_cur = 0;
fd[num_open.rlim_cur] >= 0; fd[num_open.rlim_cur] >= 0;
num_open.rlim_cur++) num_open.rlim_cur++)
close(fd[num_open.rlim_cur]); close(fd[num_open.rlim_cur]);
free(fd); free(fd);
fd = NULL; fd = NULL;
@ -394,7 +396,7 @@ static int rlimit(int keep_open)
*/ */
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
if (num_open.rlim_max > num_open.rlim_cur) { if(num_open.rlim_max > num_open.rlim_cur) {
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
FD_SETSIZE); FD_SETSIZE);
store_errmsg(strbuff, 0); store_errmsg(strbuff, 0);
@ -405,10 +407,10 @@ static int rlimit(int keep_open)
} }
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
for (rl.rlim_cur = 0; for(rl.rlim_cur = 0;
rl.rlim_cur < num_open.rlim_max; rl.rlim_cur < num_open.rlim_max;
rl.rlim_cur++) { rl.rlim_cur++) {
if ((fd[rl.rlim_cur] > 0) && if((fd[rl.rlim_cur] > 0) &&
((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) {
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
FD_SETSIZE); FD_SETSIZE);
@ -431,14 +433,14 @@ static int rlimit(int keep_open)
* if it is capable of fopen()ing some additional files. * if it is capable of fopen()ing some additional files.
*/ */
if (!fopen_works()) { if(!fopen_works()) {
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
snprintf(strbuff, sizeof(strbuff), snprintf(strbuff, sizeof(strbuff),
"stdio fopen() fails with %s fds open()", "fopen fails with %s fds open()",
strbuff1); strbuff1);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
snprintf(strbuff, sizeof(strbuff), snprintf(strbuff, sizeof(strbuff),
"stdio fopen() fails with lots of fds open()"); "fopen fails with lots of fds open()");
store_errmsg(strbuff, 0); store_errmsg(strbuff, 0);
close_file_descriptors(); close_file_descriptors();
free(memchunk); free(memchunk);
@ -452,7 +454,7 @@ static int rlimit(int keep_open)
/* close file descriptors unless instructed to keep them */ /* close file descriptors unless instructed to keep them */
if (!keep_open) { if(!keep_open) {
close_file_descriptors(); close_file_descriptors();
} }
@ -473,7 +475,7 @@ int test(char *URL)
return 0; /* sure, run this! */ return 0; /* sure, run this! */
} }
if (rlimit(TRUE)) { if(rlimit(TRUE)) {
/* failure */ /* failure */
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
@ -481,13 +483,13 @@ int test(char *URL)
/* run the test with the bunch of open file descriptors /* run the test with the bunch of open file descriptors
and close them all once the test is over */ and close them all once the test is over */
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
close_file_descriptors(); close_file_descriptors();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
close_file_descriptors(); close_file_descriptors();
curl_global_cleanup(); curl_global_cleanup();

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -34,7 +34,7 @@ int test(char *URL)
int res = 0; int res = 0;
CURL *curl = NULL; CURL *curl = NULL;
FILE *hd_src = NULL; FILE *hd_src = NULL;
int hd ; int hd;
int error; int error;
struct_stat file_info; struct_stat file_info;
CURLM *m = NULL; CURLM *m = NULL;
@ -56,7 +56,7 @@ int test(char *URL)
hd_src = fopen(libtest_arg2, "rb"); hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) { if(NULL == hd_src) {
error = ERRNO; error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d (%s)\n", fprintf(stderr, "fopen failed with error: %d (%s)\n",
error, strerror(error)); error, strerror(error));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2); fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
return TEST_ERR_FOPEN; return TEST_ERR_FOPEN;
@ -86,7 +86,7 @@ int test(char *URL)
easy_setopt(curl, CURLOPT_UPLOAD, 1L); easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */ /* specify target */
easy_setopt(curl,CURLOPT_URL, URL); easy_setopt(curl, CURLOPT_URL, URL);
/* go verbose */ /* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L); easy_setopt(curl, CURLOPT_VERBOSE, 1L);

View File

@ -66,9 +66,9 @@ static void store_errmsg(const char *msg, int err)
static void close_file_descriptors(void) static void close_file_descriptors(void)
{ {
for (num_open.rlim_cur = 0; for(num_open.rlim_cur = 0;
num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) num_open.rlim_cur++)
if(fd[num_open.rlim_cur] > 0) if(fd[num_open.rlim_cur] > 0)
close(fd[num_open.rlim_cur]); close(fd[num_open.rlim_cur]);
free(fd); free(fd);
@ -81,19 +81,19 @@ static int fopen_works(void)
int i; int i;
int ret = 1; int ret = 1;
for (i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
fpa[i] = NULL; fpa[i] = NULL;
} }
for (i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
fpa[i] = fopen(DEV_NULL, "r"); fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
if(fpa[i] == NULL) { if(fpa[i] == NULL) {
store_errmsg("fopen() failed", ERRNO); store_errmsg("fopen failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
ret = 0; ret = 0;
break; break;
} }
} }
for (i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
if(fpa[i] != NULL) if(fpa[i] != NULL)
fclose(fpa[i]); fclose(fpa[i]);
} }
@ -227,7 +227,7 @@ static int rlimit(int keep_open)
* that it becomes available to the test. * that it becomes available to the test.
*/ */
for (nitems = i = 1; nitems <= i; i *= 2) for(nitems = i = 1; nitems <= i; i *= 2)
nitems = i; nitems = i;
if(nitems > 0x7fff) if(nitems > 0x7fff)
nitems = 0x40000; nitems = 0x40000;
@ -240,7 +240,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "memchunk, malloc() failed\n"); fprintf(stderr, "memchunk, malloc() failed\n");
nitems /= 2; nitems /= 2;
} }
} while (nitems && !memchunk); } while(nitems && !memchunk);
if(!memchunk) { if(!memchunk) {
store_errmsg("memchunk, malloc() failed", ERRNO); store_errmsg("memchunk, malloc() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
@ -251,7 +251,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "initializing memchunk array\n"); fprintf(stderr, "initializing memchunk array\n");
for (i = 0; i < nitems; i++) for(i = 0; i < nitems; i++)
memchunk[i] = -1; memchunk[i] = -1;
/* set the number of file descriptors we will try to open */ /* set the number of file descriptors we will try to open */
@ -266,7 +266,7 @@ static int rlimit(int keep_open)
} }
else { else {
/* a huge number of file descriptors */ /* a huge number of file descriptors */
for (nitems = i = 1; nitems <= i; i *= 2) for(nitems = i = 1; nitems <= i; i *= 2)
nitems = i; nitems = i;
if(nitems > 0x7fff) if(nitems > 0x7fff)
nitems = 0x40000; nitems = 0x40000;
@ -295,7 +295,7 @@ static int rlimit(int keep_open)
fprintf(stderr, "fd, malloc() failed\n"); fprintf(stderr, "fd, malloc() failed\n");
num_open.rlim_max /= 2; num_open.rlim_max /= 2;
} }
} while (num_open.rlim_max && !fd); } while(num_open.rlim_max && !fd);
if(!fd) { if(!fd) {
store_errmsg("fd, malloc() failed", ERRNO); store_errmsg("fd, malloc() failed", ERRNO);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
@ -307,9 +307,9 @@ static int rlimit(int keep_open)
fprintf(stderr, "initializing fd array\n"); fprintf(stderr, "initializing fd array\n");
for (num_open.rlim_cur = 0; for(num_open.rlim_cur = 0;
num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) num_open.rlim_cur++)
fd[num_open.rlim_cur] = -1; fd[num_open.rlim_cur] = -1;
snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
@ -330,9 +330,9 @@ static int rlimit(int keep_open)
/* create a bunch of file descriptors */ /* create a bunch of file descriptors */
for (num_open.rlim_cur = 1; for(num_open.rlim_cur = 1;
num_open.rlim_cur < num_open.rlim_max; num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++) { num_open.rlim_cur++) {
fd[num_open.rlim_cur] = dup(fd[0]); fd[num_open.rlim_cur] = dup(fd[0]);
@ -345,19 +345,21 @@ static int rlimit(int keep_open)
fprintf(stderr, "%s\n", strbuff); fprintf(stderr, "%s\n", strbuff);
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s",
strbuff1);
fprintf(stderr, "%s\n", strbuff); fprintf(stderr, "%s\n", strbuff);
num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN; num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN;
num_open.rlim_cur -= num_open.rlim_max; num_open.rlim_cur -= num_open.rlim_max;
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur);
snprintf(strbuff, sizeof(strbuff), "closing %s file descriptors", strbuff1); snprintf(strbuff, sizeof(strbuff), "closing %s file descriptors",
strbuff1);
fprintf(stderr, "%s\n", strbuff); fprintf(stderr, "%s\n", strbuff);
for (num_open.rlim_cur = num_open.rlim_max; for(num_open.rlim_cur = num_open.rlim_max;
fd[num_open.rlim_cur] >= 0; fd[num_open.rlim_cur] >= 0;
num_open.rlim_cur++) { num_open.rlim_cur++) {
close(fd[num_open.rlim_cur]); close(fd[num_open.rlim_cur]);
fd[num_open.rlim_cur] = -1; fd[num_open.rlim_cur] = -1;
} }
@ -399,7 +401,8 @@ static int rlimit(int keep_open)
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
if(num_open.rlim_max > num_open.rlim_cur) { if(num_open.rlim_max > num_open.rlim_cur) {
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", FD_SETSIZE); snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
FD_SETSIZE);
store_errmsg(strbuff, 0); store_errmsg(strbuff, 0);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
close_file_descriptors(); close_file_descriptors();
@ -408,12 +411,13 @@ static int rlimit(int keep_open)
} }
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
for (rl.rlim_cur = 0; for(rl.rlim_cur = 0;
rl.rlim_cur < num_open.rlim_max; rl.rlim_cur < num_open.rlim_max;
rl.rlim_cur++) { rl.rlim_cur++) {
if((fd[rl.rlim_cur] > 0) && if((fd[rl.rlim_cur] > 0) &&
((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) {
snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", FD_SETSIZE); snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
FD_SETSIZE);
store_errmsg(strbuff, 0); store_errmsg(strbuff, 0);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
close_file_descriptors(); close_file_descriptors();
@ -435,10 +439,10 @@ static int rlimit(int keep_open)
if(!fopen_works()) { if(!fopen_works()) {
snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max);
snprintf(strbuff, sizeof(strbuff), "stdio fopen() fails with %s fds open()", snprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open",
strbuff1); strbuff1);
fprintf(stderr, "%s\n", msgbuff); fprintf(stderr, "%s\n", msgbuff);
snprintf(strbuff, sizeof(strbuff), "stdio fopen() fails with lots of fds open()"); snprintf(strbuff, sizeof(strbuff), "fopen fails with lots of fds open");
store_errmsg(strbuff, 0); store_errmsg(strbuff, 0);
close_file_descriptors(); close_file_descriptors();
free(memchunk); free(memchunk);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -30,12 +30,12 @@ int test(char *URL)
char *newURL = NULL; char *newURL = NULL;
struct curl_slist *slist = NULL; struct curl_slist *slist = NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -58,16 +58,15 @@ int test(char *URL)
* even though no directories are stored in the ftpconn->dirs array (after a * even though no directories are stored in the ftpconn->dirs array (after a
* call to freedirs). * call to freedirs).
*/ */
newURL = malloc(strlen(URL) + 3); newURL = aprintf("%s./", URL);
if (newURL == NULL) { if(newURL == NULL) {
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
newURL = strcat(strcpy(newURL, URL), "./");
slist = curl_slist_append (NULL, "SYST"); slist = curl_slist_append (NULL, "SYST");
if (slist == NULL) { if(slist == NULL) {
free(newURL); free(newURL);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -113,7 +113,7 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd,
if(res) if(res)
return res; return res;
while (U) { while(U) {
int M = -99; int M = -99;
@ -125,7 +125,7 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd,
if(res) if(res)
return res; return res;
if (U) { if(U) {
FD_ZERO(&R); FD_ZERO(&R);
FD_ZERO(&W); FD_ZERO(&W);
FD_ZERO(&E); FD_ZERO(&E);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -35,12 +35,12 @@ int test(char *URL)
{ {
CURL *curl; CURL *curl;
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
FILE *hd_src ; FILE *hd_src;
int hd; int hd;
struct_stat file_info; struct_stat file_info;
int error; int error;
if (!libtest_arg2) { if(!libtest_arg2) {
fprintf(stderr, "Usage: <url> <file-to-upload>\n"); fprintf(stderr, "Usage: <url> <file-to-upload>\n");
return TEST_ERR_USAGE; return TEST_ERR_USAGE;
} }
@ -48,7 +48,7 @@ int test(char *URL)
hd_src = fopen(libtest_arg2, "rb"); hd_src = fopen(libtest_arg2, "rb");
if(NULL == hd_src) { if(NULL == hd_src) {
error = ERRNO; error = ERRNO;
fprintf(stderr, "fopen() failed with error: %d %s\n", fprintf(stderr, "fopen failed with error: %d %s\n",
error, strerror(error)); error, strerror(error));
fprintf(stderr, "Error opening file: %s\n", libtest_arg2); fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
return -2; /* if this happens things are major weird */ return -2; /* if this happens things are major weird */
@ -72,14 +72,14 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
fclose(hd_src); fclose(hd_src);
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* get a curl handle */ /* get a curl handle */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
fclose(hd_src); fclose(hd_src);
@ -93,7 +93,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* specify target */ /* specify target */
test_setopt(curl,CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
/* now specify which file to upload */ /* now specify which file to upload */
test_setopt(curl, CURLOPT_READDATA, hd_src); test_setopt(curl, CURLOPT_READDATA, hd_src);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -36,13 +36,13 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* get a curl handle */ /* get a curl handle */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -58,7 +58,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_HEADER, 0L); test_setopt(curl, CURLOPT_HEADER, 0L);
/* specify target */ /* specify target */
test_setopt(curl,CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
/* Now run off and do what you've been told! */ /* Now run off and do what you've been told! */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2012, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -36,7 +36,7 @@ int test(char *URL)
char *s; char *s;
(void)URL; (void)URL;
if ((easy = curl_easy_init()) == NULL) { if((easy = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -42,12 +42,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -85,12 +85,12 @@ int test(char *URL)
int counter=0; int counter=0;
#endif #endif
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -108,7 +108,8 @@ int test(char *URL)
test_setopt(curl, CURLOPT_IOCTLDATA, &counter); test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
test_setopt(curl, CURLOPT_READFUNCTION, readcallback); test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
test_setopt(curl, CURLOPT_READDATA, &counter); test_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */ /* We CANNOT do the POST fine without setting the size (or choose
chunked)! */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS));
#endif #endif
test_setopt(curl, CURLOPT_POST, 1L); test_setopt(curl, CURLOPT_POST, 1L);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -33,12 +33,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -63,14 +63,14 @@ void dump(const char *text,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stream, "%c", fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -121,12 +121,14 @@ int my_trace(CURL *handle, curl_infotype type,
static size_t current_offset = 0; static size_t current_offset = 0;
static char databuf[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ static char databuf[70000]; /* MUST be more than 64k OR
MAX_INITIAL_POST_SIZE */
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t amount = nmemb * size; /* Total bytes curl wants */ size_t amount = nmemb * size; /* Total bytes curl wants */
size_t available = sizeof(databuf) - current_offset; /* What we have to give */ size_t available = sizeof(databuf) - current_offset; /* What we have to
give */
size_t given = amount < available ? amount : available; /* What is given */ size_t given = amount < available ? amount : available; /* What is given */
(void)stream; (void)stream;
memcpy(ptr, databuf + current_offset, given); memcpy(ptr, databuf + current_offset, given);
@ -135,7 +137,8 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
} }
static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) static size_t write_callback(void *ptr, size_t size, size_t nmemb,
void *stream)
{ {
int amount = curlx_uztosi(size * nmemb); int amount = curlx_uztosi(size * nmemb);
printf("%.*s", amount, (char *)ptr); printf("%.*s", amount, (char *)ptr);
@ -147,7 +150,7 @@ static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream)
static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp) static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp)
{ {
(void)clientp; (void)clientp;
if (cmd == CURLIOCMD_RESTARTREAD ) { if(cmd == CURLIOCMD_RESTARTREAD ) {
printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n"); printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n");
printf("APPLICATION: ** REWINDING! **\n"); printf("APPLICATION: ** REWINDING! **\n");
current_offset = 0; current_offset = 0;
@ -181,7 +184,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* setup repeated data string */ /* setup repeated data string */
for (i=0; i < sizeof(databuf); ++i) for(i=0; i < sizeof(databuf); ++i)
databuf[i] = fill[i % sizeof fill]; databuf[i] = fill[i % sizeof fill];
/* Post */ /* Post */
@ -206,7 +209,8 @@ int test(char *URL)
test_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 */ /* 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); test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);

View File

@ -39,7 +39,7 @@ static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream)
memset(buf, 'A', sizeof(buf)); memset(buf, 'A', sizeof(buf));
size *= nmemb; size *= nmemb;
if (size > total) if(size > total)
size = total; size = total;
if(size > sizeof(buf)) if(size > sizeof(buf))
@ -73,18 +73,18 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
for (i = 0; i < NUM_HEADERS; i++) { for(i = 0; i < NUM_HEADERS; i++) {
int len = snprintf(buf, sizeof(buf), "Header%d: ", i); int len = snprintf(buf, sizeof(buf), "Header%d: ", i);
memset(&buf[len], 'A', SIZE_HEADERS); memset(&buf[len], 'A', SIZE_HEADERS);
buf[len + SIZE_HEADERS]=0; /* zero terminate */ buf[len + SIZE_HEADERS]=0; /* zero terminate */
hl = curl_slist_append(headerlist, buf); hl = curl_slist_append(headerlist, buf);
if (!hl) if(!hl)
goto test_cleanup; goto test_cleanup;
headerlist = hl; headerlist = hl;
} }
hl = curl_slist_append(headerlist, "Expect: "); hl = curl_slist_append(headerlist, "Expect: ");
if (!hl) if(!hl)
goto test_cleanup; goto test_cleanup;
headerlist = hl; headerlist = hl;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -162,7 +162,7 @@ static int once(char *URL, bool oldstyle)
if(formrc) if(formrc)
printf("curl_formadd(4) = %d\n", (int)formrc); printf("curl_formadd(4) = %d\n", (int)formrc);
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_formfree(formpost); curl_formfree(formpost);
curl_global_cleanup(); curl_global_cleanup();
@ -208,7 +208,7 @@ int test(char *URL)
{ {
int res; int res;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -96,7 +96,8 @@ int test(char *URL)
easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
easy_setopt(curl, CURLOPT_READDATA, &counter); easy_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose chunked)! */ /* We CANNOT do the POST fine without setting the size (or choose
chunked)! */
easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS));
easy_setopt(curl, CURLOPT_POST, 1L); easy_setopt(curl, CURLOPT_POST, 1L);
@ -113,7 +114,7 @@ int test(char *URL)
multi_add_handle(m, curl); multi_add_handle(m, curl);
while (running) { while(running) {
struct timeval timeout; struct timeval timeout;
fd_set fdread, fdwrite, fdexcep; fd_set fdread, fdwrite, fdexcep;
int maxfd = -99; int maxfd = -99;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -40,12 +40,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2013, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -33,7 +33,7 @@ int test(char *URL)
(void)URL; /* we don't use this */ (void)URL; /* we don't use this */
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -40,13 +40,13 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* get a curl handle */ /* get a curl handle */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -59,7 +59,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10)); test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
/* specify target */ /* specify target */
test_setopt(curl,CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
/* Now run off and do what you've been told! */ /* Now run off and do what you've been told! */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -30,12 +30,12 @@ int test(char *URL)
double content_length = 3; double content_length = 3;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -32,12 +32,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
struct curl_slist *custom_headers=NULL; struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -50,12 +50,12 @@ int test(char *URL)
int request=1; int request=1;
struct curl_slist *custom_headers=NULL; struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -131,7 +131,8 @@ int test(char *URL)
} }
test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers);
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE);
test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n"); test_setopt(curl, CURLOPT_POSTFIELDS,
"postyfield=postystuff&project=curl\n");
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res) if(res)

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -47,13 +47,13 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
fclose(idfile); fclose(idfile);
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
fclose(idfile); fclose(idfile);
@ -86,7 +86,8 @@ int test(char *URL)
stream_uri = NULL; stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz"); test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
"Fake/NotReal/JustATest;foo=baz");
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res) if(res)
goto test_cleanup; goto test_cleanup;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2013, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -35,12 +35,12 @@ int test(char *URL)
int request=1; int request=1;
char *stream_uri = NULL; char *stream_uri = NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2013, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -75,8 +75,9 @@ static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) {
printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i); printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i);
return failure; return failure;
} }
} else { }
if (memcmp(RTP_DATA, data + i, message_size - i) != 0) { else {
if(memcmp(RTP_DATA, data + i, message_size - i) != 0) {
printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n", printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n",
message_size - i, data + i); message_size - i, data + i);
return failure; return failure;
@ -110,13 +111,13 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
fclose(protofile); fclose(protofile);
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
fclose(protofile); fclose(protofile);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -50,12 +50,12 @@ int test(char *URL)
int request=1; int request=1;
struct curl_slist *custom_headers=NULL; struct curl_slist *custom_headers=NULL;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2012, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -44,7 +44,7 @@ int test(char *URL)
dbl_epsilon = 1.0; dbl_epsilon = 1.0;
do { do {
dbl_epsilon /= 2.0; dbl_epsilon /= 2.0;
} while ((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0); } while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0);
start_test_timing(); start_test_timing();
@ -65,7 +65,7 @@ int test(char *URL)
multi_add_handle(m, c); multi_add_handle(m, c);
while (running) { while(running) {
struct timeval timeout; struct timeval timeout;
fd_set fdread, fdwrite, fdexcep; fd_set fdread, fdwrite, fdexcep;
int maxfd = -99; int maxfd = -99;
@ -94,7 +94,7 @@ int test(char *URL)
} }
curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time); curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time);
if (connect_time < dbl_epsilon) { if(connect_time < dbl_epsilon) {
fprintf(stderr, "connect time %e is < epsilon %e\n", fprintf(stderr, "connect time %e is < epsilon %e\n",
connect_time, dbl_epsilon); connect_time, dbl_epsilon);
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -35,12 +35,12 @@ int test(char *URL)
int res; int res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -74,7 +74,8 @@ long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains)
} }
if(finfo->filetype == CURLFILETYPE_FILE) { if(finfo->filetype == CURLFILETYPE_FILE) {
ch_d->print_content = 1; ch_d->print_content = 1;
printf("Content:\n-------------------------------------------------------------\n"); printf("Content:\n-----------------------"
"--------------------------------------\n");
} }
if(strcmp(finfo->filename, "someothertext.txt") == 0) { if(strcmp(finfo->filename, "someothertext.txt") == 0) {
printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n"); printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
@ -100,7 +101,7 @@ int test(char *URL)
{ {
CURL *handle = NULL; CURL *handle = NULL;
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
chunk_data_t chunk_data = {0,0}; chunk_data_t chunk_data = {0, 0};
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
handle = curl_easy_init(); handle = curl_easy_init();
if(!handle) { if(!handle) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2011, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,7 +28,8 @@ static char data[]="this is a short string.\n";
static size_t data_size = sizeof(data) / sizeof(char); static size_t data_size = sizeof(data) / sizeof(char);
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) static int progress_callback(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow)
{ {
FILE *moo = fopen(libtest_arg2, "wb"); FILE *moo = fopen(libtest_arg2, "wb");
@ -37,10 +38,11 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, double
(void)dlnow; /* UNUSED */ (void)dlnow; /* UNUSED */
if(moo) { if(moo) {
if ((size_t)ultotal == data_size && (size_t)ulnow == data_size) if((size_t)ultotal == data_size && (size_t)ulnow == data_size)
fprintf(moo, "PASSED, UL data matched data size\n"); fprintf(moo, "PASSED, UL data matched data size\n");
else else
fprintf(moo, "Progress callback called with UL %f out of %f\n", ulnow, ultotal); fprintf(moo, "Progress callback called with UL %f out of %f\n",
ulnow, ultotal);
fclose(moo); fclose(moo);
} }
return 0; return 0;
@ -51,12 +53,12 @@ int test(char *URL)
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2012, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -92,19 +92,19 @@ int test(char *URL)
struct WriteThis pooh; struct WriteThis pooh;
pooh.counter = 0; pooh.counter = 0;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
if (slist == NULL) { if(slist == NULL) {
fprintf(stderr, "curl_slist_append() failed\n"); fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -51,9 +51,9 @@ static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention)
if(mention) if(mention)
fprintf(stderr, "Remove socket fd %d\n", (int) fd); fprintf(stderr, "Remove socket fd %d\n", (int) fd);
for (i = 0; i < sockets->count; ++i) { for(i = 0; i < sockets->count; ++i) {
if (sockets->sockets[i] == fd) { if(sockets->sockets[i] == fd) {
if (i < sockets->count - 1) if(i < sockets->count - 1)
memmove(&sockets->sockets[i], &sockets->sockets[i + 1], memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
sizeof(curl_socket_t) * (sockets->count - (i + 1))); sizeof(curl_socket_t) * (sockets->count - (i + 1)));
--sockets->count; --sockets->count;
@ -110,10 +110,10 @@ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
(void)easy; /* unused */ (void)easy; /* unused */
(void)socketp; /* unused */ (void)socketp; /* unused */
if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) if(action == CURL_POLL_IN || action == CURL_POLL_INOUT)
addFd(&sockets->read, s, "read"); addFd(&sockets->read, s, "read");
if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
addFd(&sockets->write, s, "write"); addFd(&sockets->write, s, "write");
if(action == CURL_POLL_REMOVE) { if(action == CURL_POLL_REMOVE) {
@ -132,7 +132,7 @@ static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
struct timeval* timeout = userp; struct timeval* timeout = userp;
(void)multi; /* unused */ (void)multi; /* unused */
if (timeout_ms != -1) { if(timeout_ms != -1) {
*timeout = tutil_tvnow(); *timeout = tutil_tvnow();
timeout->tv_usec += timeout_ms * 1000; timeout->tv_usec += timeout_ms * 1000;
} }
@ -151,10 +151,10 @@ static int checkForCompletion(CURLM* curl, int* success)
CURLMsg* message; CURLMsg* message;
int result = 0; int result = 0;
*success = 0; *success = 0;
while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) { while((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
if (message->msg == CURLMSG_DONE) { if(message->msg == CURLMSG_DONE) {
result = 1; result = 1;
if (message->data.result == CURLE_OK) if(message->data.result == CURLE_OK)
*success = 1; *success = 1;
else else
*success = 0; *success = 0;
@ -176,7 +176,7 @@ static int getMicroSecondTimeout(struct timeval* timeout)
now = tutil_tvnow(); now = tutil_tvnow();
result = (timeout->tv_sec - now.tv_sec) * 1000000 + result = (timeout->tv_sec - now.tv_sec) * 1000000 +
timeout->tv_usec - now.tv_usec; timeout->tv_usec - now.tv_usec;
if (result < 0) if(result < 0)
result = 0; result = 0;
return curlx_sztosi(result); return curlx_sztosi(result);
@ -189,9 +189,9 @@ static void updateFdSet(struct Sockets* sockets, fd_set* fdset,
curl_socket_t *maxFd) curl_socket_t *maxFd)
{ {
int i; int i;
for (i = 0; i < sockets->count; ++i) { for(i = 0; i < sockets->count; ++i) {
FD_SET(sockets->sockets[i], fdset); FD_SET(sockets->sockets[i], fdset);
if (*maxFd < sockets->sockets[i] + 1) { if(*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1; *maxFd = sockets->sockets[i] + 1;
} }
} }
@ -202,7 +202,7 @@ static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask,
{ {
int numhandles = 0; int numhandles = 0;
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles); CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
if (result != CURLM_OK) { if(result != CURLM_OK) {
fprintf(stderr, "Curl error on %s: %i (%s)\n", fprintf(stderr, "Curl error on %s: %i (%s)\n",
info, result, curl_multi_strerror(result)); info, result, curl_multi_strerror(result));
} }
@ -215,8 +215,8 @@ static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
int evBitmask, const char *name) int evBitmask, const char *name)
{ {
int i; int i;
for (i = 0; i < sockets->count; ++i) { for(i = 0; i < sockets->count; ++i) {
if (FD_ISSET(sockets->sockets[i], fdset)) { if(FD_ISSET(sockets->sockets[i], fdset)) {
notifyCurl(curl, sockets->sockets[i], evBitmask, name); notifyCurl(curl, sockets->sockets[i], evBitmask, name);
} }
} }
@ -227,7 +227,7 @@ int test(char *URL)
int res = 0; int res = 0;
CURL *curl = NULL; CURL *curl = NULL;
FILE *hd_src = NULL; FILE *hd_src = NULL;
int hd ; int hd;
int error; int error;
struct_stat file_info; struct_stat file_info;
CURLM *m = NULL; CURLM *m = NULL;
@ -237,7 +237,7 @@ int test(char *URL)
start_test_timing(); start_test_timing();
if (!libtest_arg3) { if(!libtest_arg3) {
fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n"); fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n");
return TEST_ERR_USAGE; return TEST_ERR_USAGE;
} }
@ -276,7 +276,7 @@ int test(char *URL)
easy_setopt(curl, CURLOPT_UPLOAD, 1L); easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */ /* specify target */
easy_setopt(curl,CURLOPT_URL, URL); easy_setopt(curl, CURLOPT_URL, URL);
/* go verbose */ /* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L); easy_setopt(curl, CURLOPT_VERBOSE, 1L);
@ -300,8 +300,7 @@ int test(char *URL)
multi_add_handle(m, curl); multi_add_handle(m, curl);
while (!checkForCompletion(m, &success)) while(!checkForCompletion(m, &success)) {
{
fd_set readSet, writeSet; fd_set readSet, writeSet;
curl_socket_t maxFd = 0; curl_socket_t maxFd = 0;
struct timeval tv = {10, 0}; struct timeval tv = {10, 0};
@ -311,14 +310,12 @@ int test(char *URL)
updateFdSet(&sockets.read, &readSet, &maxFd); updateFdSet(&sockets.read, &readSet, &maxFd);
updateFdSet(&sockets.write, &writeSet, &maxFd); updateFdSet(&sockets.write, &writeSet, &maxFd);
if (timeout.tv_sec != -1) if(timeout.tv_sec != -1) {
{
int usTimeout = getMicroSecondTimeout(&timeout); int usTimeout = getMicroSecondTimeout(&timeout);
tv.tv_sec = usTimeout / 1000000; tv.tv_sec = usTimeout / 1000000;
tv.tv_usec = usTimeout % 1000000; tv.tv_usec = usTimeout % 1000000;
} }
else if (maxFd <= 0) else if(maxFd <= 0) {
{
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 100000; tv.tv_usec = 100000;
} }
@ -329,8 +326,7 @@ int test(char *URL)
checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read"); checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write"); checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
if (timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) if(timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) {
{
/* Curl's timer has elapsed. */ /* Curl's timer has elapsed. */
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout"); notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
} }
@ -338,8 +334,7 @@ int test(char *URL)
abort_on_test_timeout(); abort_on_test_timeout();
} }
if (!success) if(!success) {
{
fprintf(stderr, "Error uploading file.\n"); fprintf(stderr, "Error uploading file.\n");
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -36,8 +36,8 @@ struct userdata {
}; };
/* lock callback */ /* lock callback */
static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess, static void my_lock(CURL *handle, curl_lock_data data,
void *useptr ) curl_lock_access laccess, void *useptr)
{ {
const char *what; const char *what;
struct userdata *user = (struct userdata *)useptr; struct userdata *user = (struct userdata *)useptr;
@ -101,7 +101,7 @@ static void *fire(void *ptr)
CURL *curl; CURL *curl;
int i=0; int i=0;
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
return NULL; return NULL;
} }
@ -114,7 +114,7 @@ static void *fire(void *ptr)
printf( "PERFORM\n" ); printf( "PERFORM\n" );
code = curl_easy_perform(curl); code = curl_easy_perform(curl);
if( code != CURLE_OK ) { if(code != CURLE_OK ) {
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n", fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
tdata->url, i, (int)code); tdata->url, i, (int)code);
} }
@ -141,37 +141,38 @@ int test(char *URL)
user.counter = 0; user.counter = 0;
printf( "GLOBAL_INIT\n" ); printf( "GLOBAL_INIT\n" );
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* prepare share */ /* prepare share */
printf( "SHARE_INIT\n" ); printf( "SHARE_INIT\n" );
if ((share = curl_share_init()) == NULL) { if((share = curl_share_init()) == NULL) {
fprintf(stderr, "curl_share_init() failed\n"); fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode ) {
printf( "CURLSHOPT_LOCKFUNC\n" ); printf( "CURLSHOPT_LOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock); scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode ) {
printf( "CURLSHOPT_UNLOCKFUNC\n" ); printf( "CURLSHOPT_UNLOCKFUNC\n" );
scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock); scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode ) {
printf( "CURLSHOPT_USERDATA\n" ); printf( "CURLSHOPT_USERDATA\n" );
scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user); scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user);
} }
if ( CURLSHE_OK == scode ) { if(CURLSHE_OK == scode ) {
printf( "CURL_LOCK_DATA_SSL_SESSION\n" ); printf( "CURL_LOCK_DATA_SSL_SESSION\n" );
scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); scode = curl_share_setopt( share, CURLSHOPT_SHARE,
CURL_LOCK_DATA_SSL_SESSION);
} }
if ( CURLSHE_OK != scode ) { if(CURLSHE_OK != scode ) {
fprintf(stderr, "curl_share_setopt() failed\n"); fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
@ -182,7 +183,7 @@ int test(char *URL)
res = 0; res = 0;
/* start treads */ /* start treads */
for (i=1; i<=THREADS; i++ ) { for(i=1; i<=THREADS; i++ ) {
/* set thread data */ /* set thread data */
tdata.url = URL; tdata.url = URL;
@ -196,7 +197,7 @@ int test(char *URL)
/* fetch a another one */ /* fetch a another one */
printf( "*** run %d\n", i ); printf( "*** run %d\n", i );
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
@ -214,11 +215,11 @@ int test(char *URL)
/* try to free share, expect to fail because share is in use*/ /* try to free share, expect to fail because share is in use*/
printf( "try SHARE_CLEANUP...\n" ); printf( "try SHARE_CLEANUP...\n" );
scode = curl_share_cleanup( share ); scode = curl_share_cleanup( share );
if ( scode==CURLSHE_OK ) if(scode==CURLSHE_OK) {
{
fprintf(stderr, "curl_share_cleanup succeed but error expected\n"); fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL; share = NULL;
} else { }
else {
printf( "SHARE_CLEANUP failed, correct\n" ); printf( "SHARE_CLEANUP failed, correct\n" );
} }
@ -231,7 +232,7 @@ test_cleanup:
/* free share */ /* free share */
printf( "SHARE_CLEANUP\n" ); printf( "SHARE_CLEANUP\n" );
scode = curl_share_cleanup( share ); scode = curl_share_cleanup( share );
if ( scode!=CURLSHE_OK ) if(scode!=CURLSHE_OK )
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode); (int)scode);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2012, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -41,12 +41,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -69,7 +69,7 @@ int test(char *URL)
multi_init(multi); multi_init(multi);
for (phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) { for(phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) {
/* go verbose */ /* go verbose */
easy_setopt(easy, CURLOPT_VERBOSE, 1L); easy_setopt(easy, CURLOPT_VERBOSE, 1L);
@ -77,11 +77,11 @@ int test(char *URL)
easy_setopt(easy, CURLOPT_URL, URL); easy_setopt(easy, CURLOPT_URL, URL);
/* enable 'CONNECT_ONLY' option when in connect phase */ /* enable 'CONNECT_ONLY' option when in connect phase */
if (phase == CONNECT_ONLY_PHASE) if(phase == CONNECT_ONLY_PHASE)
easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L); easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L);
/* enable 'NOBODY' option to send 'QUIT' command in quit phase */ /* enable 'NOBODY' option to send 'QUIT' command in quit phase */
if (phase == QUIT_PHASE) { if(phase == QUIT_PHASE) {
easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L); easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L);
easy_setopt(easy, CURLOPT_NOBODY, 1L); easy_setopt(easy, CURLOPT_NOBODY, 1L);
easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L); easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L);
@ -114,7 +114,8 @@ int test(char *URL)
multi_timeout(multi, &timeout); multi_timeout(multi, &timeout);
/* At this point, timeout is guaranteed to be greater or equal than -1. */ /* At this point, timeout is guaranteed to be greater or equal than
-1. */
if(timeout != -1L) { if(timeout != -1L) {
int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2012, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,12 +28,12 @@ int test(char *URL)
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2012, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -45,12 +45,12 @@ int test(char *URL)
CURLcode res=CURLE_OK; CURLcode res=CURLE_OK;
double content_length = 0.0; double content_length = 0.0;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -75,12 +75,12 @@ int test(char *URL)
/* Perform the request, res will get the return code */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (!res) { if(!res) {
FILE *moo; FILE *moo;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
&content_length); &content_length);
moo = fopen(libtest_arg2, "wb"); moo = fopen(libtest_arg2, "wb");
if (moo) { if(moo) {
fprintf(moo, "CL: %.0f\n", content_length); fprintf(moo, "CL: %.0f\n", content_length);
fclose(moo); fclose(moo);
} }

View File

@ -34,7 +34,7 @@ static CURLcode send_request(CURL *curl, const char *url, int seq,
CURLcode res; CURLcode res;
size_t len = strlen(url) + 4 + 1; size_t len = strlen(url) + 4 + 1;
char* full_url = malloc(len); char* full_url = malloc(len);
if (!full_url) { if(!full_url) {
fprintf(stderr, "Not enough memory for full url\n"); fprintf(stderr, "Not enough memory for full url\n");
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
@ -70,13 +70,13 @@ static CURLcode send_right_password(CURL *curl, const char *url, int seq,
static long parse_auth_name(const char *arg) static long parse_auth_name(const char *arg)
{ {
if (!arg) if(!arg)
return CURLAUTH_NONE; return CURLAUTH_NONE;
if (strequal(arg, "basic")) if(strequal(arg, "basic"))
return CURLAUTH_BASIC; return CURLAUTH_BASIC;
if (strequal(arg, "digest")) if(strequal(arg, "digest"))
return CURLAUTH_DIGEST; return CURLAUTH_DIGEST;
if (strequal(arg, "ntlm")) if(strequal(arg, "ntlm"))
return CURLAUTH_NTLM; return CURLAUTH_NTLM;
return CURLAUTH_NONE; return CURLAUTH_NONE;
} }
@ -89,58 +89,58 @@ int test(char *url)
long main_auth_scheme = parse_auth_name(libtest_arg2); long main_auth_scheme = parse_auth_name(libtest_arg2);
long fallback_auth_scheme = parse_auth_name(libtest_arg3); long fallback_auth_scheme = parse_auth_name(libtest_arg3);
if (main_auth_scheme == CURLAUTH_NONE || if(main_auth_scheme == CURLAUTH_NONE ||
fallback_auth_scheme == CURLAUTH_NONE) { fallback_auth_scheme == CURLAUTH_NONE) {
fprintf(stderr, "auth schemes not found on commandline\n"); fprintf(stderr, "auth schemes not found on commandline\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
/* Send wrong password, then right password */ /* Send wrong password, then right password */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
res = send_wrong_password(curl, url, 100, main_auth_scheme); res = send_wrong_password(curl, url, 100, main_auth_scheme);
if (res != CURLE_OK) if(res != CURLE_OK)
goto test_cleanup; goto test_cleanup;
curl_easy_reset(curl); curl_easy_reset(curl);
res = send_right_password(curl, url, 200, fallback_auth_scheme); res = send_right_password(curl, url, 200, fallback_auth_scheme);
if (res != CURLE_OK) if(res != CURLE_OK)
goto test_cleanup; goto test_cleanup;
curl_easy_reset(curl); curl_easy_reset(curl);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
/* Send wrong password twice, then right password */ /* Send wrong password twice, then right password */
if ((curl = curl_easy_init()) == NULL) { if((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
res = send_wrong_password(curl, url, 300, main_auth_scheme); res = send_wrong_password(curl, url, 300, main_auth_scheme);
if (res != CURLE_OK) if(res != CURLE_OK)
goto test_cleanup; goto test_cleanup;
curl_easy_reset(curl); curl_easy_reset(curl);
res = send_wrong_password(curl, url, 400, fallback_auth_scheme); res = send_wrong_password(curl, url, 400, fallback_auth_scheme);
if (res != CURLE_OK) if(res != CURLE_OK)
goto test_cleanup; goto test_cleanup;
curl_easy_reset(curl); curl_easy_reset(curl);
res = send_right_password(curl, url, 500, fallback_auth_scheme); res = send_right_password(curl, url, 500, fallback_auth_scheme);
if (res != CURLE_OK) if(res != CURLE_OK)
goto test_cleanup; goto test_cleanup;
curl_easy_reset(curl); curl_easy_reset(curl);
test_cleanup: test_cleanup:

View File

@ -47,7 +47,7 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data)
const size_t failure = (size * nmemb) ? 0 : 1; const size_t failure = (size * nmemb) ? 0 : 1;
char *output = malloc(size * nmemb + 1); char *output = malloc(size * nmemb + 1);
if (!output) { if(!output) {
fprintf(stderr, "output, malloc() failed\n"); fprintf(stderr, "output, malloc() failed\n");
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
return failure; return failure;
@ -60,25 +60,25 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data)
/* Get socket being used for this easy handle, otherwise CURL_SOCKET_BAD */ /* Get socket being used for this easy handle, otherwise CURL_SOCKET_BAD */
code = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &longdata); code = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &longdata);
if (CURLE_OK != code) { if(CURLE_OK != code) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed, " fprintf(stderr, "%s:%d curl_easy_getinfo() failed, "
"with code %d (%s)\n", "with code %d (%s)\n",
__FILE__, __LINE__, (int)code, curl_easy_strerror(code)); __FILE__, __LINE__, (int)code, curl_easy_strerror(code));
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
return failure; return failure;
} }
if (longdata == -1L) if(longdata == -1L)
sock = CURL_SOCKET_BAD; sock = CURL_SOCKET_BAD;
else else
sock = (curl_socket_t)longdata; sock = (curl_socket_t)longdata;
if (sock != CURL_SOCKET_BAD) { if(sock != CURL_SOCKET_BAD) {
/* Track relationship between this easy handle and the socket. */ /* Track relationship between this easy handle and the socket. */
if (sockets[idx] == CURL_SOCKET_BAD) { if(sockets[idx] == CURL_SOCKET_BAD) {
/* An easy handle without previous socket, record the socket. */ /* An easy handle without previous socket, record the socket. */
sockets[idx] = sock; sockets[idx] = sock;
} }
else if (sock != sockets[idx]) { else if(sock != sockets[idx]) {
/* An easy handle with a socket different to previously /* An easy handle with a socket different to previously
tracked one, log and fail right away. Known bug #37. */ tracked one, log and fail right away. Known bug #37. */
fprintf(stderr, "Handle %d started on socket %d and moved to %d\n", fprintf(stderr, "Handle %d started on socket %d and moved to %d\n",
@ -113,7 +113,7 @@ int test(char *url)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
for (i = 0; i < MAX_EASY_HANDLES; ++i) { for(i = 0; i < MAX_EASY_HANDLES; ++i) {
easy[i] = NULL; easy[i] = NULL;
sockets[i] = CURL_SOCKET_BAD; sockets[i] = CURL_SOCKET_BAD;
} }
@ -148,7 +148,8 @@ int test(char *url)
if(num_handles % 3 == 2) { if(num_handles % 3 == 2) {
snprintf(full_url, urllen, "%s0200", url); snprintf(full_url, urllen, "%s0200", url);
easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM); easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
} else { }
else {
snprintf(full_url, urllen, "%s0100", url); snprintf(full_url, urllen, "%s0100", url);
easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC); easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
} }
@ -182,7 +183,7 @@ int test(char *url)
/* At this point, maxfd is guaranteed to be greater or equal than -1. */ /* At this point, maxfd is guaranteed to be greater or equal than -1. */
/* Any socket which is new in fdread is associated with the new handle */ /* Any socket which is new in fdread is associated with the new handle */
for (i = 0; i <= maxfd; ++i) { for(i = 0; i <= maxfd; ++i) {
bool socket_exists = FALSE; bool socket_exists = FALSE;
curl_socket_t curfd = (curl_socket_t)i; curl_socket_t curfd = (curl_socket_t)i;
@ -192,7 +193,7 @@ int test(char *url)
/* Check if this socket was already detected for an earlier handle (or /* Check if this socket was already detected for an earlier handle (or
for this handle, num_handles-1, in the callback */ for this handle, num_handles-1, in the callback */
for (j = 0; j < num_handles; ++j) { for(j = 0; j < num_handles; ++j) {
if(sockets[j] == curfd) { if(sockets[j] == curfd) {
socket_exists = TRUE; socket_exists = TRUE;
break; break;

View File

@ -43,10 +43,10 @@
#include "curl_printf.h" #include "curl_printf.h"
#define test_setopt(A,B,C) \ #define test_setopt(A,B,C) \
if((res = curl_easy_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) goto test_cleanup
#define test_multi_setopt(A,B,C) \ #define test_multi_setopt(A,B,C) \
if((res = curl_multi_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup if((res = curl_multi_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_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 */ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
@ -132,16 +132,16 @@ extern int unitfail;
} WHILE_FALSE } WHILE_FALSE
#define res_easy_init(A) \ #define res_easy_init(A) \
exe_easy_init((A),(__FILE__),(__LINE__)) exe_easy_init((A), (__FILE__), (__LINE__))
#define chk_easy_init(A,Y,Z) do { \ #define chk_easy_init(A,Y,Z) do { \
exe_easy_init((A),(Y),(Z)); \ exe_easy_init((A), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define easy_init(A) \ #define easy_init(A) \
chk_easy_init((A),(__FILE__),(__LINE__)) chk_easy_init((A), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -153,70 +153,70 @@ extern int unitfail;
} WHILE_FALSE } WHILE_FALSE
#define res_multi_init(A) \ #define res_multi_init(A) \
exe_multi_init((A),(__FILE__),(__LINE__)) exe_multi_init((A), (__FILE__), (__LINE__))
#define chk_multi_init(A,Y,Z) do { \ #define chk_multi_init(A,Y,Z) do { \
exe_multi_init((A),(Y),(Z)); \ exe_multi_init((A), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_init(A) \ #define multi_init(A) \
chk_multi_init((A),(__FILE__),(__LINE__)) chk_multi_init((A), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_easy_setopt(A,B,C,Y,Z) do { \ #define exe_easy_setopt(A,B,C,Y,Z) do { \
CURLcode ec; \ CURLcode ec; \
if((ec = curl_easy_setopt((A),(B),(C))) != CURLE_OK) { \ if((ec = curl_easy_setopt((A), (B), (C))) != CURLE_OK) { \
fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \ fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_easy_strerror(ec)); \ (Y), (Z), (int)ec, curl_easy_strerror(ec)); \
res = (int)ec; \ res = (int)ec; \
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_easy_setopt(A,B,C) \ #define res_easy_setopt(A, B, C) \
exe_easy_setopt((A),(B),(C),(__FILE__),(__LINE__)) exe_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
#define chk_easy_setopt(A,B,C,Y,Z) do { \ #define chk_easy_setopt(A, B, C, Y, Z) do { \
exe_easy_setopt((A),(B),(C),(Y),(Z)); \ exe_easy_setopt((A), (B), (C), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define easy_setopt(A,B,C) \ #define easy_setopt(A, B, C) \
chk_easy_setopt((A),(B),(C),(__FILE__),(__LINE__)) chk_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_multi_setopt(A,B,C,Y,Z) do { \ #define exe_multi_setopt(A, B, C, Y, Z) do { \
CURLMcode ec; \ CURLMcode ec; \
if((ec = curl_multi_setopt((A),(B),(C))) != CURLM_OK) { \ if((ec = curl_multi_setopt((A), (B), (C))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \ fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \ res = (int)ec; \
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_multi_setopt(A,B,C) \ #define res_multi_setopt(A,B,C) \
exe_multi_setopt((A),(B),(C),(__FILE__),(__LINE__)) exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
#define chk_multi_setopt(A,B,C,Y,Z) do { \ #define chk_multi_setopt(A,B,C,Y,Z) do { \
exe_multi_setopt((A),(B),(C),(Y),(Z)); \ exe_multi_setopt((A), (B), (C), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_setopt(A,B,C) \ #define multi_setopt(A,B,C) \
chk_multi_setopt((A),(B),(C),(__FILE__),(__LINE__)) chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_multi_add_handle(A,B,Y,Z) do { \ #define exe_multi_add_handle(A,B,Y,Z) do { \
CURLMcode ec; \ CURLMcode ec; \
if((ec = curl_multi_add_handle((A),(B))) != CURLM_OK) { \ if((ec = curl_multi_add_handle((A), (B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \ fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
@ -224,23 +224,23 @@ extern int unitfail;
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_multi_add_handle(A,B) \ #define res_multi_add_handle(A, B) \
exe_multi_add_handle((A),(B),(__FILE__),(__LINE__)) exe_multi_add_handle((A), (B), (__FILE__), (__LINE__))
#define chk_multi_add_handle(A,B,Y,Z) do { \ #define chk_multi_add_handle(A, B, Y, Z) do { \
exe_multi_add_handle((A),(B),(Y),(Z)); \ exe_multi_add_handle((A), (B), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_add_handle(A,B) \ #define multi_add_handle(A, B) \
chk_multi_add_handle((A),(B),(__FILE__),(__LINE__)) chk_multi_add_handle((A), (B), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_multi_remove_handle(A,B,Y,Z) do { \ #define exe_multi_remove_handle(A,B,Y,Z) do { \
CURLMcode ec; \ CURLMcode ec; \
if((ec = curl_multi_remove_handle((A),(B))) != CURLM_OK) { \ if((ec = curl_multi_remove_handle((A), (B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \ fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
@ -248,24 +248,24 @@ extern int unitfail;
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_multi_remove_handle(A,B) \ #define res_multi_remove_handle(A, B) \
exe_multi_remove_handle((A),(B),(__FILE__),(__LINE__)) exe_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
#define chk_multi_remove_handle(A,B,Y,Z) do { \ #define chk_multi_remove_handle(A, B, Y, Z) do { \
exe_multi_remove_handle((A),(B),(Y),(Z)); \ exe_multi_remove_handle((A), (B), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_remove_handle(A,B) \ #define multi_remove_handle(A, B) \
chk_multi_remove_handle((A),(B),(__FILE__),(__LINE__)) chk_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_multi_perform(A,B,Y,Z) do { \ #define exe_multi_perform(A,B,Y,Z) do { \
CURLMcode ec; \ CURLMcode ec; \
if((ec = curl_multi_perform((A),(B))) != CURLM_OK) { \ if((ec = curl_multi_perform((A), (B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_perform() failed, " \ fprintf(stderr, "%s:%d curl_multi_perform() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
@ -279,53 +279,53 @@ extern int unitfail;
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_multi_perform(A,B) \ #define res_multi_perform(A, B) \
exe_multi_perform((A),(B),(__FILE__),(__LINE__)) exe_multi_perform((A), (B), (__FILE__), (__LINE__))
#define chk_multi_perform(A,B,Y,Z) do { \ #define chk_multi_perform(A, B, Y, Z) do { \
exe_multi_perform((A),(B),(Y),(Z)); \ exe_multi_perform((A), (B), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_perform(A,B) \ #define multi_perform(A,B) \
chk_multi_perform((A),(B),(__FILE__),(__LINE__)) chk_multi_perform((A), (B), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_multi_fdset(A,B,C,D,E,Y,Z) do { \ #define exe_multi_fdset(A, B, C, D, E, Y, Z) do { \
CURLMcode ec; \ CURLMcode ec; \
if((ec = curl_multi_fdset((A),(B),(C),(D),(E))) != CURLM_OK) { \ if((ec = curl_multi_fdset((A), (B), (C), (D), (E))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \ fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
res = (int)ec; \ res = (int)ec; \
} \ } \
else if(*((E)) < -1) { \ else if(*((E)) < -1) { \
fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \ fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \
"but returned invalid max_fd value (%d)\n", \ "but returned invalid max_fd value (%d)\n", \
(Y), (Z), (int)*((E))); \ (Y), (Z), (int)*((E))); \
res = TEST_ERR_NUM_HANDLES; \ res = TEST_ERR_NUM_HANDLES; \
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_multi_fdset(A,B,C,D,E) \ #define res_multi_fdset(A, B, C, D, E) \
exe_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) exe_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
#define chk_multi_fdset(A,B,C,D,E,Y,Z) do { \ #define chk_multi_fdset(A, B, C, D, E, Y, Z) do { \
exe_multi_fdset((A),(B),(C),(D),(E),(Y),(Z)); \ exe_multi_fdset((A), (B), (C), (D), (E), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_fdset(A,B,C,D,E) \ #define multi_fdset(A, B, C, D, E) \
chk_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) chk_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_multi_timeout(A,B,Y,Z) do { \ #define exe_multi_timeout(A,B,Y,Z) do { \
CURLMcode ec; \ CURLMcode ec; \
if((ec = curl_multi_timeout((A),(B))) != CURLM_OK) { \ if((ec = curl_multi_timeout((A), (B))) != CURLM_OK) { \
fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \ fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \
"with code %d (%s)\n", \ "with code %d (%s)\n", \
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \
@ -339,42 +339,42 @@ extern int unitfail;
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_multi_timeout(A,B) \ #define res_multi_timeout(A, B) \
exe_multi_timeout((A),(B),(__FILE__),(__LINE__)) exe_multi_timeout((A), (B), (__FILE__), (__LINE__))
#define chk_multi_timeout(A,B,Y,Z) do { \ #define chk_multi_timeout(A, B, Y, Z) do { \
exe_multi_timeout((A),(B),(Y),(Z)); \ exe_multi_timeout((A), (B), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define multi_timeout(A,B) \ #define multi_timeout(A, B) \
chk_multi_timeout((A),(B),(__FILE__),(__LINE__)) chk_multi_timeout((A), (B), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#define exe_select_test(A,B,C,D,E,Y,Z) do { \ #define exe_select_test(A, B, C, D, E, Y, Z) do { \
int ec; \ int ec; \
if(select_wrapper((A),(B),(C),(D),(E)) == -1 ) { \ if(select_wrapper((A), (B), (C), (D), (E)) == -1 ) { \
ec = SOCKERRNO; \ ec = SOCKERRNO; \
fprintf(stderr, "%s:%d select() failed, with " \ fprintf(stderr, "%s:%d select() failed, with " \
"errno %d (%s)\n", \ "errno %d (%s)\n", \
(Y), (Z), ec, strerror(ec)); \ (Y), (Z), ec, strerror(ec)); \
res = TEST_ERR_SELECT; \ res = TEST_ERR_SELECT; \
} \ } \
} WHILE_FALSE } WHILE_FALSE
#define res_select_test(A,B,C,D,E) \ #define res_select_test(A, B, C, D, E) \
exe_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) exe_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
#define chk_select_test(A,B,C,D,E,Y,Z) do { \ #define chk_select_test(A, B, C, D, E, Y, Z) do { \
exe_select_test((A),(B),(C),(D),(E),(Y),(Z)); \ exe_select_test((A), (B), (C), (D), (E), (Y), (Z)); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define select_test(A,B,C,D,E) \ #define select_test(A, B, C, D, E) \
chk_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) chk_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -391,16 +391,16 @@ extern int unitfail;
} WHILE_FALSE } WHILE_FALSE
#define res_test_timedout() \ #define res_test_timedout() \
exe_test_timedout((__FILE__),(__LINE__)) exe_test_timedout((__FILE__), (__LINE__))
#define chk_test_timedout(Y,Z) do { \ #define chk_test_timedout(Y, Z) do { \
exe_test_timedout(Y,Z); \ exe_test_timedout(Y, Z); \
if(res) \ if(res) \
goto test_cleanup; \ goto test_cleanup; \
} WHILE_FALSE } WHILE_FALSE
#define abort_on_test_timeout() \ #define abort_on_test_timeout() \
chk_test_timedout((__FILE__),(__LINE__)) chk_test_timedout((__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -415,18 +415,18 @@ extern int unitfail;
} WHILE_FALSE } WHILE_FALSE
#define res_global_init(A) \ #define res_global_init(A) \
exe_global_init((A),(__FILE__),(__LINE__)) exe_global_init((A), (__FILE__), (__LINE__))
#define chk_global_init(A,Y,Z) do { \ #define chk_global_init(A, Y, Z) do { \
exe_global_init((A),(Y),(Z)); \ exe_global_init((A), (Y), (Z)); \
if(res) \ if(res) \
return res; \ return res; \
} WHILE_FALSE } WHILE_FALSE
/* global_init() is different than other macros. In case of /* global_init() is different than other macros. In case of
failure it 'return's instead of going to 'test_cleanup'. */ failure it 'return's instead of going to 'test_cleanup'. */
#define global_init(A) \ #define global_init(A) \
chk_global_init((A),(__FILE__),(__LINE__)) chk_global_init((A), (__FILE__), (__LINE__))
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */