test.bash 870 B

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