1# Common functionality for test scripts
2# Process arguments, expecting source file as 1st; optional path to f18 as 2nd
3# Set: $FLANG_FC1 to the path to the Flang frontend driver with options; $temp
4# to an empty temp directory; and $src to the full path of the single source
5# argument.
6
7function die {
8  echo "$(basename $0): $*" >&2
9  exit 1
10}
11if [[ $# < 3 ]]; then
12  echo "Usage: $(basename $0) <fortran-source> <temp test dir> <f18-command>"
13  exit 1
14fi
15
16case $1 in
17  (/*) src="$1" ;;
18  (*) src="$(dirname $0)/$1" ;;
19esac
20shift
21temp=$1
22mkdir -p $temp
23shift
24
25[[ ! -f $1 ]] && die "f18 executable not found: $1"
26FLANG_FC1="$*"
27