aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-17 17:19:53 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-17 17:19:53 +0000
commit713e99cec284a7bfdfdc6b598102028e0f844b8f (patch)
tree1bcbba158d1a1c9568f077271e3473d4826e69a8 /test
parentf3d952335d45772d4c5f3eb86da27c0981321527 (diff)
downloadruby-713e99cec284a7bfdfdc6b598102028e0f844b8f.tar.gz
* io.c (io_fread, io_getpartial, io_read, io_sysread): by using lock,
prohibit modification of buffer string during read (which had caused EFAULT or SEGV). [ruby-dev:40437] * test/ruby/test_io.rb: rewrite tests for the old behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 6d7f94eaab..5fc3b133dd 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -823,15 +823,15 @@ class TestIO < Test::Unit::TestCase
end)
end
- def test_readpartial_error
+ def test_readpartial_lock
with_pipe do |r, w|
s = ""
t = Thread.new { r.readpartial(5, s) }
0 until s.size == 5
- s.clear
+ assert_raise(RuntimeError) { s.clear }
w.write "foobarbaz"
w.close
- assert_raise(RuntimeError) { t.join }
+ assert_equal("fooba", t.value)
end
end
@@ -858,15 +858,15 @@ class TestIO < Test::Unit::TestCase
end)
end
- def test_read_error
+ def test_read_lock
with_pipe do |r, w|
s = ""
t = Thread.new { r.read(5, s) }
0 until s.size == 5
- s.clear
+ assert_raise(RuntimeError) { s.clear }
w.write "foobarbaz"
w.close
- assert_raise(RuntimeError) { t.join }
+ assert_equal("fooba", t.value)
end
end