Sha256: 0e456caf5c9b692f0d75ff90ebafbfb2e2fc4f78e75be76558f35d36e423ea73

Contents?: true

Size: 1019 Bytes

Versions: 6

Compression:

Stored size: 1019 Bytes

Contents

require 'test/unit'
require 'fcntl'
$-w = true

require 'sleepy_penguin'

class TestTimerFD < Test::Unit::TestCase
  include SleepyPenguin

  def test_constants
    assert_kind_of Integer, TimerFD::REALTIME
    assert_kind_of Integer, TimerFD::MONOTONIC
  end

  def test_create
    tfd = TimerFD.create
    assert_kind_of(IO, tfd)
  end

  def test_create_nonblock
    tfd = TimerFD.create(TimerFD::REALTIME, TimerFD::NONBLOCK)
    flags = tfd.fcntl(Fcntl::F_GETFL) & Fcntl::O_NONBLOCK
    assert_equal(Fcntl::O_NONBLOCK, flags)
  end if defined?(TimerFD::NONBLOCK)

  def test_create_cloexec
    tfd = TimerFD.create(TimerFD::REALTIME, TimerFD::CLOEXEC)
    flags = tfd.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC
    assert_equal(Fcntl::FD_CLOEXEC, flags)
  end if defined?(TimerFD::CLOEXEC)

  def test_settime
    tfd = TimerFD.create(TimerFD::REALTIME)
    assert_equal([0, 0], tfd.settime(TimerFD::ABSTIME, 0, 0.01))
    sleep 0.01
    assert_equal 1, tfd.expirations
  end
end if defined?(SleepyPenguin::TimerFD)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sleepy_penguin-1.4.0 test/test_timerfd.rb
sleepy_penguin-1.3.1 test/test_timerfd.rb
sleepy_penguin-1.3.0 test/test_timerfd.rb
sleepy_penguin-1.2.0 test/test_timerfd.rb
sleepy_penguin-1.1.1 test/test_timerfd.rb
sleepy_penguin-1.0.0 test/test_timerfd.rb