]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: continued attempt to deflake the VMInfo test.
authorCosmos Nicolaou <cosmos.nicolaou@gmail.com>
Sat, 3 Feb 2024 01:12:27 +0000 (17:12 -0800)
committerCherry Mui <cherryyz@google.com>
Sat, 16 Nov 2024 02:46:19 +0000 (02:46 +0000)
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 <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/runtime/pprof/vminfo_darwin_test.go

index 641587200c297f55c78175cff312c77b95624935..4c0a0fefd876000c62dcf211ed2c4cdd85dfd57b 100644 (file)
@@ -17,6 +17,7 @@ import (
        "strconv"
        "strings"
        "testing"
+       "time"
 )
 
 func TestVMInfo(t *testing.T) {
@@ -56,18 +57,35 @@ func TestVMInfo(t *testing.T) {
        }
 }
 
+type mapping struct {
+       hi, lo uint64
+       err    error
+}
+
 func useVMMapWithRetry(t *testing.T) (hi, lo uint64, err error) {
        var retryable bool
-       for {
-               hi, lo, retryable, err = useVMMap(t)
-               if err == nil {
-                       return hi, lo, nil
-               }
-               if !retryable {
-                       return 0, 0, err
+       ch := make(chan mapping)
+       go func() {
+               for {
+                       hi, lo, retryable, err = useVMMap(t)
+                       if err == nil {
+                               ch <- mapping{hi, lo, nil}
+                               return
+                       }
+                       if !retryable {
+                               ch <- mapping{0, 0, err}
+                               return
+                       }
+                       t.Logf("retrying vmmap after error: %v", err)
                }
-               t.Logf("retrying vmmap after error: %v", err)
+       }()
+       select {
+       case m := <-ch:
+               return m.hi, m.lo, m.err
+       case <-time.After(time.Minute):
+               t.Skip("vmmap taking too long")
        }
+       return 0, 0, fmt.Errorf("unreachable")
 }
 
 func useVMMap(t *testing.T) (hi, lo uint64, retryable bool, err error) {