aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-11-27 13:08:22 +0900
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-12-29 12:08:45 +1300
commit2cbec4d17e2cf374bcb554e2714e115d4344308d (patch)
treeeed59fc6b5ec4e275c91cc5b7951a377b7d7a662
parent0cddb0b736c8be8de71e231a82c08efc13f580ed (diff)
downloadruby-openssl-2cbec4d17e2cf374bcb554e2714e115d4344308d.tar.gz
Merge in changes to tests from ruby/test/openssl.
-rw-r--r--test/test_asn1.rb5
-rw-r--r--test/test_bn.rb5
-rw-r--r--test/test_ssl.rb16
-rw-r--r--test/test_x509name.rb18
-rw-r--r--test/utils.rb5
5 files changed, 36 insertions, 13 deletions
diff --git a/test/test_asn1.rb b/test/test_asn1.rb
index f9c7b7c8..8d8839dd 100644
--- a/test/test_asn1.rb
+++ b/test/test_asn1.rb
@@ -661,6 +661,11 @@ class OpenSSL::TestASN1 < OpenSSL::TestCase
assert_equal data, seq.entries
end
+ # Very time consuming test.
+ # def test_gc_stress
+ # assert_ruby_status(['--disable-gems', '-eGC.stress=true', '-erequire "openssl.so"'])
+ # end
+
private
def B(ary)
diff --git a/test/test_bn.rb b/test/test_bn.rb
index ee5b53ea..4f07841f 100644
--- a/test/test_bn.rb
+++ b/test/test_bn.rb
@@ -276,6 +276,11 @@ class OpenSSL::TestBN < OpenSSL::TestCase
assert_equal(0, @e1.ucmp(-999))
assert_instance_of(String, @e1.hash.to_s)
end
+
+ def test_argument_error
+ bug15760 = '[ruby-core:92231] [Bug #15760]'
+ assert_raise(ArgumentError, bug15760) { OpenSSL::BN.new(nil, 2) }
+ end
end
end
diff --git a/test/test_ssl.rb b/test/test_ssl.rb
index 96844ee7..fe4b6827 100644
--- a/test/test_ssl.rb
+++ b/test/test_ssl.rb
@@ -206,8 +206,20 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
}
end
+ def test_sysread_nonblock_and_syswrite_nonblock_keywords
+ start_server do |port|
+ server_connect(port) do |ssl|
+ assert_warning("") do
+ ssl.send(:syswrite_nonblock, "12", exception: false)
+ ssl.send(:sysread_nonblock, 1, exception: false) rescue nil
+ ssl.send(:sysread_nonblock, 1, String.new, exception: false) rescue nil
+ end
+ end
+ end
+ end
+
def test_sync_close
- start_server { |port|
+ start_server do |port|
begin
sock = TCPSocket.new("127.0.0.1", port)
ssl = OpenSSL::SSL::SSLSocket.new(sock)
@@ -230,7 +242,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
ensure
sock&.close
end
- }
+ end
end
def test_copy_stream
diff --git a/test/test_x509name.rb b/test/test_x509name.rb
index 2bbe29ce..6b97b236 100644
--- a/test/test_x509name.rb
+++ b/test/test_x509name.rb
@@ -403,8 +403,8 @@ class OpenSSL::TestX509Name < OpenSSL::TestCase
assert_equal n1, n2
- assert_equal false, n1 == 'abc'
- assert_equal false, n2 == nil
+ assert_equal(false, n1 == 'abc')
+ assert_equal(false, n2 == nil)
end
def test_spaceship
@@ -412,15 +412,15 @@ class OpenSSL::TestX509Name < OpenSSL::TestCase
n2 = OpenSSL::X509::Name.new([["CN", "a"]])
n3 = OpenSSL::X509::Name.new([["CN", "ab"]])
- assert_equal 0, n1 <=> n2
+ assert_equal(0, n1 <=> n2)
assert_equal(-1, n1 <=> n3)
- assert_equal 0, n2 <=> n1
+ assert_equal(0, n2 <=> n1)
assert_equal(-1, n2 <=> n3)
- assert_equal 1, n3 <=> n1
- assert_equal 1, n3 <=> n2
- assert_equal nil, n1 <=> 'abc'
- assert_equal nil, n2 <=> 123
- assert_equal nil, n3 <=> nil
+ assert_equal(1, n3 <=> n1)
+ assert_equal(1, n3 <=> n2)
+ assert_equal(nil, n1 <=> 'abc')
+ assert_equal(nil, n2 <=> 123)
+ assert_equal(nil, n3 <=> nil)
end
def name_hash(name)
diff --git a/test/utils.rb b/test/utils.rb
index 36aeda05..b5820b03 100644
--- a/test/utils.rb
+++ b/test/utils.rb
@@ -286,8 +286,9 @@ class OpenSSL::SSLTestCase < OpenSSL::TestCase
pend = nil
threads.each { |th|
begin
- th.join(10) or
- th.raise(RuntimeError, "[start_server] thread did not exit in 10 secs")
+ timeout = EnvUtil.apply_timeout_scale(30)
+ th.join(timeout) or
+ th.raise(RuntimeError, "[start_server] thread did not exit in #{timeout} secs")
rescue (defined?(MiniTest::Skip) ? MiniTest::Skip : Test::Unit::PendedError)
# MiniTest::Skip is for the Ruby tree
pend = $!