#!/bin/sh
if [ $# = 0 ] ; then
set -- test/*.c
fi
numfail=0
out=$(mktemp)
trap 'rm "$out"' EXIT
for test ; do
if ${CCQBE:=./cproc-qbe} -o $out $test && diff -Nu "${test%.c}.qbe" "$out" ; then
result="PASS"
else
result="FAIL"
numfail=$((numfail + 1))
fi
echo "[$result] $test" >&2
done
if [ "$numfail" -gt 0 ] ; then
printf "%d test(s) failed\n" "$numfail"
exit 1
fi