mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 23:45:55 +02:00
* 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
This commit is contained in:
parent
b5d612e0df
commit
25d040780f
2 changed files with 44 additions and 19 deletions
|
@ -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>
|
Thu May 5 22:23:34 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* thread_pthread.c (native_mutex_reinitialize_atfork): removed
|
* thread_pthread.c (native_mutex_reinitialize_atfork): removed
|
||||||
|
|
|
@ -1244,28 +1244,48 @@ class TestIO < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
mkcdtmpdir do
|
mkcdtmpdir do
|
||||||
normal_file = Tempfile.new("normal_file");
|
ary = []
|
||||||
assert_equal(false, normal_file.close_on_exec?)
|
begin
|
||||||
|
10.times {
|
||||||
|
ary.concat IO.pipe
|
||||||
|
}
|
||||||
|
|
||||||
cloexec_file = Tempfile.new("cloexec_file", :mode => File::CLOEXEC);
|
normal_file = Tempfile.new("normal_file");
|
||||||
assert_equal(true, cloexec_file.close_on_exec?)
|
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
|
||||||
|
|
||||||
argfile = Tempfile.new("argfile");
|
while (e = ary.shift) != nil
|
||||||
|
e.close
|
||||||
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
|
||||||
End
|
|
||||||
assert_equal("#{normal_file.fileno}\nnofile\n", f.read)
|
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
|
||||||
|
arg.close unless arg.closed?
|
||||||
|
argw.close unless argw.closed?
|
||||||
|
ret.close unless ret.closed?
|
||||||
|
retw.close unless retw.closed?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue