Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
set linger to 0 on OSX in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 19, 2022
1 parent 7b09f5f commit 8e5c864
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func init() {
}
}

func setLingerZero(c manet.Conn) {
if runtime.GOOS == "darwin" {
c.(interface{ SetLinger(int) error }).SetLinger(0)
}
}

func acceptOne(t *testing.T, listener manet.Listener) <-chan interface{} {
t.Helper()
done := make(chan interface{}, 1)
Expand All @@ -50,6 +56,7 @@ func acceptOne(t *testing.T, listener manet.Listener) <-chan interface{} {
t.Error(err)
return
}
setLingerZero(c)
c.Close()
}()
<-done
Expand All @@ -66,6 +73,7 @@ func dialOne(t *testing.T, tr *Transport, listener manet.Listener, expected ...i
}
port := c.LocalAddr().(*net.TCPAddr).Port
<-done
setLingerZero(c)
c.Close()
if len(expected) == 0 {
return port
Expand Down Expand Up @@ -126,9 +134,6 @@ func TestTwoLocal(t *testing.T) {
}

func TestGlobalPreferenceV4(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("This test is failing on OSX: https://github.com/libp2p/go-reuseport-transport/issues/33")
}
if globalV4 == nil {
t.Skip("no global IPv4 addresses configured")
return
Expand All @@ -143,9 +148,6 @@ func TestGlobalPreferenceV4(t *testing.T) {
}

func TestGlobalPreferenceV6(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("This test is failing on OSX: https://github.com/libp2p/go-reuseport-transport/issues/33")
}
if globalV6 == nil {
t.Skip("no global IPv6 addresses configured")
return
Expand All @@ -157,9 +159,6 @@ func TestGlobalPreferenceV6(t *testing.T) {
}

func TestLoopbackPreference(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("This test is failing on OSX: https://github.com/libp2p/go-reuseport-transport/issues/33")
}
testPrefer(t, loopbackV4, loopbackV4, unspecV4)
testPrefer(t, loopbackV6, loopbackV6, unspecV6)
}
Expand Down Expand Up @@ -244,9 +243,6 @@ func testUseFirst(t *testing.T, listen, use, never ma.Multiaddr) {
}

func TestDuplicateGlobal(t *testing.T) {
if runtime.GOOS == "darwin" {
t.Skip("This test is failing on OSX: https://github.com/libp2p/go-reuseport-transport/issues/33")
}
if globalV4 == nil {
t.Skip("no globalV4 addresses configured")
return
Expand Down

0 comments on commit 8e5c864

Please sign in to comment.