Skip to content

Commit 7fc8210

Browse files
committed
cmd/go, cmd/dist: temporarily disable race and PIE internal link tests on Alpine
In an effort to at least understand the complete set of things not working on Alpine Linux, I've been trying to get the build passing again, even with tests disabled. The race detector is broken on Alpine. That is #14481 (and #9918). So disable those tests for now. Also, internal linking with PIE doesn't work on Alpine yet. That is #18243. So disable that test for now. With this CL, all.bash almost passes. There's some cgo test failing still, but there's no bug yet, so that can be a separate CL. Change-Id: I3ffbb0e787ed54cb82f298b6bd5bf3ccfbc82622 Reviewed-on: https://go-review.googlesource.com/41678 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent b692e74 commit 7fc8210

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

src/cmd/dist/test.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os/exec"
1616
"path/filepath"
1717
"regexp"
18+
"runtime"
1819
"strconv"
1920
"strings"
2021
"sync"
@@ -465,7 +466,10 @@ func (t *tester) registerTests() {
465466
}
466467

467468
// Test internal linking of PIE binaries where it is supported.
468-
if t.goos == "linux" && t.goarch == "amd64" {
469+
if t.goos == "linux" && t.goarch == "amd64" && !isAlpineLinux() {
470+
// Issue 18243: We don't have a way to set the default
471+
// dynamic linker used in internal linking mode. So
472+
// this test is skipped on Alpine.
469473
t.tests = append(t.tests, distTest{
470474
name: "pie_internal",
471475
heading: "internal linking of -buildmode=pie",
@@ -1083,11 +1087,21 @@ func (t *tester) hasBash() bool {
10831087
func (t *tester) raceDetectorSupported() bool {
10841088
switch t.gohostos {
10851089
case "linux", "darwin", "freebsd", "windows":
1086-
return t.cgoEnabled && t.goarch == "amd64" && t.gohostos == t.goos
1090+
// The race detector doesn't work on Alpine Linux:
1091+
// golang.org/issue/14481
1092+
return t.cgoEnabled && t.goarch == "amd64" && t.gohostos == t.goos && !isAlpineLinux()
10871093
}
10881094
return false
10891095
}
10901096

1097+
func isAlpineLinux() bool {
1098+
if runtime.GOOS != "linux" {
1099+
return false
1100+
}
1101+
fi, err := os.Lstat("/etc/alpine-release")
1102+
return err == nil && fi.Mode().IsRegular()
1103+
}
1104+
10911105
func (t *tester) runFlag(rx string) string {
10921106
if t.compileOnly {
10931107
return "-run=^$"

src/cmd/go/go_test.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package main_test
77
import (
88
"bytes"
99
"fmt"
10-
"go/build"
1110
"go/format"
1211
"internal/race"
1312
"internal/testenv"
@@ -100,7 +99,9 @@ func TestMain(m *testing.M) {
10099

101100
switch runtime.GOOS {
102101
case "linux", "darwin", "freebsd", "windows":
103-
canRace = canCgo && runtime.GOARCH == "amd64"
102+
// The race detector doesn't work on Alpine Linux:
103+
// golang.org/issue/14481
104+
canRace = canCgo && runtime.GOARCH == "amd64" && !isAlpineLinux()
104105
}
105106
}
106107

@@ -125,6 +126,14 @@ func TestMain(m *testing.M) {
125126
os.Exit(r)
126127
}
127128

129+
func isAlpineLinux() bool {
130+
if runtime.GOOS != "linux" {
131+
return false
132+
}
133+
fi, err := os.Lstat("/etc/alpine-release")
134+
return err == nil && fi.Mode().IsRegular()
135+
}
136+
128137
// The length of an mtime tick on this system. This is an estimate of
129138
// how long we need to sleep to ensure that the mtime of two files is
130139
// different.
@@ -3037,15 +3046,8 @@ func TestGoInstallPkgdir(t *testing.T) {
30373046
}
30383047

30393048
func TestGoTestRaceInstallCgo(t *testing.T) {
3040-
switch sys := runtime.GOOS + "/" + runtime.GOARCH; sys {
3041-
case "darwin/amd64", "freebsd/amd64", "linux/amd64", "windows/amd64":
3042-
// ok
3043-
default:
3044-
t.Skip("no race detector on %s", sys)
3045-
}
3046-
3047-
if !build.Default.CgoEnabled {
3048-
t.Skip("no race detector without cgo")
3049+
if !canRace {
3050+
t.Skip("skipping because race detector not supported")
30493051
}
30503052

30513053
// golang.org/issue/10500.

0 commit comments

Comments
 (0)