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 g := newGoroutineLock()
15 g.check()
16
17 sawPanic := make(chan interface{})
18 go func() {
19 defer func() { sawPanic <- recover() }()
20 g.check()
21 }()
22 e := <-sawPanic
23 if e == nil {
24 t.Fatal("did not see panic from check in other goroutine")
25 }
26 if !strings.Contains(fmt.Sprint(e), "wrong goroutine") {
27 t.Errorf("expected on see panic about running on the wrong goroutine; got %v", e)
28 }
29 }
30
View as plain text