]> granicus.if.org Git - curl/commitdiff
tests: Make sure libtests call curl_global_cleanup()
authorDan Fandrich <dan@coneharvesters.com>
Sat, 19 Aug 2017 19:27:38 +0000 (21:27 +0200)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 19 Aug 2017 19:42:47 +0000 (21:42 +0200)
This ensures that global data allocations are freed so Valgrind stays
happy. This was a problem with at least PolarSSL and mbedTLS.

tests/libtest/lib1531.c
tests/libtest/lib1550.c
tests/libtest/lib1551.c
tests/libtest/lib543.c
tests/libtest/lib552.c
tests/libtest/lib597.c

index 287acd6c653bdf02b452754c9c4350479677058d..e203baba1b06cc044c8061481121cd9dd1f1c161 100644 (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;
 }
index 94ee576ca4bfab03cd27e8bdba716ec9df4bfa4f..d3e17e4fe8f8715464b6f9ef3c58d9bff9d52360 100644 (file)
 
 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;
 }
index 16e27275a844f632c0888f9133408320dbbd196f..36ba75715c0a83975298165b6ad298342573a5c7 100644 (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;
 }
index 6d2532d1229c136052b2ab4264e904ed1e0834b3..957839f7a65683d5e449482ee3f2d6dc699baf41 100644 (file)
 
 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;
 }
index 3a93dafafa3b2b35ae5fe696f7f3f800063cc99e..9cae4599300c9198b18ac6969f3fd0f8ca45f089 100644 (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);
index 813af75411180f477c5d3cfad865892fd6f73b57..bace92cbe62760be170bc527921c2352d9255a91 100644 (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);