Skip to content

Commit

Permalink
misc/cgo/test,cmd/dist: enable (most) Cgo tests on Android
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Elias Naur committed Jun 1, 2016
1 parent bbd1dcd commit 6de014b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 12 deletions.
13 changes: 13 additions & 0 deletions misc/cgo/test/cgo_stubs_android_test.go
Original file line number Diff line number Diff line change
@@ -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) {}
2 changes: 2 additions & 0 deletions misc/cgo/test/issue3775.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !android

package cgotest

/*
Expand Down
2 changes: 2 additions & 0 deletions misc/cgo/test/issue6997_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions misc/cgo/test/issue6997_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions misc/cgo/test/issue7978.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 2 additions & 0 deletions misc/cgo/test/issue8694.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand Down
2 changes: 1 addition & 1 deletion misc/cgo/test/sigaltstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
26 changes: 15 additions & 11 deletions src/cmd/dist/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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()
Expand All @@ -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).
Expand Down Expand Up @@ -792,17 +792,21 @@ 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

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
Expand Down

0 comments on commit 6de014b

Please sign in to comment.