diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2017-08-19 21:27:38 +0200 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2017-08-19 21:42:47 +0200 |
commit | c468c27b5a8abb8134b3f89439aaac45f37d22d7 (patch) | |
tree | 94fa73f73c03b1ff79df9264332724ecaec8e82c /tests/libtest | |
parent | c1a75407cc515f310b8b7caf6bbf6e6cb5fde38c (diff) |
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.
Diffstat (limited to 'tests/libtest')
-rw-r--r-- | tests/libtest/lib1531.c | 4 | ||||
-rw-r--r-- | tests/libtest/lib1550.c | 13 | ||||
-rw-r--r-- | tests/libtest/lib1551.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib543.c | 12 | ||||
-rw-r--r-- | tests/libtest/lib552.c | 10 | ||||
-rw-r--r-- | tests/libtest/lib597.c | 5 |
6 files changed, 28 insertions, 18 deletions
diff --git a/tests/libtest/lib1531.c b/tests/libtest/lib1531.c index 287acd6c6..e203baba1 100644 --- a/tests/libtest/lib1531.c +++ b/tests/libtest/lib1531.c @@ -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; } diff --git a/tests/libtest/lib1550.c b/tests/libtest/lib1550.c index 94ee576ca..d3e17e4fe 100644 --- a/tests/libtest/lib1550.c +++ b/tests/libtest/lib1550.c @@ -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; } diff --git a/tests/libtest/lib1551.c b/tests/libtest/lib1551.c index 16e27275a..36ba75715 100644 --- a/tests/libtest/lib1551.c +++ b/tests/libtest/lib1551.c @@ -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; } diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 6d2532d12..957839f7a 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -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; } diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 3a93dafaf..9cae45993 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -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); diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index 813af7541..bace92cbe 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -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); |