about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-16 03:16:52 +0000
committerEric Wong <e@80x24.org>2017-03-17 22:39:12 +0000
commitbf2fb0a16091201a9b2798ebdea54e03c1c3e61b (patch)
treea3cd9a2713024e87633908d59d545a07827f3b9a /test
parent17d57231c4d9d3dfb486b6d37b85d57e6065958e (diff)
downloadraindrops-bf2fb0a16091201a9b2798ebdea54e03c1c3e61b.tar.gz
FreeBSD not only uses different values than Linux for TCP
states, but different names, too.  To ease writing portable code
between the OSes, do more CPP metaprogramming via extconf.rb
and define a common hash supported on both OSes.

Putting all this in a hash allows for easy dumping and mapping
in an OS-neutral way, since the actual TCP states are
OS-independent.
Diffstat (limited to 'test')
-rw-r--r--test/test_tcp_info.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/test_tcp_info.rb b/test/test_tcp_info.rb
index 15df087..b107565 100644
--- a/test/test_tcp_info.rb
+++ b/test/test_tcp_info.rb
@@ -73,6 +73,9 @@ class TestTCP_Info < Test::Unit::TestCase
     a = s.accept
     i.get!(a)
     state = i.state
+    if Raindrops.const_defined?(:TCP)
+      assert_equal state, Raindrops::TCP[:ESTABLISHED]
+    end
     c = c.close
     sleep(0.01) # wait for kernel to update state
     i.get!(a)