2012-05-03 09:57:52 +00:00
|
|
|
#!/bin/sh
|
2023-02-07 17:25:11 +00:00
|
|
|
# $Id: run_make.sh,v 1.21 2022/11/06 20:57:33 tom Exp $
|
2012-05-03 09:57:52 +00:00
|
|
|
# vi:ts=4 sw=4:
|
|
|
|
|
|
|
|
# do a test-compile on each of the ".c" files in the test-directory
|
|
|
|
|
|
|
|
BISON=`bison --version 2>/dev/null | head -n 1 | sed -e 's/^[^0-9.]*//' -e 's/[^0-9.]*$//'`
|
|
|
|
|
|
|
|
if test $# = 1
|
|
|
|
then
|
|
|
|
PROG_DIR=`pwd`
|
|
|
|
TEST_DIR=$1
|
|
|
|
else
|
|
|
|
PROG_DIR=..
|
|
|
|
TEST_DIR=.
|
|
|
|
fi
|
2014-04-22 22:11:22 +00:00
|
|
|
THIS_DIR=`pwd`
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2023-02-07 17:25:11 +00:00
|
|
|
: "${FGREP:=grep -F}"
|
|
|
|
ifBTYACC=`$FGREP -l 'define YYBTYACC' config.h > /dev/null; test $? != 0; echo $?`
|
2014-04-22 22:11:22 +00:00
|
|
|
|
2023-02-07 17:25:11 +00:00
|
|
|
if test "$ifBTYACC" = 0; then
|
2014-04-22 22:11:22 +00:00
|
|
|
REF_DIR=${TEST_DIR}/yacc
|
|
|
|
else
|
|
|
|
REF_DIR=${TEST_DIR}/btyacc
|
|
|
|
fi
|
|
|
|
|
|
|
|
MY_MAKE="make -f $PROG_DIR/makefile srcdir=$PROG_DIR"
|
|
|
|
|
|
|
|
run_make() {
|
|
|
|
C_FILE=`basename "$1"`
|
|
|
|
O_FILE=`basename "$C_FILE" .c`.o
|
|
|
|
shift
|
2023-02-07 17:25:11 +00:00
|
|
|
RETEST=`unset CDPATH; cd $TEST_DIR; pwd`
|
|
|
|
cd "$REF_DIR"
|
|
|
|
test -f "$I_FILE" && rm "$I_FILE"
|
|
|
|
make -f "$PROG_DIR/makefile" EXTRA_CFLAGS=-I$RETEST srcdir="$PROG_DIR" "$O_FILE" "$@"
|
|
|
|
test -f "$O_FILE" && rm "$O_FILE"
|
|
|
|
cd "$THIS_DIR"
|
2014-04-22 22:11:22 +00:00
|
|
|
}
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2023-02-07 17:25:11 +00:00
|
|
|
echo "** `date`"
|
2014-04-22 22:11:22 +00:00
|
|
|
echo "** program is in $PROG_DIR"
|
|
|
|
echo "** test-files in $REF_DIR"
|
|
|
|
|
|
|
|
for input in ${REF_DIR}/*.c
|
2012-05-03 09:57:52 +00:00
|
|
|
do
|
2014-04-22 22:11:22 +00:00
|
|
|
case $input in #(vi
|
2016-10-04 20:54:49 +00:00
|
|
|
${REF_DIR}/err_*|\
|
|
|
|
${REF_DIR}/test-err_*)
|
2014-04-22 22:11:22 +00:00
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2014-04-22 22:11:22 +00:00
|
|
|
test -f "$input" || continue
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2014-04-22 22:11:22 +00:00
|
|
|
run_make "$input"
|
2012-05-03 09:57:52 +00:00
|
|
|
|
|
|
|
DEFS=
|
|
|
|
case $input in #(vi
|
2014-04-22 22:11:22 +00:00
|
|
|
${REF_DIR}/pure_*)
|
2012-05-03 09:57:52 +00:00
|
|
|
# DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if test "x$DEFS" != "x"
|
|
|
|
then
|
2014-04-22 22:11:22 +00:00
|
|
|
run_make "$input" DEFINES="$DEFS"
|
2012-05-03 09:57:52 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -n "$BISON"
|
|
|
|
then
|
|
|
|
echo "** compare with bison $BISON"
|
|
|
|
for input in ${TEST_DIR}/*.y
|
|
|
|
do
|
|
|
|
test -f "$input" || continue
|
2014-04-22 22:11:22 +00:00
|
|
|
case $input in
|
2016-10-04 20:54:49 +00:00
|
|
|
${TEST_DIR}/err_*|\
|
|
|
|
${TEST_DIR}/test-err_*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
${TEST_DIR}/ok_syntax*|\
|
|
|
|
${TEST_DIR}/varsyntax*)
|
|
|
|
# Bison does not support all byacc legacy syntax
|
2014-04-22 22:11:22 +00:00
|
|
|
continue
|
|
|
|
;;
|
|
|
|
${TEST_DIR}/btyacc_*)
|
2016-10-04 20:54:49 +00:00
|
|
|
# Bison does not support the btyacc []-action & inherited attribute extensions.
|
2014-04-22 22:11:22 +00:00
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
2012-05-03 09:57:52 +00:00
|
|
|
|
|
|
|
# Bison does not support pure-parser from command-line.
|
|
|
|
# Also, its support for %expect is generally broken.
|
|
|
|
# Work around these issues using a temporary file.
|
|
|
|
|
|
|
|
echo "... testing $input"
|
|
|
|
rm -f run_make.[coy]
|
|
|
|
|
|
|
|
case $input in
|
2014-04-22 22:11:22 +00:00
|
|
|
${TEST_DIR}/pure_*)
|
2023-02-07 17:25:11 +00:00
|
|
|
if test -z "`$FGREP -i -l '%pure-parser' "$input"`"
|
2012-05-03 09:57:52 +00:00
|
|
|
then
|
|
|
|
echo "%pure-parser" >>run_make.y
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-02-07 17:25:11 +00:00
|
|
|
sed -e '/^%expect/s,%expect.*,,' "$input" >>run_make.y
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2020-06-22 22:42:20 +00:00
|
|
|
case $BISON in
|
|
|
|
[3-9].[0-9]*.[0-9]*)
|
|
|
|
bison -Wno-other -Wno-conflicts-sr -Wconflicts-rr -y -Wno-yacc run_make.y
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
bison -y run_make.y
|
|
|
|
;;
|
|
|
|
esac
|
2014-04-22 22:11:22 +00:00
|
|
|
if test -f "y.tab.c"
|
|
|
|
then
|
2023-02-07 17:25:11 +00:00
|
|
|
sed -e '/^#line/s,"run_make.y","'"$input"'",' y.tab.c >run_make.c
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2014-04-22 22:11:22 +00:00
|
|
|
rm -f y.tab.c
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2014-04-22 22:11:22 +00:00
|
|
|
input=run_make.c
|
|
|
|
object=run_make.o
|
|
|
|
if test -f $input
|
|
|
|
then
|
|
|
|
$MY_MAKE $object DEFINES='-DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=1 -DYYSTACK_USE_ALLOCA=0 -DYYMAXDEPTH=0'
|
|
|
|
else
|
|
|
|
echo "?? $input not found"
|
|
|
|
fi
|
2012-05-03 09:57:52 +00:00
|
|
|
fi
|
|
|
|
rm -f run_make.[coy]
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
YACC=
|
|
|
|
for name in /usr/ccs/bin/yacc
|
|
|
|
do
|
|
|
|
if test -f $name
|
|
|
|
then
|
|
|
|
YACC=$name
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -n "$YACC"
|
|
|
|
then
|
|
|
|
echo "** compare with $YACC"
|
|
|
|
for input in ${TEST_DIR}/*.y
|
|
|
|
do
|
|
|
|
test -f "$input" || continue
|
|
|
|
|
|
|
|
echo "... testing $input"
|
|
|
|
rm -f run_make.[coy]
|
|
|
|
|
|
|
|
case $input in
|
|
|
|
pure_*)
|
|
|
|
echo "... skipping $input"
|
|
|
|
continue;
|
|
|
|
;;
|
|
|
|
*)
|
2023-02-07 17:25:11 +00:00
|
|
|
if $FGREP -i '%pure-parser' "$input" >/dev/null ||
|
|
|
|
$FGREP -i '%parse-param' "$input" >/dev/null ||
|
|
|
|
$FGREP -i '%lex-param' "$input" >/dev/null ||
|
|
|
|
$FGREP -i '%token-table' "$input" >/dev/null ||
|
|
|
|
$FGREP 'YYLEX_PARAM' "$input" >/dev/null
|
2012-05-03 09:57:52 +00:00
|
|
|
then
|
|
|
|
echo "... skipping $input"
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-02-07 17:25:11 +00:00
|
|
|
sed -e '/^%expect/s,%expect.*,,' "$input" >>run_make.y
|
2012-05-03 09:57:52 +00:00
|
|
|
|
|
|
|
$YACC run_make.y
|
2014-04-22 22:11:22 +00:00
|
|
|
if test -f y.tab.c
|
|
|
|
then
|
2023-02-07 17:25:11 +00:00
|
|
|
sed -e '/^#line/s,"run_make.y","'"$input"'",' y.tab.c >run_make.c
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2014-04-22 22:11:22 +00:00
|
|
|
rm -f y.tab.c
|
2012-05-03 09:57:52 +00:00
|
|
|
|
2014-04-22 22:11:22 +00:00
|
|
|
input=run_make.c
|
|
|
|
object=run_make.o
|
|
|
|
if test -f $input
|
|
|
|
then
|
|
|
|
$MY_MAKE $object
|
|
|
|
else
|
|
|
|
echo "?? $input not found"
|
|
|
|
fi
|
2012-05-03 09:57:52 +00:00
|
|
|
fi
|
|
|
|
rm -f run_make.[coy]
|
|
|
|
done
|
|
|
|
fi
|