diff --git a/src/cmd/ksh93/tests/alias.sh b/src/cmd/ksh93/tests/alias.sh index 2b3bc6196..084fdb1ab 100755 --- a/src/cmd/ksh93/tests/alias.sh +++ b/src/cmd/ksh93/tests/alias.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.alias.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } alias foo='print hello' if [[ $(foo) != hello ]] diff --git a/src/cmd/ksh93/tests/append.sh b/src/cmd/ksh93/tests/append.sh index 6afec5694..6617c36d2 100755 --- a/src/cmd/ksh93/tests/append.sh +++ b/src/cmd/ksh93/tests/append.sh @@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + { x=abc x+=def ;} 2> /dev/null diff --git a/src/cmd/ksh93/tests/arith.sh b/src/cmd/ksh93/tests/arith.sh index 0f9cb1703..e1aa91532 100755 --- a/src/cmd/ksh93/tests/arith.sh +++ b/src/cmd/ksh93/tests/arith.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.arith.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } trap '' FPE # NOTE: osf.alpha requires this (no ieee math) diff --git a/src/cmd/ksh93/tests/arrays.sh b/src/cmd/ksh93/tests/arrays.sh index 201833aa1..a766bd37f 100755 --- a/src/cmd/ksh93/tests/arrays.sh +++ b/src/cmd/ksh93/tests/arrays.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.arrays.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } function fun { diff --git a/src/cmd/ksh93/tests/arrays2.sh b/src/cmd/ksh93/tests/arrays2.sh index ff9e21f64..f3e208927 100755 --- a/src/cmd/ksh93/tests/arrays2.sh +++ b/src/cmd/ksh93/tests/arrays2.sh @@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + for ((i=0; i < 4; i++ )) do for ((j=0; j < 5; j++ )) do a[i][j]=$i$j diff --git a/src/cmd/ksh93/tests/attributes.sh b/src/cmd/ksh93/tests/attributes.sh index 435657b5a..5090b66f9 100755 --- a/src/cmd/ksh93/tests/attributes.sh +++ b/src/cmd/ksh93/tests/attributes.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.attributes.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } r=readonly u=Uppercase l=Lowercase i=22 i8=10 L=abc L5=def uL5=abcdef xi=20 x=export t=tagged H=hostname LZ5=026 RZ5=026 Z5=123 lR5=ABcdef R5=def n=l diff --git a/src/cmd/ksh93/tests/basic.sh b/src/cmd/ksh93/tests/basic.sh index aae2995fe..515dfb28d 100755 --- a/src/cmd/ksh93/tests/basic.sh +++ b/src/cmd/ksh93/tests/basic.sh @@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.basic.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + bincat=$(whence -p cat) binecho=$(whence -p echo) # make an external 'sleep' command that supports fractional seconds diff --git a/src/cmd/ksh93/tests/bracket.sh b/src/cmd/ksh93/tests/bracket.sh index 5b7745fe2..25e47a461 100755 --- a/src/cmd/ksh93/tests/bracket.sh +++ b/src/cmd/ksh93/tests/bracket.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.bracket.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } null='' if [[ ! -z $null ]] diff --git a/src/cmd/ksh93/tests/builtins.sh b/src/cmd/ksh93/tests/builtins.sh index 43b23fb82..470644be4 100755 --- a/src/cmd/ksh93/tests/builtins.sh +++ b/src/cmd/ksh93/tests/builtins.sh @@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.builtins.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + bincat=$(whence -p cat) # test shell builtin commands @@ -194,7 +188,7 @@ mkdir -p $tmp/a/b/c 2>/dev/null || err_exit "mkdir -p failed" $SHELL -c "cd $tmp/a/b; cd c" 2>/dev/null || err_exit "initial script relative cd fails" trap 'print TERM' TERM -exp=$'trap -- \'print TERM\' TERM\ntrap -- \'cd / && rm -rf "$tmp"\' EXIT' +exp="trap -- 'print TERM' TERM" got=$(trap) [[ $got == $exp ]] || err_exit "\$(trap) failed -- expected \"$exp\", got \"$got\"" exp='print TERM' diff --git a/src/cmd/ksh93/tests/case.sh b/src/cmd/ksh93/tests/case.sh index 7fe01ea88..500fc6bc5 100755 --- a/src/cmd/ksh93/tests/case.sh +++ b/src/cmd/ksh93/tests/case.sh @@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + bar=foo2 bam=foo[3] for i in foo1 foo2 foo3 foo4 foo5 foo6 diff --git a/src/cmd/ksh93/tests/comvar.sh b/src/cmd/ksh93/tests/comvar.sh index e705238b4..387cf1358 100755 --- a/src/cmd/ksh93/tests/comvar.sh +++ b/src/cmd/ksh93/tests/comvar.sh @@ -25,14 +25,10 @@ function err_exit } alias err_exit='err_exit $LINENO' -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.comvar.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +Command=${0##*/} +integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } #test for compound variables Command=${0##*/} diff --git a/src/cmd/ksh93/tests/comvario.sh b/src/cmd/ksh93/tests/comvario.sh index 2069dd5aa..b4be1bd4d 100755 --- a/src/cmd/ksh93/tests/comvario.sh +++ b/src/cmd/ksh93/tests/comvario.sh @@ -46,6 +46,11 @@ function err_exit } alias err_exit='err_exit $LINENO' +Command=${0##*/} +integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + # "nounset" disabled for now #set -o nounset Command=${0##*/} diff --git a/src/cmd/ksh93/tests/coprocess.sh b/src/cmd/ksh93/tests/coprocess.sh index 4e2d0b730..95f85cca6 100755 --- a/src/cmd/ksh93/tests/coprocess.sh +++ b/src/cmd/ksh93/tests/coprocess.sh @@ -29,14 +29,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.coprocess.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } if [[ -d /cygdrive ]] then err_exit cygwin detected - coprocess tests disabled - enable at the risk of wedging your system diff --git a/src/cmd/ksh93/tests/cubetype.sh b/src/cmd/ksh93/tests/cubetype.sh index dbe4e8bef..e8a2282c7 100755 --- a/src/cmd/ksh93/tests/cubetype.sh +++ b/src/cmd/ksh93/tests/cubetype.sh @@ -29,6 +29,8 @@ Command=${0##*/} integer Errors=0 integer n=2 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + typeset -T Box_t=( float -h 'height in inches' x=2 float -h 'width in inches' y=4 diff --git a/src/cmd/ksh93/tests/enum.sh b/src/cmd/ksh93/tests/enum.sh index 4f9ff834b..5487c37e7 100755 --- a/src/cmd/ksh93/tests/enum.sh +++ b/src/cmd/ksh93/tests/enum.sh @@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + enum Color_t=(red green blue orange yellow) enum -i Sex_t=(Male Female) for ((i=0; i < 1000; i++)) diff --git a/src/cmd/ksh93/tests/exit.sh b/src/cmd/ksh93/tests/exit.sh index aaf822eb0..166f2010c 100755 --- a/src/cmd/ksh93/tests/exit.sh +++ b/src/cmd/ksh93/tests/exit.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.exit.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } function abspath { diff --git a/src/cmd/ksh93/tests/expand.sh b/src/cmd/ksh93/tests/expand.sh index 123698cd5..c568e457a 100755 --- a/src/cmd/ksh93/tests/expand.sh +++ b/src/cmd/ksh93/tests/expand.sh @@ -27,6 +27,8 @@ function err_exit integer Errors=0 Command=${0##*/} +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + # {...} expansion tests -- ignore if not supported [[ $(print a{0,1}z) == "a0z a1z" ]] || exit 0 diff --git a/src/cmd/ksh93/tests/functions.sh b/src/cmd/ksh93/tests/functions.sh index e5dbd7173..7178bbf97 100755 --- a/src/cmd/ksh93/tests/functions.sh +++ b/src/cmd/ksh93/tests/functions.sh @@ -27,20 +27,15 @@ alias err_exit='err_exit $LINENO' integer Errors=0 Command=${0##*/} + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + compiled='' read -n4 c < $0 2> /dev/null [[ $c == *$'\ck'* ]] && compiled=1 ulimit -c 0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.functions.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT binecho=$(whence -p echo) integer foo=33 diff --git a/src/cmd/ksh93/tests/glob.sh b/src/cmd/ksh93/tests/glob.sh index a0ad8b196..8dec730ae 100755 --- a/src/cmd/ksh93/tests/glob.sh +++ b/src/cmd/ksh93/tests/glob.sh @@ -27,14 +27,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer aware=0 contrary=0 Errors=0 ignorant=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.glob.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } function test_glob { diff --git a/src/cmd/ksh93/tests/grep.sh b/src/cmd/ksh93/tests/grep.sh index a0b80ccf7..c07b97813 100755 --- a/src/cmd/ksh93/tests/grep.sh +++ b/src/cmd/ksh93/tests/grep.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.grep.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } function grep { diff --git a/src/cmd/ksh93/tests/heredoc.sh b/src/cmd/ksh93/tests/heredoc.sh index 2d9e21d5b..1cabd44e3 100755 --- a/src/cmd/ksh93/tests/heredoc.sh +++ b/src/cmd/ksh93/tests/heredoc.sh @@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.heredoc.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + bincat=$(whence -p cat) f=$tmp/here1 diff --git a/src/cmd/ksh93/tests/io.sh b/src/cmd/ksh93/tests/io.sh index 51eba6ce0..fb86b45cd 100755 --- a/src/cmd/ksh93/tests/io.sh +++ b/src/cmd/ksh93/tests/io.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.io.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } unset HISTFILE diff --git a/src/cmd/ksh93/tests/leaks.sh b/src/cmd/ksh93/tests/leaks.sh index a1c5cfbad..54b0f711e 100755 --- a/src/cmd/ksh93/tests/leaks.sh +++ b/src/cmd/ksh93/tests/leaks.sh @@ -29,6 +29,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + # Get the current amount of memory usage function getmem { diff --git a/src/cmd/ksh93/tests/locale.sh b/src/cmd/ksh93/tests/locale.sh index 26dc9c20e..f8aeb7703 100755 --- a/src/cmd/ksh93/tests/locale.sh +++ b/src/cmd/ksh93/tests/locale.sh @@ -28,17 +28,10 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -unset LANG ${!LC_*} +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } +CDPATH= cd -P -- "$tmp" || exit -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.locale.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT -cd $tmp || exit +unset LANG ${!LC_*} a=$($SHELL -c '/' 2>&1 | sed -e "s,.*: *,," -e "s, *\[.*,,") b=$($SHELL -c '(LC_ALL=debug / 2>/dev/null); /' 2>&1 | sed -e "s,.*: *,," -e "s, *\[.*,,") diff --git a/src/cmd/ksh93/tests/math.sh b/src/cmd/ksh93/tests/math.sh index 76cb518c9..4c34d14e2 100755 --- a/src/cmd/ksh93/tests/math.sh +++ b/src/cmd/ksh93/tests/math.sh @@ -25,25 +25,14 @@ function err_exit } alias err_exit='err_exit $LINENO' -set -o nounset Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } +CDPATH= cd -P -- "$tmp" || exit + set -o nounset -typeset tmp - -# create temporary test directory -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.math.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT -cd $tmp || exit - function test_arithmetric_expression_accesss_array_element_through_nameref { compound out=( typeset stdout stderr ; integer res ) diff --git a/src/cmd/ksh93/tests/nameref.sh b/src/cmd/ksh93/tests/nameref.sh index abf46829c..36d4ef914 100755 --- a/src/cmd/ksh93/tests/nameref.sh +++ b/src/cmd/ksh93/tests/nameref.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.nameref.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } function checkref { diff --git a/src/cmd/ksh93/tests/namespace.sh b/src/cmd/ksh93/tests/namespace.sh index 46b98cd15..99b6843bb 100755 --- a/src/cmd/ksh93/tests/namespace.sh +++ b/src/cmd/ksh93/tests/namespace.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.namespace.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } foo=abc typeset -C bar=(x=3 y=4 t=7) diff --git a/src/cmd/ksh93/tests/options.sh b/src/cmd/ksh93/tests/options.sh index 5093f7d6d..28eb7df43 100755 --- a/src/cmd/ksh93/tests/options.sh +++ b/src/cmd/ksh93/tests/options.sh @@ -28,19 +28,13 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + unset HISTFILE export LC_ALL=C ENV=/./dev/null ulimit -c 0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.options.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT bincat=$(whence -p cat) if [[ $( ${SHELL-ksh} -s hello<<-\! diff --git a/src/cmd/ksh93/tests/path.sh b/src/cmd/ksh93/tests/path.sh index 9725c74e3..295f5706c 100755 --- a/src/cmd/ksh93/tests/path.sh +++ b/src/cmd/ksh93/tests/path.sh @@ -28,16 +28,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.path.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } +CDPATH= cd -P -- "$tmp" || exit -cd $tmp || exit type /xxxxxx > out1 2> out2 [[ -s out1 ]] && err_exit 'type should not write on stdout for not found case' [[ -s out2 ]] || err_exit 'type should write on stderr for not found case' diff --git a/src/cmd/ksh93/tests/pointtype.sh b/src/cmd/ksh93/tests/pointtype.sh index b0a533319..dad634f12 100755 --- a/src/cmd/ksh93/tests/pointtype.sh +++ b/src/cmd/ksh93/tests/pointtype.sh @@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + typeset -T Pt_t=( float x=1 float y=0 diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh index bed9564ef..e588226cc 100755 --- a/src/cmd/ksh93/tests/pty.sh +++ b/src/cmd/ksh93/tests/pty.sh @@ -41,7 +41,8 @@ alias err_exit='err_exit $lineno' Command=${0##*/} integer Errors=0 lineno=1 -whence -q pty || { lineno=$LINENO; err_exit "pty command not found -- tests skipped"; exit 0; } +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } +whence -q pty || { lineno=$LINENO; err\_exit "$LINENO" "pty command not found -- tests skipped"; exit 0; } bintrue=$(whence -p true) diff --git a/src/cmd/ksh93/tests/quoting.sh b/src/cmd/ksh93/tests/quoting.sh index 60fbf3a0b..c1651df9f 100755 --- a/src/cmd/ksh93/tests/quoting.sh +++ b/src/cmd/ksh93/tests/quoting.sh @@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + binecho=$(whence -p echo) if [[ 'hi there' != "hi there" ]] diff --git a/src/cmd/ksh93/tests/quoting2.sh b/src/cmd/ksh93/tests/quoting2.sh index bc7380d06..0ffcb4fae 100755 --- a/src/cmd/ksh93/tests/quoting2.sh +++ b/src/cmd/ksh93/tests/quoting2.sh @@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + set -o noglob if [[ 'hi there' != "hi there" ]] then err_exit "single quotes not the same as double quotes" diff --git a/src/cmd/ksh93/tests/readcsv.sh b/src/cmd/ksh93/tests/readcsv.sh index 97cea24e9..a01e782bc 100755 --- a/src/cmd/ksh93/tests/readcsv.sh +++ b/src/cmd/ksh93/tests/readcsv.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.readcsv.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } tmp1=$tmp/tmp1.csv tmp2=$tmp/tmp2.csv diff --git a/src/cmd/ksh93/tests/recttype.sh b/src/cmd/ksh93/tests/recttype.sh index 9f41d9266..e62a7171c 100755 --- a/src/cmd/ksh93/tests/recttype.sh +++ b/src/cmd/ksh93/tests/recttype.sh @@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + typeset -T Pt_t=( float x=1 float y=0 diff --git a/src/cmd/ksh93/tests/restricted.sh b/src/cmd/ksh93/tests/restricted.sh index a52c51731..b77ecdbea 100755 --- a/src/cmd/ksh93/tests/restricted.sh +++ b/src/cmd/ksh93/tests/restricted.sh @@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.restricted.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + binecho=$(whence -p echo) # test restricted shell diff --git a/src/cmd/ksh93/tests/return.sh b/src/cmd/ksh93/tests/return.sh index 65a7be536..b492409db 100755 --- a/src/cmd/ksh93/tests/return.sh +++ b/src/cmd/ksh93/tests/return.sh @@ -30,14 +30,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.return.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } unset HISTFILE diff --git a/src/cmd/ksh93/tests/select.sh b/src/cmd/ksh93/tests/select.sh index 6a465507f..01051b9bf 100755 --- a/src/cmd/ksh93/tests/select.sh +++ b/src/cmd/ksh93/tests/select.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.select.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } PS3='ABC ' diff --git a/src/cmd/ksh93/tests/shtests b/src/cmd/ksh93/tests/shtests index 926db479f..52aa0c8d9 100755 --- a/src/cmd/ksh93/tests/shtests +++ b/src/cmd/ksh93/tests/shtests @@ -10,7 +10,7 @@ valgrindflags='--xml=yes --log-file=/dev/null --track-origins=yes --read-var-inf USAGE=$' [-s8? -@(#)$Id: shtests (AT&T Research/ksh93) 2020-06-23 $ +@(#)$Id: shtests (AT&T Research/ksh93) 2020-07-04 $ ] '$USAGE_LICENSE$' [+NAME?shtests - ksh regression test harness] @@ -31,6 +31,7 @@ USAGE=$' } [c:compile?Run test scripts using \bshcomp\b(1).] [d:debug?Enable \bshtests\b execution trace.] +[k:keep?Keep temporary files after test run; shtests will report the location.] [l:locale?Disable \b--utf8\b and run the \b--posix\b and \b--compile\b tests, if enabled, in the locale of the caller. This may cause invalid regressions, especially for locales where \b.\b is not the radix @@ -170,7 +171,7 @@ export ENV=/./dev/null trap + PIPE # unadvertized -- set SIGPIPE to SIG_DFL # integer compile=-1 posix=-1 utf8=-1 -integer debug=0 locale=0 time=1 +integer debug=0 keep=0 locale=0 time=1 typeset vmalloc_options=abort trace= valgrind= vmalloc_options= #XXX# until multi-region vmalloc trace fixed #XXX# @@ -183,6 +184,9 @@ do case $OPT in ;; d) debug=$OPTARG ;; + k) keep=$OPTARG + echo "[DEBUG] keep == [$keep]" >&2 + ;; l) locale=$OPTARG ;; p) posix=$OPTARG @@ -282,7 +286,10 @@ tmp=$( echo 'mkdir failed' >&2 exit 1 } -trap 'cd / && rm -rf "$tmp"' EXIT +if (( keep )) +then trap 'printf "\nTemporary files left in: %s\n" "$tmp"' EXIT +else trap 'cd / && rm -rf "$tmp"' EXIT +fi if (( compile )) then if whence $SHCOMP > /dev/null @@ -329,14 +336,22 @@ do [[ $i == *.sh ]] || i+='.sh' [[ $utf8 == 0 || $i == $setslocale ]] || locales+=" C.UTF-8" for lang in $locales do o=$u + tmp_s=$tmp/$u.$lang + mkdir -m700 "$tmp_s" || exit if [[ $lang == C ]] then lang= else o="$o($lang)" lang=LANG=$lang fi echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} - eval $lang \$valgrind \$SHELL \$trace \$i + ( + export ${lang:+"$lang"} "tmp=$tmp_s" + $valgrind $SHELL $trace $i + ) e=$? + if (( !keep )) + then rm -rf "$tmp_s" + fi if [[ $valgrind ]] then valxml $valxml (( e += $? )) @@ -361,8 +376,10 @@ do [[ $i == *.sh ]] || i+='.sh' then c=$tmp/shcomp-$u.ksh o="$u(shcomp)" echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} + tmp_s=$tmp/$u.shcomp + mkdir -m700 "$tmp_s" || exit if $SHCOMP $i > $c - then if $valgrind $SHELL $trace $c + then if tmp=$tmp_s $valgrind $SHELL $trace $c then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 errors ]" else e=$? if (( e > 128 && ++total_e )) @@ -381,6 +398,9 @@ do [[ $i == *.sh ]] || i+='.sh' (( ++total_e )) echo test $o failed to compile ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ 1 test 1 error ]" fi + if (( !keep )) + then rm -rf "$tmp_s" "$c" + fi if [[ $i == $timesensitive ]] then VMALLOC_OPTIONS=$vmalloc_options fi diff --git a/src/cmd/ksh93/tests/sigchld.sh b/src/cmd/ksh93/tests/sigchld.sh index 47c5bf8fc..3cd9e804e 100755 --- a/src/cmd/ksh93/tests/sigchld.sh +++ b/src/cmd/ksh93/tests/sigchld.sh @@ -23,20 +23,15 @@ function err_exit print -u2 -r ${Command}[$1]: "${@:2}" (( Errors+=1 )) } - alias err_exit='err_exit $LINENO' -float DELAY=${1:-0.02} -integer FOREGROUND=10 BACKGROUND=2 Errors=0 +Command=${0##*/} +integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.sigchld.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + +float DELAY=${1:-0.02} +integer FOREGROUND=10 BACKGROUND=2 s=$($SHELL -c ' integer i foreground=0 background=0 diff --git a/src/cmd/ksh93/tests/signal.sh b/src/cmd/ksh93/tests/signal.sh index 9c0b86223..5e7f4b9dd 100755 --- a/src/cmd/ksh93/tests/signal.sh +++ b/src/cmd/ksh93/tests/signal.sh @@ -28,16 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.signal.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT - -cd $tmp || err_exit "cd $tmp failed" +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } +CDPATH= cd -P -- "$tmp" || exit unset n s t typeset -A SIG diff --git a/src/cmd/ksh93/tests/statics.sh b/src/cmd/ksh93/tests/statics.sh index 2168f156c..b3e989b56 100755 --- a/src/cmd/ksh93/tests/statics.sh +++ b/src/cmd/ksh93/tests/statics.sh @@ -27,14 +27,14 @@ function err_exit print -u2 -r ${Command}[$1]: "${@:2}" (( Errors < 127 && Errors++ )) } - alias err_exit='err_exit $LINENO' -set -o nounset Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } +set -o nounset typeset -T test_t=( typeset name diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh index d7b67a97d..edd11b3ba 100755 --- a/src/cmd/ksh93/tests/subshell.sh +++ b/src/cmd/ksh93/tests/subshell.sh @@ -29,14 +29,7 @@ Command=${0##*/} integer Errors=0 typeset -F SECONDS # for fractional seconds in PS4 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.subshell.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } builtin getconf bincat=$(PATH=$(getconf PATH) whence -p cat) diff --git a/src/cmd/ksh93/tests/substring.sh b/src/cmd/ksh93/tests/substring.sh index b74c18143..e4b970ff3 100755 --- a/src/cmd/ksh93/tests/substring.sh +++ b/src/cmd/ksh93/tests/substring.sh @@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + tmpPS4='+ [temp_PS4|L$LINENO|e$?] ' # used to avoid interference to ${.sh.match} from $PS4 set by shtests integer j=4 diff --git a/src/cmd/ksh93/tests/tilde.sh b/src/cmd/ksh93/tests/tilde.sh index 7b2e645c0..affb117cd 100755 --- a/src/cmd/ksh93/tests/tilde.sh +++ b/src/cmd/ksh93/tests/tilde.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.tilde.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } if $SHELL -c '[[ ~root == /* ]]' then x=$(print -r -- ~root) diff --git a/src/cmd/ksh93/tests/timetype.sh b/src/cmd/ksh93/tests/timetype.sh index 16453c47e..d8a58f356 100755 --- a/src/cmd/ksh93/tests/timetype.sh +++ b/src/cmd/ksh93/tests/timetype.sh @@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + typeset -T Time_t=( integer .=-1 _='%F+%H:%M' diff --git a/src/cmd/ksh93/tests/treemove.sh b/src/cmd/ksh93/tests/treemove.sh index 8e293c082..f5ef434f9 100755 --- a/src/cmd/ksh93/tests/treemove.sh +++ b/src/cmd/ksh93/tests/treemove.sh @@ -59,11 +59,13 @@ function err_exit print -u2 -r ${Command}[$1]: "${@:2}" (( Errors+=1 )) } - alias err_exit='err_exit $LINENO' +Command=${0##*/} integer Errors=0 +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + ## test start typeset -C tree1 tree2 diff --git a/src/cmd/ksh93/tests/types.sh b/src/cmd/ksh93/tests/types.sh index 220cccdb8..95135abd8 100755 --- a/src/cmd/ksh93/tests/types.sh +++ b/src/cmd/ksh93/tests/types.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.types.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } integer n=2 diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index c9bb3fc54..60554282d 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO' Command=${0##*/} integer Errors=0 -tmp=$( - d=${TMPDIR:-/tmp}/ksh93.variables.$$.${RANDOM:-0} - mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd -) || { - err\_exit $LINENO 'mkdir failed' - exit 1 -} -trap 'cd / && rm -rf "$tmp"' EXIT +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } [[ ${.sh.version} == "$KSH_VERSION" ]] || err_exit '.sh.version != KSH_VERSION' unset ss diff --git a/src/cmd/ksh93/tests/vartree1.sh b/src/cmd/ksh93/tests/vartree1.sh index d558dc6ef..61d130973 100755 --- a/src/cmd/ksh93/tests/vartree1.sh +++ b/src/cmd/ksh93/tests/vartree1.sh @@ -30,9 +30,13 @@ function err_exit print -u2 -r ${Command}[$1]: "${@:2}" (( Errors+=1 )) } - alias err_exit='err_exit $LINENO' +Command=${0##*/} +integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + function build_tree { #set -o errexit -o xtrace diff --git a/src/cmd/ksh93/tests/vartree2.sh b/src/cmd/ksh93/tests/vartree2.sh index e3e4cffc2..b4c37cc58 100755 --- a/src/cmd/ksh93/tests/vartree2.sh +++ b/src/cmd/ksh93/tests/vartree2.sh @@ -30,9 +30,13 @@ function err_exit print -u2 -r ${Command}[$1]: "${@:2}" (( Errors+=1 )) } - alias err_exit='err_exit $LINENO' +Command=${0##*/} +integer Errors=0 + +[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } + # "built_tree1" and "built_tree2" are identical except the way how they test # whether a variable exists: # - "built_tree1" uses "${varname}" != "", e.g. looking whether the variable