If memory debugging enabled return error on leaks.
[openssl.git] / test / ecdhtest.c
index 47c8185b7701f321bea1cdef6a35b01da5593628..16d8cedac1d6f0701be7a95a45eb89e00e4333fa 100644 (file)
@@ -1,4 +1,3 @@
-/* crypto/ecdh/ecdhtest.c */
 /* ====================================================================
  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
  *
 /* ====================================================================
  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
  *
@@ -90,7 +89,6 @@ int main(int argc, char *argv[])
 }
 #else
 # include <openssl/ec.h>
 }
 #else
 # include <openssl/ec.h>
-# include <openssl/ecdh.h>
 
 static const char rnd_seed[] =
     "string to make the random number generator think it has entropy";
 
 static const char rnd_seed[] =
     "string to make the random number generator think it has entropy";
@@ -453,20 +451,15 @@ int main(int argc, char *argv[])
     int ret = 1;
     BIO *out;
 
     int ret = 1;
     BIO *out;
 
-    CRYPTO_malloc_debug_init();
-    CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
+    CRYPTO_set_mem_debug(1);
     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
 
     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
 
-# ifdef OPENSSL_SYS_WIN32
-    CRYPTO_malloc_init();
-# endif
-
     RAND_seed(rnd_seed, sizeof rnd_seed);
 
     out = BIO_new(BIO_s_file());
     if (out == NULL)
         EXIT(1);
     RAND_seed(rnd_seed, sizeof rnd_seed);
 
     out = BIO_new(BIO_s_file());
     if (out == NULL)
         EXIT(1);
-    BIO_set_fp(out, stdout, BIO_NOCLOSE);
+    BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 
     if ((ctx = BN_CTX_new()) == NULL)
         goto err;
 
     if ((ctx = BN_CTX_new()) == NULL)
         goto err;
@@ -522,7 +515,10 @@ int main(int argc, char *argv[])
     BIO_free(out);
     CRYPTO_cleanup_all_ex_data();
     ERR_remove_thread_state(NULL);
     BIO_free(out);
     CRYPTO_cleanup_all_ex_data();
     ERR_remove_thread_state(NULL);
-    CRYPTO_mem_leaks_fp(stderr);
+#ifndef OPENSSL_NO_CRYPTO_MDEBUG
+    if (CRYPTO_mem_leaks_fp(stderr) <= 0)
+        ret = 1;
+#endif
     EXIT(ret);
 }
 #endif
     EXIT(ret);
 }
 #endif