#! /bin/sh
#
# squid-gw/html-reg
#
# Regression tests for HTML parser
#
verbose=true
do_test()
{
if [ ! -f $2.opt ] ;then
echo "$2.opt: No such file or directory"
exit 2
fi
options=`cat $2.opt`
$verbose "Current test: $1 $2.exp $options"
./testhtml $options <$1 >reg.out
if cmp reg.out $2.exp ;then true
else
echo "Regression test $2 failed."
echo "Input from: $1"
echo "Expected output from: $2.exp"
echo "Actual output in: reg.out"
echo -n "Options: "
sed '2,$s/^/ /' <$2.opt
exit 1
fi
rm -f reg.out
}
if [ $# -ge 1 -a "$1" = "-v" ] ;then
verbose=echo
shift
fi
if [ $# -lt 1 ] ;then
echo "Usage: html-reg ..."
exit 1
fi
for i in $*
do
if [ ! -f $i ] ;then
echo "$i: No such file or directory"
exit 2
fi
t=`echo $i|sed 's/\.inp$//'`
if [ -f ${t}.exp ] ;then
if [ -f ${t}a.exp ] ;then
echo "Both ${t}.exp and ${t}a.exp exist!"
exit 2
fi
do_test $i $t
elif [ -f ${t}a.exp ] ;then
for s in a b c d e f
do
test -f ${t}${s}.exp || break
do_test $i ${t}${s}
done
else
echo "${t}.exp: No such file or directory"
exit 2
fi
done
exit 0