1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:47:58 -07:00

test: skip -buildmode=pie tests on alpine

Skip a collection of -buildmode=pie tests on alpine, which are
currently failing on the linux-amd64-alpine builder. Once #54354 has
been investigated and resolved we can turn these tests back on.

Updates #54354.

Change-Id: I99d4016a40873ee6bb4eda571a64eddbe719c76a
Reviewed-on: https://go-review.googlesource.com/c/go/+/422295
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2022-08-09 10:32:59 -04:00
parent c7942f87a2
commit 0d9ed0638b
3 changed files with 20 additions and 4 deletions

View File

@ -528,6 +528,9 @@ func checkPIE(t *testing.T, name string) {
} }
func TestTrivialPIE(t *testing.T) { func TestTrivialPIE(t *testing.T) {
if strings.HasSuffix(os.Getenv("GO_BUILDER_NAME"), "-alpine") {
t.Skip("skipping on alpine until issue #54354 resolved")
}
name := "trivial_pie" name := "trivial_pie"
goCmd(t, "build", "-buildmode=pie", "-o="+name, "./trivial") goCmd(t, "build", "-buildmode=pie", "-o="+name, "./trivial")
defer os.Remove(name) defer os.Remove(name)

17
src/cmd/dist/test.go vendored
View File

@ -700,8 +700,12 @@ func (t *tester) registerTests() {
}) })
} }
// Stub out following test on alpine until 54354 resolved.
builderName := os.Getenv("GO_BUILDER_NAME")
disablePIE := strings.HasSuffix(builderName, "-alpine")
// Test internal linking of PIE binaries where it is supported. // Test internal linking of PIE binaries where it is supported.
if t.internalLinkPIE() { if t.internalLinkPIE() && !disablePIE {
t.tests = append(t.tests, distTest{ t.tests = append(t.tests, distTest{
name: "pie_internal", name: "pie_internal",
heading: "internal linking of -buildmode=pie", heading: "internal linking of -buildmode=pie",
@ -711,7 +715,7 @@ func (t *tester) registerTests() {
}, },
}) })
// Also test a cgo package. // Also test a cgo package.
if t.cgoEnabled && t.internalLink() { if t.cgoEnabled && t.internalLink() && !disablePIE {
t.tests = append(t.tests, distTest{ t.tests = append(t.tests, distTest{
name: "pie_internal_cgo", name: "pie_internal_cgo",
heading: "internal linking of -buildmode=pie", heading: "internal linking of -buildmode=pie",
@ -1188,6 +1192,10 @@ func (t *tester) cgoTest(dt *distTest) error {
cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), ".") cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), ".")
setEnv(cmd, "GOFLAGS", "-ldflags=-linkmode=auto") setEnv(cmd, "GOFLAGS", "-ldflags=-linkmode=auto")
// Stub out various buildmode=pie tests on alpine until 54354 resolved.
builderName := os.Getenv("GO_BUILDER_NAME")
disablePIE := strings.HasSuffix(builderName, "-alpine")
if t.internalLink() { if t.internalLink() {
cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-tags=internal", ".") cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-tags=internal", ".")
setEnv(cmd, "GOFLAGS", "-ldflags=-linkmode=internal") setEnv(cmd, "GOFLAGS", "-ldflags=-linkmode=internal")
@ -1206,7 +1214,8 @@ func (t *tester) cgoTest(dt *distTest) error {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external -s", ".") t.addCmd(dt, "misc/cgo/test", t.goTest(), "-ldflags", "-linkmode=external -s", ".")
if t.supportedBuildmode("pie") { if t.supportedBuildmode("pie") && !disablePIE {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", ".") t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", ".")
if t.internalLink() && t.internalLinkPIE() { if t.internalLink() && t.internalLinkPIE() {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie", ".") t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie", ".")
@ -1262,7 +1271,7 @@ func (t *tester) cgoTest(dt *distTest) error {
} }
} }
if t.supportedBuildmode("pie") { if t.supportedBuildmode("pie") && !disablePIE {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", ".") t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", ".")
if t.internalLink() && t.internalLinkPIE() { if t.internalLink() && t.internalLinkPIE() {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie", ".") t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie", ".")

View File

@ -2147,6 +2147,10 @@ func TestBuildmodePIE(t *testing.T) {
default: default:
t.Skipf("skipping test because buildmode=pie is not supported on %s", platform) t.Skipf("skipping test because buildmode=pie is not supported on %s", platform)
} }
// Skip on alpine until https://go.dev/issues/54354 resolved.
if strings.HasSuffix(testenv.Builder(), "-alpine") {
t.Skip("skipping PIE tests on alpine; see https://go.dev/issues/54354")
}
t.Run("non-cgo", func(t *testing.T) { t.Run("non-cgo", func(t *testing.T) {
testBuildmodePIE(t, false, true) testBuildmodePIE(t, false, true)
}) })