Commit e27a8122 authored by Alex Brainman's avatar Alex Brainman

misc/cgo/testcshared: run tests in parallel

Change-Id: Id1b5939cfcd210a0cb5f61915ce2d077c7fcec11
Reviewed-on: https://go-review.googlesource.com/62592Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 410b7372
...@@ -54,6 +54,14 @@ func TestMain(m *testing.M) { ...@@ -54,6 +54,14 @@ func TestMain(m *testing.M) {
} }
androiddir = fmt.Sprintf("/data/local/tmp/testcshared-%d", os.Getpid()) androiddir = fmt.Sprintf("/data/local/tmp/testcshared-%d", os.Getpid())
if GOOS == "android" {
cmd := exec.Command("adb", "shell", "mkdir", "-p", androiddir)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("setupAndroid failed: %v\n%s\n", err, out)
}
}
libgoname = "libgo." + libSuffix libgoname = "libgo." + libSuffix
ccOut := goEnv("CC") ccOut := goEnv("CC")
...@@ -273,27 +281,6 @@ func cleanupHeaders() { ...@@ -273,27 +281,6 @@ func cleanupHeaders() {
os.Remove("libgo.h") os.Remove("libgo.h")
} }
var (
androidOnce sync.Once
androidErr error
)
func setupAndroid(t *testing.T) {
if GOOS != "android" {
return
}
androidOnce.Do(func() {
cmd := exec.Command("adb", "shell", "mkdir", "-p", androiddir)
out, err := cmd.CombinedOutput()
if err != nil {
androidErr = fmt.Errorf("setupAndroid failed: %v\n%s\n", err, out)
}
})
if androidErr != nil {
t.Fatal(androidErr)
}
}
func cleanupAndroid() { func cleanupAndroid() {
if GOOS != "android" { if GOOS != "android" {
return return
...@@ -307,16 +294,17 @@ func cleanupAndroid() { ...@@ -307,16 +294,17 @@ func cleanupAndroid() {
// test0: exported symbols in shared lib are accessible. // test0: exported symbols in shared lib are accessible.
func TestExportedSymbols(t *testing.T) { func TestExportedSymbols(t *testing.T) {
cmd := "testp" t.Parallel()
cmd := "testp0"
bin := cmdToRun(cmd) bin := cmdToRun(cmd)
setupAndroid(t)
createHeadersOnce(t) createHeadersOnce(t)
run(t, append(cc, "-I", installdir, "-o", cmd, "main0.c", libgoname)...) run(t, append(cc, "-I", installdir, "-o", cmd, "main0.c", libgoname)...)
adbPush(t, cmd) adbPush(t, cmd)
defer os.Remove("testp") defer os.Remove(cmd)
out := runwithldlibrarypath(t, bin...) out := runwithldlibrarypath(t, bin...)
if strings.TrimSpace(out) != "PASS" { if strings.TrimSpace(out) != "PASS" {
...@@ -326,10 +314,11 @@ func TestExportedSymbols(t *testing.T) { ...@@ -326,10 +314,11 @@ func TestExportedSymbols(t *testing.T) {
// test1: shared library can be dynamically loaded and exported symbols are accessible. // test1: shared library can be dynamically loaded and exported symbols are accessible.
func TestExportedSymbolsWithDynamicLoad(t *testing.T) { func TestExportedSymbolsWithDynamicLoad(t *testing.T) {
cmd := "testp" t.Parallel()
cmd := "testp1"
bin := cmdToRun(cmd) bin := cmdToRun(cmd)
setupAndroid(t)
createHeadersOnce(t) createHeadersOnce(t)
run(t, append(cc, "-o", cmd, "main1.c", "-ldl")...) run(t, append(cc, "-o", cmd, "main1.c", "-ldl")...)
...@@ -345,12 +334,12 @@ func TestExportedSymbolsWithDynamicLoad(t *testing.T) { ...@@ -345,12 +334,12 @@ func TestExportedSymbolsWithDynamicLoad(t *testing.T) {
// test2: tests libgo2 which does not export any functions. // test2: tests libgo2 which does not export any functions.
func TestUnexportedSymbols(t *testing.T) { func TestUnexportedSymbols(t *testing.T) {
t.Parallel()
cmd := "testp2" cmd := "testp2"
libname := "libgo2." + libSuffix libname := "libgo2." + libSuffix
bin := cmdToRun(cmd) bin := cmdToRun(cmd)
setupAndroid(t)
rungocmd(t, rungocmd(t,
"go", "build", "go", "build",
"-buildmode=c-shared", "-buildmode=c-shared",
...@@ -383,6 +372,8 @@ func TestUnexportedSymbols(t *testing.T) { ...@@ -383,6 +372,8 @@ func TestUnexportedSymbols(t *testing.T) {
// test3: tests main.main is exported on android. // test3: tests main.main is exported on android.
func TestMainExportedOnAndroid(t *testing.T) { func TestMainExportedOnAndroid(t *testing.T) {
t.Parallel()
if GOOS != "android" { if GOOS != "android" {
return return
} }
...@@ -390,7 +381,6 @@ func TestMainExportedOnAndroid(t *testing.T) { ...@@ -390,7 +381,6 @@ func TestMainExportedOnAndroid(t *testing.T) {
cmd := "testp3" cmd := "testp3"
bin := cmdToRun(cmd) bin := cmdToRun(cmd)
setupAndroid(t)
createHeadersOnce(t) createHeadersOnce(t)
run(t, append(cc, "-o", cmd, "main3.c", "-ldl")...) run(t, append(cc, "-o", cmd, "main3.c", "-ldl")...)
...@@ -406,12 +396,12 @@ func TestMainExportedOnAndroid(t *testing.T) { ...@@ -406,12 +396,12 @@ func TestMainExportedOnAndroid(t *testing.T) {
// test4: test signal handlers // test4: test signal handlers
func TestSignalHandlers(t *testing.T) { func TestSignalHandlers(t *testing.T) {
t.Parallel()
cmd := "testp4" cmd := "testp4"
libname := "libgo4." + libSuffix libname := "libgo4." + libSuffix
bin := cmdToRun(cmd) bin := cmdToRun(cmd)
setupAndroid(t)
rungocmd(t, rungocmd(t,
"go", "build", "go", "build",
"-buildmode=c-shared", "-buildmode=c-shared",
...@@ -438,12 +428,12 @@ func TestSignalHandlers(t *testing.T) { ...@@ -438,12 +428,12 @@ func TestSignalHandlers(t *testing.T) {
// test5: test signal handlers with os/signal.Notify // test5: test signal handlers with os/signal.Notify
func TestSignalHandlersWithNotify(t *testing.T) { func TestSignalHandlersWithNotify(t *testing.T) {
t.Parallel()
cmd := "testp5" cmd := "testp5"
libname := "libgo5." + libSuffix libname := "libgo5." + libSuffix
bin := cmdToRun(cmd) bin := cmdToRun(cmd)
setupAndroid(t)
rungocmd(t, rungocmd(t,
"go", "build", "go", "build",
"-buildmode=c-shared", "-buildmode=c-shared",
...@@ -469,6 +459,8 @@ func TestSignalHandlersWithNotify(t *testing.T) { ...@@ -469,6 +459,8 @@ func TestSignalHandlersWithNotify(t *testing.T) {
} }
func TestPIE(t *testing.T) { func TestPIE(t *testing.T) {
t.Parallel()
switch GOOS { switch GOOS {
case "linux", "android": case "linux", "android":
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment