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

Misc regression test fixes

src/cmd/ksh93/tests/basic.sh:
- Fix syntax error (unbalanced single quote) in two -c script
  invocations. It only failed to throw a syntax error due to a
  problematic hack in ksh that may be removed soon.
  See: https://github.com/ksh93/ksh/issues/199

src/cmd/ksh93/tests/builtins.sh,
src/cmd/ksh93/tests/io.sh:
- Redirect standard error on two ksh -i invocations to /dev/null
  to work around the test hanging on AIX.

src/cmd/ksh93/tests/comvario.sh:
- Remove duplicate copyright header.
- Fix warning format.

src/cmd/ksh93/tests/functions.sh:
- Fix the 'TERM signal sent to last process of function kills the
  script' test so that it works on AIX. We cannot rely on grepping
  'ps' output as the external 'sleep' command does not show the
  command name on AIX. Instead, find it by its parent PID.

src/cmd/ksh93/tests/locale.sh,
src/cmd/ksh93/tests/substring.sh:
- Rewrite the very broken multibyte locale tests (two outright
  syntax errors due to unbalanced quotes, and none of the tests
  actually worked).
- Since they set LC_ALL, move them to locale.sh.

src/cmd/ksh93/tests/variables.sh:
- Redirect stderr on some 'ulimit -t unlimited' invocations (which
  fork subshells as the intended side effect) to /dev/null in case
  that exceeds a system-defined limit.
This commit is contained in:
Martijn Dekker 2021-02-28 21:57:38 +00:00
parent 7ad274f8b6
commit 5d82004426
8 changed files with 45 additions and 44 deletions

View file

