mirror of
https://github.com/golang/go
synced 2024-11-12 07:00:21 -07:00
misc/cgo/testshared: do not run gccgo tests when gccgo is too old
Fixes #12083 Change-Id: I8256739b33cf08d84dec23120d527667de2e6eea Reviewed-on: https://go-review.googlesource.com/13822 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a94e906c41
commit
abab21b1d1
@ -460,24 +460,39 @@ func TestTwoGopathShlibs(t *testing.T) {
|
||||
run(t, "executable linked to GOPATH library", "./bin/exe2")
|
||||
}
|
||||
|
||||
// Build a GOPATH package into a shared library with gccgo and an executable that
|
||||
// links against it.
|
||||
func TestGoPathShlibGccgo(t *testing.T) {
|
||||
// If gccgo is not available or not new enough call t.Skip. Otherwise,
|
||||
// return a build.Context that is set up for gccgo.
|
||||
func prepGccgo(t *testing.T) build.Context {
|
||||
gccgoName := os.Getenv("GCCGO")
|
||||
if gccgoName == "" {
|
||||
gccgoName = "gccgo"
|
||||
}
|
||||
_, err := exec.LookPath(gccgoName)
|
||||
gccgoPath, err := exec.LookPath(gccgoName)
|
||||
if err != nil {
|
||||
t.Skip("gccgo not found")
|
||||
}
|
||||
|
||||
libgoRE := regexp.MustCompile("libgo.so.[0-9]+")
|
||||
|
||||
cmd := exec.Command(gccgoPath, "-dumpversion")
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("%s -dumpversion failed: %v\n%s", gccgoPath, err, output)
|
||||
}
|
||||
if string(output) < "5" {
|
||||
t.Skipf("gccgo too old (%s)", strings.TrimSpace(string(output)))
|
||||
}
|
||||
gccgoContext := build.Default
|
||||
gccgoContext.InstallSuffix = suffix + "_fPIC"
|
||||
gccgoContext.Compiler = "gccgo"
|
||||
gccgoContext.GOPATH = os.Getenv("GOPATH")
|
||||
return gccgoContext
|
||||
}
|
||||
|
||||
// Build a GOPATH package into a shared library with gccgo and an executable that
|
||||
// links against it.
|
||||
func TestGoPathShlibGccgo(t *testing.T) {
|
||||
gccgoContext := prepGccgo(t)
|
||||
|
||||
libgoRE := regexp.MustCompile("libgo.so.[0-9]+")
|
||||
|
||||
depP, err := gccgoContext.Import("dep", ".", build.ImportComment)
|
||||
if err != nil {
|
||||
t.Fatalf("import failed: %v", err)
|
||||
@ -497,21 +512,10 @@ func TestGoPathShlibGccgo(t *testing.T) {
|
||||
// library with gccgo, another GOPATH package that depends on the first and an
|
||||
// executable that links the second library.
|
||||
func TestTwoGopathShlibsGccgo(t *testing.T) {
|
||||
gccgoName := os.Getenv("GCCGO")
|
||||
if gccgoName == "" {
|
||||
gccgoName = "gccgo"
|
||||
}
|
||||
_, err := exec.LookPath(gccgoName)
|
||||
if err != nil {
|
||||
t.Skip("gccgo not found")
|
||||
}
|
||||
gccgoContext := prepGccgo(t)
|
||||
|
||||
libgoRE := regexp.MustCompile("libgo.so.[0-9]+")
|
||||
|
||||
gccgoContext := build.Default
|
||||
gccgoContext.InstallSuffix = suffix + "_fPIC"
|
||||
gccgoContext.Compiler = "gccgo"
|
||||
gccgoContext.GOPATH = os.Getenv("GOPATH")
|
||||
depP, err := gccgoContext.Import("dep", ".", build.ImportComment)
|
||||
if err != nil {
|
||||
t.Fatalf("import failed: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user