#!/bin/bash export LAB=lab1 (make clean; make) || exit 1 total=0 totalmax=0 rm -f total.txt *out total.txt # Test driver function runtest { prog=$1 args=$2 testinput=$3 grade=$4 totalmax=`expr $totalmax + $grade`; inputdescr= echo > none if [ "$testinput" != "none" ]; then inputdescr=" < $testinput" fi descr="$prog $args $inputdescr" echo "======= $descr ===========" #Run tested program ./$prog $args < $testinput > $prog.out ./$prog.org $args< $testinput > $prog.org.out diff $prog.out $prog.org.out > diff.out if [ $? -eq 0 ]; then cat $prog.out echo Test passed...; printf "%-36s: %-3d of %-3d\n" "$descr " $grade $grade >> total.txt total=`expr $total + $grade`; else echo "*****Test Failed*****"; echo ------ Your Output ---------- cat $prog.out echo ------ Expected Output ------ cat $prog.org.out echo ------ Difference ----------- cat diff.out echo ----------------------------- printf "%-36s: %-3d of %-3d\n" "$descr " 0 $grade >> total.txt fi echo } # List of tests running runtest test0 "" none 5 runtest test1-1 "" none 5 runtest test1-2 "" none 5 runtest test1-3 "" none 5 runtest test1-4 "" none 5 runtest test1 "" none 5 runtest test2 "" none 5 runtest test3 "" none 5 runtest test4 "" none 10 runtest test5 "" none 10 runtest test6 "" none 10 runtest test7 "" none 10 runtest test8 "" none 5 runtest test9 "" none 5 runtest test10 "" none 10 echo echo echo "-------------------------------------------------" echo "CS252: $LAB. $USER " echo "-------------------------------------------------" cat total.txt echo "-------------------------------------------------" echo "CS252: $LAB. $USER" `date` " Total: " $total of $totalmax >> total.out echo >> total.out cat total.out cat total.out >> .local.total.out echo