Skip to content

Commit 60178e6

Browse files
aclementsgopherbot
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Austin Clements <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 8619d3b commit 60178e6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/cmd/dist/test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,55 @@ func (t *tester) registerTests() {
556556
})
557557
}
558558

559+
// morestack tests. We only run these on in long-test mode
560+
// (with GO_TEST_SHORT=false) because the runtime test is
561+
// already quite long and mayMoreStackMove makes it about
562+
// twice as slow.
563+
if !t.compileOnly && short() == "false" {
564+
// hooks is the set of maymorestack hooks to test with.
565+
hooks := []string{"mayMoreStackPreempt", "mayMoreStackMove"}
566+
// pkgs is the set of test packages to run.
567+
pkgs := []string{"runtime", "reflect", "sync"}
568+
// hookPkgs is the set of package patterns to apply
569+
// the maymorestack hook to.
570+
hookPkgs := []string{"runtime/...", "reflect", "sync"}
571+
// unhookPkgs is the set of package patterns to
572+
// exclude from hookPkgs.
573+
unhookPkgs := []string{"runtime/testdata/..."}
574+
for _, hook := range hooks {
575+
// Construct the build flags to use the
576+
// maymorestack hook in the compiler and
577+
// assembler. We pass this via the GOFLAGS
578+
// environment variable so that it applies to
579+
// both the test itself and to binaries built
580+
// by the test.
581+
goFlagsList := []string{}
582+
for _, flag := range []string{"-gcflags", "-asmflags"} {
583+
for _, hookPkg := range hookPkgs {
584+
goFlagsList = append(goFlagsList, flag+"="+hookPkg+"=-d=maymorestack=runtime."+hook)
585+
}
586+
for _, unhookPkg := range unhookPkgs {
587+
goFlagsList = append(goFlagsList, flag+"="+unhookPkg+"=")
588+
}
589+
}
590+
goFlags := strings.Join(goFlagsList, " ")
591+
592+
for _, pkg := range pkgs {
593+
pkg := pkg
594+
testName := hook + ":" + pkg
595+
t.tests = append(t.tests, distTest{
596+
name: testName,
597+
heading: "maymorestack=" + hook,
598+
fn: func(dt *distTest) error {
599+
cmd := t.addCmd(dt, "src", t.goTest(), t.timeout(600), pkg, "-short")
600+
setEnv(cmd, "GOFLAGS", goFlags)
601+
return nil
602+
},
603+
})
604+
}
605+
}
606+
}
607+
559608
// This test needs its stdout/stderr to be terminals, so we don't run it from cmd/go's tests.
560609
// See issue 18153.
561610
if goos == "linux" {

0 commit comments

Comments
 (0)