about summary refs log tree commit homepage
path: root/test/test_poll.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_poll.rb')
-rw-r--r--test/test_poll.rb29
1 files changed, 17 insertions, 12 deletions
diff --git a/test/test_poll.rb b/test/test_poll.rb
index 8cade91..1c92223 100644
--- a/test/test_poll.rb
+++ b/test/test_poll.rb
@@ -42,27 +42,32 @@ class TestPoll < Test::Unit::TestCase
     assert_nil res
   end
 
-  def test_poll_interrupt
+  def test_poll_close
     foo = nil
-    oldquit = trap(:QUIT) { foo = :bar }
-    thr = Thread.new { sleep 0.100; Process.kill(:QUIT, $$) }
+    thr = Thread.new { sleep 0.100; @wr.close }
     t0 = Time.now
-    assert_raises(Errno::EINTR) { Kgio.poll({}) }
+    res = Kgio.poll({@rd => Kgio::POLLIN})
     diff = Time.now - t0
     thr.join
+    assert_equal([ @rd ], res.keys)
     assert diff >= 0.010, "diff=#{diff}"
-    ensure
-      trap(:QUIT, "DEFAULT")
   end
 
-  def test_poll_close
-    foo = nil
-    thr = Thread.new { sleep 0.100; @wr.close }
+  def test_poll_EINTR
+    ok = false
+    orig = trap(:USR1) { ok = true }
+    thr = Thread.new do
+      sleep 0.100
+      Process.kill(:USR1, $$)
+    end
     t0 = Time.now
-    res = Kgio.poll({@rd => Kgio::POLLIN})
+    res = Kgio.poll({@rd => Kgio::POLLIN}, 1000)
     diff = Time.now - t0
     thr.join
-    assert_equal([ @rd ], res.keys)
-    assert diff >= 0.010, "diff=#{diff}"
+    assert_nil res
+    assert diff >= 1.0, "diff=#{diff}"
+    assert ok
+    ensure
+      trap(:USR1, orig)
   end
 end if Kgio.respond_to?(:poll)