2 # $Id: run_test.sh,v 1.31 2019/11/03 23:44:07 tom Exp $
7 # NEW is the file created by the testcase
8 # REF is the reference file against which to compare
10 # echo "...test_diffs $NEW vs $REF"
11 mv -f $NEW ${REF_DIR}/
15 echo "...not found $CMP"
19 -e "s%$YACC_escaped%YACC%" \
20 -e "s%^yacc\>%YACC%" \
21 -e "s%YACC:.*option.*$%YACC: error message%" \
22 -e "s%^Usage: yacc\>%Usage: YACC%" \
23 -e '/YYPATCH/s/[0-9][0-9]*/"yyyymmdd"/' \
24 -e '/#define YYPATCH/s/PATCH/CHECK/' \
25 -e 's,#line \([1-9][0-9]*\) "'$REF_DIR'/,#line \1 ",' \
26 -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
27 -e 's,\(YACC:.* line [0-9][0-9]* of "\)'$TEST_DIR/',\1./,' \
34 elif ( cmp -s $REF $CMP )
47 echo "** testing flags $*"
51 $YACC "$@" >$ROOT.output 2>$ROOT.error
52 for type in .output .error
55 REF=$REF_DIR/$root$type
61 echo "** testing stdin $*"
67 code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"`
68 if test "x$opts" = "x-"
70 $YACC -o $ROOT.$code $opts <$1 >$ROOT.output 2>$ROOT.error
72 $YACC -o $ROOT.$code $opts $1 >$ROOT.output 2>$ROOT.error
74 for type in .output .error .$code
77 REF=$REF_DIR/$root$type
83 echo "** testing defines $*"
93 head=`echo "$1"|sed -e 's/y$/h/' -e "s,${TEST_DIR}/,,"`
94 code=`echo "$1"|sed -e 's/y$/c/' -e "s,${TEST_DIR}/,,"`
95 $YACC $opts -H $ROOT.$head $1 >$ROOT.output 2>$ROOT.error
96 for name in prefix.tab.c y.tab.c
104 for name in .output .error .$head .$code
107 REF=$REF_DIR/$root$name
116 PROG_DIR=`echo "$PROG_DIR" | sed -e 's/ /\\\\ /g'`
117 TEST_DIR=`echo "$TEST_DIR" | sed -e 's/ /\\\\ /g'`
124 YACC_escaped=`echo "$PROG_DIR/yacc" | sed -e 's/\./\\\./g'`
128 ifBTYACC=`fgrep -l 'define YYBTYACC' $PROG_DIR/config.h > /dev/null; test $? != 0; echo $?`
130 if test $ifBTYACC = 0; then
131 REF_DIR=${TEST_DIR}/yacc
133 REF_DIR=${TEST_DIR}/btyacc
136 rm -f ${REF_DIR}/test-*
140 # Tests which do not need files
146 # Test attempts to read non-existent file
148 test_flags nostdin - $MYFILE.y
149 test_flags no_opts -- $MYFILE.y
151 # Test attempts to write to readonly file
156 test_flags no_b_opt -b
157 test_flags no_b_opt1 -bBASE -o $MYFILE.c $MYFILE.y
161 test_flags no_p_opt -p
162 test_flags no_p_opt1 -pBASE -o $MYFILE.c $MYFILE.y
167 test_flags no_graph -g -o $MYFILE.c $MYFILE.y
172 test_flags no_verbose -v -o $MYFILE.c $MYFILE.y
173 test_flags no_output -o $MYFILE.output $MYFILE.y
174 test_flags no_output1 -o$MYFILE.output $MYFILE.y
175 test_flags no_output2 -o
180 test_flags no_defines -d -o $MYFILE.c $MYFILE.y
185 test_flags no_include -i -o $MYFILE.c $MYFILE.y
190 test_flags no_code_c -r -o $MYFILE.c $MYFILE.y
196 test_stdin stdin1 - ${TEST_DIR}/calc.y
197 test_stdin stdin2 -- ${TEST_DIR}/calc.y
199 test_defines defines1 ${TEST_DIR}/calc.y
200 test_defines defines2 -d ${TEST_DIR}/calc.y
201 test_defines defines3 -b prefix ${TEST_DIR}/calc.y
203 for input in ${TEST_DIR}/*.y
207 echo "?? ignored $input"
210 root=`basename $input .y`
217 TYPE=".error .output .tab.c .tab.h"
219 ${TEST_DIR}/btyacc_*)
220 if test $ifBTYACC = 0; then continue; fi
222 prefix=`echo "$prefix" | sed -e 's/^btyacc_//'`
224 ${TEST_DIR}/grammar*)
228 ${TEST_DIR}/code_debug*)
237 prefix=`echo "$prefix" | sed -e 's/^code_//'`
241 prefix=`echo "$prefix" | sed -e 's/^pure_//'`
246 ${TEST_DIR}/inherit*|\
247 ${TEST_DIR}/err_inherit*)
248 if test $ifBTYACC = 0; then continue; fi
252 echo "** testing $input"
254 test -n "$prefix" && prefix="-p $prefix"
262 error=`basename $OOPT .c`.error
264 error=${ROOT}${opt2}.error
267 $YACC $OPTS $opt2 -v -d $output $prefix -b $ROOT${opt2} $input 2>$error
270 REF=${REF_DIR}/${root}${opt2}${type}
272 # handle renaming due to "-o" option
285 NEW=`basename $OOPT .c`${type}
299 NEW=${ROOT}${opt2}${type}