hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.19k stars 232 forks source link

TestPing failed on Windows #101

Closed jinmiaoluo closed 2 years ago

jinmiaoluo commented 2 years ago

run TestPing on Linux

$ go test . -run '^TestPing$' -v 
=== RUN   TestPing
--- PASS: TestPing (0.00s)
PASS
ok      github.com/hashicorp/yamux      0.002s

run TestPing on Windows

PS C:\Users\jinmiaoluo\repo\yamux> go test . -run '^TestPing$' -v 
=== RUN   TestPing
    session_test.go:98: bad: 0s
--- FAIL: TestPing (0.00s)
FAIL
FAIL    github.com/hashicorp/yamux      0.178s
FAIL
PS C:\Users\jinmiaoluo\repo\yamux>

debug on Linux

$ dlv test .
Type 'help' for list of commands.
(dlv) b ./session_test.go:94
Breakpoint 1 set at 0x56eb44 for github.com/hashicorp/yamux.TestPing() ./session_test.go:94
(dlv) c
> github.com/hashicorp/yamux.TestPing() ./session_test.go:94 (hits goroutine(8):1 total:1) (PC: 0x56eb44)
    89:         client, server := testClientServer()
    90:         defer client.Close()
    91:         defer server.Close()
    92: 
    93:         rtt, err := client.Ping()
=>  94:         if err != nil {
    95:                 t.Fatalf("err: %v", err)
    96:         }
    97:         if rtt == 0 {
    98:                 t.Fatalf("bad: %v", rtt)
    99:         }
(dlv) p rtt
196033
(dlv) 

debug on Windows

(dlv) b c:/users/jinmiaoluo/repo/yamux/session_test.go:94
Breakpoint 1 set at 0x5b8544 for github.com/hashicorp/yamux.TestPing() c:/users/jinmiaoluo/repo/yamux/session_test.go:94
(dlv) c
> github.com/hashicorp/yamux.TestPing() c:/users/jinmiaoluo/repo/yamux/session_test.go:94 (hits goroutine(8):1 total:1) (PC: 0x5b8544)
    89:         client, server := testClientServer()
    90:         defer client.Close()
    91:         defer server.Close()
    92:
    93:         rtt, err := client.Ping()
=>  94:         if err != nil {
    95:                 t.Fatalf("err: %v", err)
    96:         }
    97:         if rtt == 0 {
    98:                 t.Fatalf("bad: %v", rtt)
    99:         }
(dlv) p rtt
0
(dlv)
jinmiaoluo commented 2 years ago

Same issue: https://github.com/hashicorp/yamux/pull/41