]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/httptest: add test for issue 7264
authorDmitriy Vyukov <dvyukov@google.com>
Fri, 11 Apr 2014 09:01:10 +0000 (13:01 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Fri, 11 Apr 2014 09:01:10 +0000 (13:01 +0400)
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

src/pkg/net/http/httptest/server_test.go

index 500a9f0b80000b93a1c85f9f6fd1689e487c7239..14f8bed18ee245f9db9314a91e1582b3dd872ada 100644 (file)
@@ -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()
+                       }
+               }()
+       }
+}