tests: relax TestStacktraceGoroutine with Go 1.14

The test was always flaky because we can't fully control the state of
all goroutines in the target program, Go 1.14's asynchronous preemption
exacerbates the problem.

See for example:
https://travis-ci.com/github/go-delve/delve/jobs/302407282

This commit relaxes the checks made by the test to avoid irrelevante
flakiness.
This commit is contained in:
aarzilli 2020-03-25 16:36:32 +01:00 committed by Derek Parker
parent a61b6c0d7c
commit 1ee8d5c218
2 changed files with 29 additions and 2 deletions

@ -946,6 +946,19 @@ func TestStacktraceGoroutine(t *testing.T) {
{{10, "main.agoroutine"}},
}
tgtAgoroutineCount := 10
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 14) {
// We try to make sure that all goroutines are stopped at a sensible place
// before reading their stacktrace, but due to the nature of the test
// program there is no guarantee that we always find them in a reasonable
// state.
// Asynchronous preemption in Go 1.14 exacerbates this problem, to avoid
// unnecessary flakiness reduce the target count to 9, allowing one
// goroutine to be in a bad state.
tgtAgoroutineCount = 9
}
protest.AllowRecording(t)
withTestProcess("goroutinestackprog", t, func(p *proc.Target, fixture protest.Fixture) {
bp := setFunctionBreakpoint(p, t, "main.stacktraceme")
@ -995,7 +1008,7 @@ func TestStacktraceGoroutine(t *testing.T) {
t.Fatalf("Main goroutine stack not found %d", mainCount)
}
if agoroutineCount != 10 {
if agoroutineCount < tgtAgoroutineCount {
t.Fatalf("Goroutine stacks not found (%d)", agoroutineCount)
}

@ -847,9 +847,23 @@ func TestClientServer_FullStacktrace(t *testing.T) {
}
}
firsterr := false
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 14) {
// We try to make sure that all goroutines are stopped at a sensible place
// before reading their stacktrace, but due to the nature of the test
// program there is no guarantee that we always find them in a reasonable
// state.
// Asynchronous preemption in Go 1.14 exacerbates this problem, to avoid
// unnecessary flakiness allow a single goroutine to be in a bad state.
firsterr = true
}
for i := range found {
if !found[i] {
t.Fatalf("Goroutine %d not found", i)
if firsterr {
firsterr = false
} else {
t.Fatalf("Goroutine %d not found", i)
}
}
}