From bf2fb0a16091201a9b2798ebdea54e03c1c3e61b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 16 Mar 2017 03:16:52 +0000 Subject: define Raindrops::TCP hash for TCP states 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. --- test/test_tcp_info.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') 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) -- cgit v1.2.3-24-ge0c7