From 97e3fc261cc326747b86aae87d3c48b20bf0d5ed Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Mon, 13 Mar 2017 18:45:53 +0100 Subject: [PATCH] proc/tests: make TestStacktraceGoroutine more reliable (#764) One of those goroutines could also conceivably be stopped on line 8. --- pkg/proc/proc_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index 3d157932..2814e09c 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -799,8 +799,7 @@ func stackMatch(stack []loc, locations []Stackframe, skipRuntime bool) bool { func TestStacktraceGoroutine(t *testing.T) { mainStack := []loc{{13, "main.stacktraceme"}, {26, "main.main"}} - agoroutineStackA := []loc{{9, "main.agoroutine"}} - agoroutineStackB := []loc{{10, "main.agoroutine"}} + agoroutineStacks := [][]loc{[]loc{{8, "main.agoroutine"}}, []loc{{9, "main.agoroutine"}}, []loc{{10, "main.agoroutine"}}} withTestProcess("goroutinestackprog", t, func(p *Process, fixture protest.Fixture) { bp, err := setFunctionBreakpoint(p, "main.stacktraceme") @@ -826,9 +825,14 @@ func TestStacktraceGoroutine(t *testing.T) { mainCount++ } - if stackMatch(agoroutineStackA, locations, true) { - agoroutineCount++ - } else if stackMatch(agoroutineStackB, locations, true) { + found := false + for _, agoroutineStack := range agoroutineStacks { + if stackMatch(agoroutineStack, locations, true) { + found = true + } + } + + if found { agoroutineCount++ } else { t.Logf("Non-goroutine stack: %d (%d)", i, len(locations))