symtab_test.go 1.1 KB

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