Date: Sun, 16 Jan 2011 23:41:41 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r217489 - in stable/8/tools/regression/bin/sh: builtins expansion Message-ID: <201101162341.p0GNffIi081127@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun Jan 16 23:41:40 2011 New Revision: 217489 URL: http://svn.freebsd.org/changeset/base/217489 Log: MFC r215547,r216763,r216819,r216871,r217172: sh testcases. Added: stable/8/tools/regression/bin/sh/builtins/exit1.0 - copied unchanged from r216871, head/tools/regression/bin/sh/builtins/exit1.0 stable/8/tools/regression/bin/sh/builtins/exit2.8 - copied unchanged from r217172, head/tools/regression/bin/sh/builtins/exit2.8 stable/8/tools/regression/bin/sh/builtins/wait3.0 - copied unchanged from r215547, head/tools/regression/bin/sh/builtins/wait3.0 stable/8/tools/regression/bin/sh/expansion/cmdsubst6.0 - copied unchanged from r216763, head/tools/regression/bin/sh/expansion/cmdsubst6.0 stable/8/tools/regression/bin/sh/expansion/cmdsubst8.0 - copied unchanged from r216819, head/tools/regression/bin/sh/expansion/cmdsubst8.0 stable/8/tools/regression/bin/sh/expansion/cmdsubst9.0 - copied unchanged from r216819, head/tools/regression/bin/sh/expansion/cmdsubst9.0 Modified: Directory Properties: stable/8/tools/regression/bin/sh/ (props changed) Copied: stable/8/tools/regression/bin/sh/builtins/exit1.0 (from r216871, head/tools/regression/bin/sh/builtins/exit1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/exit1.0 Sun Jan 16 23:41:40 2011 (r217489, copy of r216871, head/tools/regression/bin/sh/builtins/exit1.0) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +# exit with an argument should overwrite the exit status in an EXIT trap. + +trap 'true; exit $?' 0 +false Copied: stable/8/tools/regression/bin/sh/builtins/exit2.8 (from r217172, head/tools/regression/bin/sh/builtins/exit2.8) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/exit2.8 Sun Jan 16 23:41:40 2011 (r217489, copy of r217172, head/tools/regression/bin/sh/builtins/exit2.8) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +# exit without arguments is the same as exit $? outside a trap. + +trap 'true; true' 0 +(exit 8) +exit Copied: stable/8/tools/regression/bin/sh/builtins/wait3.0 (from r215547, head/tools/regression/bin/sh/builtins/wait3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/wait3.0 Sun Jan 16 23:41:40 2011 (r217489, copy of r215547, head/tools/regression/bin/sh/builtins/wait3.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) +trap 'rm -rf $T' 0 +cd $T || exit 3 +mkfifo fifo1 +for i in 1 2 3 4 5 6 7 8 9 10; do + exit $i 4<fifo1 & +done +exec 3>fifo1 +wait || failure $LINENO +(echo >&3) 2>/dev/null && failure $LINENO +wait || failure $LINENO + +test -z "$failures" Copied: stable/8/tools/regression/bin/sh/expansion/cmdsubst6.0 (from r216763, head/tools/regression/bin/sh/expansion/cmdsubst6.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/cmdsubst6.0 Sun Jan 16 23:41:40 2011 (r217489, copy of r216763, head/tools/regression/bin/sh/expansion/cmdsubst6.0) @@ -0,0 +1,53 @@ +# $FreeBSD$ +# This tests if the cmdsubst optimization is still used if possible. + +failures='' +ok='' + +testcase() { + code="$1" + + unset v + eval "pid=\$(dummy=$code echo \$(\$SH -c echo\ \\\$PPID))" + + if [ "$pid" = "$$" ]; then + ok=x$ok + else + failures=x$failures + echo "Failure for $code" + fi +} + +unset v +w=1 +testcase '$w' +testcase '1${w+1}' +testcase '1${w-1}' +testcase '1${v+1}' +testcase '1${v-1}' +testcase '1${w:+1}' +testcase '1${w:-1}' +testcase '1${v:+1}' +testcase '1${v:-1}' +testcase '${w?}' +testcase '${w:?}' +testcase '${w#x}' +testcase '${w##x}' +testcase '${w%x}' +testcase '${w%%x}' + +testcase '$((w))' +testcase '$(((w+4)*2/3))' +testcase '$((w==1))' +testcase '$((w>=0 && w<=5 && w!=2))' +testcase '$((${#w}))' +testcase '$((${#IFS}))' +testcase '$((${#w}>=1))' +testcase '$(($$))' +testcase '$(($#))' +testcase '$(($?))' + +testcase '$(: $((w=4)))' +testcase '$(: ${v=2})' + +test "x$failures" = x Copied: stable/8/tools/regression/bin/sh/expansion/cmdsubst8.0 (from r216819, head/tools/regression/bin/sh/expansion/cmdsubst8.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/cmdsubst8.0 Sun Jan 16 23:41:40 2011 (r217489, copy of r216819, head/tools/regression/bin/sh/expansion/cmdsubst8.0) @@ -0,0 +1,17 @@ +# $FreeBSD$ +# Not required by POSIX (although referenced in a non-normative section), +# but possibly useful. + +: hi there & +p=$! +q=$(jobs -l $p) + +# Change tabs to spaces. +set -f +set -- $q +r="$*" + +case $r in +*" $p "*) ;; +*) echo Pid missing; exit 3 ;; +esac Copied: stable/8/tools/regression/bin/sh/expansion/cmdsubst9.0 (from r216819, head/tools/regression/bin/sh/expansion/cmdsubst9.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/cmdsubst9.0 Sun Jan 16 23:41:40 2011 (r217489, copy of r216819, head/tools/regression/bin/sh/expansion/cmdsubst9.0) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +set -e + +cd / +dummy=$(cd /bin) +[ "$(pwd)" = / ] + +v=1 +dummy=$(eval v=2) +[ "$v" = 1 ]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101162341.p0GNffIi081127>