From 4bfff613235390e418af6fe340d465e53afba83a Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 20 Feb 2011 11:33:23 -1000 Subject: [PATCH] Sync /bin/sh regression tests with FreeBSD. -Add some tests for omitting whitespace. -Split off some special behaviour into separate tests. -Do not use "local" in the test runner. -Make execution/fork1.0 work even if the basename of ${SH} is not "sh". -Test that the read builtin passes through all byte values except NUL, newline and backslash. -Unset some locale vars in two tests that may cause them to break. Obtained-from: FreeBSD --- tools/regression/bin/sh/builtins/locale1.0 | 3 ++- tools/regression/bin/sh/builtins/read5.0 | 32 +++++++++++++++++++++++++++ tools/regression/bin/sh/execution/fork1.0 | 7 ++++-- tools/regression/bin/sh/expansion/cmdsubst3.0 | 5 ++++- tools/regression/bin/sh/regress.sh | 3 +-- 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 tools/regression/bin/sh/builtins/read5.0 diff --git a/tools/regression/bin/sh/builtins/locale1.0 b/tools/regression/bin/sh/builtins/locale1.0 index 181a6b8523..2de987cfe2 100644 --- a/tools/regression/bin/sh/builtins/locale1.0 +++ b/tools/regression/bin/sh/builtins/locale1.0 @@ -1,4 +1,4 @@ -# $FreeBSD: src/tools/regression/bin/sh/builtins/locale1.0,v 1.1 2010/05/05 21:48:40 jilles Exp $ +# $FreeBSD: src/tools/regression/bin/sh/builtins/locale1.0,v 1.2 2011/02/18 20:37:09 jilles Exp $ # Note: this test depends on strerror() using locale. failures=0 @@ -11,6 +11,7 @@ check() { } unset LANG LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME LC_MESSAGES +unset LANGUAGE msgeng="No such file or directory" msgdut="Bestand of map niet gevonden" diff --git a/tools/regression/bin/sh/builtins/read5.0 b/tools/regression/bin/sh/builtins/read5.0 new file mode 100644 index 0000000000..5683b1162b --- /dev/null +++ b/tools/regression/bin/sh/builtins/read5.0 @@ -0,0 +1,32 @@ +# $FreeBSD: src/tools/regression/bin/sh/builtins/read5.0,v 1.1 2011/02/18 20:51:13 jilles Exp $ + +unset LC_ALL +LC_CTYPE=en_US.ISO8859-1 +export LC_CTYPE + +# Note: the first and last characters are not whitespace. +# Exclude backslash and newline. +bad1=`printf %03o \'\\\\` +bad2=`printf %03o \'' +'` +e= +for i in 0 1 2 3; do + for j in 0 1 2 3 4 5 6 7; do + for k in 0 1 2 3 4 5 6 7; do + case $i$j$k in + 000|$bad1|$bad2) continue ;; + esac + e="$e\\$i$j$k" + done + done +done +e=`printf "$e"` +[ "${#e}" = 253 ] || echo length bad + +r1=`printf '%s\n' "$e" | { read -r x; printf '%s' "$x"; }` +[ "$r1" = "$e" ] || echo "read with -r bad" +r2=`printf '%s\n' "$e" | { read x; printf '%s' "$x"; }` +[ "$r2" = "$e" ] || echo "read without -r bad 1" +IFS= +r3=`printf '%s\n' "$e" | { read x; printf '%s' "$x"; }` +[ "$r3" = "$e" ] || echo "read without -r bad 2" diff --git a/tools/regression/bin/sh/execution/fork1.0 b/tools/regression/bin/sh/execution/fork1.0 index d98d6a8984..5a81e80534 100644 --- a/tools/regression/bin/sh/execution/fork1.0 +++ b/tools/regression/bin/sh/execution/fork1.0 @@ -1,7 +1,10 @@ -# $FreeBSD: src/tools/regression/bin/sh/execution/fork1.0,v 1.2 2010/10/12 18:20:38 obrien Exp $ +# $FreeBSD: src/tools/regression/bin/sh/execution/fork1.0,v 1.3 2011/02/19 13:22:18 jilles Exp $ + +shname=${SH%% *} +shname=${shname##*/} result=$(${SH} -c 'ps -p $$ -o comm=') test "$result" = "ps" || exit 1 result=$(${SH} -c 'ps -p $$ -o comm=; :') -test "$result" = "sh" || exit 1 +test "$result" = "$shname" || exit 1 diff --git a/tools/regression/bin/sh/expansion/cmdsubst3.0 b/tools/regression/bin/sh/expansion/cmdsubst3.0 index f897fcb967..9f824ce874 100644 --- a/tools/regression/bin/sh/expansion/cmdsubst3.0 +++ b/tools/regression/bin/sh/expansion/cmdsubst3.0 @@ -1,4 +1,7 @@ -# $FreeBSD: src/tools/regression/bin/sh/expansion/cmdsubst3.0,v 1.1 2010/12/16 23:28:20 jilles Exp $ +# $FreeBSD: src/tools/regression/bin/sh/expansion/cmdsubst3.0,v 1.2 2011/02/18 20:37:09 jilles Exp $ + +unset LC_ALL +export LC_CTYPE=en_US.ISO8859-1 e= for i in 0 1 2 3; do diff --git a/tools/regression/bin/sh/regress.sh b/tools/regression/bin/sh/regress.sh index 89a76e6bb5..6db261b969 100644 --- a/tools/regression/bin/sh/regress.sh +++ b/tools/regression/bin/sh/regress.sh @@ -1,4 +1,4 @@ -# $FreeBSD: src/tools/regression/bin/sh/regress.sh,v 1.4 2010/10/12 18:20:38 obrien Exp $ +# $FreeBSD: src/tools/regression/bin/sh/regress.sh,v 1.5 2011/02/19 13:23:13 jilles Exp $ if [ -z "${SH}" ]; then echo '${SH} is not set, please correct and re-run.' @@ -9,7 +9,6 @@ export SH=${SH} COUNTER=1 do_test() { - local c c=${COUNTER} COUNTER=$((COUNTER+1)) ${SH} $1 > tmp.stdout 2> tmp.stderr -- 2.11.4.GIT