#!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NUM=1 FAILED=0 echo "Testing binary: $1 in directory $DIR" while [ -f "$DIR/$NUM.eqns" ] do OUTPUT=$($1 "$DIR/$NUM.eqns" smart smart) DIFF=$(echo "$OUTPUT" | diff - "$DIR/$NUM.soln") if [ ! -z "$DIFF" ]; then echo "==================" echo "Test #$NUM failed:" echo "$OUTPUT" | sdiff - "$DIR/$NUM.soln" echo FAILED=$(($FAILED + 1)) fi NUM=$(($NUM + 1)) done if [ "$FAILED" -eq "0" ]; then echo "All tests passed." fi if [ ! "$FAILED" -eq "0" ]; then echo "$FAILED tests failed." fi