mirror of
https://github.com/golang/net.git
synced 2026-03-31 02:17:08 +09:00
TestGoroutineLock sets DebugGoroutines = true. When a previous test leaves a server running after exiting, this write to DebugGoroutines can race with reads from the server. Obviously tests shouldn't leave goroutines around after they exit, but it happens and when it does it can show up here as a rare and hard-to-debug flake. DebugGoroutines is always true in tests, so there's no need to set it here. Just leave it alone. Fixes golang/go#75811 Change-Id: Iebeab2a22642cbd6867b9f4f5a171c91ea697b17 Reviewed-on: https://go-review.googlesource.com/c/net/+/710675 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Nicholas Husin <nsh@golang.org> Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org>
30 lines
660 B
Go
30 lines
660 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package http2
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGoroutineLock(t *testing.T) {
|
|
g := newGoroutineLock()
|
|
g.check()
|
|
|
|
sawPanic := make(chan interface{})
|
|
go func() {
|
|
defer func() { sawPanic <- recover() }()
|
|
g.check() // should panic
|
|
}()
|
|
e := <-sawPanic
|
|
if e == nil {
|
|
t.Fatal("did not see panic from check in other goroutine")
|
|
}
|
|
if !strings.Contains(fmt.Sprint(e), "wrong goroutine") {
|
|
t.Errorf("expected on see panic about running on the wrong goroutine; got %v", e)
|
|
}
|
|
}
|