From 96c8be2ea8830e2eb3a9108f501df52c21b42546 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 4 Mar 2011 17:08:13 -0800 Subject: test_linux_tcp_info: add test for last_data_recv --- test/test_linux_tcp_info.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/test_linux_tcp_info.rb b/test/test_linux_tcp_info.rb index e008a92..1751dee 100644 --- a/test/test_linux_tcp_info.rb +++ b/test/test_linux_tcp_info.rb @@ -42,4 +42,20 @@ class TestLinuxTCP_Info < Test::Unit::TestCase ensure s.close end + + def test_tcp_server_delayed + delay = 0.010 + delay_ms = (delay * 1000).to_i + s = TCPServer.new(TEST_ADDR, 0) + c = TCPSocket.new TEST_ADDR, s.addr[1] + c.syswrite "." + sleep delay + a = s.accept + i = Raindrops::TCP_Info.new(a) + assert i.last_data_recv >= delay_ms, "#{i.last_data_recv} < #{delay_ms}" + ensure + c.close if c + a.close if a + s.close + end end -- cgit v1.2.3-24-ge0c7