1 # This program runs ksh regression tests
2 # shtests [ name=value ... ] [ --all | --compile ] [ --time ] [ a.sh b.sh ... ]
4 timesensitive='*@(options|sigchld|subshell).sh'
6 unset DISPLAY ENV FIGNORE HISTFILE
26 -v|--nov*)vmalloc_options=
28 -*) echo $0: $1: invalid option >&2
41 if [[ $VMALLOC_OPTIONS ]]
42 then vmalloc_options=$VMALLOC_OPTIONS
43 else VMALLOC_OPTIONS=$vmalloc_options
45 [[ $VMALLOC_OPTIONS ]] || timesensitive=.
46 export LANG LC_ALL PATH PWD SHELL VMALLOC_OPTIONS
51 */*) d=$PWD/`dirname $0`;;
56 */*) SHELL=$d/$SHELL;;
57 *) SHELL=$(whence $SHELL);;
61 then PATH=$PATH:/usr/ucb
64 if [[ $INSTALLROOT && -r $INSTALLROOT/bin/.paths ]]
65 then PATH=$INSTALLROOT/bin:$PATH
68 then SHCOMP=${SHCOMP:-shcomp}
69 if whence $SHCOMP > /dev/null
70 then tmp=$(mktemp -dt) || { echo mktemp -dt failed >&2; exit 1; }
71 trap "cd /; rm -rf $tmp" EXIT
72 elif [[ $compile != 1 ]]
73 then echo $0: --compile: $SHCOMP not found >&2
81 then echo $0: $i: not found >&2
84 t=$(grep -c err_exit $i)
95 then echo test $i begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"}
96 if [[ $i == $timesensitive ]]
100 then echo test $i passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 ${E}s ]"
109 echo test $i failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $e $E ]"
111 if [[ $i == $timesensitive ]]
112 then VMALLOC_OPTIONS=$vmalloc_options
117 then for i in ${*-*.sh}
127 o=shcomp-${o%.sh}.ksh
128 echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"}
130 if $SHCOMP $i > $tmp/$o
131 then if [[ $i == $timesensitive ]]
132 then VMALLOC_OPTIONS=
135 then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 ${E}s ]"
144 echo test $o failed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T $e $E ]"
146 if [[ $i == $timesensitive ]]
147 then VMALLOC_OPTIONS=$vmalloc_options
152 echo test $o failed to compile ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ $t $T 1 $E ]"