"os/exec"
"path/filepath"
"regexp"
+ "runtime"
"strconv"
"strings"
"sync"
}
// Test internal linking of PIE binaries where it is supported.
- if t.goos == "linux" && t.goarch == "amd64" {
+ if t.goos == "linux" && t.goarch == "amd64" && !isAlpineLinux() {
+ // Issue 18243: We don't have a way to set the default
+ // dynamic linker used in internal linking mode. So
+ // this test is skipped on Alpine.
t.tests = append(t.tests, distTest{
name: "pie_internal",
heading: "internal linking of -buildmode=pie",
func (t *tester) raceDetectorSupported() bool {
switch t.gohostos {
case "linux", "darwin", "freebsd", "windows":
- return t.cgoEnabled && t.goarch == "amd64" && t.gohostos == t.goos
+ // The race detector doesn't work on Alpine Linux:
+ // golang.org/issue/14481
+ return t.cgoEnabled && t.goarch == "amd64" && t.gohostos == t.goos && !isAlpineLinux()
}
return false
}
+func isAlpineLinux() bool {
+ if runtime.GOOS != "linux" {
+ return false
+ }
+ fi, err := os.Lstat("/etc/alpine-release")
+ return err == nil && fi.Mode().IsRegular()
+}
+
func (t *tester) runFlag(rx string) string {
if t.compileOnly {
return "-run=^$"
import (
"bytes"
"fmt"
- "go/build"
"go/format"
"internal/race"
"internal/testenv"
switch runtime.GOOS {
case "linux", "darwin", "freebsd", "windows":
- canRace = canCgo && runtime.GOARCH == "amd64"
+ // The race detector doesn't work on Alpine Linux:
+ // golang.org/issue/14481
+ canRace = canCgo && runtime.GOARCH == "amd64" && !isAlpineLinux()
}
}
os.Exit(r)
}
+func isAlpineLinux() bool {
+ if runtime.GOOS != "linux" {
+ return false
+ }
+ fi, err := os.Lstat("/etc/alpine-release")
+ return err == nil && fi.Mode().IsRegular()
+}
+
// The length of an mtime tick on this system. This is an estimate of
// how long we need to sleep to ensure that the mtime of two files is
// different.
}
func TestGoTestRaceInstallCgo(t *testing.T) {
- switch sys := runtime.GOOS + "/" + runtime.GOARCH; sys {
- case "darwin/amd64", "freebsd/amd64", "linux/amd64", "windows/amd64":
- // ok
- default:
- t.Skip("no race detector on %s", sys)
- }
-
- if !build.Default.CgoEnabled {
- t.Skip("no race detector without cgo")
+ if !canRace {
+ t.Skip("skipping because race detector not supported")
}
// golang.org/issue/10500.