#!/bin/sh : ${CCQBE:=./cproc-qbe} if [ $# = 0 ] ; then set -- test/*.c fi numfail=0 got=$(mktemp) trap 'rm "$got"' EXIT for test ; do name=${test%.c} if [ -f "$name.qbe" ] ; then want=$name.qbe set -- $CCQBE -o "$got" "$test" elif [ -f "$name.pp" ] ; then want=$name.pp set -- $CCQBE -E -o "$got" "$test" else echo "invalid test '$test'" >&2 set -- false fi if "$@" && diff -Nu "$want" "$got" ; 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