File: testthreads.rb

package info (click to toggle)
ruby-log4r 1.1.10-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 648 kB
  • sloc: ruby: 2,744; xml: 96; makefile: 5
file content (31 lines) | stat: -rw-r--r-- 833 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# $Id$
# Test guts sent in by chetreddy bug #27184
#
# Note: this test won't always catch a threading problem, as it
# relies on a brute force approach.  NUM_THREADS can be increased
# to stress the system longer and therefore increasing the chance
# of exposing a threading issue, however, it is not a definitive
# test.
#

require 'test_helper'

class TestThreads < TestCase
  include Log4r

  NUMTHREADS = 1000

  def test_threads

    assert_nothing_raised do
      (0..NUMTHREADS).map do |i|
        Thread.new do
          Thread.current[:logger] = Log4r::Logger.new "Hello #{i}"
          Thread.current[:logger].outputters = [StdoutOutputter.new("log4r#{i}")]
          Thread.current[:logger].outputters.each { |j| j.flush }
          Thread.current.exit()
        end
      end.each do |thr| thr.join end
    end
  end
end