PR target/83013
[official-gcc.git] / libgo / misc / cgo / fortran / test.bash
blob1e0d59ea1c6a9f88bc3d59f3769e6ef8002164b6
1 #!/usr/bin/env bash
2 # Copyright 2016 The Go Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
6 # This directory is intended to test the use of Fortran with cgo.
8 set -e
10 FC=$1
12 goos=$(go env GOOS)
14 libext="so"
15 if [ "$goos" = "darwin" ]; then
16 libext="dylib"
19 case "$FC" in
20 *gfortran*)
21 libpath=$(dirname $($FC -print-file-name=libgfortran.$libext))
22 export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-rpath,$libpath -L $libpath"
24 esac
26 if ! $FC helloworld/helloworld.f90 -o main.exe >& /dev/null; then
27 echo "skipping Fortran test: could not build helloworld.f90 with $FC"
28 exit 0
30 rm -f main.exe
32 status=0
34 if ! go test; then
35 echo "FAIL: go test"
36 status=1
39 exit $status