aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Rakefile6
-rw-r--r--test/mdebug/extconf.rb9
-rw-r--r--test/mdebug/ossl_test.c87
-rw-r--r--test/utils.rb22
4 files changed, 0 insertions, 124 deletions
diff --git a/Rakefile b/Rakefile
index e0fb9c8e..f3e7e3fa 100644
--- a/Rakefile
+++ b/Rakefile
@@ -12,12 +12,6 @@ Rake::TestTask.new do |t|
t.warning = true
end
-Rake::ExtensionTask.new('test/mdebug') do |ext|
- # hack to emit mdebug.so under ./test/
- ext.ext_dir = 'test/mdebug'
- ext.lib_dir = '.'
-end
-
RDoc::Task.new do |rdoc|
rdoc.main = "README.md"
rdoc.rdoc_files.include("*.md", "lib/**/*.rb", "ext/**/*.c")
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'