2005-09-04 11:59:59 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
2013-12-11 04:09:17 +00:00
|
|
|
: ${SH:="__SH__"}
|
|
|
|
export SH
|
|
|
|
|
|
|
|
# TODO(jmmv): The Kyua TAP interface should be passing us the value of
|
|
|
|
# "srcdir" as an environment variable, just as it does with the ATF
|
|
|
|
# interface in the form of a configuration variable. For now, just try
|
|
|
|
# to guess this.
|
|
|
|
: ${TESTS_DATA:=$(dirname ${0})}
|
2010-10-12 18:20:38 +00:00
|
|
|
|
2005-09-04 11:59:59 +00:00
|
|
|
COUNTER=1
|
|
|
|
|
|
|
|
do_test() {
|
|
|
|
c=${COUNTER}
|
|
|
|
COUNTER=$((COUNTER+1))
|
2010-10-12 18:20:38 +00:00
|
|
|
${SH} $1 > tmp.stdout 2> tmp.stderr
|
2005-09-04 11:59:59 +00:00
|
|
|
if [ $? -ne $2 ]; then
|
|
|
|
echo "not ok ${c} - ${1} # wrong exit status"
|
|
|
|
rm tmp.stdout tmp.stderr
|
|
|
|
return
|
|
|
|
fi
|
2013-12-11 04:09:17 +00:00
|
|
|
sed -I '' -e "s|^${TESTS_DATA}|.|" tmp.stderr
|
2005-09-04 11:59:59 +00:00
|
|
|
for i in stdout stderr; do
|
|
|
|
if [ -f ${1}.${i} ]; then
|
|
|
|
if ! cmp -s tmp.${i} ${1}.${i}; then
|
|
|
|
echo "not ok ${c} - ${1} # wrong output on ${i}"
|
|
|
|
rm tmp.stdout tmp.stderr
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
elif [ -s tmp.${i} ]; then
|
|
|
|
echo "not ok ${c} - ${1} # wrong output on ${i}"
|
|
|
|
rm tmp.stdout tmp.stderr
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "ok ${c} - ${1}"
|
|
|
|
rm tmp.stdout tmp.stderr
|
|
|
|
}
|
|
|
|
|
2013-12-11 04:09:17 +00:00
|
|
|
TESTS=$(find -Es ${TESTS_DATA} -regex ".*\.[0-9]+")
|
2005-10-28 14:02:42 +00:00
|
|
|
printf "1..%d\n" $(echo ${TESTS} | wc -w)
|
|
|
|
|
2005-09-05 09:42:10 +00:00
|
|
|
for i in ${TESTS} ; do
|
|
|
|
do_test ${i} ${i##*.}
|
2005-09-04 11:59:59 +00:00
|
|
|
done
|