diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-07 19:57:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-07 19:57:46 +0000 |
commit | 85521e60eef7eee999cf1c0c0e460cabdeaa6f7f (patch) | |
tree | 45a563ae8fba7d02fcbf26958150b06bacba83f3 /bootstraptest/test_fork.rb | |
parent | 7d8fc3696ef8fa9f600d1943afe2f525debc5564 (diff) |
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
Diffstat (limited to 'bootstraptest/test_fork.rb')
-rw-r--r-- | bootstraptest/test_fork.rb | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/bootstraptest/test_fork.rb b/bootstraptest/test_fork.rb index 384294727f..91281a3640 100644 --- a/bootstraptest/test_fork.rb +++ b/bootstraptest/test_fork.rb @@ -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] |