Skip to content

Commit 8ac0a7c

Browse files
cosnicolaoucherrymui
authored andcommitted
runtime/pprof: continued attempt to deflake the VMInfo test.
This PR will use test.Skip to bypass a test run for which the vmmap subprocess appears to hang before the test times out. In addition it catches a different error message from vmmap that can occur due to transient resource shortages and triggers a retry for this additional case. Fixes #62352 Change-Id: I3ae749e5cd78965c45b1b7c689b896493aa37ba0 Reviewed-on: https://go-review.googlesource.com/c/go/+/560935 Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 992f635 commit 8ac0a7c

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/runtime/pprof/vminfo_darwin_test.go

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"strconv"
1818
"strings"
1919
"testing"
20+
"time"
2021
)
2122

2223
func TestVMInfo(t *testing.T) {
@@ -56,18 +57,35 @@ func TestVMInfo(t *testing.T) {
5657
}
5758
}
5859

60+
type mapping struct {
61+
hi, lo uint64
62+
err error
63+
}
64+
5965
func useVMMapWithRetry(t *testing.T) (hi, lo uint64, err error) {
6066
var retryable bool
61-
for {
62-
hi, lo, retryable, err = useVMMap(t)
63-
if err == nil {
64-
return hi, lo, nil
65-
}
66-
if !retryable {
67-
return 0, 0, err
67+
ch := make(chan mapping)
68+
go func() {
69+
for {
70+
hi, lo, retryable, err = useVMMap(t)
71+
if err == nil {
72+
ch <- mapping{hi, lo, nil}
73+
return
74+
}
75+
if !retryable {
76+
ch <- mapping{0, 0, err}
77+
return
78+
}
79+
t.Logf("retrying vmmap after error: %v", err)
6880
}
69-
t.Logf("retrying vmmap after error: %v", err)
81+
}()
82+
select {
83+
case m := <-ch:
84+
return m.hi, m.lo, m.err
85+
case <-time.After(time.Minute):
86+
t.Skip("vmmap taking too long")
7087
}
88+
return 0, 0, fmt.Errorf("unreachable")
7189
}
7290

7391
func useVMMap(t *testing.T) (hi, lo uint64, retryable bool, err error) {

0 commit comments

Comments
 (0)