summaryrefslogtreecommitdiff
path: root/src/pkg/net/hosts_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/net/hosts_test.go')
-rw-r--r--src/pkg/net/hosts_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pkg/net/hosts_test.go b/src/pkg/net/hosts_test.go
index 470e35f78..e5793eef2 100644
--- a/src/pkg/net/hosts_test.go
+++ b/src/pkg/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)
+ }
+ }
+}