]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix short tests on ios
authorBryan C. Mills <bcmills@google.com>
Thu, 4 May 2023 15:16:04 +0000 (11:16 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 4 May 2023 17:09:07 +0000 (17:09 +0000)
As of CL 488076, many cmd/go tests can run on the ios-arm64-corellium
builder. Some of them had made erroneous assumptions about cmd/go's
use of the C toolchain.

Change-Id: Ib59d9858ef3930de2b412daa4462b72065f69cfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/492597
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/go/scriptconds_test.go
src/cmd/go/testdata/script/README
src/cmd/go/testdata/script/cache_unix.txt
src/cmd/go/testdata/script/cgo_path.txt
src/cmd/go/testdata/script/cgo_suspect_flag_force_external.txt

index a9b5f9acec404b3e08de413ad43917ff6e9277bb..3c893eeae561384e0ae4f5bfbfa7599d1206b4c5 100644 (file)
@@ -39,8 +39,9 @@ func scriptConditions() map[string]script.Cond {
        add("asan", sysCondition("-asan", platform.ASanSupported, true))
        add("buildmode", script.PrefixCondition("go supports -buildmode=<suffix>", hasBuildmode))
        add("case-sensitive", script.OnceCondition("$WORK filesystem is case-sensitive", isCaseSensitive))
+       add("cc", script.PrefixCondition("go env CC = <suffix> (ignoring the go/env file)", ccIs))
        add("cgo", script.BoolCondition("host CGO_ENABLED", testenv.HasCGO()))
-       add("cgolinkext", script.BoolCondition("platform requires external linking for cgo", platform.MustLinkExternal(cfg.Goos, cfg.Goarch, true)))
+       add("cgolinkext", script.Condition("platform requires external linking for cgo", cgoLinkExt))
        add("cross", script.BoolCondition("cmd/go GOOS/GOARCH != GOHOSTOS/GOHOSTARCH", goHostOS != runtime.GOOS || goHostArch != runtime.GOARCH))
        add("fuzz", sysCondition("-fuzz", platform.FuzzSupported, false))
        add("fuzz-instrumented", sysCondition("-fuzz with instrumentation", platform.FuzzInstrumented, false))
@@ -50,6 +51,7 @@ func scriptConditions() map[string]script.Cond {
        add("link", lazyBool("testenv.HasLink()", testenv.HasLink))
        add("mismatched-goroot", script.Condition("test's GOROOT_FINAL does not match the real GOROOT", isMismatchedGoroot))
        add("msan", sysCondition("-msan", platform.MSanSupported, true))
+       add("mustlinkext", script.Condition("platform always requires external linking", mustLinkExt))
        add("net", script.PrefixCondition("can connect to external network host <suffix>", hasNet))
        add("race", sysCondition("-race", platform.RaceDetectorSupported, true))
        add("symlink", lazyBool("testenv.HasSymlink()", testenv.HasSymlink))
@@ -70,6 +72,16 @@ func defaultCCIsAbsolute(s *script.State) (bool, error) {
        return false, nil
 }
 
+func ccIs(s *script.State, want string) (bool, error) {
+       CC, _ := s.LookupEnv("CC")
+       if CC != "" {
+               return CC == want, nil
+       }
+       GOOS, _ := s.LookupEnv("GOOS")
+       GOARCH, _ := s.LookupEnv("GOARCH")
+       return cfg.DefaultCC(GOOS, GOARCH) == want, nil
+}
+
 func isMismatchedGoroot(s *script.State) (bool, error) {
        gorootFinal, _ := s.LookupEnv("GOROOT_FINAL")
        if gorootFinal == "" {
@@ -185,3 +197,15 @@ func hasWorkingGit() bool {
        _, err := exec.LookPath("git")
        return err == nil
 }
+
+func cgoLinkExt(s *script.State) (bool, error) {
+       GOOS, _ := s.LookupEnv("GOOS")
+       GOARCH, _ := s.LookupEnv("GOARCH")
+       return platform.MustLinkExternal(GOOS, GOARCH, true), nil
+}
+
+func mustLinkExt(s *script.State) (bool, error) {
+       GOOS, _ := s.LookupEnv("GOOS")
+       GOARCH, _ := s.LookupEnv("GOARCH")
+       return platform.MustLinkExternal(GOOS, GOARCH, false), nil
+}
index c653764145efe5a4630bbaca70c7dc4708918f73..b7215e8f4f5c4f2ad024617ab4705821554ea1cf 100644 (file)
@@ -380,6 +380,8 @@ The available conditions are:
        go supports -buildmode=<suffix>
 [case-sensitive]
        $WORK filesystem is case-sensitive
+[cc:*]
+       go env CC = <suffix> (ignoring the go/env file)
 [cgo]
        host CGO_ENABLED
 [cgolinkext]
@@ -402,6 +404,8 @@ The available conditions are:
        test's GOROOT_FINAL does not match the real GOROOT
 [msan]
        GOOS/GOARCH supports -msan
+[mustlinkext]
+       platform always requires external linking
 [net:*]
        can connect to external network host <suffix>
 [race]
index 569480051ce2af1f252c1b2790713f43cb707c8d..e11804d39abebdad9bb07f724f5d948346ff3682 100644 (file)
@@ -2,9 +2,10 @@ env GO111MODULE=off
 
 # Integration test for cache directory calculation (cmd/go/internal/cache).
 
-[GOOS:windows] skip
-[GOOS:darwin] skip
-[GOOS:plan9] skip
+[GOOS:windows] skip 'windows does not use XDG_CACHE_HOME'
+[GOOS:darwin]  skip 'darwin does not use XDG_CACHE_HOME'
+[GOOS:ios]     skip 'ios does not use XDG_CACHE_HOME'
+[GOOS:plan9]   skip 'plan9 does not use XDG_CACHE_HOME'
 
 mkdir $WORK/gocache
 mkdir $WORK/xdg
index 88f57f0a5b15f6ccd7e4d24940237c0c42c0a5fb..be23893df59863ddf5e20cd0ff4c50bdcd51316e 100644 (file)
@@ -1,11 +1,9 @@
 [!cgo] skip
 
-# Set CC explicitly to something that requires a PATH lookup.
+# Require that CC is something that requires a PATH lookup.
 # Normally, the default is gcc or clang, but if CC was set during make.bash,
 # that becomes the default.
-[exec:clang] env CC=clang
-[exec:gcc] env CC=gcc
-[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
+[!cc:clang] [!cc:gcc] skip 'C compiler is not gcc or clang'
 
 env GOCACHE=$WORK/gocache  # Looking for compile flags, so need a clean cache.
 [!GOOS:windows] env PATH=.:$PATH
index fbe8236f9da4e9c3c001b17b98eb4ac104e52aca..b2c84a387c510ae87762723b451211583210acf1 100644 (file)
@@ -5,8 +5,8 @@
 
 [compiler:gccgo] skip # only external linking for gccgo
 
-# This test requires external linking, so use cgo as a proxy
-[!cgo] skip
+[!cgo] skip 'test verifies behavior that depends on CGO_CFLAGS'
+[mustlinkext] skip 'test expects internal linking for non-cgo programs'
 
 # Here we build three program: one with explicit CGO use, one with no
 # CGO use, and one that uses a stdlib package ("runtime/cgo") that has