proc/tests: make TestStacktraceGoroutine more reliable (#764)
One of those goroutines could also conceivably be stopped on line 8.
This commit is contained in:
parent
cda7316421
commit
97e3fc261c
@ -799,8 +799,7 @@ func stackMatch(stack []loc, locations []Stackframe, skipRuntime bool) bool {
|
|||||||
|
|
||||||
func TestStacktraceGoroutine(t *testing.T) {
|
func TestStacktraceGoroutine(t *testing.T) {
|
||||||
mainStack := []loc{{13, "main.stacktraceme"}, {26, "main.main"}}
|
mainStack := []loc{{13, "main.stacktraceme"}, {26, "main.main"}}
|
||||||
agoroutineStackA := []loc{{9, "main.agoroutine"}}
|
agoroutineStacks := [][]loc{[]loc{{8, "main.agoroutine"}}, []loc{{9, "main.agoroutine"}}, []loc{{10, "main.agoroutine"}}}
|
||||||
agoroutineStackB := []loc{{10, "main.agoroutine"}}
|
|
||||||
|
|
||||||
withTestProcess("goroutinestackprog", t, func(p *Process, fixture protest.Fixture) {
|
withTestProcess("goroutinestackprog", t, func(p *Process, fixture protest.Fixture) {
|
||||||
bp, err := setFunctionBreakpoint(p, "main.stacktraceme")
|
bp, err := setFunctionBreakpoint(p, "main.stacktraceme")
|
||||||
@ -826,9 +825,14 @@ func TestStacktraceGoroutine(t *testing.T) {
|
|||||||
mainCount++
|
mainCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
if stackMatch(agoroutineStackA, locations, true) {
|
found := false
|
||||||
agoroutineCount++
|
for _, agoroutineStack := range agoroutineStacks {
|
||||||
} else if stackMatch(agoroutineStackB, locations, true) {
|
if stackMatch(agoroutineStack, locations, true) {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
agoroutineCount++
|
agoroutineCount++
|
||||||
} else {
|
} else {
|
||||||
t.Logf("Non-goroutine stack: %d (%d)", i, len(locations))
|
t.Logf("Non-goroutine stack: %d (%d)", i, len(locations))
|
||||||
|
Loading…
Reference in New Issue
Block a user