diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/dist/test.go | 15 | ||||
| -rw-r--r-- | src/internal/testenv/testenv_test.go | 5 | ||||
| -rwxr-xr-x | src/run.bash | 7 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 78213a7a55..b09c3f2ce8 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -30,6 +30,8 @@ func cmdtest() { var t tester + t.asmflags = os.Getenv("GO_TEST_ASMFLAGS") + var noRebuild bool flag.BoolVar(&t.listMode, "list", false, "list available tests") flag.BoolVar(&t.rebuild, "rebuild", false, "rebuild everything first") @@ -63,6 +65,10 @@ type tester struct { failed bool keepGoing bool compileOnly bool // just try to compile all tests, but no need to run + short bool + cgoEnabled bool + asmflags string + json bool runRxStr string runRx *regexp.Regexp runRxWant bool // want runRx to match (true) or not match (false) @@ -70,10 +76,6 @@ type tester struct { banner string // prefix, or "" for none lastHeading string // last dir heading printed - short bool - cgoEnabled bool - json bool - tests []distTest // use addTest to extend testNames map[string]bool timeoutScale int @@ -478,6 +480,9 @@ func (opts *goTest) buildArgs(t *tester) (build, run, pkgs, testFlags []string, if opts.ldflags != "" { build = append(build, "-ldflags="+opts.ldflags) } + if t.asmflags != "" { + build = append(build, "-asmflags="+t.asmflags) + } if opts.buildmode != "" { build = append(build, "-buildmode="+opts.buildmode) } @@ -806,7 +811,7 @@ func (t *tester) registerTests() { } // Spectre mitigation smoke test. - if goos == "linux" && goarch == "amd64" { + if goos == "linux" && goarch == "amd64" && !(gogcflags == "-spectre=all" && t.asmflags == "all=-spectre=all") { // Pick a bunch of packages known to have some assembly. pkgs := []string{"internal/runtime/...", "reflect", "crypto/..."} if !t.short { diff --git a/src/internal/testenv/testenv_test.go b/src/internal/testenv/testenv_test.go index 769db3a033..8313079983 100644 --- a/src/internal/testenv/testenv_test.go +++ b/src/internal/testenv/testenv_test.go @@ -97,8 +97,9 @@ func TestHasGoBuild(t *testing.T) { } } - if strings.Contains(b, "-noopt") { - // The -noopt builder sets GO_GCFLAGS, which causes tests of 'go build' to + if strings.Contains(b, "-noopt") || + strings.Contains(b, "-spectre") { + // These builders set GO_GCFLAGS, which causes tests of 'go build' to // be skipped. t.Logf("HasGoBuild is false on %s", b) return diff --git a/src/run.bash b/src/run.bash index cb474325c4..e774f03b30 100755 --- a/src/run.bash +++ b/src/run.bash @@ -21,6 +21,13 @@ # # GO_TEST_TIMEOUT_SCALE: a non-negative integer factor to scale test timeout by. # Defaults to 1. +# +# GO_TEST_ASMFLAGS: Additional go tool asm arguments to use when running the tests. +# This environment variable is an internal implementation detail between the +# Go build system (x/build) and cmd/dist to enable builders that need to control this, +# and will be removed if it stops being needed, or if a more general-purpose +# GO_ASMFLAGS environment variable gets added to make.bash and supersedes this +# test-only subset of it. See go.dev/issue/77427. set -e |
