diff options
Diffstat (limited to 'libgo/go/net/hosts_test.go')
-rw-r--r-- | libgo/go/net/hosts_test.go | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/libgo/go/net/hosts_test.go b/libgo/go/net/hosts_test.go index aca64c38b05..4c67bfa9824 100644 --- a/libgo/go/net/hosts_test.go +++ b/libgo/go/net/hosts_test.go @@ -6,6 +6,7 @@ package net import ( "reflect" + "strings" "testing" ) @@ -48,6 +49,13 @@ var lookupStaticHostTests = []struct { {"localhost.localdomain", []string{"fe80::3%lo0"}}, }, }, + { + "testdata/case-hosts", // see golang.org/issue/12806 + []staticHostEntry{ + {"PreserveMe", []string{"127.0.0.1", "::1"}}, + {"PreserveMe.local", []string{"127.0.0.1", "::1"}}, + }, + }, } func TestLookupStaticHost(t *testing.T) { @@ -56,9 +64,12 @@ func TestLookupStaticHost(t *testing.T) { for _, tt := range lookupStaticHostTests { testHookHostsPath = tt.name for _, ent := range tt.ents { - addrs := lookupStaticHost(ent.in) - if !reflect.DeepEqual(addrs, ent.out) { - t.Errorf("%s, lookupStaticHost(%s) = %v; want %v", tt.name, ent.in, addrs, ent.out) + ins := []string{ent.in, absDomainName([]byte(ent.in)), strings.ToLower(ent.in), strings.ToUpper(ent.in)} + for _, in := range ins { + addrs := lookupStaticHost(in) + if !reflect.DeepEqual(addrs, ent.out) { + t.Errorf("%s, lookupStaticHost(%s) = %v; want %v", tt.name, in, addrs, ent.out) + } } } } @@ -103,6 +114,13 @@ var lookupStaticAddrTests = []struct { {"fe80::3%lo0", []string{"localhost", "localhost.localdomain"}}, }, }, + { + "testdata/case-hosts", // see golang.org/issue/12806 + []staticHostEntry{ + {"127.0.0.1", []string{"PreserveMe", "PreserveMe.local"}}, + {"::1", []string{"PreserveMe", "PreserveMe.local"}}, + }, + }, } func TestLookupStaticAddr(t *testing.T) { @@ -112,6 +130,9 @@ func TestLookupStaticAddr(t *testing.T) { testHookHostsPath = tt.name for _, ent := range tt.ents { hosts := lookupStaticAddr(ent.in) + for i := range ent.out { + ent.out[i] = absDomainName([]byte(ent.out[i])) + } if !reflect.DeepEqual(hosts, ent.out) { t.Errorf("%s, lookupStaticAddr(%s) = %v; want %v", tt.name, ent.in, hosts, ent.out) } |