diff options
author | Viktor Dukhovni <openssl-users@dukhovni.org> | 2016-01-10 20:42:10 +0100 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2016-01-11 03:41:16 +0100 |
commit | c2e27310c790c0dd2f87dd420e65e0cca522ddb2 (patch) | |
tree | bda08e77fcbd3f993498ef5a4c7d9b551b0b47ed /test | |
parent | Disable some algorithms by default (diff) | |
download | openssl-c2e27310c790c0dd2f87dd420e65e0cca522ddb2.tar.xz openssl-c2e27310c790c0dd2f87dd420e65e0cca522ddb2.zip |
Enable/disable crypto-mdebug just like other features
Also always abort() on leak failure.
Reviewed-by: Stephen Henson <steve@openssl.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/clienthellotest.c | 2 | ||||
-rw-r--r-- | test/danetest.c | 2 | ||||
-rw-r--r-- | test/dsatest.c | 2 | ||||
-rw-r--r-- | test/ecdhtest.c | 2 | ||||
-rw-r--r-- | test/ecdsatest.c | 2 | ||||
-rw-r--r-- | test/ectest.c | 2 | ||||
-rw-r--r-- | test/enginetest.c | 2 | ||||
-rw-r--r-- | test/evp_extra_test.c | 2 | ||||
-rw-r--r-- | test/evp_test.c | 2 | ||||
-rw-r--r-- | test/exptest.c | 2 | ||||
-rw-r--r-- | test/memleaktest.c | 31 | ||||
-rw-r--r-- | test/p5_crpt2_test.c | 2 | ||||
-rw-r--r-- | test/recipes/90-test_memleak.t | 5 | ||||
-rw-r--r-- | test/rsa_test.c | 2 | ||||
-rw-r--r-- | test/srptest.c | 2 | ||||
-rw-r--r-- | test/ssltest.c | 2 | ||||
-rw-r--r-- | test/verify_extra_test.c | 2 |
17 files changed, 41 insertions, 25 deletions
diff --git a/test/clienthellotest.c b/test/clienthellotest.c index 289ca1e572..9cb563c548 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) ERR_remove_thread_state(NULL); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(err); #endif BIO_free(err); diff --git a/test/danetest.c b/test/danetest.c index 02d0f79efc..09156a6991 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -526,7 +526,7 @@ end: ERR_free_strings(); ERR_remove_thread_state(NULL); EVP_cleanup(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(bio_err); #endif BIO_free(bio_err); diff --git a/test/dsatest.c b/test/dsatest.c index 81c36cb48a..8190e6f2ee 100644 --- a/test/dsatest.c +++ b/test/dsatest.c @@ -215,7 +215,7 @@ int main(int argc, char **argv) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(bio_err); #endif BIO_free(bio_err); diff --git a/test/ecdhtest.c b/test/ecdhtest.c index c299c32d95..8be4e50094 100644 --- a/test/ecdhtest.c +++ b/test/ecdhtest.c @@ -516,7 +516,7 @@ int main(int argc, char *argv[]) BIO_free(out); CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif EXIT(ret); diff --git a/test/ecdsatest.c b/test/ecdsatest.c index 2e85d5e04b..5a27a38a9a 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -545,7 +545,7 @@ int main(void) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(out); #endif BIO_free(out); diff --git a/test/ectest.c b/test/ectest.c index 9667772315..fbf5081f89 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -1664,7 +1664,7 @@ int main(int argc, char *argv[]) CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); ERR_remove_thread_state(NULL); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif diff --git a/test/enginetest.c b/test/enginetest.c index f5924e07b6..32df0e45fc 100644 --- a/test/enginetest.c +++ b/test/enginetest.c @@ -249,7 +249,7 @@ int main(int argc, char *argv[]) CRYPTO_cleanup_all_ex_data(); ERR_free_strings(); ERR_remove_thread_state(NULL); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif return to_return; diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 0d6ad03eb3..13dd262705 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -466,7 +466,7 @@ int main(void) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif diff --git a/test/evp_test.c b/test/evp_test.c index 91caa4fc25..c8d1f60eaf 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -610,7 +610,7 @@ int main(int argc, char **argv) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif if (t.errors) diff --git a/test/exptest.c b/test/exptest.c index 53286d8924..5fdcc3800e 100644 --- a/test/exptest.c +++ b/test/exptest.c @@ -300,7 +300,7 @@ int main(int argc, char *argv[]) BN_free(m); BN_CTX_free(ctx); ERR_remove_thread_state(NULL); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(out); #endif BIO_free(out); diff --git a/test/memleaktest.c b/test/memleaktest.c index cccbcf6625..cdb61a3608 100644 --- a/test/memleaktest.c +++ b/test/memleaktest.c @@ -56,12 +56,23 @@ #include <string.h> #include <openssl/bio.h> #include <openssl/crypto.h> +#include <setjmp.h> + +#ifndef OPENSSL_NO_CRYPTO_MDEBUG +static sigjmp_buf env; + +static void handler(int sig) +{ + siglongjmp(env, 1); +} +#endif int main(int argc, char **argv) { -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG char *p; char *lost; + int aborted = 0; p = getenv("OPENSSL_DEBUG_MEMORY"); if (p != NULL && strcmp(p, "on") == 0) @@ -74,15 +85,19 @@ int main(int argc, char **argv) return 1; } - if (argv[1] && strcmp(argv[1], "freeit") == 0) + signal(SIGABRT, handler); + + if (argv[1] && strcmp(argv[1], "freeit") == 0) { OPENSSL_free(lost); + lost = NULL; + } - CRYPTO_mem_leaks_fp(stderr); - return 0; + if (sigsetjmp(env, 0) == 0) + CRYPTO_mem_leaks_fp(stderr); + else + aborted = 1; + return ((lost != NULL) ^ (aborted == 1)); #else - if (argv[1] && strcmp(argv[1], "freeit") == 0) - return 0; - fprintf(stderr, "Leak simulated\n"); - return 1; + return 0; #endif } diff --git a/test/p5_crpt2_test.c b/test/p5_crpt2_test.c index 657d10e768..303906fa9c 100644 --- a/test/p5_crpt2_test.c +++ b/test/p5_crpt2_test.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -# ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); # endif return 0; diff --git a/test/recipes/90-test_memleak.t b/test/recipes/90-test_memleak.t index 7aff0c011b..bc72f2e6dc 100644 --- a/test/recipes/90-test_memleak.t +++ b/test/recipes/90-test_memleak.t @@ -3,5 +3,6 @@ use OpenSSL::Test; setup("test_memleak"); -plan tests => 1; -ok(!run(test(["memleaktest"])), "running memleaktest"); +plan tests => 2; +ok(run(test(["memleaktest"])), "running leak test"); +ok(run(test(["memleaktest", "freeit"])), "running no leak test"); diff --git a/test/rsa_test.c b/test/rsa_test.c index 3cfd32edb4..0b707bf715 100644 --- a/test/rsa_test.c +++ b/test/rsa_test.c @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif diff --git a/test/srptest.c b/test/srptest.c index 03e8cf438a..f6555a60e1 100644 --- a/test/srptest.c +++ b/test/srptest.c @@ -146,7 +146,7 @@ int main(int argc, char **argv) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(bio_err); #endif BIO_free(bio_err); diff --git a/test/ssltest.c b/test/ssltest.c index c3d655e36f..d6b6618cbd 100644 --- a/test/ssltest.c +++ b/test/ssltest.c @@ -1821,7 +1821,7 @@ int main(int argc, char *argv[]) ERR_free_strings(); ERR_remove_thread_state(NULL); EVP_cleanup(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks(bio_err); #endif BIO_free(bio_err); diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c index 005fae63c0..843252051d 100644 --- a/test/verify_extra_test.c +++ b/test/verify_extra_test.c @@ -207,7 +207,7 @@ int main(int argc, char **argv) CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); ERR_free_strings(); -#ifdef CRYPTO_MDEBUG +#ifndef OPENSSL_NO_CRYPTO_MDEBUG CRYPTO_mem_leaks_fp(stderr); #endif |