1#!/bin/sh 2# Id: run_test.sh,v 1.8 2012/01/15 11:50:35 tom Exp 3# vi:ts=4 sw=4: 4 5if test $# = 1 6then 7 PROG_DIR=`pwd` 8 TEST_DIR=$1 9else 10 PROG_DIR=.. 11 TEST_DIR=. 12fi 13 14YACC=$PROG_DIR/yacc 15 16tmpfile=temp$$ 17rm -f test-* 18 19echo '** '`date` 20for input in ${TEST_DIR}/*.y 21do 22 case $input in 23 test*) 24 echo "?? ignored $input" 25 ;; 26 *) 27 root=`basename $input .y` 28 ROOT="test-$root" 29 prefix=${root}_ 30 31 OPTS= 32 OPT2= 33 TYPE=".output .tab.c .tab.h" 34 case $input in 35 ${TEST_DIR}/code_*) 36 OPTS="$OPTS -r" 37 TYPE="$TYPE .code.c" 38 prefix=`echo "$prefix" | sed -e 's/^code_//'` 39 ;; 40 ${TEST_DIR}/pure_*) 41 OPTS="$OPTS -P" 42 prefix=`echo "$prefix" | sed -e 's/^pure_//'` 43 ;; 44 ${TEST_DIR}/quote_*) 45 OPT2="-s" 46 ;; 47 esac 48 49 for opt2 in "" $OPT2 50 do 51 $YACC $OPTS $opt2 -v -d -p $prefix -b $ROOT${opt2} $input 52 for type in $TYPE 53 do 54 REF=${TEST_DIR}/${root}${opt2}${type} 55 CMP=${ROOT}${opt2}${type} 56 if test ! -f $CMP 57 then 58 echo "...not found $CMP" 59 else 60 sed -e s,$CMP,$REF, \ 61 -e /YYPATCH/d \ 62 -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \ 63 < $CMP >$tmpfile \ 64 && mv $tmpfile $CMP 65 if test ! -f $REF 66 then 67 mv $CMP $REF 68 echo "...saved $REF" 69 elif ( cmp -s $REF $CMP ) 70 then 71 echo "...ok $REF" 72 rm -f $CMP 73 else 74 echo "...diff $REF" 75 diff -u $REF $CMP 76 fi 77 fi 78 done 79 done 80 ;; 81 esac 82done 83