aboutsummaryrefslogtreecommitdiffstats
path: root/test/openssl/test_pair.rb
diff options
context:
space:
mode:
authorrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-05 09:47:59 +0000
committerrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-05 09:47:59 +0000
commit360007a69339cf254af605896e47e90be6902b0e (patch)
tree5accd137e04d652ac826105672d6bbed97e95db6 /test/openssl/test_pair.rb
parentad56a458e2652d5fb88c0b36b13d663e2c2e672d (diff)
downloadruby-360007a69339cf254af605896e47e90be6902b0e.tar.gz
openssl: merge test fixes from upstream
Fix platform-dependent or fragile test cases added by r59734. This is a combined patch of the three commits below: 4fc17977350a test/test_fips: skip if setting FIPS mode fails b25179fbeebf test/test_asn1: fix possible failure in test_utctime 8ed81ff4b0a8 test/test_pair: fix test_write_nonblock{,_no_exceptions} git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/test_pair.rb')
-rw-r--r--test/openssl/test_pair.rb58
1 files changed, 28 insertions, 30 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
index 89cf41a86b..f22183446f 100644
--- a/test/openssl/test_pair.rb
+++ b/test/openssl/test_pair.rb
@@ -238,44 +238,42 @@ module OpenSSL::TestPairM
}
end
- def write_nonblock(socket, meth, str)
- ret = socket.send(meth, str)
- ret.is_a?(Symbol) ? 0 : ret
- end
-
- def write_nonblock_no_ex(socket, str)
- ret = socket.write_nonblock str, exception: false
- ret.is_a?(Symbol) ? 0 : ret
- end
-
def test_write_nonblock
ssl_pair {|s1, s2|
- n = 0
- begin
- n += write_nonblock s1, :write_nonblock, "a" * 100000
- n += write_nonblock s1, :write_nonblock, "b" * 100000
- n += write_nonblock s1, :write_nonblock, "c" * 100000
- n += write_nonblock s1, :write_nonblock, "d" * 100000
- n += write_nonblock s1, :write_nonblock, "e" * 100000
- n += write_nonblock s1, :write_nonblock, "f" * 100000
- rescue IO::WaitWritable
+ assert_equal 3, s1.write_nonblock("foo")
+ assert_equal "foo", s2.read(3)
+
+ data = "x" * 16384
+ written = 0
+ while true
+ begin
+ written += s1.write_nonblock(data)
+ rescue IO::WaitWritable, IO::WaitReadable
+ break
+ end
end
- s1.close
- assert_equal(n, s2.read.length)
+ assert written > 0
+ assert_equal written, s2.read(written).bytesize
}
end
def test_write_nonblock_no_exceptions
ssl_pair {|s1, s2|
- n = 0
- n += write_nonblock_no_ex s1, "a" * 100000
- n += write_nonblock_no_ex s1, "b" * 100000
- n += write_nonblock_no_ex s1, "c" * 100000
- n += write_nonblock_no_ex s1, "d" * 100000
- n += write_nonblock_no_ex s1, "e" * 100000
- n += write_nonblock_no_ex s1, "f" * 100000
- s1.close
- assert_equal(n, s2.read.length)
+ assert_equal 3, s1.write_nonblock("foo", exception: false)
+ assert_equal "foo", s2.read(3)
+
+ data = "x" * 16384
+ written = 0
+ while true
+ case ret = s1.write_nonblock(data, exception: false)
+ when :wait_readable, :wait_writable
+ break
+ else
+ written += ret
+ end
+ end
+ assert written > 0
+ assert_equal written, s2.read(written).bytesize
}
end