diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-08-26 17:54:22 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-08-26 17:59:32 +0900 |
commit | 4c1ca766918014b90caf37b08591485bc4261906 (patch) | |
tree | 7905594adc527d7b5a3abe4fdf1b5587d7d3983d /test | |
parent | bc83a57b4acd4b4ae77a284c2c4383e8c9cdb94a (diff) | |
download | ruby-openssl-4c1ca766918014b90caf37b08591485bc4261906.tar.gz |
Remove test/mdebug
It was not implemented in a good way - for example it doesn't compile on
Windows and causes 'rake compile' to fail... So remove for now.
Diffstat (limited to 'test')
-rw-r--r-- | test/mdebug/extconf.rb | 9 | ||||
-rw-r--r-- | test/mdebug/ossl_test.c | 87 | ||||
-rw-r--r-- | test/utils.rb | 22 |
3 files changed, 0 insertions, 118 deletions
diff --git a/test/mdebug/extconf.rb b/test/mdebug/extconf.rb deleted file mode 100644 index 6b2fa522..00000000 --- a/test/mdebug/extconf.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: false -require "mkmf" - -dir_config("openssl") -pkg_config("openssl") or - have_library("crypto", "CRYPTO_malloc") or - have_library("libeay32", "CRYPTO_malloc") - -create_makefile("mdebug") diff --git a/test/mdebug/ossl_test.c b/test/mdebug/ossl_test.c deleted file mode 100644 index 4d0b57ed..00000000 --- a/test/mdebug/ossl_test.c +++ /dev/null @@ -1,87 +0,0 @@ -#include <ruby.h> -#include <openssl/opensslv.h> -#include <openssl/crypto.h> -#include <openssl/bn.h> -#include <openssl/err.h> - -static VALUE mOSSL; - -#if !defined(OPENSSL_NO_MDEBUG) -/* - * call-seq: - * OpenSSL.print_mem_leaks -> nil - * - * For debugging this openssl library. Prints memory leaks recorded by OpenSSL - * to stderr. This is available only when OpenSSL is compiled with - * crypto-mdebug. This methods cleanups the global state of OpenSSL thus you - * mustn't use any methods of the library after calling this. - * - * === Example - * OpenSSL.debug = true - * NOT_GCED = OpenSSL::PKey::RSA.new(256) - * - * END { - * GC.start - * OpenSSL.print_mem_leaks # will print the leakage - * } - */ -static VALUE -print_mem_leaks(VALUE self) -{ - extern BN_CTX *ossl_bn_ctx; - - BN_CTX_free(ossl_bn_ctx); - ossl_bn_ctx = NULL; - - CRYPTO_mem_leaks_fp(stderr); - - ossl_bn_ctx = BN_CTX_new(); - if (!ossl_bn_ctx) - rb_raise(rb_eRuntimeError, "BN_CTX_new"); - - return Qnil; -} -#endif - -void -Init_mdebug(void) -{ - mOSSL = rb_path2class("OpenSSL"); - -#if !defined(OPENSSL_NO_MDEBUG) - rb_define_module_function(mOSSL, "print_mem_leaks", print_mem_leaks, 0); - - /* - * Prepare for OpenSSL.print_mem_leaks. Below are all dirty hack and may - * not work depending the version of OpenSSL. - */ - { - int i; - /* - * See crypto/ex_data.c; call def_get_class() - * 100 is the maximum number that is used as the class index in OpenSSL - * 1.0.2. - */ -#if defined(CRYPTO_EX_INDEX__COUNT) - for (i = 0; i < CRYPTO_EX_INDEX__COUNT; i++) { -#else - for (i = 0; i <= 100; i++) { -#endif - if (CRYPTO_get_ex_new_index(i, 0, (void *)"mdebug-tmp", - 0, 0, 0) < 0) - rb_raise(rb_eRuntimeError, "CRYPTO_get_ex_new_index for " - "class index %d failed", i); - } - -#if defined(V_CRYPTO_MDEBUG_ALL) - /* - * Show full information in OpenSSL.print_mem_leaks - */ - CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); -#endif - } - - /* Then, enable memcheck */ - CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); -#endif -} diff --git a/test/utils.rb b/test/utils.rb index ff44e076..2288a260 100644 --- a/test/utils.rb +++ b/test/utils.rb @@ -9,28 +9,6 @@ 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" - begin - require "mdebug" - rescue LoadError - end - - if OpenSSL.respond_to?(:print_mem_leaks) - END { - # FIXME: maybe extract fixtures to file and load dynamically? - OpenSSL::TestUtils.constants.each do |v| - OpenSSL::TestUtils.send(:remove_const, v) - end - GC.start - OpenSSL.print_mem_leaks - } - else - warn "OpenSSL is not built with crypto-mdebug" - end -end - require "test/unit" require "digest/md5" require 'tempfile' |