1 # -*- encoding: binary -*-
7 $stderr.sync = $stdout.sync = true
8 class TestLinuxTCP_Info < Test::Unit::TestCase
10 TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'
12 # Linux kernel commit 5ee3afba88f5a79d0bff07ddd87af45919259f91
13 TCP_INFO_useful_listenq = `uname -r`.strip >= '2.6.24'
16 s = TCPServer.new(TEST_ADDR, 0)
17 rv = Raindrops::TCP_Info.new s
18 c = TCPSocket.new TEST_ADDR, s.addr[1]
19 tmp = Raindrops::TCP_Info.new s
20 TCP_INFO_useful_listenq and assert_equal 1, tmp.unacked
22 assert_equal 0, rv.unacked
24 tmp = Raindrops::TCP_Info.new s
25 assert_equal 0, tmp.unacked
33 s = TCPServer.new TEST_ADDR, 0
34 tmp = Raindrops::TCP_Info.new s
35 tcp_info_methods = tmp.methods - Object.new.methods
36 assert tcp_info_methods.size >= 32
37 tcp_info_methods.each do |m|
39 assert_kind_of Integer, val
46 def test_tcp_server_delayed
48 delay_ms = (delay * 1000).to_i
49 s = TCPServer.new(TEST_ADDR, 0)
50 c = TCPSocket.new TEST_ADDR, s.addr[1]
54 i = Raindrops::TCP_Info.new(a)
55 assert i.last_data_recv >= delay_ms, "#{i.last_data_recv} < #{delay_ms}"