From 3779d84220cd0737d7a21d06ab061bd590ae7b2c Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 16 Dec 2021 11:45:53 +0100 Subject: [PATCH] more regression test updates (re: 7cdb01f6) --- src/cmd/ksh93/tests/builtins.sh | 42 ++++++++++++++++++--------------- src/cmd/ksh93/tests/locale.sh | 40 ++++++++++++++++--------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/cmd/ksh93/tests/builtins.sh b/src/cmd/ksh93/tests/builtins.sh index 6c95c14bf..7d01e73e7 100755 --- a/src/cmd/ksh93/tests/builtins.sh +++ b/src/cmd/ksh93/tests/builtins.sh @@ -1100,14 +1100,16 @@ got=$($SHELL -c 't=good; t=bad command -@; print $t' 2>/dev/null) # ====== # Regression test for https://github.com/att/ast/issues/949 -foo_script='#!/bin/sh -exit 0' -echo "$foo_script" > "$tmp/foo1.sh" -echo "$foo_script" > "$tmp/foo2.sh" -builtin chmod -chmod +x "$tmp/foo1.sh" "$tmp/foo2.sh" -$SHELL "$tmp/foo1.sh" || err_exit "builtin 'chmod +x' doesn't work on first script" -$SHELL "$tmp/foo2.sh" || err_exit "builtin 'chmod +x' doesn't work on second script" +if (builtin chmod) 2>/dev/null +then foo_script='#!/bin/sh + exit 0' + echo "$foo_script" > "$tmp/foo1.sh" + echo "$foo_script" > "$tmp/foo2.sh" + builtin chmod + chmod +x "$tmp/foo1.sh" "$tmp/foo2.sh" + $SHELL "$tmp/foo1.sh" || err_exit "builtin 'chmod +x' doesn't work on first script" + $SHELL "$tmp/foo2.sh" || err_exit "builtin 'chmod +x' doesn't work on second script" +fi # ====== # In ksh93v- 2013-10-10 alpha cd doesn't fail on directories without execute permission. @@ -1208,19 +1210,21 @@ got=$( # ====== # Test for bugs related to 'uname -d' # https://github.com/att/ast/pull/1187 -builtin uname -exp=$(uname -o) +if (builtin uname) 2>/dev/null +then builtin uname + exp=$(uname -o) -# Test for a possible crash (to avoid crashing the script, fork the subshell) -( - ulimit -t unlimited 2> /dev/null - uname -d > /dev/null -) || err_exit "'uname -d' crashes" + # Test for a possible crash (to avoid crashing the script, fork the subshell) + ( + ulimit -t unlimited 2> /dev/null + uname -d > /dev/null + ) || err_exit "'uname -d' crashes" -# 'uname -d' shouldn't change the output of 'uname -o' -got=$(ulimit -t unlimited 2> /dev/null; uname -d > /dev/null; uname -o) -[[ $exp == $got ]] || err_exit "'uname -d' changes the output of 'uname -o'" \ - "(expected $(printf %q "$exp"), got $(printf %q "$got"))" + # 'uname -d' shouldn't change the output of 'uname -o' + got=$(ulimit -t unlimited 2> /dev/null; uname -d > /dev/null; uname -o) + [[ $exp == $got ]] || err_exit "'uname -d' changes the output of 'uname -o'" \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" +fi # ====== # https://github.com/ksh93/ksh/issues/138 diff --git a/src/cmd/ksh93/tests/locale.sh b/src/cmd/ksh93/tests/locale.sh index 5a2998cc6..86f3c7153 100755 --- a/src/cmd/ksh93/tests/locale.sh +++ b/src/cmd/ksh93/tests/locale.sh @@ -157,25 +157,27 @@ fi #$SHELL -c 'export LANG='$locale'; printf "\u[20ac]\u[20ac]" > $tmp/two_euro_chars.txt' printf $'\342\202\254\342\202\254' > $tmp/two_euro_chars.txt -if((SHOPT_MULTIBYTE)); then -exp="6 2 6" -else -exp="6 6 6" -fi # SHOPT_MULTIBYTE -set -- $($SHELL -c " - if builtin wc 2>/dev/null || builtin -f cmd wc 2>/dev/null - then unset LC_CTYPE - export LANG=$locale - export LC_ALL=C - wc -C < $tmp/two_euro_chars.txt - unset LC_ALL - wc -C < $tmp/two_euro_chars.txt - export LC_ALL=C - wc -C < $tmp/two_euro_chars.txt - fi -") -got=$* -[[ $got == $exp ]] || err_exit "builtin wc LC_ALL default failed -- expected '$exp', got '$got'" +if (builtin wc) 2>/dev/null +then if((SHOPT_MULTIBYTE)); then + exp="6 2 6" + else + exp="6 6 6" + fi # SHOPT_MULTIBYTE + set -- $($SHELL -c " + if builtin wc 2>/dev/null || builtin -f cmd wc 2>/dev/null + then unset LC_CTYPE + export LANG=$locale + export LC_ALL=C + wc -C < $tmp/two_euro_chars.txt + unset LC_ALL + wc -C < $tmp/two_euro_chars.txt + export LC_ALL=C + wc -C < $tmp/two_euro_chars.txt + fi + ") + got=$* + [[ $got == $exp ]] || err_exit "builtin wc LC_ALL default failed -- expected '$exp', got '$got'" +fi # multibyte char straddling buffer boundary