mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/pprof: deflake TestGoroutineCounts
TestGoroutineCounts was flaky when running on a system under load. This happened on three builds the last couple of days. Fix this by running this test with a single operating system thread, so we do not depend on the operating system scheduler. 50 000 tests ran without failure with the new version, the old version failed 0.5% of the time. Fixes #15156. Change-Id: I1e5a18d0fef4f72cc9a56e376822b2849cdb0f8b Reviewed-on: https://go-review.googlesource.com/43590 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
b3e577b9e7
commit
2dc27839df
1 changed files with 4 additions and 0 deletions
|
|
@ -602,6 +602,10 @@ func func3(c chan int) { <-c }
|
||||||
func func4(c chan int) { <-c }
|
func func4(c chan int) { <-c }
|
||||||
|
|
||||||
func TestGoroutineCounts(t *testing.T) {
|
func TestGoroutineCounts(t *testing.T) {
|
||||||
|
// Setting GOMAXPROCS to 1 ensures we can force all goroutines to the
|
||||||
|
// desired blocking point.
|
||||||
|
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
|
||||||
|
|
||||||
c := make(chan int)
|
c := make(chan int)
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
switch {
|
switch {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue