1#! /bin/sh 2 3set -e 4 5agrep="$top_builddir/src/agrep" 6 7echo "$builddir $top_builddir $srcdir" 8 9num_cases=0 10num_expanded=0 11num_tests=0 12num_fail=0 13num_ok=0 14 15SIFS="$IFS" 16 17for args in $srcdir/*.args; do 18 dir=`dirname $args` 19 base=`basename $args .args` 20 orig_input=$dir/$base.input 21 input=$base.in 22 ok=$dir/$base.ok 23 out=$base.out 24 25 rm -f $out 26 IFS=" 27" 28 for arg in `cat $args`; do 29 IFS="$SIFS" 30 case "$arg" in 31 \#*) continue;; 32 esac 33 34 num_cases=`expr $num_cases + 1` 35 cp "$orig_input" $input 36 37 for extra in "" -c -H -l -n -s -M --show-position --color \ 38 "-H -n -s --color --show-position"; do 39 num_expanded=`expr $num_expanded + 1` 40 # Note that `echo' cannot be used since it works differently on 41 # different platforms with regards to expanding \n (IRIX expands 42 # it, others typically do not). `cat' doesn't process its output. 43 cat >> $out <<EOF 44#### TEST: agrep $extra $arg $input 45EOF 46 cat <<EOF 47agrep $extra $arg $input 48EOF 49 set +e 50 $agrep $extra $arg $input >> $out 51 status=$? 52 set -e 53 cat >> $out <<EOF 54 55Exit status $status. 56EOF 57 58 num_expanded=`expr $num_expanded + 1` 59 cat >> $out <<EOF 60#### TEST: agrep $extra $arg < $input 61EOF 62 cat <<EOF 63agrep $extra $arg < $input 64EOF 65 set +e 66 $agrep $extra $arg < $input >> $out 67 status=$? 68 set -e 69 cat >> $out <<EOF 70 71Exit status $status. 72EOF 73 done 74 done 75 num_tests=`expr $num_tests + 1` 76 case $host_triplet in 77 *-mingw*) 78 # On MinGW something causes \r\n newlines to be output to $out, 79 # and our reference results don't have them. 80 tr -d '\015' < $out > $out.tmp 81 mv $out.tmp $out 82 ;; 83 esac 84 if diff $ok $out; then 85 num_ok=`expr $num_ok + 1` 86 else 87 echo "FAILED (see above)" 88 num_fail=`expr $num_fail + 1` 89 fi 90done 91 92echo "Ran $num_cases tests ($num_expanded expanded) from $num_tests suites." 93echo "$num_ok/$num_tests tests OK" 94 95test $num_fail -eq 0 96exit $? 97