From 69195fd9b26d4585ad0d13d45ce9fd7b7ebac154 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Wed, 19 Jun 2019 17:53:52 +1200 Subject: Show thread and fiber limits as part of bootstrap tests. --- bootstraptest/runner.rb | 21 +++++++++++++++++---- bootstraptest/test_thread.rb | 26 ++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index dcaabc9743..3481402401 100755 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -208,6 +208,9 @@ def exec_test(pathes) $stderr.puts unless @quiet and @tty and @error == error end $stderr.print(erase) if @quiet + @errbuf.each do |msg| + $stderr.puts msg + end if @error == 0 if @count == 0 $stderr.puts "No tests, no problem" @@ -216,9 +219,6 @@ def exec_test(pathes) end exit true else - @errbuf.each do |msg| - $stderr.puts msg - end $stderr.puts "#{@failed}FAIL#{@reset} #{@error}/#{@count} tests failed" exit false end @@ -244,7 +244,7 @@ def show_progress(message = '') else $stderr.print "#{@failed}F" $stderr.printf(" %.3f", t) if @verbose - $stderr.print "#{@reset}" + $stderr.print @reset $stderr.puts if @verbose error faildesc, message unless errout.empty? @@ -263,6 +263,19 @@ rescue Exception => err error err.message, message end +def show_limit(testsrc, opt = '', **argh) + result = get_result_string(testsrc, opt, **argh) + $stderr.print '.' + $stderr.print @reset + $stderr.puts if @verbose + + if @tty + $stderr.puts "#{erase}#{result}" + else + @errbuf.push result + end +end + def assert_check(testsrc, message = '', opt = '', **argh) show_progress(message) { result = get_result_string(testsrc, opt, **argh) diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb index 854065f87e..319f9ca625 100644 --- a/bootstraptest/test_thread.rb +++ b/bootstraptest/test_thread.rb @@ -1,5 +1,27 @@ -# Thread and Fiber - +show_limit %q{ + threads = [] + begin + threads << Thread.new{sleep} + + raise Exception, "skipping" if threads.count >= 10_000 + rescue Exception => error + puts "Thread count: #{threads.count} (#{error})" + break + end while true +} +show_limit %q{ + fibers = [] + begin + fiber = Fiber.new{Fiber.yield} + fiber.resume + fibers << fiber + + raise Exception, "skipping" if fibers.count >= 10_000 + rescue Exception => error + puts "Fiber count: #{fibers.count} (#{error})" + break + end while true +} assert_equal %q{ok}, %q{ Thread.new{ }.join -- cgit v1.2.3