diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-03 00:06:55 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-03 00:06:55 +0200 |
commit | a62bc80571eae6d286aed9a92d47dc42318a8146 (patch) | |
tree | 45ce124c7a8426ebf95c07a34c3c521595e400de /shell/ash_test/ash-vars | |
parent | ce332a23a3ff45a5aeb3e737da15b469badd5d12 (diff) | |
download | busybox-a62bc80571eae6d286aed9a92d47dc42318a8146.tar.gz |
ash testsuite: add most of hust tests which pass for ash
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test/ash-vars')
22 files changed, 170 insertions, 0 deletions
diff --git a/shell/ash_test/ash-vars/empty.right b/shell/ash_test/ash-vars/empty.right new file mode 100644 index 000000000..2cb3c70f2 --- /dev/null +++ b/shell/ash_test/ash-vars/empty.right @@ -0,0 +1,3 @@ +a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F +a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F +a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F diff --git a/shell/ash_test/ash-vars/empty.tests b/shell/ash_test/ash-vars/empty.tests new file mode 100755 index 000000000..a9c247e31 --- /dev/null +++ b/shell/ash_test/ash-vars/empty.tests @@ -0,0 +1,5 @@ +e= + +echo a b c d e f 1 2 3 4 5 6 7 8 9 0 A B C D E F +echo a $e b $e c $e d $e e $e f $e 1 $e 2 $e 3 $e 4 $e 5 $e 6 $e 7 $e 8 $e 9 $e 0 $e A $e B $e C $e D $e E $e F +echo $e a $e b $e c $e d $e e $e f $e 1 $e 2 $e 3 $e 4 $e 5 $e 6 $e 7 $e 8 $e 9 $e 0 $e A $e B $e C $e D $e E $e F diff --git a/shell/ash_test/ash-vars/glob_and_vars.right b/shell/ash_test/ash-vars/glob_and_vars.right new file mode 100644 index 000000000..3ac7ec5ff --- /dev/null +++ b/shell/ash_test/ash-vars/glob_and_vars.right @@ -0,0 +1 @@ +./glob_and_vars.right ./glob_and_vars.tests diff --git a/shell/ash_test/ash-vars/glob_and_vars.tests b/shell/ash_test/ash-vars/glob_and_vars.tests new file mode 100755 index 000000000..482cf9d8a --- /dev/null +++ b/shell/ash_test/ash-vars/glob_and_vars.tests @@ -0,0 +1,2 @@ +v=. +echo $v/glob_and_vars.[tr]* diff --git a/shell/ash_test/ash-vars/param_expand_len.right b/shell/ash_test/ash-vars/param_expand_len.right new file mode 100644 index 000000000..96e8cb59b --- /dev/null +++ b/shell/ash_test/ash-vars/param_expand_len.right @@ -0,0 +1,9 @@ +0 +0 +1 +Make sure len parsing doesnt break arg count +0 0 +4 4 +Testing len op +4 3 2 1 0 0 +0 3 0 diff --git a/shell/ash_test/ash-vars/param_expand_len.tests b/shell/ash_test/ash-vars/param_expand_len.tests new file mode 100755 index 000000000..fe20a45e9 --- /dev/null +++ b/shell/ash_test/ash-vars/param_expand_len.tests @@ -0,0 +1,17 @@ +"$THIS_SH" -c 'echo $#' +"$THIS_SH" -c 'echo $#' arg0 +"$THIS_SH" -c 'echo $#' arg0 arg1 + +echo Make sure len parsing doesnt break arg count +set -- +echo $# ${#} +set -- aaaa bbb cc d +echo $# ${#} + +echo Testing len op +echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6} + +unset e +f=abc +g= +echo ${#e} ${#f} ${#g} diff --git a/shell/ash_test/ash-vars/param_glob.right b/shell/ash_test/ash-vars/param_glob.right new file mode 100644 index 000000000..bdee8fe0f --- /dev/null +++ b/shell/ash_test/ash-vars/param_glob.right @@ -0,0 +1,4 @@ +param_glob.tests +param_glob.tests +param_glob.t* +param_glob.t* diff --git a/shell/ash_test/ash-vars/param_glob.tests b/shell/ash_test/ash-vars/param_glob.tests new file mode 100755 index 000000000..4d74fee02 --- /dev/null +++ b/shell/ash_test/ash-vars/param_glob.tests @@ -0,0 +1,9 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" 'param_glob.t*' + echo NOT SHOWN + exit +fi +echo $* +echo $@ +echo "$*" +echo "$@" diff --git a/shell/ash_test/ash-vars/param_subshell.right b/shell/ash_test/ash-vars/param_subshell.right new file mode 100644 index 000000000..f3c3767de --- /dev/null +++ b/shell/ash_test/ash-vars/param_subshell.right @@ -0,0 +1,7 @@ +1=1 +2=2 +3=3 +4=4 +5=5 +6=6 +7=7 diff --git a/shell/ash_test/ash-vars/param_subshell.tests b/shell/ash_test/ash-vars/param_subshell.tests new file mode 100755 index 000000000..27fdc5b9b --- /dev/null +++ b/shell/ash_test/ash-vars/param_subshell.tests @@ -0,0 +1,15 @@ +if test $# = 0; then + "$THIS_SH" "$0" 1 2 3 4 5 6 7 8 9 + exit +fi +echo 1=$1 +{ echo 2=$2; } +{ echo 3=$3; } & +# cant use usleep as it isnt standard in $PATH -- +# we fail when testing busybox compiled solely as "hush" +wait +( echo 4=$4 ) +( echo 5=$5 ) & +wait +true | echo 6=$6 | cat +true | { echo 7=$7; } | cat diff --git a/shell/ash_test/ash-vars/star.right b/shell/ash_test/ash-vars/star.right new file mode 100644 index 000000000..0ecc55bc2 --- /dev/null +++ b/shell/ash_test/ash-vars/star.right @@ -0,0 +1,6 @@ +.1. +.abc. +.d. +.e. +.f. +.1 abc d e f. diff --git a/shell/ash_test/ash-vars/star.tests b/shell/ash_test/ash-vars/star.tests new file mode 100755 index 000000000..5554c4090 --- /dev/null +++ b/shell/ash_test/ash-vars/star.tests @@ -0,0 +1,8 @@ +if test $# = 0; then + exec "$THIS_SH" star.tests 1 abc 'd e f' +fi +# 'd e f' should be split into 3 separate args: +for a in $*; do echo ".$a."; done + +# must produce .1 abc d e f. +for a in "$*"; do echo ".$a."; done diff --git a/shell/ash_test/ash-vars/var_expand_in_assign.right b/shell/ash_test/ash-vars/var_expand_in_assign.right new file mode 100644 index 000000000..352210d7e --- /dev/null +++ b/shell/ash_test/ash-vars/var_expand_in_assign.right @@ -0,0 +1,5 @@ +. . +.abc d e. +.abc d e. +.abc d e. +.abc d e. diff --git a/shell/ash_test/ash-vars/var_expand_in_assign.tests b/shell/ash_test/ash-vars/var_expand_in_assign.tests new file mode 100755 index 000000000..18cdc74c0 --- /dev/null +++ b/shell/ash_test/ash-vars/var_expand_in_assign.tests @@ -0,0 +1,15 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" abc "d e" +fi + +space=' ' +echo .$space. + +a=$* +echo .$a. +a=$@ +echo .$a. +a="$*" +echo .$a. +a="$@" +echo .$a. diff --git a/shell/ash_test/ash-vars/var_expand_in_redir.right b/shell/ash_test/ash-vars/var_expand_in_redir.right new file mode 100644 index 000000000..423299c97 --- /dev/null +++ b/shell/ash_test/ash-vars/var_expand_in_redir.right @@ -0,0 +1,3 @@ +TEST1 +TEST2 +TEST3 diff --git a/shell/ash_test/ash-vars/var_expand_in_redir.tests b/shell/ash_test/ash-vars/var_expand_in_redir.tests new file mode 100755 index 000000000..bda6bdd7f --- /dev/null +++ b/shell/ash_test/ash-vars/var_expand_in_redir.tests @@ -0,0 +1,13 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" abc "d e" +fi + +echo TEST1 >"$1.out" +echo TEST2 >"$2.out" +# bash says: "$@.out": ambiguous redirect +# ash handles it as if it is '$*' - we do the same +echo TEST3 >"$@.out" + +cat abc.out "d e.out" "abc d e.out" + +rm abc.out "d e.out" "abc d e.out" diff --git a/shell/ash_test/ash-vars/var_expand_on_ifs.right b/shell/ash_test/ash-vars/var_expand_on_ifs.right new file mode 100644 index 000000000..2ed2069f7 --- /dev/null +++ b/shell/ash_test/ash-vars/var_expand_on_ifs.right @@ -0,0 +1,9 @@ +1 a b c +2 a + b c +3 a b c +4 a b c +5 a b c +6 a b + c +7 a b c +8 a b c +9 a b c diff --git a/shell/ash_test/ash-vars/var_expand_on_ifs.tests b/shell/ash_test/ash-vars/var_expand_on_ifs.tests new file mode 100755 index 000000000..a12ff8ec8 --- /dev/null +++ b/shell/ash_test/ash-vars/var_expand_on_ifs.tests @@ -0,0 +1,11 @@ +b=' b ' +e='' +echo 1 a $b c +echo 2 a +$b c +echo 3 a $e$b c +echo 4 a "$e"$b c +echo 5 a ""$b c +echo 6 a $b+ c +echo 7 a $b$e c +echo 8 a $b"$e" c +echo 9 a $b"" c diff --git a/shell/ash_test/ash-vars/var_in_pipes.right b/shell/ash_test/ash-vars/var_in_pipes.right new file mode 100644 index 000000000..faf65bed4 --- /dev/null +++ b/shell/ash_test/ash-vars/var_in_pipes.right @@ -0,0 +1,6 @@ +b=1 +b=2 +b=3 +b=4 +b=5 +b=6 diff --git a/shell/ash_test/ash-vars/var_in_pipes.tests b/shell/ash_test/ash-vars/var_in_pipes.tests new file mode 100755 index 000000000..3f8cd2729 --- /dev/null +++ b/shell/ash_test/ash-vars/var_in_pipes.tests @@ -0,0 +1,7 @@ +b=1 env | grep ^b= +true | b=2 env | grep ^b= +a=1 true | b=3 env | grep ^b= + +(b=4 env) | grep ^b= +(true | b=5 env) | grep ^b= +(a=1 true | b=6 env) | grep ^b= diff --git a/shell/ash_test/ash-vars/var_leaks.right b/shell/ash_test/ash-vars/var_leaks.right new file mode 100644 index 000000000..d86bac9de --- /dev/null +++ b/shell/ash_test/ash-vars/var_leaks.right @@ -0,0 +1 @@ +OK diff --git a/shell/ash_test/ash-vars/var_leaks.tests b/shell/ash_test/ash-vars/var_leaks.tests new file mode 100755 index 000000000..27c8c6504 --- /dev/null +++ b/shell/ash_test/ash-vars/var_leaks.tests @@ -0,0 +1,14 @@ +# external program +a=b /bin/true +env | grep ^a= + +# builtin +a=b true +env | grep ^a= + +# exec with redirection only +# in bash, this leaks! +a=b exec 1>&1 +env | grep ^a= + +echo OK |