#!/bin/sh # # Compile the compiler and run the test suite. # # Test programs with no corresponding .in files are expected to fail # at compile-time. The error message is not controlled. This script # should be run from the directory containing the compiler. # # Written by Troels Henriksen . # RESDIR is the path at which test programs can be found. RESDIR=. RESDIR=/home/athas/G/ sh compile.sh chmod +x CC for CAT in $RESDIR/*cat; do CAT=$(basename $CAT) echo Testing $CAT: PROG=$(echo $CAT|sed 's/.cat$//') INPUT=$(echo $CAT|sed 's/cat$/in/') OUTPUT=$(echo $CAT|sed 's/cat$/out/') ASM=$(echo $CAT|sed 's/cat$/asm/') TESTOUT=$(mktemp) CORRECTOUT=$(mktemp) if [ -f $RESDIR/$INPUT ]; then ./CC $RESDIR/$PROG if [ -f $RESDIR/$ASM ]; then touch $RESDIR/$INPUT java -jar $RESDIR/Mars_4_0_1.jar $RESDIR/$ASM < $RESDIR/$INPUT | tail -n +2 > $TESTOUT if [ -f $RESDIR/$OUTPUT ]; then tail -n +2 $RESDIR/$OUTPUT > $CORRECTOUT if ! cmp -s $CORRECTOUT $TESTOUT; then echo Output for $PROG does not match expected output. fi rm $CORRECTOUT fi fi else ./CC $RESDIR/$PROG >& $TESTOUT if cmp -s $TESTOUT /dev/null; then echo $PROG compiled, but should result in compile error. fi fi done rm $TESTOUT