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

Minor improvements to the regression tests (#366)

- tests/basic.sh: Fix a regression test that was failing under dtksh by
  allowing the error message to name ksh 'lt-dtksh'. Additionally, fix
  the test's inaccurate failure message (a version string is not what
  the regression test expects).

- test/builtins.sh: Exclude the expr builtin from the unrecognized
  options test because it's incompatible. Additionally, put the
  unrecognized options test inside of a function to ensure that it works
  with the future local builtin (https://github.com/ksh93/ksh/issues/123).

- tests/io.sh: The long seek test may fail to seek past the 2 GiB
  boundary on 32-bit systems, so only allow it to run on 64-bit.
  References:
  3222ac2b59/f/ksh-1.0.0-beta.1-regre-tests.patch
  a5c692e1bd

- tests/substring.sh: Add a regression test for the ${.sh.match}
  crashing bug fixed in commit 1bf1d2f8.
This commit is contained in:
Johnothan King 2021-12-08 16:58:40 -08:00 committed by Martijn Dekker
parent caae7dd7c9
commit 1f5ad85cd4
4 changed files with 30 additions and 18 deletions

View file

@ -832,7 +832,7 @@ actual=$($SHELL --verson 2>&1)
actual_status=$? actual_status=$?
expect='ksh: verson: bad option(s)' expect='ksh: verson: bad option(s)'
expect_status=2 expect_status=2
[[ "$actual" == ${expect}* ]] || err_exit "failed to get version string" \ [[ "$actual" == *${expect}* ]] || err_exit "failed to handle invalid flag" \
"(expected $(printf %q ${expect}*), got $(printf %q "$actual"))" "(expected $(printf %q ${expect}*), got $(printf %q "$actual"))"
[[ $actual_status == $expect_status ]] || [[ $actual_status == $expect_status ]] ||
err_exit "wrong exit status (expected '$expect_status', got '$actual_status')" err_exit "wrong exit status (expected '$expect_status', got '$actual_status')"

View file

@ -1031,22 +1031,25 @@ EOF
# ====== # ======
# Builtins should handle unrecognized options correctly # Builtins should handle unrecognized options correctly
while IFS= read -r bltin <&3 function test_usage
do case $bltin in {
echo | test | true | false | \[ | : | getconf | */getconf | uname | */uname | catclose | catgets | catopen | Dt* | _Dt* | X* | login | newgrp ) while IFS= read -r bltin <&3
continue ;; do case $bltin in
/*/*) expect="Usage: ${bltin##*/} " echo | test | true | false | \[ | : | expr | */expr | getconf | */getconf | uname | */uname | catclose | catgets | catopen | Dt* | _Dt* | X* | login | newgrp )
actual=$({ PATH=${bltin%/*}; "${bltin##*/}" --this-option-does-not-exist; } 2>&1) ;; continue ;;
*/*) err_exit "strange path name in 'builtin' output: $(printf %q "$bltin")" /*/*) expect="Usage: ${bltin##*/} "
continue ;; actual=$({ PATH=${bltin%/*}; "${bltin##*/}" --this-option-does-not-exist; } 2>&1) ;;
autoload | compound | float | functions | integer | nameref) */*) err_exit "strange path name in 'builtin' output: $(printf %q "$bltin")"
bltin=typeset ;& continue ;;
*) expect="Usage: $bltin " autoload | compound | float | functions | integer | nameref)
actual=$({ "${bltin}" --this-option-does-not-exist; } 2>&1) ;; bltin=typeset ;&
esac *) expect="Usage: $bltin "
[[ $actual == *"$expect"* ]] || err_exit "$bltin should show usage info on unrecognized options" \ actual=$({ "${bltin}" --this-option-does-not-exist; } 2>&1) ;;
"(expected string containing $(printf %q "$expect"), got $(printf %q "$actual"))" esac
done 3< <(builtin) [[ $actual == *"$expect"* ]] || err_exit "$bltin should show usage info on unrecognized options" \
"(expected string containing $(printf %q "$expect"), got $(printf %q "$actual"))"
done 3< <(builtin)
}; test_usage
# ====== # ======
# The 'alarm' builtin could make 'read' crash due to IFS table corruption caused by unsafe asynchronous execution. # The 'alarm' builtin could make 'read' crash due to IFS table corruption caused by unsafe asynchronous execution.

View file

@ -241,7 +241,12 @@ then [[ $(3<#) -eq 0 ]] || err_exit "not at position 0"
read -u3 && err_exit "not found pattern not positioning at eof" read -u3 && err_exit "not found pattern not positioning at eof"
cat $tmp/seek | read -r <# *WWW* cat $tmp/seek | read -r <# *WWW*
[[ $REPLY == *WWWWW* ]] || err_exit '<# not working for pipes' [[ $REPLY == *WWWWW* ]] || err_exit '<# not working for pipes'
{ < $tmp/seek <# ((2358336120)) ;} 2> /dev/null || err_exit 'long seek not working' # The next test seeks past a 2 GiB boundary, which may fail on 32-bit systems. To prevent
# a test failure, the long seek test is only run on 64-bit systems.
# https://github.com/att/ast/commit/a5c692e1bd0d800e3f19be249d3170e69cbe001d
if [[ $(builtin getconf 2> /dev/null; getconf LONG_BIT 2>&1) == 64 ]]; then
{ < $tmp/seek <# ((2358336120)) ;} 2> /dev/null || err_exit 'long seek not working'
fi
else err_exit "$tmp/seek: cannot open for reading" else err_exit "$tmp/seek: cannot open for reading"
fi fi
redirect 3<&- || 'cannot close 3' redirect 3<&- || 'cannot close 3'

View file

@ -680,5 +680,9 @@ exit $Errors
) )
Errors=$? Errors=$?
# ======
# Test for a crash after unsetting ${.sh.match} then matching a pattern
$SHELL -c 'unset .sh.match; [[ bar == ba* ]]' || err_exit 'crash after unsetting .sh.match then trying to match a pattern'
# ====== # ======
exit $((Errors<125?Errors:125)) exit $((Errors<125?Errors:125))