X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Ftest-tests;h=9b813590cf9f27acc168f96695db24fbfbdad1c2;hb=d166f048818e10cf3799aa24a174fb22835f1acc;hp=1fb0dc8fbaa8ae8e7912df1116d59561009bc567;hpb=ccc6cda312fea9f0468ee65b8f368e9653e1380b;p=platform%2Fupstream%2Fbash.git diff --git a/tests/test-tests b/tests/test-tests index 1fb0dc8..9b81359 100644 --- a/tests/test-tests +++ b/tests/test-tests @@ -1,3 +1,13 @@ +if (( $UID == 0 )); then + echo "test-tests: the test suite should not be run as root" >&2 +fi + +b() +{ + [ "$@" ] + echo $? +} + t() { test "$@" @@ -23,6 +33,10 @@ echo 't -d run-all' t -d run-all echo 't -d /etc' t -d /etc +echo 't -d ""' +t -d "" +echo 'b -d ""' +b -d "" echo 't -e noexist' t -e noexist @@ -40,6 +54,7 @@ echo 't -g run-all' t -g run-all touch /tmp/test.setgid +chgrp ${GROUPS[0]} /tmp/test.setgid chmod ug+x /tmp/test.setgid chmod g+s /tmp/test.setgid echo 't -g /tmp/test.setgid' @@ -60,11 +75,16 @@ t -p run-all echo 't -r noexist' t -r noexist -touch /tmp/test.noread -chmod a-r /tmp/test.noread -echo 't -r /tmp/test.noread' -t -r /tmp/test.noread -rm -f /tmp/test.noread +if (( $UID != 0 )); then + touch /tmp/test.noread + chmod a-r /tmp/test.noread + echo 't -r /tmp/test.noread' + t -r /tmp/test.noread + rm -f /tmp/test.noread +else + echo 't -r /tmp/test.noread' + echo 1 +fi echo 't -r run-all' t -r run-all @@ -97,11 +117,16 @@ rm -f /tmp/test.setuid echo 't -w noexist' t -w noexist -touch /tmp/test.nowrite -chmod a-w /tmp/test.nowrite -echo 't -w /tmp/test.nowrite' -t -w /tmp/test.nowrite -rm -f /tmp/test.nowrite +if (( $UID != 0 )); then + touch /tmp/test.nowrite + chmod a-w /tmp/test.nowrite + echo 't -w /tmp/test.nowrite' + t -w /tmp/test.nowrite + rm -f /tmp/test.nowrite +else + echo 't -w /tmp/test.nowrite' + echo 1 +fi echo 't -w /dev/null' t -w /dev/null @@ -163,6 +188,8 @@ echo 't 200 -eq 200' t 200 -eq 200 echo 't 34 -eq 222' t 34 -eq 222 +echo 't -32 -eq 32' +t -32 -eq 32 echo 't 200 -ne 200' t 200 -ne 200 @@ -221,8 +248,11 @@ echo 't -w /dev/fd/1' t -w /dev/fd/1 echo 't -w /dev/fd/2' t -w /dev/fd/2 + echo 't' t +echo 'b' +b echo 't 12 -eq 34' t 12 -eq 34 @@ -277,3 +307,86 @@ echo 't ( -E )' t \( -E \) echo 't ( "" )' t \( "" \) + +z=42 + +echo 't ! -z "$z"' +t ! -z "$z" + +echo 't ! -n "$z"' +t ! -n "$z" + +zero= +echo 't "$zero"' +t "$zero" +echo 't ! "$zero"' +t ! "$zero" +echo 'b "$zero"' +b "$zero" +echo 'b ! "$zero"' +b ! "$zero" + +touch /tmp/test.group +chgrp ${GROUPS[0]} /tmp/test.group +echo 't -G /tmp/test.group' +t -G /tmp/test.group +rm /tmp/test.group + +case "${THIS_SH}" in +/*) SHNAME=${THIS_SH} ;; +*) SHNAME=${PWD}/${THIS_SH} ;; +esac + +if ln -s ${SHNAME} /tmp/test.symlink 2>/dev/null; then + chgrp ${GROUPS[0]} /tmp/test.symlink + echo 't -h /tmp/test.symlink' + t -h /tmp/test.symlink + # some systems don't let you remove this + rm -f /tmp/test.symlink 2>/dev/null +else + echo 't -h /tmp/test.symlink' + echo 0 +fi + +# arithmetic constant errors +echo "t 4+3 -eq 7" +t 4+3 -eq 7 +echo "b 4-5 -eq 7" +b 4+3 -eq 7 + +echo "t 9 -eq 4+5" +t 9 -eq 4+5 +echo "b 9 -eq 4+5" +b 9 -eq 4+5 + +A=7 +echo "t A -eq 7" +t A -eq 7 +echo "b A -eq 7" +b A -eq 7 + +B=9 +echo "t 9 -eq B" +t 9 -eq B +echo "b 9 -eq B" +b 9 -eq B + +# badly formed expressions +echo 't ( 1 = 2' +t \( 1 = 2 +echo 'b ( 1 = 2' +b \( 1 = 2 + +# more errors +t a b +t a b c +t -A v +# too many arguments -- argument expected is also reasonable +t 4 -eq 4 -a 2 -ne 5 -a 4 -ne +# too many arguments +t 4 -eq 4 -a 3 4 + +[ +echo $? + +t \( \)