1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48: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:
Dan Fandrich 2017-08-19 21:27:38 +02:00
parent c1a75407cc
commit c468c27b5a
6 changed files with 28 additions and 18 deletions

View File

@ -37,6 +37,9 @@ int test(char *URL)
int still_running; /* keep number of running handles */
CURLMsg *msg; /* for picking up messages with the transfer status */
int msgs_left; /* how many messages are left */
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
/* Allocate one CURL handle per transfer */
easy = curl_easy_init();
@ -139,6 +142,7 @@ int test(char *URL)
/* Free the CURL handles */
curl_easy_cleanup(easy);
curl_global_cleanup();
return 0;
}

View File

@ -27,13 +27,20 @@
int test(char *URL)
{
CURLM *handle = curl_multi_init();
const char *bl_servers[] = {"Microsoft-IIS/6.0", "nginx/0.8.54", NULL};
const char *bl_sites[] = {"curl.haxx.se:443", "example.com:80", NULL};
CURLM *handle;
int res = CURLE_OK;
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 */
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SERVER_BL, bl_servers);
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SITE_BL, bl_sites);
curl_multi_cleanup(handle);
curl_global_cleanup();
return 0;
}

View File

@ -30,6 +30,7 @@ int test(char *URL)
CURL *curl;
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, URL);
@ -41,5 +42,6 @@ int test(char *URL)
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return (int)res;
}

View File

@ -27,15 +27,18 @@
int test(char *URL)
{
unsigned char a[] = {0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
0x1d, 0x57, 0xe1};
static const unsigned char a[] = {
0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
0x1d, 0x57, 0xe1};
CURL *easy;
int asize;
char *s;
CURLcode res = CURLE_OK;
(void)URL;
global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
fprintf(stderr, "curl_easy_init() failed\n");
@ -44,7 +47,7 @@ int test(char *URL)
asize = (int)sizeof(a);
s = curl_easy_escape(easy, (char *)a, asize);
s = curl_easy_escape(easy, (const char *)a, asize);
if(s)
printf("%s\n", s);
@ -53,6 +56,7 @@ int test(char *URL)
curl_free(s);
curl_easy_cleanup(easy);
curl_global_cleanup();
return 0;
}

View File

@ -166,19 +166,15 @@ static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OUT_OF_MEMORY;
CURLcode res = CURLE_OK;
struct data config;
size_t i;
static const char fill[] = "test data";
config.trace_ascii = 1; /* enable ascii tracing */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
test_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
test_setopt(curl, CURLOPT_DEBUGDATA, &config);

View File

@ -60,10 +60,7 @@ int test(char *URL)
start_test_timing();
res_global_init(CURL_GLOBAL_ALL);
if(res) {
return res;
}
global_init(CURL_GLOBAL_ALL);
easy_init(easy);