sleepy_penguin.git  about / heads / tags
Linux I/O events for Ruby
blob c9ff1436b89bd0fc4a3addd1fd6f79ba5822b162 591 bytes (raw)
$ git show HEAD:test/test_pipesize.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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

git clone https://yhbt.net/sleepy_penguin.git