Skip to content

Commit 6de014b

Browse files
author
Elias Naur
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: David Crawshaw <[email protected]>
1 parent bbd1dcd commit 6de014b

File tree

8 files changed

+40
-12
lines changed

8 files changed

+40
-12
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2012 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package cgotest
6+
7+
import "testing"
8+
9+
// Stubs for tests that fails to build on Android
10+
func test6997(t *testing.T) {}
11+
func test3775(t *testing.T) {}
12+
func test8694(t *testing.T) {}
13+
func testSigaltstack(t *testing.T) {}

misc/cgo/test/issue3775.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build !android
2+
13
package cgotest
24

35
/*

misc/cgo/test/issue6997_linux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !android
6+
57
#include <pthread.h>
68
#include <stdio.h>
79
#include <unistd.h>

misc/cgo/test/issue6997_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !android
6+
57
// Test that pthread_cancel works as expected
68
// (NPTL uses SIGRTMIN to implement thread cancelation)
79
// See https://golang.org/issue/6997

misc/cgo/test/issue7978.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func test7978(t *testing.T) {
103103
if C.HAS_SYNC_FETCH_AND_ADD == 0 {
104104
t.Skip("clang required for __sync_fetch_and_add support on darwin/arm")
105105
}
106+
if runtime.GOOS == "android" {
107+
t.Skip("GOTRACEBACK is not passed on to the exec wrapper")
108+
}
106109
if os.Getenv("GOTRACEBACK") != "2" {
107110
t.Fatalf("GOTRACEBACK must be 2")
108111
}

misc/cgo/test/issue8694.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !android
6+
57
package cgotest
68

79
/*

misc/cgo/test/sigaltstack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build !windows
5+
// +build !windows,!android
66

77
// Test that the Go runtime still works if C code changes the signal stack.
88

src/cmd/dist/test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ func (t *tester) registerTests() {
432432
},
433433
})
434434

435-
if t.cgoEnabled && t.goos != "android" && !t.iOS() {
436-
// Disabled on android and iOS. golang.org/issue/8345
435+
if t.cgoEnabled && !t.iOS() {
436+
// Disabled on iOS. golang.org/issue/15919
437437
t.tests = append(t.tests, distTest{
438438
name: "cgo_stdio",
439439
heading: "../misc/cgo/stdio",
@@ -465,9 +465,9 @@ func (t *tester) registerTests() {
465465
})
466466
}
467467
}
468-
if t.cgoEnabled && t.goos != "android" && !t.iOS() {
469-
// TODO(crawshaw): reenable on android and iOS
470-
// golang.org/issue/8345
468+
if t.cgoEnabled && !t.iOS() {
469+
// TODO(crawshaw): reenable on iOS
470+
// golang.org/issue/15919
471471
//
472472
// These tests are not designed to run off the host.
473473
t.tests = append(t.tests, distTest{
@@ -729,7 +729,7 @@ func (t *tester) runHostTest(dirBanner, pkg string) error {
729729
func (t *tester) cgoTest(dt *distTest) error {
730730
env := mergeEnvLists([]string{"GOTRACEBACK=2"}, os.Environ())
731731

732-
if t.goos == "android" || t.iOS() {
732+
if t.iOS() {
733733
cmd := t.dirCmd("misc/cgo/test", "go", "test", t.tags())
734734
cmd.Env = env
735735
return cmd.Run()
@@ -738,7 +738,7 @@ func (t *tester) cgoTest(dt *distTest) error {
738738
cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", t.tags(), "-ldflags", "-linkmode=auto", t.runFlag(""))
739739
cmd.Env = env
740740

741-
if t.gohostos != "dragonfly" && t.gohostarch != "ppc64le" {
741+
if t.gohostos != "dragonfly" && t.gohostarch != "ppc64le" && t.goos != "android" {
742742
// linkmode=internal fails on dragonfly since errno is a TLS relocation.
743743
// linkmode=internal fails on ppc64le because cmd/link doesn't
744744
// handle the TOC correctly (issue 15409).
@@ -792,17 +792,21 @@ func (t *tester) cgoTest(dt *distTest) error {
792792
if err := cmd.Run(); err != nil {
793793
fmt.Println("No support for static linking found (lacks libc.a?), skip cgo static linking test.")
794794
} else {
795-
cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
796-
cmd.Env = env
795+
if t.goos != "android" {
796+
cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
797+
cmd.Env = env
798+
}
797799

798800
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test")
799801
cmd.Env = env
800802

801803
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external`)
802804
cmd.Env = env
803805

804-
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
805-
cmd.Env = env
806+
if t.goos != "android" {
807+
cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
808+
cmd.Env = env
809+
}
806810
}
807811

808812
if pair != "freebsd-amd64" { // clang -pie fails to link misc/cgo/test

0 commit comments

Comments
 (0)