@ -357,8 +357,8 @@ fi
print cat > $tmp/scriptx print cat > $tmp/scriptx
chmod +x $tmp/scriptx chmod +x $tmp/scriptx
[[ $($SHELL -c "print foo | $tmp/scriptx ;:" 2> /dev/null ) == foo ]] || err_exit 'piping into script fails' [[ $($SHELL -c "print foo | $tmp/scriptx ;:" 2> /dev/null ) == foo ]] || err_exit 'piping into script fails'
[[ $($SHELL -c 'X=1;print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}'" 2> /dev/null) == 1 ]] || err_exit 'x=1;${x:=$(..."...")} failure' [[ $($SHELL -c 'X=1;print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}" 2> /dev/null) == 1 ]] || err_exit 'x=1;${x:=$(..."...")} failure'
[[ $($SHELL -c 'print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}'" 2> /dev/null) == 0 ]] || err_exit '${x:=$(..."...")} failure' [[ $($SHELL -c 'print -r -- ${X:=$(expr "a(0)" : '"'a*(\([^)]\))')}" 2> /dev/null) == 0 ]] || err_exit '${x:=$(..."...")} failure'
if cat /dev/fd/3 >/dev/null 2>&1 || whence mkfifo > /dev/null if cat /dev/fd/3 >/dev/null 2>&1 || whence mkfifo > /dev/null
then [[ $(cat <(print hello) ) == hello ]] || err_exit "process substitution not working outside for or while loop" then [[ $(cat <(print hello) ) == hello ]] || err_exit "process substitution not working outside for or while loop"
$SHELL -c '[[ $(for i in 1;do cat <(print hello);done ) == hello ]]' 2> /dev/null|| err_exit "process substitution not working in for or while loop" $SHELL -c '[[ $(for i in 1;do cat <(print hello);done ) == hello ]]' 2> /dev/null|| err_exit "process substitution not working in for or while loop"

View file

@ -686,7 +686,7 @@ then (
fi fi
cd "$tmp" cd "$tmp"
$SHELL +E -i <<- \! && err_exit 'interactive shell should not exit 0 after false' $SHELL +E -i 2>/dev/null <<- \! && err_exit 'interactive shell should not exit 0 after false'
false false
exit exit
! !

View file

@ -15,24 +15,6 @@
# Florham Park NJ # # Florham Park NJ #
# # # #
# David Korn <dgk@research.att.com> # # David Korn <dgk@research.att.com> #
# #
########################################################################
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2012 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# http://www.eclipse.org/org/documents/epl-v10.html #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# Roland Mainz <roland.mainz@nrubsig.org> # # Roland Mainz <roland.mainz@nrubsig.org> #
# # # #
######################################################################## ########################################################################
@ -41,10 +23,11 @@
function err_exit function err_exit
{ {
print -u2 -n '\t' print -u2 -n '\t'
print -u2 -r ${Command}[$1]: "${@:2}" print -u2 -r "${Command}[$1]: ${@:2}"
(( Errors++ )) (( Errors++ ))
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
alias warning='err\_exit $((Errors--,LINENO)) warning:'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
@ -58,7 +41,7 @@ integer Errors=0 HAVE_signbit=0
if typeset -f .sh.math.signbit >/dev/null && (( signbit(-NaN) )) if typeset -f .sh.math.signbit >/dev/null && (( signbit(-NaN) ))
then HAVE_signbit=1 then HAVE_signbit=1
else print -u2 "$0: warning: -lm does not support signbit(-NaN)" else warning "-lm does not support signbit(-NaN)"
fi fi
compound bracketstat=( compound bracketstat=(

View file

@ -36,8 +36,9 @@ read -n4 c < $0 2> /dev/null
ulimit -c 0 ulimit -c 0
binecho=$(whence -p echo) bin_echo=$(whence -p echo)
bin_sleep=$(whence -p sleep) bin_sleep=$(whence -p sleep)
bin_kill=$(whence -p kill)
integer foo=33 integer foo=33
bar=bye bar=bye
@ -138,7 +139,7 @@ fi
if [[ $PWD != "$dir" ]] if [[ $PWD != "$dir" ]]
then err_exit 'cd inside nested subshell changes $PWD' then err_exit 'cd inside nested subshell changes $PWD'
fi fi
fun() "$binecho" hello fun() "$bin_echo" hello
if [[ $(fun) != hello ]] if [[ $(fun) != hello ]]
then err_exit one line functions not working then err_exit one line functions not working
fi fi
@ -1126,7 +1127,15 @@ function gosleep
"$bin_sleep" 1 "$bin_sleep" 1
} }
x=$( x=$(
(sleep .25; pid=; ps 2>/dev/null | grep sleep | read pid extra; [[ $pid ]] && kill -- "$pid") & ulimit -t unlimited 2>/dev/null # fork this subshell
mysubpid=${.sh.pid} # this subshell's new PID (new 93u+m feature)
(
sleep .25
# kill 'gosleep' by getting the PIDs that have $mysubpid as their parent PID
# (which includes this background process itself, but that's fine as we're invoking external 'kill')
pids=$(UNIX95=1 ps -o ppid= -o pid= 2>/dev/null | awk -v p=$mysubpid '$1==p { print $2 }')
[[ -n $pids ]] && "$bin_kill" $pids
) &
gosleep 2> /dev/null gosleep 2> /dev/null
print ok print ok
) )

View file

@ -643,7 +643,7 @@ err=$(
# ====== # ======
# A redirection with a null command could crash under certain circumstances (rhbz#1200534) # A redirection with a null command could crash under certain circumstances (rhbz#1200534)
"$SHELL" -i >/dev/null -c ' "$SHELL" -i >/dev/null 2>&1 -c '
function dlog function dlog
{ {
fc -ln -0 fc -ln -0

View file

@ -42,6 +42,29 @@ 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, *\[.*,,") b=$($SHELL -c '(LC_ALL=debug; / 2>/dev/null); /' 2>&1 | sed -e "s,.*: *,," -e "s, *\[.*,,")
[[ "$b" == "$a" ]] || err_exit "locale not restored after subshell -- expected '$a', got '$b'" [[ "$b" == "$a" ]] || err_exit "locale not restored after subshell -- expected '$a', got '$b'"
# multibyte locale tests
if ((SHOPT_MULTIBYTE))
then LC_ALL=debug
x='a<2b|>c<3d|\>e'
typeset -A exp=(
['${x:0:1}']=a
['${x:1:1}']='<2b|>'
['${x:3:1}']='<3d|\>'
['${x:4:1}']=e
['${x:1}']='<2b|>c<3d|\>e'
['${x: -1:1}']=e
['${x: -2:1}']='<3d|\>'
['${x:1:3}']='<2b|>c<3d|\>'
['${x:1:20}']='<2b|>c<3d|\>e'
['${x#??}']='c<3d|\>e'
)
for i in "${!exp[@]}"
do eval "got=$i"
test "$got" = "${exp[$i]}" || err_exit "$i: expected '${exp[$i]}', got '$got'"
done
unset exp LC_ALL
fi # SHOPT_MULTIBYTE
# test shift-jis \x81\x40 ... \x81\x7E encodings # test shift-jis \x81\x40 ... \x81\x7E encodings
# (shift char followed by 7 bit ascii) # (shift char followed by 7 bit ascii)

View file

@ -585,20 +585,6 @@ do i=$1
shift 4 shift 4
done done
#multibyte locale tests
if((SHOPT_MULTIBYTE)); then
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:0:1}" == a || err_exit ${x:0:1} should be a'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1:1}" == "<2b|>" || err_exit ${x:1:1} should be <2b|>'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:3:1}" == "<3d|\\>" || err_exit ${x:3:1} should be <3d|\>'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:4:1}" == e || err_exit ${x:4:1} should bee'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1}" == "<2b|>c<3d|\\>e" || print -u2 ${x:1}" should be <2b|>c<3d|\>e'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x: -1:1}" == e || err_exit ${x: -1:1} should be e'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x: -2:1}" == "<3d|\\>" || err_exit ${x: -2:1} == <3d|\>'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1:3}" == "<2b|>c<3d|\\>" || err_exit ${x:1:3} should be <2b|>c<3d|\>'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x:1:20}" == "<2b|>c<3d|\\>e" || err_exit ${x:1:20} should be <2b|>c<3d|\>e'
x='a<2b|>c<3d|\>e' LC_ALL=debug $SHELL -c 'test "${x#??}" == "c<3d|\\>e" || err_exit "${x#??} should be c<3d|\>e'
fi # SHOPT_MULTIBYTE
x='a one and a two' x='a one and a two'
[[ "${x//~(E)\<.\>/}" == ' one and two' ]] || err_exit "\< and \> not working in with ere's" [[ "${x//~(E)\<.\>/}" == ' one and two' ]] || err_exit "\< and \> not working in with ere's"

View file

@ -710,7 +710,7 @@ actual=$(
( (
echo ${.sh.subshell} | cat # left element of pipe should increase ${.sh.subshell} echo ${.sh.subshell} | cat # left element of pipe should increase ${.sh.subshell}
echo ${.sh.subshell} echo ${.sh.subshell}
ulimit -t unlimited # fork ulimit -t unlimited 2>/dev/null # fork
echo ${.sh.subshell} # should be same after forking existing virtual subshell echo ${.sh.subshell} # should be same after forking existing virtual subshell
) )
echo ${.sh.subshell} # a background job should also increase ${.sh.subshell} echo ${.sh.subshell} # a background job should also increase ${.sh.subshell}
@ -730,7 +730,7 @@ set --
unset r v x unset r v x
( (
ulimit -t unlimited # TODO: this test messes up LINENO past the subshell unless we fork it ulimit -t unlimited 2>/dev/null # TODO: this test messes up LINENO past the subshell unless we fork it
x=foo x=foo
for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV RANDOM SECONDS _ LINENO for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV RANDOM SECONDS _ LINENO
do nameref r=$v do nameref r=$v
@ -1082,7 +1082,7 @@ $SHELL -c '
# ====== # ======
# ${.sh.pid} should be the forked subshell's PID # ${.sh.pid} should be the forked subshell's PID
( (
ulimit -t unlimited ulimit -t unlimited 2>/dev/null # fork the subshell
[[ ${.sh.pid} == $$ ]] [[ ${.sh.pid} == $$ ]]
) && err_exit "\${.sh.pid} is the same as \$$ (both are $$)" ) && err_exit "\${.sh.pid} is the same as \$$ (both are $$)"