mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/pprof: skip profiling tests on mips if highres timers not available
Fixes #17936 Change-Id: I20d09712b7d7303257994356904052ba64bc5bf2 Reviewed-on: https://go-review.googlesource.com/33306 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
e279280d0d
commit
cd66c38619
1 changed files with 51 additions and 1 deletions
|
|
@ -8,9 +8,12 @@ package pprof_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/pprof/profile"
|
"internal/pprof/profile"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -343,8 +346,49 @@ func TestMathBigDivide(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func slurpString(r io.Reader) string {
|
||||||
|
slurp, _ := ioutil.ReadAll(r)
|
||||||
|
return string(slurp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLinuxKernelConfig() string {
|
||||||
|
if f, err := os.Open("/proc/config"); err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
return slurpString(f)
|
||||||
|
}
|
||||||
|
if f, err := os.Open("/proc/config.gz"); err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
r, err := gzip.NewReader(f)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return slurpString(r)
|
||||||
|
}
|
||||||
|
if f, err := os.Open("/boot/config"); err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
return slurpString(f)
|
||||||
|
}
|
||||||
|
uname, _ := exec.Command("uname, -r").Output()
|
||||||
|
if len(uname) > 0 {
|
||||||
|
if f, err := os.Open("/boot/config-" + string(uname)); err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
return slurpString(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func haveLinuxHiresTimers() bool {
|
||||||
|
config := getLinuxKernelConfig()
|
||||||
|
return strings.Contains(config, "CONFIG_HIGH_RES_TIMERS=y")
|
||||||
|
}
|
||||||
|
|
||||||
func TestStackBarrierProfiling(t *testing.T) {
|
func TestStackBarrierProfiling(t *testing.T) {
|
||||||
if (runtime.GOOS == "linux" && runtime.GOARCH == "arm") || runtime.GOOS == "openbsd" || runtime.GOOS == "solaris" || runtime.GOOS == "dragonfly" || runtime.GOOS == "freebsd" {
|
if (runtime.GOOS == "linux" && runtime.GOARCH == "arm") ||
|
||||||
|
runtime.GOOS == "openbsd" ||
|
||||||
|
runtime.GOOS == "solaris" ||
|
||||||
|
runtime.GOOS == "dragonfly" ||
|
||||||
|
runtime.GOOS == "freebsd" {
|
||||||
// This test currently triggers a large number of
|
// This test currently triggers a large number of
|
||||||
// usleep(100)s. These kernels/arches have poor
|
// usleep(100)s. These kernels/arches have poor
|
||||||
// resolution timers, so this gives up a whole
|
// resolution timers, so this gives up a whole
|
||||||
|
|
@ -357,6 +401,12 @@ func TestStackBarrierProfiling(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "linux" && strings.HasPrefix(runtime.GOARCH, "mips") {
|
||||||
|
if !haveLinuxHiresTimers() {
|
||||||
|
t.Skipf("low resolution timers inhibit profiling signals (golang.org/issue/13405, golang.org/issue/17936)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !strings.Contains(os.Getenv("GODEBUG"), "gcstackbarrierall=1") {
|
if !strings.Contains(os.Getenv("GODEBUG"), "gcstackbarrierall=1") {
|
||||||
// Re-execute this test with constant GC and stack
|
// Re-execute this test with constant GC and stack
|
||||||
// barriers at every frame.
|
// barriers at every frame.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue