2016-08-26 07:04:27 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Copyright 2016 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.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ ! -f src/host/host.go ]; then
|
|
|
|
cwd=$(pwd)
|
|
|
|
echo "misc/cgo/testplugin/test.bash is running in $cwd" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
goos=$(go env GOOS)
|
|
|
|
goarch=$(go env GOARCH)
|
|
|
|
|
|
|
|
function cleanup() {
|
2017-01-11 16:08:08 -07:00
|
|
|
rm -f plugin*.so unnamed*.so iface*.so
|
2017-04-25 17:32:48 -06:00
|
|
|
rm -rf host pkg sub iface issue18676 issue19534
|
2016-08-26 07:04:27 -06:00
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
2016-10-30 13:31:21 -06:00
|
|
|
rm -rf pkg sub
|
|
|
|
mkdir sub
|
2016-08-26 07:04:27 -06:00
|
|
|
|
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin plugin1
|
2016-10-30 21:53:09 -06:00
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin plugin2
|
2016-11-12 04:24:36 -07:00
|
|
|
GOPATH=$(pwd)/altpath go build -buildmode=plugin plugin-mismatch
|
2016-10-30 13:31:21 -06:00
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin -o=sub/plugin1.so sub/plugin1
|
2016-11-12 04:50:24 -07:00
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin unnamed1.go
|
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin unnamed2.go
|
2016-08-26 07:04:27 -06:00
|
|
|
GOPATH=$(pwd) go build host
|
|
|
|
|
|
|
|
LD_LIBRARY_PATH=$(pwd) ./host
|
2017-01-11 16:08:08 -07:00
|
|
|
|
|
|
|
# Test that types and itabs get properly uniqified.
|
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin iface_a
|
|
|
|
GOPATH=$(pwd) go build -buildmode=plugin iface_b
|
|
|
|
GOPATH=$(pwd) go build iface
|
|
|
|
LD_LIBRARY_PATH=$(pwd) ./iface
|
2017-01-11 16:14:06 -07:00
|
|
|
|
|
|
|
# Test for issue 18676 - make sure we don't add the same itab twice.
|
|
|
|
# The buggy code hangs forever, so use a timeout to check for that.
|
|
|
|
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
|
2017-04-25 17:32:48 -06:00
|
|
|
|
|
|
|
# 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
|