about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-22 19:24:54 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-23 13:14:27 -0800
commitdb192979f096d0153ad14e530e1e2e193289c7e0 (patch)
tree356c4a8bf64f30dd6c4886adc92f253bd4bf831d /test
parentebc2093847705c382b4d83ed5120e44b9afad3c0 (diff)
downloadraindrops-db192979f096d0153ad14e530e1e2e193289c7e0.tar.gz
This returns a Raindrops::TCP_Info object
that wraps a tcp_info struct.
Diffstat (limited to 'test')
-rw-r--r--test/test_linux_tcp_info.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/test_linux_tcp_info.rb b/test/test_linux_tcp_info.rb
new file mode 100644
index 0000000..bfa7eb3
--- /dev/null
+++ b/test/test_linux_tcp_info.rb
@@ -0,0 +1,41 @@
+# -*- encoding: binary -*-
+require 'test/unit'
+require 'tempfile'
+require 'raindrops'
+require 'socket'
+require 'pp'
+$stderr.sync = $stdout.sync = true
+class TestLinuxTCP_Info < Test::Unit::TestCase
+
+  TEST_ADDR = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'
+
+  def test_tcp_server
+    s = TCPServer.new(TEST_ADDR, 0)
+    rv = Raindrops::TCP_Info.new s
+    c = TCPSocket.new TEST_ADDR, s.addr[1]
+    tmp = Raindrops::TCP_Info.new s
+    assert_equal 1, tmp.unacked
+    assert_equal 0, rv.unacked
+    a = s.accept
+    tmp = Raindrops::TCP_Info.new s
+    assert_equal 0, tmp.unacked
+    ensure
+      c.close if c
+      a.close if a
+      s.close
+  end
+
+  def test_accessors
+    s = TCPServer.new TEST_ADDR, 0
+    tmp = Raindrops::TCP_Info.new s
+    tcp_info_methods = tmp.methods - Object.new.methods
+    assert tcp_info_methods.size >= 32
+    tcp_info_methods.each do |m|
+      val = tmp.__send__ m
+      assert_kind_of Integer, val
+      assert val >= 0
+    end
+    ensure
+      s.close
+  end
+end