diff options
author | Jari Aalto <jari.aalto@cante.net> | 2001-11-13 17:56:06 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:54 +0000 |
commit | f73dda092b33638d2d5e9c35375f687a607b5403 (patch) | |
tree | f21584e70a444d6a1ecba0fb5e2cf79e8cce91db /tests | |
parent | 28ef6c316f1aff914bb95ac09787a3c83c1815fd (diff) | |
download | android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.tar.gz android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.tar.bz2 android_external_bash-f73dda092b33638d2d5e9c35375f687a607b5403.zip |
Imported from ../bash-2.05a.tar.gz.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arith.tests | 3 | ||||
-rw-r--r-- | tests/array.right | 17 | ||||
-rw-r--r-- | tests/array.tests | 3 | ||||
-rw-r--r-- | tests/builtins.right | 6 | ||||
-rw-r--r-- | tests/errors.right | 4 | ||||
-rw-r--r-- | tests/errors.tests | 7 | ||||
-rw-r--r-- | tests/exec.right | 3 | ||||
-rw-r--r-- | tests/execscript | 5 | ||||
-rw-r--r-- | tests/posix2.tests | 6 | ||||
-rw-r--r-- | tests/printf.right | bin | 1241 -> 1262 bytes | |||
-rw-r--r-- | tests/printf.tests | 18 | ||||
-rw-r--r-- | tests/shopt.right | 8 | ||||
-rw-r--r-- | tests/trap.right | 10 | ||||
-rw-r--r-- | tests/trap.tests | 4 | ||||
-rwxr-xr-x | tests/trap2.sub | 25 | ||||
-rwxr-xr-x | tests/trap2a.sub | 3 |
16 files changed, 95 insertions, 27 deletions
diff --git a/tests/arith.tests b/tests/arith.tests index fa56ad7..ccc6e5d 100644 --- a/tests/arith.tests +++ b/tests/arith.tests @@ -136,8 +136,8 @@ echo $(( 32#A )) echo $(( 56#A )) echo $(( 64#A )) -echo $(( 64#_ )) echo $(( 64#@ )) +echo $(( 64#_ )) # weird bases echo $(( 3425#56 )) @@ -265,6 +265,7 @@ echo $x $y (( x=9 y=41 )) # These are errors +unset b echo $((a b)) ((a b)) diff --git a/tests/array.right b/tests/array.right index 80027b2..b337656 100644 --- a/tests/array.right +++ b/tests/array.right @@ -27,7 +27,6 @@ declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")' declare -ar c='()' readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")' readonly -a c='()' -./array.tests: declare: e: cannot assign to array variables in this way a test declare -a DIRSTACK='()' declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression")' @@ -111,14 +110,14 @@ for case if then else 12 14 16 18 20 4414758999202 aaa bbb -./array.tests: array assign: line 262: syntax error near unexpected token `for' -./array.tests: array assign: line 262: `a b c for case if then else' -./array.tests: array assign: line 264: syntax error near unexpected token `for' -./array.tests: array assign: line 264: `for case if then else' -./array.tests: array assign: line 266: syntax error near unexpected token `<>' -./array.tests: array assign: line 266: ` <> < > ! ' -./array.tests: array assign: line 267: syntax error near unexpected token `[1]=<>' -./array.tests: array assign: line 267: ` [1]=<> [2]=< [3]=> [4]=! ' +./array.tests: array assign: line 263: syntax error near unexpected token `for' +./array.tests: array assign: line 263: `a b c for case if then else' +./array.tests: array assign: line 265: syntax error near unexpected token `for' +./array.tests: array assign: line 265: `for case if then else' +./array.tests: array assign: line 267: syntax error near unexpected token `<>' +./array.tests: array assign: line 267: ` <> < > ! ' +./array.tests: array assign: line 268: syntax error near unexpected token `[1]=<>' +./array.tests: array assign: line 268: ` [1]=<> [2]=< [3]=> [4]=! ' abc 3 0 abc 1 diff --git a/tests/array.tests b/tests/array.tests index d8b6564..85dae0d 100644 --- a/tests/array.tests +++ b/tests/array.tests @@ -21,6 +21,7 @@ unset a a=abcde a[2]=bdef +unset b declare -a b[256] unset c[2] @@ -78,7 +79,7 @@ set +o posix declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")' d[9]="ninth element" -declare -a e[10]=test +declare -a e[10]=test # this works in post-bash-2.05 versions declare -a e[10]='(test)' pass=/etc/passwd diff --git a/tests/builtins.right b/tests/builtins.right index 03a509c..0cb71f9 100644 --- a/tests/builtins.right +++ b/tests/builtins.right @@ -45,11 +45,11 @@ $BVAR foo bar xxx -022 +0022 u=rwx,g=rx,o=rx -002 +0002 u=rwx,g=rwx,o=rx -umask 002 +umask 0002 umask -S u=rwx,g=rwx,o=rx u=rwx,g=rwx,o=rwx enable . diff --git a/tests/errors.right b/tests/errors.right index 039b2bf..8c5a724 100644 --- a/tests/errors.right +++ b/tests/errors.right @@ -31,14 +31,13 @@ exec: usage: exec [-cl] [-a name] file [redirection ...] ./errors.tests: logout: not login shell: use `exit' ./errors.tests: hash: notthere: not found ./errors.tests: hash: illegal option: -v -hash: usage: hash [-r] [-p pathname] [name ...] +hash: usage: hash [-r] [-p pathname] [-t] [name ...] ./errors.tests: hash: hashing disabled ./errors.tests: export: `AA[4]': not a valid identifier ./errors.tests: readonly: `AA[4]': not a valid identifier ./errors.tests: [-2]: bad array subscript ./errors.tests: AA: readonly variable ./errors.tests: AA: readonly variable -./errors.tests: readonly: ZZZ: cannot assign to array variables in this way ./errors.tests: shift: shift count must be <= $# ./errors.tests: shift: shift count must be >= 0 ./errors.tests: shopt: no_such_option: unknown shell option name @@ -86,7 +85,6 @@ command: usage: command [-pVv] command [arg ...] ./errors.tests: trap: NOSIG: not a signal specification ./errors.tests: trap: illegal option: -s trap: usage: trap [arg] [signal_spec ...] or trap -l -./errors.tests: trap: ERR: not a signal specification ./errors.tests: return: can only `return' from a function or sourced script ./errors.tests: break: loop count must be > 0 ./errors.tests: continue: loop count must be > 0 diff --git a/tests/errors.tests b/tests/errors.tests index 9311a5d..4ead467 100644 --- a/tests/errors.tests +++ b/tests/errors.tests @@ -121,7 +121,8 @@ readonly -n AA AA=(one two three) # try to assign a readonly array with bad assignment syntax -readonly -a ZZZ=bbb +# NOTE: this works in post-bash-2.05 (at least when I write this) +# readonly -a ZZZ=bbb # bad counts to `shift' shopt -s shift_verbose @@ -217,8 +218,8 @@ trap -p NOSIG # maybe someday trap will take a -s argument like kill, but not now trap -p -s NOSIG -# maybe someday we will have a ksh-like ERR trap, but not yet -trap 'echo [$LINENO] -- error' ERR +# we have a ksh-like ERR trap, post-bash-2.05 +#trap 'echo [$LINENO] -- error' ERR # can only return from a function or sourced script return 2 diff --git a/tests/exec.right b/tests/exec.right index 556f1a1..98fe41e 100644 --- a/tests/exec.right +++ b/tests/exec.right @@ -17,8 +17,7 @@ notthere: notthere: No such file or directory ./execscript: .: /: is a directory 1 127 -./execscript: .: /dev/null: not a regular file -1 +0 this is bashenv ./exec3.sub: /tmp/bash-notthere: No such file or directory ./exec3.sub: exec: /tmp/bash-notthere: cannot execute: No such file or directory diff --git a/tests/execscript b/tests/execscript index 749b733..7eab4af 100644 --- a/tests/execscript +++ b/tests/execscript @@ -1,6 +1,10 @@ export LC_ALL=C export LANG=C +if (( $UID == 0 )); then + echo "execscript: the test suite should not be run as root" >&2 +fi + set -- one two three echo before exec1.sub: "$@" echo calling exec1.sub @@ -40,6 +44,7 @@ echo $? . ${THIS_SH} 2>/dev/null echo $? +# post-bash-2.05 versions allow sourcing non-regular files . /dev/null echo $? diff --git a/tests/posix2.tests b/tests/posix2.tests index 2161379..a186e78 100644 --- a/tests/posix2.tests +++ b/tests/posix2.tests @@ -146,14 +146,14 @@ fi newtest SQUOTE="'" val1=$(set | sed -n 's:^SQUOTE=::p') -if [ "$val1" != "\$'\\''" ]; then +if [ "$val1" != "''\\'''" ]; then testfail "variable quoting 1" fi newtest VTILDE='~' val1=$(set | sed -n 's:^VTILDE=::p') -if [ "$val1" != "\$'~'" ]; then +if [ "$val1" != "'~'" ]; then testfail "variable quoting 2" fi @@ -167,7 +167,7 @@ fi newtest VHASH2=#abcd val1=$(set | sed -n 's:^VHASH2=::p') -if [ "$val1" != "\$'#abcd'" ]; then +if [ "$val1" != "'#abcd'" ]; then testfail "variable quoting 4" fi diff --git a/tests/printf.right b/tests/printf.right Binary files differindex 53b79b0..80d1a7e 100644 --- a/tests/printf.right +++ b/tests/printf.right diff --git a/tests/printf.tests b/tests/printf.tests index 5654ea4..5f6d8aa 100644 --- a/tests/printf.tests +++ b/tests/printf.tests @@ -61,11 +61,11 @@ printf -- "--%b--\n" '\t\101' # these should all display `A7' echo -e "\1017" -echo -e "\x0417" +echo -e "\x417" printf "%b\n" '\01017' printf "%b\n" '\1017' -printf "%b\n" '\x0417' +printf "%b\n" '\x417' printf -- "--%b--\n" '\"abcd\"' printf -- "--%b--\n" "\'abcd\'" @@ -206,5 +206,19 @@ printf "ab%Mcd\n" # this caused an infinite loop in older versions of printf printf "%y" 0 +# these should print a warning and `0', according to POSIX.2 printf "%d\n" GNU printf "%o\n" GNU + +# failures in all bash versions through bash-2.05 +printf "%.0s" foo +printf "%.*s" 0 foo + +printf '%.0b-%.0s\n' foo bar +printf '(%*b)(%*s)\n' -4 foo -4 bar + +format='%'`printf '%0100384d' 0`'d\n' +printf $format 0 + +# this doesn't work with printf(3) on all systems +#printf "%'s\n" foo diff --git a/tests/shopt.right b/tests/shopt.right index 32c422a..0f073e1 100644 --- a/tests/shopt.right +++ b/tests/shopt.right @@ -17,6 +17,7 @@ shopt -s hostcomplete shopt -u huponexit shopt -s interactive_comments shopt -u lithist +shopt -u login_shell shopt -u mailwarn shopt -u no_empty_cmd_completion shopt -u nocaseglob @@ -52,6 +53,7 @@ shopt -u histappend shopt -u histverify shopt -u huponexit shopt -u lithist +shopt -u login_shell shopt -u mailwarn shopt -u no_empty_cmd_completion shopt -u nocaseglob @@ -71,6 +73,7 @@ histappend off histverify off huponexit off lithist off +login_shell off mailwarn off no_empty_cmd_completion off nocaseglob off @@ -99,6 +102,7 @@ set +o xtrace set -o history set +o ignoreeof set -o interactive-comments +set +o nolog set +o posix set -o emacs set +o vi @@ -123,6 +127,7 @@ xtrace off history on ignoreeof off interactive-comments on +nolog off posix off emacs on vi off @@ -147,6 +152,7 @@ set +o xtrace set -o history set +o ignoreeof set -o interactive-comments +set +o nolog set +o posix set -o emacs set +o vi @@ -176,6 +182,7 @@ set +o physical set +o verbose set +o xtrace set +o ignoreeof +set +o nolog set +o posix set +o vi -- @@ -192,6 +199,7 @@ physical off verbose off xtrace off ignoreeof off +nolog off posix off vi off -- diff --git a/tests/trap.right b/tests/trap.right index f7b89a5..370d9b7 100644 --- a/tests/trap.right +++ b/tests/trap.right @@ -45,6 +45,16 @@ trap -- 'echo aborting' SIGQUIT trap -- 'echo aborting' SIGABRT trap -- 'echo aborting' SIGTERM 0 +ERRTRAP +ERRTRAP +ERRTRAP +after falses +if negation ok +after negation +after while +before false in trap2a.sub +after false in trap2a.sub +command substitution caught a child death caught a child death caught a child death diff --git a/tests/trap.tests b/tests/trap.tests index 24f25ab..f34e825 100644 --- a/tests/trap.tests +++ b/tests/trap.tests @@ -53,6 +53,9 @@ echo $? trap '' USR2 ./trap1.sub +# test ERR trap +./trap2.sub + # # show that setting a trap on SIGCHLD is not disastrous. # @@ -71,3 +74,4 @@ trap -p SIGCHLD trap SIGINT QUIT TERM trap + diff --git a/tests/trap2.sub b/tests/trap2.sub new file mode 100755 index 0000000..73357df --- /dev/null +++ b/tests/trap2.sub @@ -0,0 +1,25 @@ +set +e +trap 'echo ERRTRAP' ERR + +false +false +false + +echo after falses + +if ! false; then + echo if negation ok +fi + +! false +echo after negation + +while false; do + echo while negation ok +done + +echo after while + +./trap2a.sub + +echo $(false ; echo command substitution) diff --git a/tests/trap2a.sub b/tests/trap2a.sub new file mode 100755 index 0000000..44d6b50 --- /dev/null +++ b/tests/trap2a.sub @@ -0,0 +1,3 @@ +echo before false in trap2a.sub +false +echo after false in trap2a.sub |