summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2010-09-03 21:51:38 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2010-09-03 21:51:38 +0000
commita1fdfe542cc9419e41ebb1fb6156407d971f356d (patch)
tree28148623dea195dfb56f286d73131e8e0c0258c0 /tools
parent2bfdd3d2c53c2789d8403b273968dd4f6c3ebb89 (diff)
Notes
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/builtins/break2.012
-rw-r--r--tools/regression/bin/sh/builtins/break2.0.stdout1
-rw-r--r--tools/regression/bin/sh/builtins/dot1.021
-rw-r--r--tools/regression/bin/sh/builtins/eval4.05
-rw-r--r--tools/regression/bin/sh/builtins/exec1.025
-rw-r--r--tools/regression/bin/sh/builtins/return4.016
-rw-r--r--tools/regression/bin/sh/builtins/wait1.023
-rw-r--r--tools/regression/bin/sh/builtins/wait2.015
-rw-r--r--tools/regression/bin/sh/expansion/ifs2.024
-rw-r--r--tools/regression/bin/sh/expansion/plus-minus4.038
10 files changed, 180 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/break2.0 b/tools/regression/bin/sh/builtins/break2.0
new file mode 100644
index 000000000000..ff52dd321469
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/break2.0
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+# It is not immediately obvious that this should work, and someone probably
+# relies on it.
+
+while :; do
+ trap 'break' USR1
+ kill -USR1 $$
+ echo bad
+ exit 1
+done
+echo good
diff --git a/tools/regression/bin/sh/builtins/break2.0.stdout b/tools/regression/bin/sh/builtins/break2.0.stdout
new file mode 100644
index 000000000000..12799ccbe7ce
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/break2.0.stdout
@@ -0,0 +1 @@
+good
diff --git a/tools/regression/bin/sh/builtins/dot1.0 b/tools/regression/bin/sh/builtins/dot1.0
new file mode 100644
index 000000000000..43eab0ddeb33
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/dot1.0
@@ -0,0 +1,21 @@
+# $FreeBSD$
+
+failures=
+failure() {
+ echo "Error at line $1" >&2
+ failures=x$failures
+}
+
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) || exit
+trap 'rm -rf $T' 0
+cd $T || exit 3
+unset x
+echo 'x=2' >testscript
+. ./testscript
+[ "$x" = 2 ] || failure $LINENO
+cd / || exit 3
+x=1
+PATH=$T:$PATH . testscript
+[ "$x" = 2 ] || failure $LINENO
+
+test -z "$failures"
diff --git a/tools/regression/bin/sh/builtins/eval4.0 b/tools/regression/bin/sh/builtins/eval4.0
new file mode 100644
index 000000000000..67da2f5c832d
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/eval4.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+# eval should preserve $? from command substitutions when starting
+# the parsed command.
+[ $(eval 'echo $?' $(false)) = 1 ]
diff --git a/tools/regression/bin/sh/builtins/exec1.0 b/tools/regression/bin/sh/builtins/exec1.0
new file mode 100644
index 000000000000..94af2a08f3cd
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/exec1.0
@@ -0,0 +1,25 @@
+# $FreeBSD$
+
+failures=
+failure() {
+ echo "Error at line $1" >&2
+ failures=x$failures
+}
+
+(
+ exec >/dev/null
+ echo bad
+)
+[ $? = 0 ] || failure $LINENO
+(
+ exec sh -c 'exit 42'
+ echo bad
+)
+[ $? = 42 ] || failure $LINENO
+(
+ exec /var/empty/nosuch
+ echo bad
+) 2>/dev/null
+[ $? = 127 ] || failure $LINENO
+
+test -z "$failures"
diff --git a/tools/regression/bin/sh/builtins/return4.0 b/tools/regression/bin/sh/builtins/return4.0
new file mode 100644
index 000000000000..be5582b458b4
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/return4.0
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+failures=
+failure() {
+ echo "Error at line $1" >&2
+ failures=x$failures
+}
+
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) || exit
+trap 'rm -rf $T' 0
+cd $T || exit 3
+echo 'return 42; exit 4' >testscript
+. ./testscript
+[ "$?" = 42 ] || failure $LINENO
+
+test -z "$failures"
diff --git a/tools/regression/bin/sh/builtins/wait1.0 b/tools/regression/bin/sh/builtins/wait1.0
new file mode 100644
index 000000000000..1ca85308c9ac
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/wait1.0
@@ -0,0 +1,23 @@
+# $FreeBSD$
+
+failures=
+failure() {
+ echo "Error at line $1" >&2
+ failures=x$failures
+}
+
+exit 4 & p4=$!
+exit 8 & p8=$!
+wait $p4
+[ $? = 4 ] || failure $LINENO
+wait $p8
+[ $? = 8 ] || failure $LINENO
+
+exit 3 & p3=$!
+exit 7 & p7=$!
+wait $p7
+[ $? = 7 ] || failure $LINENO
+wait $p3
+[ $? = 3 ] || failure $LINENO
+
+test -z "$failures"
diff --git a/tools/regression/bin/sh/builtins/wait2.0 b/tools/regression/bin/sh/builtins/wait2.0
new file mode 100644
index 000000000000..e61455cf5f0e
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/wait2.0
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+failures=
+failure() {
+ echo "Error at line $1" >&2
+ failures=x$failures
+}
+
+for i in 1 2 3 4 5 6 7 8 9 10; do
+ exit $i &
+done
+wait || failure $LINENO
+wait || failure $LINENO
+
+test -z "$failures"
diff --git a/tools/regression/bin/sh/expansion/ifs2.0 b/tools/regression/bin/sh/expansion/ifs2.0
new file mode 100644
index 000000000000..e91b86707183
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/ifs2.0
@@ -0,0 +1,24 @@
+# $FreeBSD$
+
+failures=0
+i=1
+set -f
+while [ "$i" -le 127 ]; do
+ # A different byte still in the range 1..127.
+ i2=$((i^2+(i==2)))
+ # Add a character to work around command substitution's removal of
+ # final newlines, then remove it again.
+ c=$(printf \\"$(printf %o@ "$i")")
+ c=${c%@}
+ c2=$(printf \\"$(printf %o@ "$i2")")
+ c2=${c2%@}
+ IFS=$c
+ set -- $c2$c$c2$c$c2
+ if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] ||
+ [ "$3" != "$c2" ]; then
+ echo "Bad results for separator $i (word $i2)" >&2
+ : $((failures += 1))
+ fi
+ i=$((i+1))
+done
+exit $((failures > 0))
diff --git a/tools/regression/bin/sh/expansion/plus-minus4.0 b/tools/regression/bin/sh/expansion/plus-minus4.0
new file mode 100644
index 000000000000..66dea3851efc
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/plus-minus4.0
@@ -0,0 +1,38 @@
+# $FreeBSD$
+
+# These may be a bit unclear in the POSIX spec or the proposed revisions,
+# and conflict with bash's interpretation, but I think ksh93's interpretation
+# makes most sense. In particular, it makes no sense to me that single-quotes
+# must match but are not removed.
+
+e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
+h='##'
+failures=''
+ok=''
+
+testcase() {
+ code="$1"
+ expected="$2"
+ oIFS="$IFS"
+ eval "$code"
+ IFS='|'
+ result="$#|$*"
+ IFS="$oIFS"
+ if [ "x$result" = "x$expected" ]; then
+ ok=x$ok
+ else
+ failures=x$failures
+ echo "For $code, expected $expected actual $result"
+ fi
+}
+
+testcase 'set -- ${e:-'"'"'}'"'"'}' '1|}'
+testcase "set -- \${e:-\\'}" "1|'"
+testcase "set -- \${e:-\\'\\'}" "1|''"
+testcase "set -- \"\${e:-'}\"" "1|'"
+testcase "set -- \"\${e:-'}'}\"" "1|''}"
+testcase "set -- \"\${e:-''}\"" "1|''"
+testcase 'set -- ${e:-\a}' '1|a'
+testcase 'set -- "${e:-\a}"' '1|\a'
+
+test "x$failures" = x