#!/bin/bash # # alltests - run the regression tests for chess in the test subdirectory # Test file format: # Line 1: stdin # Line 2: command line # Rest: expected output # set -x PRGINPUT=test.in PRGOUTPUT=test.out EXPOUTPUT=expect.out list=$* test $# = 0 && list=*.tst trap 'rm -f $PRGOUTPUT $EXPOUTPUT $PRGINPUT' EXIT SIGINT SIGHUP SIGTERM for file in $list; do sed -n '1p;1q' $file > $PRGINPUT awk 'NR>2' $file > $EXPOUTPUT eval `sed -n '2p;2q' $file` < $PRGINPUT > $PRGOUTPUT 2>&1 # cat $EXPOUTPUT $PRGOUTPUT if diff -b $PRGOUTPUT $EXPOUTPUT >/dev/null; then echo "OK: $file" else echo "Differences for $file:" echo "% diff -b PRGOUTPUT EXPOUTPUT" diff $PRGOUTPUT $EXPOUTPUT fi done exit 0