Skip to content

Commit 4f40182

Browse files
committed
net: fix TestLookupDotsWithLocalSource
Fixes #14050. Change-Id: I2d9c32213b0da35703edf28f92ed3efb23325921 Reviewed-on: https://go-review.googlesource.com/18792 Run-TryBot: Mikio Hara <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 2a09a68 commit 4f40182

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/net/lookup_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,19 @@ func TestLookupDotsWithLocalSource(t *testing.T) {
441441
if i == 1 {
442442
mode = "netcgo"
443443
}
444-
for _, name := range names {
444+
loop:
445+
for i, name := range names {
445446
if strings.Index(name, ".") == len(name)-1 { // "localhost" not "localhost."
447+
for j := range names {
448+
if j == i {
449+
continue
450+
}
451+
if names[j] == name[:len(name)-1] {
452+
// It's OK if we find the name without the dot,
453+
// as some systems say 127.0.0.1 localhost localhost.
454+
continue loop
455+
}
456+
}
446457
t.Errorf("%s: got %s; want %s", mode, name, name[:len(name)-1])
447458
} else if strings.Contains(name, ".") && !strings.HasSuffix(name, ".") { // "localhost.localdomain." not "localhost.localdomain"
448459
t.Errorf("%s: got %s; want name ending with trailing dot", mode, name)

0 commit comments

Comments
 (0)