Sha256: 54f70a319e1fbfb0e6d02824228c64fe8bcf504439d3f3a5a68815717cb7b1e0
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
require 'test/unit' require 'fcntl' $-w = true require 'sleepy_penguin' class TestEventFD < Test::Unit::TestCase include SleepyPenguin def test_constants defined?(EventFD::NONBLOCK) and assert_kind_of Integer, EventFD::NONBLOCK defined?(EventFD::CLOEXEC) and assert_kind_of Integer, EventFD::CLOEXEC defined?(EventFD::SEMAPHORE) and assert_kind_of Integer, EventFD::SEMAPHORE end def test_new efd = EventFD.new 0 assert_kind_of(IO, efd) end def test_new_nonblock efd = EventFD.new(0, EventFD::NONBLOCK) flags = efd.fcntl(Fcntl::F_GETFL) & Fcntl::O_NONBLOCK assert_equal(Fcntl::O_NONBLOCK, flags) end if defined?(EventFD::NONBLOCK) def test_new_cloexec efd = EventFD.new(0, EventFD::CLOEXEC) flags = efd.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC assert_equal(Fcntl::FD_CLOEXEC, flags) end if defined?(EventFD::CLOEXEC) def test_incr_value efd = EventFD.new(0) assert_nil efd.incr(1) assert_equal 1, efd.value assert_raises(Errno::EAGAIN) { efd.value_nonblock } assert_nil efd.incr(9) assert_equal 9, efd.value_nonblock assert_nil efd.incr(0xfffffffffffffffe) assert_raises(Errno::EAGAIN) { efd.incr_nonblock 1 } end end if defined?(SleepyPenguin::EventFD)
Version data entries
6 entries across 6 versions & 1 rubygems