Sync /bin/sh regression tests with FreeBSD.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 20 Feb 2011 21:33:23 +0000 (11:33 -1000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 20 Feb 2011 21:33:23 +0000 (11:33 -1000)
-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
tools/regression/bin/sh/builtins/read5.0 [new file with mode: 0644]
tools/regression/bin/sh/execution/fork1.0
tools/regression/bin/sh/expansion/cmdsubst3.0
tools/regression/bin/sh/regress.sh

index 181a6b8..2de987c 100644 (file)
@@ -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 (file)
index 0000000..5683b11
--- /dev/null
@@ -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"
index d98d6a8..5a81e80 100644 (file)
@@ -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
index f897fcb..9f824ce 100644 (file)
@@ -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
index 89a76e6..6db261b 100644 (file)
@@ -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