1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

bootstraptest/test_{fork,io,thread}.rb: reduce sleep times

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-06-07 19:57:46 +00:00
parent 7d8fc3696e
commit 85521e60ee
3 changed files with 57 additions and 39 deletions

View file

@ -22,26 +22,32 @@ assert_finish 10, %q{
}, '[ruby-core:22158]'
assert_normal_exit(<<'End', '[ruby-dev:37934]')
Thread.new { sleep 1; Thread.kill Thread.main }
main = Thread.current
Thread.new { sleep 0.01 until main.stop?; Thread.kill main }
Process.setrlimit(:NPROC, 1)
fork {}
End
assert_equal 'ok', %q{
begin
r, w = IO.pipe
if pid1 = fork
sleep 1
w.close
r.read(1)
Process.kill("USR1", pid1)
_, s = Process.wait2(pid1)
s.success? ? :ok : :ng
else
r.close
if pid2 = fork
trap("USR1") { Time.now.to_s }
trap("USR1") { Time.now.to_s; Process.kill("USR2", pid2) }
w.close
Process.wait2(pid2)
else
sleep 2
w.close
sleep 0.2
end
exit 0
exit true
end
rescue NotImplementedError
:ok
@ -50,17 +56,16 @@ assert_equal 'ok', %q{
assert_equal '[1, 2]', %q{
a = []
trap(:INT) { a.push(1) }
trap(:TERM) { a.push(2) }
main = Thread.current
trap(:INT) { a.push(1).size == 2 and main.wakeup }
trap(:TERM) { a.push(2).size == 2 and main.wakeup }
pid = $$
begin
fork do
sleep 0.5
pid = fork do
Process.kill(:INT, pid)
Process.kill(:TERM, pid)
end
sleep 1
Process.wait(pid)
a.sort
rescue NotImplementedError
[1, 2]