diff options
author | jilles <jilles@FreeBSD.org> | 2010-05-28 22:08:34 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-05-28 22:08:34 +0000 |
commit | bb4be30b2dbb8dae012830d33db99d965bf90222 (patch) | |
tree | 9865b417d06674a56b07cc2937aa6d9ef0d69a07 /tools | |
parent | cadeb05108049c61cafe2d8616c8ab7a8134e980 (diff) | |
download | FreeBSD-src-bb4be30b2dbb8dae012830d33db99d965bf90222.zip FreeBSD-src-bb4be30b2dbb8dae012830d33db99d965bf90222.tar.gz |
sh: Add some simple tests for ., exec and return from . script.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/builtins/dot1.0 | 21 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/exec1.0 | 25 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/return4.0 | 16 |
3 files changed, 62 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/dot1.0 b/tools/regression/bin/sh/builtins/dot1.0 new file mode 100644 index 0000000..43eab0d --- /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/exec1.0 b/tools/regression/bin/sh/builtins/exec1.0 new file mode 100644 index 0000000..94af2a0 --- /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 0000000..be5582b --- /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" |