Skip to content

Commit

Permalink
test: skip -buildmode=pie tests on alpine
Browse files Browse the repository at this point in the history
Skip a collection of -buildmode=pie tests on alpine, which are
currently failing on the linux-amd64-alpine builder. Once golang#54354 has
been investigated and resolved we can turn these tests back on.

Updates golang#54354.

Change-Id: I99d4016a40873ee6bb4eda571a64eddbe719c76a
Reviewed-on: https://go-review.googlesource.com/c/go/+/422295
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
  • Loading branch information
thanm authored and jproberts committed Aug 10, 2022
1 parent 0022905 commit 55a8deb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions misc/cgo/testshared/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ func checkPIE(t *testing.T, name string) {
}

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"
goCmd(t, "build", "-buildmode=pie", "-o="+name, "./trivial")
defer os.Remove(name)
Expand Down
17 changes: 13 additions & 4 deletions src/cmd/dist/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
if t.internalLinkPIE() {
if t.internalLinkPIE() && !disablePIE {
t.tests = append(t.tests, distTest{
name: "pie_internal",
heading: "internal linking of -buildmode=pie",
Expand All @@ -711,7 +715,7 @@ func (t *tester) registerTests() {
},
})
// Also test a cgo package.
if t.cgoEnabled && t.internalLink() {
if t.cgoEnabled && t.internalLink() && !disablePIE {
t.tests = append(t.tests, distTest{
name: "pie_internal_cgo",
heading: "internal linking of -buildmode=pie",
Expand Down Expand Up @@ -1188,6 +1192,10 @@ func (t *tester) cgoTest(dt *distTest) error {
cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), ".")
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() {
cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-tags=internal", ".")
setEnv(cmd, "GOFLAGS", "-ldflags=-linkmode=internal")
Expand All @@ -1206,7 +1214,8 @@ func (t *tester) cgoTest(dt *distTest) error {

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", ".")
if t.internalLink() && t.internalLinkPIE() {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie", ".")
Expand Down Expand Up @@ -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", ".")
if t.internalLink() && t.internalLinkPIE() {
t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie", ".")
Expand Down
4 changes: 4 additions & 0 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,10 @@ func TestBuildmodePIE(t *testing.T) {
default:
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) {
testBuildmodePIE(t, false, true)
})
Expand Down

0 comments on commit 55a8deb

Please sign in to comment.