mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/dist: refine test conditions and enable more cgo tests on Android, iOS
This CL moves many cgo test conditions out of dist and into the tests themselves, now that they can use the testenv.Must* helpers. This refines a lot of the conditions, which happens to have the effect of enabling many tests on Android and iOS that are disabled by too-coarse GOOS checks in dist today. Fixes #15919. Change-Id: I2947526b08928d2f7f89f107b5b2403b32092ed8 Reviewed-on: https://go-review.googlesource.com/c/go/+/495918 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
071770b846
commit
a674ab1961
24 changed files with 197 additions and 148 deletions
|
|
@ -12,6 +12,8 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"internal/platform"
|
||||
"internal/testenv"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
|
@ -91,6 +93,17 @@ func goCmd(t *testing.T, args ...string) string {
|
|||
|
||||
// TestMain calls testMain so that the latter can use defer (TestMain exits with os.Exit).
|
||||
func testMain(m *testing.M) (int, error) {
|
||||
// TODO: Move all of this initialization stuff into a sync.Once that each
|
||||
// test can use, where we can properly t.Skip.
|
||||
if !platform.BuildModeSupported(runtime.Compiler, "shared", runtime.GOOS, runtime.GOARCH) {
|
||||
fmt.Printf("SKIP - shared build mode not supported\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
if !testenv.HasCGO() {
|
||||
fmt.Printf("SKIP - cgo not supported\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
@ -531,6 +544,7 @@ func TestTrivialPIE(t *testing.T) {
|
|||
if strings.HasSuffix(os.Getenv("GO_BUILDER_NAME"), "-alpine") {
|
||||
t.Skip("skipping on alpine until issue #54354 resolved")
|
||||
}
|
||||
testenv.MustHaveBuildMode(t, "pie")
|
||||
name := "trivial_pie"
|
||||
goCmd(t, "build", "-buildmode=pie", "-o="+name, "./trivial")
|
||||
defer os.Remove(name)
|
||||
|
|
@ -539,6 +553,8 @@ func TestTrivialPIE(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCgoPIE(t *testing.T) {
|
||||
testenv.MustHaveCGO(t)
|
||||
testenv.MustHaveBuildMode(t, "pie")
|
||||
name := "cgo_pie"
|
||||
goCmd(t, "build", "-buildmode=pie", "-o="+name, "./execgo")
|
||||
defer os.Remove(name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue