diff options
Diffstat (limited to 'test/utils.rb')
-rw-r--r-- | test/utils.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/utils.rb b/test/utils.rb index 70bb5941..54f75f25 100644 --- a/test/utils.rb +++ b/test/utils.rb @@ -9,6 +9,26 @@ begin rescue LoadError end +# Compile OpenSSL with crypto-mdebug and run this test suite with OSSL_MDEBUG=1 +# environment variable to enable memory leak check. +if ENV["OSSL_MDEBUG"] == "1" + if OpenSSL.respond_to?(:print_mem_leaks) + OpenSSL.mem_check_start + + END { + GC.start + case OpenSSL.print_mem_leaks + when nil + warn "mdebug: check what is printed" + when true + raise "mdebug: memory leaks detected" + end + } + else + warn "OSSL_MDEBUG=1 is specified but OpenSSL is not built with crypto-mdebug" + end +end + require "test/unit" require 'tempfile' require "rbconfig" |