summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <zn@mbf.nifty.com>2020-01-26 19:52:16 +0900
committerKazuhiro NISHIYAMA <zn@mbf.nifty.com>2020-01-26 20:03:27 +0900
commit838fa941f157537ebaa98150fab7664bf602f356 (patch)
tree4b3990e0be4c426d6d774eb70696d8be6e10194c /test/net
parentd4e1d4e94e866d498ead1f370236df216917a6c7 (diff)
Add more debug print
https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11x/ruby-master/log/20200125T032406Z.fail.html.gz ``` IMAPTest#test_connection_closed_without_greeting [/export/home/rubyci/chkbuild-tmp/tmp/build/20200125T032406Z/ruby/test/net/imap/test_imap.rb:485]: [Net::IMAP::Error] exception expected, not #<RuntimeError: {:"server before close"=>"#<TCPServer:fd 10, AF_INET6, ::1, 48515>", :sock_addr=>["AF_INET6", 48515, "::1", "::1"], :sock_peeraddr=>["AF_INET6", 35223, "::1", "::1"], :e=>#<Errno::EINVAL: Invalid argument - connect(2) for [::1]:48515>, :server=>#<TCPServer:(closed)>, :port=>48515, :server_addr=>"::1"}>. ```
Diffstat (limited to 'test/net')
-rw-r--r--test/net/imap/test_imap.rb58
1 files changed, 49 insertions, 9 deletions
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 33b305e..03692c2 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -472,25 +472,65 @@ class IMAPTest < Test::Unit::TestCase
def test_connection_closed_without_greeting
server = create_tcp_server
port = server.addr[1]
- h = {'server before close': server.inspect} # inspect info before close
+ h = {
+ server: server,
+ port: port,
+ server_created: {
+ server: server.inspect,
+ t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+ }
+ }
+ net_imap = Class.new(Net::IMAP) do
+ @@h = h
+ def tcp_socket(host, port)
+ @@h[:in_tcp_socket] = {
+ host: host,
+ port: port,
+ server: @@h[:server].inspect,
+ t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+ }
+ super
+ end
+ end
start_server do
begin
+ h[:in_start_server_before_accept] = {
+ t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+ }
sock = server.accept
- h[:sock_addr], h[:sock_peeraddr] = sock.addr, sock.peeraddr
+ h[:in_start_server] = {
+ sock_addr: sock.addr,
+ sock_peeraddr: sock.peeraddr,
+ t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+ }
sock.close
+ h[:in_start_server_sock_closed] = {
+ t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+ }
ensure
server.close
end
end
assert_raise(Net::IMAP::Error) do
- #begin
- Net::IMAP.new(server_addr, :port => port)
- #rescue Net::IMAP::Error
- # raise Errno::EINVAL
- #end
+ #Net::IMAP.new(server_addr, :port => port)
+ if true
+ net_imap.new(server_addr, :port => port)
+ else
+ # for testing debug print
+ begin
+ net_imap.new(server_addr, :port => port)
+ rescue Net::IMAP::Error
+ raise Errno::EINVAL
+ end
+ end
rescue Errno::EINVAL => e # for debug on OpenCSW
- h.merge!({e: e, server: server, port: port, server_addr: server_addr})
- raise(h.inspect)
+ h[:in_rescue] = {
+ e: e,
+ server_addr: server_addr,
+ t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+ }
+ require 'pp'
+ raise(PP.pp(h, +''))
end
end