summaryrefslogtreecommitdiff
path: root/test/ruby/test_notimp.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-13 03:16:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-13 03:16:50 +0000
commit060b4df0acb9ef7258ce7b0e9f23d4d3c8111a83 (patch)
tree791861ce53f6622bcbf684449bb84bee3ac8de13 /test/ruby/test_notimp.rb
parent0574cc87259cc9fa7f75771668ed8faeaf645296 (diff)
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
Diffstat (limited to 'test/ruby/test_notimp.rb')
-rw-r--r--test/ruby/test_notimp.rb26
1 files 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)