1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
25 gogcflags = os.Getenv("GO_GCFLAGS")
31 flag.BoolVar(&t.listMode, "list", false, "list available tests")
32 flag.BoolVar(&t.rebuild, "rebuild", false, "rebuild everything first")
33 flag.BoolVar(&noRebuild, "no-rebuild", false, "overrides -rebuild (historical dreg)")
34 flag.BoolVar(&t.keepGoing, "k", false, "keep going even when error occurred")
35 flag.BoolVar(&t.race, "race", false, "run in race builder mode (different set of tests)")
36 flag.BoolVar(&t.compileOnly, "compile-only", false, "compile tests, but don't run them. This is for some builders. Not all dist tests respect this flag, but most do.")
37 flag.StringVar(&t.banner, "banner", "##### ", "banner prefix; blank means no section banners")
38 flag.StringVar(&t.runRxStr, "run", "",
39 "run only those tests matching the regular expression; empty means to run all. "+
40 "Special exception: if the string begins with '!', the match is inverted.")
41 flag.BoolVar(&t.msan, "msan", false, "run in memory sanitizer builder mode")
42 flag.BoolVar(&t.asan, "asan", false, "run in address sanitizer builder mode")
44 xflagparse(-1) // any number of args
52 // tester executes cmdtest.
61 compileOnly bool // just try to compile all tests, but no need to run
64 runRxWant bool // want runRx to match (true) or not match (false)
65 runNames []string // tests to run, exclusive with runRx; empty means all
66 banner string // prefix, or "" for none
67 lastHeading string // last dir heading printed
73 goExe string // For host tests
74 goTmpDir string // For host tests
91 // A distTest is a test run by dist test.
92 // Each test has a unique name and belongs to a group (heading)
93 type distTest struct {
94 name string // unique test name; may be filtered with -run flag
95 heading string // group section; this header is printed before the test is run.
96 fn func(*distTest) error
99 func (t *tester) run() {
100 timelog("start", "dist test")
102 os.Setenv("PATH", fmt.Sprintf("%s%c%s", gorootBin, os.PathListSeparator, os.Getenv("PATH")))
105 if v := os.Getenv("GO_TEST_SHORT"); v != "" {
106 short, err := strconv.ParseBool(v)
108 fatalf("invalid GO_TEST_SHORT %q: %v", v, err)
113 cmd := exec.Command(gorootBinGo, "env", "CGO_ENABLED", "GOEXE", "GOTMPDIR")
114 cmd.Stderr = new(bytes.Buffer)
115 slurp, err := cmd.Output()
117 fatalf("Error running %s: %v\n%s", cmd, err, cmd.Stderr)
119 parts := strings.Split(string(slurp), "\n")
121 fatalf("Error running %s: output contains <3 lines\n%s", cmd, cmd.Stderr)
123 t.cgoEnabled, _ = strconv.ParseBool(parts[0])
125 t.goTmpDir = parts[2]
127 if flag.NArg() > 0 && t.runRxStr != "" {
128 fatalf("the -run regular expression flag is mutually exclusive with test name arguments")
131 t.runNames = flag.Args()
133 // Set GOTRACEBACK to system if the user didn't set a level explicitly.
134 // Since we're running tests for Go, we want as much detail as possible
135 // if something goes wrong.
137 // Set it before running any commands just in case something goes wrong.
138 if ok := isEnvSet("GOTRACEBACK"); !ok {
139 if err := os.Setenv("GOTRACEBACK", "system"); err != nil {
141 log.Printf("Failed to set GOTRACEBACK: %v", err)
143 fatalf("Failed to set GOTRACEBACK: %v", err)
149 t.out("Building packages and commands.")
150 // Force rebuild the whole toolchain.
151 goInstall(toolenv(), gorootBinGo, append([]string{"-a"}, toolchain...)...)
155 if builder := os.Getenv("GO_BUILDER_NAME"); builder == "" {
156 // Ensure that installed commands are up to date, even with -no-rebuild,
157 // so that tests that run commands end up testing what's actually on disk.
158 // If everything is up-to-date, this is a no-op.
159 // We first build the toolchain twice to allow it to converge,
160 // as when we first bootstrap.
161 // See cmdbootstrap for a description of the overall process.
163 // On the builders, we skip this step: we assume that 'dist test' is
164 // already using the result of a clean build, and because of test sharding
165 // and virtualization we usually start with a clean GOCACHE, so we would
166 // end up rebuilding large parts of the standard library that aren't
167 // otherwise relevant to the actual set of packages under test.
168 goInstall(toolenv(), gorootBinGo, toolchain...)
169 goInstall(toolenv(), gorootBinGo, toolchain...)
170 goInstall(toolenv(), gorootBinGo, "cmd")
175 if s := os.Getenv("GO_TEST_TIMEOUT_SCALE"); s != "" {
176 t.timeoutScale, err = strconv.Atoi(s)
178 fatalf("failed to parse $GO_TEST_TIMEOUT_SCALE = %q as integer: %v", s, err)
182 if t.runRxStr != "" {
183 if t.runRxStr[0] == '!' {
185 t.runRxStr = t.runRxStr[1:]
189 t.runRx = regexp.MustCompile(t.runRxStr)
194 for _, tt := range t.tests {
200 for _, name := range t.runNames {
201 if !t.isRegisteredTestName(name) {
202 fatalf("unknown test %q", name)
206 // On a few builders, make GOROOT unwritable to catch tests writing to it.
207 if strings.HasPrefix(os.Getenv("GO_BUILDER_NAME"), "linux-") {
208 if os.Getuid() == 0 {
209 // Don't bother making GOROOT unwritable:
210 // we're running as root, so permissions would have no effect.
212 xatexit(t.makeGOROOTUnwritable())
216 if err := t.maybeLogMetadata(); err != nil {
219 log.Printf("Failed logging metadata: %v", err)
221 fatalf("Failed logging metadata: %v", err)
225 for _, dt := range t.tests {
226 if !t.shouldRunTest(dt.name) {
230 dt := dt // dt used in background after this iteration
231 if err := dt.fn(&dt); err != nil {
232 t.runPending(&dt) // in case that hasn't been done yet
235 log.Printf("Failed: %v", err)
237 fatalf("Failed: %v", err)
242 timelog("end", "dist test")
245 fmt.Println("\nFAILED")
247 } else if t.partial {
248 fmt.Println("\nALL TESTS PASSED (some were excluded)")
250 fmt.Println("\nALL TESTS PASSED")
254 func (t *tester) shouldRunTest(name string) bool {
256 return t.runRx.MatchString(name) == t.runRxWant
258 if len(t.runNames) == 0 {
261 for _, runName := range t.runNames {
269 func (t *tester) maybeLogMetadata() error {
271 // We need to run a subprocess to log metadata. Don't do that
272 // on compile-only runs.
275 t.out("Test execution environment.")
276 // Helper binary to print system metadata (CPU model, etc). This is a
277 // separate binary from dist so it need not build with the bootstrap
280 // TODO(prattmic): If we split dist bootstrap and dist test then this
281 // could be simplified to directly use internal/sysinfo here.
282 return t.dirCmd(filepath.Join(goroot, "src/cmd/internal/metadata"), gorootBinGo, []string{"run", "main.go"}).Run()
285 // goTest represents all options to a "go test" command. The final command will
286 // combine configuration from goTest and tester flags.
288 timeout time.Duration // If non-zero, override timeout
289 short bool // If true, force -short
290 tags []string // Build tags
291 race bool // Force -race
292 bench bool // Run benchmarks (briefly), not tests.
293 runTests string // Regexp of tests to run
294 cpu string // If non-empty, -cpu flag
295 goroot string // If non-empty, use alternate goroot for go command
297 gcflags string // If non-empty, build with -gcflags=all=X
298 ldflags string // If non-empty, build with -ldflags=X
299 buildmode string // If non-empty, -buildmode flag
301 dir string // If non-empty, run in GOROOT/src-relative directory dir
302 env []string // Environment variables to add, as KEY=VAL. KEY= unsets a variable
304 // We have both pkg and pkgs as a convenience. Both may be set, in which
305 // case they will be combined. If both are empty, the default is ".".
306 pkgs []string // Multiple packages to test
307 pkg string // A single package to test
309 testFlags []string // Additional flags accepted by this test
312 // bgCommand returns a go test Cmd. The result has Stdout and Stderr set to nil
313 // and is intended to be added to the work queue.
314 func (opts *goTest) bgCommand(t *tester) *exec.Cmd {
315 goCmd, build, run, pkgs, setupCmd := opts.buildArgs(t)
317 // Combine the flags.
318 args := append([]string{"test"}, build...)
320 args = append(args, "-c", "-o", os.DevNull)
322 args = append(args, run...)
324 args = append(args, pkgs...)
326 args = append(args, opts.testFlags...)
329 cmd := exec.Command(goCmd, args...)
335 // command returns a go test Cmd intended to be run immediately.
336 func (opts *goTest) command(t *tester) *exec.Cmd {
337 cmd := opts.bgCommand(t)
338 cmd.Stdout = os.Stdout
339 cmd.Stderr = os.Stderr
343 func (opts *goTest) run(t *tester) error {
344 return opts.command(t).Run()
347 // runHostTest runs a test that should be built and run on the host GOOS/GOARCH,
348 // but run with GOOS/GOARCH set to the target GOOS/GOARCH. This is for tests
349 // that do nothing but compile and run other binaries. If the host and target
350 // are different, then the assumption is that the target is running in an
351 // emulator and does not have a Go toolchain at all, so the test needs to run on
352 // the host, but its resulting binaries will be run through a go_exec wrapper
353 // that runs them on the target.
354 func (opts *goTest) runHostTest(t *tester) error {
355 goCmd, build, run, pkgs, setupCmd := opts.buildArgs(t)
357 // Build the host test binary
359 // We can't compile more than one package.
360 panic("host tests must have a single test package")
362 if len(opts.env) != 0 {
363 // It's not clear if these are for the host or the target.
364 panic("host tests must not have environment variables")
367 f, err := os.CreateTemp(t.goTmpDir, "test.test-*"+t.goExe)
369 fatalf("failed to create temporary file: %s", err)
373 xatexit(func() { os.Remove(bin) })
375 args := append([]string{"test", "-c", "-o", bin}, build...)
376 args = append(args, pkgs...)
377 cmd := exec.Command(goCmd, args...)
379 cmd.Stdout = os.Stdout
380 cmd.Stderr = os.Stderr
381 setEnv(cmd, "GOARCH", gohostarch)
382 setEnv(cmd, "GOOS", gohostos)
384 errprintf("%s\n", cmd)
386 if err := cmd.Run(); err != nil {
394 // Transform run flags to be passed directly to a test binary.
395 for i, f := range run {
396 if !strings.HasPrefix(f, "-") {
397 panic("run flag does not start with -: " + f)
399 run[i] = "-test." + f[1:]
403 args = append(run, opts.testFlags...)
404 cmd = exec.Command(bin, args...)
406 cmd.Stdout = os.Stdout
407 cmd.Stderr = os.Stderr
409 errprintf("%s\n", cmd)
414 // buildArgs is in internal helper for goTest that constructs the elements of
415 // the "go test" command line. goCmd is the path to the go command to use. build
416 // is the flags for building the test. run is the flags for running the test.
417 // pkgs is the list of packages to build and run.
419 // The caller is responsible for adding opts.testFlags, and must call setupCmd
420 // on the resulting exec.Cmd to set its directory and environment.
421 func (opts *goTest) buildArgs(t *tester) (goCmd string, build, run, pkgs []string, setupCmd func(*exec.Cmd)) {
423 if opts.goroot != "" {
424 goCmd = filepath.Join(opts.goroot, "bin", "go")
427 run = append(run, "-count=1") // Disallow caching
428 if opts.timeout != 0 {
429 d := opts.timeout * time.Duration(t.timeoutScale)
430 run = append(run, "-timeout="+d.String())
432 if opts.short || t.short {
433 run = append(run, "-short")
437 tags = append(tags, "lldb")
440 tags = append(tags, "noopt")
442 tags = append(tags, opts.tags...)
444 build = append(build, "-tags="+strings.Join(tags, ","))
446 if t.race || opts.race {
447 build = append(build, "-race")
450 build = append(build, "-msan")
453 build = append(build, "-asan")
457 run = append(run, "-run=^$")
458 // Run benchmarks as a smoke test
459 run = append(run, "-bench=.*", "-benchtime=.1s")
460 } else if opts.runTests != "" {
461 run = append(run, "-run="+opts.runTests)
464 run = append(run, "-cpu="+opts.cpu)
467 if opts.gcflags != "" {
468 build = append(build, "-gcflags=all="+opts.gcflags)
470 if opts.ldflags != "" {
471 build = append(build, "-ldflags="+opts.ldflags)
473 if opts.buildmode != "" {
474 build = append(build, "-buildmode="+opts.buildmode)
479 pkgs = append(pkgs[:len(pkgs):len(pkgs)], opts.pkg)
486 if opts.goroot != "" {
487 thisGoroot = opts.goroot
491 if filepath.IsAbs(opts.dir) {
492 panic("dir must be relative, got: " + opts.dir)
494 dir = filepath.Join(thisGoroot, "src", opts.dir)
496 dir = filepath.Join(thisGoroot, "src")
498 setupCmd = func(cmd *exec.Cmd) {
500 if len(opts.env) != 0 {
501 for _, kv := range opts.env {
502 if i := strings.Index(kv, "="); i < 0 {
503 unsetEnv(cmd, kv[:len(kv)-1])
505 setEnv(cmd, kv[:i], kv[i+1:])
514 // ranGoTest and stdMatches are state closed over by the stdlib
515 // testing func in registerStdTest below. The tests are run
516 // sequentially, so there's no need for locks.
518 // ranGoBench and benchMatches are the same, but are only used
525 benchMatches []string
528 func (t *tester) registerStdTest(pkg string) {
529 heading := "Testing packages."
530 testPrefix := "go_test:"
533 testName := testPrefix + pkg
534 if t.runRx == nil || t.runRx.MatchString(testName) == t.runRxWant {
535 stdMatches = append(stdMatches, pkg)
538 t.tests = append(t.tests, distTest{
541 fn: func(dt *distTest) error {
546 timelog("start", dt.name)
547 defer timelog("end", dt.name)
550 timeoutSec := 180 * time.Second
551 for _, pkg := range stdMatches {
566 func (t *tester) registerRaceBenchTest(pkg string) {
567 testName := "go_test_bench:" + pkg
568 if t.runRx == nil || t.runRx.MatchString(testName) == t.runRxWant {
569 benchMatches = append(benchMatches, pkg)
571 t.tests = append(t.tests, distTest{
573 heading: "Running benchmarks briefly.",
574 fn: func(dt *distTest) error {
579 timelog("start", dt.name)
580 defer timelog("end", dt.name)
583 timeout: 1200 * time.Second, // longer timeout for race with benchmarks
593 func (t *tester) registerTests() {
594 // registerStdTestSpecially tracks import paths in the standard library
595 // whose test registration happens in a special way.
596 registerStdTestSpecially := map[string]bool{
597 "internal/testdir": true, // Registered at the bottom with sharding.
598 // cgo tests are registered specially because they involve unusual build
599 // conditions and flags.
600 "cmd/cgo/internal/teststdio": true,
601 "cmd/cgo/internal/testlife": true,
602 "cmd/cgo/internal/testfortran": true,
603 "cmd/cgo/internal/test": true,
604 "cmd/cgo/internal/testnocgo": true,
605 "cmd/cgo/internal/testtls": true,
606 "cmd/cgo/internal/testgodefs": true,
607 "cmd/cgo/internal/testso": true,
608 "cmd/cgo/internal/testsovar": true,
609 "cmd/cgo/internal/testcarchive": true,
610 "cmd/cgo/internal/testcshared": true,
611 "cmd/cgo/internal/testshared": true,
612 "cmd/cgo/internal/testplugin": true,
613 "cmd/cgo/internal/testsanitizers": true,
614 "cmd/cgo/internal/testerrors": true,
617 // Fast path to avoid the ~1 second of `go list std cmd` when
618 // the caller lists specific tests to run. (as the continuous
619 // build coordinator does).
620 if len(t.runNames) > 0 {
621 for _, name := range t.runNames {
622 if strings.HasPrefix(name, "go_test:") {
623 t.registerStdTest(strings.TrimPrefix(name, "go_test:"))
625 if strings.HasPrefix(name, "go_test_bench:") {
626 t.registerRaceBenchTest(strings.TrimPrefix(name, "go_test_bench:"))
630 // Use a format string to only list packages and commands that have tests.
631 const format = "{{if (or .TestGoFiles .XTestGoFiles)}}{{.ImportPath}}{{end}}"
632 cmd := exec.Command(gorootBinGo, "list", "-f", format)
634 cmd.Args = append(cmd.Args, "-tags=race")
636 cmd.Args = append(cmd.Args, "std", "cmd")
637 cmd.Stderr = new(bytes.Buffer)
638 all, err := cmd.Output()
640 fatalf("Error running go list std cmd: %v:\n%s", err, cmd.Stderr)
642 pkgs := strings.Fields(string(all))
643 for _, pkg := range pkgs {
644 if registerStdTestSpecially[pkg] {
647 t.registerStdTest(pkg)
650 for _, pkg := range pkgs {
651 if registerStdTestSpecially[pkg] {
654 if t.packageHasBenchmarks(pkg) {
655 t.registerRaceBenchTest(pkg)
665 // Test the os/user package in the pure-Go mode too.
667 t.registerTest("osusergo", "os/user with tag osusergo",
669 timeout: 300 * time.Second,
670 tags: []string{"osusergo"},
673 t.registerTest("purego:hash/maphash", "hash/maphash purego implementation",
675 timeout: 300 * time.Second,
676 tags: []string{"purego"},
681 // Test ios/amd64 for the iOS simulator.
682 if goos == "darwin" && goarch == "amd64" && t.cgoEnabled {
683 t.registerTest("amd64ios", "GOOS=ios on darwin/amd64",
685 timeout: 300 * time.Second,
686 runTests: "SystemRoots",
687 env: []string{"GOOS=ios", "CGO_ENABLED=1"},
692 // Runtime CPU tests.
693 if !t.compileOnly && t.hasParallelism() {
694 t.registerTest("runtime:cpu124", "GOMAXPROCS=2 runtime -cpu=1,2,4 -quick",
696 timeout: 300 * time.Second,
699 testFlags: []string{"-quick"},
700 // We set GOMAXPROCS=2 in addition to -cpu=1,2,4 in order to test runtime bootstrap code,
701 // creation of first goroutines and first garbage collections in the parallel setting.
702 env: []string{"GOMAXPROCS=2"},
707 // morestack tests. We only run these on in long-test mode
708 // (with GO_TEST_SHORT=false) because the runtime test is
709 // already quite long and mayMoreStackMove makes it about
711 if !t.compileOnly && !t.short {
712 // hooks is the set of maymorestack hooks to test with.
713 hooks := []string{"mayMoreStackPreempt", "mayMoreStackMove"}
714 // pkgs is the set of test packages to run.
715 pkgs := []string{"runtime", "reflect", "sync"}
716 // hookPkgs is the set of package patterns to apply
717 // the maymorestack hook to.
718 hookPkgs := []string{"runtime/...", "reflect", "sync"}
719 // unhookPkgs is the set of package patterns to
720 // exclude from hookPkgs.
721 unhookPkgs := []string{"runtime/testdata/..."}
722 for _, hook := range hooks {
723 // Construct the build flags to use the
724 // maymorestack hook in the compiler and
725 // assembler. We pass this via the GOFLAGS
726 // environment variable so that it applies to
727 // both the test itself and to binaries built
729 goFlagsList := []string{}
730 for _, flag := range []string{"-gcflags", "-asmflags"} {
731 for _, hookPkg := range hookPkgs {
732 goFlagsList = append(goFlagsList, flag+"="+hookPkg+"=-d=maymorestack=runtime."+hook)
734 for _, unhookPkg := range unhookPkgs {
735 goFlagsList = append(goFlagsList, flag+"="+unhookPkg+"=")
738 goFlags := strings.Join(goFlagsList, " ")
740 for _, pkg := range pkgs {
741 t.registerTest(hook+":"+pkg, "maymorestack="+hook,
743 timeout: 600 * time.Second,
745 env: []string{"GOFLAGS=" + goFlags},
752 // On the builders only, test that a moved GOROOT still works.
753 // Fails on iOS because CC_FOR_TARGET refers to clangwrap.sh
754 // in the unmoved GOROOT.
755 // Fails on Android, js/wasm and wasip1/wasm with an exec format error.
756 // Fails on plan9 with "cannot find GOROOT" (issue #21016).
757 if os.Getenv("GO_BUILDER_NAME") != "" && goos != "android" && !t.iOS() && goos != "plan9" && goos != "js" && goos != "wasip1" {
758 t.tests = append(t.tests, distTest{
759 name: "moved_goroot",
760 heading: "moved GOROOT",
761 fn: func(dt *distTest) error {
763 timelog("start", dt.name)
764 defer timelog("end", dt.name)
765 moved := goroot + "-moved"
766 if err := os.Rename(goroot, moved); err != nil {
767 if goos == "windows" {
768 // Fails on Windows (with "Access is denied") if a process
769 // or binary is in this directory. For instance, using all.bat
770 // when run from c:\workdir\go\src fails here
771 // if GO_BUILDER_NAME is set. Our builders invoke tests
772 // a different way which happens to work when sharding
773 // tests, but we should be tolerant of the non-sharded
775 log.Printf("skipping test on Windows")
781 // Run `go test fmt` in the moved GOROOT, without explicitly setting
782 // GOROOT in the environment. The 'go' command should find itself.
787 unsetEnv(cmd, "GOROOT")
790 if rerr := os.Rename(moved, goroot); rerr != nil {
791 fatalf("failed to restore GOROOT: %v", rerr)
798 // Test that internal linking of standard packages does not
799 // require libgcc. This ensures that we can install a Go
800 // release on a system that does not have a C compiler
801 // installed and still build Go programs (that don't use cgo).
802 for _, pkg := range cgoPackages {
803 if !t.internalLink() {
807 // ARM libgcc may be Thumb, which internal linking does not support.
812 // What matters is that the tests build and start up.
813 // Skip expensive tests, especially x509 TestSystemRoots.
816 run = "TestTCPStress"
818 t.registerTest("nolibgcc:"+pkg, "Testing without libgcc.",
820 ldflags: "-linkmode=internal -libgcc=none",
826 // Stub out following test on alpine until 54354 resolved.
827 builderName := os.Getenv("GO_BUILDER_NAME")
828 disablePIE := strings.HasSuffix(builderName, "-alpine")
830 // Test internal linking of PIE binaries where it is supported.
831 if t.internalLinkPIE() && !disablePIE {
832 t.registerTest("pie_internal", "internal linking of -buildmode=pie",
834 timeout: 60 * time.Second,
836 ldflags: "-linkmode=internal",
837 env: []string{"CGO_ENABLED=0"},
840 // Also test a cgo package.
841 if t.cgoEnabled && t.internalLink() && !disablePIE {
842 t.registerTest("pie_internal_cgo", "internal linking of -buildmode=pie",
844 timeout: 60 * time.Second,
846 ldflags: "-linkmode=internal",
853 if t.hasParallelism() {
854 t.registerTest("sync_cpu", "sync -cpu=10",
856 timeout: 120 * time.Second,
862 if t.raceDetectorSupported() {
863 t.registerRaceTests()
866 if t.cgoEnabled && !t.iOS() {
867 // Disabled on iOS. golang.org/issue/15919
868 t.registerTest("cgo_teststdio", "", &goTest{dir: "cmd/cgo/internal/teststdio", timeout: 5 * time.Minute}, rtHostTest{})
869 t.registerTest("cgo_testlife", "", &goTest{dir: "cmd/cgo/internal/testlife", timeout: 5 * time.Minute}, rtHostTest{})
870 if goos != "android" {
871 t.registerTest("cgo_testfortran", "", &goTest{dir: "cmd/cgo/internal/testfortran", timeout: 5 * time.Minute}, rtHostTest{})
873 if t.hasSwig() && goos != "android" {
874 t.registerTest("swig_stdio", "", &goTest{dir: "../misc/swig/stdio"})
876 t.registerTest("swig_callback", "", &goTest{dir: "../misc/swig/callback"})
877 const cflags = "-flto -Wno-lto-type-mismatch -Wno-unknown-warning-option"
878 t.registerTest("swig_callback_lto", "",
880 dir: "../misc/swig/callback",
882 "CGO_CFLAGS=" + cflags,
883 "CGO_CXXFLAGS=" + cflags,
884 "CGO_LDFLAGS=" + cflags,
894 // Don't run these tests with $GO_GCFLAGS because most of them
895 // assume that they can run "go install" with no -gcflags and not
896 // recompile the entire standard library. If make.bash ran with
897 // special -gcflags, that's not true.
898 if t.cgoEnabled && gogcflags == "" {
899 t.registerTest("cgo_testgodefs", "", &goTest{dir: "cmd/cgo/internal/testgodefs", timeout: 5 * time.Minute}, rtHostTest{})
901 t.registerTest("cgo_testso", "", &goTest{dir: "cmd/cgo/internal/testso", timeout: 600 * time.Second})
902 t.registerTest("cgo_testsovar", "", &goTest{dir: "cmd/cgo/internal/testsovar", timeout: 600 * time.Second})
903 if t.supportedBuildmode("c-archive") {
904 t.registerTest("cgo_testcarchive", "", &goTest{dir: "cmd/cgo/internal/testcarchive", timeout: 5 * time.Minute}, rtHostTest{})
906 if t.supportedBuildmode("c-shared") {
907 t.registerTest("cgo_testcshared", "", &goTest{dir: "cmd/cgo/internal/testcshared", timeout: 5 * time.Minute}, rtHostTest{})
909 if t.supportedBuildmode("shared") {
910 t.registerTest("cgo_testshared", "", &goTest{dir: "cmd/cgo/internal/testshared", timeout: 600 * time.Second})
912 if t.supportedBuildmode("plugin") {
913 t.registerTest("cgo_testplugin", "", &goTest{dir: "cmd/cgo/internal/testplugin", timeout: 600 * time.Second})
915 if goos == "linux" || (goos == "freebsd" && goarch == "amd64") {
916 // because Pdeathsig of syscall.SysProcAttr struct used in cmd/cgo/internal/testsanitizers is only
917 // supported on Linux and FreeBSD.
918 t.registerTest("cgo_testsanitizers", "", &goTest{dir: "cmd/cgo/internal/testsanitizers", timeout: 5 * time.Minute}, rtHostTest{})
920 if t.hasBash() && goos != "android" && !t.iOS() && gohostos != "windows" {
921 t.registerTest("cgo_errors", "", &goTest{dir: "cmd/cgo/internal/testerrors", timeout: 5 * time.Minute}, rtHostTest{})
925 if goos != "android" && !t.iOS() {
926 // There are no tests in this directory, only benchmarks.
927 // Check that the test binary builds.
928 t.registerTest("bench_go1", "", &goTest{dir: "../test/bench/go1"})
930 if goos != "android" && !t.iOS() {
931 // Only start multiple test dir shards on builders,
932 // where they get distributed to multiple machines.
933 // See issues 20141 and 31834.
935 if os.Getenv("GO_BUILDER_NAME") != "" {
938 if n, err := strconv.Atoi(os.Getenv("GO_TEST_SHARDS")); err == nil {
941 for shard := 0; shard < nShards; shard++ {
943 fmt.Sprintf("test:%d_%d", shard, nShards),
946 dir: "internal/testdir",
947 testFlags: []string{fmt.Sprintf("-shard=%d", shard), fmt.Sprintf("-shards=%d", nShards)},
953 // Only run the API check on fast development platforms.
954 // Every platform checks the API on every GOOS/GOARCH/CGO_ENABLED combination anyway,
955 // so we really only need to run this check once anywhere to get adequate coverage.
956 // To help developers avoid trybot-only failures, we try to run on typical developer machines
957 // which is darwin,linux,windows/amd64 and darwin/arm64.
958 if goos == "darwin" || ((goos == "linux" || goos == "windows") && goarch == "amd64") {
959 t.registerTest("api", "", &goTest{dir: "cmd/api", timeout: 5 * time.Minute, testFlags: []string{"-check"}})
962 // Ensure that the toolchain can bootstrap itself.
963 // This test adds another ~45s to all.bash if run sequentially, so run it only on the builders.
964 if os.Getenv("GO_BUILDER_NAME") != "" && goos != "android" && !t.iOS() {
965 t.registerTest("reboot", "", &goTest{dir: "../misc/reboot", timeout: 5 * time.Minute}, rtHostTest{})
969 // isRegisteredTestName reports whether a test named testName has already
971 func (t *tester) isRegisteredTestName(testName string) bool {
972 for _, tt := range t.tests {
973 if tt.name == testName {
980 type registerTestOpt interface {
984 // rtSequential is a registerTest option that causes the registered test to run
986 type rtSequential struct{}
988 func (rtSequential) isRegisterTestOpt() {}
990 // rtPreFunc is a registerTest option that runs a pre function before running
992 type rtPreFunc struct {
993 pre func(*distTest) bool // Return false to skip the test
996 func (rtPreFunc) isRegisterTestOpt() {}
998 // rtHostTest is a registerTest option that indicates this is a host test that
999 // should be run using goTest.runHostTest. It implies rtSequential.
1000 type rtHostTest struct{}
1002 func (rtHostTest) isRegisterTestOpt() {}
1004 // registerTest registers a test that runs the given goTest.
1006 // If heading is "", it uses test.dir as the heading.
1007 func (t *tester) registerTest(name, heading string, test *goTest, opts ...registerTestOpt) {
1010 var preFunc func(*distTest) bool
1011 for _, opt := range opts {
1012 switch opt := opt.(type) {
1018 seq, hostTest = true, true
1021 if t.isRegisteredTestName(name) {
1022 panic("duplicate registered test name " + name)
1027 t.tests = append(t.tests, distTest{
1030 fn: func(dt *distTest) error {
1031 if preFunc != nil && !preFunc(dt) {
1037 return test.runHostTest(t)
1043 cmd: test.bgCommand(t),
1045 t.worklist = append(t.worklist, w)
1051 // bgDirCmd constructs a Cmd intended to be run in the background as
1052 // part of the worklist. The worklist runner will buffer its output
1053 // and replay it sequentially. The command will be run in dir.
1054 func (t *tester) bgDirCmd(dir, bin string, args ...string) *exec.Cmd {
1055 cmd := exec.Command(bin, args...)
1056 if filepath.IsAbs(dir) {
1059 setDir(cmd, filepath.Join(goroot, dir))
1064 // dirCmd constructs a Cmd intended to be run in the foreground.
1065 // The command will be run in dir, and Stdout and Stderr will go to os.Stdout
1067 func (t *tester) dirCmd(dir string, cmdline ...interface{}) *exec.Cmd {
1068 bin, args := flattenCmdline(cmdline)
1069 cmd := t.bgDirCmd(dir, bin, args...)
1070 cmd.Stdout = os.Stdout
1071 cmd.Stderr = os.Stderr
1073 errprintf("%s\n", strings.Join(cmd.Args, " "))
1078 // flattenCmdline flattens a mixture of string and []string as single list
1079 // and then interprets it as a command line: first element is binary, then args.
1080 func flattenCmdline(cmdline []interface{}) (bin string, args []string) {
1082 for _, x := range cmdline {
1083 switch x := x.(type) {
1085 list = append(list, x)
1087 list = append(list, x...)
1089 panic("invalid addCmd argument type: " + reflect.TypeOf(x).String())
1094 if !filepath.IsAbs(bin) {
1095 panic("command is not absolute: " + bin)
1097 return bin, list[1:]
1100 // addCmd adds a command to the worklist. Commands can be run in
1101 // parallel, but their output will be buffered and replayed in the
1102 // order they were added to worklist.
1103 func (t *tester) addCmd(dt *distTest, dir string, cmdline ...interface{}) *exec.Cmd {
1104 bin, args := flattenCmdline(cmdline)
1107 cmd: t.bgDirCmd(dir, bin, args...),
1109 t.worklist = append(t.worklist, w)
1113 func (t *tester) iOS() bool {
1114 return goos == "ios"
1117 func (t *tester) out(v string) {
1121 fmt.Println("\n" + t.banner + v)
1124 // extLink reports whether the current goos/goarch supports
1125 // external linking. This should match the test in determineLinkMode
1126 // in cmd/link/internal/ld/config.go.
1127 func (t *tester) extLink() bool {
1128 if goarch == "ppc64" && goos != "aix" {
1134 func (t *tester) internalLink() bool {
1135 if gohostos == "dragonfly" {
1136 // linkmode=internal fails on dragonfly since errno is a TLS relocation.
1139 if goos == "android" {
1145 if goos == "windows" && goarch == "arm64" {
1148 // Internally linking cgo is incomplete on some architectures.
1149 // https://golang.org/issue/10373
1150 // https://golang.org/issue/14449
1151 if goarch == "loong64" || goarch == "mips64" || goarch == "mips64le" || goarch == "mips" || goarch == "mipsle" || goarch == "riscv64" {
1155 // linkmode=internal isn't supported.
1161 func (t *tester) internalLinkPIE() bool {
1162 switch goos + "-" + goarch {
1163 case "darwin-amd64", "darwin-arm64",
1164 "linux-amd64", "linux-arm64", "linux-ppc64le",
1166 "windows-amd64", "windows-386", "windows-arm":
1172 // supportedBuildMode reports whether the given build mode is supported.
1173 func (t *tester) supportedBuildmode(mode string) bool {
1175 case "c-archive", "c-shared", "shared", "plugin", "pie":
1177 fatalf("internal error: unknown buildmode %s", mode)
1181 return buildModeSupported("gc", mode, goos, goarch)
1184 func (t *tester) registerCgoTests() {
1185 cgoTest := func(name string, subdir, linkmode, buildmode string, opts ...registerTestOpt) *goTest {
1187 dir: "cmd/cgo/internal/" + subdir,
1188 buildmode: buildmode,
1189 ldflags: "-linkmode=" + linkmode,
1192 if linkmode == "internal" {
1193 gt.tags = append(gt.tags, "internal")
1194 if buildmode == "pie" {
1195 gt.tags = append(gt.tags, "internal_pie")
1198 if buildmode == "static" {
1199 // This isn't actually a Go buildmode, just a convenient way to tell
1200 // cgoTest we want static linking.
1202 if linkmode == "external" {
1203 gt.ldflags += ` -extldflags "-static -pthread"`
1204 } else if linkmode == "auto" {
1205 gt.env = append(gt.env, "CGO_LDFLAGS=-static -pthread")
1207 panic("unknown linkmode with static build: " + linkmode)
1209 gt.tags = append(gt.tags, "static")
1212 t.registerTest("cgo:"+name, "cmd/cgo/internal/test", gt, opts...)
1216 cgoTest("test-auto", "test", "auto", "")
1218 // Stub out various buildmode=pie tests on alpine until 54354 resolved.
1219 builderName := os.Getenv("GO_BUILDER_NAME")
1220 disablePIE := strings.HasSuffix(builderName, "-alpine")
1222 if t.internalLink() {
1223 cgoTest("test-internal", "test", "internal", "")
1227 p := gohostos + "/" + goarch
1229 case os == "darwin", os == "windows":
1233 // test linkmode=external, but __thread not supported, so skip testtls.
1234 cgoTest("test-external", "test", "external", "")
1236 gt := cgoTest("test-external-s", "test", "external", "")
1239 if t.supportedBuildmode("pie") && !disablePIE {
1240 cgoTest("test-auto-pie", "test", "auto", "pie")
1241 if t.internalLink() && t.internalLinkPIE() {
1242 cgoTest("test-internal-pie", "test", "internal", "pie")
1246 case os == "aix", os == "android", os == "dragonfly", os == "freebsd", os == "linux", os == "netbsd", os == "openbsd":
1247 gt := cgoTest("test-external-g0", "test", "external", "")
1248 gt.env = append(gt.env, "CGO_CFLAGS=-g0 -fdiagnostics-color")
1250 cgoTest("testtls-auto", "testtls", "auto", "")
1251 cgoTest("testtls-external", "testtls", "external", "")
1254 // no static linking
1255 case p == "freebsd/arm":
1256 // -fPIC compiled tls code will use __tls_get_addr instead
1257 // of __aeabi_read_tp, however, on FreeBSD/ARM, __tls_get_addr
1258 // is implemented in rtld-elf, so -fPIC isn't compatible with
1259 // static linking on FreeBSD/ARM with clang. (cgo depends on
1260 // -fPIC fundamentally.)
1262 // Check for static linking support
1263 var staticCheck rtPreFunc
1264 ccName := compilerEnvLookup("CC", defaultcc, goos, goarch)
1265 cc, err := exec.LookPath(ccName)
1267 staticCheck.pre = func(*distTest) bool {
1268 fmt.Printf("$CC (%q) not found, skip cgo static linking test.\n", ccName)
1272 cmd := t.dirCmd("src/cmd/cgo/internal/test", cc, "-xc", "-o", "/dev/null", "-static", "-")
1273 cmd.Stdin = strings.NewReader("int main() {}")
1274 cmd.Stdout, cmd.Stderr = nil, nil // Discard output
1275 if err := cmd.Run(); err != nil {
1277 staticCheck.pre = func(*distTest) bool {
1278 fmt.Println("No support for static linking found (lacks libc.a?), skip cgo static linking test.")
1284 // Doing a static link with boringcrypto gets
1285 // a C linker warning on Linux.
1286 // in function `bio_ip_and_port_to_socket_and_addr':
1287 // warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
1288 if staticCheck.pre == nil && goos == "linux" && strings.Contains(goexperiment, "boringcrypto") {
1289 staticCheck.pre = func(*distTest) bool {
1290 fmt.Println("skipping static linking check on Linux when using boringcrypto to avoid C linker warning about getaddrinfo")
1295 // Static linking tests
1296 if goos != "android" && p != "netbsd/arm" {
1297 // TODO(#56629): Why does this fail on netbsd-arm?
1298 cgoTest("testtls-static", "testtls", "external", "static", staticCheck)
1300 cgoTest("nocgo-auto", "testnocgo", "auto", "", staticCheck)
1301 cgoTest("nocgo-external", "testnocgo", "external", "", staticCheck)
1302 if goos != "android" {
1303 cgoTest("nocgo-static", "testnocgo", "external", "static", staticCheck)
1304 cgoTest("test-static", "test", "external", "static", staticCheck)
1305 // -static in CGO_LDFLAGS triggers a different code path
1306 // than -static in -extldflags, so test both.
1307 // See issue #16651.
1308 if goarch != "loong64" {
1309 // TODO(#56623): Why does this fail on loong64?
1310 cgoTest("test-static-env", "test", "auto", "static", staticCheck)
1314 // PIE linking tests
1315 if t.supportedBuildmode("pie") && !disablePIE {
1316 cgoTest("test-pie", "test", "auto", "pie")
1317 if t.internalLink() && t.internalLinkPIE() {
1318 cgoTest("test-pie-internal", "test", "internal", "pie")
1320 cgoTest("testtls-pie", "testtls", "auto", "pie")
1321 cgoTest("nocgo-pie", "testnocgo", "auto", "pie")
1327 // run pending test commands, in parallel, emitting headers as appropriate.
1328 // When finished, emit header for nextTest, which is going to run after the
1329 // pending commands are done (and runPending returns).
1330 // A test should call runPending if it wants to make sure that it is not
1331 // running in parallel with earlier tests, or if it has some other reason
1332 // for needing the earlier tests to be done.
1333 func (t *tester) runPending(nextTest *distTest) {
1334 worklist := t.worklist
1336 for _, w := range worklist {
1337 w.start = make(chan bool)
1338 w.end = make(chan bool)
1341 timelog("skip", w.dt.name)
1342 w.out = []byte(fmt.Sprintf("skipped due to earlier error\n"))
1344 timelog("start", w.dt.name)
1345 w.out, w.err = w.cmd.CombinedOutput()
1347 if isUnsupportedVMASize(w) {
1348 timelog("skip", w.dt.name)
1349 w.out = []byte(fmt.Sprintf("skipped due to unsupported VMA\n"))
1354 timelog("end", w.dt.name)
1362 for ended < len(worklist) {
1363 for started < len(worklist) && started-ended < maxbg {
1364 w := worklist[started]
1366 w.start <- !t.failed || t.keepGoing
1368 w := worklist[ended]
1370 if dt.heading != "" && t.lastHeading != dt.heading {
1371 t.lastHeading = dt.heading
1375 // Assumes all the entries for a single dt are in one worklist.
1378 fmt.Printf("# go tool dist test -run=^%s$\n", dt.name)
1382 errprintf("%s\n", strings.Join(w.cmd.Args, " "))
1386 os.Stdout.Write(w.out)
1388 log.Printf("Failed: %v", w.err)
1392 if t.failed && !t.keepGoing {
1396 if dt := nextTest; dt != nil {
1397 if dt.heading != "" && t.lastHeading != dt.heading {
1398 t.lastHeading = dt.heading
1402 fmt.Printf("# go tool dist test -run=^%s$\n", dt.name)
1407 func (t *tester) hasBash() bool {
1409 case "windows", "plan9":
1415 func (t *tester) hasCxx() bool {
1416 cxx, _ := exec.LookPath(compilerEnvLookup("CXX", defaultcxx, goos, goarch))
1420 func (t *tester) hasSwig() bool {
1421 swig, err := exec.LookPath("swig")
1426 // Check that swig was installed with Go support by checking
1427 // that a go directory exists inside the swiglib directory.
1428 // See https://golang.org/issue/23469.
1429 output, err := exec.Command(swig, "-go", "-swiglib").Output()
1433 swigDir := strings.TrimSpace(string(output))
1435 _, err = os.Stat(filepath.Join(swigDir, "go"))
1440 // Check that swig has a new enough version.
1441 // See https://golang.org/issue/22858.
1442 out, err := exec.Command(swig, "-version").CombinedOutput()
1447 re := regexp.MustCompile(`[vV]ersion +(\d+)([.]\d+)?([.]\d+)?`)
1448 matches := re.FindSubmatch(out)
1450 // Can't find version number; hope for the best.
1454 major, err := strconv.Atoi(string(matches[1]))
1456 // Can't find version number; hope for the best.
1467 // We have SWIG version 3.x.
1468 if len(matches[2]) > 0 {
1469 minor, err := strconv.Atoi(string(matches[2][1:]))
1479 // We have SWIG version 3.0.x.
1480 if len(matches[3]) > 0 {
1481 patch, err := strconv.Atoi(string(matches[3][1:]))
1494 // hasParallelism is a copy of the function
1495 // internal/testenv.HasParallelism, which can't be used here
1496 // because cmd/dist can not import internal packages during bootstrap.
1497 func (t *tester) hasParallelism() bool {
1499 case "js", "wasip1":
1505 func (t *tester) raceDetectorSupported() bool {
1506 if gohostos != goos {
1512 if !raceDetectorSupported(goos, goarch) {
1515 // The race detector doesn't work on Alpine Linux:
1516 // golang.org/issue/14481
1517 if isAlpineLinux() {
1520 // NetBSD support is unfinished.
1521 // golang.org/issue/26403
1522 if goos == "netbsd" {
1528 func isAlpineLinux() bool {
1529 if runtime.GOOS != "linux" {
1532 fi, err := os.Lstat("/etc/alpine-release")
1533 return err == nil && fi.Mode().IsRegular()
1536 func (t *tester) registerRaceTests() {
1537 hdr := "Testing race detector"
1538 t.registerTest("race:runtime/race", hdr,
1542 pkg: "runtime/race",
1544 t.registerTest("race", hdr,
1547 runTests: "TestParse|TestEcho|TestStdinCloseRace|TestClosedPipeRace|TestTypeRace|TestFdRace|TestFdReadRace|TestFileCloseRace",
1548 pkgs: []string{"flag", "net", "os", "os/exec", "encoding/gob"},
1550 // We don't want the following line, because it
1551 // slows down all.bash (by 10 seconds on my laptop).
1552 // The race builder should catch any error here, but doesn't.
1553 // TODO(iant): Figure out how to catch this.
1554 // t.registerTest("race:cmd/go", hdr, &goTest{race: true, runTests: "TestParallelTest", pkg: "cmd/go"})
1556 // Building cmd/cgo/internal/test takes a long time.
1557 // There are already cgo-enabled packages being tested with the race detector.
1558 // We shouldn't need to redo all of cmd/cgo/internal/test too.
1559 // The race buildler will take care of this.
1560 // t.registerTest("race:cmd/cgo/internal/test", hdr, &goTest{dir: "cmd/cgo/internal/test", race: true, env: []string{"GOTRACEBACK=2"}})
1563 // Test with external linking; see issue 9133.
1564 t.registerTest("race:external", hdr,
1567 ldflags: "-linkmode=external",
1568 runTests: "TestParse|TestEcho|TestStdinCloseRace",
1569 pkgs: []string{"flag", "os/exec"},
1574 // cgoPackages is the standard packages that use cgo.
1575 var cgoPackages = []string{
1580 var funcBenchmark = []byte("\nfunc Benchmark")
1582 // packageHasBenchmarks reports whether pkg has benchmarks.
1583 // On any error, it conservatively returns true.
1585 // This exists just to eliminate work on the builders, since compiling
1586 // a test in race mode just to discover it has no benchmarks costs a
1587 // second or two per package, and this function returns false for
1588 // about 100 packages.
1589 func (t *tester) packageHasBenchmarks(pkg string) bool {
1590 pkgDir := filepath.Join(goroot, "src", pkg)
1591 d, err := os.Open(pkgDir)
1593 return true // conservatively
1596 names, err := d.Readdirnames(-1)
1598 return true // conservatively
1600 for _, name := range names {
1601 if !strings.HasSuffix(name, "_test.go") {
1604 slurp, err := os.ReadFile(filepath.Join(pkgDir, name))
1606 return true // conservatively
1608 if bytes.Contains(slurp, funcBenchmark) {
1615 // makeGOROOTUnwritable makes all $GOROOT files & directories non-writable to
1616 // check that no tests accidentally write to $GOROOT.
1617 func (t *tester) makeGOROOTUnwritable() (undo func()) {
1618 dir := os.Getenv("GOROOT")
1620 panic("GOROOT not set")
1623 type pathMode struct {
1627 var dirs []pathMode // in lexical order
1630 for i := range dirs {
1631 os.Chmod(dirs[i].path, dirs[i].mode) // best effort
1635 filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
1636 if suffix := strings.TrimPrefix(path, dir+string(filepath.Separator)); suffix != "" {
1637 if suffix == ".git" {
1638 // Leave Git metadata in whatever state it was in. It may contain a lot
1639 // of files, and it is highly unlikely that a test will try to modify
1640 // anything within that directory.
1641 return filepath.SkipDir
1648 info, err := d.Info()
1654 if mode&0222 != 0 && (mode.IsDir() || mode.IsRegular()) {
1655 dirs = append(dirs, pathMode{path, mode})
1660 // Run over list backward to chmod children before parents.
1661 for i := len(dirs) - 1; i >= 0; i-- {
1662 err := os.Chmod(dirs[i].path, dirs[i].mode&^0222)
1664 dirs = dirs[i:] // Only undo what we did so far.
1666 fatalf("failed to make GOROOT read-only: %v", err)
1673 // raceDetectorSupported is a copy of the function
1674 // internal/platform.RaceDetectorSupported, which can't be used here
1675 // because cmd/dist can not import internal packages during bootstrap.
1676 // The race detector only supports 48-bit VMA on arm64. But we don't have
1677 // a good solution to check VMA size(See https://golang.org/issue/29948)
1678 // raceDetectorSupported will always return true for arm64. But race
1679 // detector tests may abort on non 48-bit VMA configuration, the tests
1680 // will be marked as "skipped" in this case.
1681 func raceDetectorSupported(goos, goarch string) bool {
1684 return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64" || goarch == "s390x"
1686 return goarch == "amd64" || goarch == "arm64"
1687 case "freebsd", "netbsd", "openbsd", "windows":
1688 return goarch == "amd64"
1694 // buildModeSupports is a copy of the function
1695 // internal/platform.BuildModeSupported, which can't be used here
1696 // because cmd/dist can not import internal packages during bootstrap.
1697 func buildModeSupported(compiler, buildmode, goos, goarch string) bool {
1698 if compiler == "gccgo" {
1702 platform := goos + "/" + goarch
1710 case "aix", "darwin", "ios", "windows":
1714 case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64le", "riscv64", "s390x":
1715 // linux/ppc64 not supported because it does
1716 // not support external linking mode yet.
1719 // Other targets do not support -shared,
1720 // per ParseFlags in
1721 // cmd/compile/internal/base/flag.go.
1722 // For c-archive the Go tool passes -shared,
1723 // so that the result is suitable for inclusion
1724 // in a PIE or shared library.
1728 return goarch == "amd64"
1734 case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x",
1735 "android/amd64", "android/arm", "android/arm64", "android/386",
1737 "darwin/amd64", "darwin/arm64",
1738 "windows/amd64", "windows/386", "windows/arm64":
1751 case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/ppc64le", "linux/riscv64", "linux/s390x",
1752 "android/amd64", "android/arm", "android/arm64", "android/386",
1754 "darwin/amd64", "darwin/arm64",
1755 "ios/amd64", "ios/arm64",
1757 "windows/386", "windows/amd64", "windows/arm", "windows/arm64":
1764 case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
1771 case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",
1772 "android/amd64", "android/386",
1773 "darwin/amd64", "darwin/arm64",
1784 // isUnsupportedVMASize reports whether the failure is caused by an unsupported
1785 // VMA for the race detector (for example, running the race detector on an
1786 // arm64 machine configured with 39-bit VMA)
1787 func isUnsupportedVMASize(w *work) bool {
1788 unsupportedVMA := []byte("unsupported VMA range")
1789 return w.dt.name == "race" && bytes.Contains(w.out, unsupportedVMA)
1792 // isEnvSet reports whether the environment variable evar is
1793 // set in the environment.
1794 func isEnvSet(evar string) bool {
1795 evarEq := evar + "="
1796 for _, e := range os.Environ() {
1797 if strings.HasPrefix(e, evarEq) {