From 060b4df0acb9ef7258ce7b0e9f23d4d3c8111a83 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 13 Oct 2013 03:16:50 +0000 Subject: test_notimp.rb: test timeout * test/ruby/test_notimp.rb (test_call_fork): test timeout directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_notimp.rb | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb index 10affd6c81..9721723b29 100644 --- a/test/ruby/test_notimp.rb +++ b/test/ruby/test_notimp.rb @@ -23,26 +23,28 @@ class TestNotImplement < Test::Unit::TestCase def test_call_fork GC.start pid = nil - begin - Timeout.timeout(5) { - pid = fork {} - Process.wait pid - pid = nil - } - rescue Timeout::Error + ps = case RUBY_PLATFORM when /linux/ # assume Linux Distribution uses procps - ps = `ps -eLf #{pid}` + proc {`ps -eLf #{pid}`} when /freebsd/ - ps = `ps -lH #{pid}` + proc {`ps -lH #{pid}`} when /darwin/ - ps = `ps -lM #{pid}` + proc {`ps -lM #{pid}`} else - ps = `ps -l #{pid}` + proc {`ps -l #{pid}`} end + assert_nothing_raised(Timeout::Error, ps) do + Timeout.timeout(5) { + pid = fork {} + Process.wait pid + pid = nil + } + end + ensure + if pid Process.kill(:KILL, pid) Process.wait pid - assert_equal nil, pid, ps end end if Process.respond_to?(:fork) -- cgit v1.2.3