diff options
Diffstat (limited to 'release/src/router/busybox/shell/hush_test/hush-misc')
82 files changed, 682 insertions, 0 deletions
diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/and-or.right b/release/src/router/busybox/shell/hush_test/hush-misc/and-or.right new file mode 100644 index 00000000..f9fa5fbf --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/and-or.right @@ -0,0 +1,18 @@ +a1 +a4 +b1 +b3 +b4 +b6 +c4 +c5 +c7 +c8 +ff1 +ff3 +ft2 +ft3 +tf2 +tf3 +tt2 +tt4 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/and-or.tests b/release/src/router/busybox/shell/hush_test/hush-misc/and-or.tests new file mode 100755 index 00000000..485458ab --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/and-or.tests @@ -0,0 +1,34 @@ +false || echo a1 +false && echo a2 +true || echo a3 +true && echo a4 + +false || echo b1 || echo b2 +false || echo b3 && echo b4 +false && echo b5 || echo b6 +false && echo b7 && echo b8 + +true || echo c1 || echo c2 +true || echo c3 && echo c4 +true && echo c5 || echo c6 +true && echo c7 && echo c8 + +false || false || echo ff1 +false || false && echo ff2 +false && false || echo ff3 +false && false && echo ff4 + +false || true || echo ft1 +false || true && echo ft2 +false && true || echo ft3 +false && true && echo ft4 + +true || false || echo tf1 +true || false && echo tf2 +true && false || echo tf3 +true && false && echo tf4 + +true || true || echo tt1 +true || true && echo tt2 +true && true || echo tt3 +true && true && echo tt4 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/assignment1.right b/release/src/router/busybox/shell/hush_test/hush-misc/assignment1.right new file mode 100644 index 00000000..d0a13d3d --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/assignment1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/assignment1.tests new file mode 100755 index 00000000..033b3525 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/assignment2.rigth b/release/src/router/busybox/shell/hush_test/hush-misc/assignment2.rigth new file mode 100644 index 00000000..591552cd --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/assignment2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/assignment2.tests new file mode 100755 index 00000000..540e01ec --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/break1.right b/release/src/router/busybox/shell/hush_test/hush-misc/break1.right new file mode 100644 index 00000000..04a4b175 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/break1.right @@ -0,0 +1,2 @@ +A +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/break1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/break1.tests new file mode 100755 index 00000000..912f149c --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/break2.right b/release/src/router/busybox/shell/hush_test/hush-misc/break2.right new file mode 100644 index 00000000..8a15cb95 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/break2.right @@ -0,0 +1,3 @@ +A +AA +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/break2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/break2.tests new file mode 100755 index 00000000..7da9faf3 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/break3.right b/release/src/router/busybox/shell/hush_test/hush-misc/break3.right new file mode 100644 index 00000000..04a4b175 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/break3.right @@ -0,0 +1,2 @@ +A +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/break3.tests b/release/src/router/busybox/shell/hush_test/hush-misc/break3.tests new file mode 100755 index 00000000..d138dcac --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/break4.right b/release/src/router/busybox/shell/hush_test/hush-misc/break4.right new file mode 100644 index 00000000..6f41c141 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/break4.right @@ -0,0 +1,6 @@ +A +AA +TRUE +A +AA +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/break4.tests b/release/src/router/busybox/shell/hush_test/hush-misc/break4.tests new file mode 100755 index 00000000..67da2889 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/break5.right b/release/src/router/busybox/shell/hush_test/hush-misc/break5.right new file mode 100644 index 00000000..0b9df2a4 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/break5.tests b/release/src/router/busybox/shell/hush_test/hush-misc/break5.tests new file mode 100755 index 00000000..273e040e --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/builtin1.right b/release/src/router/busybox/shell/hush_test/hush-misc/builtin1.right new file mode 100644 index 00000000..2e55ecb0 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/builtin1.right @@ -0,0 +1,2 @@ +VARIABLE=export +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/builtin1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/builtin1.tests new file mode 100755 index 00000000..1a2941fa --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/case1.right b/release/src/router/busybox/shell/hush_test/hush-misc/case1.right new file mode 100644 index 00000000..e9e371ac --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/case1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/case1.tests new file mode 100755 index 00000000..0174893e --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/colon.right b/release/src/router/busybox/shell/hush_test/hush-misc/colon.right new file mode 100644 index 00000000..2a87d029 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/colon.right @@ -0,0 +1,2 @@ +0 +OK: 0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/colon.tests b/release/src/router/busybox/shell/hush_test/hush-misc/colon.tests new file mode 100755 index 00000000..cb8ab530 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/colon.tests @@ -0,0 +1,5 @@ +false +: +echo $? +(while :; do exit; done) +echo OK: $? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/continue1.right b/release/src/router/busybox/shell/hush_test/hush-misc/continue1.right new file mode 100644 index 00000000..c4a5565b --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/continue1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/continue1.tests new file mode 100755 index 00000000..72d35666 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/continue2.right b/release/src/router/busybox/shell/hush_test/hush-misc/continue2.right new file mode 100644 index 00000000..49d3ebd3 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/continue2.right @@ -0,0 +1 @@ +Ok:1 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/continue2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/continue2.tests new file mode 100755 index 00000000..c2df0719 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/continue2.tests @@ -0,0 +1,3 @@ +e='' +(while test $e && exit 1; true; do e=1; continue; done) +echo Ok:$? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/continue3.right b/release/src/router/busybox/shell/hush_test/hush-misc/continue3.right new file mode 100644 index 00000000..aa47d0d4 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/continue3.right @@ -0,0 +1,2 @@ +0 +0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/continue3.tests b/release/src/router/busybox/shell/hush_test/hush-misc/continue3.tests new file mode 100755 index 00000000..0aff867c --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/continue3.tests @@ -0,0 +1,3 @@ +# Test that "continue" does affect exitcode (sets to 0) +e='' +while echo $?; test $e && exit; true; do e=1; false; continue; done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/empty_for.right b/release/src/router/busybox/shell/hush_test/hush-misc/empty_for.right new file mode 100644 index 00000000..290d39b7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/empty_for.right @@ -0,0 +1 @@ +OK: 0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/empty_for.tests b/release/src/router/busybox/shell/hush_test/hush-misc/empty_for.tests new file mode 100755 index 00000000..0cb52e84 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/empty_for2.right b/release/src/router/busybox/shell/hush_test/hush-misc/empty_for2.right new file mode 100644 index 00000000..1acee9eb --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/empty_for2.right @@ -0,0 +1,4 @@ +PARAM:abc +PARAM:d e +PARAM:123 +OK: 0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/empty_for2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/empty_for2.tests new file mode 100755 index 00000000..2b12ec2c --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/exec.right b/release/src/router/busybox/shell/hush_test/hush-misc/exec.right new file mode 100644 index 00000000..a0de6089 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/exec.right @@ -0,0 +1,6 @@ +pass fd out open +pass fd out dup +pass fd out close +pass fd in open +pass fd in dup +pass fd in close diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/exec.tests b/release/src/router/busybox/shell/hush_test/hush-misc/exec.tests new file mode 100755 index 00000000..6de50fa7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/exec.tests @@ -0,0 +1,30 @@ +# make sure we have a way of checking these things +cd /proc/$$/fd || cd /dev/fd || exit 1 + +[ -e 44 ] && exit 1 +exec 44>/dev/null +[ -e 44 ] || exit 1 +echo pass fd out open + +[ -e 55 ] && exit 1 +exec 55>&44 +[ -e 55 ] || exit 1 +echo pass fd out dup + +exec 44>&- +[ -e 44 ] && exit 1 +echo pass fd out close + +[ -e 66 ] && exit 1 +exec 66</dev/null +[ -e 66 ] || exit 1 +echo pass fd in open + +[ -e 77 ] && exit 1 +exec 77<&66 +[ -e 77 ] || exit 1 +echo pass fd in dup + +exec 66<&- +[ -e 66 ] && exit 1 +echo pass fd in close diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/exit1.right b/release/src/router/busybox/shell/hush_test/hush-misc/exit1.right new file mode 100644 index 00000000..dd2cfc27 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/exit1.right @@ -0,0 +1 @@ +Once diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/exit1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/exit1.tests new file mode 100755 index 00000000..41e0d092 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/exit1.tests @@ -0,0 +1,4 @@ +trap "echo Not shown" EXIT +(exit) # must be silent +trap "echo Once; exit" EXIT +{ exit; } diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/export.right b/release/src/router/busybox/shell/hush_test/hush-misc/export.right new file mode 100644 index 00000000..4df2e385 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/export.right @@ -0,0 +1,6 @@ +export aaa1="'''" +export aaa2= +export aaa3="'''"'abc' +export aaa4='def'"'''" +export aaa5="'''"'abc'"'''"'def'"'''" +Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/export.tests b/release/src/router/busybox/shell/hush_test/hush-misc/export.tests new file mode 100755 index 00000000..87a27ecc --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/export.tests @@ -0,0 +1,7 @@ +export aaa1="'''" +export aaa2="" +export aaa3="'''abc" +export aaa4="def'''" +export aaa5="'''abc'''def'''" +export | grep aaa.= +echo Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/for_with_bslashes.right b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_bslashes.right new file mode 100644 index 00000000..02d96692 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_bslashes.right @@ -0,0 +1,8 @@ +a +b\c +b\\c +b"c +b'c +b$c +b`true`c +Zero:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/for_with_bslashes.tests b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_bslashes.tests new file mode 100755 index 00000000..363f3d85 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_bslashes.tests @@ -0,0 +1,10 @@ +# UNFIXED BUG. +# commented-out words contain ^C character. +# It's a SPECIAL_VAR_SYMBOL, for now hush does not escape it. +# When it is fixed, update this test. + +for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' ### 'b#c' +do + echo $a +done +echo Zero:$? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/for_with_keywords.right b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_keywords.right new file mode 100644 index 00000000..eb04e9af --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_keywords.right @@ -0,0 +1,4 @@ +do +done +then +OK: 0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/for_with_keywords.tests b/release/src/router/busybox/shell/hush_test/hush-misc/for_with_keywords.tests new file mode 100755 index 00000000..a8b8e426 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/func1.right b/release/src/router/busybox/shell/hush_test/hush-misc/func1.right new file mode 100644 index 00000000..e21665aa --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/func1.right @@ -0,0 +1,6 @@ +Hello +Zero: 0 +One: 1 Param1: World +Zero: 0 Param1: Restored +Multi line function +One: 1 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/func1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/func1.tests new file mode 100755 index 00000000..ffb269fa --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/func1.tests @@ -0,0 +1,16 @@ +f() { echo Hello; } +g () { echo One: $# Param1: $1; } +h ( ) +{ + echo -n 'Multi ' && echo -n 'line ' + echo function + false +} + +f +echo Zero: $? +set -- Restored +{ g World; } +echo Zero: $? Param1: $1 +( h ) +echo One: $? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/func2.right b/release/src/router/busybox/shell/hush_test/hush-misc/func2.right new file mode 100644 index 00000000..f2a041da --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/func2.right @@ -0,0 +1,5 @@ +First 0 +Second 0 +First 1 +Second 1 +Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/func2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/func2.tests new file mode 100755 index 00000000..763203f1 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/func2.tests @@ -0,0 +1,9 @@ +i=0 +while test $i != 2; do + f() { echo First $i; } + f + f() { echo Second $i; } + f + : $((i++)) +done +echo Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc1.right b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc1.right new file mode 100644 index 00000000..7fc68f3e --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc1.right @@ -0,0 +1,5 @@ +qwe +asd +123 +456 +Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc1.tests new file mode 100755 index 00000000..2eeb4726 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc1.tests @@ -0,0 +1,9 @@ +cat <<000; cat <<www; cat <<eee +000 +qwe +asd +www +123 +456 +eee +echo Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc2.right b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc2.right new file mode 100644 index 00000000..74110e3b --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc2.right @@ -0,0 +1,9 @@ +exit EOF-f +" +echo 1 +echo Hello World +moo + EOF-f +EOF-f f +EOF-f +Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc2.tests new file mode 100755 index 00000000..e619bded --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc2.tests @@ -0,0 +1,12 @@ +f=1 + cat <<- EOF-f + exit EOF-f +" +echo $f +echo `echo Hello World` + moo + EOF-f +EOF-f f +EOF-f +EOF-f +echo Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc3.right b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc3.right new file mode 100644 index 00000000..6ed517f7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc3.right @@ -0,0 +1,9 @@ +exit EOF-f +" +echo $f +echo `echo Hello World` +moo + EOF-f +EOF-f f +EOF-f +Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc3.tests b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc3.tests new file mode 100755 index 00000000..938577a8 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc3.tests @@ -0,0 +1,12 @@ +f=1 + cat <<- EOF-f"" + exit EOF-f +" +echo $f +echo `echo Hello World` + moo + EOF-f +EOF-f f +EOF-f +EOF-f +echo Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc_huge.right b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc_huge.right new file mode 100644 index 00000000..11740f67 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc_huge.right @@ -0,0 +1,3 @@ +546ed3f5c81c780d3ab86ada14824237 - +546ed3f5c81c780d3ab86ada14824237 - +End diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/heredoc_huge.tests b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc_huge.tests new file mode 100755 index 00000000..c2ec2817 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/heredoc_huge.tests @@ -0,0 +1,9 @@ +# This creates 120k heredoc +echo 'cat <<HERE | md5sum' >"$0.tmp" +yes "123456789 123456789 123456789 123456789" | head -3000 >>"$0.tmp" +echo 'HERE' >>"$0.tmp" + +yes "123456789 123456789 123456789 123456789" | head -3000 | md5sum +. "$0.tmp" +rm "$0.tmp" +echo End diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/if_false_exitcode.right b/release/src/router/busybox/shell/hush_test/hush-misc/if_false_exitcode.right new file mode 100644 index 00000000..7b24a35f --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/if_false_exitcode.right @@ -0,0 +1 @@ +Ok:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests b/release/src/router/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests new file mode 100755 index 00000000..01b36b10 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/if_false_exitcode.tests @@ -0,0 +1,2 @@ +if false; then echo Bad; fi +echo Ok:$? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/pid.right b/release/src/router/busybox/shell/hush_test/hush-misc/pid.right new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/pid.right @@ -0,0 +1 @@ +0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/pid.tests b/release/src/router/busybox/shell/hush_test/hush-misc/pid.tests new file mode 100755 index 00000000..eaeaa717 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/pid.tests @@ -0,0 +1 @@ +test `(echo $$)` = `echo $$`; echo $? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/read.right b/release/src/router/busybox/shell/hush_test/hush-misc/read.right new file mode 100644 index 00000000..0e50e2a2 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/read.right @@ -0,0 +1,4 @@ +read +cat +echo "REPLY=$REPLY" +REPLY=exec <read.tests diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/read.tests b/release/src/router/busybox/shell/hush_test/hush-misc/read.tests new file mode 100755 index 00000000..ff1acbde --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/read.tests @@ -0,0 +1,4 @@ +exec <read.tests +read +cat +echo "REPLY=$REPLY" diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir1.right b/release/src/router/busybox/shell/hush_test/hush-misc/redir1.right new file mode 100644 index 00000000..15515d1a --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir1.right @@ -0,0 +1,12 @@ +Test 0: var:ok +File created:ok +Test 1: var:ok +File created:ok +Test 2: var:ok +File created:ok +Test 3: var:ok +File created:ok +Test 4: var:ok +File created:ok +Test 5: var:ok +File created:ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/redir1.tests new file mode 100755 index 00000000..ef2fbfb7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir1.tests @@ -0,0 +1,40 @@ +rm shell_test_$$ 2>/dev/null +var=bad +>shell_test_$$ var=ok +echo "Test 0: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=bad +var=ok >shell_test_$$ +echo "Test 1: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +true | var=bad >shell_test_$$ +echo "Test 2: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=bad +{ var=ok >shell_test_$$; } +echo "Test 3: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +{ var=bad >shell_test_$$; } & +# cant use usleep as it isnt standard in $PATH -- +# we fail when testing busybox compiled solely as "hush" +wait +echo "Test 4: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +( var=bad >shell_test_$$ ) +echo "Test 5: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir2.right b/release/src/router/busybox/shell/hush_test/hush-misc/redir2.right new file mode 100644 index 00000000..7326d960 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir2.right @@ -0,0 +1 @@ +Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/redir2.tests new file mode 100755 index 00000000..81983cae --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir2.tests @@ -0,0 +1,2 @@ +echo NOT SHOWN \2>/dev/null +echo Ok diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir3.right b/release/src/router/busybox/shell/hush_test/hush-misc/redir3.right new file mode 100644 index 00000000..3d20bbf6 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir3.right @@ -0,0 +1,14 @@ +hush: can't open '/does/not/exist': No such file or directory +One:1 +hush: can't open '/cant/be/created': No such file or directory +One:1 +Ok +hush: can't open '/cant/be/created': No such file or directory +Zero:0 +hush: can't open '/cant/be/created': No such file or directory +One:1 +hush: can't open '/cant/be/created': No such file or directory +One:1 +hush: can't open '/cant/be/created': No such file or directory +Zero:0 +Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir3.tests b/release/src/router/busybox/shell/hush_test/hush-misc/redir3.tests new file mode 100755 index 00000000..7c28e432 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir3.tests @@ -0,0 +1,9 @@ +echo Error >/does/not/exist; echo One:$? +t=BAD +t=Ok >>/cant/be/created; echo One:$? +echo $t +! >/cant/be/created; echo Zero:$? +exec >/cant/be/created; echo One:$? +exec /bin/true >/cant/be/created; echo One:$? +! exec /bin/true >/cant/be/created; echo Zero:$? +echo Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir4.right b/release/src/router/busybox/shell/hush_test/hush-misc/redir4.right new file mode 100644 index 00000000..ead25f60 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir4.right @@ -0,0 +1,18 @@ +shell_test +\shell_test +\shell_test +\shell_test +Here1 +Ok1 +Here2 +Ok2 +Here3 +Ok3 +Here4 +Ok4 +Now with variable refs +shell_test_1 +\shell_test_1 +\shell_test_1 +\shell_test_1 +Done diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/redir4.tests b/release/src/router/busybox/shell/hush_test/hush-misc/redir4.tests new file mode 100755 index 00000000..c50b8ced --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/redir4.tests @@ -0,0 +1,85 @@ +rm *shell_test* 2>/dev/null + +>\shell_test +echo *shell_test* +rm *shell_test* + +>\\shell_test +echo *shell_test* +rm *shell_test* + +>"\shell_test" +echo *shell_test* +rm *shell_test* + +>"\\shell_test" +echo *shell_test* +rm *shell_test* + + +cat <<\shell_test +Here1 +shell_test +echo Ok1 + +cat <<\\shell_test +Here2 +\shell_test +echo Ok2 + +cat <<"\shell_test" +Here3 +\shell_test +echo Ok3 + +cat <<"\\shell_test" +Here4 +\shell_test +echo Ok4 + + +echo Now with variable refs +i=1 + + +>\shell_test_$i +echo *shell_test* +rm *shell_test* + +>\\shell_test_$i +echo *shell_test* +rm *shell_test* + +>"\shell_test_$i" +echo *shell_test* +rm *shell_test* + +>"\\shell_test_$i" +echo *shell_test* +rm *shell_test* + +echo Done;exit +# UNFIXED BUG. bash apparently will expand $i even in terminating delimiter. +# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html +# does not mandate this behavior. +# This is not likely to be used much in real-world. + +cat <<\shell_test_$i +Here1 +shell_test_$i +echo Ok1 + +cat <<\\shell_test_$i +Here2 +\shell_test_$i +echo Ok2 + +cat <<"\shell_test_$i" +Here3 +\shell_test_$i +echo Ok3 + +cat <<"\\shell_test_$i" +Here4 +\shell_test_$i +echo Ok4 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/shift.right b/release/src/router/busybox/shell/hush_test/hush-misc/shift.right new file mode 100644 index 00000000..d281e358 --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/shift.tests b/release/src/router/busybox/shell/hush_test/hush-misc/shift.tests new file mode 100755 index 00000000..53ef249f --- /dev/null +++ b/release/src/router/busybox/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/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err.right b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err.right new file mode 100644 index 00000000..680e7967 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err.right @@ -0,0 +1,4 @@ +shown +hush: syntax error: unterminated ' +test +not shown diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err.tests b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err.tests new file mode 100755 index 00000000..d10ed42e --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err.tests @@ -0,0 +1,3 @@ +echo shown +echo test `echo 'aa` +echo not shown diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err_negate.right b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err_negate.right new file mode 100644 index 00000000..8c701062 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err_negate.right @@ -0,0 +1,2 @@ +bash 3.2 fails this +hush: syntax error: ! ! command diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err_negate.tests b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err_negate.tests new file mode 100755 index 00000000..d61b1b09 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/syntax_err_negate.tests @@ -0,0 +1,2 @@ +echo bash 3.2 fails this +! ! true diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/until1.right b/release/src/router/busybox/shell/hush_test/hush-misc/until1.right new file mode 100644 index 00000000..be2daad9 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/until1.right @@ -0,0 +1,3 @@ +1 +1 +Ok:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/until1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/until1.tests new file mode 100755 index 00000000..10ab2838 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/until1.tests @@ -0,0 +1,11 @@ +x=1 +until test "$x" = 4; do echo $x; x=4; done + +# We had a bug in multi-line form +x=1 +until test "$x" = 4; do + echo $x + x=4 +done + +echo Ok:$? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/while1.right b/release/src/router/busybox/shell/hush_test/hush-misc/while1.right new file mode 100644 index 00000000..7c4d7beb --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/while1.right @@ -0,0 +1 @@ +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/while1.tests b/release/src/router/busybox/shell/hush_test/hush-misc/while1.tests new file mode 100755 index 00000000..11e201e6 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/while1.tests @@ -0,0 +1,2 @@ +while false; do echo NOT SHOWN; done +echo OK:$? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/while2.right b/release/src/router/busybox/shell/hush_test/hush-misc/while2.right new file mode 100644 index 00000000..07207cc8 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/while2.right @@ -0,0 +1,2 @@ +Hello +OK:0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/while2.tests b/release/src/router/busybox/shell/hush_test/hush-misc/while2.tests new file mode 100755 index 00000000..2247adc7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/while2.tests @@ -0,0 +1,2 @@ +while echo Hello; false; do echo NOT SHOWN; done +echo OK:$? diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/while_in_subshell.right b/release/src/router/busybox/shell/hush_test/hush-misc/while_in_subshell.right new file mode 100644 index 00000000..290d39b7 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/while_in_subshell.right @@ -0,0 +1 @@ +OK: 0 diff --git a/release/src/router/busybox/shell/hush_test/hush-misc/while_in_subshell.tests b/release/src/router/busybox/shell/hush_test/hush-misc/while_in_subshell.tests new file mode 100755 index 00000000..def8e092 --- /dev/null +++ b/release/src/router/busybox/shell/hush_test/hush-misc/while_in_subshell.tests @@ -0,0 +1,2 @@ +(while true; do exit; done) +echo OK: $? |