2009-09-09 01:05:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo_so()
|
|
|
|
{
|
|
|
|
tput smso
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
echo -n "$1 "
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
tput rmso
|
|
|
|
}
|
|
|
|
|
|
|
|
echo_title()
|
|
|
|
{
|
|
|
|
echo "--------------------------------------------------------------------------------"
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
echo -n "$1 "
|
|
|
|
echo -n "$1 " >/dev/stderr
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo > /dev/stderr
|
|
|
|
echo "--------------------------------------------------------------------------------"
|
|
|
|
}
|
|
|
|
|
|
|
|
print_usage()
|
|
|
|
{
|
|
|
|
echo_so "Usage: $0 init"
|
|
|
|
echo_so " $0 test"
|
|
|
|
}
|
|
|
|
|
|
|
|
###################
|
|
|
|
# MAIN #
|
|
|
|
###################
|
|
|
|
|
|
|
|
[ -z "${QSESED}" ] && {
|
|
|
|
QSESED=../../cmd/sed/.libs/qsesed
|
|
|
|
[ -f "${QSESED}" ] || QSESED=../../cmd/sed/qsesed
|
|
|
|
}
|
|
|
|
[ -f "${QSESED}" -a -x "${QSESED}" ] || {
|
|
|
|
echo_so "the executable '${QSESED}' is not found or not executable"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
TMPFILE="${TMPFILE:=./regress.temp}"
|
|
|
|
OUTFILE="${OUTFILE:=./regress.out}"
|
|
|
|
|
|
|
|
PROGS="
|
|
|
|
001.sed/001.dat//-n
|
|
|
|
002.sed/002.dat//
|
|
|
|
003.sed/003.dat//
|
|
|
|
004.sed/004.dat//
|
|
|
|
"
|
|
|
|
|
|
|
|
[ -x "${QSESED}" ] ||
|
|
|
|
{
|
|
|
|
echo "ERROR: ${QSESED} not found"
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
run_scripts()
|
|
|
|
{
|
2009-09-09 01:39:46 +00:00
|
|
|
valgrind="$1"
|
2009-09-09 01:05:48 +00:00
|
|
|
echo "${PROGS}" > "${TMPFILE}"
|
|
|
|
|
|
|
|
while read prog
|
|
|
|
do
|
|
|
|
[ -z "${prog}" ] && continue
|
|
|
|
|
2009-09-09 01:39:46 +00:00
|
|
|
script="`echo ${prog} | cut -d/ -f1`"
|
|
|
|
datafile="`echo ${prog} | cut -d/ -f2`"
|
|
|
|
redinfile="`echo ${prog} | cut -d/ -f3`"
|
|
|
|
options="`echo ${prog} | cut -d/ -f4`"
|
2009-09-09 01:05:48 +00:00
|
|
|
|
|
|
|
[ -z "${script}" ] && continue
|
|
|
|
|
|
|
|
[ -f "${script}" ] ||
|
|
|
|
{
|
|
|
|
echo_so "${script} not found"
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
[ -z "${redinfile}" ] && redinfile="/dev/stdin"
|
|
|
|
|
|
|
|
echo_title "${valgrind} ${QSESED} ${options} -f ${script} ${datafile} <${redinfile} 2>&1"
|
|
|
|
${valgrind} ${QSESED} ${options} -f ${script} ${datafile} <${redinfile} 2>&1
|
|
|
|
|
|
|
|
done < "${TMPFILE}"
|
|
|
|
|
|
|
|
rm -f "${TMPFILE}"
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
init)
|
|
|
|
rm -f *.dp
|
|
|
|
run_scripts > "${OUTFILE}"
|
|
|
|
rm -f *.dp
|
|
|
|
echo_so "INIT OK"
|
|
|
|
;;
|
|
|
|
test)
|
|
|
|
run_scripts > "${OUTFILE}.test"
|
|
|
|
|
|
|
|
# diff -q is not supported on old platforms.
|
|
|
|
# redirect output to /dev/null instead.
|
|
|
|
diff "${OUTFILE}" "${OUTFILE}.test" > /dev/null || {
|
|
|
|
echo_so "ERROR: Difference is found between expected output and actual output."
|
|
|
|
echo_so " The expected output is stored in '${OUTFILE}'."
|
|
|
|
echo_so " The actual output is stored in '${OUTFILE}.test'."
|
|
|
|
echo_so " You may execute 'diff ${OUTFILE} ${OUTFILE}.test' for more info."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
rm -f "${OUTFILE}.test"
|
|
|
|
echo_so "TEST OK"
|
|
|
|
;;
|
|
|
|
leakcheck)
|
2009-09-09 01:39:46 +00:00
|
|
|
bin_valgrind="`which valgrind 2> /dev/null || echo ""`"
|
2009-09-09 01:43:38 +00:00
|
|
|
[ -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
|
|
|
|
}
|
2009-09-09 01:39:46 +00:00
|
|
|
run_scripts "${bin_valgrind} --leak-check=full --show-reachable=yes --track-fds=yes" 2>&1 > "${OUTFILE}.test"
|
2009-09-09 01:05:48 +00:00
|
|
|
echo_so "Inspect the '${OUTFILE}.test' file for any memory and file descriptor leaks."
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo_so "USAGE: $0 init"
|
|
|
|
echo_so " $0 test"
|
|
|
|
echo_so " $0 leakcheck"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|