]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix TestLookupDotsWithLocalSource
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 21 Jan 2016 08:22:30 +0000 (17:22 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Sat, 23 Jan 2016 01:28:06 +0000 (01:28 +0000)
Fixes #14050.

Change-Id: I2d9c32213b0da35703edf28f92ed3efb23325921
Reviewed-on: https://go-review.googlesource.com/18792
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/lookup_test.go

index 677a5f57fd48effb89d9ff5ecc6302d3325c375a..de4c4bd729cc6a47f91764119f0988eff97f9b3b 100644 (file)
@@ -441,8 +441,19 @@ func TestLookupDotsWithLocalSource(t *testing.T) {
                if i == 1 {
                        mode = "netcgo"
                }
-               for _, name := range names {
+       loop:
+               for i, name := range names {
                        if strings.Index(name, ".") == len(name)-1 { // "localhost" not "localhost."
+                               for j := range names {
+                                       if j == i {
+                                               continue
+                                       }
+                                       if names[j] == name[:len(name)-1] {
+                                               // It's OK if we find the name without the dot,
+                                               // as some systems say 127.0.0.1 localhost localhost.
+                                               continue loop
+                                       }
+                               }
                                t.Errorf("%s: got %s; want %s", mode, name, name[:len(name)-1])
                        } else if strings.Contains(name, ".") && !strings.HasSuffix(name, ".") { // "localhost.localdomain." not "localhost.localdomain"
                                t.Errorf("%s: got %s; want name ending with trailing dot", mode, name)