mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/ruby/test_thread.rb: add diagnosis code for [Bug #15430]
I can't find stderr in the test-all output of the CI machine, so maybe the assertion will show what's going on. http://rubyci.s3.amazonaws.com/centos7/ruby-trunk/log/20181221T170003Z.log.html.gz#test-all git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a934b66437
commit
6f91160fa9
1 changed files with 25 additions and 4 deletions
|
|
@ -1241,23 +1241,44 @@ q.pop
|
|||
|
||||
def test_fork_while_parent_locked
|
||||
skip 'needs fork' unless Process.respond_to?(:fork)
|
||||
require 'tempfile'
|
||||
m = Thread::Mutex.new
|
||||
failures = 0
|
||||
run = true
|
||||
thrs = 50.times.map do
|
||||
Thread.new do
|
||||
errs = ''
|
||||
nr = 50
|
||||
tmps = nr.times.map { Tempfile.new('Bug.15430.diagnosis') }
|
||||
thrs = nr.times.map do |_i|
|
||||
Thread.new(_i) do |i|
|
||||
t = tmps[i]
|
||||
t.sync = true
|
||||
while run
|
||||
pid = fork { m.synchronize {} }
|
||||
pid = fork do
|
||||
STDERR.reopen(t.path)
|
||||
tmps.each(&:close)
|
||||
m.synchronize {}
|
||||
end
|
||||
m.synchronize {}
|
||||
_, st = Process.waitpid2(pid)
|
||||
m.synchronize { failures += 1 } unless st.success?
|
||||
unless st.success?
|
||||
m.synchronize do
|
||||
failures += 1
|
||||
if errs.empty?
|
||||
errs = st.inspect << t.read
|
||||
t.rewind
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
sleep 0.5
|
||||
run = false
|
||||
thrs.each(&:join)
|
||||
assert_empty errs
|
||||
assert_equal 0, failures, '[ruby-core:90312] [Bug #15383]'
|
||||
ensure
|
||||
tmps&.each(&:close!)
|
||||
end
|
||||
|
||||
def test_fork_while_mutex_locked_by_forker
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue