Fix cross-Linux setup on non-amd64 arches
In that case, an emulator is needed for amd64, and tests should be run for amd64 as a _cross_ test.
Этот коммит содержится в:
родитель
ac7e370c72
коммит
010cc13e9e
2 изменённых файлов: 35 добавлений и 23 удалений
|
@ -317,11 +317,20 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
|
|||
if goarch != runtime.GOARCH {
|
||||
// Some educated guesses as to how to invoke helper programs.
|
||||
spec.GDB = []string{"gdb-multiarch"}
|
||||
if goarch == "arm" && goos == "linux" {
|
||||
spec.Emulator = []string{"qemu-arm"}
|
||||
}
|
||||
if goarch == "arm64" && goos == "linux" {
|
||||
spec.Emulator = []string{"qemu-aarch64"}
|
||||
if goos == "linux" {
|
||||
switch goarch {
|
||||
case "386":
|
||||
// amd64 can _usually_ run 32-bit programs, so skip the emulator in that case.
|
||||
if runtime.GOARCH != "amd64" {
|
||||
spec.Emulator = []string{"qemu-i386"}
|
||||
}
|
||||
case "amd64":
|
||||
spec.Emulator = []string{"qemu-x86_64"}
|
||||
case "arm":
|
||||
spec.Emulator = []string{"qemu-arm"}
|
||||
case "arm64":
|
||||
spec.Emulator = []string{"qemu-aarch64"}
|
||||
}
|
||||
}
|
||||
}
|
||||
if goos != runtime.GOOS {
|
||||
|
|
39
main_test.go
39
main_test.go
|
@ -31,6 +31,13 @@ const TESTDATA = "testdata"
|
|||
|
||||
var testTarget = flag.String("target", "", "override test target")
|
||||
|
||||
var supportedLinuxArches = map[string]string{
|
||||
"AMD64Linux": "linux/amd64",
|
||||
"X86Linux": "linux/386",
|
||||
"ARMLinux": "linux/arm/6",
|
||||
"ARM64Linux": "linux/arm64",
|
||||
}
|
||||
|
||||
var sema = make(chan struct{}, runtime.NumCPU())
|
||||
|
||||
func TestBuild(t *testing.T) {
|
||||
|
@ -180,18 +187,14 @@ func TestBuild(t *testing.T) {
|
|||
})
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
t.Run("X86Linux", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runPlatTests(optionsFromOSARCH("linux/386", sema), tests, t)
|
||||
})
|
||||
t.Run("ARMLinux", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runPlatTests(optionsFromOSARCH("linux/arm/6", sema), tests, t)
|
||||
})
|
||||
t.Run("ARM64Linux", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runPlatTests(optionsFromOSARCH("linux/arm64", sema), tests, t)
|
||||
})
|
||||
for name, osArch := range supportedLinuxArches {
|
||||
options := optionsFromOSARCH(osArch, sema)
|
||||
if options.GOARCH != runtime.GOARCH { // Native architecture already run above.
|
||||
t.Run(name, func(t *testing.T) {
|
||||
runPlatTests(options, tests, t)
|
||||
})
|
||||
}
|
||||
}
|
||||
t.Run("WebAssembly", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runPlatTests(optionsFromTarget("wasm", sema), tests, t)
|
||||
|
@ -475,12 +478,12 @@ func TestTest(t *testing.T) {
|
|||
}
|
||||
if !testing.Short() {
|
||||
if runtime.GOOS == "linux" {
|
||||
targs = append(targs,
|
||||
// Linux
|
||||
targ{"X86Linux", optionsFromOSARCH("linux/386", sema)},
|
||||
targ{"ARMLinux", optionsFromOSARCH("linux/arm/6", sema)},
|
||||
targ{"ARM64Linux", optionsFromOSARCH("linux/arm64", sema)},
|
||||
)
|
||||
for name, osArch := range supportedLinuxArches {
|
||||
options := optionsFromOSARCH(osArch, sema)
|
||||
if options.GOARCH != runtime.GOARCH { // Native architecture already run above.
|
||||
targs = append(targs, targ{name, options})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targs = append(targs,
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче