#!/bin/bash #created by Dr. Ramsey #last edited on 01/30/2006 wc=$(echo "202") dt=$(echo "/home/netdrive/faculty/sramsey2/public_html/class/06SPRING/testcases/"$wc) cd cd $wc # pwd echo "Which program #?" read pnum echo let " pnum += 0 " pr=$(echo "hw"$pnum) pc=$(echo "hw"$pnum".cpp") fl=$(echo $dt"/filelist"$pr) if [ -e $fl ]; then files=$(cat $fl) echo " (*) Expecting the files ["$files"] in ~/"$wc else echo " (*) ERROR LIST OF FILES NOT YET CREATED " exit fi files=$(cat $fl) # echo "[*]DEBUG: "$files #echo " (*) Expecting a file called hw"$pnum".cpp in directory ~/"$wc list=$(echo $pnum".1 "$pnum".2 "$pnum".3 "$pnum".4 "$pnum".5") #list=$(echo "in"$pnum".1") # echo $list if [ -e $pc ]; then echo " (*) Recompiling: [g++ "$files" -o "$pr"]" g++ $files -o $pr val=$(echo $?) let " val += 0 " if [ $val -eq 0 ]; then echo -en '\E[40;32m'"\033[1m (*) [PASS] compilation\033[0m" echo else echo -en '\E[40;31m'"\033[1m (*) [FAIL] compilation\033[0m" echo fi chmod 755 $pr chmod 755 $pc echo " (*) Executing "$pr; for id in $list do ./$pr < $dt/in$id > .r diff .r $dt/out$id > .s res=$(ls -l .s | awk '{print $5}') rm -f .r rm -f .s let " res += 0 " if [ $res -eq 0 ]; then echo -en '\E[40;32m'"\033[1m (*) ["$id"] - [PASS]\033[0m" echo else echo -en '\E[40;31m'"\033[1m (*) ["$id"] - [FAIL]\033[0m" echo fi done else echo "Could not execute ~/"$wc"/"$pr fi