2
0
mirror of https://github.com/soheilhy/cmux.git synced 2025-10-18 05:08:08 +08:00

2 Commits

Author SHA1 Message Date
Soheil Hassas Yeganeh
711042c095 Use IPv4 for the listener to avoid v6 failures on Travis. 2017-12-04 12:32:43 -05:00
Soheil Hassas Yeganeh
ac00452023 Fix TestClose for Go10.
Depending on the Go version used, reading from a closed pipe can return
net.OpError or io.ErrClosedPipe. Simply check the string content of the
error.
2017-12-04 12:18:06 -05:00

View File

@@ -81,7 +81,7 @@ func (l *chanListener) Accept() (net.Conn, error) {
}
func testListener(t *testing.T) (net.Listener, func()) {
l, err := net.Listen("tcp", ":0")
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
@@ -659,7 +659,9 @@ func TestClose(t *testing.T) {
if err != ErrListenerClosed {
t.Fatal(err)
}
if _, err := c2.Read([]byte{}); err != io.ErrClosedPipe {
// The error is either io.ErrClosedPipe or net.OpError wrapping
// a net.pipeError depending on the go version.
if _, err := c2.Read([]byte{}); !strings.Contains(err.Error(), "closed") {
t.Fatalf("connection is not closed and is leaked: %v", err)
}
}