Forum: Ruby-core test_io.rb: test 2 fails on FreeBSD

Posted by mame (Yusuke Endoh) (Guest)
on 2013-02-18 13:09
(Received via mailing list)
Issue #2008 has been updated by mame (Yusuke Endoh).

Target version changed from 2.0.0 to next minor


----------------------------------------
Bug #2008: test_io.rb: test 2 fails on FreeBSD
https://bugs.ruby-lang.org/issues/2008#change-36503

Author: lucas (Lucas Nussbaum)
Status: Feedback
Priority: Low
Assignee: akr (Akira Tanaka)
Category: core
Target version: next minor
ruby -v: 1.9.1.243 GNU/kfreebsd


=begin
 Hi,

 Test 2 in test_io.rb fails on FreeBSD. This is related to 
http://redmine.ruby-lang.org/issues/show/1066, which, according to the 
comments posted after the bug was closed, wasn't really fixed.

 I ran into this on Debian GNU/kfreebsd (Debian userland, freebsd 
kernel). One of our freebsd porter wrote (see 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543805):

 > The test assumes that the kernel buffer for pipes have fixed size.
 > It does not have to be true, there could be adaptive buffer size
 > provided by kernel. After filling whole kernel buffer (by 
non-blocking
 > write), it might be required to buffer becomes filled only from half
 > or even empty. The next write() might be blocked until whole
 > kernel buffer is read. Such behaviour of kernel is correct one.
 >
 > The kernel of FreeBSD uses adaptive pipe sizes and direct pipe 
writes,
 > see http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern...

 (It is likely to be the same on Mac OS X)

 He suggests changing the test to:
 >   begin
 >     require "io/nonblock"
 >     r, w = IO.pipe
 >     w.nonblock = true
 >     bytes = w.write_nonblock("a" * 100000)
 >     w.nonblock = false
 >     t1 = Thread.new { w.write("b" * 4096) }
 >     t2 = Thread.new { w.write("c" * 4096) }
 >     sleep 0.5
 >     blocks = 2 + bytes/4096
 >     blocks.times {
 >          r.sysread(4096).length
 >          sleep 0.1
 >     }
 >     t1.join
 >     t2.join
 >   rescue LoadError
 >   end

 However, I don't understand what that test is trying to test. It might 
be better to simply remove that test...
=end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.