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.
13 func TestGoroutineLock(t *testing.T) {
14 oldDebug := DebugGoroutines
15 DebugGoroutines = true
16 defer func() { DebugGoroutines = oldDebug }()
18 g := newGoroutineLock()
21 sawPanic := make(chan interface{})
23 defer func() { sawPanic <- recover() }()
24 g.check() // should panic
28 t.Fatal("did not see panic from check in other goroutine")
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)