aboutsummaryrefslogtreecommitdiffstats
path: root/test/socket
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-07 18:39:47 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-07 18:39:47 +0000
commit889f50227cd01425fd22692d552c5f9a3410373f (patch)
treed0708f3401a27cf023a8cf5644b3331ab827a25a /test/socket
parent6757d13ee17b737464de68eea3d914390ee2787b (diff)
downloadruby-889f50227cd01425fd22692d552c5f9a3410373f.tar.gz
socket: expand docs+tests for recv_io/send_io
* ext/socket/unixsocket.c (unix_send_io): document args (unix_recv_io): ditto * test/socket/test_unix.rb (test_fd_passing_class_mode): added I was working on these when I encountered the problem in with BasicSocket.for_fd not handling mode args: https://bugs.ruby-lang.org/issues/11778 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_unix.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 313a1f018b..3fe7fb368b 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -37,6 +37,26 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
end
end
+ def test_fd_passing_class_mode
+ UNIXSocket.pair do |s1, s2|
+ s1.send_io(s1.fileno)
+ r = s2.recv_io(nil)
+ assert_kind_of Integer, r, 'recv_io with klass=nil returns integer FD'
+ assert_not_equal s1.fileno, r
+ r = IO.for_fd(r)
+ assert_equal s1.stat.ino, r.stat.ino
+ r.close
+
+ s1.send_io(s1)
+ # klass = UNIXSocket FIXME: [ruby-core:71860] [Bug #11778]
+ klass = IO
+ r = s2.recv_io(klass, 'r+')
+ assert_instance_of klass, r, 'recv_io with proper klass'
+ assert_not_equal s1.fileno, r.fileno
+ r.close
+ end
+ end
+
def test_fd_passing_n
io_ary = []
return if !defined?(Socket::SCM_RIGHTS)