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.
4
5package runtime_test
6
7import (
8	"runtime"
9	"strings"
10	"testing"
11)
12
13var _ = runtime.Caller
14var _ = strings.HasSuffix
15type _ testing.T
16
17/* runtime.Caller is not fully implemented for gccgo.
18
19func 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)
26			}
27			c <- true
28		}()
29		defer func() {
30			<-c
31		}()
32	}
33}
34
35func testCallerFoo(t *testing.T) {
36	testCallerBar(t)
37}
38
39func 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)
51		}
52	}
53}
54
55*/
56