5 class TestPoll < Test::Unit::TestCase
7 [ @rd, @wr ].each { |io| io.close unless io.closed? }
15 assert_kind_of Integer, Kgio::POLLIN
16 assert_kind_of Integer, Kgio::POLLOUT
17 assert_kind_of Integer, Kgio::POLLPRI
18 assert_kind_of Integer, Kgio::POLLHUP
19 assert_kind_of Integer, Kgio::POLLERR
20 assert_kind_of Integer, Kgio::POLLNVAL
24 set = { @rd => :wait_readable, @wr => :wait_writable }
26 assert_equal({@wr => Kgio::POLLOUT}, res)
27 assert_equal set.object_id, res.object_id
31 set = { @wr => Kgio::POLLOUT|Kgio::POLLHUP }
33 assert_equal({@wr => Kgio::POLLOUT}, res)
34 assert_equal set.object_id, res.object_id
39 res = Kgio.poll({}, 10)
41 assert diff >= 0.010, "diff=#{diff}"
45 def test_poll_interrupt
47 oldquit = trap(:QUIT) { foo = :bar }
48 thr = Thread.new { sleep 0.100; Process.kill(:QUIT, $$) }
50 assert_raises(Errno::EINTR) { Kgio.poll({}) }
53 assert diff >= 0.010, "diff=#{diff}"
55 trap(:QUIT, "DEFAULT")
60 thr = Thread.new { sleep 0.100; @wr.close }
62 res = Kgio.poll({@rd => Kgio::POLLIN})
65 assert_equal([ @rd ], res.keys)
66 assert diff >= 0.010, "diff=#{diff}"
68 end if Kgio.respond_to?(:poll)