qse/regress/awk/regress.sh.in

368 lines
10 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
echo_so()
2009-07-01 07:14:39 +00:00
{
tput smso
while [ $# -gt 0 ]
do
echo -n "$1 "
shift
2019-06-09 16:06:03 +00:00
done
2009-07-01 07:14:39 +00:00
echo
tput rmso
}
echo_title()
{
echo "--------------------------------------------------------------------------------"
while [ $# -gt 0 ]
do
2010-08-01 01:45:47 +00:00
echo -n "[CMD] $1 "
echo -n "[CMD] $1 " >/dev/stderr
shift
done
echo
2009-07-01 07:14:39 +00:00
echo > /dev/stderr
echo "--------------------------------------------------------------------------------"
}
print_usage()
{
2009-07-01 07:14:39 +00:00
echo_so "Usage: $0 init"
echo_so " $0 test"
}
###################
# MAIN #
###################
2009-09-09 01:05:48 +00:00
[ -z "${QSEAWK}" ] && {
QSEAWK="@abs_top_builddir@/cmd/awk/.libs/qseawk"
[ -f "${QSEAWK}" ] || QSEAWK="@abs_top_builddir@/cmd/awk/qseawk"
2009-09-09 01:05:48 +00:00
}
2010-08-01 01:45:47 +00:00
[ -z "${QSESED}" ] && {
QSESED="@abs_top_builddir@/cmd/sed/.libs/qsesed"
[ -f "${QSESED}" ] || QSESED="@abs_top_builddir@/cmd/sed/qsesed"
2010-08-01 01:45:47 +00:00
}
2009-09-09 01:05:48 +00:00
[ -f "${QSEAWK}" -a -x "${QSEAWK}" ] || {
echo_so "the executable '${QSEAWK}' is not found or not executable"
exit 1
}
2010-08-01 01:45:47 +00:00
[ -f "${QSESED}" -a -x "${QSESED}" ] || {
echo_so "the executable '${QSESED}' is not found or not executable"
exit 1
}
2009-09-09 01:05:48 +00:00
QSEAWK_BASENAME="`basename "${QSEAWK}"`"
SCRIPT_DIR="@abs_top_srcdir@/regress/awk"
BASE_OUTFILE="@abs_top_srcdir@/regress/awk/regress.out"
BASE_OUTFILE_XMA="@abs_top_srcdir@/regress/awk/regress.out.xma"
TMPFILE="${TMPFILE:=./regress.temp}"
2009-07-01 07:14:39 +00:00
OUTFILE="${OUTFILE:=./regress.out}"
2010-08-01 01:45:47 +00:00
OUTFILE_XMA="${OUTFILE}.xma"
XMAOPTS="-m 500000"
2010-07-29 07:27:03 +00:00
PROGS="
cou-001.awk!cou.dat!!
cou-002.awk!cou.dat!!
cou-003.awk!cou.dat!!
cou-004.awk!cou.dat!!
cou-005.awk!cou.dat!!
cou-006.awk!cou.dat!!
cou-007.awk!cou.dat!!
cou-008.awk!cou.dat!!
cou-009.awk!cou.dat!!
cou-010.awk!cou.dat!!
cou-011.awk!cou.dat!!
cou-012.awk!cou.dat!!
cou-013.awk!cou.dat!!
cou-014.awk!cou.dat!!
cou-015.awk!cou.dat!!
cou-016.awk!cou.dat!!
cou-017.awk!cou.dat!!
cou-018.awk!cou.dat!!
cou-019.awk!cou.dat!!
cou-020.awk!cou.dat!!
cou-021.awk!cou.dat!!
cou-022.awk!cou.dat!!
cou-023.awk!cou.dat!!
cou-024.awk!cou.dat!!
cou-025.awk!cou.dat!!
cou-026.awk!cou.dat!!
cou-027.awk!cou.dat!!
emp-001.awk!emp.dat!!
emp-002.awk!emp.dat!!
emp-003.awk!emp.dat!!
emp-004.awk!emp.dat!!
emp-005.awk!emp.dat!!
emp-006.awk!emp.dat!!
emp-007.awk!emp.dat!!
emp-008.awk!emp.dat!!
emp-009.awk!emp.dat!!
emp-010.awk!emp.dat!!
emp-011.awk!emp.dat!!
emp-012.awk!emp.dat!!
emp-013.awk!emp.dat!!
emp-014.awk!emp.dat!!
emp-015.awk!emp.dat!!
emp-016.awk!emp.dat!!
emp-017.awk!emp.dat!!
emp-018.awk!emp.dat!!
emp-019.awk!emp.dat!!
emp-020.awk!emp.dat!!
emp-021.awk!emp.dat!!
emp-022.awk!emp.dat!!
emp-023.awk!emp.dat!!
emp-024.awk!emp.dat!!
emp-025.awk!emp.dat!!
emp-026.awk!emp.dat!!
emp-027.awk!emp.dat!!
adr-001.awk!adr.dat!!
adr-002.awk!adr.dat!!
unr-001.awk!unr.dat!!
lang-001.awk!!!--strictnaming=off --newline=on -d-
lang-002.awk!!!--newline=on -d-
lang-003.awk!!!--newline=on -d-
lang-004.awk!!!--newline=on -d-
lang-005.awk!!!--implicit=off --newline=on -d-
lang-006.awk!!!--implicit=off --newline=on -d-
lang-007.awk!!!--implicit=on --newline=on -d-
lang-008.awk!!!--implicit=off --newline=on -d-
lang-009.awk!lang-009.awk!!--implicit=off --newline=on --strictnaming=off -d-
lang-010.awk!this is just a test!!--newline=on -d-
lang-011.awk!!!--newline=on -d-
lang-012.awk!!!--newline=on -d-
lang-013.awk!!!--newline=on -d-
lang-014.awk!!!--newline=on -d-
lang-015.awk!!!--newline=on -d-
lang-016.awk!!!--newline=on -d-
lang-017.awk!!!--newline=on -d-
lang-017.awk!!!--call main --newline=on -d-
lang-018.awk!!!--newline=on -d-
lang-019.awk!!!--newline=on -d-
lang-020.awk!!!--newline=on -d-
lang-021.awk!!!--newline=on -d-
lang-022.awk!!!--newline=on -d-
lang-023.awk!!!--newline=on -d-
lang-024.awk!!!--newline=on -d-
lang-025.awk!!!--newline=on -d-
lang-026.awk!!!--newline=on -d-
lang-027.awk!!!--newline=on -d-
lang-028.awk!!!--newline=on -d-
lang-029.awk!!!--newline=on -d-
lang-030.awk!!!--newline=on -d-
lang-031.awk!!!--newline=on -d-
lang-032.awk!!!--newline=on -d-
lang-033.awk!!!--newline=on -d- -vdatadir=@abs_srcdir@ -vdatafile=passwd.dat
lang-034.awk!!!--newline=on --rwpipe=on -d-
lang-035.awk!lang-035.dat2!!--newline=on -d- -vdatadir=@abs_srcdir@ -vdatafile=lang-035.dat1 -vgroupname=lang-035
lang-036.awk!lang-036.dat!!--newline=on -d-
lang-037.awk!lang-037.dat!!--newline=on -d-
lang-038.awk!!!--newline=on -d-
lang-039.awk!!!--newline=on -d-
lang-040.awk!!!--newline=on -d-
lang-041.awk!!!--newline=on -d-
lang-042.awk!!!--newline=on -d-
lang-043.awk!lang-043.dat!!--newline=on -d-
lang-044.awk!lang-044.dat!!--newline=on -d-
lang-045.awk!!!--newline=on -d-
lang-046.awk!lang-046.dat2!!--newline=on -d- -vdatadir=@abs_srcdir@ -vdatafile=lang-046.dat1
2012-08-17 06:53:17 +00:00
lang-047.awk!!!--newline=on --tolerant=on -d-
lang-048.awk!!!--newline=on -d-
lang-049.awk!!!--newline=on -d-
lang-050.awk!!!--newline=on --flexmap=off -d-
lang-050.awk!!!--newline=on --flexmap=on -d-
lang-051.awk!!!--newline=on --flexmap=off -d-
lang-051.awk!!!--newline=on --flexmap=on -d-
lang-052.awk!!!--newline=on --flexmap=off -d-
lang-052.awk!!!--newline=on --flexmap=on -d-
lang-053.awk!!!--newline=on --flexmap=off -d-
lang-053.awk!!!--newline=on --flexmap=on -d-
lang-054.awk!!!--newline=on --flexmap=off -d-
lang-054.awk!!!--newline=on --flexmap=on -d-
columnate.awk!passwd.dat!!--newline=on -F:
levenshtein-utests.awk!!!--newline=on
rcalc.awk!!!--newline=on -v target=89000
quicksort.awk!quicksort.dat!!
quicksort2.awk!quicksort2.dat!!-vQSEAWK=\"${QSEAWK}\" -vSCRIPT_PATH=\"${SCRIPT_DIR}\"
asm.awk!asm.s!asm.dat!
stripcomment.awk!stripcomment.dat!!
wordfreq.awk!wordfreq.awk!!
hanoi.awk!!!
indent.awk!indent.dat!!
lisp/awklisp!lisp/startup lisp/fib.lsp!!-d-
lisp/awklisp!lisp/startup lisp/numbers lisp/numbers.dat!!-d-
lisp/awklisp!lisp/startup lisp/scmhelp.lsp lisp/tail.lsp!!-d-
lisp/awklisp!lisp/startup lisp/scmhelp.lsp lisp/scheme.lsp!!-d-
"
#
# I can't include this as eliza.lsp gives different output on each run.
# lisp/awklisp!lisp/startup lisp/lists lisp/eliza.lsp lisp/eliza.dat!!-d-
#
2009-06-27 07:05:19 +00:00
[ -x "${QSEAWK}" ] ||
{
echo "ERROR: ${QSEAWK} not found"
exit 1;
}
2009-07-01 07:14:39 +00:00
run_scripts()
{
2009-09-09 01:39:46 +00:00
valgrind="${1}"
2010-08-01 01:45:47 +00:00
extraopts="${2}"
2009-07-01 07:14:39 +00:00
echo "${PROGS}" > "${TMPFILE}"
2019-06-09 16:06:03 +00:00
curdir="`pwd`"
2009-07-01 07:14:39 +00:00
while read prog
do
[ -z "${prog}" ] && continue
script="`echo ${prog} | cut -d! -f1`"
datafile="`echo ${prog} | cut -d! -f2`"
readinfile="`echo ${prog} | cut -d! -f3`"
awkopts="`echo ${prog} | cut -d! -f4`"
2009-09-09 01:39:46 +00:00
orgscript="${script}"
2019-06-09 16:06:03 +00:00
2009-07-01 07:14:39 +00:00
[ -z "${script}" ] && continue
2009-09-03 06:55:55 +00:00
script_path="@abs_srcdir@/${script}"
2019-06-09 16:06:03 +00:00
script_dp_path="@abs_builddir@/${script}.dp"
readinfile_path="@abs_srcdir@/${readinfile}"
2019-06-09 16:06:03 +00:00
datafile_path=""
[ -n "${datafile}" ] && {
for i in ${datafile}
do
[ -f "@abs_srcdir@/${i}" ] && datafile_path="${datafile_path} @abs_srcdir@/${i}"
done
}
2019-06-09 16:06:03 +00:00
[ -f "${script_path}" ] || {
2009-07-01 07:14:39 +00:00
echo_so "${script} not found"
continue
}
2019-06-09 16:06:03 +00:00
[ -z "${readinfile}" ] && {
readinfile="/dev/stdin"
readinfile_path="/dev/stdin"
}
2009-09-03 06:55:55 +00:00
echo_title "${valgrind} ${QSEAWK_BASENAME} ${extraopts} ${awkopts} -f ${orgscript} ${datafile} <${readinfile} 2>&1"
2019-06-09 16:06:03 +00:00
if [ -f "${script_dp_path}" ]
then
# run the deparsed script
cd "`dirname ${script_dp_path}`"
${valgrind} ${QSEAWK} ${extraopts} ${awkopts} -f "`basename ${script_dp_path}`" ${datafile_path} <${readinfile_path} 2>&1
cd "$curdir"
else
# run the orignal script
cd "`dirname ${script_path}`"
${valgrind} ${QSEAWK} ${extraopts} -d "${script_dp_path}" ${awkopts} -f "`basename ${script_path}`" ${datafile_path} <${readinfile_path} 2>&1
cd "$curdir"
fi
2009-07-01 07:14:39 +00:00
done < "${TMPFILE}"
2019-06-09 16:06:03 +00:00
2009-07-01 07:14:39 +00:00
rm -f "${TMPFILE}"
}
2010-08-01 01:45:47 +00:00
run_test()
{
base_outfile="${1}"
outfile="${2}"
extraopts="${3}"
2010-08-01 01:45:47 +00:00
2009-09-03 06:55:55 +00:00
rm -f *.dp
echo_so "FIRST RUN WITH ORIGINAL SOURCE"
2010-08-01 01:45:47 +00:00
run_scripts "" "${extraopts}" > "${outfile}.test"
2009-09-03 06:55:55 +00:00
echo_so "SECOND RUN WITH DEPARSED SOURCE"
2010-08-01 01:45:47 +00:00
run_scripts "" "${extraopts}" > "${outfile}.test2"
2009-09-03 06:55:55 +00:00
rm -f *.dp
2010-08-01 01:45:47 +00:00
diff "${outfile}.test" "${outfile}.test2" > /dev/null || {
2009-09-03 06:55:55 +00:00
echo_so "ERROR: Difference is found between the first run and the second run."
2010-08-01 01:45:47 +00:00
echo_so " The output of the first run is stored in '${outfile}.test'."
echo_so " The output of the seconds run is stored in '${outfile}.test2'."
echo_so " You may execute 'diff ${outfile}.test ${outfile}.test2' for more info."
2009-09-03 06:55:55 +00:00
exit 1
}
2010-08-01 01:45:47 +00:00
rm -f "${outfile}.test2"
2009-09-03 06:55:55 +00:00
# diff -q is not supported on old platforms.
# redirect output to /dev/null instead.
diff "${base_outfile}" "${outfile}.test" > /dev/null || {
2009-09-03 06:55:55 +00:00
echo_so "ERROR: Difference is found between expected output and actual output."
echo_so " The expected output is stored in '${base_outfile}'."
2010-08-01 01:45:47 +00:00
echo_so " The actual output is stored in '${outfile}.test'."
echo_so " You may execute 'diff ${base_outfile} ${outfile}.test' for more info."
2010-08-01 01:45:47 +00:00
return 1
}
2012-04-30 09:46:58 +00:00
#rm -f "${outfile}.test"
2010-08-01 01:45:47 +00:00
return 0
}
case $1 in
init)
rm -f *.dp
run_scripts "" "" > "${BASE_OUTFILE}"
run_scripts "" "${XMAOPTS}" > "${BASE_OUTFILE_XMA}"
2010-08-01 01:45:47 +00:00
rm -f *.dp
echo_so "INIT OK"
;;
test)
run_test "${BASE_OUTFILE}" "${OUTFILE}" "" &&
{
run_test "${BASE_OUTFILE_XMA}" "${OUTFILE_XMA}" "${XMAOPTS}" &&
{
${QSESED} "s|${QSESED_BASENAME} ${XMAOPTS}|${QSESED_BASENAME} |" "${OUTFILE_XMA}.test" > "${OUTFILE_XMA}.$$"
diff "${OUTFILE}.test" "${OUTFILE_XMA}.$$" ||
{
2010-08-01 01:45:47 +00:00
rm -f "${OUTFILE_XMA}.$$"
echo_so "ERROR: Difference is found between normal output and xma output."
echo_so " The normal output is stored in '${OUTFILE}.test'."
echo_so " The xma output is stored in '${OUTFILE_XMA}.test'."
2010-08-01 01:45:47 +00:00
echo_so " Ignore lines staring with [CMD] in the difference."
exit 1;
}
rm -f "${OUTFILE_XMA}.$$"
echo_so "TEST OK"
}
}
2009-07-01 07:14:39 +00:00
;;
2009-09-09 01:05:48 +00:00
leakcheck)
2009-09-09 01:39:46 +00:00
bin_valgrind="`which valgrind 2> /dev/null || echo ""`"
[ -n "${bin_valgrind}" -a -f "${bin_valgrind}" ] || {
2009-09-09 01:05:48 +00:00
echo_so "valgrind not found. cannot perform this test"
exit 1
}
2010-08-01 01:45:47 +00:00
run_scripts "${bin_valgrind} --leak-check=full --show-reachable=yes --track-fds=yes" "" 2>&1 > "${OUTFILE}.test"
x=`grep -Fic "no leaks are possible" "${OUTFILE}.test"`
y=`grep -Fic "${bin_valgrind}" "${OUTFILE}.test"`
if [ ${x} -eq ${y} ]
then
echo_so "(POSSIBLY) no memory leaks detected".
else
echo_so "(POSSIBLY) some memory leaks detected".
fi
echo_so "Inspect the '${OUTFILE}.test' file for details"
;;
*)
echo_so "USAGE: $0 init"
echo_so " $0 test"
echo_so " $0 leakcheck"
exit 1
;;
esac
exit 0