mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
tests: Make sure libtests call curl_global_cleanup()
This ensures that global data allocations are freed so Valgrind stays happy. This was a problem with at least PolarSSL and mbedTLS.
This commit is contained in:
parent
c1a75407cc
commit
c468c27b5a
@ -37,6 +37,9 @@ int test(char *URL)
|
|||||||
int still_running; /* keep number of running handles */
|
int still_running; /* keep number of running handles */
|
||||||
CURLMsg *msg; /* for picking up messages with the transfer status */
|
CURLMsg *msg; /* for picking up messages with the transfer status */
|
||||||
int msgs_left; /* how many messages are left */
|
int msgs_left; /* how many messages are left */
|
||||||
|
int res = CURLE_OK;
|
||||||
|
|
||||||
|
global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
/* Allocate one CURL handle per transfer */
|
/* Allocate one CURL handle per transfer */
|
||||||
easy = curl_easy_init();
|
easy = curl_easy_init();
|
||||||
@ -139,6 +142,7 @@ int test(char *URL)
|
|||||||
|
|
||||||
/* Free the CURL handles */
|
/* Free the CURL handles */
|
||||||
curl_easy_cleanup(easy);
|
curl_easy_cleanup(easy);
|
||||||
|
curl_global_cleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,20 @@
|
|||||||
|
|
||||||
int test(char *URL)
|
int test(char *URL)
|
||||||
{
|
{
|
||||||
CURLM *handle = curl_multi_init();
|
CURLM *handle;
|
||||||
const char *bl_servers[] = {"Microsoft-IIS/6.0", "nginx/0.8.54", NULL};
|
int res = CURLE_OK;
|
||||||
const char *bl_sites[] = {"curl.haxx.se:443", "example.com:80", NULL};
|
static const char * const bl_servers[] =
|
||||||
|
{"Microsoft-IIS/6.0", "nginx/0.8.54", NULL};
|
||||||
|
static const char * const bl_sites[] =
|
||||||
|
{"curl.haxx.se:443", "example.com:80", NULL};
|
||||||
|
|
||||||
|
global_init(CURL_GLOBAL_ALL);
|
||||||
|
handle = curl_multi_init();
|
||||||
(void)URL; /* unused */
|
(void)URL; /* unused */
|
||||||
|
|
||||||
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SERVER_BL, bl_servers);
|
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SERVER_BL, bl_servers);
|
||||||
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SITE_BL, bl_sites);
|
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SITE_BL, bl_sites);
|
||||||
curl_multi_cleanup(handle);
|
curl_multi_cleanup(handle);
|
||||||
|
curl_global_cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ int test(char *URL)
|
|||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
|
|
||||||
|
global_init(CURL_GLOBAL_ALL);
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(curl) {
|
if(curl) {
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||||
@ -41,5 +42,6 @@ int test(char *URL)
|
|||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
|
curl_global_cleanup();
|
||||||
return (int)res;
|
return (int)res;
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,18 @@
|
|||||||
|
|
||||||
int test(char *URL)
|
int test(char *URL)
|
||||||
{
|
{
|
||||||
unsigned char a[] = {0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
|
static const unsigned char a[] = {
|
||||||
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
|
0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
|
||||||
0x1d, 0x57, 0xe1};
|
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
|
||||||
|
0x1d, 0x57, 0xe1};
|
||||||
|
|
||||||
CURL *easy;
|
CURL *easy;
|
||||||
int asize;
|
int asize;
|
||||||
char *s;
|
char *s;
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
(void)URL;
|
(void)URL;
|
||||||
|
|
||||||
|
global_init(CURL_GLOBAL_ALL);
|
||||||
easy = curl_easy_init();
|
easy = curl_easy_init();
|
||||||
if(!easy) {
|
if(!easy) {
|
||||||
fprintf(stderr, "curl_easy_init() failed\n");
|
fprintf(stderr, "curl_easy_init() failed\n");
|
||||||
@ -44,7 +47,7 @@ int test(char *URL)
|
|||||||
|
|
||||||
asize = (int)sizeof(a);
|
asize = (int)sizeof(a);
|
||||||
|
|
||||||
s = curl_easy_escape(easy, (char *)a, asize);
|
s = curl_easy_escape(easy, (const char *)a, asize);
|
||||||
|
|
||||||
if(s)
|
if(s)
|
||||||
printf("%s\n", s);
|
printf("%s\n", s);
|
||||||
@ -53,6 +56,7 @@ int test(char *URL)
|
|||||||
curl_free(s);
|
curl_free(s);
|
||||||
|
|
||||||
curl_easy_cleanup(easy);
|
curl_easy_cleanup(easy);
|
||||||
|
curl_global_cleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -166,19 +166,15 @@ static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
|
|||||||
int test(char *URL)
|
int test(char *URL)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res = CURLE_OUT_OF_MEMORY;
|
CURLcode res = CURLE_OK;
|
||||||
struct data config;
|
struct data config;
|
||||||
size_t i;
|
size_t i;
|
||||||
static const char fill[] = "test data";
|
static const char fill[] = "test data";
|
||||||
|
|
||||||
config.trace_ascii = 1; /* enable ascii tracing */
|
config.trace_ascii = 1; /* enable ascii tracing */
|
||||||
|
|
||||||
curl = curl_easy_init();
|
global_init(CURL_GLOBAL_ALL);
|
||||||
if(!curl) {
|
easy_init(curl);
|
||||||
fprintf(stderr, "curl_easy_init() failed\n");
|
|
||||||
curl_global_cleanup();
|
|
||||||
return TEST_ERR_MAJOR_BAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
test_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
|
test_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
|
||||||
test_setopt(curl, CURLOPT_DEBUGDATA, &config);
|
test_setopt(curl, CURLOPT_DEBUGDATA, &config);
|
||||||
|
@ -60,10 +60,7 @@ int test(char *URL)
|
|||||||
|
|
||||||
start_test_timing();
|
start_test_timing();
|
||||||
|
|
||||||
res_global_init(CURL_GLOBAL_ALL);
|
global_init(CURL_GLOBAL_ALL);
|
||||||
if(res) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
easy_init(easy);
|
easy_init(easy);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user