1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

don't get a name for anonymous Unix socket.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-01-05 13:40:42 +00:00
parent 8dee58d7e1
commit 0cd078e358

View file

@ -5,6 +5,7 @@ end
require "test/unit"
require "tempfile"
require "tmpdir"
class TestUNIXSocket < Test::Unit::TestCase
def test_fd_passing
@ -167,17 +168,20 @@ class TestUNIXSocket < Test::Unit::TestCase
end
def test_initialize
Socket.open(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) {|s|
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
}
Socket.open("AF_UNIX", "SOCK_STREAM", 0) {|s|
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
Dir.mktmpdir {|d|
Socket.open(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) {|s|
s.bind(Socket.pack_sockaddr_un("#{d}/s1"))
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
}
Socket.open("AF_UNIX", "SOCK_STREAM", 0) {|s|
s.bind(Socket.pack_sockaddr_un("#{d}/s2"))
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
}
}
end
end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM