mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
0574cc8725
commit
060b4df0ac
1 changed files with 15 additions and 13 deletions
|
@ -23,26 +23,28 @@ class TestNotImplement < Test::Unit::TestCase
|
||||||
def test_call_fork
|
def test_call_fork
|
||||||
GC.start
|
GC.start
|
||||||
pid = nil
|
pid = nil
|
||||||
begin
|
ps =
|
||||||
|
case RUBY_PLATFORM
|
||||||
|
when /linux/ # assume Linux Distribution uses procps
|
||||||
|
proc {`ps -eLf #{pid}`}
|
||||||
|
when /freebsd/
|
||||||
|
proc {`ps -lH #{pid}`}
|
||||||
|
when /darwin/
|
||||||
|
proc {`ps -lM #{pid}`}
|
||||||
|
else
|
||||||
|
proc {`ps -l #{pid}`}
|
||||||
|
end
|
||||||
|
assert_nothing_raised(Timeout::Error, ps) do
|
||||||
Timeout.timeout(5) {
|
Timeout.timeout(5) {
|
||||||
pid = fork {}
|
pid = fork {}
|
||||||
Process.wait pid
|
Process.wait pid
|
||||||
pid = nil
|
pid = nil
|
||||||
}
|
}
|
||||||
rescue Timeout::Error
|
end
|
||||||
case RUBY_PLATFORM
|
ensure
|
||||||
when /linux/ # assume Linux Distribution uses procps
|
if pid
|
||||||
ps = `ps -eLf #{pid}`
|
|
||||||
when /freebsd/
|
|
||||||
ps = `ps -lH #{pid}`
|
|
||||||
when /darwin/
|
|
||||||
ps = `ps -lM #{pid}`
|
|
||||||
else
|
|
||||||
ps = `ps -l #{pid}`
|
|
||||||
end
|
|
||||||
Process.kill(:KILL, pid)
|
Process.kill(:KILL, pid)
|
||||||
Process.wait pid
|
Process.wait pid
|
||||||
assert_equal nil, pid, ps
|
|
||||||
end
|
end
|
||||||
end if Process.respond_to?(:fork)
|
end if Process.respond_to?(:fork)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue