diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-07 12:22:02 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-07 12:22:02 +0000 |
commit | 1386a2303f85d6905cf1b45cfe3c4155535a05e2 (patch) | |
tree | 4119bf1de285d1ac09e24bd6ef4a519690cdba88 /test/openssl/test_pair.rb | |
parent | a352b0a20744a19c2fcb2ea5af576805c0706aea (diff) |
refactoring to extract tcp_pair.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/test_pair.rb')
-rw-r--r-- | test/openssl/test_pair.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index 933f61292c..38b6989bac 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -245,19 +245,24 @@ class OpenSSL::TestPair < Test::Unit::TestCase } end - def test_connect_accept_nonblock + def tcp_pair host = "127.0.0.1" - port = 0 - ctx = OpenSSL::SSL::SSLContext.new() - ctx.ciphers = "ADH" - ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } - serv = TCPServer.new(host, port) - + serv = TCPServer.new(host, 0) port = serv.connect_address.ip_port - sock1 = TCPSocket.new(host, port) sock2 = serv.accept serv.close + [sock1, sock2] + ensure + serv.close if serv && !serv.closed? + end + + def test_connect_accept_nonblock + ctx = OpenSSL::SSL::SSLContext.new() + ctx.ciphers = "ADH" + ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::TEST_KEY_DH1024 } + + sock1, sock2 = tcp_pair th = Thread.new { s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx) @@ -298,7 +303,6 @@ class OpenSSL::TestPair < Test::Unit::TestCase ensure s1.close if s1 && !s1.closed? s2.close if s2 && !s2.closed? - serv.close if serv && !serv.closed? sock1.close if sock1 && !sock1.closed? sock2.close if sock2 && !sock2.closed? end |