summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-04 11:29:24 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-04 11:29:24 +0000
commitbe62297f9230c4cf8d73321c5c9e28037b35fc1d (patch)
tree8f8ef97f4db6938963daf0b6e4adffe957bb4af2 /test/ruby
parentc06da4735da0e2285c1e3e52202b7090b3f43b1b (diff)
* io.c (Init_IO): Added File::CLOEXEC constant. [ruby-core:22893] [Feature #1291]
* test/ruby/test_io.rb (TestIO#test_o_cloexec): test for File::CLOEXEC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 25e6ddbe7f..5a55722115 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1238,6 +1238,37 @@ class TestIO < Test::Unit::TestCase
end
end
+ def test_O_CLOEXEC
+ if !defined? File::CLOEXEC
+ return
+ end
+
+ mkcdtmpdir do
+ normal_file = Tempfile.new("normal_file");
+ assert_equal(false, normal_file.close_on_exec?)
+
+ cloexec_file = Tempfile.new("cloexec_file", :mode => File::CLOEXEC);
+ assert_equal(true, cloexec_file.close_on_exec?)
+
+ argfile = Tempfile.new("argfile");
+
+ argfile.puts normal_file.fileno
+ argfile.puts cloexec_file.fileno
+ argfile.flush
+
+ ruby('-e', <<-'End', argfile.path) { |f|
+ begin
+ puts IO.for_fd(ARGF.gets.to_i).fileno
+ puts IO.for_fd(ARGF.gets.to_i).fileno
+ rescue
+ puts "nofile"
+ end
+ End
+ assert_equal("#{normal_file.fileno}\nnofile\n", f.read)
+ }
+ end
+ end
+
def test_close_security_error
with_pipe do |r, w|
assert_raise(SecurityError) do