diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2017-11-08 19:16:02 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2017-11-08 19:16:02 +0200 |
commit | 51bb00256c3cb0a130d470a087a98684ce003065 (patch) | |
tree | 190920c6bc5170d7ae58c4f9d1af79694ec6b389 /reuseport | |
parent | an attempt to fix TestTCP6 on travis. It looks like travis doesnt know about ... (diff) | |
download | fasthttp-51bb00256c3cb0a130d470a087a98684ce003065.tar.gz fasthttp-51bb00256c3cb0a130d470a087a98684ce003065.tar.bz2 fasthttp-51bb00256c3cb0a130d470a087a98684ce003065.zip |
attempt #2 to fix TestTCP6 on travis: run the test only if local tcp6 interface is present
Diffstat (limited to 'reuseport')
-rw-r--r-- | reuseport/reuseport_test.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/reuseport/reuseport_test.go b/reuseport/reuseport_test.go index ef26b58..0c70e83 100644 --- a/reuseport/reuseport_test.go +++ b/reuseport/reuseport_test.go @@ -13,7 +13,23 @@ func TestTCP4(t *testing.T) { } func TestTCP6(t *testing.T) { - testNewListener(t, "tcp6", "[::1]:10082", 20, 1000) + // Run this test only if tcp6 interface exists. + if hasLocalIPv6(t) { + testNewListener(t, "tcp6", "[::1]:10082", 20, 1000) + } +} + +func hasLocalIPv6(t *testing.T) bool { + addrs, err := net.InterfaceAddrs() + if err != nil { + t.Fatalf("cannot obtain local interfaces: %s", err) + } + for _, a := range addrs { + if a.String() == "::1/128" { + return true + } + } + return false } func testNewListener(t *testing.T, network, addr string, serversCount, requestsCount int) { |