1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add a test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-02-22 18:14:01 +00:00
parent b7fe065741
commit decee68028

View file

@ -273,4 +273,22 @@ class TestSocket < Test::Unit::TestCase
} }
end end
def test_timestamp
return if /linux|solaris|darwin/ !~ RUBY_PLATFORM
t1 = Time.now.strftime("%Y-%m-%d")
stamp = nil
Addrinfo.udp("127.0.0.1", 0).bind {|s1|
Addrinfo.udp("127.0.0.1", 0).bind {|s2|
s1.setsockopt(:SOCKET, :SO_TIMESTAMP, true)
s2.send "a", 0, s1.local_address
msg, addr, rflags, stamp = s1.recvmsg
assert_equal("a", msg)
assert(stamp.cmsg_is?(:SOCKET, :TIMESTAMP))
}
}
t2 = Time.now.strftime("%Y-%m-%d")
pat = Regexp.union([t1, t2].uniq)
assert_match(pat, stamp.inspect)
end
end if defined?(Socket) end if defined?(Socket)