From: Dmitriy Vyukov Date: Fri, 11 Apr 2014 09:01:10 +0000 (+0400) Subject: net/http/httptest: add test for issue 7264 X-Git-Tag: go1.3beta1~110 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=388d5330ac64eb4f2e3ad0635bf1a440c07923ca;p=gostls13.git net/http/httptest: add test for issue 7264 The test fails now with -race, so it's disabled. The intention is that the fix for issue 7264 will also modify this test the same way and enable it. Reporduce with 'go test -race -issue7264 -cpu=4'. Update #7264 LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/86770043 --- diff --git a/src/pkg/net/http/httptest/server_test.go b/src/pkg/net/http/httptest/server_test.go index 500a9f0b80..14f8bed18e 100644 --- a/src/pkg/net/http/httptest/server_test.go +++ b/src/pkg/net/http/httptest/server_test.go @@ -5,9 +5,11 @@ package httptest import ( + "flag" "io/ioutil" "net/http" "testing" + "time" ) func TestServer(t *testing.T) { @@ -27,3 +29,26 @@ func TestServer(t *testing.T) { t.Errorf("got %q, want hello", string(got)) } } + +var testIssue7264 = flag.Bool("issue7264", false, "enable failing test for issue 7264") + +func TestIssue7264(t *testing.T) { + if !*testIssue7264 { + t.Skip("skipping failing test for issue 7264") + } + for i := 0; i < 1000; i++ { + func() { + ts := NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) + defer ts.Close() + tr := &http.Transport{ + ResponseHeaderTimeout: time.Nanosecond, + } + defer tr.CloseIdleConnections() + c := &http.Client{Transport: tr} + res, err := c.Get(ts.URL) + if err == nil { + res.Body.Close() + } + }() + } +}