]> Cypherpunks.ru repositories - gostls13.git/blob - misc/cgo/fortran/test.bash
runtime: run TestCgoSigfwd on all Unix platforms
[gostls13.git] / misc / cgo / fortran / test.bash
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.
5
6 # This directory is intended to test the use of Fortran with cgo.
7
8 set -e
9
10 FC=$1
11
12 goos=$(go env GOOS)
13
14 libext="so"
15 if [ "$goos" = "darwin" ]; then
16         libext="dylib"
17 elif [ "$goos" = "aix" ]; then
18         libtext="a"
19 fi
20
21 case "$FC" in
22 *gfortran*)
23   libpath=$(dirname $($FC -print-file-name=libgfortran.$libext))
24   if [ "$goos" != "aix" ]; then
25           RPATH_FLAG="-Wl,-rpath,$libpath"
26   fi
27   export CGO_LDFLAGS="$CGO_LDFLAGS $RPATH_FLAG -L $libpath"
28   ;;
29 esac
30
31 if ! $FC helloworld/helloworld.f90 -o /dev/null >& /dev/null; then
32   echo "skipping Fortran test: could not build helloworld.f90 with $FC"
33   exit 0
34 fi
35 rm -f main.exe
36
37 status=0
38
39 if ! go test; then
40   echo "FAIL: go test"
41   status=1
42 fi
43
44 exit $status