#!/bin/bash num="$1" if [[ 'X' == "X${num}" ]] then echo "Usage: ${0} num [source]" echo "where num is the udebug data case" echo " where optional source is the anme of source file without extension" echo " " echo "Example: ${0} 1 b (which will compile b.c into b and then process u1.in and compare to u1.ans" exit fi if [[ "X" == "X$2" ]] then source='a' else source="$2" if [[ ! -e ${source} ]] then echo " Source file (${source}.c) is missing!" echo " " echo "Usage: ${0} num [source]" echo "where num is the udebug data case" echo " where optional source is the anme of source file without extension" echo " " echo "Example: ${0} 1 b (which will compile b.c into b and then process u1.in and compare to u1.ans" exit fi fi echo "Compiling ${source}.c ..." gcc ${source}.c -o ${source} -lm echo "Running ${source} against input file: u${num}.in ..." time ./${source} < u${num}.in > u${num}.out tmp=$(diff --text u${num}.out u${num}.ans) cnt=$(echo "${tmp}" | wc -l) if ((1 < cnt)) then echo "${cnt} difference lines found" else echo "Correct" fi