Date: Fri, 28 May 2010 22:08:35 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r208629 - head/tools/regression/bin/sh/builtins Message-ID: <201005282208.o4SM8Z3I021877@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Fri May 28 22:08:34 2010 New Revision: 208629 URL: http://svn.freebsd.org/changeset/base/208629 Log: sh: Add some simple tests for ., exec and return from . script. Added: head/tools/regression/bin/sh/builtins/dot1.0 (contents, props changed) head/tools/regression/bin/sh/builtins/exec1.0 (contents, props changed) head/tools/regression/bin/sh/builtins/return4.0 (contents, props changed) Added: head/tools/regression/bin/sh/builtins/dot1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/dot1.0 Fri May 28 22:08:34 2010 (r208629) @@ -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" Added: head/tools/regression/bin/sh/builtins/exec1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/exec1.0 Fri May 28 22:08:34 2010 (r208629) @@ -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" Added: head/tools/regression/bin/sh/builtins/return4.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/return4.0 Fri May 28 22:08:34 2010 (r208629) @@ -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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005282208.o4SM8Z3I021877>