diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-05-04 19:26:38 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-05-04 19:26:38 -0700 |
commit | 537e4c341137a45330e28376e8f29da7df44808f (patch) | |
tree | f0219be01788f3c1b11c2f3221e9e2a64ec8a7b7 /test | |
parent | f2a3998e0c0f63ad14acf5ccc0141fc6cdce24e3 (diff) | |
download | kgio-537e4c341137a45330e28376e8f29da7df44808f.tar.gz |
This changes our semantics, but it's unlikely anybody relies on EINTR right now...
Diffstat (limited to 'test')
-rw-r--r-- | test/test_poll.rb | 29 |
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) |