1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

shtests: use central temporary directory; add --keep option

This gets rid of repetitive code in test scripts to create their
own temporary directories. Instead, shtests exports a $tmp to each
test script that is a subdirectory of its own temporary directory.
This has the advantage of having all test script temporary
directories in one hierarchy. Along with a new option to keep
temporary files, this makes it easy to inspect them if wanted.

This does make the test scripts less self-contained as they now
depend on a temporary directory being exported as $tmp. But they
already depended on $SHELL being the shell to test, so they already
were not quite self-contained.

src/cmd/ksh93/tests/shtests:
- Add -k/--keep option to keep temporary directory. Make the EXIT
  trap report its location instead of deleting it.
- For each test, create a subdirectory of $tmp (named after the
  test script plus the tested locale or 'shcomp') and export that
  subdirectory to the test script as its own $tmp.
- If -k is not given, delete each script's temporary files
  immediately after running it to minimise disk usage.

src/cmd/ksh93/tests/*.sh:
- Don't make own temp directory.
- Refuse to run if $tmp is not set.
- Miscellaneous tweaks.
This commit is contained in:
Martijn Dekker 2020-07-04 01:28:08 +02:00
parent fa70fc3f77
commit d7afb57c49
51 changed files with 132 additions and 274 deletions

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
alias foo='print hello' alias foo='print hello'
if [[ $(foo) != hello ]] if [[ $(foo) != hello ]]

View file

@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
{ {
x=abc x=abc
x+=def ;} 2> /dev/null x+=def ;} 2> /dev/null

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
trap '' FPE # NOTE: osf.alpha requires this (no ieee math) trap '' FPE # NOTE: osf.alpha requires this (no ieee math)

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
function fun function fun
{ {

View file

@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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++ )) for ((i=0; i < 4; i++ ))
do for ((j=0; j < 5; j++ )) do for ((j=0; j < 5; j++ ))
do a[i][j]=$i$j do a[i][j]=$i$j

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
r=readonly u=Uppercase l=Lowercase i=22 i8=10 L=abc L5=def uL5=abcdef xi=20 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 x=export t=tagged H=hostname LZ5=026 RZ5=026 Z5=123 lR5=ABcdef R5=def n=l

View file

@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
bincat=$(whence -p cat) bincat=$(whence -p cat)
binecho=$(whence -p echo) binecho=$(whence -p echo)
# make an external 'sleep' command that supports fractional seconds # make an external 'sleep' command that supports fractional seconds

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
null='' null=''
if [[ ! -z $null ]] if [[ ! -z $null ]]

View file

@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
bincat=$(whence -p cat) bincat=$(whence -p cat)
# test shell builtin commands # 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" $SHELL -c "cd $tmp/a/b; cd c" 2>/dev/null || err_exit "initial script relative cd fails"
trap 'print TERM' TERM trap 'print TERM' TERM
exp=$'trap -- \'print TERM\' TERM\ntrap -- \'cd / && rm -rf "$tmp"\' EXIT' exp="trap -- 'print TERM' TERM"
got=$(trap) got=$(trap)
[[ $got == $exp ]] || err_exit "\$(trap) failed -- expected \"$exp\", got \"$got\"" [[ $got == $exp ]] || err_exit "\$(trap) failed -- expected \"$exp\", got \"$got\""
exp='print TERM' exp='print TERM'

View file

@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
bar=foo2 bar=foo2
bam=foo[3] bam=foo[3]
for i in foo1 foo2 foo3 foo4 foo5 foo6 for i in foo1 foo2 foo3 foo4 foo5 foo6

View file

@ -25,14 +25,10 @@ function err_exit
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
tmp=$( Command=${0##*/}
d=${TMPDIR:-/tmp}/ksh93.comvar.$$.${RANDOM:-0} integer Errors=0
mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd
) || { [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
err\_exit $LINENO 'mkdir failed'
exit 1
}
trap 'cd / && rm -rf "$tmp"' EXIT
#test for compound variables #test for compound variables
Command=${0##*/} Command=${0##*/}

View file

@ -46,6 +46,11 @@ function err_exit
} }
alias err_exit='err_exit $LINENO' 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 # "nounset" disabled for now
#set -o nounset #set -o nounset
Command=${0##*/} Command=${0##*/}

View file

@ -29,14 +29,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
if [[ -d /cygdrive ]] if [[ -d /cygdrive ]]
then err_exit cygwin detected - coprocess tests disabled - enable at the risk of wedging your system then err_exit cygwin detected - coprocess tests disabled - enable at the risk of wedging your system

View file

@ -29,6 +29,8 @@ Command=${0##*/}
integer Errors=0 integer Errors=0
integer n=2 integer n=2
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
typeset -T Box_t=( typeset -T Box_t=(
float -h 'height in inches' x=2 float -h 'height in inches' x=2
float -h 'width in inches' y=4 float -h 'width in inches' y=4

View file

@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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 Color_t=(red green blue orange yellow)
enum -i Sex_t=(Male Female) enum -i Sex_t=(Male Female)
for ((i=0; i < 1000; i++)) for ((i=0; i < 1000; i++))

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
function abspath function abspath
{ {

View file

@ -27,6 +27,8 @@ function err_exit
integer Errors=0 integer Errors=0
Command=${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 # {...} expansion tests -- ignore if not supported
[[ $(print a{0,1}z) == "a0z a1z" ]] || exit 0 [[ $(print a{0,1}z) == "a0z a1z" ]] || exit 0

View file

@ -27,20 +27,15 @@ alias err_exit='err_exit $LINENO'
integer Errors=0 integer Errors=0
Command=${0##*/} Command=${0##*/}
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
compiled='' compiled=''
read -n4 c < $0 2> /dev/null read -n4 c < $0 2> /dev/null
[[ $c == *$'\ck'* ]] && compiled=1 [[ $c == *$'\ck'* ]] && compiled=1
ulimit -c 0 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) binecho=$(whence -p echo)
integer foo=33 integer foo=33

View file

@ -27,14 +27,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer aware=0 contrary=0 Errors=0 ignorant=0 integer aware=0 contrary=0 Errors=0 ignorant=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
function test_glob function test_glob
{ {

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
function grep function grep
{ {

View file

@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
bincat=$(whence -p cat) bincat=$(whence -p cat)
f=$tmp/here1 f=$tmp/here1

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
unset HISTFILE unset HISTFILE

View file

@ -29,6 +29,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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 # Get the current amount of memory usage
function getmem function getmem
{ {

View file

@ -28,17 +28,10 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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=$( unset LANG ${!LC_*}
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
a=$($SHELL -c '/' 2>&1 | sed -e "s,.*: *,," -e "s, *\[.*,,") 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, *\[.*,,") b=$($SHELL -c '(LC_ALL=debug / 2>/dev/null); /' 2>&1 | sed -e "s,.*: *,," -e "s, *\[.*,,")

View file

@ -25,25 +25,14 @@ function err_exit
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
set -o nounset
Command=${0##*/} Command=${0##*/}
integer Errors=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 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 function test_arithmetric_expression_accesss_array_element_through_nameref
{ {
compound out=( typeset stdout stderr ; integer res ) compound out=( typeset stdout stderr ; integer res )

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
function checkref function checkref
{ {

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
foo=abc foo=abc
typeset -C bar=(x=3 y=4 t=7) typeset -C bar=(x=3 y=4 t=7)

View file

@ -28,19 +28,13 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
unset HISTFILE unset HISTFILE
export LC_ALL=C ENV=/./dev/null export LC_ALL=C ENV=/./dev/null
ulimit -c 0 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) bincat=$(whence -p cat)
if [[ $( ${SHELL-ksh} -s hello<<-\! if [[ $( ${SHELL-ksh} -s hello<<-\!

View file

@ -28,16 +28,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
d=${TMPDIR:-/tmp}/ksh93.path.$$.${RANDOM:-0} CDPATH= cd -P -- "$tmp" || exit
mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd
) || {
err\_exit $LINENO 'mkdir failed'
exit 1
}
trap 'cd / && rm -rf "$tmp"' EXIT
cd $tmp || exit
type /xxxxxx > out1 2> out2 type /xxxxxx > out1 2> out2
[[ -s out1 ]] && err_exit 'type should not write on stdout for not found case' [[ -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' [[ -s out2 ]] || err_exit 'type should write on stderr for not found case'

View file

@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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=( typeset -T Pt_t=(
float x=1 float x=1
float y=0 float y=0

View file

@ -41,7 +41,8 @@ alias err_exit='err_exit $lineno'
Command=${0##*/} Command=${0##*/}
integer Errors=0 lineno=1 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) bintrue=$(whence -p true)

View file

@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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) binecho=$(whence -p echo)
if [[ 'hi there' != "hi there" ]] if [[ 'hi there' != "hi there" ]]

View file

@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
set -o noglob set -o noglob
if [[ 'hi there' != "hi there" ]] if [[ 'hi there' != "hi there" ]]
then err_exit "single quotes not the same as double quotes" then err_exit "single quotes not the same as double quotes"

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
tmp1=$tmp/tmp1.csv tmp1=$tmp/tmp1.csv
tmp2=$tmp/tmp2.csv tmp2=$tmp/tmp2.csv

View file

@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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=( typeset -T Pt_t=(
float x=1 float x=1
float y=0 float y=0

View file

@ -28,14 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
binecho=$(whence -p echo) binecho=$(whence -p echo)
# test restricted shell # test restricted shell

View file

@ -30,14 +30,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
unset HISTFILE unset HISTFILE

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
PS3='ABC ' PS3='ABC '

View file

@ -10,7 +10,7 @@ valgrindflags='--xml=yes --log-file=/dev/null --track-origins=yes --read-var-inf
USAGE=$' USAGE=$'
[-s8? [-s8?
@(#)$Id: shtests (AT&T Research/ksh93) 2020-06-23 $ @(#)$Id: shtests (AT&T Research/ksh93) 2020-07-04 $
] ]
'$USAGE_LICENSE$' '$USAGE_LICENSE$'
[+NAME?shtests - ksh regression test harness] [+NAME?shtests - ksh regression test harness]
@ -31,6 +31,7 @@ USAGE=$'
} }
[c:compile?Run test scripts using \bshcomp\b(1).] [c:compile?Run test scripts using \bshcomp\b(1).]
[d:debug?Enable \bshtests\b execution trace.] [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 [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 tests, if enabled, in the locale of the caller. This may cause invalid
regressions, especially for locales where \b.\b is not the radix 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 # trap + PIPE # unadvertized -- set SIGPIPE to SIG_DFL #
integer compile=-1 posix=-1 utf8=-1 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= typeset vmalloc_options=abort trace= valgrind=
vmalloc_options= #XXX# until multi-region vmalloc trace fixed #XXX# vmalloc_options= #XXX# until multi-region vmalloc trace fixed #XXX#
@ -183,6 +184,9 @@ do case $OPT in
;; ;;
d) debug=$OPTARG d) debug=$OPTARG
;; ;;
k) keep=$OPTARG
echo "[DEBUG] keep == [$keep]" >&2
;;
l) locale=$OPTARG l) locale=$OPTARG
;; ;;
p) posix=$OPTARG p) posix=$OPTARG
@ -282,7 +286,10 @@ tmp=$(
echo 'mkdir failed' >&2 echo 'mkdir failed' >&2
exit 1 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 )) if (( compile ))
then if whence $SHCOMP > /dev/null then if whence $SHCOMP > /dev/null
@ -329,14 +336,22 @@ do [[ $i == *.sh ]] || i+='.sh'
[[ $utf8 == 0 || $i == $setslocale ]] || locales+=" C.UTF-8" [[ $utf8 == 0 || $i == $setslocale ]] || locales+=" C.UTF-8"
for lang in $locales for lang in $locales
do o=$u do o=$u
tmp_s=$tmp/$u.$lang
mkdir -m700 "$tmp_s" || exit
if [[ $lang == C ]] if [[ $lang == C ]]
then lang= then lang=
else o="$o($lang)" else o="$o($lang)"
lang=LANG=$lang lang=LANG=$lang
fi fi
echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} 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=$? e=$?
if (( !keep ))
then rm -rf "$tmp_s"
fi
if [[ $valgrind ]] if [[ $valgrind ]]
then valxml $valxml then valxml $valxml
(( e += $? )) (( e += $? ))
@ -361,8 +376,10 @@ do [[ $i == *.sh ]] || i+='.sh'
then c=$tmp/shcomp-$u.ksh then c=$tmp/shcomp-$u.ksh
o="$u(shcomp)" o="$u(shcomp)"
echo test $o begins ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} 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 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 ]" then echo test $o passed ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} "[ $t $T 0 errors ]"
else e=$? else e=$?
if (( e > 128 && ++total_e )) if (( e > 128 && ++total_e ))
@ -381,6 +398,9 @@ do [[ $i == *.sh ]] || i+='.sh'
(( ++total_e )) (( ++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 ]" echo test $o failed to compile ${time:+"at $(date +%Y-%m-%d+%H:%M:%S)"} with exit code $e "[ 1 test 1 error ]"
fi fi
if (( !keep ))
then rm -rf "$tmp_s" "$c"
fi
if [[ $i == $timesensitive ]] if [[ $i == $timesensitive ]]
then VMALLOC_OPTIONS=$vmalloc_options then VMALLOC_OPTIONS=$vmalloc_options
fi fi

View file

@ -23,20 +23,15 @@ function err_exit
print -u2 -r ${Command}[$1]: "${@:2}" print -u2 -r ${Command}[$1]: "${@:2}"
(( Errors+=1 )) (( Errors+=1 ))
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
float DELAY=${1:-0.02} Command=${0##*/}
integer FOREGROUND=10 BACKGROUND=2 Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
d=${TMPDIR:-/tmp}/ksh93.sigchld.$$.${RANDOM:-0}
mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd float DELAY=${1:-0.02}
) || { integer FOREGROUND=10 BACKGROUND=2
err\_exit $LINENO 'mkdir failed'
exit 1
}
trap 'cd / && rm -rf "$tmp"' EXIT
s=$($SHELL -c ' s=$($SHELL -c '
integer i foreground=0 background=0 integer i foreground=0 background=0

View file

@ -28,16 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
d=${TMPDIR:-/tmp}/ksh93.signal.$$.${RANDOM:-0} CDPATH= cd -P -- "$tmp" || exit
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"
unset n s t unset n s t
typeset -A SIG typeset -A SIG

View file

@ -27,14 +27,14 @@ function err_exit
print -u2 -r ${Command}[$1]: "${@:2}" print -u2 -r ${Command}[$1]: "${@:2}"
(( Errors < 127 && Errors++ )) (( Errors < 127 && Errors++ ))
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
set -o nounset
Command=${0##*/} Command=${0##*/}
integer Errors=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 -T test_t=(
typeset name typeset name

View file

@ -29,14 +29,7 @@ Command=${0##*/}
integer Errors=0 integer Errors=0
typeset -F SECONDS # for fractional seconds in PS4 typeset -F SECONDS # for fractional seconds in PS4
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
builtin getconf builtin getconf
bincat=$(PATH=$(getconf PATH) whence -p cat) bincat=$(PATH=$(getconf PATH) whence -p cat)

View file

@ -27,6 +27,9 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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 tmpPS4='+ [temp_PS4|L$LINENO|e$?] ' # used to avoid interference to ${.sh.match} from $PS4 set by shtests
integer j=4 integer j=4

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
if $SHELL -c '[[ ~root == /* ]]' if $SHELL -c '[[ ~root == /* ]]'
then x=$(print -r -- ~root) then x=$(print -r -- ~root)

View file

@ -28,6 +28,8 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=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=( typeset -T Time_t=(
integer .=-1 integer .=-1
_='%F+%H:%M' _='%F+%H:%M'

View file

@ -59,11 +59,13 @@ function err_exit
print -u2 -r ${Command}[$1]: "${@:2}" print -u2 -r ${Command}[$1]: "${@:2}"
(( Errors+=1 )) (( Errors+=1 ))
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
Command=${0##*/}
integer Errors=0 integer Errors=0
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
## test start ## test start
typeset -C tree1 tree2 typeset -C tree1 tree2

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
integer n=2 integer n=2

View file

@ -28,14 +28,7 @@ alias err_exit='err_exit $LINENO'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
tmp=$( [[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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
[[ ${.sh.version} == "$KSH_VERSION" ]] || err_exit '.sh.version != KSH_VERSION' [[ ${.sh.version} == "$KSH_VERSION" ]] || err_exit '.sh.version != KSH_VERSION'
unset ss unset ss

View file

@ -30,9 +30,13 @@ function err_exit
print -u2 -r ${Command}[$1]: "${@:2}" print -u2 -r ${Command}[$1]: "${@:2}"
(( Errors+=1 )) (( Errors+=1 ))
} }
alias err_exit='err_exit $LINENO' 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 function build_tree
{ {
#set -o errexit -o xtrace #set -o errexit -o xtrace

View file

@ -30,9 +30,13 @@ function err_exit
print -u2 -r ${Command}[$1]: "${@:2}" print -u2 -r ${Command}[$1]: "${@:2}"
(( Errors+=1 )) (( Errors+=1 ))
} }
alias err_exit='err_exit $LINENO' 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 # "built_tree1" and "built_tree2" are identical except the way how they test
# whether a variable exists: # whether a variable exists:
# - "built_tree1" uses "${varname}" != "", e.g. looking whether the variable # - "built_tree1" uses "${varname}" != "", e.g. looking whether the variable