summaryrefslogtreecommitdiffstats
path: root/tools/regression/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tools/regression/bin')
-rw-r--r--tools/regression/bin/sh/builtins/cd3.021
-rw-r--r--tools/regression/bin/sh/builtins/cd4.038
-rw-r--r--tools/regression/bin/sh/builtins/dot4.012
-rw-r--r--tools/regression/bin/sh/parameters/positional1.013
-rw-r--r--tools/regression/bin/sh/parser/alias4.05
-rw-r--r--tools/regression/bin/sh/parser/alias5.05
-rw-r--r--tools/regression/bin/sh/parser/heredoc11.026
7 files changed, 120 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/cd3.0 b/tools/regression/bin/sh/builtins/cd3.0
new file mode 100644
index 0000000..7729c54
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/cd3.0
@@ -0,0 +1,21 @@
+# $FreeBSD$
+
+# If fully successful, cd -Pe must be like cd -P.
+
+set -e
+
+cd "${TMPDIR:-/tmp}"
+cd -Pe /
+[ "$PWD" = / ]
+[ "$(pwd)" = / ]
+cd "${TMPDIR:-/tmp}"
+cd -eP /
+[ "$PWD" = / ]
+[ "$(pwd)" = / ]
+
+set +e
+
+# If cd -Pe cannot chdir, the exit status must be greater than 1.
+
+v=$( (cd -Pe /var/empty/nonexistent) 2>&1 >/dev/null)
+[ $? -gt 1 ] && [ -n "$v" ]
diff --git a/tools/regression/bin/sh/builtins/cd4.0 b/tools/regression/bin/sh/builtins/cd4.0
new file mode 100644
index 0000000..df3a9a4
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/cd4.0
@@ -0,0 +1,38 @@
+# $FreeBSD$
+
+# This test assumes that whatever mechanism cd -P uses to determine the
+# pathname to the current directory if it is longer than PATH_MAX requires
+# read permission on all parent directories. It also works if this
+# requirement always applies.
+
+set -e
+L=$(getconf PATH_MAX / 2>/dev/null) || L=4096
+[ "$L" -lt 100000 ] 2>/dev/null || L=4096
+L=$((L+100))
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
+trap 'chmod u+r ${T}; rm -rf ${T}' 0
+cd -Pe $T
+D=$(pwd)
+chmod u-r "$D"
+if [ -r "$D" ]; then
+ # Running as root, cannot test.
+ exit 0
+fi
+set +e
+while [ ${#D} -lt $L ]; do
+ mkdir veryverylongdirectoryname || exit
+ cd -Pe veryverylongdirectoryname 2>/dev/null
+ r=$?
+ [ $r -gt 1 ] && exit $r
+ if [ $r -eq 1 ]; then
+ # Verify that the directory was changed correctly.
+ cd -Pe .. || exit
+ [ "$(pwd)" = "$D" ] || exit
+ # Verify that omitting -e results in success.
+ cd -P veryverylongdirectoryname 2>/dev/null || exit
+ exit 0
+ fi
+ D=$D/veryverylongdirectoryname
+done
+echo "cd -Pe never returned 1"
+exit 0
diff --git a/tools/regression/bin/sh/builtins/dot4.0 b/tools/regression/bin/sh/builtins/dot4.0
new file mode 100644
index 0000000..b898131
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/dot4.0
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+v=abcd
+v=$v$v$v$v
+v=$v$v$v$v
+v=$v$v$v$v
+v=$v$v$v$v
+v=$v$v$v$v
+r=$( (
+ trap 'exit 0' 0
+ . "$v"
+) 2>&1 >/dev/null) && [ -n "$r" ]
diff --git a/tools/regression/bin/sh/parameters/positional1.0 b/tools/regression/bin/sh/parameters/positional1.0
new file mode 100644
index 0000000..67d1951
--- /dev/null
+++ b/tools/regression/bin/sh/parameters/positional1.0
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+set -- a b c d e f g h i j
+[ "$1" = a ] || echo "error at line $LINENO"
+[ "${1}" = a ] || echo "error at line $LINENO"
+[ "${1-foo}" = a ] || echo "error at line $LINENO"
+[ "${1+foo}" = foo ] || echo "error at line $LINENO"
+[ "$1+foo" = a+foo ] || echo "error at line $LINENO"
+[ "$10" = a0 ] || echo "error at line $LINENO"
+[ "$100" = a00 ] || echo "error at line $LINENO"
+[ "${10}" = j ] || echo "error at line $LINENO"
+[ "${10-foo}" = j ] || echo "error at line $LINENO"
+[ "${100-foo}" = foo ] || echo "error at line $LINENO"
diff --git a/tools/regression/bin/sh/parser/alias4.0 b/tools/regression/bin/sh/parser/alias4.0
new file mode 100644
index 0000000..19332ed
--- /dev/null
+++ b/tools/regression/bin/sh/parser/alias4.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+alias alias0=exit
+eval 'x=1 alias0 0'
+exit 1
diff --git a/tools/regression/bin/sh/parser/alias5.0 b/tools/regression/bin/sh/parser/alias5.0
new file mode 100644
index 0000000..3d0205f
--- /dev/null
+++ b/tools/regression/bin/sh/parser/alias5.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+alias alias0=exit
+eval '</dev/null alias0 0'
+exit 1
diff --git a/tools/regression/bin/sh/parser/heredoc11.0 b/tools/regression/bin/sh/parser/heredoc11.0
new file mode 100644
index 0000000..5839e46
--- /dev/null
+++ b/tools/regression/bin/sh/parser/heredoc11.0
@@ -0,0 +1,26 @@
+# $FreeBSD$
+
+failures=''
+
+check() {
+ if eval "[ $* ]"; then
+ :
+ else
+ echo "Failed: $*"
+ failures=x$failures
+ fi
+}
+
+check '`cat <<EOF
+foo
+EOF` = foo'
+
+check '"`cat <<EOF
+foo
+EOF`" = foo'
+
+check '`eval "cat <<EOF
+foo
+EOF"` = foo'
+
+test "x$failures" = x
OpenPOWER on IntegriCloud