File: test_cross_thread_close.rb

package info (click to toggle)
ruby-kgio 2.11.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 504 kB
  • sloc: ruby: 2,779; ansic: 2,017; sh: 32; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (6)
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
require 'test/unit'
$-w = true
require 'kgio'

class TestCrossThreadClose < Test::Unit::TestCase

  def test_cross_thread_close
    host = ENV["TEST_HOST"] || '127.0.0.1'
    srv = Kgio::TCPServer.new(host, 0)
    thr = Thread.new do
      begin
        srv.kgio_accept
      rescue => e
        e
      end
    end
    sleep(0.1) until thr.stop?
    srv.close
    unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" &&
           RUBY_VERSION == "1.9.3"
      thr.run rescue nil
    end
    thr.join
    assert_kind_of IOError, thr.value
  end
end if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby"