diff options
Diffstat (limited to 'libgo/go/net/hosts_test.go')
-rw-r--r-- | libgo/go/net/hosts_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libgo/go/net/hosts_test.go b/libgo/go/net/hosts_test.go index 470e35f7863..e5793eef2c7 100644 --- a/libgo/go/net/hosts_test.go +++ b/libgo/go/net/hosts_test.go @@ -5,6 +5,7 @@ package net import ( + "sort" "testing" ) @@ -51,3 +52,17 @@ func TestLookupStaticHost(t *testing.T) { } hostsPath = p } + +func TestLookupHost(t *testing.T) { + // Can't depend on this to return anything in particular, + // but if it does return something, make sure it doesn't + // duplicate addresses (a common bug due to the way + // getaddrinfo works). + addrs, _ := LookupHost("localhost") + sort.SortStrings(addrs) + for i := 0; i+1 < len(addrs); i++ { + if addrs[i] == addrs[i+1] { + t.Fatalf("LookupHost(\"localhost\") = %v, has duplicate addresses", addrs) + } + } +} |