diff options
author | Bjørn Mork <bjorn@mork.no> | 2015-05-15 10:20:47 +0200 |
---|---|---|
committer | Bjørn Mork <bjorn@mork.no> | 2015-05-15 10:20:47 +0200 |
commit | 73b16af8feec390afbabd9356d6e5e83c0390838 (patch) | |
tree | 3730020ba2f9caeb9d7815a975af51830b51ce11 /shell/hush_test |
busybox: imported from http://www.busybox.net/downloads/busybox-1.13.3.tar.bz2busybox-1.13.3
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Diffstat (limited to 'shell/hush_test')
115 files changed, 1007 insertions, 0 deletions
diff --git a/shell/hush_test/hush-glob/glob1.right b/shell/hush_test/hush-glob/glob1.right new file mode 100644 index 0000000..f29ab4e --- /dev/null +++ b/shell/hush_test/hush-glob/glob1.right @@ -0,0 +1,2 @@ +glob1.tests +glob1.tests diff --git a/shell/hush_test/hush-glob/glob1.tests b/shell/hush_test/hush-glob/glob1.tests new file mode 100755 index 0000000..f980ce0 --- /dev/null +++ b/shell/hush_test/hush-glob/glob1.tests @@ -0,0 +1,2 @@ +echo *glob1?t[e]sts* +echo "glob1"?'t'[e]s* diff --git a/shell/hush_test/hush-glob/glob_and_assign.right b/shell/hush_test/hush-glob/glob_and_assign.right new file mode 100644 index 0000000..d46e443 --- /dev/null +++ b/shell/hush_test/hush-glob/glob_and_assign.right @@ -0,0 +1,6 @@ +ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp +ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp +*.tmp +ZVAR=z.tmp z.tmp +ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp +ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp diff --git a/shell/hush_test/hush-glob/glob_and_assign.tests b/shell/hush_test/hush-glob/glob_and_assign.tests new file mode 100755 index 0000000..0b158f2 --- /dev/null +++ b/shell/hush_test/hush-glob/glob_and_assign.tests @@ -0,0 +1,10 @@ +>ZVAR=z.tmp +>z.tmp +ZVAR=*.tmp echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp" +ZVAR=*.tmp /bin/echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp" +ZVAR=*.tmp +echo "$ZVAR" +echo $ZVAR +echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp" +/bin/echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp" +rm ZVAR=z.tmp z.tmp diff --git a/shell/hush_test/hush-glob/glob_redir.right b/shell/hush_test/hush-glob/glob_redir.right new file mode 100644 index 0000000..fbd0309 --- /dev/null +++ b/shell/hush_test/hush-glob/glob_redir.right @@ -0,0 +1,2 @@ +z.tmp: +?.tmp: TEST diff --git a/shell/hush_test/hush-glob/glob_redir.tests b/shell/hush_test/hush-glob/glob_redir.tests new file mode 100755 index 0000000..621d120 --- /dev/null +++ b/shell/hush_test/hush-glob/glob_redir.tests @@ -0,0 +1,9 @@ +# Redirections are not globbed. +# bash: +# if run as "sh", they are not globbed, but +# if run as "bash", they are! +>z.tmp +echo TEST >?.tmp +echo 'z.tmp:' `cat 'z.tmp'` +echo '?.tmp:' `cat '?.tmp'` +rm 'z.tmp' '?.tmp' diff --git a/shell/hush_test/hush-misc/assignment1.right b/shell/hush_test/hush-misc/assignment1.right new file mode 100644 index 0000000..d0a13d3 --- /dev/null +++ b/shell/hush_test/hush-misc/assignment1.right @@ -0,0 +1,9 @@ +if1:0 +while1:0 +until1:0 +if2:0 +while2:0 +until2:0 +if3:0 +while3:0 +until3:0 diff --git a/shell/hush_test/hush-misc/assignment1.tests b/shell/hush_test/hush-misc/assignment1.tests new file mode 100755 index 0000000..033b352 --- /dev/null +++ b/shell/hush_test/hush-misc/assignment1.tests @@ -0,0 +1,42 @@ +# Assignments after some keywords should still work + +if a=1 true; then a=1 true; elif a=1 true; then a=1 true; else a=1 true; fi +echo if1:$? +while a=1 true; do a=1 true; break; done +echo while1:$? +until a=1 false; do a=1 true; break; done +echo until1:$? + +if a=1 true + then a=1 true + elif a=1 true + then a=1 true + else a=1 true + fi +echo if2:$? +while a=1 true + do a=1 true + break + done +echo while2:$? +until a=1 false + do a=1 true + break + done +echo until2:$? + +if + a=1 true; then + a=1 true; elif + a=1 true; then + a=1 true; else + a=1 true; fi +echo if3:$? +while + a=1 true; do + a=1 true; break; done +echo while3:$? +until + a=1 false; do + a=1 true; break; done +echo until3:$? diff --git a/shell/hush_test/hush-misc/assignment2.rigth b/shell/hush_test/hush-misc/assignment2.rigth new file mode 100644 index 0000000..591552c --- /dev/null +++ b/shell/hush_test/hush-misc/assignment2.rigth @@ -0,0 +1,2 @@ +hush: can't exec 'a=b': No such file or directory +1 diff --git a/shell/hush_test/hush-misc/assignment2.tests b/shell/hush_test/hush-misc/assignment2.tests new file mode 100755 index 0000000..540e01e --- /dev/null +++ b/shell/hush_test/hush-misc/assignment2.tests @@ -0,0 +1,4 @@ +# This must not be interpreted as an assignment +a''=b true +echo $? +# (buglet: $? should be 127. it is currently 1) diff --git a/shell/hush_test/hush-misc/break1.right b/shell/hush_test/hush-misc/break1.right new file mode 100644 index 0000000..04a4b17 --- /dev/null +++ b/shell/hush_test/hush-misc/break1.right @@ -0,0 +1,2 @@ +A +OK:0 diff --git a/shell/hush_test/hush-misc/break1.tests b/shell/hush_test/hush-misc/break1.tests new file mode 100755 index 0000000..912f149 --- /dev/null +++ b/shell/hush_test/hush-misc/break1.tests @@ -0,0 +1,3 @@ +while true; do echo A; break; echo B; done +echo OK:$? + diff --git a/shell/hush_test/hush-misc/break2.right b/shell/hush_test/hush-misc/break2.right new file mode 100644 index 0000000..8a15cb9 --- /dev/null +++ b/shell/hush_test/hush-misc/break2.right @@ -0,0 +1,3 @@ +A +AA +OK:0 diff --git a/shell/hush_test/hush-misc/break2.tests b/shell/hush_test/hush-misc/break2.tests new file mode 100755 index 0000000..7da9faf --- /dev/null +++ b/shell/hush_test/hush-misc/break2.tests @@ -0,0 +1,6 @@ +while true; do + echo A + while true; do echo AA; break 2; echo BB; done + echo B +done +echo OK:$? diff --git a/shell/hush_test/hush-misc/break3.right b/shell/hush_test/hush-misc/break3.right new file mode 100644 index 0000000..04a4b17 --- /dev/null +++ b/shell/hush_test/hush-misc/break3.right @@ -0,0 +1,2 @@ +A +OK:0 diff --git a/shell/hush_test/hush-misc/break3.tests b/shell/hush_test/hush-misc/break3.tests new file mode 100755 index 0000000..d138dca --- /dev/null +++ b/shell/hush_test/hush-misc/break3.tests @@ -0,0 +1,2 @@ +v=break; while true; do echo A; $v; echo B; break; echo C; done +echo OK:$? diff --git a/shell/hush_test/hush-misc/break4.right b/shell/hush_test/hush-misc/break4.right new file mode 100644 index 0000000..6f41c14 --- /dev/null +++ b/shell/hush_test/hush-misc/break4.right @@ -0,0 +1,6 @@ +A +AA +TRUE +A +AA +OK:0 diff --git a/shell/hush_test/hush-misc/break4.tests b/shell/hush_test/hush-misc/break4.tests new file mode 100755 index 0000000..67da288 --- /dev/null +++ b/shell/hush_test/hush-misc/break4.tests @@ -0,0 +1,12 @@ +cond=true +while $cond; do + echo A + if test "$cond" = true; then + cond='echo TRUE' + else + cond=false + fi + while true; do echo AA; continue 2; echo BB; done + echo B +done +echo OK:$? diff --git a/shell/hush_test/hush-misc/break5.right b/shell/hush_test/hush-misc/break5.right new file mode 100644 index 0000000..0b9df2a --- /dev/null +++ b/shell/hush_test/hush-misc/break5.right @@ -0,0 +1,13 @@ +A +B +0 +A:a +B +D +A:b +B +D +A:c +B +D +0 diff --git a/shell/hush_test/hush-misc/break5.tests b/shell/hush_test/hush-misc/break5.tests new file mode 100755 index 0000000..273e040 --- /dev/null +++ b/shell/hush_test/hush-misc/break5.tests @@ -0,0 +1,4 @@ +while true; do echo A; { echo B; break; echo C; }; echo D; done +echo $? +for v in a b c; do echo A:$v; (echo B; break; echo C); echo D; done +echo $? diff --git a/shell/hush_test/hush-misc/builtin1.right b/shell/hush_test/hush-misc/builtin1.right new file mode 100644 index 0000000..2e55ecb --- /dev/null +++ b/shell/hush_test/hush-misc/builtin1.right @@ -0,0 +1,2 @@ +VARIABLE=export +OK:0 diff --git a/shell/hush_test/hush-misc/builtin1.tests b/shell/hush_test/hush-misc/builtin1.tests new file mode 100755 index 0000000..1a2941f --- /dev/null +++ b/shell/hush_test/hush-misc/builtin1.tests @@ -0,0 +1,6 @@ +# builtins, unlike keywords like "while", can be constructed +# with substitutions +VARIABLE=export +$VARIABLE VARIABLE +env | grep ^VARIABLE +echo OK:$? diff --git a/shell/hush_test/hush-misc/case1.right b/shell/hush_test/hush-misc/case1.right new file mode 100644 index 0000000..e9e371a --- /dev/null +++ b/shell/hush_test/hush-misc/case1.right @@ -0,0 +1,14 @@ +OK_1 +OK_1 +OK_21 +OK_22 +OK_23 +OK_31 +OK_32 +OK_41 +OK_42 +OK_43 +OK_44 +OK_51 +OK_52 +OK_53 diff --git a/shell/hush_test/hush-misc/case1.tests b/shell/hush_test/hush-misc/case1.tests new file mode 100755 index 0000000..0174893 --- /dev/null +++ b/shell/hush_test/hush-misc/case1.tests @@ -0,0 +1,25 @@ +case w in a) echo SKIP;; w) echo OK_1;; w) echo WRONG;; esac + +case w in + a) echo SKIP;; + w)echo OK_1 ;; + w) + echo WRONG + ;; +esac + +t=w +case $t in a) echo SKIP;; w) echo OK_21;; w) echo WRONG;; esac; +case "$t" in a) echo SKIP;; w) echo OK_22;; w) echo WRONG;; esac; +case w in a) echo SKIP;; $t) echo OK_23;; "$t") echo WRONG;; esac; + +case '' in a) echo SKIP;; w) echo WRONG;; *) echo OK_31;; esac; +case '' in a) echo SKIP;; '') echo OK_32;; *) echo WRONG;; esac; + +case `echo w` in a) echo SKIP;; w) echo OK_41;; w) echo WRONG;; esac; +case "`echo w`" in a) echo SKIP;; w) echo OK_42;; w) echo WRONG;; esac; +case `echo w w` in a) echo SKIP;; w) echo WRONG;; 'w w') echo OK_43;; esac; +case `echo w w` in a) echo SKIP;; w) echo WRONG;; w*) echo OK_44;; esac; + +case w in `echo w`) echo OK_51;; `echo WRONG >&2`w) echo WRONG;; esac; +case w in `echo OK_52 >&2`) echo SKIP;; `echo`w) echo OK_53;; esac; diff --git a/shell/hush_test/hush-misc/colon.right b/shell/hush_test/hush-misc/colon.right new file mode 100644 index 0000000..2a87d02 --- /dev/null +++ b/shell/hush_test/hush-misc/colon.right @@ -0,0 +1,2 @@ +0 +OK: 0 diff --git a/shell/hush_test/hush-misc/colon.tests b/shell/hush_test/hush-misc/colon.tests new file mode 100755 index 0000000..cb8ab53 --- /dev/null +++ b/shell/hush_test/hush-misc/colon.tests @@ -0,0 +1,5 @@ +false +: +echo $? +(while :; do exit; done) +echo OK: $? diff --git a/shell/hush_test/hush-misc/continue1.right b/shell/hush_test/hush-misc/continue1.right new file mode 100644 index 0000000..c4a5565 --- /dev/null +++ b/shell/hush_test/hush-misc/continue1.right @@ -0,0 +1,8 @@ +A:a +A:b +A:c +OK1 +A:a +A:b +A:c +OK2 diff --git a/shell/hush_test/hush-misc/continue1.tests b/shell/hush_test/hush-misc/continue1.tests new file mode 100755 index 0000000..72d3566 --- /dev/null +++ b/shell/hush_test/hush-misc/continue1.tests @@ -0,0 +1,4 @@ +for v in a b c; do echo A:$v; continue 666; done +echo OK1 +for v in a b c; do echo A:$v; continue 666; done +echo OK2 diff --git a/shell/hush_test/hush-misc/empty_for.right b/shell/hush_test/hush-misc/empty_for.right new file mode 100644 index 0000000..290d39b --- /dev/null +++ b/shell/hush_test/hush-misc/empty_for.right @@ -0,0 +1 @@ +OK: 0 diff --git a/shell/hush_test/hush-misc/empty_for.tests b/shell/hush_test/hush-misc/empty_for.tests new file mode 100755 index 0000000..0cb52e8 --- /dev/null +++ b/shell/hush_test/hush-misc/empty_for.tests @@ -0,0 +1,3 @@ +false +for a in; do echo "HELLO"; done +echo OK: $? diff --git a/shell/hush_test/hush-misc/empty_for2.right b/shell/hush_test/hush-misc/empty_for2.right new file mode 100644 index 0000000..1acee9e --- /dev/null +++ b/shell/hush_test/hush-misc/empty_for2.right @@ -0,0 +1,4 @@ +PARAM:abc +PARAM:d e +PARAM:123 +OK: 0 diff --git a/shell/hush_test/hush-misc/empty_for2.tests b/shell/hush_test/hush-misc/empty_for2.tests new file mode 100755 index 0000000..2b12ec2 --- /dev/null +++ b/shell/hush_test/hush-misc/empty_for2.tests @@ -0,0 +1,6 @@ +if test $# = 0; then + exec "$THIS_SH" $0 abc "d e" 123 +fi +false +for v; do echo "PARAM:$v"; done +echo OK: $? diff --git a/shell/hush_test/hush-misc/for_with_keywords.right b/shell/hush_test/hush-misc/for_with_keywords.right new file mode 100644 index 0000000..eb04e9a --- /dev/null +++ b/shell/hush_test/hush-misc/for_with_keywords.right @@ -0,0 +1,4 @@ +do +done +then +OK: 0 diff --git a/shell/hush_test/hush-misc/for_with_keywords.tests b/shell/hush_test/hush-misc/for_with_keywords.tests new file mode 100755 index 0000000..a8b8e42 --- /dev/null +++ b/shell/hush_test/hush-misc/for_with_keywords.tests @@ -0,0 +1,2 @@ +for if in do done then; do echo $if; done +echo OK: $? diff --git a/shell/hush_test/hush-misc/pid.right b/shell/hush_test/hush-misc/pid.right new file mode 100644 index 0000000..573541a --- /dev/null +++ b/shell/hush_test/hush-misc/pid.right @@ -0,0 +1 @@ +0 diff --git a/shell/hush_test/hush-misc/pid.tests b/shell/hush_test/hush-misc/pid.tests new file mode 100755 index 0000000..eaeaa71 --- /dev/null +++ b/shell/hush_test/hush-misc/pid.tests @@ -0,0 +1 @@ +test `(echo $$)` = `echo $$`; echo $? diff --git a/shell/hush_test/hush-misc/read.right b/shell/hush_test/hush-misc/read.right new file mode 100644 index 0000000..0e50e2a --- /dev/null +++ b/shell/hush_test/hush-misc/read.right @@ -0,0 +1,4 @@ +read +cat +echo "REPLY=$REPLY" +REPLY=exec <read.tests diff --git a/shell/hush_test/hush-misc/read.tests b/shell/hush_test/hush-misc/read.tests new file mode 100755 index 0000000..ff1acbd --- /dev/null +++ b/shell/hush_test/hush-misc/read.tests @@ -0,0 +1,4 @@ +exec <read.tests +read +cat +echo "REPLY=$REPLY" diff --git a/shell/hush_test/hush-misc/shift.right b/shell/hush_test/hush-misc/shift.right new file mode 100644 index 0000000..d281e35 --- /dev/null +++ b/shell/hush_test/hush-misc/shift.right @@ -0,0 +1,6 @@ +./shift.tests abc d e +./shift.tests d e 123 +./shift.tests d e 123 +./shift.tests +./shift.tests +./shift.tests diff --git a/shell/hush_test/hush-misc/shift.tests b/shell/hush_test/hush-misc/shift.tests new file mode 100755 index 0000000..53ef249 --- /dev/null +++ b/shell/hush_test/hush-misc/shift.tests @@ -0,0 +1,14 @@ +if test $# = 0; then + exec "$THIS_SH" $0 abc "d e" 123 +fi +echo $0 $1 $2 +shift +echo $0 $1 $2 +shift 999 +echo $0 $1 $2 +shift 2 +echo $0 $1 $2 +shift 2 +echo $0 $1 $2 +shift +echo $0 $1 $2 diff --git a/shell/hush_test/hush-misc/syntax_err.right b/shell/hush_test/hush-misc/syntax_err.right new file mode 100644 index 0000000..08a270c --- /dev/null +++ b/shell/hush_test/hush-misc/syntax_err.right @@ -0,0 +1,2 @@ +shown +hush: syntax error: unterminated ' diff --git a/shell/hush_test/hush-misc/syntax_err.tests b/shell/hush_test/hush-misc/syntax_err.tests new file mode 100755 index 0000000..d10ed42 --- /dev/null +++ b/shell/hush_test/hush-misc/syntax_err.tests @@ -0,0 +1,3 @@ +echo shown +echo test `echo 'aa` +echo not shown diff --git a/shell/hush_test/hush-misc/syntax_err_negate.right b/shell/hush_test/hush-misc/syntax_err_negate.right new file mode 100644 index 0000000..d1e7654 --- /dev/null +++ b/shell/hush_test/hush-misc/syntax_err_negate.right @@ -0,0 +1,2 @@ +bash 3.2 fails this +hush: syntax error diff --git a/shell/hush_test/hush-misc/syntax_err_negate.tests b/shell/hush_test/hush-misc/syntax_err_negate.tests new file mode 100755 index 0000000..d61b1b0 --- /dev/null +++ b/shell/hush_test/hush-misc/syntax_err_negate.tests @@ -0,0 +1,2 @@ +echo bash 3.2 fails this +! ! true diff --git a/shell/hush_test/hush-misc/while1.right b/shell/hush_test/hush-misc/while1.right new file mode 100644 index 0000000..7c4d7be --- /dev/null +++ b/shell/hush_test/hush-misc/while1.right @@ -0,0 +1 @@ +OK:0 diff --git a/shell/hush_test/hush-misc/while1.tests b/shell/hush_test/hush-misc/while1.tests new file mode 100755 index 0000000..11e201e --- /dev/null +++ b/shell/hush_test/hush-misc/while1.tests @@ -0,0 +1,2 @@ +while false; do echo NOT SHOWN; done +echo OK:$? diff --git a/shell/hush_test/hush-misc/while_in_subshell.right b/shell/hush_test/hush-misc/while_in_subshell.right new file mode 100644 index 0000000..290d39b --- /dev/null +++ b/shell/hush_test/hush-misc/while_in_subshell.right @@ -0,0 +1 @@ +OK: 0 diff --git a/shell/hush_test/hush-misc/while_in_subshell.tests b/shell/hush_test/hush-misc/while_in_subshell.tests new file mode 100755 index 0000000..def8e09 --- /dev/null +++ b/shell/hush_test/hush-misc/while_in_subshell.tests @@ -0,0 +1,2 @@ +(while true; do exit; done) +echo OK: $? diff --git a/shell/hush_test/hush-parsing/argv0.right b/shell/hush_test/hush-parsing/argv0.right new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/shell/hush_test/hush-parsing/argv0.right @@ -0,0 +1 @@ +OK diff --git a/shell/hush_test/hush-parsing/argv0.tests b/shell/hush_test/hush-parsing/argv0.tests new file mode 100755 index 0000000..f5c40f6 --- /dev/null +++ b/shell/hush_test/hush-parsing/argv0.tests @@ -0,0 +1,4 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" arg +fi +echo OK diff --git a/shell/hush_test/hush-parsing/escape1.right b/shell/hush_test/hush-parsing/escape1.right new file mode 100644 index 0000000..1899b87 --- /dev/null +++ b/shell/hush_test/hush-parsing/escape1.right @@ -0,0 +1,4 @@ +\ +a\b +\\ +c\\d diff --git a/shell/hush_test/hush-parsing/escape1.tests b/shell/hush_test/hush-parsing/escape1.tests new file mode 100755 index 0000000..67cfd1f --- /dev/null +++ b/shell/hush_test/hush-parsing/escape1.tests @@ -0,0 +1,4 @@ +echo "\\" +echo a"\\"b +echo '\\' +echo c'\\'d diff --git a/shell/hush_test/hush-parsing/escape2.right b/shell/hush_test/hush-parsing/escape2.right new file mode 100644 index 0000000..f55fd4a --- /dev/null +++ b/shell/hush_test/hush-parsing/escape2.right @@ -0,0 +1,4 @@ +*?[a]* +a*?[a]*b +*?[a]* +c*?[a]*d diff --git a/shell/hush_test/hush-parsing/escape2.tests b/shell/hush_test/hush-parsing/escape2.tests new file mode 100755 index 0000000..ee71801 --- /dev/null +++ b/shell/hush_test/hush-parsing/escape2.tests @@ -0,0 +1,4 @@ +echo "*?[a]*" +echo a"*?[a]*"b +echo '*?[a]*' +echo c'*?[a]*'d diff --git a/shell/hush_test/hush-parsing/escape3.right b/shell/hush_test/hush-parsing/escape3.right new file mode 100644 index 0000000..da02a97 --- /dev/null +++ b/shell/hush_test/hush-parsing/escape3.right @@ -0,0 +1,23 @@ +v: a \ b \\ c \\\ d \\\\ e +v: a \ b \\ c \\\ d \\\\ e +Unquoted: +.a. +.\. +.b. +.\\. +.c. +.\\\. +.d. +.\\\\. +.e. +Quoted: +.a. +.\. +.b. +.\\. +.c. +.\\\. +.d. +.\\\\. +.e. +done diff --git a/shell/hush_test/hush-parsing/escape3.tests b/shell/hush_test/hush-parsing/escape3.tests new file mode 100755 index 0000000..111ed40 --- /dev/null +++ b/shell/hush_test/hush-parsing/escape3.tests @@ -0,0 +1,8 @@ +v='a \ b \\ c \\\ d \\\\ e' +echo v: $v +echo v: "$v" +echo Unquoted: +for a in $v; do echo .$a.; done +echo Quoted: +for a in $v; do echo ".$a."; done +echo done diff --git a/shell/hush_test/hush-parsing/negate.right b/shell/hush_test/hush-parsing/negate.right new file mode 100644 index 0000000..0116601 --- /dev/null +++ b/shell/hush_test/hush-parsing/negate.right @@ -0,0 +1,35 @@ +! printing ! +0 +1 +1 +0 +0 +0 +! +a +b +c +! 1 +a 1 +b 1 +c 1 +! 1 +a 1 +b 1 +c 1 +0 +0 +0 +0 +1 +1 +1 +1 +0 +0 +0 +0 +1 +1 +1 +1 diff --git a/shell/hush_test/hush-parsing/negate.tests b/shell/hush_test/hush-parsing/negate.tests new file mode 100755 index 0000000..72e731f --- /dev/null +++ b/shell/hush_test/hush-parsing/negate.tests @@ -0,0 +1,16 @@ +echo ! printing ! +! false +echo $? +! true +echo $? +if ! false; then false; echo $?; fi +echo $? +if ! false; then ! false; echo $?; fi +echo $? +for a in ! a b c; do echo $a; done +for a in ! a b c; do ! echo -n "$a "; echo $?; done +for a in ! a b c; do ! /bin/echo -n "$a "; echo $?; done +for a in ! a b c; do ! echo -n "$a " | false; echo $?; done +for a in ! a b c; do ! echo -n "$a " | true; echo $?; done +for a in ! a b c; do ! { echo -n "$a " | false; }; echo $?; done +for a in ! a b c; do ! { echo -n "$a " | true; }; echo $?; done diff --git a/shell/hush_test/hush-parsing/noeol.right b/shell/hush_test/hush-parsing/noeol.right new file mode 100644 index 0000000..e427984 --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol.right @@ -0,0 +1 @@ +HELLO diff --git a/shell/hush_test/hush-parsing/noeol.tests b/shell/hush_test/hush-parsing/noeol.tests new file mode 100755 index 0000000..a93113a --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol.tests @@ -0,0 +1,2 @@ +# next line has no EOL! +echo HELLO
\ No newline at end of file diff --git a/shell/hush_test/hush-parsing/noeol2.right b/shell/hush_test/hush-parsing/noeol2.right new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol2.right @@ -0,0 +1 @@ +1 diff --git a/shell/hush_test/hush-parsing/noeol2.tests b/shell/hush_test/hush-parsing/noeol2.tests new file mode 100755 index 0000000..1220f05 --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol2.tests @@ -0,0 +1,7 @@ +# last line has no EOL! +if true +then + echo 1 +else + echo 2 +fi
\ No newline at end of file diff --git a/shell/hush_test/hush-parsing/noeol3.right b/shell/hush_test/hush-parsing/noeol3.right new file mode 100644 index 0000000..56f8515 --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol3.right @@ -0,0 +1 @@ +hush: syntax error: unterminated " diff --git a/shell/hush_test/hush-parsing/noeol3.tests b/shell/hush_test/hush-parsing/noeol3.tests new file mode 100755 index 0000000..ec958ed --- /dev/null +++ b/shell/hush_test/hush-parsing/noeol3.tests @@ -0,0 +1,2 @@ +# last line has no EOL! +echo "unterminated
\ No newline at end of file diff --git a/shell/hush_test/hush-parsing/process_subst.right b/shell/hush_test/hush-parsing/process_subst.right new file mode 100644 index 0000000..397bc80 --- /dev/null +++ b/shell/hush_test/hush-parsing/process_subst.right @@ -0,0 +1,3 @@ +TESTzzBEST +TEST$(echo zz)BEST +TEST'BEST diff --git a/shell/hush_test/hush-parsing/process_subst.tests b/shell/hush_test/hush-parsing/process_subst.tests new file mode 100755 index 0000000..21996bc --- /dev/null +++ b/shell/hush_test/hush-parsing/process_subst.tests @@ -0,0 +1,3 @@ +echo "TEST`echo zz;echo;echo`BEST" +echo "TEST`echo '$(echo zz)'`BEST" +echo "TEST`echo "'"`BEST" diff --git a/shell/hush_test/hush-parsing/quote1.right b/shell/hush_test/hush-parsing/quote1.right new file mode 100644 index 0000000..cb38205 --- /dev/null +++ b/shell/hush_test/hush-parsing/quote1.right @@ -0,0 +1 @@ +'1' diff --git a/shell/hush_test/hush-parsing/quote1.tests b/shell/hush_test/hush-parsing/quote1.tests new file mode 100755 index 0000000..f558954 --- /dev/null +++ b/shell/hush_test/hush-parsing/quote1.tests @@ -0,0 +1,2 @@ +a=1 +echo "'$a'" diff --git a/shell/hush_test/hush-parsing/quote2.right b/shell/hush_test/hush-parsing/quote2.right new file mode 100644 index 0000000..3bc9edc --- /dev/null +++ b/shell/hush_test/hush-parsing/quote2.right @@ -0,0 +1 @@ +>1 diff --git a/shell/hush_test/hush-parsing/quote2.tests b/shell/hush_test/hush-parsing/quote2.tests new file mode 100755 index 0000000..bd966f3 --- /dev/null +++ b/shell/hush_test/hush-parsing/quote2.tests @@ -0,0 +1,2 @@ +a=1 +echo ">$a" diff --git a/shell/hush_test/hush-parsing/quote3.right b/shell/hush_test/hush-parsing/quote3.right new file mode 100644 index 0000000..bbe46df --- /dev/null +++ b/shell/hush_test/hush-parsing/quote3.right @@ -0,0 +1,12 @@ +Testing: in "" +.. +Testing: in '' +.. +Testing: in $empty +Testing: in $empty"" +.. +Testing: in $empty'' +.. +Testing: in "$empty" +.. +Finished diff --git a/shell/hush_test/hush-parsing/quote3.tests b/shell/hush_test/hush-parsing/quote3.tests new file mode 100755 index 0000000..b5fd597 --- /dev/null +++ b/shell/hush_test/hush-parsing/quote3.tests @@ -0,0 +1,21 @@ +empty='' + +echo 'Testing: in ""' +for a in ""; do echo ".$a."; done + +echo 'Testing: in '"''" +for a in ''; do echo ".$a."; done + +echo 'Testing: in $empty' +for a in $empty; do echo ".$a."; done + +echo 'Testing: in $empty""' +for a in $empty""; do echo ".$a."; done + +echo 'Testing: in $empty'"''" +for a in $empty''; do echo ".$a."; done + +echo 'Testing: in "$empty"' +for a in "$empty"; do echo ".$a."; done + +echo Finished diff --git a/shell/hush_test/hush-parsing/quote4.right b/shell/hush_test/hush-parsing/quote4.right new file mode 100644 index 0000000..b2901ea --- /dev/null +++ b/shell/hush_test/hush-parsing/quote4.right @@ -0,0 +1 @@ +a b diff --git a/shell/hush_test/hush-parsing/quote4.tests b/shell/hush_test/hush-parsing/quote4.tests new file mode 100755 index 0000000..f1dabfa --- /dev/null +++ b/shell/hush_test/hush-parsing/quote4.tests @@ -0,0 +1,2 @@ +a_b='a b' +echo "$a_b" diff --git a/shell/hush_test/hush-parsing/redir_space.right b/shell/hush_test/hush-parsing/redir_space.right new file mode 100644 index 0000000..0842952 --- /dev/null +++ b/shell/hush_test/hush-parsing/redir_space.right @@ -0,0 +1,3 @@ +z1.tmp: 1 +z2.tmp: 1 +"z1.tmp z2.tmp": TEST 0 diff --git a/shell/hush_test/hush-parsing/redir_space.tests b/shell/hush_test/hush-parsing/redir_space.tests new file mode 100755 index 0000000..c0b5430 --- /dev/null +++ b/shell/hush_test/hush-parsing/redir_space.tests @@ -0,0 +1,6 @@ +v='z1.tmp z2.tmp' +echo TEST >$v +echo 'z1.tmp:' `cat 'z1.tmp' 2>/dev/null; echo $?` +echo 'z2.tmp:' `cat 'z2.tmp' 2>/dev/null; echo $?` +echo '"z1.tmp z2.tmp":' `cat 'z1.tmp z2.tmp' 2>/dev/null; echo $?` +rm z*.tmp diff --git a/shell/hush_test/hush-parsing/starquoted.right b/shell/hush_test/hush-parsing/starquoted.right new file mode 100644 index 0000000..b56323f --- /dev/null +++ b/shell/hush_test/hush-parsing/starquoted.right @@ -0,0 +1,8 @@ +.1 abc d e f. +.1. +.abc. +.d e f. +.-1 abc d e f-. +.-1. +.abc. +.d e f-. diff --git a/shell/hush_test/hush-parsing/starquoted.tests b/shell/hush_test/hush-parsing/starquoted.tests new file mode 100755 index 0000000..2fe49b1 --- /dev/null +++ b/shell/hush_test/hush-parsing/starquoted.tests @@ -0,0 +1,8 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" 1 abc 'd e f' +fi + +for a in "$*"; do echo ".$a."; done +for a in "$@"; do echo ".$a."; done +for a in "-$*-"; do echo ".$a."; done +for a in "-$@-"; do echo ".$a."; done diff --git a/shell/hush_test/hush-parsing/starquoted2.right b/shell/hush_test/hush-parsing/starquoted2.right new file mode 100644 index 0000000..46f2436 --- /dev/null +++ b/shell/hush_test/hush-parsing/starquoted2.right @@ -0,0 +1,2 @@ +Should be printed +Should be printed diff --git a/shell/hush_test/hush-parsing/starquoted2.tests b/shell/hush_test/hush-parsing/starquoted2.tests new file mode 100755 index 0000000..782d71b --- /dev/null +++ b/shell/hush_test/hush-parsing/starquoted2.tests @@ -0,0 +1,14 @@ +if test $# != 0; then + exec "$THIS_SH" "$0" +fi + +# No params! +for a in "$*"; do echo Should be printed; done +for a in "$@"; do echo Should not be printed; done +# Yes, believe it or not, bash is mesmerized by "$@" and stops +# treating "" as "this word cannot be expanded to nothing, +# but must be at least null string". Now it can be expanded to nothing. +for a in "$@"""; do echo Should not be printed; done +for a in """$@"; do echo Should not be printed; done +for a in """$@"''"$@"''; do echo Should not be printed; done +for a in ""; do echo Should be printed; done diff --git a/shell/hush_test/hush-psubst/tick.right b/shell/hush_test/hush-psubst/tick.right new file mode 100644 index 0000000..6ed281c --- /dev/null +++ b/shell/hush_test/hush-psubst/tick.right @@ -0,0 +1,2 @@ +1 +1 diff --git a/shell/hush_test/hush-psubst/tick.tests b/shell/hush_test/hush-psubst/tick.tests new file mode 100755 index 0000000..1f749a9 --- /dev/null +++ b/shell/hush_test/hush-psubst/tick.tests @@ -0,0 +1,4 @@ +true +false; echo `echo $?` +true +{ false; echo `echo $?`; } diff --git a/shell/hush_test/hush-psubst/tick2.right b/shell/hush_test/hush-psubst/tick2.right new file mode 100644 index 0000000..216c883 --- /dev/null +++ b/shell/hush_test/hush-psubst/tick2.right @@ -0,0 +1 @@ +BAZ diff --git a/shell/hush_test/hush-psubst/tick2.tests b/shell/hush_test/hush-psubst/tick2.tests new file mode 100755 index 0000000..db4e944 --- /dev/null +++ b/shell/hush_test/hush-psubst/tick2.tests @@ -0,0 +1,5 @@ +if false; then + echo "FOO" + tmp=`echo BAR >&2` +fi +echo BAZ diff --git a/shell/hush_test/hush-psubst/tick3.right b/shell/hush_test/hush-psubst/tick3.right new file mode 100644 index 0000000..dc84e92 --- /dev/null +++ b/shell/hush_test/hush-psubst/tick3.right @@ -0,0 +1,6 @@ +\TESTZZBEST +$TEST +Q +a\bc +a"c +done:0 diff --git a/shell/hush_test/hush-psubst/tick3.tests b/shell/hush_test/hush-psubst/tick3.tests new file mode 100755 index 0000000..2b055bb --- /dev/null +++ b/shell/hush_test/hush-psubst/tick3.tests @@ -0,0 +1,10 @@ +TEST=Q +# \` is special +echo `echo '\'TEST\`echo ZZ\`BEST` +# \$ and \\ are special +echo `echo \\$TEST` +echo `echo \$TEST` +echo a`echo \\\\b`c +# \" etc are NOT special (passed verbatim WITH \)! +echo a`echo \"`c +echo done:$? diff --git a/shell/hush_test/hush-psubst/tick4.right b/shell/hush_test/hush-psubst/tick4.right new file mode 100644 index 0000000..d8030ea --- /dev/null +++ b/shell/hush_test/hush-psubst/tick4.right @@ -0,0 +1,7 @@ +(TEST) BEST +TEST) BEST +((TEST) BEST +) +abc +a)c +OK: 0 diff --git a/shell/hush_test/hush-psubst/tick4.tests b/shell/hush_test/hush-psubst/tick4.tests new file mode 100755 index 0000000..f2305fb --- /dev/null +++ b/shell/hush_test/hush-psubst/tick4.tests @@ -0,0 +1,7 @@ +echo $(echo '(TEST)' BEST) +echo $(echo 'TEST)' BEST) +echo $(echo \(\(TEST\) BEST) +echo $(echo \)) +echo $(echo a"`echo "b"`"c ) +echo $(echo a"`echo ")"`"c ) +echo OK: $? diff --git a/shell/hush_test/hush-vars/empty.right b/shell/hush_test/hush-vars/empty.right new file mode 100644 index 0000000..2cb3c70 --- /dev/null +++ b/shell/hush_test/hush-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/hush_test/hush-vars/empty.tests b/shell/hush_test/hush-vars/empty.tests new file mode 100755 index 0000000..a9c247e --- /dev/null +++ b/shell/hush_test/hush-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/hush_test/hush-vars/glob_and_vars.right b/shell/hush_test/hush-vars/glob_and_vars.right new file mode 100644 index 0000000..3ac7ec5 --- /dev/null +++ b/shell/hush_test/hush-vars/glob_and_vars.right @@ -0,0 +1 @@ +./glob_and_vars.right ./glob_and_vars.tests diff --git a/shell/hush_test/hush-vars/glob_and_vars.tests b/shell/hush_test/hush-vars/glob_and_vars.tests new file mode 100755 index 0000000..482cf9d --- /dev/null +++ b/shell/hush_test/hush-vars/glob_and_vars.tests @@ -0,0 +1,2 @@ +v=. +echo $v/glob_and_vars.[tr]* diff --git a/shell/hush_test/hush-vars/param_glob.right b/shell/hush_test/hush-vars/param_glob.right new file mode 100644 index 0000000..bdee8fe --- /dev/null +++ b/shell/hush_test/hush-vars/param_glob.right @@ -0,0 +1,4 @@ +param_glob.tests +param_glob.tests +param_glob.t* +param_glob.t* diff --git a/shell/hush_test/hush-vars/param_glob.tests b/shell/hush_test/hush-vars/param_glob.tests new file mode 100755 index 0000000..801d58e --- /dev/null +++ b/shell/hush_test/hush-vars/param_glob.tests @@ -0,0 +1,10 @@ +if test $# = 0; then + #BUG in builtin_exec! will glob param! + #exec "$THIS_SH" "$0" 'param_glob.t*' + "$THIS_SH" "$0" 'param_glob.t*' + exit +fi +echo $* +echo $@ +echo "$*" +echo "$@" diff --git a/shell/hush_test/hush-vars/star.right b/shell/hush_test/hush-vars/star.right new file mode 100644 index 0000000..0ecc55b --- /dev/null +++ b/shell/hush_test/hush-vars/star.right @@ -0,0 +1,6 @@ +.1. +.abc. +.d. +.e. +.f. +.1 abc d e f. diff --git a/shell/hush_test/hush-vars/star.tests b/shell/hush_test/hush-vars/star.tests new file mode 100755 index 0000000..5554c40 --- /dev/null +++ b/shell/hush_test/hush-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/hush_test/hush-vars/var1.right b/shell/hush_test/hush-vars/var1.right new file mode 100644 index 0000000..14b2314 --- /dev/null +++ b/shell/hush_test/hush-vars/var1.right @@ -0,0 +1,4 @@ +http://busybox.net +http://busybox.net_abc +1 +1 diff --git a/shell/hush_test/hush-vars/var1.tests b/shell/hush_test/hush-vars/var1.tests new file mode 100755 index 0000000..0a63696 --- /dev/null +++ b/shell/hush_test/hush-vars/var1.tests @@ -0,0 +1,9 @@ +URL=http://busybox.net + +echo $URL +echo ${URL}_abc + +true +false; echo $? +true +{ false; echo $?; } diff --git a/shell/hush_test/hush-vars/var2.right b/shell/hush_test/hush-vars/var2.right new file mode 100644 index 0000000..40bf4bf --- /dev/null +++ b/shell/hush_test/hush-vars/var2.right @@ -0,0 +1,2 @@ +http://busybox.net +http://busybox.net_abc diff --git a/shell/hush_test/hush-vars/var2.tests b/shell/hush_test/hush-vars/var2.tests new file mode 100755 index 0000000..1292410 --- /dev/null +++ b/shell/hush_test/hush-vars/var2.tests @@ -0,0 +1,4 @@ +_1=http://busybox.net + +echo $_1 +echo ${_1}_abc diff --git a/shell/hush_test/hush-vars/var_expand_in_assign.right b/shell/hush_test/hush-vars/var_expand_in_assign.right new file mode 100644 index 0000000..352210d --- /dev/null +++ b/shell/hush_test/hush-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/hush_test/hush-vars/var_expand_in_assign.tests b/shell/hush_test/hush-vars/var_expand_in_assign.tests new file mode 100755 index 0000000..18cdc74 --- /dev/null +++ b/shell/hush_test/hush-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/hush_test/hush-vars/var_expand_in_redir.right b/shell/hush_test/hush-vars/var_expand_in_redir.right new file mode 100644 index 0000000..423299c --- /dev/null +++ b/shell/hush_test/hush-vars/var_expand_in_redir.right @@ -0,0 +1,3 @@ +TEST1 +TEST2 +TEST3 diff --git a/shell/hush_test/hush-vars/var_expand_in_redir.tests b/shell/hush_test/hush-vars/var_expand_in_redir.tests new file mode 100755 index 0000000..bda6bdd --- /dev/null +++ b/shell/hush_test/hush-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/hush_test/hush-vars/var_leaks.right b/shell/hush_test/hush-vars/var_leaks.right new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/shell/hush_test/hush-vars/var_leaks.right @@ -0,0 +1 @@ +OK diff --git a/shell/hush_test/hush-vars/var_leaks.tests b/shell/hush_test/hush-vars/var_leaks.tests new file mode 100755 index 0000000..27c8c65 --- /dev/null +++ b/shell/hush_test/hush-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 diff --git a/shell/hush_test/hush-vars/var_preserved.right b/shell/hush_test/hush-vars/var_preserved.right new file mode 100644 index 0000000..2a9917c --- /dev/null +++ b/shell/hush_test/hush-vars/var_preserved.right @@ -0,0 +1,4 @@ +a=b +a=b +a=b +OK diff --git a/shell/hush_test/hush-vars/var_preserved.tests b/shell/hush_test/hush-vars/var_preserved.tests new file mode 100755 index 0000000..1bddd87 --- /dev/null +++ b/shell/hush_test/hush-vars/var_preserved.tests @@ -0,0 +1,16 @@ +export a=b + +# external program +a=c /bin/true +env | grep ^a= + +# builtin +a=d true +env | grep ^a= + +# exec with redirection only +# in bash, this leaks! +a=e exec 1>&1 +env | grep ^a= + +echo OK diff --git a/shell/hush_test/hush-vars/var_subst_in_for.right b/shell/hush_test/hush-vars/var_subst_in_for.right new file mode 100644 index 0000000..c8aca1c --- /dev/null +++ b/shell/hush_test/hush-vars/var_subst_in_for.right @@ -0,0 +1,40 @@ +Testing: in x y z +.x. +.y. +.z. +Testing: in u $empty v +.u. +.v. +Testing: in u " $empty" v +.u. +. . +.v. +Testing: in u $empty $empty$a v +.u. +.a. +.v. +Testing: in $a_b +.a. +.b. +Testing: in $* +.abc. +.d. +.e. +Testing: in $@ +.abc. +.d. +.e. +Testing: in -$*- +.-abc. +.d. +.e-. +Testing: in -$@- +.-abc. +.d. +.e-. +Testing: in $a_b -$a_b- +.a. +.b. +.-a. +.b-. +Finished diff --git a/shell/hush_test/hush-vars/var_subst_in_for.tests b/shell/hush_test/hush-vars/var_subst_in_for.tests new file mode 100755 index 0000000..433c606 --- /dev/null +++ b/shell/hush_test/hush-vars/var_subst_in_for.tests @@ -0,0 +1,40 @@ +if test $# = 0; then + exec "$THIS_SH" "$0" abc "d e" +fi + +echo 'Testing: in x y z' +for a in x y z; do echo ".$a."; done + +echo 'Testing: in u $empty v' +empty='' +for a in u $empty v; do echo ".$a."; done + +echo 'Testing: in u " $empty" v' +empty='' +for a in u " $empty" v; do echo ".$a."; done + +echo 'Testing: in u $empty $empty$a v' +a='a' +for a in u $empty $empty$a v; do echo ".$a."; done + +echo 'Testing: in $a_b' +a_b='a b' +for a in $a_b; do echo ".$a."; done + +echo 'Testing: in $*' +for a in $*; do echo ".$a."; done + +echo 'Testing: in $@' +for a in $@; do echo ".$a."; done + +echo 'Testing: in -$*-' +for a in -$*-; do echo ".$a."; done + +echo 'Testing: in -$@-' +for a in -$@-; do echo ".$a."; done + +echo 'Testing: in $a_b -$a_b-' +a_b='a b' +for a in $a_b -$a_b-; do echo ".$a."; done + +echo Finished diff --git a/shell/hush_test/hush-z_slow/leak_var.right b/shell/hush_test/hush-z_slow/leak_var.right new file mode 100644 index 0000000..7bccc1e --- /dev/null +++ b/shell/hush_test/hush-z_slow/leak_var.right @@ -0,0 +1,2 @@ +Measuring memory leak... +vsz does not grow diff --git a/shell/hush_test/hush-z_slow/leak_var.tests b/shell/hush_test/hush-z_slow/leak_var.tests new file mode 100755 index 0000000..b3e13e3 --- /dev/null +++ b/shell/hush_test/hush-z_slow/leak_var.tests @@ -0,0 +1,138 @@ +pid=$$ + +# Warm up +beg=`ps -o pid,vsz | grep "^ *$pid "` +i=1 +while test $i != X; do + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + i=1$i + if test $i = 1111111111111111111111111111111111111111111111; then i=2; fi + if test $i = 1111111111111111111111111111111111111111111112; then i=3; fi + if test $i = 1111111111111111111111111111111111111111111113; then i=4; fi + if test $i = 1111111111111111111111111111111111111111111114; then i=5; fi + if test $i = 1111111111111111111111111111111111111111111115; then i=6; fi + if test $i = 1111111111111111111111111111111111111111111116; then i=7; fi + if test $i = 1111111111111111111111111111111111111111111117; then i=8; fi + if test $i = 1111111111111111111111111111111111111111111118; then i=9; fi + if test $i = 1111111111111111111111111111111111111111111119; then i=a; fi + if test $i = 111111111111111111111111111111111111111111111a; then i=b; fi + if test $i = 111111111111111111111111111111111111111111111b; then i=c; fi + if test $i = 111111111111111111111111111111111111111111111c; then i=d; fi + if test $i = 111111111111111111111111111111111111111111111d; then i=e; fi + if test $i = 111111111111111111111111111111111111111111111e; then i=f; fi + if test $i = 111111111111111111111111111111111111111111111f; then i=g; fi + if test $i = 111111111111111111111111111111111111111111111g; then i=h; fi + if test $i = 111111111111111111111111111111111111111111111h; then i=i; fi + if test $i = 111111111111111111111111111111111111111111111i; then i=j; fi + if test $i = 111111111111111111111111111111111111111111111j; then i=X; fi +done +end=`ps -o pid,vsz | grep "^ *$pid "` + +# Warm up again (I do need it on my machine) +beg=`ps -o pid,vsz | grep "^ *$pid "` +i=1 +while test $i != X; do + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + i=1$i + if test $i = 1111111111111111111111111111111111111111111111; then i=2; fi + if test $i = 1111111111111111111111111111111111111111111112; then i=3; fi + if test $i = 1111111111111111111111111111111111111111111113; then i=4; fi + if test $i = 1111111111111111111111111111111111111111111114; then i=5; fi + if test $i = 1111111111111111111111111111111111111111111115; then i=6; fi + if test $i = 1111111111111111111111111111111111111111111116; then i=7; fi + if test $i = 1111111111111111111111111111111111111111111117; then i=8; fi + if test $i = 1111111111111111111111111111111111111111111118; then i=9; fi + if test $i = 1111111111111111111111111111111111111111111119; then i=a; fi + if test $i = 111111111111111111111111111111111111111111111a; then i=b; fi + if test $i = 111111111111111111111111111111111111111111111b; then i=c; fi + if test $i = 111111111111111111111111111111111111111111111c; then i=d; fi + if test $i = 111111111111111111111111111111111111111111111d; then i=e; fi + if test $i = 111111111111111111111111111111111111111111111e; then i=f; fi + if test $i = 111111111111111111111111111111111111111111111f; then i=g; fi + if test $i = 111111111111111111111111111111111111111111111g; then i=h; fi + if test $i = 111111111111111111111111111111111111111111111h; then i=i; fi + if test $i = 111111111111111111111111111111111111111111111i; then i=j; fi + if test $i = 111111111111111111111111111111111111111111111j; then i=X; fi +done +end=`ps -o pid,vsz | grep "^ *$pid "` +if test "$beg" != "$end"; then + true echo "vsz grows: $beg -> $end" +else + true echo "vsz does not grow" +fi + +echo "Measuring memory leak..." +beg=`ps -o pid,vsz | grep "^ *$pid "` +i=1 +while test $i != X; do + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + unset t + t=111111111111111111111111111111111111111111111111111111111111111111111111 + export t + i=1$i + if test $i = 1111111111111111111111111111111111111111111111; then i=2; fi + if test $i = 1111111111111111111111111111111111111111111112; then i=3; fi + if test $i = 1111111111111111111111111111111111111111111113; then i=4; fi + if test $i = 1111111111111111111111111111111111111111111114; then i=5; fi + if test $i = 1111111111111111111111111111111111111111111115; then i=6; fi + if test $i = 1111111111111111111111111111111111111111111116; then i=7; fi + if test $i = 1111111111111111111111111111111111111111111117; then i=8; fi + if test $i = 1111111111111111111111111111111111111111111118; then i=9; fi + if test $i = 1111111111111111111111111111111111111111111119; then i=a; fi + if test $i = 111111111111111111111111111111111111111111111a; then i=b; fi + if test $i = 111111111111111111111111111111111111111111111b; then i=c; fi + if test $i = 111111111111111111111111111111111111111111111c; then i=d; fi + if test $i = 111111111111111111111111111111111111111111111d; then i=e; fi + if test $i = 111111111111111111111111111111111111111111111e; then i=f; fi + if test $i = 111111111111111111111111111111111111111111111f; then i=g; fi + if test $i = 111111111111111111111111111111111111111111111g; then i=h; fi + if test $i = 111111111111111111111111111111111111111111111h; then i=i; fi + if test $i = 111111111111111111111111111111111111111111111i; then i=j; fi + if test $i = 111111111111111111111111111111111111111111111j; then i=X; fi +done +end=`ps -o pid,vsz | grep "^ *$pid "` + +if test "$beg" != "$end"; then + echo "vsz grows: $beg -> $end" +else + echo "vsz does not grow" +fi diff --git a/shell/hush_test/hush-z_slow/leak_var2.right b/shell/hush_test/hush-z_slow/leak_var2.right new file mode 100644 index 0000000..7bccc1e --- /dev/null +++ b/shell/hush_test/hush-z_slow/leak_var2.right @@ -0,0 +1,2 @@ +Measuring memory leak... +vsz does not grow diff --git a/shell/hush_test/hush-z_slow/leak_var2.tests b/shell/hush_test/hush-z_slow/leak_var2.tests new file mode 100755 index 0000000..09f2475 --- /dev/null +++ b/shell/hush_test/hush-z_slow/leak_var2.tests @@ -0,0 +1,63 @@ +pid=$$ + +t=1 +export t + +# Warm up +beg=`ps -o pid,vsz | grep "^ *$pid "` +i=1 +while test $i != X; do + t=111111111111111111111111111111111111111111111111111111111111111111111110$i + t=111111111111111111111111111111111111111111111111111111111111111111111111$i true + t=111111111111111111111111111111111111111111111111111111111111111111111112$i /bin/true + t=111111111111111111111111111111111111111111111111111111111111111111111113$i exec 1>&1 + i=1$i + if test $i = 1111111111111111111111111111111111111111111111; then i=2; fi + if test $i = 1111111111111111111111111111111111111111111112; then i=3; fi + if test $i = 1111111111111111111111111111111111111111111113; then i=4; fi + if test $i = 1111111111111111111111111111111111111111111114; then i=X; fi +done +end=`ps -o pid,vsz | grep "^ *$pid "` + +# Warm up again (I do need it on my machine) +beg=`ps -o pid,vsz | grep "^ *$pid "` +i=1 +while test $i != X; do + t=111111111111111111111111111111111111111111111111111111111111111111111110$i + t=111111111111111111111111111111111111111111111111111111111111111111111111$i true + t=111111111111111111111111111111111111111111111111111111111111111111111112$i /bin/true + t=111111111111111111111111111111111111111111111111111111111111111111111113$i exec 1>&1 + i=1$i + if test $i = 1111111111111111111111111111111111111111111111; then i=2; fi + if test $i = 1111111111111111111111111111111111111111111112; then i=3; fi + if test $i = 1111111111111111111111111111111111111111111113; then i=4; fi + if test $i = 1111111111111111111111111111111111111111111114; then i=X; fi +done +end=`ps -o pid,vsz | grep "^ *$pid "` +if test "$beg" != "$end"; then + true echo "vsz grows: $beg -> $end" +else + true echo "vsz does not grow" +fi + +echo "Measuring memory leak..." +beg=`ps -o pid,vsz | grep "^ *$pid "` +i=1 +while test $i != X; do + t=111111111111111111111111111111111111111111111111111111111111111111111110$i + t=111111111111111111111111111111111111111111111111111111111111111111111111$i true + t=111111111111111111111111111111111111111111111111111111111111111111111112$i /bin/true + t=111111111111111111111111111111111111111111111111111111111111111111111113$i exec 1>&1 + i=1$i + if test $i = 1111111111111111111111111111111111111111111111; then i=2; fi + if test $i = 1111111111111111111111111111111111111111111112; then i=3; fi + if test $i = 1111111111111111111111111111111111111111111113; then i=4; fi + if test $i = 1111111111111111111111111111111111111111111114; then i=X; fi +done +end=`ps -o pid,vsz | grep "^ *$pid "` + +if test "$beg" != "$end"; then + echo "vsz grows: $beg -> $end" +else + echo "vsz does not grow" +fi diff --git a/shell/hush_test/run-all b/shell/hush_test/run-all new file mode 100755 index 0000000..b79af2f --- /dev/null +++ b/shell/hush_test/run-all @@ -0,0 +1,73 @@ +#!/bin/sh + +unset LANG LANGUAGE +unset LC_COLLATE +unset LC_CTYPE +unset LC_MONETARY +unset LC_MESSAGES +unset LC_NUMERIC +unset LC_TIME +unset LC_ALL + +test -x hush || { + echo "No ./hush - creating a link to ../../busybox" + ln -s ../../busybox hush +} + +PATH="$PWD:$PATH" # for hush and recho/zecho/printenv +export PATH + +THIS_SH="$PWD/hush" +export THIS_SH + +do_test() +{ + test -d "$1" || return 0 +# echo Running tests in directory "$1" + ( + cd "$1" || { echo "cannot cd $1!"; exit 1; } + for x in run-*; do + test -f "$x" || continue + case "$x" in + "$0"|run-minimal|run-gprof) ;; + *.orig|*~) ;; + #*) echo $x ; sh $x ;; + *) + sh "$x" >"../$1-$x.fail" 2>&1 && \ + { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; + ;; + esac + done + # Many bash run-XXX scripts just do this, + # no point in duplication it all over the place + for x in *.tests; do + test -x "$x" || continue + name="${x%%.tests}" + test -f "$name.right" || continue +# echo Running test: "$name.right" + { + "$THIS_SH" "./$x" >"$name.xx" 2>&1 + diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" + } && echo "$1/$x: ok" || echo "$1/$x: fail" + done + ) +} + +# Main part of this script +# Usage: run-all [directories] + +if [ $# -lt 1 ]; then + # All sub directories + modules=`ls -d hush-*` + + for module in $modules; do + do_test $module + done +else + while [ $# -ge 1 ]; do + if [ -d $1 ]; then + do_test $1 + fi + shift + done +fi |