blob: 3ff4957e97f12abfb7022f4625ff4c1f59525a95 [file] [log] [blame]
Brad Fitzpatrick6fe76312014-11-11 09:26:28 -06001// Copyright 2014 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4// See https://code.google.com/p/go/source/browse/CONTRIBUTORS
5// Licensed under the same terms as Go itself:
6// https://code.google.com/p/go/source/browse/LICENSE
7
8package http2
9
10import (
11 "fmt"
12 "strings"
13 "testing"
14)
15
16func TestGoroutineLock(t *testing.T) {
17 DebugGoroutines = true
18 g := newGoroutineLock()
19 g.check()
20
21 sawPanic := make(chan interface{})
22 go func() {
23 defer func() { sawPanic <- recover() }()
24 g.check() // should panic
25 }()
26 e := <-sawPanic
27 if e == nil {
28 t.Fatal("did not see panic from check in other goroutine")
29 }
30 if !strings.Contains(fmt.Sprint(e), "wrong goroutine") {
31 t.Errorf("expected on see panic about running on the wrong goroutine; got %v", e)
32 }
33}