summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-31 04:59:31 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-31 04:59:31 +0000
commit4ccfb2743f38d54eeecc5a229b3a8edf2eb84f3c (patch)
tree1cfe1c98bc6e86ad2c05505275110e5af9241410 /test
parent1ff38a5bbf2baa5fa6646fffdc81ed3611be805b (diff)
* ext/socket/raddrinfo.c (rsock_unix_sockaddr_len): return
sizeof(sa_familiy_t) if path is empty. see "Autobind Feature" in unix(7) for details. * ext/socket/lib/socket.rb (unix_socket_abstract_name?): treat an empty path as an abstract name. * test/socket/test_unix.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/socket/test_unix.rb31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 19efb32219..faf70f2e19 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -542,7 +542,11 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
s0 = s
UNIXSocket.open(name) {|c|
sock = s.accept
- assert_equal(name, c.remote_address.unix_path)
+ begin
+ assert_equal(name, c.remote_address.unix_path)
+ ensure
+ sock.close
+ end
}
}
assert(s0.closed?)
@@ -565,7 +569,30 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
s0 = s
Socket.unix(name) {|c|
sock, = s.accept
- assert_equal(name, c.remote_address.unix_path)
+ begin
+ assert_equal(name, c.remote_address.unix_path)
+ ensure
+ sock.close
+ end
+ }
+ }
+ assert(s0.closed?)
+ end
+
+ def test_autobind
+ return if /linux/ !~ RUBY_PLATFORM
+ s0 = nil
+ Socket.unix_server_socket("") {|s|
+ name = s.local_address.unix_path
+ assert_match(/\A\0[0-9a-f]{5}\z/, name)
+ s0 = s
+ Socket.unix(name) {|c|
+ sock, = s.accept
+ begin
+ assert_equal(name, c.remote_address.unix_path)
+ ensure
+ sock.close
+ end
}
}
assert(s0.closed?)