1149781Sstefanf# $FreeBSD: releng/10.2/bin/sh/tests/legacy_test.sh 259210 2013-12-11 04:09:17Z jmmv $ 2149781Sstefanf 3259210Sjmmv: ${SH:="__SH__"} 4259210Sjmmvexport SH 5213738Sobrien 6259210Sjmmv# TODO(jmmv): The Kyua TAP interface should be passing us the value of 7259210Sjmmv# "srcdir" as an environment variable, just as it does with the ATF 8259210Sjmmv# interface in the form of a configuration variable. For now, just try 9259210Sjmmv# to guess this. 10259210Sjmmv: ${TESTS_DATA:=$(dirname ${0})} 11259210Sjmmv 12149781SstefanfCOUNTER=1 13149781Sstefanf 14149781Sstefanfdo_test() { 15149781Sstefanf c=${COUNTER} 16149781Sstefanf COUNTER=$((COUNTER+1)) 17213738Sobrien ${SH} $1 > tmp.stdout 2> tmp.stderr 18149781Sstefanf if [ $? -ne $2 ]; then 19149781Sstefanf echo "not ok ${c} - ${1} # wrong exit status" 20149781Sstefanf rm tmp.stdout tmp.stderr 21149781Sstefanf return 22149781Sstefanf fi 23259210Sjmmv sed -I '' -e "s|^${TESTS_DATA}|.|" tmp.stderr 24149781Sstefanf for i in stdout stderr; do 25149781Sstefanf if [ -f ${1}.${i} ]; then 26149781Sstefanf if ! cmp -s tmp.${i} ${1}.${i}; then 27149781Sstefanf echo "not ok ${c} - ${1} # wrong output on ${i}" 28149781Sstefanf rm tmp.stdout tmp.stderr 29149781Sstefanf return 30149781Sstefanf fi 31149781Sstefanf elif [ -s tmp.${i} ]; then 32149781Sstefanf echo "not ok ${c} - ${1} # wrong output on ${i}" 33149781Sstefanf rm tmp.stdout tmp.stderr 34149781Sstefanf return 35149781Sstefanf fi 36149781Sstefanf done 37149781Sstefanf echo "ok ${c} - ${1}" 38149781Sstefanf rm tmp.stdout tmp.stderr 39149781Sstefanf} 40149781Sstefanf 41259210SjmmvTESTS=$(find -Es ${TESTS_DATA} -regex ".*\.[0-9]+") 42151797Sstefanfprintf "1..%d\n" $(echo ${TESTS} | wc -w) 43151797Sstefanf 44149791Sstefanffor i in ${TESTS} ; do 45149791Sstefanf do_test ${i} ${i##*.} 46149781Sstefanfdone 47