1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/bootstraptest/test_io.rb
akr 82b088aa0c * io.c (io_reopen): don't change access mode for stdin, stdout and
stderr.  [ruby-core:15360]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-07 07:40:25 +00:00

54 lines
1,023 B
Ruby

assert_finish 5, %q{
r, w = IO.pipe
t1 = Thread.new { r.sysread(1) }
t2 = Thread.new { r.sysread(1) }
sleep 0.1
w.write "a"
sleep 0.1
w.write "a"
}, '[ruby-dev:31866]'
assert_finish 10, %q{
begin
require "io/nonblock"
r, w = IO.pipe
w.nonblock = true
w.write_nonblock("a" * 100000)
w.nonblock = false
t1 = Thread.new { w.write("b" * 4096) }
t2 = Thread.new { w.write("c" * 4096) }
sleep 0.5
r.sysread(4096).length
sleep 0.5
r.sysread(4096).length
t1.join
t2.join
rescue LoadError
end
}, '[ruby-dev:32566]'
assert_finish 1, %q{
r, w = IO.pipe
Thread.new {
w << "ab"
sleep 0.1
w << "ab"
}
r.gets("abab")
}
assert_equal 'ok', %q{
require 'tmpdir'
begin
tmpname = "#{Dir.tmpdir}/ruby-btest-#{$$}-#{rand(0x100000000).to_s(36)}"
rw = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL)
rescue Errno::EEXIST
retry
end
save = STDIN.dup
STDIN.reopen(rw)
STDIN.reopen(save)
rw.close
File.unlink(tmpname)
:ok
}