xref: /titanic_44/usr/src/lib/libshell/common/tests/shtests (revision edcc07547a39d6570197493a9836083bd6b2a197)
1# This program runs ksh regression tests
2# shtests [ name=value ... ] a.sh b.sh ...
3
4unset DISPLAY ENV FIGNORE
5LANG=C
6LC_ALL=C
7time=1
8while	:
9do	case $1 in
10	*=*)	n=${1%%=*}
11		v=${1#*=}
12		eval $n=\'$v\'
13		export $n
14		;;
15	-t|--t*)time=
16		;;
17	*)	break
18		;;
19	esac
20	shift
21done
22export LANG LC_ALL PATH PWD SHELL
23PWD=`pwd`
24SHELL=${SHELL-ksh}
25case $0 in
26/*)	d=`dirname $0`;;
27*/*)	d=$PWD/`dirname $0`;;
28*)	d=$PWD;;
29esac
30case $SHELL in
31/*)	;;
32*/*)	SHELL=$d/$SHELL;;
33*)	SHELL=$(whence $SHELL);;
34esac
35PATH=/bin:/usr/bin
36if	[[ -d /usr/ucb ]]
37then	PATH=$PATH:/usr/ucb
38fi
39PATH=$PATH:$d
40if [[ $INSTALLROOT && -r $INSTALLROOT/bin/.paths ]]
41then	PATH=$INSTALLROOT/bin:$PATH
42fi
43for i in ${*-*.sh}
44do	echo test $i begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"}
45	t=$(grep -c err_exit $i)
46	if	(( $t ))
47	then	(( t = $t - 1 ))
48	fi
49	T=test
50	if	(( $t != 1 ))
51	then	T=${T}s
52	fi
53	E=error
54	if	$SHELL $i
55	then	echo test $i passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 ${E}s ]"
56	else	e=$?
57		E=error
58		if	(( $e != 1 ))
59		then	E=${E}s
60		fi
61		echo test $i failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $e $E ]"
62	fi
63done
64