diff options
| author | Hyang-Ah (Hana) Kim <hyangah@gmail.com> | 2015-05-12 16:47:40 -0400 |
|---|---|---|
| committer | Hyang-Ah Hana Kim <hyangah@gmail.com> | 2015-05-12 23:46:33 +0000 |
| commit | a4f4a46c28fdf6a2b0724bd779c9cf1bad32b066 (patch) | |
| tree | ce450baa0d63c7a4af93bb82289051a19a611613 /misc/cgo/testcshared/test.bash | |
| parent | c06b8565558d9060aad39442270e9fd48f2448b6 (diff) | |
| download | go-a4f4a46c28fdf6a2b0724bd779c9cf1bad32b066.tar.xz | |
misc/cgo/testcshared: fix test for android.
On android the generated header files are located in
pkg/$(go env GOOS)_$(go env GOARCH)_testcshared.
The test was broken since https://go-review.googlesource.com/9798.
The installation path differs based on codegenArgs
(around src/cmd/go/build.go line 389), and the codegenArgs
is platform dependent.
Change-Id: I01ae9cb957fb7676e399f3b8c067f24c5bd20b9d
Reviewed-on: https://go-review.googlesource.com/9980
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'misc/cgo/testcshared/test.bash')
| -rwxr-xr-x | misc/cgo/testcshared/test.bash | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/misc/cgo/testcshared/test.bash b/misc/cgo/testcshared/test.bash index 9862a37993..ed437577c7 100755 --- a/misc/cgo/testcshared/test.bash +++ b/misc/cgo/testcshared/test.bash @@ -15,6 +15,14 @@ if [ ! -f src/libgo/libgo.go ]; then fi goos=$(go env GOOS) +goarch=$(go env GOARCH) + +# Directory where cgo headers and outputs will be installed. +# The installation directory format varies depending on the platform. +installdir=pkg/${goos}_${goarch}_testcshared_shared +if [ "${goos}/${goarch}" == "android/arm" ]; then + installdir=pkg/${goos}_${goarch}_testcshared +fi # Temporary directory on the android device. androidpath=/data/local/tmp/testcshared-$$ @@ -22,9 +30,9 @@ androidpath=/data/local/tmp/testcshared-$$ function cleanup() { rm -rf libgo.so libgo2.so libgo.h testp testp2 testp3 pkg - rm -rf $(go env GOROOT)/pkg/$(go env GOOS)_$(go env GOARCH)_testcshared_shared + rm -rf $(go env GOROOT)/${installdir} - if [ "$(go env GOOS)" == "android" ]; then + if [ "$goos" == "android" ]; then adb shell rm -rf $androidpath fi } @@ -38,11 +46,8 @@ function run() { case "$goos" in "android") local args=$@ - for ((i=0; i < ${#args}; i++)); do - args[$i]=${args[$i]//.\//${androidpath}\/} - args[$i]=${args[$i]//=./=${androidpath}} - done - output=$(adb shell ${args} | tr -d '\r') + output=$(adb shell "cd ${androidpath}; env $@") + output=$(echo $output|tr -d '\r') case $output in *PASS) echo "PASS";; *) echo "$output";; @@ -73,8 +78,9 @@ binpush libgo.so # test0: exported symbols in shared lib are accessible. # TODO(iant): using _shared here shouldn't really be necessary. -$(go env CC) $(go env GOGCCFLAGS) -I pkg/$(go env GOOS)_$(go env GOARCH)_testcshared_shared -o testp main0.c libgo.so +$(go env CC) $(go env GOGCCFLAGS) -I ${installdir} -o testp main0.c libgo.so binpush testp + output=$(run LD_LIBRARY_PATH=. ./testp) if [ "$output" != "PASS" ]; then echo "FAIL test0 got ${output}" |
