3 Thread.abort_on_exception = true
4 require 'sleepy_penguin'
6 class TestKqueueIO < Test::Unit::TestCase
14 @to_close.each do |io|
15 io.close unless io.closed?
22 assert_raises(TypeError) { kq.kevent("HI") }
29 pipes = [ IO.pipe, IO.pipe, IO.pipe, IO.pipe ]
33 list << Kevent[r.fileno, EvFilt::READ, Ev::ADD|Ev::ONESHOT, 0, 0, r]
42 kq.kevent(nil, 1) do |*args|
44 assert_equal 6, args.size
45 assert_kind_of IO, args[5]
46 assert_nil seen[args[5]]
50 assert_equal 1, received.size
52 kq.kevent(nil, 666) do |*args|
54 assert_equal 6, args.size
55 assert_kind_of IO, args[5]
56 assert_nil seen[args[5]]
59 assert_equal 4, received.size
66 ev = Kevent[rd.fileno, EvFilt::READ, Ev::ADD|Ev::ONESHOT, 0, 0, rd]
73 n = kq.kevent(nil, 1) do |ident,filter,flags,fflags,data,udata|
74 events << [ ident,filter,flags,fflags,data,udata ]
76 assert_equal 1, events.size
77 assert_equal rd.fileno, events[0][0]
78 assert_equal EvFilt::READ, events[0][1]
83 # we should be drained
85 n = kq.kevent(nil, 1, 0) do |ident,filter,flags,fflags,data,udata|
86 events << [ ident,filter,flags,fflags,data,udata ]
88 assert_equal 0, events.size
93 ev = Kevent[wr.fileno, EvFilt::WRITE, Ev::ADD|Ev::ONESHOT, 0, 0, wr]
95 n = kq.kevent(nil, 1, 0) do |ident,filter,flags,fflags,data,udata|
96 events << [ ident,filter,flags,fflags,data,udata ]
98 assert_equal 1, events.size
99 assert_equal wr.fileno, events[0][0]
100 assert_equal EvFilt::WRITE, events[0][1]
107 end if defined?(SleepyPenguin::Kqueue::IO)