From 44baf906e73c13577186e3135be4356b33b8be43 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 2 Jan 2019 20:37:38 +0000 Subject: use sleepy_penguin 3.5+ for splice and tee support Eliminate loading of the io_splice RubyGem to reduce memory overhead. Extra DSOs are wasteful and io_splice is being phased oiut for sleepy_penguin, which encapsulates more Linux-specific functionality anyways. cf. https://udrepper.livejournal.com/8790.html --- test/test_buffer.rb | 22 +++++++++++++--------- test/test_sink_pipe_size.rb | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/test_buffer.rb b/test/test_buffer.rb index 0fb4fba..b21a69f 100644 --- a/test/test_buffer.rb +++ b/test/test_buffer.rb @@ -49,14 +49,14 @@ class TestBuffer < Testcase buf = new_buffer buf.buffer_size = @@max_size assert_equal @@max_size, buf.buffer_size - end if @@max_size + end if defined?(SleepyPenguin::F_GETPIPE_SZ) def test_buffer_size buf = new_buffer assert_operator buf.buffer_size, :>, 128 buf.buffer_size = @@max_size assert_equal @@max_size, buf.buffer_size - end if @@max_size + end if defined?(SleepyPenguin::F_GETPIPE_SZ) def test_broadcast_1 buf = new_buffer @@ -87,9 +87,9 @@ class TestBuffer < Testcase assert_empty blocked assert_equal "HELLO", a[0].read(5) assert_equal "HELLO", b[0].read(5) - max = '*' * a[0].pipe_size + max = '*' * pipe_size(a[0]) assert_equal max.size, a[1].write(max) - assert_equal a[0].nread, a[0].pipe_size + assert_equal a[0].nread, pipe_size(a[0]) a[1].nonblock = true assert_equal 5, buf.__broadcast_tee(blocked, [a[1], b[1]], 5) assert_equal [a[1]], blocked @@ -108,10 +108,10 @@ class TestBuffer < Testcase assert_equal "HELLO", a[0].read(5) assert_equal "HELLO", b[0].read(5) - return unless b[1].respond_to?(:pipe_size) + return unless defined?(SleepyPenguin::F_GETPIPE_SZ) b[1].nonblock = true - b[1].write('*' * b[1].pipe_size) + b[1].write('*' * pipe_size(b[1])) buf.wr.write "BYE" assert_equal :wait_readable, buf.broadcast([a[1], b[1]]) assert_equal 8, buf.bytes_xfer @@ -157,8 +157,8 @@ class TestBuffer < Testcase a = pipe b = pipe buf = new_buffer - a[1].write('*' * a[1].pipe_size) - b[1].write('*' * b[1].pipe_size) + a[1].write('*' * pipe_size(a[1])) + b[1].write('*' * pipe_size(b[1])) a[1].nonblock = true b[1].nonblock = true @@ -167,7 +167,7 @@ class TestBuffer < Testcase buf.wr.write "HELLO" assert_equal tmp, buf.broadcast(tmp) assert_equal [a[1], b[1]], tmp - end if IO.method_defined?(:pipe_size) + end if defined?(SleepyPenguin::F_GETPIPE_SZ) def test_serialize buf = new_buffer @@ -204,4 +204,8 @@ class TestBuffer < Testcase assert_equal 4096, buf.buffer_size buf.close! end + + def pipe_size(io) + io.fcntl(SleepyPenguin::F_GETPIPE_SZ) + end end diff --git a/test/test_sink_pipe_size.rb b/test/test_sink_pipe_size.rb index 645084a..1ca3108 100644 --- a/test/test_sink_pipe_size.rb +++ b/test/test_sink_pipe_size.rb @@ -2,7 +2,7 @@ # License: GPL-3.0+ # frozen_string_literal: true begin - require 'io/splice' + require 'sleepy_penguin' require './test/player_integration' class TestSinkPipeSizeIntegration < Testcase include PlayerIntegration @@ -14,7 +14,7 @@ begin s.req_ok("sink ed default pipe_size=0x10000") s.req_ok("sink ed default pipe_size=") s.req_ok("sink ed default pipe_size=4096") - end if IO.method_defined?(:pipe_size=) + end if SleepyPenguin.const_defined?(:F_SETPIPE_SZ) end rescue LoadError end -- cgit v1.2.3-24-ge0c7