summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_io.rb58
2 files changed, 44 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 16f7bce67f..ffd8998aa2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 5 23:08:32 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * test/ruby/test_io.rb (TestIO#test_O_CLOEXEC): fix false positive
+ detection.
+
Thu May 5 22:23:34 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* thread_pthread.c (native_mutex_reinitialize_atfork): removed
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 5a55722115..07308a07ce 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1244,28 +1244,48 @@ class TestIO < Test::Unit::TestCase
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");
+ ary = []
+ begin
+ 10.times {
+ ary.concat IO.pipe
+ }
- argfile.puts normal_file.fileno
- argfile.puts cloexec_file.fileno
- argfile.flush
+ 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?)
+ arg, argw = IO.pipe
+ argw.puts normal_file.fileno
+ argw.puts cloexec_file.fileno
+ argw.flush
+ ret, retw = IO.pipe
+
+ while (e = ary.shift) != nil
+ e.close
+ end
- 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"
+ spawn("ruby", "-e", <<-'End', :close_others=>false, :in=>arg, :out=>retw)
+ begin
+ puts IO.for_fd(gets.to_i).fileno
+ puts IO.for_fd(gets.to_i).fileno
+ rescue
+ puts "nofile"
+ ensure
+ exit
+ end
+ End
+ retw.close
+ Process.wait
+ assert_equal("#{normal_file.fileno}\nnofile\n", ret.read)
+ ensure
+ while (e = ary.shift) != nil
+ e.close
end
- End
- assert_equal("#{normal_file.fileno}\nnofile\n", f.read)
- }
+ arg.close unless arg.closed?
+ argw.close unless argw.closed?
+ ret.close unless ret.closed?
+ retw.close unless retw.closed?
+ end
end
end