Daily bump.
[official-gcc.git] / libgo / go / runtime / symtab_test.go
blob0db63c347fd709dcc8d437ee7106ce400e6951fe
1 // Copyright 2009 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.
5 package runtime_test
7 import (
8 "runtime"
9 "strings"
10 "testing"
13 var _ = runtime.Caller
14 var _ = strings.HasSuffix
15 type _ testing.T
17 /* runtime.Caller is not fully implemented for gccgo.
19 func TestCaller(t *testing.T) {
20 procs := runtime.GOMAXPROCS(-1)
21 c := make(chan bool, procs)
22 for p := 0; p < procs; p++ {
23 go func() {
24 for i := 0; i < 1000; i++ {
25 testCallerFoo(t)
27 c <- true
28 }()
29 defer func() {
30 <-c
31 }()
35 func testCallerFoo(t *testing.T) {
36 testCallerBar(t)
39 func testCallerBar(t *testing.T) {
40 for i := 0; i < 2; i++ {
41 pc, file, line, ok := runtime.Caller(i)
42 f := runtime.FuncForPC(pc)
43 if !ok ||
44 !strings.HasSuffix(file, "symtab_test.go") ||
45 (i == 0 && !strings.HasSuffix(f.Name(), "testCallerBar")) ||
46 (i == 1 && !strings.HasSuffix(f.Name(), "testCallerFoo")) ||
47 line < 5 || line > 1000 ||
48 f.Entry() >= pc {
49 t.Errorf("incorrect symbol info %d: %t %d %d %s %s %d",
50 i, ok, f.Entry(), pc, f.Name(), file, line)