diff options
author | Ian Lance Taylor <iant@golang.org> | 2016-12-12 16:53:12 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2016-12-13 01:56:36 +0000 |
commit | c06b10ae9df81ea3ffdfe118a92410da4e153fea (patch) | |
tree | 0f79d0c5d2f413f6e2d3c9580ead3126600d008c /src/os/exec/exec_test.go | |
parent | d986daec1375527ef78cd59d81d42be7406a9803 (diff) | |
download | go-c06b10ae9df81ea3ffdfe118a92410da4e153fea.tar.gz go-c06b10ae9df81ea3ffdfe118a92410da4e153fea.zip |
os/exec: fix race in TestStdinCloseRace
The test for the race detector itself had a race of a sort not
detected by the race detector.
Fixes #18286.
Change-Id: I3265eae275aaa2869a6b6d3e8675b0d88b25831b
Reviewed-on: https://go-review.googlesource.com/34287
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/os/exec/exec_test.go')
-rw-r--r-- | src/os/exec/exec_test.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 4052e71042..34337450a0 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -247,6 +247,11 @@ func TestStdinClose(t *testing.T) { } // Issue 17647. +// It used to be the case that TestStdinClose, above, would fail when +// run under the race detector. This test is a variant of TestStdinClose +// that also used to fail when run under the race detector. +// This test is run by cmd/dist under the race detector to verify that +// the race detector no longer reports any problems. func TestStdinCloseRace(t *testing.T) { cmd := helperCommand(t, "stdinClose") stdin, err := cmd.StdinPipe() @@ -262,7 +267,12 @@ func TestStdinCloseRace(t *testing.T) { } }() go func() { - io.Copy(stdin, strings.NewReader(stdinCloseTestString)) + // Send the wrong string, so that the child fails even + // if the other goroutine doesn't manage to kill it first. + // This test is to check that the race detector does not + // falsely report an error, so it doesn't matter how the + // child process fails. + io.Copy(stdin, strings.NewReader("unexpected string")) if err := stdin.Close(); err != nil { t.Errorf("stdin.Close: %v", err) } |