Commit 40cd845e authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: improve test leak checker flakiness

And make it have more useful output on failure.

Update #5005

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8016046
parent d1eb9c8e
......@@ -65,8 +65,6 @@ func afterTest(t *testing.T) {
if testing.Short() {
return
}
buf := make([]byte, 1<<20)
var stacks string
var bad string
badSubstring := map[string]string{
").readLoop(": "a Transport",
......@@ -75,9 +73,10 @@ func afterTest(t *testing.T) {
"timeoutHandler": "a TimeoutHandler",
"net.(*netFD).connect(": "a timing out dial",
}
var stacks string
for i := 0; i < 4; i++ {
bad = ""
stacks = string(buf[:runtime.Stack(buf, true)])
stacks = strings.Join(interestingGoroutines(), "\n\n")
for substr, what := range badSubstring {
if strings.Contains(stacks, substr) {
bad = what
......@@ -90,6 +89,5 @@ func afterTest(t *testing.T) {
// shutting down, so give it some time.
time.Sleep(250 * time.Millisecond)
}
gs := interestingGoroutines()
t.Errorf("Test appears to have leaked %s:\n%s", bad, strings.Join(gs, "\n\n"))
t.Errorf("Test appears to have leaked %s:\n%s", bad, stacks)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment