#!/bin/sh

set -e

cp Fortran/test/* C/test/tofits.c C/test/*.keyrec $AUTOPKGTEST_TMP/
cd $AUTOPKGTEST_TMP/

# Create FITS files for tests
gcc -O2 -o tofits tofits.c
for f in *.keyrec; do
    fits=`echo $f | sed s/.keyrec/.fits/`
    ./tofits < $f > $fits
done

# wcslib related tests only
TESTS="tlin tdis1 tdis2 tlog tprj1 tsph tspx ttab1 twcs twcssub tpih1 \
       tfitshdr twcsfix"

# Run test that need compiling programs
for t in $TESTS ; do
    gfortran -O2 -I. -I/usr/include/wcslib -o $t $t.f -lwcs -lm
    echo +++++ Test: $t +++++
    ./$t
done

