LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package net | 5 package net |
6 | 6 |
7 import ( | 7 import ( |
8 "flag" | 8 "flag" |
9 "fmt" | 9 "fmt" |
10 "io" | 10 "io" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 "%d.%d.%d.%d:80", | 45 "%d.%d.%d.%d:80", |
46 "www.google.com:80", | 46 "www.google.com:80", |
47 "%d.%d.%d.%d:http", | 47 "%d.%d.%d.%d:http", |
48 "www.google.com:http", | 48 "www.google.com:http", |
49 "%03d.%03d.%03d.%03d:0080", | 49 "%03d.%03d.%03d.%03d:0080", |
50 "[::ffff:%d.%d.%d.%d]:80", | 50 "[::ffff:%d.%d.%d.%d]:80", |
51 "[::ffff:%02x%02x:%02x%02x]:80", | 51 "[::ffff:%02x%02x:%02x%02x]:80", |
52 "[0:0:0:0:0000:ffff:%d.%d.%d.%d]:80", | 52 "[0:0:0:0:0000:ffff:%d.%d.%d.%d]:80", |
53 "[0:0:0:0:000000:ffff:%d.%d.%d.%d]:80", | 53 "[0:0:0:0:000000:ffff:%d.%d.%d.%d]:80", |
54 "[0:0:0:0:0:ffff::%d.%d.%d.%d]:80", | 54 "[0:0:0:0:0:ffff::%d.%d.%d.%d]:80", |
| 55 } |
| 56 |
| 57 func TestDNSThreadLimit(t *testing.T) { |
| 58 if testing.Short() || !*testExternal { |
| 59 t.Skip("skipping test to avoid external network") |
| 60 } |
| 61 |
| 62 const N = 10000 |
| 63 c := make(chan int, N) |
| 64 for i := 0; i < N; i++ { |
| 65 go func() { |
| 66 LookupIP(fmt.Sprintf("%d.net-test.golang.org", i)) |
| 67 c <- 1 |
| 68 }() |
| 69 } |
| 70 // Don't bother waiting for the stragglers; stop at 0.9 N. |
| 71 for i := 0; i < N*9/10; i++ { |
| 72 if i%100 == 0 { |
| 73 //println("TestDNSThreadLimit:", i) |
| 74 } |
| 75 <-c |
| 76 } |
| 77 |
| 78 // If we're still here, it worked. |
55 } | 79 } |
56 | 80 |
57 func TestDialGoogleIPv4(t *testing.T) { | 81 func TestDialGoogleIPv4(t *testing.T) { |
58 if testing.Short() || !*testExternal { | 82 if testing.Short() || !*testExternal { |
59 t.Skip("skipping test to avoid external network") | 83 t.Skip("skipping test to avoid external network") |
60 } | 84 } |
61 | 85 |
62 // Insert an actual IPv4 address for google.com | 86 // Insert an actual IPv4 address for google.com |
63 // into the table. | 87 // into the table. |
64 addrs, err := LookupIP("www.google.com") | 88 addrs, err := LookupIP("www.google.com") |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 for i := 0; i < len(googleaddrsipv6); i++ { | 171 for i := 0; i < len(googleaddrsipv6); i++ { |
148 addr := googleaddrsipv6[i] | 172 addr := googleaddrsipv6[i] |
149 if addr == "" { | 173 if addr == "" { |
150 continue | 174 continue |
151 } | 175 } |
152 t.Logf("-- %s --", addr) | 176 t.Logf("-- %s --", addr) |
153 doDial(t, "tcp", addr) | 177 doDial(t, "tcp", addr) |
154 doDial(t, "tcp6", addr) | 178 doDial(t, "tcp6", addr) |
155 } | 179 } |
156 } | 180 } |
LEFT | RIGHT |