summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-21 21:44:09 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-21 21:44:09 +0000
commit6f91160fa9413e501239ab883dacc5064d0a2661 (patch)
tree468414051616b354840c4150aa458166fbc34ef3
parenta934b664373af3e439977ce62de6c62909608652 (diff)
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
-rw-r--r--test/ruby/test_thread.rb29
1 files changed, 25 insertions, 4 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 6557f881fc..c3ebaf34d5 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -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