...
1
2
3
4
5 package http2
6
7 import (
8 "fmt"
9 "strings"
10 "testing"
11 )
12
13 func TestGoroutineLock(t *testing.T) {
14 oldDebug := DebugGoroutines
15 DebugGoroutines = true
16 defer func() { DebugGoroutines = oldDebug }()
17
18 g := newGoroutineLock()
19 g.check()
20
21 sawPanic := make(chan interface{})
22 go func() {
23 defer func() { sawPanic <- recover() }()
24 g.check()
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 }
34
View as plain text