]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add code to run test, get malloc counts
authorRich Salz <rsalz@openssl.org>
Thu, 15 Mar 2018 14:51:17 +0000 (10:51 -0400)
committerRich Salz <rsalz@openssl.org>
Thu, 15 Mar 2018 14:51:17 +0000 (10:51 -0400)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4528)

test/sslapitest.c

index 2c122be3c8ad6beefc71119b12442d82887eab74..8e9115178069d73b5eac97004a2e740b85b1cbac 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "ssltestlib.h"
 #include "testutil.h"
+#include "testutil/output.h"
 #include "internal/nelem.h"
 #include "../ssl/ssl_locl.h"
 
@@ -3638,6 +3639,22 @@ int setup_tests(void)
             || !TEST_ptr(privkey = test_get_argument(1)))
         return 0;
 
+    if (getenv("OPENSSL_TEST_GETCOUNTS") != NULL) {
+#ifdef OPENSSL_NO_CRYPTO_MDEBUG
+        TEST_error("not supported in this build");
+        return 0;
+#else
+        int i, mcount, rcount, fcount;
+
+        for (i = 0; i < 4; i++)
+            test_export_key_mat(i);
+        CRYPTO_get_alloc_counts(&mcount, &rcount, &fcount);
+        test_printf_stdout("malloc %d realloc %d free %d\n",
+                mcount, rcount, fcount);
+        return 1;
+#endif
+    }
+
     ADD_TEST(test_large_message_tls);
     ADD_TEST(test_large_message_tls_read_ahead);
 #ifndef OPENSSL_NO_DTLS