#!/bin/sh
export GP='gp -q -f --test'
testdir=`pwd`/test2
bugs=0;
cd $AUTOPKGTEST_TMP
for i in `ls "$testdir/input"`; do
  if test -f "$testdir/gp/$i.gp"; then
    echo -n "Testing script $i..."
    cp "$testdir/gp/$i.gp" "$i.gp"
    if gp2c-run -p gp2c_ -g "$i.gp" < "$testdir/input/$i"  >$i.res 2>/dev/null; then
      if test -f "$testdir/res/$i.res"; then
        if diff "$testdir/res/$i.res" $i.res >/dev/null; then
          echo "OK."
        else
          echo "BUG."
          bugs=1;
        fi
      fi
    else
      echo "BUG."
      bugs=1;
    fi
  fi
done
exit $bugs
