mirror of
https://github.com/golang/go
synced 2025-05-02 02:51:41 +00:00
misc/cgo/test,cmd/dist: enable (most) Cgo tests on Android
Some tests cannot build for Android; use build tags and stubs to skip them. For #15919 Change-Id: Ieedcb73d4cabe23c3775cfb1d44c1276982dccd9 Reviewed-on: https://go-review.googlesource.com/23634 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
13
misc/cgo/test/cgo_stubs_android_test.go
Normal file
13
misc/cgo/test/cgo_stubs_android_test.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package cgotest
|
||||
|
||||
import "testing"
|
||||
|
||||
// Stubs for tests that fails to build on Android
|
||||
func test6997(t *testing.T) {}
|
||||
func test3775(t *testing.T) {}
|
||||
func test8694(t *testing.T) {}
|
||||
func testSigaltstack(t *testing.T) {}
|
@ -1,3 +1,5 @@
|
||||
// +build !android
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !android
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !android
|
||||
|
||||
// Test that pthread_cancel works as expected
|
||||
// (NPTL uses SIGRTMIN to implement thread cancelation)
|
||||
// See https://golang.org/issue/6997
|
||||
|
@ -103,6 +103,9 @@ func test7978(t *testing.T) {
|
||||
if C.HAS_SYNC_FETCH_AND_ADD == 0 {
|
||||
t.Skip("clang required for __sync_fetch_and_add support on darwin/arm")
|
||||
}
|
||||
if runtime.GOOS == "android" {
|
||||
t.Skip("GOTRACEBACK is not passed on to the exec wrapper")
|
||||
}
|
||||
if os.Getenv("GOTRACEBACK") != "2" {
|
||||
t.Fatalf("GOTRACEBACK must be 2")
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !android
|
||||
|
||||
package cgotest
|
||||
|
||||
/*
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !windows
|
||||
// +build !windows,!android
|
||||
|
||||
// Test that the Go runtime still works if C code changes the signal stack.
|
||||
|
||||
|
26
src/cmd/dist/test.go
vendored
26
src/cmd/dist/test.go
vendored
@ -432,8 +432,8 @@ func (t *tester) registerTests() {
|
||||
},
|
||||
})
|
||||
|
||||
if t.cgoEnabled && t.goos != "android" && !t.iOS() {
|
||||
// Disabled on android and iOS. golang.org/issue/8345
|
||||
if t.cgoEnabled && !t.iOS() {
|
||||
// Disabled on iOS. golang.org/issue/15919
|
||||
t.tests = append(t.tests, distTest{
|
||||
name: "cgo_stdio",
|
||||
heading: "../misc/cgo/stdio",
|
||||
@ -465,9 +465,9 @@ func (t *tester) registerTests() {
|
||||
})
|
||||
}
|
||||
}
|
||||
if t.cgoEnabled && t.goos != "android" && !t.iOS() {
|
||||
// TODO(crawshaw): reenable on android and iOS
|
||||
// golang.org/issue/8345
|
||||
if t.cgoEnabled && !t.iOS() {
|
||||
// TODO(crawshaw): reenable on iOS
|
||||
// golang.org/issue/15919
|
||||
//
|
||||
// These tests are not designed to run off the host.
|
||||
t.tests = append(t.tests, distTest{
|
||||
@ -729,7 +729,7 @@ func (t *tester) runHostTest(dirBanner, pkg string) error {
|
||||
func (t *tester) cgoTest(dt *distTest) error {
|
||||
env := mergeEnvLists([]string{"GOTRACEBACK=2"}, os.Environ())
|
||||
|
||||
if t.goos == "android" || t.iOS() {
|
||||
if t.iOS() {
|
||||
cmd := t.dirCmd("misc/cgo/test", "go", "test", t.tags())
|
||||
cmd.Env = env
|
||||
return cmd.Run()
|
||||
@ -738,7 +738,7 @@ func (t *tester) cgoTest(dt *distTest) error {
|
||||
cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", t.tags(), "-ldflags", "-linkmode=auto", t.runFlag(""))
|
||||
cmd.Env = env
|
||||
|
||||
if t.gohostos != "dragonfly" && t.gohostarch != "ppc64le" {
|
||||
if t.gohostos != "dragonfly" && t.gohostarch != "ppc64le" && t.goos != "android" {
|
||||
// linkmode=internal fails on dragonfly since errno is a TLS relocation.
|
||||
// linkmode=internal fails on ppc64le because cmd/link doesn't
|
||||
// handle the TOC correctly (issue 15409).
|
||||
@ -792,8 +792,10 @@ func (t *tester) cgoTest(dt *distTest) error {
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Println("No support for static linking found (lacks libc.a?), skip cgo static linking test.")
|
||||
} else {
|
||||
cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
|
||||
cmd.Env = env
|
||||
if t.goos != "android" {
|
||||
cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
|
||||
cmd.Env = env
|
||||
}
|
||||
|
||||
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test")
|
||||
cmd.Env = env
|
||||
@ -801,8 +803,10 @@ func (t *tester) cgoTest(dt *distTest) error {
|
||||
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external`)
|
||||
cmd.Env = env
|
||||
|
||||
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
|
||||
cmd.Env = env
|
||||
if t.goos != "android" {
|
||||
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
|
||||
cmd.Env = env
|
||||
}
|
||||
}
|
||||
|
||||
if pair != "freebsd-amd64" { // clang -pie fails to link misc/cgo/test
|
||||
|
Reference in New Issue
Block a user