Commit 046c6589 authored by David Crawshaw's avatar David Crawshaw

misc/cgo/testplugin: add test for issue 18584

Fixes #18584

Change-Id: I5f9428758999cacee49f3449e596e0a88bc06f91
Reviewed-on: https://go-review.googlesource.com/67150
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 33c06b1d
// 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("G")
if err != nil {
panic(err)
}
g := sym.(func() bool)
if !g() {
panic("expected types to match, Issue #18584")
}
}
// 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 "reflect"
type C struct {
}
func F(c *C) *C {
return nil
}
func G() bool {
var c *C
return reflect.TypeOf(F).Out(0) == reflect.TypeOf(c)
}
...@@ -15,8 +15,8 @@ goos=$(go env GOOS) ...@@ -15,8 +15,8 @@ goos=$(go env GOOS)
goarch=$(go env GOARCH) goarch=$(go env GOARCH)
function cleanup() { function cleanup() {
rm -f plugin*.so unnamed*.so iface*.so rm -f plugin*.so unnamed*.so iface*.so issue*
rm -rf host pkg sub iface issue18676 issue19534 rm -rf host pkg sub iface
} }
trap cleanup EXIT trap cleanup EXIT
...@@ -61,3 +61,8 @@ _timeout 10s ./issue18676 ...@@ -61,3 +61,8 @@ _timeout 10s ./issue18676
GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -ldflags='-pluginpath=issue.19534' -o plugin.so src/issue19534/plugin.go GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -ldflags='-pluginpath=issue.19534' -o plugin.so src/issue19534/plugin.go
GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -o issue19534 src/issue19534/main.go GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -o issue19534 src/issue19534/main.go
./issue19534 ./issue19534
# Test for issue 18584
GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -o plugin.so src/issue18584/plugin.go
GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -o issue18584 src/issue18584/main.go
./issue18584
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