#!/bin/sh

set -e

indir=debian/tests/why
outdir=${TMPDIR-/tmp}

for infile in $indir/*.why
do
    base=$(basename $infile)
    echo "Testing why + cvc3 on $base" >&2
    whyoutfile=$outdir/${base%.why}_why.cvc
    cvcoutfile=$outdir/${base%.why}.cvcout
    why --cvcl --output $whyoutfile $infile
    cvc3 $whyoutfile > $cvcoutfile
    if $(grep -qv "Valid" $cvcoutfile); then
	cat $cvcoutfile
	exit 1
    fi
done