about summary refs log tree commit homepage
path: root/test/test_pipesize.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_pipesize.rb')
-rw-r--r--test/test_pipesize.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_pipesize.rb b/test/test_pipesize.rb
new file mode 100644
index 0000000..c9ff143
--- /dev/null
+++ b/test/test_pipesize.rb
@@ -0,0 +1,22 @@
+# -*- encoding: binary -*-
+require_relative 'helper'
+require 'fcntl'
+
+class TestPipesize < Test::Unit::TestCase
+  def test_pipe_size
+    return unless RUBY_PLATFORM =~ /linux/
+    [ :F_GETPIPE_SZ, :F_SETPIPE_SZ ].each do |c|
+      return unless SleepyPenguin.const_defined?(c)
+    end
+    r, w = pipe = IO.pipe
+    nr = r.fcntl(SleepyPenguin::F_GETPIPE_SZ)
+    assert_kind_of Integer, nr
+    assert_operator nr, :>, 0
+
+    set = 131072
+    r.fcntl(SleepyPenguin::F_SETPIPE_SZ, set)
+    assert_equal set, r.fcntl(SleepyPenguin::F_GETPIPE_SZ)
+  ensure
+    pipe.each(&:close) if pipe
+  end
+end