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

tests/variables.sh: tweaks for special and locale variable tests

src/cmd/ksh93/tests/variables.sh:
- Fork the subshell with the test that includes unsetting LINENO
  and changing its type. Otherwise, some side effect of that leaks
  out of the subshell, messing up $LINENO. This is a bug, but it's
  low priority -- we may get to it someday. Marked with a TODO.
- Do the LC_* tests in their own subshell. Skip them if changing
  LANG to an invalid value does not produce a diagnostic message.
  This occurs on OpenBSD and Alpine Linux (with musl libc). It
  looks like their C libraries do not verify the locale, so
  failures here are not a ksh problem; skip the tests in that case.
This commit is contained in:
Martijn Dekker 2021-01-20 05:38:55 +00:00
parent 21c42fcef8
commit ec0155ee65

View file

@ -721,10 +721,11 @@ set -- {1..32768}
(( $# == 32768 )) || err_exit "\$# failed -- expected 32768, got $#" (( $# == 32768 )) || err_exit "\$# failed -- expected 32768, got $#"
set -- 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
x=foo x=foo
for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV LINENO RANDOM SECONDS _ for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV RANDOM SECONDS _ LINENO
do nameref r=$v do nameref r=$v
unset $v unset $v
if ( $SHELL -c "unset $v; : \$$v" ) 2>/dev/null if ( $SHELL -c "unset $v; : \$$v" ) 2>/dev/null
@ -734,7 +735,15 @@ set --
else err_exit "unset $v; : \$$v failed" else err_exit "unset $v; : \$$v failed"
fi fi
done done
exit $Errors
)
Errors=$? # ensure error count survives subshell
(
errmsg=$({ LANG=bad_LOCALE; } 2>&1)
if [[ -z $errmsg ]]
then print -u2 -r "${Command}[$LINENO]: warning: C library does not seem to verify locales: skipping LC_* tests"
exit $Errors
fi
x=x x=x
for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC
do nameref r=$v do nameref r=$v
@ -747,7 +756,6 @@ set --
{ g=$( r=C; r=$x; print -- $r ); } 2>/dev/null { g=$( r=C; r=$x; print -- $r ); } 2>/dev/null
[[ $g == 'C' ]] || err_exit "$v=C; $v=$x failed -- expected 'C', got '$g'" [[ $g == 'C' ]] || err_exit "$v=C; $v=$x failed -- expected 'C', got '$g'"
done done
exit $Errors exit $Errors
) )
Errors=$? # ensure error count survives subshell Errors=$? # ensure error count survives subshell