aboutsummaryrefslogtreecommitdiffstats
path: root/test/socket/test_unix.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-03 11:15:15 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-03 11:15:15 +0000
commit88f1b8cf0c286d5a499d0832cde5ff6be4105d89 (patch)
treede55d3ce3930d527ccd672ed2cb58b92567dd3d0 /test/socket/test_unix.rb
parentdf6a0fe8bb0d41634689af8dcbee2c3e5eed4818 (diff)
downloadruby-88f1b8cf0c286d5a499d0832cde5ff6be4105d89.tar.gz
add test for close-on-exec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket/test_unix.rb')
-rw-r--r--test/socket/test_unix.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index b4c4592537..a9918b108b 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -22,6 +22,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
r2 = s2.recv_io
assert_equal(r1.stat.ino, r2.stat.ino)
assert_not_equal(r1.fileno, r2.fileno)
+ assert(r2.close_on_exec?)
w.syswrite "a"
assert_equal("a", r2.sysread(10))
ensure
@@ -61,6 +62,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
send_io_ary.length.times {|i|
assert_not_equal(send_io_ary[i].fileno, recv_io_ary[i].fileno)
assert(File.identical?(send_io_ary[i], recv_io_ary[i]))
+ assert(recv_io_ary[i].close_on_exec?)
}
}
}
@@ -97,6 +99,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
send_io_ary.length.times {|i|
assert_not_equal(send_io_ary[i].fileno, recv_io_ary[i].fileno)
assert(File.identical?(send_io_ary[i], recv_io_ary[i]))
+ assert(recv_io_ary[i].close_on_exec?)
}
}
}
@@ -150,6 +153,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
r2 = s2.recv_io
begin
assert(File.identical?(r1, r2))
+ assert(r2.close_on_exec?)
ensure
r2.close
end
@@ -230,6 +234,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
r2 = ios[0]
begin
assert(File.identical?(r1, r2))
+ assert(r2.close_on_exec?)
ensure
r2.close
end
@@ -260,6 +265,16 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
}
end
+ def test_cloexec
+ bound_unix_socket(UNIXServer) {|serv, path|
+ c = UNIXSocket.new(path)
+ s = serv.accept
+ assert(serv.close_on_exec?)
+ assert(c.close_on_exec?)
+ assert(s.close_on_exec?)
+ }
+ end
+
def test_noname_path
s1, s2 = UNIXSocket.pair
assert_equal("", s1.path)
@@ -374,6 +389,14 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
assert_kind_of(UNIXSocket, pair[1])
end
+ def test_unix_socket_pair_close_on_exec
+ pair = nil
+ UNIXSocket.pair {|s1, s2|
+ assert(s1.close_on_exec?)
+ assert(s2.close_on_exec?)
+ }
+ end
+
def test_initialize
Dir.mktmpdir {|d|
Socket.open(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) {|s|