Sha256: 0d882f8f0b523f827df170ba031c9d49c8beb0358a82d1967f6fb95d46443e29
Contents?: true
Size: 1.36 KB
Versions: 26
Compression:
Stored size: 1.36 KB
Contents
# -*- encoding: binary -*- require 'test/unit' require 'socket' require 'raindrops' require 'pp' $stderr.sync = $stdout.sync = true class TestLinuxAllTcpListenStats < Test::Unit::TestCase include Raindrops::Linux TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1' def test_print_all puts "EVERYTHING" pp Raindrops::Linux.tcp_listener_stats puts("-" * 72) end if $stdout.tty? def setup @socks = [] end def teardown @socks.each { |io| io.closed? or io.close } end def new_server s = TCPServer.new TEST_ADDR, 0 @socks << s [ s, s.addr[1] ] end def new_client(port) s = TCPSocket.new("127.0.0.1", port) @socks << s s end def new_accept(srv) c = srv.accept @socks << c c end def test_all_ports srv, port = new_server addr = "#{TEST_ADDR}:#{port}" all = Raindrops::Linux.tcp_listener_stats assert_equal [0,0], all[addr].to_a new_client(port) all = Raindrops::Linux.tcp_listener_stats assert_equal [0,1], all[addr].to_a new_client(port) all = Raindrops::Linux.tcp_listener_stats assert_equal [0,2], all[addr].to_a new_accept(srv) all = Raindrops::Linux.tcp_listener_stats assert_equal [1,1], all[addr].to_a new_accept(srv) all = Raindrops::Linux.tcp_listener_stats assert_equal [2,0], all[addr].to_a end end if RUBY_PLATFORM =~ /linux/
Version data entries
26 entries across 26 versions & 3 rubygems