Commit ed99905e by Ian Lance Taylor

runtime: adjust tests for gofrontend

    
    - don't run tests that depend on SetCgoTraceback
    - don't expect a '(' after the function name in a traceback
    - change the expected name of nested functions in a traceback
    
    These tests are not currently run, but they will be soon.
    
    Reviewed-on: https://go-review.googlesource.com/46453

From-SVN: r249557
parent 2a208bc2
e017833e4ce4a3bc3ba02eac4351b15c86157ec0 a81079a81b63714221674f07d13bedc768092f27
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -251,6 +251,9 @@ func TestCgoCrashTraceback(t *testing.T) { ...@@ -251,6 +251,9 @@ func TestCgoCrashTraceback(t *testing.T) {
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" { if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
if runtime.Compiler == "gccgo" {
t.Skip("gccgo does not have SetCgoTraceback")
}
got := runTestProg(t, "testprogcgo", "CrashTraceback") got := runTestProg(t, "testprogcgo", "CrashTraceback")
for i := 1; i <= 3; i++ { for i := 1; i <= 3; i++ {
if !strings.Contains(got, fmt.Sprintf("cgo symbolizer:%d", i)) { if !strings.Contains(got, fmt.Sprintf("cgo symbolizer:%d", i)) {
...@@ -261,6 +264,9 @@ func TestCgoCrashTraceback(t *testing.T) { ...@@ -261,6 +264,9 @@ func TestCgoCrashTraceback(t *testing.T) {
func TestCgoTracebackContext(t *testing.T) { func TestCgoTracebackContext(t *testing.T) {
t.Parallel() t.Parallel()
if runtime.Compiler == "gccgo" {
t.Skip("gccgo does not have SetCgoTraceback")
}
got := runTestProg(t, "testprogcgo", "TracebackContext") got := runTestProg(t, "testprogcgo", "TracebackContext")
want := "OK\n" want := "OK\n"
if got != want { if got != want {
...@@ -273,6 +279,9 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) { ...@@ -273,6 +279,9 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) {
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" { if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
if runtime.Compiler == "gccgo" {
t.Skip("gccgo does not have SetCgoTraceback")
}
testenv.MustHaveGoRun(t) testenv.MustHaveGoRun(t)
exe, err := buildTestProg(t, "testprogcgo", buildArg) exe, err := buildTestProg(t, "testprogcgo", buildArg)
...@@ -332,6 +341,9 @@ func TestRaceProf(t *testing.T) { ...@@ -332,6 +341,9 @@ func TestRaceProf(t *testing.T) {
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" { if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
if runtime.Compiler == "gccgo" {
t.Skip("gccgo does not have SetCgoTraceback")
}
testenv.MustHaveGoRun(t) testenv.MustHaveGoRun(t)
......
...@@ -225,6 +225,9 @@ func TestGoexitDeadlock(t *testing.T) { ...@@ -225,6 +225,9 @@ func TestGoexitDeadlock(t *testing.T) {
} }
func TestStackOverflow(t *testing.T) { func TestStackOverflow(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("gccgo does not do stack overflow checking")
}
output := runTestProg(t, "testprog", "StackOverflow") output := runTestProg(t, "testprog", "StackOverflow")
want := "runtime: goroutine stack exceeds 1474560-byte limit\nfatal error: stack overflow" want := "runtime: goroutine stack exceeds 1474560-byte limit\nfatal error: stack overflow"
if !strings.HasPrefix(output, want) { if !strings.HasPrefix(output, want) {
...@@ -302,7 +305,7 @@ func TestNoHelperGoroutines(t *testing.T) { ...@@ -302,7 +305,7 @@ func TestNoHelperGoroutines(t *testing.T) {
func TestBreakpoint(t *testing.T) { func TestBreakpoint(t *testing.T) {
output := runTestProg(t, "testprog", "Breakpoint") output := runTestProg(t, "testprog", "Breakpoint")
want := "runtime.Breakpoint()" want := "runtime.Breakpoint"
if !strings.Contains(output, want) { if !strings.Contains(output, want) {
t.Fatalf("output:\n%s\n\nwant output containing: %s", output, want) t.Fatalf("output:\n%s\n\nwant output containing: %s", output, want)
} }
...@@ -419,8 +422,16 @@ func TestPanicTraceback(t *testing.T) { ...@@ -419,8 +422,16 @@ func TestPanicTraceback(t *testing.T) {
// Check functions in the traceback. // Check functions in the traceback.
fns := []string{"main.pt1.func1", "panic", "main.pt2.func1", "panic", "main.pt2", "main.pt1"} fns := []string{"main.pt1.func1", "panic", "main.pt2.func1", "panic", "main.pt2", "main.pt1"}
if runtime.Compiler == "gccgo" {
fns = []string{"main.$nested", "panic", "main.$nested", "panic", "main.pt2", "main.pt1"}
}
for _, fn := range fns { for _, fn := range fns {
re := regexp.MustCompile(`(?m)^` + regexp.QuoteMeta(fn) + `\(.*\n`) var re *regexp.Regexp
if runtime.Compiler != "gccgo" {
re = regexp.MustCompile(`(?m)^` + regexp.QuoteMeta(fn) + `\(.*\n`)
} else {
re = regexp.MustCompile(`(?m)^` + regexp.QuoteMeta(fn) + `.*\n`)
}
idx := re.FindStringIndex(output) idx := re.FindStringIndex(output)
if idx == nil { if idx == nil {
t.Fatalf("expected %q function in traceback:\n%s", fn, output) t.Fatalf("expected %q function in traceback:\n%s", fn, output)
...@@ -454,6 +465,9 @@ func TestPanicLoop(t *testing.T) { ...@@ -454,6 +465,9 @@ func TestPanicLoop(t *testing.T) {
func TestMemPprof(t *testing.T) { func TestMemPprof(t *testing.T) {
testenv.MustHaveGoRun(t) testenv.MustHaveGoRun(t)
if runtime.Compiler == "gccgo" {
t.Skip("gccgo may not have the pprof tool")
}
exe, err := buildTestProg(t, "testprog") exe, err := buildTestProg(t, "testprog")
if err != nil { if err != nil {
......
...@@ -105,7 +105,7 @@ func TestCrashDumpsAllThreads(t *testing.T) { ...@@ -105,7 +105,7 @@ func TestCrashDumpsAllThreads(t *testing.T) {
// Before https://golang.org/cl/2811 running threads would say // Before https://golang.org/cl/2811 running threads would say
// "goroutine running on other thread; stack unavailable". // "goroutine running on other thread; stack unavailable".
out = outbuf.Bytes() out = outbuf.Bytes()
n := bytes.Count(out, []byte("main.loop(")) n := bytes.Count(out, []byte("main.loop"))
if n != 4 { if n != 4 {
t.Errorf("found %d instances of main.loop; expected 4", n) t.Errorf("found %d instances of main.loop; expected 4", n)
t.Logf("%s", out) t.Logf("%s", out)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment