misc/cgo/testcshared: add c-shared test with no exports
The purpose of this test is to make sure that -buildmode=c-shared
works even when the shared library can be built without invoking cgo.
Change-Id: Id6f95af755992b209aff770440ca9819b74113ab
Reviewed-on: https://go-review.googlesource.com/9166
Reviewed-by: David Crawshaw <crawshaw@golang.org>
diff --git a/misc/cgo/testcshared/test.bash b/misc/cgo/testcshared/test.bash
index 61f80ea..1c2e3c2 100755
--- a/misc/cgo/testcshared/test.bash
+++ b/misc/cgo/testcshared/test.bash
@@ -6,7 +6,7 @@
set -e
function cleanup() {
- rm libgo.so testp
+ rm -f libgo.so libgo2.so testp testp2
}
trap cleanup EXIT
@@ -27,3 +27,13 @@
echo "FAIL: got $output"
exit 1
fi
+
+GOPATH=$(pwd) go build -buildmode=c-shared -o libgo2.so src/libgo2/libgo2.go
+
+$(go env CC) $(go env GOGCCFLAGS) -o testp2 main2.c -Wl,--no-as-needed libgo2.so
+output=$(LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./testp2)
+# testp2 prints PASS at the end of its execution.
+if [ "$output" != "PASS" ]; then
+ echo "FAIL: got $output"
+ exit 1
+fi