Commit 22afca66 by Ian Lance Taylor

Fix race condition in test case.

Brought over from master repository.

From-SVN: r169106
parent 95cc031f
...@@ -27,7 +27,7 @@ var tests = []testCase{ ...@@ -27,7 +27,7 @@ var tests = []testCase{
{"a.b..com", false}, {"a.b..com", false},
} }
func getTestCases(ch chan<- *testCase) { func getTestCases(ch chan<- testCase) {
defer close(ch) defer close(ch)
var char59 = "" var char59 = ""
var char63 = "" var char63 = ""
...@@ -39,17 +39,17 @@ func getTestCases(ch chan<- *testCase) { ...@@ -39,17 +39,17 @@ func getTestCases(ch chan<- *testCase) {
char64 = char63 + "a" char64 = char63 + "a"
for _, tc := range tests { for _, tc := range tests {
ch <- &tc ch <- tc
} }
ch <- &testCase{char63 + ".com", true} ch <- testCase{char63 + ".com", true}
ch <- &testCase{char64 + ".com", false} ch <- testCase{char64 + ".com", false}
// 255 char name is fine: // 255 char name is fine:
ch <- &testCase{char59 + "." + char63 + "." + char63 + "." + ch <- testCase{char59 + "." + char63 + "." + char63 + "." +
char63 + ".com", char63 + ".com",
true} true}
// 256 char name is bad: // 256 char name is bad:
ch <- &testCase{char59 + "a." + char63 + "." + char63 + "." + ch <- testCase{char59 + "a." + char63 + "." + char63 + "." +
char63 + ".com", char63 + ".com",
false} false}
} }
...@@ -58,7 +58,7 @@ func TestDNSNames(t *testing.T) { ...@@ -58,7 +58,7 @@ func TestDNSNames(t *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
return return
} }
ch := make(chan *testCase) ch := make(chan testCase)
go getTestCases(ch) go getTestCases(ch)
for tc := range ch { for tc := range ch {
if isDomainName(tc.name) != tc.result { if isDomainName(tc.name) != tc.result {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment