aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2021-11-04 21:06:06 -0400
committerGopher Robot <gobot@golang.org>2022-04-25 18:12:08 +0000
commit60178e6240d6d0e52ca0556fcab29a1d3effef4d (patch)
treecddea9f9473a056c5059032ef385203d5ad2d939
parent8619d3b2ec5d23d39acb4968ce7938230e0728ad (diff)
downloadgo-60178e6240d6d0e52ca0556fcab29a1d3effef4d.tar.gz
go-60178e6240d6d0e52ca0556fcab29a1d3effef4d.zip
cmd/dist: add maymorestack tests
These tests run the runtime, reflect, and sync package tests with the two maymorestack hooks we have. These tests only run on the longtest builders (or with GO_TEST_SHORT=false) because we're running the runtime test two additional times and the mayMoreStackMove hook makes it about twice as slow (~230 seconds). To run just these tests by hand, do GO_TEST_SHORT=false go tool dist test -run mayMoreStack Updates #48297. This detected #49354, which was found as a flake on the dashboard, but was reliably reproducible with these tests; and #49395. Change-Id: If785a8b8d6e1b9ad4d2ae67493b54055ab6cbc85 Reviewed-on: https://go-review.googlesource.com/c/go/+/361212 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
-rw-r--r--src/cmd/dist/test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index ee521f81ba..7c8f1ea46d 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -556,6 +556,55 @@ func (t *tester) registerTests() {
})
}
+ // morestack tests. We only run these on in long-test mode
+ // (with GO_TEST_SHORT=false) because the runtime test is
+ // already quite long and mayMoreStackMove makes it about
+ // twice as slow.
+ if !t.compileOnly && short() == "false" {
+ // hooks is the set of maymorestack hooks to test with.
+ hooks := []string{"mayMoreStackPreempt", "mayMoreStackMove"}
+ // pkgs is the set of test packages to run.
+ pkgs := []string{"runtime", "reflect", "sync"}
+ // hookPkgs is the set of package patterns to apply
+ // the maymorestack hook to.
+ hookPkgs := []string{"runtime/...", "reflect", "sync"}
+ // unhookPkgs is the set of package patterns to
+ // exclude from hookPkgs.
+ unhookPkgs := []string{"runtime/testdata/..."}
+ for _, hook := range hooks {
+ // Construct the build flags to use the
+ // maymorestack hook in the compiler and
+ // assembler. We pass this via the GOFLAGS
+ // environment variable so that it applies to
+ // both the test itself and to binaries built
+ // by the test.
+ goFlagsList := []string{}
+ for _, flag := range []string{"-gcflags", "-asmflags"} {
+ for _, hookPkg := range hookPkgs {
+ goFlagsList = append(goFlagsList, flag+"="+hookPkg+"=-d=maymorestack=runtime."+hook)
+ }
+ for _, unhookPkg := range unhookPkgs {
+ goFlagsList = append(goFlagsList, flag+"="+unhookPkg+"=")
+ }
+ }
+ goFlags := strings.Join(goFlagsList, " ")
+
+ for _, pkg := range pkgs {
+ pkg := pkg
+ testName := hook + ":" + pkg
+ t.tests = append(t.tests, distTest{
+ name: testName,
+ heading: "maymorestack=" + hook,
+ fn: func(dt *distTest) error {
+ cmd := t.addCmd(dt, "src", t.goTest(), t.timeout(600), pkg, "-short")
+ setEnv(cmd, "GOFLAGS", goFlags)
+ return nil
+ },
+ })
+ }
+ }
+ }
+
// This test needs its stdout/stderr to be terminals, so we don't run it from cmd/go's tests.
// See issue 18153.
if goos == "linux" {