]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/fcgi: fix test
authorDmitry Vyukov <dvyukov@google.com>
Sun, 1 Mar 2015 13:23:55 +0000 (16:23 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Mon, 2 Mar 2015 06:59:29 +0000 (06:59 +0000)
Currently the test fails if run more than once:

$ go test -v -run=TestChildServeCleansUp -cpu=1,1 net/http/fcgi
=== RUN TestChildServeCleansUp
--- PASS: TestChildServeCleansUp (0.00s)
=== RUN TestChildServeCleansUp
fatal error: all goroutines are asleep - deadlock!

The problem is that the writer mutates test input data,
so it is wrong on the second execution.

Change-Id: I4ca54dd2926c6986b2908023ac65e5e65630ed26
Reviewed-on: https://go-review.googlesource.com/6383
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/fcgi/fcgi_test.go

index 74d91bf1347017b8f2cc901f024b8d2db3d72170..de0f7f831f61683a34dd6be8619f25e6e341002a 100644 (file)
@@ -233,7 +233,9 @@ func (nopWriteCloser) Close() error {
 // isn't met. See issue 6934.
 func TestChildServeCleansUp(t *testing.T) {
        for _, tt := range cleanUpTests {
-               rc := nopWriteCloser{bytes.NewBuffer(tt.input)}
+               input := make([]byte, len(tt.input))
+               copy(input, tt.input)
+               rc := nopWriteCloser{bytes.NewBuffer(input)}
                done := make(chan bool)
                c := newChild(rc, http.HandlerFunc(func(
                        w http.ResponseWriter,