2022-07-28 13:10:24 +03:00
|
|
|
/freebsd/ =~ RUBY_PLATFORM or
|
2007-11-28 01:53:28 +03:00
|
|
|
assert_finish 5, %q{
|
2007-11-26 04:20:48 +03:00
|
|
|
r, w = IO.pipe
|
|
|
|
t1 = Thread.new { r.sysread(1) }
|
|
|
|
t2 = Thread.new { r.sysread(1) }
|
2014-06-07 23:57:46 +04:00
|
|
|
sleep 0.01 until t1.stop? and t2.stop?
|
2007-11-26 04:20:48 +03:00
|
|
|
w.write "a"
|
|
|
|
w.write "a"
|
|
|
|
}, '[ruby-dev:31866]'
|
2007-12-21 12:43:49 +03:00
|
|
|
|
|
|
|
assert_finish 10, %q{
|
2007-12-22 00:35:08 +03:00
|
|
|
begin
|
|
|
|
require "io/nonblock"
|
2009-07-21 20:36:41 +04:00
|
|
|
require "timeout"
|
|
|
|
timeout(3) do
|
|
|
|
r, w = IO.pipe
|
2009-11-25 07:09:59 +03:00
|
|
|
w.nonblock?
|
2009-07-21 20:36:41 +04:00
|
|
|
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
|
|
|
|
end
|
2014-10-08 00:00:09 +04:00
|
|
|
rescue LoadError, Timeout::Error, NotImplementedError
|
2007-12-22 00:35:08 +03:00
|
|
|
end
|
2007-12-21 12:43:49 +03:00
|
|
|
}, '[ruby-dev:32566]'
|
2007-12-25 12:52:52 +03:00
|
|
|
|
2022-09-06 10:24:55 +03:00
|
|
|
/freebsd/ =~ RUBY_PLATFORM or
|
2022-02-14 08:50:01 +03:00
|
|
|
assert_finish 5, %q{
|
2007-12-25 12:52:52 +03:00
|
|
|
r, w = IO.pipe
|
2018-09-04 08:28:38 +03:00
|
|
|
Thread.new {
|
2014-06-07 23:57:46 +04:00
|
|
|
w << "ab"
|
2018-09-04 08:28:38 +03:00
|
|
|
sleep 0.01
|
2014-06-07 23:57:46 +04:00
|
|
|
w << "ab"
|
2007-12-25 12:52:52 +03:00
|
|
|
}
|
2007-12-26 09:28:42 +03:00
|
|
|
r.gets("abab")
|
2007-12-25 12:52:52 +03:00
|
|
|
}
|
2008-02-07 10:40:25 +03:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
2014-04-24 17:54:07 +04:00
|
|
|
require 'tmpdir'
|
2008-02-07 10:40:25 +03:00
|
|
|
begin
|
2014-04-24 17:54:07 +04:00
|
|
|
tmpname = "#{Dir.tmpdir}/ruby-btest-#{$$}-#{rand(0x100000000).to_s(36)}"
|
2008-02-07 10:40:25 +03:00
|
|
|
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
|
2017-10-23 08:56:25 +03:00
|
|
|
File.unlink(tmpname)
|
2008-02-07 10:40:25 +03:00
|
|
|
:ok
|
|
|
|
}
|
2008-02-14 15:01:50 +03:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
2014-04-24 17:54:07 +04:00
|
|
|
require 'tmpdir'
|
2008-02-14 15:01:50 +03:00
|
|
|
begin
|
2014-04-24 17:54:07 +04:00
|
|
|
tmpname = "#{Dir.tmpdir}/ruby-btest-#{$$}-#{rand(0x100000000).to_s(36)}"
|
2008-02-14 15:01:50 +03:00
|
|
|
rw = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL)
|
|
|
|
rescue Errno::EEXIST
|
|
|
|
retry
|
|
|
|
end
|
|
|
|
save = STDIN.dup
|
|
|
|
STDIN.reopen(rw)
|
|
|
|
STDIN.print "a"
|
|
|
|
STDIN.reopen(save)
|
|
|
|
rw.close
|
2017-10-23 08:56:25 +03:00
|
|
|
File.unlink(tmpname)
|
2008-02-14 15:01:50 +03:00
|
|
|
:ok
|
|
|
|
}
|
2008-02-21 08:47:12 +03:00
|
|
|
|
2013-01-06 13:48:00 +04:00
|
|
|
assert_equal 'ok', %q{
|
|
|
|
dup = STDIN.dup
|
|
|
|
dupfd = dup.fileno
|
|
|
|
dupfd == STDIN.dup.fileno ? :ng : :ok
|
|
|
|
}, '[ruby-dev:46834]'
|
|
|
|
|
2008-02-21 08:47:12 +03:00
|
|
|
assert_normal_exit %q{
|
|
|
|
ARGF.set_encoding "foo"
|
|
|
|
}
|
2008-07-11 15:51:39 +04:00
|
|
|
|
2022-06-21 03:36:37 +03:00
|
|
|
/freebsd/ =~ RUBY_PLATFORM or
|
2010-05-05 06:43:15 +04:00
|
|
|
10.times do
|
2008-07-11 15:51:39 +04:00
|
|
|
assert_normal_exit %q{
|
|
|
|
at_exit { p :foo }
|
|
|
|
|
|
|
|
megacontent = "abc" * 12345678
|
2024-07-09 07:01:44 +03:00
|
|
|
#File.write("megasrc", megacontent)
|
2008-07-11 15:51:39 +04:00
|
|
|
|
2014-06-07 23:57:46 +04:00
|
|
|
t0 = Thread.main
|
|
|
|
Thread.new { sleep 0.001 until t0.stop?; Process.kill(:INT, $$) }
|
2008-07-11 15:51:39 +04:00
|
|
|
|
|
|
|
r1, w1 = IO.pipe
|
|
|
|
r2, w2 = IO.pipe
|
|
|
|
t1 = Thread.new { w1 << megacontent; w1.close }
|
2010-05-05 06:43:15 +04:00
|
|
|
t2 = Thread.new { r2.read; r2.close }
|
2008-07-11 15:51:39 +04:00
|
|
|
IO.copy_stream(r1, w2) rescue nil
|
2010-05-05 06:43:15 +04:00
|
|
|
w2.close
|
|
|
|
r1.close
|
|
|
|
t1.join
|
|
|
|
t2.join
|
|
|
|
}, 'megacontent-copy_stream', ["INT"], :timeout => 10 or break
|
2008-07-11 15:51:39 +04:00
|
|
|
end
|
2009-04-26 13:44:35 +04:00
|
|
|
|
|
|
|
assert_normal_exit %q{
|
|
|
|
r, w = IO.pipe
|
|
|
|
STDOUT.reopen(w)
|
|
|
|
STDOUT.reopen(__FILE__, "r")
|
|
|
|
}, '[ruby-dev:38131]'
|