aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof/pprof_test.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2017-05-09 09:42:16 -0400
committerAustin Clements <austin@google.com>2017-05-09 15:04:46 +0000
commitd659682de2c16c2eeec3ea67d0cc8d8cbd052609 (patch)
tree5e20eb7bcead420a70873ee1cbcfaf24b132abb2 /src/runtime/pprof/pprof_test.go
parent9eacd977a0d2329ea5856db7ab9bf5130f7bafcc (diff)
downloadgo-d659682de2c16c2eeec3ea67d0cc8d8cbd052609.tar.xz
runtime/pprof: deflake TestGoroutineCounts
TestGoroutineCounts currently depends on timing to get 100 goroutines to a known blocking point before taking a profile. This fails frequently, with different goroutines captured at different stacks. The test is disabled on openbsd because it was too flaky, but in fact it flakes on all platforms. Fix this by using Gosched instead of timing. This is both much more reliable and makes the test run faster. Fixes #15156. Change-Id: Ia6e894196d717655b8fb4ee96df53f6cc8bc5f1f Reviewed-on: https://go-review.googlesource.com/42953 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/pprof/pprof_test.go')
-rw-r--r--src/runtime/pprof/pprof_test.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index fd942de567..f762fa5a6c 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -575,22 +575,21 @@ func func3(c chan int) { <-c }
func func4(c chan int) { <-c }
func TestGoroutineCounts(t *testing.T) {
- if runtime.GOOS == "openbsd" {
- testenv.SkipFlaky(t, 15156)
- }
c := make(chan int)
for i := 0; i < 100; i++ {
- if i%10 == 0 {
+ switch {
+ case i%10 == 0:
go func1(c)
- continue
- }
- if i%2 == 0 {
+ case i%2 == 0:
go func2(c)
- continue
+ default:
+ go func3(c)
+ }
+ // Let goroutines block on channel
+ for j := 0; j < 5; j++ {
+ runtime.Gosched()
}
- go func3(c)
}
- time.Sleep(10 * time.Millisecond) // let goroutines block on channel
var w bytes.Buffer
goroutineProf := Lookup("goroutine")