about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-16 18:37:37 -0800
committerEric Wong <normalperson@yhbt.net>2011-11-17 17:58:06 -0800
commitbe3672501ecde716dae723e887d4a9e4d731240c (patch)
tree07c6fc18258a4adecf51deb7e2136d81892cac08 /test
parent48dc3c5a1943801311567e72a8e69fcb0cd8cf8d (diff)
downloadkgio-be3672501ecde716dae723e887d4a9e4d731240c.tar.gz
All IO objects created by Kgio will have FD_CLOEXEC descriptor
flag set on it when run under Ruby 2.0.0dev.  This matches the
upcoming behavior of Ruby 2.0.0dev for IO objects in the core
and standard library.  This change does not affect users on Ruby
1.9.3 and earlier.

accept()-ed sockets in kgio have _always_ had FD_CLOEXEC
set by default.
Diffstat (limited to 'test')
-rw-r--r--test/test_tcp_connect.rb11
-rw-r--r--test/test_tryopen.rb4
-rw-r--r--test/test_unix_connect.rb8
3 files changed, 23 insertions, 0 deletions
diff --git a/test/test_tcp_connect.rb b/test/test_tcp_connect.rb
index 9756407..2dbe541 100644
--- a/test/test_tcp_connect.rb
+++ b/test/test_tcp_connect.rb
@@ -31,10 +31,17 @@ class TestKgioTcpConnect < Test::Unit::TestCase
     ready = IO.select(nil, [ sock ])
     assert_equal sock, ready[1][0]
     assert_equal nil, sock.kgio_write("HELLO")
+
+    sock.respond_to?(:close_on_exec?) and
+      assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
   end
 
   def test_start
     sock = Kgio::Socket.start(@addr)
+
+    sock.respond_to?(:close_on_exec?) and
+      assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
+
     assert_kind_of Kgio::Socket, sock
     ready = IO.select(nil, [ sock ])
     assert_equal sock, ready[1][0]
@@ -50,6 +57,10 @@ class TestKgioTcpConnect < Test::Unit::TestCase
 
   def test_tcp_socket_new
     sock = Kgio::TCPSocket.new(@host, @port)
+
+    sock.respond_to?(:close_on_exec?) and
+      assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
+
     assert_instance_of Kgio::TCPSocket, sock
     ready = IO.select(nil, [ sock ])
     assert_equal sock, ready[1][0]
diff --git a/test/test_tryopen.rb b/test/test_tryopen.rb
index 380026d..5a8efb2 100644
--- a/test/test_tryopen.rb
+++ b/test/test_tryopen.rb
@@ -7,6 +7,10 @@ class TestTryopen < Test::Unit::TestCase
 
   def test_tryopen_success
     tmp = Kgio::File.tryopen(__FILE__)
+
+    tmp.respond_to?(:close_on_exec?) and
+      assert_equal(RUBY_VERSION.to_f >= 2.0, tmp.close_on_exec?)
+
     assert_kind_of File, tmp
     assert_equal File.read(__FILE__), tmp.read
     assert_equal __FILE__, tmp.path
diff --git a/test/test_unix_connect.rb b/test/test_unix_connect.rb
index f99a877..b85f1f6 100644
--- a/test/test_unix_connect.rb
+++ b/test/test_unix_connect.rb
@@ -34,6 +34,10 @@ class TestKgioUnixConnect < Test::Unit::TestCase
 
   def test_unix_socket_new
     sock = Kgio::UNIXSocket.new(@path)
+
+    sock.respond_to?(:close_on_exec?) and
+      assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
+
     assert_instance_of Kgio::UNIXSocket, sock
     ready = IO.select(nil, [ sock ])
     assert_equal sock, ready[1][0]
@@ -42,6 +46,10 @@ class TestKgioUnixConnect < Test::Unit::TestCase
 
   def test_new
     sock = Kgio::Socket.new(@addr)
+
+    sock.respond_to?(:close_on_exec?) and
+      assert_equal(RUBY_VERSION.to_f >= 2.0, sock.close_on_exec?)
+
     assert_instance_of Kgio::Socket, sock
     ready = IO.select(nil, [ sock ])
     assert_equal sock, ready[1][0]