about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-10 02:12:46 +0000
committerEric Wong <normalperson@yhbt.net>2011-03-10 02:12:46 +0000
commit3e75c60006b42b2c4eff8c95f11c4289e8229bb1 (patch)
tree4b97dfadfd4b0f8a227b474192133bb1734390a2
parentfd1509a7854d0da1227964a562a5f344bc0569b5 (diff)
downloadsleepy_penguin-3e75c60006b42b2c4eff8c95f11c4289e8229bb1.tar.gz
-rw-r--r--ext/sleepy_penguin/eventfd.c2
-rw-r--r--test/test_eventfd.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/ext/sleepy_penguin/eventfd.c b/ext/sleepy_penguin/eventfd.c
index fd169f5..06663a8 100644
--- a/ext/sleepy_penguin/eventfd.c
+++ b/ext/sleepy_penguin/eventfd.c
@@ -100,7 +100,7 @@ retry:
  * the counter to zero.
  *
  * If created as a semaphore, this decrements the counter value by one
- * and returns one.
+ * and returns +1+.
  *
  * If the counter is zero at the time of the call, this will block until
  * the counter becomes non-zero.
diff --git a/test/test_eventfd.rb b/test/test_eventfd.rb
index 7739448..f97bd0a 100644
--- a/test/test_eventfd.rb
+++ b/test/test_eventfd.rb
@@ -54,4 +54,12 @@ class TestEventFD < Test::Unit::TestCase
     assert_nil efd.incr(0xfffffffffffffffe)
     assert_raises(Errno::EAGAIN) { efd.incr_nonblock 1 }
   end
+
+  def test_incr_value_semaphore
+    efd = EventFD.new(6, :SEMAPHORE)
+    6.times { assert_equal 1, efd.value }
+    assert_raises(Errno::EAGAIN) { efd.value_nonblock }
+    assert_nothing_raised { efd.incr(1) }
+    assert_equal 1, efd.value
+  end
 end if defined?(SleepyPenguin::EventFD)