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:
parent
8dee58d7e1
commit
0cd078e358
1 changed files with 14 additions and 10 deletions
|
@ -5,6 +5,7 @@ end
|
||||||
|
|
||||||
require "test/unit"
|
require "test/unit"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
require "tmpdir"
|
||||||
|
|
||||||
class TestUNIXSocket < Test::Unit::TestCase
|
class TestUNIXSocket < Test::Unit::TestCase
|
||||||
def test_fd_passing
|
def test_fd_passing
|
||||||
|
@ -167,17 +168,20 @@ class TestUNIXSocket < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize
|
def test_initialize
|
||||||
Socket.open(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) {|s|
|
Dir.mktmpdir {|d|
|
||||||
addr = s.getsockname
|
Socket.open(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) {|s|
|
||||||
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
|
s.bind(Socket.pack_sockaddr_un("#{d}/s1"))
|
||||||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
|
addr = s.getsockname
|
||||||
}
|
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
|
||||||
Socket.open("AF_UNIX", "SOCK_STREAM", 0) {|s|
|
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
|
||||||
addr = s.getsockname
|
}
|
||||||
assert_nothing_raised { Socket.unpack_sockaddr_un(addr) }
|
Socket.open("AF_UNIX", "SOCK_STREAM", 0) {|s|
|
||||||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(addr) }
|
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
|
||||||
|
|
||||||
|
|
||||||
end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM
|
end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM
|
||||||
|
|
Loading…
Add table
Reference in a new issue