mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add a test for file descriptor passing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8a85b8bef1
commit
f27ff52d1e
1 changed files with 28 additions and 0 deletions
28
test/socket/test_unix.rb
Normal file
28
test/socket/test_unix.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
begin
|
||||||
|
require "socket"
|
||||||
|
require "test/unit"
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestUNIXSocket < Test::Unit::TestCase
|
||||||
|
def test_fd_passing
|
||||||
|
r1, w = IO.pipe
|
||||||
|
s1, s2 = UNIXSocket.pair
|
||||||
|
begin
|
||||||
|
s1.send_io r1
|
||||||
|
rescue NotImplementedError
|
||||||
|
s1.close
|
||||||
|
assert_raise(NotImplementedError) { s2.recv_io }
|
||||||
|
return
|
||||||
|
end
|
||||||
|
r2 = s2.recv_io
|
||||||
|
assert_equal(r1.stat.ino, r2.stat.ino)
|
||||||
|
assert_not_equal(r1.fileno, r2.fileno)
|
||||||
|
ensure
|
||||||
|
s1.close if s1
|
||||||
|
s2.close if s2
|
||||||
|
r1.close if r1
|
||||||
|
r2.close if r2
|
||||||
|
w.close if w
|
||||||
|
end
|
||||||
|
end if defined?(UNIXSocket)
|
Loading…
Reference in a new issue