mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Add more regression tests, mostly from ksh93v- and ksh2020 (#216)
src/cmd/ksh93/tests/arrays.sh, src/cmd/ksh93/tests/arrays2.sh: - Backport some regression tests from ksh93v- for associative arrays. src/cmd/ksh93/tests/basic.sh: - Add ksh93v- regression tests for background process output in backtick and shared-state command substitutions as well as functions used in command substitutions. - Add regression tests for using EXIT traps in subshells. In ksh93v- and ksh2020 EXIT traps don't work in forked subshells: https://github.com/att/ast/issues/1452 - The trap builtin shouldn't segfault after receiving an invalid signal name. ksh2020 regression: https://github.com/att/ast/issues/1403 - Add a test to make sure invalid flags don't crash ksh. ksh2020 regression: https://github.com/att/ast/issues/1284 - Test for an illegal seek error when using the 'join' command with process substitutions. ksh93v- regression: https://www.mail-archive.com/ast-users@lists.research.att.com/msg00816.html src/cmd/ksh93/tests/bracket.sh: - Add some regression tests from ksh93v- for the -eq test operator. src/cmd/ksh93/tests/builtins.sh: - Move the regression test for 'exit' in an interactive shell to the exit.sh script. - Test for assignments preceding the command builtin persisting after an error. ksh2020 regression: https://github.com/att/ast/issues/1402 - The chmod builtin should modify the permissions of all files passed to it. ksh2020 regression: https://github.com/att/ast/issues/949 - Add regression tests for the cd builtin. In ksh93v- 2013-10-10 alpha, using cd on a directory without an execute bit doesn't cause an error. The test for using cd on a normal file was backported from ksh93v-. - Backport a ksh93v- regression test for the exit status from 'kill %'. src/cmd/ksh93/tests/case.sh: - Test for a segfault when ksh handles an invalid character class in a pattern. ksh2020 regression: https://github.com/att/ast/issues/1409 src/cmd/ksh93/tests/exit.sh: - Add regression tests from ksh2020 for the 'exit' builtin:d9491d46src/cmd/ksh93/tests/io.sh: - Add a regression test from ksh93v- for a process substitution hang. This test fails in the 93v- 2013 alpha but succeeds in the 2014 beta. src/cmd/ksh93/tests/math.sh: - 'typeset -s foo=30000' adds garbage to $foo in ksh93u+, ksh93v- and ksh2020: $ typeset -s foo=30000 $ echo $foo 5#1430000 This bug was fixed in commit88a6baa1, but that commit didn't add a regression test for it. src/cmd/ksh93/tests/variables.sh: - Add a regression test for $PS4 incorrectly unsetting ${.sh.subshell}: https://github.com/att/ast/issues/1092
This commit is contained in:
parent
5939964725
commit
59bacfd494
10 changed files with 206 additions and 7 deletions
|
|
@ -419,8 +419,16 @@ unset foo
|
|||
unset foo
|
||||
foo=$(false) > /dev/null && err_exit 'failed command substitution with redirection not returning false'
|
||||
expected=foreback
|
||||
got=`print -n fore; (sleep 2;print back)&`
|
||||
[[ $got == $expected ]] || err_exit "\`\` command substitution background process output error (expected '$expected', got '$got')"
|
||||
got=$(print -n fore; (sleep .2;print back)&)
|
||||
[[ $got == $expected ]] || err_exit "command substitution background process output error -- got '$got', expected '$expected'"
|
||||
[[ $got == $expected ]] || err_exit "\$() command substitution background process output error (expected '$expected', got '$got')"
|
||||
got=${ print -n fore; (sleep 2;print back)& }
|
||||
[[ $got == $expected ]] || err_exit "\${} shared-state command substitution background process output error (expected '$expected', got '$got')"
|
||||
function abc { sleep 2; print back; }
|
||||
function abcd { abc & }
|
||||
got=$(print -n fore;abcd)
|
||||
[[ $got == $expected ]] || err_exit "\$() command substitution background with function process output error (expected '$expected', got '$got')"
|
||||
|
||||
for false in false $binfalse
|
||||
do x=$($false) && err_exit "x=\$($false) should fail"
|
||||
|
|
@ -790,5 +798,46 @@ trap - DEBUG # bug compat
|
|||
[[ $got == "$exp" ]] || err_exit "DEBUG trap did not trigger return from POSIX function on status 255" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# In ksh93v- and ksh2020 EXIT traps don't work in forked subshells
|
||||
# https://github.com/att/ast/issues/1452
|
||||
exp="forked subshell EXIT trap okay"
|
||||
got="$(ulimit -t unlimited; trap 'echo forked subshell EXIT trap okay' EXIT)"
|
||||
[[ $got == $exp ]] || err_exit "EXIT trap did not trigger in forked subshell" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
exp="virtual subshell EXIT trap okay"
|
||||
got="$(trap 'echo virtual subshell EXIT trap okay' EXIT)"
|
||||
[[ $got == $exp ]] || err_exit "EXIT trap did not trigger in virtual subshell" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
# Regression test for https://github.com/att/ast/issues/1403
|
||||
for t in {A..Z}; do
|
||||
$SHELL -c "trap - $t 2> /dev/null"
|
||||
[[ $? == 1 ]] || err_exit "'trap' throws segfault when given invalid signal name '$t'"
|
||||
done
|
||||
|
||||
# ======
|
||||
# Is an invalid flag handled correctly?
|
||||
# ksh2020 regression: https://github.com/att/ast/issues/1284
|
||||
actual=$($SHELL --verson 2>&1)
|
||||
actual_status=$?
|
||||
expect='ksh: verson: bad option(s)'
|
||||
expect_status=2
|
||||
[[ "$actual" == ${expect}* ]] || err_exit "failed to get version string" \
|
||||
"(expected $(printf %q ${expect}*), got $(printf %q "$actual"))"
|
||||
[[ $actual_status == $expect_status ]] ||
|
||||
err_exit "wrong exit status (expected '$expect_status', got '$actual_status')"
|
||||
|
||||
# ======
|
||||
# Test for illegal seek error (ksh93v- regression)
|
||||
# https://www.mail-archive.com/ast-users@lists.research.att.com/msg00816.html
|
||||
exp='1
|
||||
2'
|
||||
got="$(join <(printf '%d\n' 1 2) <(printf '%d\n' 1 2))"
|
||||
[[ $exp == $got ]] || err_exit "pipeline fails with illegal seek error" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue