#!/bin/sh

set -e

this=frama-c+jessie+alt-ergo
indir=${PWD}/debian/tests/c
outdir=${ADT_ARTIFACTS}/${this}
mkdir -p ${outdir}

# why expects a ${HOME}/.whyrc :-(
export HOME=${ADTTMP}
why-config  > /dev/null 2>&1

cd ${outdir}

for infile in ${indir}/minimum.c
do
    base=$(basename $infile)
    # we copy the input file into the outdir since jessie insists on
    # creating "project" files in the directory of the input file :-(
    cp ${infile} .
    framacoutfile=${base%.c}.frc
    successpattern="why/${base%.c}_why.why           : .. (2/0/0/0/0)"
    frama-c -jessie -jessie-atp=alt-ergo ${base} \
        | tee ${framacoutfile} \
	| grep -q "${successpattern}"
done
