OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / net / http2 / gotrack_test.go
1 // 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
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() // 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 }