summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-05 14:09:21 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-05 14:09:21 +0000
commit25d040780fcff44b3b03062d1d2c4540df7b33ef (patch)
tree1ed5b340ef42062c59fa7c73c7bc96f7e3cadc6b /test/ruby
parentb5d612e0df4b77f7918323d25d7b46ccdd2756d9 (diff)
* test/ruby/test_io.rb (TestIO#test_O_CLOEXEC): fix false positive
detection. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb58
1 files changed, 39 insertions, 19 deletions
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