mirror of
https://github.com/golang/go
synced 2024-10-06 06:31:22 -06:00
92189a2be2
Followed the same test pattern in misc/cgo/testcarchive. Change-Id: I2f863b5c24a28f0b38b0128ed3e8a92c17fb5b9f Reviewed-on: https://go-review.googlesource.com/8985 Reviewed-by: David Crawshaw <crawshaw@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
30 lines
759 B
Bash
Executable File
30 lines
759 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright 2015 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
|
|
|
|
function cleanup() {
|
|
rm libgo.so testp
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
GOPATH=$(pwd) go build -buildmode=c-shared -o libgo.so src/libgo/libgo.go
|
|
|
|
$(go env CC) $(go env GOGCCFLAGS) -o testp main0.c libgo.so
|
|
output=$(LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./testp)
|
|
# testp prints PASS at the end of its execution.
|
|
if [ "$output" != "PASS" ]; then
|
|
echo "FAIL: got $output"
|
|
exit 1
|
|
fi
|
|
|
|
$(go env CC) $(go env GOGCCFLAGS) -o testp main1.c -ldl
|
|
output=$(./testp ./libgo.so)
|
|
# testp prints PASS at the end of its execution.
|
|
if [ "$output" != "PASS" ]; then
|
|
echo "FAIL: got $output"
|
|
exit 1
|
|
fi
|