From owner-svn-src-stable-8@FreeBSD.ORG Sun Jan 16 23:41:41 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EEB4106566C; Sun, 16 Jan 2011 23:41:41 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C3128FC1D; Sun, 16 Jan 2011 23:41:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0GNffAq081133; Sun, 16 Jan 2011 23:41:41 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0GNffIi081127; Sun, 16 Jan 2011 23:41:41 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201101162341.p0GNffIi081127@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 16 Jan 2011 23:41:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217489 - in stable/8/tools/regression/bin/sh: builtins expansion X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Jan 2011 23:41:41 -0000 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 4fifo1 +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 ]