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

shtests: cd to each test set's temp dir before running

An oops in tests/io.sh (re: c607c48c) wrote temporary files outside
$tmp and into src/cmd/ksh93/tests. Let's fix this properly so it
doesn't happen again.

src/cmd/ksh93/tests/shtests:
- Start each test set in its own temporary directory by default.

src/cmd/ksh93/tests/*.sh:
- Refuse to run if $tmp != $PWD.
- Related cleanups.
This commit is contained in:
Martijn Dekker 2020-09-02 06:02:40 +01:00
parent 55f0f8ce52
commit 5395641036
51 changed files with 63 additions and 82 deletions

View file

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

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
{ {
x=abc x=abc

View file

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

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
function fun function fun
{ {

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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++ ))

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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 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,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
bincat=$(whence -p cat) bincat=$(whence -p cat)
binecho=$(whence -p echo) binecho=$(whence -p echo)
@ -66,9 +66,6 @@ umask u=rwx,go=rx || err_exit "umask u=rws,go=rx failed"
if [[ $(umask -S) != u=rwx,g=rx,o=rx ]] if [[ $(umask -S) != u=rwx,g=rx,o=rx ]]
then err_exit 'umask -S incorrect' then err_exit 'umask -S incorrect'
fi fi
pwd=$PWD
[[ $SHELL != /* ]] && SHELL=$pwd/$SHELL
cd $tmp || { err_exit "cd $tmp failed"; exit 1; }
um=$(umask -S) um=$(umask -S)
( umask 0777; > foobar ) ( umask 0777; > foobar )
rm -f foobar rm -f foobar
@ -235,7 +232,6 @@ if [[ $x != hello ]]
then err_exit "command substitution with stdout closed failed" then err_exit "command substitution with stdout closed failed"
fi fi
exec >& 9 exec >& 9
cd $pwd
x=$(export binecho bincat; cat <<\! | $SHELL x=$(export binecho bincat; cat <<\! | $SHELL
"$binecho" | "$bincat" "$binecho" | "$bincat"
"$binecho" hello "$binecho" hello

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
null='' null=''
if [[ ! -z $null ]] if [[ ! -z $null ]]

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
bincat=$(whence -p cat) bincat=$(whence -p cat)

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
bar=foo2 bar=foo2
bam=foo[3] bam=foo[3]

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
#test for compound variables #test for compound variables
Command=${0##*/} Command=${0##*/}

View file

@ -49,7 +49,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -29,7 +29,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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,7 +29,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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)

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
function abspath function abspath
{ {
@ -41,7 +41,6 @@ function abspath
#test for proper exit of shell #test for proper exit of shell
builtin getconf builtin getconf
ABSHELL=$(abspath) ABSHELL=$(abspath)
cd $tmp || { err_exit "cd $tmp failed"; exit 1; }
print exit 0 >.profile print exit 0 >.profile
${ABSHELL} <<! ${ABSHELL} <<!
HOME=$PWD \ HOME=$PWD \
@ -73,6 +72,7 @@ EOF
if [[ $($SHELL ./run.sh) != 123 ]] if [[ $($SHELL ./run.sh) != 123 ]]
then err_exit 'subshell trap on exit overwrites parent trap' then err_exit 'subshell trap on exit overwrites parent trap'
fi fi
cd /
cd ~- || err_exit "cd back failed" cd ~- || err_exit "cd back failed"
$SHELL -c 'builtin -f cmd getconf; getconf --"?-version"; exit 0' >/dev/null 2>&1 || err_exit 'ksh plugin exit failed -- was ksh built with CCFLAGS+=$(CC.EXPORT.DYNAMIC)?' $SHELL -c 'builtin -f cmd getconf; getconf --"?-version"; exit 0' >/dev/null 2>&1 || err_exit 'ksh plugin exit failed -- was ksh built with CCFLAGS+=$(CC.EXPORT.DYNAMIC)?'

View file

@ -27,7 +27,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -27,7 +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
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
function test_glob function test_glob
{ {
@ -89,8 +89,6 @@ alias test_case='test_case $LINENO'
unset undefined unset undefined
cd $tmp || { err_exit "cd $tmp failed"; exit 1; }
export LC_COLLATE=C export LC_COLLATE=C
touch B b touch B b
set -- * set -- *

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
function grep function grep
{ {

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
bincat=$(whence -p cat) bincat=$(whence -p cat)

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
unset HISTFILE unset HISTFILE
@ -49,7 +49,6 @@ done
exec 3> /dev/null exec 3> /dev/null
[[ $(fun) == good ]] || err_exit 'file 3 closed before subshell completes' [[ $(fun) == good ]] || err_exit 'file 3 closed before subshell completes'
exec 3>&- exec 3>&-
cd $tmp || { err_exit "cd $tmp failed"; exit ; }
print foo > file1 print foo > file1
print bar >> file1 print bar >> file1
if [[ $(<file1) != $'foo\nbar' ]] if [[ $(<file1) != $'foo\nbar' ]]
@ -145,7 +144,6 @@ print world
! !
chmod +x script chmod +x script
[[ $( $SHELL ./script) == $'hello\nworld' ]] || err_exit 'closing 3 & 4 causes script to fail' [[ $( $SHELL ./script) == $'hello\nworld' ]] || err_exit 'closing 3 & 4 causes script to fail'
cd ~- || err_exit "cd back failed"
( exec > '' ) 2> /dev/null && err_exit '> "" does not fail' ( exec > '' ) 2> /dev/null && err_exit '> "" does not fail'
unset x unset x
( exec > ${x} ) 2> /dev/null && err_exit '> $x, where x null does not fail' ( exec > ${x} ) 2> /dev/null && err_exit '> $x, where x null does not fail'
@ -542,13 +540,9 @@ actual=$( (redirect /dev/null/foo >$tmp/wrong_redirect) 2>&1; echo " status = $?
# Process substitution # Process substitution
# An output process substitution should work when combined with a redirection. # An output process substitution should work when combined with a redirection.
# The 'cd "$tmp"' is because in many versions of ksh the test creates a bizarre
# file that isn't easy to delete individually.
cd "$tmp"
result=$("$SHELL" -c 'echo ok > >(sed s/ok/good/); wait') result=$("$SHELL" -c 'echo ok > >(sed s/ok/good/); wait')
[[ $result == good ]] || err_exit 'process substitution does not work with redirections' \ [[ $result == good ]] || err_exit 'process substitution does not work with redirections' \
"(expected 'good', got $(printf %q "$result"))" "(expected 'good', got $(printf %q "$result"))"
cd - >/dev/null
# Process substitution in an interactive shell shouldn't print the # Process substitution in an interactive shell shouldn't print the
# process ID of the asynchronous process. # process ID of the asynchronous process.

View file

@ -29,7 +29,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
builtin vmstate 2>/dev/null || { err\_exit "$LINENO" 'vmstate built-in command not compiled in; skipping tests'; exit 0; } builtin vmstate 2>/dev/null || { err\_exit "$LINENO" 'vmstate built-in command not compiled in; skipping tests'; exit 0; }
# Get the current amount of memory usage # Get the current amount of memory usage

View file

@ -28,8 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
CDPATH= cd -P -- "$tmp" || exit
unset LANG ${!LC_*} unset LANG ${!LC_*}

View file

@ -28,8 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
CDPATH= cd -P -- "$tmp" || exit
set -o nounset set -o nounset

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
function checkref function checkref
{ {

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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
@ -139,8 +139,7 @@ fi
rm -rf $tmp/.kshrc rm -rf $tmp/.kshrc
if command set -G 2> /dev/null if command set -G 2> /dev/null
then cd $tmp then mkdir bar foo
mkdir bar foo
> bar.c > bam.c > bar.c > bam.c
> bar/foo.c > bar/bam.c > bar/foo.c > bar/bam.c
> foo/bam.c > foo/bam.c
@ -160,10 +159,8 @@ then cd $tmp
expected='bam.c bar/bam.c foo/bam.c' expected='bam.c bar/bam.c foo/bam.c'
[[ $* == $expected ]] || [[ $* == $expected ]] ||
err_exit "-G **/bam.c failed -- expected '$expected', got '$*'" err_exit "-G **/bam.c failed -- expected '$expected', got '$*'"
cd ~-
fi fi
cd $tmp
t="<$$>.profile.<$$>" t="<$$>.profile.<$$>"
echo "echo '$t'" > .profile echo "echo '$t'" > .profile
cp $SHELL ./-ksh cp $SHELL ./-ksh
@ -201,8 +198,7 @@ else
[[ $(HOME=$PWD ./-ksh -ip </dev/null 2>&1) == *$t* ]] && [[ $(HOME=$PWD ./-ksh -ip </dev/null 2>&1) == *$t* ]] &&
err_exit './-ksh -p does not ignore .profile' err_exit './-ksh -p does not ignore .profile'
fi fi
cd ~- rm .profile
rm -rf $tmp/.profile
# { exec interactive login_shell restricted xtrace } in the following test # { exec interactive login_shell restricted xtrace } in the following test
@ -441,7 +437,6 @@ PAR=(
CMD=( command-kill script-kill ) CMD=( command-kill script-kill )
ADD=( '' '; :' ) ADD=( '' '; :' )
cd $tmp
print $'#!'$SHELL$'\nkill -KILL $$' > command-kill print $'#!'$SHELL$'\nkill -KILL $$' > command-kill
print $'kill -KILL $$' > script-kill print $'kill -KILL $$' > script-kill
chmod +x command-kill script-kill chmod +x command-kill script-kill

View file

@ -28,8 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
CDPATH= cd -P -- "$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'

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -41,7 +41,7 @@ alias err_exit='err_exit $lineno'
Command=${0##*/} Command=${0##*/}
integer Errors=0 lineno=1 integer Errors=0 lineno=1
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
whence -q pty || { err\_exit "$LINENO" "pty command not found -- tests skipped"; exit 0; } whence -q pty || { err\_exit "$LINENO" "pty command not found -- tests skipped"; exit 0; }
# On FreeBSD, the stty command does not appear to work correctly on a pty pseudoterminal. # On FreeBSD, the stty command does not appear to work correctly on a pty pseudoterminal.

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
binecho=$(whence -p echo) binecho=$(whence -p echo)

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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" ]]

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
tmp1=$tmp/tmp1.csv tmp1=$tmp/tmp1.csv
tmp2=$tmp/tmp2.csv tmp2=$tmp/tmp2.csv

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
binecho=$(whence -p echo) binecho=$(whence -p echo)
@ -46,8 +46,6 @@ function check_restricted
grep restricted out > /dev/null 2>&1 grep restricted out > /dev/null 2>&1
} }
[[ $SHELL != /* ]] && SHELL=$pwd/$SHELL
cd $tmp || err_exit "cd $tmp failed"
ln -s $SHELL rksh ln -s $SHELL rksh
PATH=$PWD:$PATH PATH=$PWD:$PATH
rksh -c '[[ -o restricted ]]' || err_exit 'restricted option not set' rksh -c '[[ -o restricted ]]' || err_exit 'restricted option not set'

View file

@ -30,7 +30,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
unset HISTFILE unset HISTFILE

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
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-08-11 $ @(#)$Id: shtests (AT&T Research/ksh93) 2020-09-02 $
] ]
'$USAGE_LICENSE$' '$USAGE_LICENSE$'
[+NAME?shtests - ksh regression test harness] [+NAME?shtests - ksh regression test harness]
@ -355,6 +355,7 @@ do [[ $i == *.sh ]] || i+='.sh'
do o=$u do o=$u
tmp_s=$tmp/$u.$lang tmp_s=$tmp/$u.$lang
mkdir -m700 "$tmp_s" || exit mkdir -m700 "$tmp_s" || exit
cd "$tmp_s" || exit
if [[ $lang == C ]] if [[ $lang == C ]]
then lang= then lang=
else o="$o($lang)" else o="$o($lang)"
@ -363,9 +364,10 @@ do [[ $i == *.sh ]] || i+='.sh'
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)"}
( (
export ${lang:+"$lang"} "tmp=$tmp_s" export ${lang:+"$lang"} "tmp=$tmp_s"
$valgrind $SHELL $trace $i $valgrind $SHELL $trace "$OLDPWD/$i"
) )
e=$? e=$?
cd "$OLDPWD" || exit
if (( !keep )) if (( !keep ))
then rm -rf "$tmp_s" then rm -rf "$tmp_s"
fi fi
@ -395,7 +397,8 @@ do [[ $i == *.sh ]] || i+='.sh'
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 tmp_s=$tmp/$u.shcomp
mkdir -m700 "$tmp_s" || exit mkdir -m700 "$tmp_s" || exit
if $SHCOMP $i > $c cd "$tmp_s" || exit
if $SHCOMP "$OLDPWD/$i" > $c
then if tmp=$tmp_s $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=$?
@ -415,6 +418,7 @@ 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
cd "$OLDPWD" || exit
if (( !keep )) if (( !keep ))
then rm -rf "$tmp_s" "$c" then rm -rf "$tmp_s" "$c"
fi fi

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
float DELAY=${1:-0.02} float DELAY=${1:-0.02}
integer FOREGROUND=10 BACKGROUND=2 integer FOREGROUND=10 BACKGROUND=2

View file

@ -28,8 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
CDPATH= cd -P -- "$tmp" || exit
unset n s t unset n s t
typeset -A SIG typeset -A SIG

View file

@ -32,7 +32,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
set -o nounset set -o nounset

View file

@ -29,7 +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
[[ -d $tmp && -w $tmp ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
builtin getconf builtin getconf
bincat=$(PATH=$(getconf PATH) whence -p cat) bincat=$(PATH=$(getconf PATH) whence -p cat)

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

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

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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

View file

@ -64,7 +64,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
integer n=2 integer n=2

View file

@ -28,7 +28,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
[[ ${.sh.version} == "$KSH_VERSION" ]] || err_exit '.sh.version != KSH_VERSION' [[ ${.sh.version} == "$KSH_VERSION" ]] || err_exit '.sh.version != KSH_VERSION'
unset ss unset ss
@ -74,7 +74,7 @@ cd /
if [[ $OLDPWD != $old ]] if [[ $OLDPWD != $old ]]
then err_exit "OLDPWD variable failed -- expected '$old', got '$OLDPWD'" then err_exit "OLDPWD variable failed -- expected '$old', got '$OLDPWD'"
fi fi
cd $old || err_exit cd failed cd "$old" || err_exit cd failed
# REPLY # REPLY
read <<-! read <<-!
foobar foobar
@ -220,6 +220,7 @@ done
kill -s 0 $! || err_exit '$! does not point to latest asynchronous process' kill -s 0 $! || err_exit '$! does not point to latest asynchronous process'
kill $! kill $!
unset x unset x
cd /tmp || exit
CDPATH=/ CDPATH=/
x=$(cd ${tmp#/}) x=$(cd ${tmp#/})
if [[ $x != $tmp ]] if [[ $x != $tmp ]]
@ -234,6 +235,7 @@ x=$(cd ${tmp#/})
if [[ $x != $tmp ]] if [[ $x != $tmp ]]
then err_exit "CDPATH ${tmp#/} does not display new directory" then err_exit "CDPATH ${tmp#/} does not display new directory"
fi fi
cd "$tmp" || exit
TMOUT=100 TMOUT=100
(TMOUT=20) (TMOUT=20)
if (( TMOUT !=100 )) if (( TMOUT !=100 ))
@ -750,8 +752,6 @@ set --
) )
Errors=$? # ensure error count survives subshell Errors=$? # ensure error count survives subshell
cd $tmp
print print -n zzz > zzz print print -n zzz > zzz
chmod +x zzz chmod +x zzz
exp='aaazzz' exp='aaazzz'

View file

@ -35,7 +35,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { err\_exit "$LINENO" '$tmp not set; run this from shtests. Aborting.'; exit 1; }
function build_tree function build_tree
{ {

View file

@ -35,7 +35,7 @@ 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; } [[ -d $tmp && -w $tmp && $tmp == "$PWD" ]] || { 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: