diff options
author | Ian Lance Taylor <iant@golang.org> | 2017-09-14 17:11:35 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-09-14 17:11:35 +0000 |
commit | bc998d034f45d1828a8663b2eed928faf22a7d01 (patch) | |
tree | 8d262a22ca7318f4bcd64269fe8fe9e45bcf8d0f /libgo/misc/cgo/testplugin | |
parent | a41a6142df74219f596e612d3a7775f68ca6e96f (diff) |
libgo: update to go1.9
Reviewed-on: https://go-review.googlesource.com/63753
From-SVN: r252767
Diffstat (limited to 'libgo/misc/cgo/testplugin')
-rw-r--r-- | libgo/misc/cgo/testplugin/src/issue19534/main.go | 23 | ||||
-rw-r--r-- | libgo/misc/cgo/testplugin/src/issue19534/plugin.go | 9 | ||||
-rw-r--r-- | libgo/misc/cgo/testplugin/test.bash | 8 | ||||
-rw-r--r-- | libgo/misc/cgo/testplugin/unnamed1.go | 11 | ||||
-rw-r--r-- | libgo/misc/cgo/testplugin/unnamed2.go | 9 |
5 files changed, 59 insertions, 1 deletions
diff --git a/libgo/misc/cgo/testplugin/src/issue19534/main.go b/libgo/misc/cgo/testplugin/src/issue19534/main.go new file mode 100644 index 00000000000..de263b6f0f2 --- /dev/null +++ b/libgo/misc/cgo/testplugin/src/issue19534/main.go @@ -0,0 +1,23 @@ +// Copyright 2017 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 main + +import "plugin" + +func main() { + p, err := plugin.Open("plugin.so") + if err != nil { + panic(err) + } + + sym, err := p.Lookup("Foo") + if err != nil { + panic(err) + } + f := sym.(func() int) + if f() != 42 { + panic("expected f() == 42") + } +} diff --git a/libgo/misc/cgo/testplugin/src/issue19534/plugin.go b/libgo/misc/cgo/testplugin/src/issue19534/plugin.go new file mode 100644 index 00000000000..582d33305c9 --- /dev/null +++ b/libgo/misc/cgo/testplugin/src/issue19534/plugin.go @@ -0,0 +1,9 @@ +// Copyright 2017 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 main + +func Foo() int { + return 42 +} diff --git a/libgo/misc/cgo/testplugin/test.bash b/libgo/misc/cgo/testplugin/test.bash index ab7430acc37..69df5bd2bfa 100644 --- a/libgo/misc/cgo/testplugin/test.bash +++ b/libgo/misc/cgo/testplugin/test.bash @@ -16,7 +16,7 @@ goarch=$(go env GOARCH) function cleanup() { rm -f plugin*.so unnamed*.so iface*.so - rm -rf host pkg sub iface issue18676 + rm -rf host pkg sub iface issue18676 issue19534 } trap cleanup EXIT @@ -44,3 +44,9 @@ LD_LIBRARY_PATH=$(pwd) ./iface GOPATH=$(pwd) go build -buildmode=plugin -o plugin.so src/issue18676/plugin.go GOPATH=$(pwd) go build -o issue18676 src/issue18676/main.go timeout 10s ./issue18676 + +# Test for issue 19534 - that we can load a plugin built in a path with non-alpha +# characters +GOPATH=$(pwd) go build -buildmode=plugin -ldflags='-pluginpath=issue.19534' -o plugin.so src/issue19534/plugin.go +GOPATH=$(pwd) go build -o issue19534 src/issue19534/main.go +./issue19534 diff --git a/libgo/misc/cgo/testplugin/unnamed1.go b/libgo/misc/cgo/testplugin/unnamed1.go index 102edaf3e29..5c1df086d76 100644 --- a/libgo/misc/cgo/testplugin/unnamed1.go +++ b/libgo/misc/cgo/testplugin/unnamed1.go @@ -9,4 +9,15 @@ import "C" func FuncInt() int { return 1 } +// Add a recursive type to to check that type equality across plugins doesn't +// crash. See https://golang.org/issues/19258 +func FuncRecursive() X { return X{} } + +type Y struct { + X *X +} +type X struct { + Y Y +} + func main() {} diff --git a/libgo/misc/cgo/testplugin/unnamed2.go b/libgo/misc/cgo/testplugin/unnamed2.go index 55070d5e9f7..7ef66109c5c 100644 --- a/libgo/misc/cgo/testplugin/unnamed2.go +++ b/libgo/misc/cgo/testplugin/unnamed2.go @@ -9,4 +9,13 @@ import "C" func FuncInt() int { return 2 } +func FuncRecursive() X { return X{} } + +type Y struct { + X *X +} +type X struct { + Y Y +} + func main() {} |