h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

test.sh (685B)


      1 #!/bin/sh
      2 
      3 re="${TEST:-$@}"
      4 
      5 TESTBIN="test/run"
      6 TESTOUT="test/last.out"
      7 TESTERR="test/last.err"
      8 
      9 for t in test/*; do
     10 	if [ -n "$re" ] && !(echo "$t" | grep -q "$re"); then
     11 		continue
     12 	fi
     13 
     14 	# Verify if $t is a directory and if its name starts with three digits
     15 	if [ -d "$t" ] && basename "$t" | grep -Eq '^[0-9]{3}'; then
     16 		$CC -o $TESTBIN "$t"/*.c $OBJ || exit 1
     17 		for cin in "$t"/*.in; do
     18 			c=$(echo "$cin" | sed 's/\.in//')
     19 			cout="$c.out"
     20 			printf "%s: " "$c"
     21 			$TESTBIN < "$cin" > $TESTOUT 2> $TESTERR
     22 			if diff "$cout" "$TESTOUT"; then
     23 				printf "OK\n"
     24 			else
     25 				printf "Test failed! stderr:\n"
     26 				cat $TESTERR
     27 				exit 1
     28 			fi
     29 		done
     30 	fi
     31 done
     32 
     33 echo "All tests passed!"