summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-21 04:02:41 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-21 04:02:41 +0000
commit7e9c19ad3d6f6f040b04ef616a4b8a40b5a00b50 (patch)
treed7b63fb31605390b3b04dc4cb31d0fd05ca98c10
parent645f7fbd4ec0199c6266df19ad82d99bdd8553a8 (diff)
test/ruby/test_io.rb: add closing recycled FD test
Followup-to: r63216 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_io.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 43c3ed7566..ad775dffa8 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -3760,4 +3760,36 @@ __END__
con.close
end
end if Socket.const_defined?(:MSG_OOB)
+
+ def test_recycled_fd_close
+ dot = -'.'
+ IO.pipe do |sig_rd, sig_wr|
+ noex = Thread.new do # everything right and never see exceptions :)
+ until sig_rd.wait_readable(0)
+ IO.pipe do |r, w|
+ th = Thread.new { r.read(1) }
+ w.write(dot)
+ assert_equal(dot, th.value)
+ end
+ end
+ sig_rd.read(4)
+ end
+ 1000.times do # stupid things and make exceptions:
+ IO.pipe do |r,w|
+ th = Thread.new do
+ begin
+ r.read(1)
+ rescue IOError => e
+ e
+ end
+ end
+ Thread.pass until th.stop?
+ r.close
+ assert_match(/stream closed/, th.value.message)
+ end
+ end
+ sig_wr.write 'done'
+ assert_equal 'done', noex.value ,'r63216'
+ end
+ end
end