Sync /bin/sh regression tests with FreeBSD.
[dragonfly.git] / tools / regression / bin / sh / regress.sh
CommitLineData
4bfff613 1# $FreeBSD: src/tools/regression/bin/sh/regress.sh,v 1.5 2011/02/19 13:23:13 jilles Exp $
3df4d8b0
PA
2
3if [ -z "${SH}" ]; then
4 echo '${SH} is not set, please correct and re-run.'
5 exit 1
6fi
7export SH=${SH}
8
9COUNTER=1
10
11do_test() {
3df4d8b0
PA
12 c=${COUNTER}
13 COUNTER=$((COUNTER+1))
14 ${SH} $1 > tmp.stdout 2> tmp.stderr
15 if [ $? -ne $2 ]; then
16 echo "not ok ${c} - ${1} # wrong exit status"
17 rm tmp.stdout tmp.stderr
18 return
19 fi
20 for i in stdout stderr; do
21 if [ -f ${1}.${i} ]; then
22 if ! cmp -s tmp.${i} ${1}.${i}; then
23 echo "not ok ${c} - ${1} # wrong output on ${i}"
24 rm tmp.stdout tmp.stderr
25 return
26 fi
27 elif [ -s tmp.${i} ]; then
28 echo "not ok ${c} - ${1} # wrong output on ${i}"
29 rm tmp.stdout tmp.stderr
30 return
31 fi
32 done
33 echo "ok ${c} - ${1}"
34 rm tmp.stdout tmp.stderr
35}
36
37TESTS=$(find -Es . -regex ".*\.[0-9]+")
38printf "1..%d\n" $(echo ${TESTS} | wc -w)
39
40for i in ${TESTS} ; do
41 do_test ${i} ${i##*.}
42done