From 04a3a74456fc32ff5a5197b4cb10640f270d19e4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 1 Mar 2015 16:23:55 +0300 Subject: [PATCH] net/http/fcgi: fix test 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 --- src/net/http/fcgi/fcgi_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/net/http/fcgi/fcgi_test.go b/src/net/http/fcgi/fcgi_test.go index 74d91bf134..de0f7f831f 100644 --- a/src/net/http/fcgi/fcgi_test.go +++ b/src/net/http/fcgi/fcgi_test.go @@ -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, -- 2.48.1