]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testplugin: add test for issue 18584
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 29 Sep 2017 15:40:40 +0000 (15:40 +0000)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 29 Sep 2017 22:10:22 +0000 (22:10 +0000)
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: Ian Lance Taylor <iant@golang.org>
misc/cgo/testplugin/src/issue18584/main.go [new file with mode: 0644]
misc/cgo/testplugin/src/issue18584/plugin.go [new file with mode: 0644]
misc/cgo/testplugin/test.bash

diff --git a/misc/cgo/testplugin/src/issue18584/main.go b/misc/cgo/testplugin/src/issue18584/main.go
new file mode 100644 (file)
index 0000000..c280fd4
--- /dev/null
@@ -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("G")
+       if err != nil {
+               panic(err)
+       }
+       g := sym.(func() bool)
+       if !g() {
+               panic("expected types to match, Issue #18584")
+       }
+}
diff --git a/misc/cgo/testplugin/src/issue18584/plugin.go b/misc/cgo/testplugin/src/issue18584/plugin.go
new file mode 100644 (file)
index 0000000..be0868d
--- /dev/null
@@ -0,0 +1,19 @@
+// 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)
+}
index 3f964c1b041c63da336498d1d79548ce1d3d23a3..a52aa4603704ce4b66a0a170f57c4d30ca8c92f0 100755 (executable)
@@ -15,8 +15,8 @@ goos=$(go env GOOS)
 goarch=$(go env GOARCH)
 
 function cleanup() {
-       rm -f plugin*.so unnamed*.so iface*.so
-       rm -rf host pkg sub iface issue18676 issue19534
+       rm -f plugin*.so unnamed*.so iface*.so issue*
+       rm -rf host pkg sub iface
 }
 trap cleanup EXIT
 
@@ -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" -o issue19534 src/issue19534/main.go
 ./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