Date: Fri, 3 Sep 2010 21:51:38 +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: r212188 - in stable/8/tools/regression/bin/sh: builtins expansion Message-ID: <201009032151.o83LpcAS065169@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Fri Sep 3 21:51:38 2010 New Revision: 212188 URL: http://svn.freebsd.org/changeset/base/212188 Log: MFC r208476,208629,210738,211080,211341,211467: New tests that also work with stable/8 sh. Added: stable/8/tools/regression/bin/sh/builtins/break2.0 - copied unchanged from r211467, head/tools/regression/bin/sh/builtins/break2.0 stable/8/tools/regression/bin/sh/builtins/break2.0.stdout - copied unchanged from r211467, head/tools/regression/bin/sh/builtins/break2.0.stdout stable/8/tools/regression/bin/sh/builtins/dot1.0 - copied unchanged from r208629, head/tools/regression/bin/sh/builtins/dot1.0 stable/8/tools/regression/bin/sh/builtins/eval4.0 - copied unchanged from r210738, head/tools/regression/bin/sh/builtins/eval4.0 stable/8/tools/regression/bin/sh/builtins/exec1.0 - copied unchanged from r208629, head/tools/regression/bin/sh/builtins/exec1.0 stable/8/tools/regression/bin/sh/builtins/return4.0 - copied unchanged from r208629, head/tools/regression/bin/sh/builtins/return4.0 stable/8/tools/regression/bin/sh/builtins/wait1.0 - copied unchanged from r208476, head/tools/regression/bin/sh/builtins/wait1.0 stable/8/tools/regression/bin/sh/builtins/wait2.0 - copied unchanged from r208476, head/tools/regression/bin/sh/builtins/wait2.0 stable/8/tools/regression/bin/sh/expansion/ifs2.0 - copied unchanged from r211341, head/tools/regression/bin/sh/expansion/ifs2.0 stable/8/tools/regression/bin/sh/expansion/plus-minus4.0 - copied unchanged from r211080, head/tools/regression/bin/sh/expansion/plus-minus4.0 Modified: Directory Properties: stable/8/tools/regression/bin/sh/ (props changed) Copied: stable/8/tools/regression/bin/sh/builtins/break2.0 (from r211467, head/tools/regression/bin/sh/builtins/break2.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/break2.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r211467, head/tools/regression/bin/sh/builtins/break2.0) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +# It is not immediately obvious that this should work, and someone probably +# relies on it. + +while :; do + trap 'break' USR1 + kill -USR1 $$ + echo bad + exit 1 +done +echo good Copied: stable/8/tools/regression/bin/sh/builtins/break2.0.stdout (from r211467, head/tools/regression/bin/sh/builtins/break2.0.stdout) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/break2.0.stdout Fri Sep 3 21:51:38 2010 (r212188, copy of r211467, head/tools/regression/bin/sh/builtins/break2.0.stdout) @@ -0,0 +1 @@ +good Copied: stable/8/tools/regression/bin/sh/builtins/dot1.0 (from r208629, head/tools/regression/bin/sh/builtins/dot1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/dot1.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r208629, head/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" Copied: stable/8/tools/regression/bin/sh/builtins/eval4.0 (from r210738, head/tools/regression/bin/sh/builtins/eval4.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/eval4.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r210738, head/tools/regression/bin/sh/builtins/eval4.0) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +# eval should preserve $? from command substitutions when starting +# the parsed command. +[ $(eval 'echo $?' $(false)) = 1 ] Copied: stable/8/tools/regression/bin/sh/builtins/exec1.0 (from r208629, head/tools/regression/bin/sh/builtins/exec1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/exec1.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r208629, head/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" Copied: stable/8/tools/regression/bin/sh/builtins/return4.0 (from r208629, head/tools/regression/bin/sh/builtins/return4.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/return4.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r208629, head/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" Copied: stable/8/tools/regression/bin/sh/builtins/wait1.0 (from r208476, head/tools/regression/bin/sh/builtins/wait1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/wait1.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r208476, head/tools/regression/bin/sh/builtins/wait1.0) @@ -0,0 +1,23 @@ +# $FreeBSD$ + +failures= +failure() { + echo "Error at line $1" >&2 + failures=x$failures +} + +exit 4 & p4=$! +exit 8 & p8=$! +wait $p4 +[ $? = 4 ] || failure $LINENO +wait $p8 +[ $? = 8 ] || failure $LINENO + +exit 3 & p3=$! +exit 7 & p7=$! +wait $p7 +[ $? = 7 ] || failure $LINENO +wait $p3 +[ $? = 3 ] || failure $LINENO + +test -z "$failures" Copied: stable/8/tools/regression/bin/sh/builtins/wait2.0 (from r208476, head/tools/regression/bin/sh/builtins/wait2.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/wait2.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r208476, head/tools/regression/bin/sh/builtins/wait2.0) @@ -0,0 +1,15 @@ +# $FreeBSD$ + +failures= +failure() { + echo "Error at line $1" >&2 + failures=x$failures +} + +for i in 1 2 3 4 5 6 7 8 9 10; do + exit $i & +done +wait || failure $LINENO +wait || failure $LINENO + +test -z "$failures" Copied: stable/8/tools/regression/bin/sh/expansion/ifs2.0 (from r211341, head/tools/regression/bin/sh/expansion/ifs2.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/ifs2.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r211341, head/tools/regression/bin/sh/expansion/ifs2.0) @@ -0,0 +1,24 @@ +# $FreeBSD$ + +failures=0 +i=1 +set -f +while [ "$i" -le 127 ]; do + # A different byte still in the range 1..127. + i2=$((i^2+(i==2))) + # Add a character to work around command substitution's removal of + # final newlines, then remove it again. + c=$(printf \\"$(printf %o@ "$i")") + c=${c%@} + c2=$(printf \\"$(printf %o@ "$i2")") + c2=${c2%@} + IFS=$c + set -- $c2$c$c2$c$c2 + if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] || + [ "$3" != "$c2" ]; then + echo "Bad results for separator $i (word $i2)" >&2 + : $((failures += 1)) + fi + i=$((i+1)) +done +exit $((failures > 0)) Copied: stable/8/tools/regression/bin/sh/expansion/plus-minus4.0 (from r211080, head/tools/regression/bin/sh/expansion/plus-minus4.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/plus-minus4.0 Fri Sep 3 21:51:38 2010 (r212188, copy of r211080, head/tools/regression/bin/sh/expansion/plus-minus4.0) @@ -0,0 +1,38 @@ +# $FreeBSD$ + +# These may be a bit unclear in the POSIX spec or the proposed revisions, +# and conflict with bash's interpretation, but I think ksh93's interpretation +# makes most sense. In particular, it makes no sense to me that single-quotes +# must match but are not removed. + +e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' +h='##' +failures='' +ok='' + +testcase() { + code="$1" + expected="$2" + oIFS="$IFS" + eval "$code" + IFS='|' + result="$#|$*" + IFS="$oIFS" + if [ "x$result" = "x$expected" ]; then + ok=x$ok + else + failures=x$failures + echo "For $code, expected $expected actual $result" + fi +} + +testcase 'set -- ${e:-'"'"'}'"'"'}' '1|}' +testcase "set -- \${e:-\\'}" "1|'" +testcase "set -- \${e:-\\'\\'}" "1|''" +testcase "set -- \"\${e:-'}\"" "1|'" +testcase "set -- \"\${e:-'}'}\"" "1|''}" +testcase "set -- \"\${e:-''}\"" "1|''" +testcase 'set -- ${e:-\a}' '1|a' +testcase 'set -- "${e:-\a}"' '1|\a' + +test "x$failures" = x
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009032151.o83LpcAS065169>