From 4aca87515a5083ae0e31ce3177189fd43b6d05ac Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 3 Jan 2015 13:58:15 +0100 Subject: patch to Vanilla Tomato 1.28 --- .../busybox/shell/ash_test/ash-alias/alias.right | 4 + .../busybox/shell/ash_test/ash-alias/alias.tests | 37 +++ .../busybox/shell/ash_test/ash-arith/README.ash | 1 + .../shell/ash_test/ash-arith/arith-bash1.right | 2 + .../shell/ash_test/ash-arith/arith-bash1.tests | 5 + .../shell/ash_test/ash-arith/arith-for.right | 74 +++++ .../shell/ash_test/ash-arith/arith-for.testsx | 94 +++++++ .../busybox/shell/ash_test/ash-arith/arith.right | 138 ++++++++++ .../busybox/shell/ash_test/ash-arith/arith.tests | 302 +++++++++++++++++++++ .../busybox/shell/ash_test/ash-arith/arith1.sub | 40 +++ .../busybox/shell/ash_test/ash-arith/arith2.sub | 57 ++++ .../shell/ash_test/ash-heredoc/heredoc.right | 21 ++ .../shell/ash_test/ash-heredoc/heredoc.tests | 94 +++++++ .../busybox/shell/ash_test/ash-invert/invert.right | 10 + .../busybox/shell/ash_test/ash-invert/invert.tests | 19 ++ .../busybox/shell/ash_test/ash-misc/last_amp.right | 2 + .../busybox/shell/ash_test/ash-misc/last_amp.tests | 8 + .../busybox/shell/ash_test/ash-misc/shift1.right | 9 + .../busybox/shell/ash_test/ash-misc/shift1.tests | 10 + .../ash_test/ash-quoting/dollar_squote_bash1.right | 9 + .../ash_test/ash-quoting/dollar_squote_bash1.tests | 7 + .../busybox/shell/ash_test/ash-read/read_ifs.right | 7 + .../busybox/shell/ash_test/ash-read/read_ifs.tests | 7 + .../busybox/shell/ash_test/ash-read/read_n.right | 3 + .../busybox/shell/ash_test/ash-read/read_n.tests | 3 + .../busybox/shell/ash_test/ash-read/read_r.right | 2 + .../busybox/shell/ash_test/ash-read/read_r.tests | 2 + .../busybox/shell/ash_test/ash-read/read_t.right | 4 + .../busybox/shell/ash_test/ash-read/read_t.tests | 10 + .../busybox/shell/ash_test/ash-redir/redir.right | 1 + .../busybox/shell/ash_test/ash-redir/redir.tests | 6 + .../busybox/shell/ash_test/ash-redir/redir2.right | 1 + .../busybox/shell/ash_test/ash-redir/redir2.tests | 5 + .../busybox/shell/ash_test/ash-redir/redir3.right | 3 + .../busybox/shell/ash_test/ash-redir/redir3.tests | 5 + .../busybox/shell/ash_test/ash-redir/redir4.right | 1 + .../busybox/shell/ash_test/ash-redir/redir4.tests | 72 +++++ .../busybox/shell/ash_test/ash-redir/redir5.right | 2 + .../busybox/shell/ash_test/ash-redir/redir5.tests | 3 + .../busybox/shell/ash_test/ash-redir/redir6.right | 2 + .../busybox/shell/ash_test/ash-redir/redir6.tests | 3 + .../busybox/shell/ash_test/ash-signals/reap1.right | 1 + .../busybox/shell/ash_test/ash-signals/reap1.tests | 14 + .../shell/ash_test/ash-signals/signal1.right | 20 ++ .../shell/ash_test/ash-signals/signal1.tests | 23 ++ .../shell/ash_test/ash-signals/signal2.right | 3 + .../shell/ash_test/ash-signals/signal2.tests | 18 ++ .../shell/ash_test/ash-signals/signal3.right | 4 + .../shell/ash_test/ash-signals/signal3.tests | 17 ++ .../ash-standalone/noexec_gets_no_env.right | 4 + .../ash-standalone/noexec_gets_no_env.tests | 5 + .../ash-standalone/nofork_trashes_getopt.right | 1 + .../ash-standalone/nofork_trashes_getopt.tests | 6 + .../busybox/shell/ash_test/ash-vars/var1.right | 6 + .../busybox/shell/ash_test/ash-vars/var1.tests | 14 + .../busybox/shell/ash_test/ash-vars/var2.right | 1 + .../busybox/shell/ash_test/ash-vars/var2.tests | 1 + .../shell/ash_test/ash-vars/var_bash1.right | 14 + .../shell/ash_test/ash-vars/var_bash1.tests | 18 ++ .../shell/ash_test/ash-vars/var_bash2.right | 10 + .../shell/ash_test/ash-vars/var_bash2.tests | 24 ++ .../shell/ash_test/ash-vars/var_bash3.right | 20 ++ .../shell/ash_test/ash-vars/var_bash3.tests | 41 +++ .../busybox/shell/ash_test/ash-vars/var_leak.right | 2 + .../busybox/shell/ash_test/ash-vars/var_leak.tests | 9 + .../shell/ash_test/ash-vars/var_posix1.right | 17 ++ .../shell/ash_test/ash-vars/var_posix1.tests | 21 ++ .../src/router/busybox/shell/ash_test/printenv.c | 67 +++++ release/src/router/busybox/shell/ash_test/recho.c | 63 +++++ release/src/router/busybox/shell/ash_test/run-all | 74 +++++ release/src/router/busybox/shell/ash_test/zecho.c | 39 +++ 71 files changed, 1642 insertions(+) create mode 100644 release/src/router/busybox/shell/ash_test/ash-alias/alias.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-alias/alias.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-arith/README.ash create mode 100644 release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-arith/arith-for.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-arith/arith-for.testsx create mode 100644 release/src/router/busybox/shell/ash_test/ash-arith/arith.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-arith/arith.tests create mode 100755 release/src/router/busybox/shell/ash_test/ash-arith/arith1.sub create mode 100755 release/src/router/busybox/shell/ash_test/ash-arith/arith2.sub create mode 100644 release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-invert/invert.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-invert/invert.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-misc/last_amp.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-misc/last_amp.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-misc/shift1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-misc/shift1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-read/read_ifs.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-read/read_ifs.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-read/read_n.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-read/read_n.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-read/read_r.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-read/read_r.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-read/read_t.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-read/read_t.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-redir/redir.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-redir/redir.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-redir/redir2.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-redir/redir2.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-redir/redir3.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-redir/redir3.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-redir/redir4.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-redir/redir4.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-redir/redir5.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-redir/redir5.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-redir/redir6.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-redir/redir6.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-signals/reap1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-signals/reap1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-signals/signal1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-signals/signal1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-signals/signal2.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-signals/signal2.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-signals/signal3.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-signals/signal3.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var2.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var2.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var_bash1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var_bash1.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var_bash2.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var_bash2.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var_bash3.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var_bash3.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var_leak.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var_leak.tests create mode 100644 release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.right create mode 100755 release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.tests create mode 100644 release/src/router/busybox/shell/ash_test/printenv.c create mode 100644 release/src/router/busybox/shell/ash_test/recho.c create mode 100755 release/src/router/busybox/shell/ash_test/run-all create mode 100644 release/src/router/busybox/shell/ash_test/zecho.c (limited to 'release/src/router/busybox/shell/ash_test') diff --git a/release/src/router/busybox/shell/ash_test/ash-alias/alias.right b/release/src/router/busybox/shell/ash_test/ash-alias/alias.right new file mode 100644 index 00000000..0667b218 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-alias/alias.right @@ -0,0 +1,4 @@ +alias: 0 +alias: 0 +./alias.tests: line 25: qfoo: not found +quux diff --git a/release/src/router/busybox/shell/ash_test/ash-alias/alias.tests b/release/src/router/busybox/shell/ash_test/ash-alias/alias.tests new file mode 100755 index 00000000..8d07b0b2 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-alias/alias.tests @@ -0,0 +1,37 @@ +# place holder for future alias testing +#ash# shopt -s expand_aliases + +# alias/unalias tests originally in builtins.tests + +unalias -a +# this should return success, according to POSIX.2 +alias +echo alias: $? +alias foo=bar +unalias foo +# this had better return success, according to POSIX.2 +alias +echo alias: $? + +# bug in all versions through bash-2.05b + +unalias qfoo qbar qbaz quux 2>/dev/null + +alias qfoo=qbar +alias qbar=qbaz +alias qbaz=quux +alias quux=qfoo + +qfoo + +unalias qfoo qbar qbaz quux + +unalias -a + +alias foo='echo ' +alias bar=baz +alias baz=quux + +foo bar + +unalias foo bar baz diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/README.ash b/release/src/router/busybox/shell/ash_test/ash-arith/README.ash new file mode 100644 index 00000000..7da22ef7 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/README.ash @@ -0,0 +1 @@ +there is no support for (( )) constructs in ash diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.right b/release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.right new file mode 100644 index 00000000..b261da18 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.right @@ -0,0 +1,2 @@ +1 +0 diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.tests b/release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.tests new file mode 100755 index 00000000..b37b7302 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith-bash1.tests @@ -0,0 +1,5 @@ +# checks for [[ ]] + +# && and || +[[ a && "" ]]; echo $? +[[ a || "" ]]; echo $? diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith-for.right b/release/src/router/busybox/shell/ash_test/ash-arith/arith-for.right new file mode 100644 index 00000000..88dbc15f --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith-for.right @@ -0,0 +1,74 @@ +0 +1 +2 +0 +1 +2 +0 +1 +2 +0 +2 +4 +fx is a function +fx () +{ + i=0; + for ((1; i < 3; i++ )) + do + echo $i; + done; + for ((i=0; 1; i++ )) + do + if (( i >= 3 )); then + break; + fi; + echo $i; + done; + for ((i=0; i<3; 1)) + do + echo $i; + (( i++ )); + done; + i=0; + for ((1; 1; 1)) + do + if (( i > 2 )); then + break; + fi; + echo $i; + (( i++ )); + done; + i=0; + for ((1; 1; 1)) + do + if (( i > 2 )); then + break; + fi; + echo $i; + (( i++ )); + done +} +0 +1 +2 +0 +1 +2 +0 +1 +2 +0 +1 +2 +0 +1 +2 +./arith-for.tests: line 77: syntax error: arithmetic expression required +./arith-for.tests: line 77: syntax error: `(( i=0; "i < 3" ))' +2 +./arith-for.tests: line 83: syntax error: `;' unexpected +./arith-for.tests: line 83: syntax error: `(( i=0; i < 3; i++; 7 ))' +2 +20 +20 diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith-for.testsx b/release/src/router/busybox/shell/ash_test/ash-arith/arith-for.testsx new file mode 100755 index 00000000..4fa30ff9 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith-for.testsx @@ -0,0 +1,94 @@ +fx() +{ +i=0 +for (( ; i < 3; i++ )) +do + echo $i +done + +for (( i=0; ; i++ )) +do + if (( i >= 3 )); then + break; + fi + echo $i +done + +for (( i=0; i<3; )) +do + echo $i + (( i++ )) +done + +i=0 +for (( ; ; )) +do + if (( i > 2 )); then + break; + fi + echo $i; + (( i++ )) +done + +i=0 +for ((;;)) +do + if (( i > 2 )); then + break; + fi + echo $i; + (( i++ )) +done +} + +for (( i=0; "i < 3" ; i++ )) +do + echo $i +done + +i=0 +for (( ; "i < 3"; i++ )) +do + echo $i +done + +for (( i=0; ; i++ )) +do + if (( i >= 3 )); then + break; + fi + echo $i +done + +for ((i = 0; ;i++ )) +do + echo $i + if (( i < 3 )); then + (( i++ )) + continue; + fi + break +done + +type fx +fx + +# errors +for (( i=0; "i < 3" )) +do + echo $i +done +echo $? + +for (( i=0; i < 3; i++; 7 )) +do + echo $i +done +echo $? + +# one-liners added in post-bash-2.04 +for ((i=0; i < 20; i++)) do : ; done +echo $i + +for ((i=0; i < 20; i++)) { : ; } +echo $i diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith.right b/release/src/router/busybox/shell/ash_test/ash-arith/arith.right new file mode 100644 index 00000000..3ea7ce68 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith.right @@ -0,0 +1,138 @@ +Format: 'expected actual' +163 163 +4 4 +16 16 +8 8 +2 2 +4 4 +2 2 +2 2 +1 1 +0 0 +0 0 +0 0 +1 1 +1 1 +2 2 +-3 -3 +-2 -2 +1 1 +0 0 +2 2 +131072 131072 +29 29 +33 33 +49 49 +1 1 +1 1 +0 0 +0 0 +1 1 +1 1 +1 1 +2 2 +3 3 +1 1 +58 58 +2 2 +60 60 +1 1 +256 256 +16 16 +62 62 +4 4 +29 29 +5 5 +-4 -4 +4 4 +1 1 +32 32 +32 32 +1 1 +1 1 +32 32 +20 20 +30 30 +20 20 +30 30 +./arith.tests: line 117: syntax error: 1 ? 20 : x+=2 +6 6 +6,5,3 6,5,3 +263 263 +255 255 +40 40 +./arith.tests: line 163: syntax error: 7 = 43 +./arith.tests: line 165: divide by zero +./arith.tests: let: line 166: syntax error: jv += $iv +./arith.tests: line 167: syntax error: jv += $iv +./arith.tests: let: line 168: syntax error: rv = 7 + (43 * 6 +abc +def +ghi +./arith.tests: line 191: syntax error: ( 4 + A ) + 4 +16 16 +./arith.tests: line 196: syntax error: 4 ? : 3 + 5 +./arith.tests: line 197: syntax error: 1 ? 20 +./arith.tests: line 198: syntax error: 4 ? 20 : +9 9 +./arith.tests: line 205: syntax error: 0 && B=42 +./arith.tests: line 208: syntax error: 1 || B=88 +9 9 +9 9 +9 9 +7 7 +7 +4 4 +32767 32767 +32768 32768 +131072 131072 +2147483647 2147483647 +1 1 +4 4 +4 4 +5 5 +5 5 +4 4 +3 3 +3 3 +4 4 +4 4 +./arith.tests: line 257: syntax error: 7-- +./arith.tests: line 259: syntax error: --x=7 +./arith.tests: line 260: syntax error: ++x=7 +./arith.tests: line 262: syntax error: x++=7 +./arith.tests: line 263: syntax error: x--=7 +4 4 +7 7 +-7 -7 +./arith1.sub: line 2: syntax error: 4-- +./arith1.sub: line 3: syntax error: 4++ +./arith1.sub: line 4: syntax error: 4 -- +./arith1.sub: line 5: syntax error: 4 ++ +6 6 +3 3 +7 7 +4 4 +0 0 +3 3 +7 7 +2 2 +-2 -2 +1 1 +./arith1.sub: line 37: syntax error: +++7 +./arith2.sub: line 2: syntax error: --7 +./arith2.sub: line 3: syntax error: ++7 +./arith2.sub: line 4: syntax error: -- 7 +./arith2.sub: line 5: syntax error: ++ 7 +5 5 +1 1 +4 4 +0 0 +./arith2.sub: line 42: syntax error: -- - 7 +./arith2.sub: line 47: syntax error: ++ + 7 +8 12 +./arith.tests: line 290: syntax error: a b +42 +42 +42 +./arith.tests: line 302: a[b[c]d]=e: not found diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith.tests b/release/src/router/busybox/shell/ash_test/ash-arith/arith.tests new file mode 100755 index 00000000..d65758e7 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith.tests @@ -0,0 +1,302 @@ +#ash# set +o posix +#ash# declare -i iv jv + +echo "Format: 'expected actual'" + +iv=$(( 3 + 5 * 32 )) +echo 163 $iv +#ash# iv=iv+3 +#ash# echo 166 $iv +iv=2 +jv=iv + +let "jv *= 2" +echo 4 $jv +jv=$(( $jv << 2 )) +echo 16 $jv + +let jv="$jv / 2" +echo 8 $jv +#ash# jv="jv >> 2" + let jv="jv >> 2" +echo 2 $jv + +iv=$((iv+ $jv)) +echo 4 $iv +echo 2 $((iv -= jv)) +echo 2 $iv +echo 1 $(( iv == jv )) +echo 0 $(( iv != $jv )) +echo 0 $(( iv < jv )) +echo 0 $(( $iv > $jv )) +echo 1 $(( iv <= $jv )) +echo 1 $(( $iv >= jv )) + +echo 2 $jv +echo -3 $(( ~$jv )) +echo -2 $(( ~1 )) +echo 1 $(( ! 0 )) + +echo 0 $(( jv % 2 )) +echo 2 $(( $iv % 4 )) + +echo 131072 $(( iv <<= 16 )) +echo 29 $(( iv %= 33 )) + +echo 33 $(( 33 & 55 )) +echo 49 $(( 33 | 17 )) + +echo 1 $(( iv && $jv )) +echo 1 $(( $iv || jv )) + +echo 0 $(( iv && 0 )) +echo 0 $(( iv & 0 )) +echo 1 $(( iv && 1 )) +echo 1 $(( iv & 1 )) + +echo 1 $(( $jv || 0 )) +echo 2 $(( jv | 0 )) +echo 3 $(( jv | 1 )) +echo 1 $(( $jv || 1 )) + +let 'iv *= jv' +echo 58 $iv +echo 2 $jv +let "jv += $iv" +echo 60 $jv + +echo 1 $(( jv /= iv )) +echo 256 $(( jv <<= 8 )) +echo 16 $(( jv >>= 4 )) + +echo 62 $(( iv |= 4 )) +echo 4 $(( iv &= 4 )) + +echo 29 $(( iv += (jv + 9))) +echo 5 $(( (iv + 4) % 7 )) + +# unary plus, minus +echo -4 $(( +4 - 8 )) +echo 4 $(( -4 + 8 )) + +# conditional expressions +echo 1 $(( 4<5 ? 1 : 32)) +echo 32 $(( 4>5 ? 1 : 32)) +echo 32 $(( 4>(2+3) ? 1 : 32)) +echo 1 $(( 4<(2+3) ? 1 : 32)) +echo 1 $(( (2+2)<(2+3) ? 1 : 32)) +echo 32 $(( (2+2)>(2+3) ? 1 : 32)) + +# check that the unevaluated part of the ternary operator does not do +# evaluation or assignment +x=i+=2 +y=j+=2 +#ash# declare -i i=1 j=1 + i=1 + j=1 +echo 20 $((1 ? 20 : (x+=2))) +#ash# echo $i,$x # ash mishandles this +echo 30 $((0 ? (y+=2) : 30)) +#ash# echo $j,$y # ash mishandles this + +x=i+=2 +y=j+=2 +#ash# declare -i i=1 j=1 + i=1 + j=1 +echo 20 $((1 ? 20 : (x+=2))) +#ash# echo $i,$x # ash mishandles this +echo 30 $((0 ? (y+=2) : 30)) +#ash# echo $i,$y # ash mishandles this + +# check precedence of assignment vs. conditional operator +# should be an error +#ash# declare -i x=2 + x=2 +#ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: +( y=$((1 ? 20 : x+=2)) ) + +# check precedence of assignment vs. conditional operator +#ash# declare -i x=2 + x=2 +# ash says "line NNN: syntax error: 0 ? x+=2 : 20" +#ash# echo 20 $((0 ? x+=2 : 20)) + +# associativity of assignment-operator operator +#ash# declare -i i=1 j=2 k=3 +i=1 +j=2 +k=3 +echo 6 $((i += j += k)) +echo 6,5,3 $i,$j,$k + +# octal, hex +echo 263 $(( 0x100 | 007 )) +echo 255 $(( 0xff )) +#ash# echo 255 $(( 16#ff )) +#ash# echo 127 $(( 16#FF/2 )) +#ash# echo 36 $(( 8#44 )) + +echo 40 $(( 8 ^ 32 )) + +#ash# # other bases +#ash# echo 10 $(( 16#a )) +#ash# echo 10 $(( 32#a )) +#ash# echo 10 $(( 56#a )) +#ash# echo 10 $(( 64#a )) +#ash# +#ash# echo 10 $(( 16#A )) +#ash# echo 10 $(( 32#A )) +#ash# echo 36 $(( 56#A )) +#ash# echo 36 $(( 64#A )) +#ash# +#ash# echo 62 $(( 64#@ )) +#ash# echo 63 $(( 64#_ )) + +#ash# # weird bases (error) +#ash# echo $(( 3425#56 )) + +#ash# # missing number after base +#ash# echo 0 $(( 2# )) + +# these should generate errors +( echo $(( 7 = 43 )) ) +#ash# echo $(( 2#44 )) +( echo $(( 44 / 0 )) ) +( let 'jv += $iv' ) +( echo $(( jv += \$iv )) ) +( let 'rv = 7 + (43 * 6' ) + +#ash# # more errors +#ash# declare -i i +#ash# i=0#4 +#ash# i=2#110#11 + +((echo abc; echo def;); echo ghi) + +#ash# if (((4+4) + (4 + 7))); then +#ash# echo ok +#ash# fi + +#ash# (()) # make sure the null expression works OK + +#ash# a=(0 2 4 6) +#ash# echo 6 $(( a[1] + a[2] )) +#ash# echo 1 $(( (a[1] + a[2]) == a[3] )) +#ash# (( (a[1] + a[2]) == a[3] )) ; echo 0 $? + +# test pushing and popping the expression stack +unset A +A="4 + " +( echo A $(( ( 4 + A ) + 4 )) ) +A="3 + 5" +echo 16 $(( ( 4 + A ) + 4 )) + +# badly-formed conditional expressions +( echo $(( 4 ? : $A )) ) +( echo $(( 1 ? 20 )) ) +( echo $(( 4 ? 20 : )) ) + +# precedence and short-circuit evaluation +B=9 +echo 9 $B + +# error +( echo $(( 0 && B=42 )); echo 9 $B ) + +# error +( echo $(( 1 || B=88 )); echo 9 $B ) + +# ash mistakenly evaluates B=... below +#ash# echo 0 $(( 0 && (B=42) )) +echo 9 $B +#ash# echo 0 $(( (${$} - $$) && (B=42) )) +echo 9 $B +#ash# echo 1 $(( 1 || (B=88) )) +echo 9 $B + + +# until command with (( )) command +x=7 + +echo 7 $x +#ash# until (( x == 4 )) + until test "$x" = 4 +do + echo $x + x=4 +done + +echo 4 $x + +# exponentiation +echo 32767 $(( 2**15 - 1)) +echo 32768 $(( 2**(16-1))) +echo 131072 $(( 2**16*2 )) +echo 2147483647 $(( 2**31-1)) +echo 1 $(( 2**0 )) + +# {pre,post}-{inc,dec}rement and associated errors + +x=4 + +echo 4 $x +echo 4 $(( x++ )) +echo 5 $x +echo 5 $(( x-- )) +echo 4 $x + +echo 3 $(( --x )) +echo 3 $x + +echo 4 $(( ++x )) +echo 4 $x + +# bash 3.2 apparently thinks that ++7 is 7 +#ash# echo 7 $(( ++7 )) +( echo $(( 7-- )) ) + +( echo $(( --x=7 )) ) +( echo $(( ++x=7 )) ) + +( echo $(( x++=7 )) ) +( echo $(( x--=7 )) ) + +echo 4 $x + +echo 7 $(( +7 )) +echo -7 $(( -7 )) + +# bash 3.2 apparently thinks that ++7 is 7 +#ash# echo $(( ++7 )) +#ash# echo $(( --7 )) + +${THIS_SH} ./arith1.sub +${THIS_SH} ./arith2.sub + +x=4 +y=7 + +#ash# (( x=8 , y=12 )) + x=8 + y=12 +echo $x $y + +#ash# # should be an error +#ash# (( x=9 y=41 )) + +# These are errors +unset b +( echo $((a b)) ) +#ash# ((a b)) + +n=42 +printf "%d\n" $n +printf "%i\n" $n +#ash# echo $(( 8#$(printf "%o\n" $n) )) +printf "%u\n" $n +#ash# echo $(( 16#$(printf "%x\n" $n) )) +#ash# echo $(( 16#$(printf "%X\n" $n) )) + +# causes longjmp botches through bash-2.05b +a[b[c]d]=e diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith1.sub b/release/src/router/busybox/shell/ash_test/ash-arith/arith1.sub new file mode 100755 index 00000000..80aa9992 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith1.sub @@ -0,0 +1,40 @@ +# test of redone post-increment and post-decrement code +( echo $(( 4-- )) ) +( echo $(( 4++ )) ) +( echo $(( 4 -- )) ) +( echo $(( 4 ++ )) ) + +#ash# (( array[0]++ )) +#ash# echo ${array} + +#ash# (( array[0] ++ )) +#ash# echo ${array} + +#ash# (( a++ )) +#ash# echo $a +#ash# (( a ++ )) +#ash# echo $a + a=2 + +echo 6 $(( a ++ + 4 )) +echo 3 $a + +echo 7 $(( a+++4 )) +echo 4 $a + +echo 0 $(( a---4 )) +echo 3 $a + +echo 7 $(( a -- + 4 )) +echo 2 $a + +echo -2 $(( a -- - 4 )) +echo 1 $a + +#ash# (( ++ + 7 )) + +#ash# (( ++ )) +( echo $(( +++7 )) ) +# bash 3.2 apparently thinks that ++ +7 is 7 +#ash# echo $(( ++ + 7 )) +#ash# (( -- )) diff --git a/release/src/router/busybox/shell/ash_test/ash-arith/arith2.sub b/release/src/router/busybox/shell/ash_test/ash-arith/arith2.sub new file mode 100755 index 00000000..f7e3c923 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-arith/arith2.sub @@ -0,0 +1,57 @@ +# bash 3.2 apparently thinks that ++7 is 7 etc +( echo $(( --7 )) ) +( echo $(( ++7 )) ) +( echo $(( -- 7 )) ) +( echo $(( ++ 7 )) ) + +#ash# ((++array[0] )) +#ash# echo 1 $array +#ash# (( ++ array[0] )) +#ash# echo 2 $array + +#ash# (( ++a )) +#ash# echo 1 $a +#ash# (( ++ a )) +#ash# echo 2 $a + +#ash# (( --a )) +#ash# echo 1 $a +#ash# (( -- a )) +#ash# echo 0 $a + a=0 + +echo 5 $(( 4 + ++a )) +echo 1 $a + +# ash doesn't handle it right... +#ash# echo 6 $(( 4+++a )) +#ash# echo 2 $a + a=2 + +# ash doesn't handle it right... +#ash# echo 3 $(( 4---a )) +#ash# echo 1 $a + a=1 + +echo 4 $(( 4 - -- a )) +echo 0 $a + +#ash# (( -- )) +# bash 3.2 apparently thinks that ---7 is -7 +#ash# echo $(( ---7 )) +( echo $(( -- - 7 )) ) + +#ash# (( ++ )) +# bash 3.2: 7 +#ash# echo 7 $(( ++7 )) +( echo $(( ++ + 7 )) ) + +# bash 3.2: -7 +#ash# echo -7 $(( ++-7 )) +# bash 3.2: -7 +#ash# echo -7 $(( ++ - 7 )) + +# bash 3.2: 7 +#ash# echo 7 $(( +--7 )) +# bash 3.2: 7 +#ash# echo 7 $(( -- + 7 )) diff --git a/release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.right b/release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.right new file mode 100644 index 00000000..baf11516 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.right @@ -0,0 +1,21 @@ +there +one - alpha +two - beta +three - gamma +hi\ +there$a +stuff +hi\ +there +EO\ +F +hi +tab 1 +tab 2 +tab 3 +abc +def ghi +jkl mno +fff is a shell function +hi +there diff --git a/release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.tests b/release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.tests new file mode 100755 index 00000000..b3cdc3f7 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-heredoc/heredoc.tests @@ -0,0 +1,94 @@ +# check order and content of multiple here docs + +cat << EOF1 << EOF2 +hi +EOF1 +there +EOF2 + +while read line1; do + read line2 <&3 + echo $line1 - $line2 +done < /tmp/bash-zzz << EOF +abc +EOF +cat >> /tmp/bash-zzz << EOF +def ghi +jkl mno +EOF +cat /tmp/bash-zzz +rm -f /tmp/bash-zzz + +# make sure command printing puts the here-document as the last redirection +# on the line, and the function export code preserves syntactic correctness +fff() +{ + ed /tmp/foo </dev/null +/^name/d +w +q +ENDOFINPUT +aa=1 +} + +type fff +#ash# export -f fff +#ash# ${THIS_SH} -c 'type fff' + +# check that end of file delimits a here-document +# THIS MUST BE LAST! + +cat << EOF +hi +there diff --git a/release/src/router/busybox/shell/ash_test/ash-invert/invert.right b/release/src/router/busybox/shell/ash_test/ash-invert/invert.right new file mode 100644 index 00000000..5a9239aa --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-invert/invert.right @@ -0,0 +1,10 @@ +1 +1 +1 +0 +0 +1 +0 +1 +0 +1 diff --git a/release/src/router/busybox/shell/ash_test/ash-invert/invert.tests b/release/src/router/busybox/shell/ash_test/ash-invert/invert.tests new file mode 100755 index 00000000..8393d95a --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-invert/invert.tests @@ -0,0 +1,19 @@ +# tests of return value inversion +# placeholder for future expansion + +# user subshells (...) did this wrong in bash versions before 2.04 + +! ( echo hello | grep h >/dev/null 2>&1 ); echo $? +! echo hello | grep h >/dev/null 2>&1 ; echo $? + +! true ; echo $? +! false; echo $? + +! (false) ; echo $? +! (true); echo $? + +! true | false ; echo $? +! false | true ; echo $? + +! (true | false) ; echo $? +! (false | true) ; echo $? diff --git a/release/src/router/busybox/shell/ash_test/ash-misc/last_amp.right b/release/src/router/busybox/shell/ash_test/ash-misc/last_amp.right new file mode 100644 index 00000000..3da21aec --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-misc/last_amp.right @@ -0,0 +1,2 @@ +3 +End diff --git a/release/src/router/busybox/shell/ash_test/ash-misc/last_amp.tests b/release/src/router/busybox/shell/ash_test/ash-misc/last_amp.tests new file mode 100755 index 00000000..16093764 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-misc/last_amp.tests @@ -0,0 +1,8 @@ +$THIS_SH -c 'echo 3&' +d=`date` +while test "`date`" = "$d"; do true; done +d1=`date` +$THIS_SH -c 'sleep 1&' +d2=`date` +test "$d1" = "$d2" || echo BAD +echo End diff --git a/release/src/router/busybox/shell/ash_test/ash-misc/shift1.right b/release/src/router/busybox/shell/ash_test/ash-misc/shift1.right new file mode 100644 index 00000000..b53453c3 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-misc/shift1.right @@ -0,0 +1,9 @@ +2 3 4 +0: shift: line 1: Illegal number: -1 +1 2 3 4 +2 3 4 +3 4 +4 + +1 2 3 4 +1 2 3 4 diff --git a/release/src/router/busybox/shell/ash_test/ash-misc/shift1.tests b/release/src/router/busybox/shell/ash_test/ash-misc/shift1.tests new file mode 100755 index 00000000..0992d9b1 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-misc/shift1.tests @@ -0,0 +1,10 @@ +$THIS_SH -c 'shift; echo "$@"' 0 1 2 3 4 +#We do abort on -1, but then we abort. bash executes echo. +$THIS_SH -c 'shift -1; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 0; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 1; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 2; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 3; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 4; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 5; echo "$@"' 0 1 2 3 4 +$THIS_SH -c 'shift 6; echo "$@"' 0 1 2 3 4 diff --git a/release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.right b/release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.right new file mode 100644 index 00000000..57536b1d --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.right @@ -0,0 +1,9 @@ +a b +a +b c +def +a'b c"d e\f +a3b c3b e33f +a\80b c08b +a3b c30b +x y diff --git a/release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.tests b/release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.tests new file mode 100755 index 00000000..93a56cac --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-quoting/dollar_squote_bash1.tests @@ -0,0 +1,7 @@ +echo $'a\tb' +echo $'a\nb' $'c\nd''ef' +echo $'a\'b' $'c\"d' $'e\\f' +echo $'a\63b' $'c\063b' $'e\0633f' +echo $'a\80b' $'c\608b' +echo $'a\x33b' $'c\x330b' +echo $'x\x9y' diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_ifs.right b/release/src/router/busybox/shell/ash_test/ash-read/read_ifs.right new file mode 100644 index 00000000..027ecd18 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_ifs.right @@ -0,0 +1,7 @@ +.a. .b. .c. +.a. .b. .c. +.a. .. .b,c. +.a. .. .b,c. +.a. .. .c. +.a. .. .c. .d. +.a. .. .b,c,d , ,. diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_ifs.tests b/release/src/router/busybox/shell/ash_test/ash-read/read_ifs.tests new file mode 100755 index 00000000..cf7cd934 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_ifs.tests @@ -0,0 +1,7 @@ +printf 'a\t\tb\tc\n' | ( IFS=$(printf "\t") read a b c; echo ".$a. .$b. .$c." ) +printf 'a\t\tb\tc\n' | ( IFS=$(printf " \t") read a b c; echo ".$a. .$b. .$c." ) +printf 'a,,b,c\n' | ( IFS="," read a b c; echo ".$a. .$b. .$c." ) +printf 'a,,b,c\n' | ( IFS=" ," read a b c; echo ".$a. .$b. .$c." ) +printf 'a ,, c\n' | ( IFS=" ," read a b c; echo ".$a. .$b. .$c." ) +printf 'a ,, c d\n' | ( IFS=" ," read a b c d; echo ".$a. .$b. .$c. .$d." ) +printf ' a,,b,c,d , ,\n' | ( IFS=" ," read a b c; echo ".$a. .$b. .$c." ) diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_n.right b/release/src/router/busybox/shell/ash_test/ash-read/read_n.right new file mode 100644 index 00000000..1f81af0b --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_n.right @@ -0,0 +1,3 @@ +test +tes +tes diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_n.tests b/release/src/router/busybox/shell/ash_test/ash-read/read_n.tests new file mode 100755 index 00000000..12423ba6 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_n.tests @@ -0,0 +1,3 @@ +echo 'test' | (read reply; echo "$reply") +echo 'test' | (read -n 3 reply; echo "$reply") +echo 'test' | (read -n3 reply; echo "$reply") diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_r.right b/release/src/router/busybox/shell/ash_test/ash-read/read_r.right new file mode 100644 index 00000000..3536bf75 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_r.right @@ -0,0 +1,2 @@ +testbest +test\ diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_r.tests b/release/src/router/busybox/shell/ash_test/ash-read/read_r.tests new file mode 100755 index 00000000..2c4cc610 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_r.tests @@ -0,0 +1,2 @@ +echo -e 'test\\\nbest' | (read reply; echo "$reply") +echo -e 'test\\\nbest' | (read -r reply; echo "$reply") diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_t.right b/release/src/router/busybox/shell/ash_test/ash-read/read_t.right new file mode 100644 index 00000000..04126cbe --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_t.right @@ -0,0 +1,4 @@ +>< +>< +>test< +>test< diff --git a/release/src/router/busybox/shell/ash_test/ash-read/read_t.tests b/release/src/router/busybox/shell/ash_test/ash-read/read_t.tests new file mode 100755 index 00000000..d65f1aea --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-read/read_t.tests @@ -0,0 +1,10 @@ +# bash 3.2 outputs: + +# >< +{ echo -n 'te'; sleep 2; echo 'st'; } | (read -t 1 reply; echo ">$reply<") +# >< +{ sleep 2; echo 'test'; } | (read -t 1 reply; echo ">$reply<") +# >test< +{ echo -n 'te'; sleep 1; echo 'st'; } | (read -t 2 reply; echo ">$reply<") +# >test< +{ sleep 1; echo 'test'; } | (read -t 2 reply; echo ">$reply<") diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir.right b/release/src/router/busybox/shell/ash_test/ash-redir/redir.right new file mode 100644 index 00000000..2a02d41c --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir.right @@ -0,0 +1 @@ +TEST diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir.tests b/release/src/router/busybox/shell/ash_test/ash-redir/redir.tests new file mode 100755 index 00000000..7a1a6680 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir.tests @@ -0,0 +1,6 @@ +# test: closed fds should stay closed +exec 1>&- +echo TEST >TEST +echo JUNK # lost: stdout is closed +cat TEST >&2 +rm TEST diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir2.right b/release/src/router/busybox/shell/ash_test/ash-redir/redir2.right new file mode 100644 index 00000000..d86bac9d --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir2.right @@ -0,0 +1 @@ +OK diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir2.tests b/release/src/router/busybox/shell/ash_test/ash-redir/redir2.tests new file mode 100755 index 00000000..61ccea30 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir2.tests @@ -0,0 +1,5 @@ +# ash once couldn't redirect above fd#9 +exec 1>/dev/null +(echo LOST1 >&22) 22>&1 +(echo LOST2 >&22) 22>&1 +(echo OK >&22) 22>&2 diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir3.right b/release/src/router/busybox/shell/ash_test/ash-redir/redir3.right new file mode 100644 index 00000000..fd641a8e --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir3.right @@ -0,0 +1,3 @@ +TEST +./redir3.tests: line 4: 9: Bad file descriptor +Output to fd#9: 1 diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir3.tests b/release/src/router/busybox/shell/ash_test/ash-redir/redir3.tests new file mode 100755 index 00000000..f50a7674 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir3.tests @@ -0,0 +1,5 @@ +# redirects to closed descriptors should not leave these descriptors" +# open afterwards +echo TEST 9>/dev/null +echo MUST ERROR OUT >&9 +echo "Output to fd#9: $?" diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir4.right b/release/src/router/busybox/shell/ash_test/ash-redir/redir4.right new file mode 100644 index 00000000..d86bac9d --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir4.right @@ -0,0 +1 @@ +OK diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir4.tests b/release/src/router/busybox/shell/ash_test/ash-redir/redir4.tests new file mode 100755 index 00000000..4bdf5ae2 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir4.tests @@ -0,0 +1,72 @@ +# ash uses fd 10 (usually) for reading the script +exec 13>&- +exec 12>&- +exec 11>&- +exec 10>&- +# some amount of input is prefetched. +# make sure final echo is far enough to not be prefetched. +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +############################################################### +echo "OK" diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir5.right b/release/src/router/busybox/shell/ash_test/ash-redir/redir5.right new file mode 100644 index 00000000..9d087776 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir5.right @@ -0,0 +1,2 @@ +./redir5.tests: line 2: 10: Bad file descriptor +OK diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir5.tests b/release/src/router/busybox/shell/ash_test/ash-redir/redir5.tests new file mode 100755 index 00000000..91b0c1ff --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir5.tests @@ -0,0 +1,3 @@ +# ash uses fd 10 (usually) for reading the script +echo LOST >&10 +echo OK diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir6.right b/release/src/router/busybox/shell/ash_test/ash-redir/redir6.right new file mode 100644 index 00000000..ed754df7 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir6.right @@ -0,0 +1,2 @@ +Hello +OK diff --git a/release/src/router/busybox/shell/ash_test/ash-redir/redir6.tests b/release/src/router/busybox/shell/ash_test/ash-redir/redir6.tests new file mode 100755 index 00000000..33b6d4cd --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-redir/redir6.tests @@ -0,0 +1,3 @@ +# we had a bug where this would hang +(head -n 1 /dev/null & + +sleep 1 & +PID=$! + +# We must exit the loop in one second. +# We had bug 5304: builtins never waited for exited children +while kill -0 $PID >/dev/null 2>&1; do + true +done +echo Ok diff --git a/release/src/router/busybox/shell/ash_test/ash-signals/signal1.right b/release/src/router/busybox/shell/ash_test/ash-signals/signal1.right new file mode 100644 index 00000000..cf403ac6 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-signals/signal1.right @@ -0,0 +1,20 @@ +got signal +trap -- 'echo got signal' USR1 +sent 1 signal +got signal +wait interrupted +trap -- 'echo got signal' USR1 +sent 2 signal +got signal +wait interrupted +trap -- 'echo got signal' USR1 +sent 3 signal +got signal +wait interrupted +trap -- 'echo got signal' USR1 +sent 4 signal +got signal +wait interrupted +trap -- 'echo got signal' USR1 +sent 5 signal +sleep completed diff --git a/release/src/router/busybox/shell/ash_test/ash-signals/signal1.tests b/release/src/router/busybox/shell/ash_test/ash-signals/signal1.tests new file mode 100755 index 00000000..098d21fd --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-signals/signal1.tests @@ -0,0 +1,23 @@ +trap "echo got signal" USR1 + +for try in 1 2 3 4 5; do + kill -USR1 $$ + sleep 0.2 + echo "sent $try signal" +done & + +sleep 2 & + +sleeping=true +while $sleeping; do + trap + if wait %%; then + echo "sleep completed" + sleeping=false + elif [ $? == 127 ]; then + echo "BUG: no processes to wait for?!" + sleeping=false + else + echo "wait interrupted" + fi +done diff --git a/release/src/router/busybox/shell/ash_test/ash-signals/signal2.right b/release/src/router/busybox/shell/ash_test/ash-signals/signal2.right new file mode 100644 index 00000000..a2af919c --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-signals/signal2.right @@ -0,0 +1,3 @@ +child sleeps +child exits as expected +parent exits diff --git a/release/src/router/busybox/shell/ash_test/ash-signals/signal2.tests b/release/src/router/busybox/shell/ash_test/ash-signals/signal2.tests new file mode 100755 index 00000000..df639ca2 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-signals/signal2.tests @@ -0,0 +1,18 @@ +#!/bin/sh + +$THIS_SH -c ' +cleanup() { + echo "child exits as expected" + exit +} +trap cleanup HUP +echo "child sleeps" +sleep 1 +echo "BAD exit from child!" +' & + +child=$! +sleep 0.1 # let child install handler first +kill -HUP $child +wait +echo "parent exits" diff --git a/release/src/router/busybox/shell/ash_test/ash-signals/signal3.right b/release/src/router/busybox/shell/ash_test/ash-signals/signal3.right new file mode 100644 index 00000000..3113ba5c --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-signals/signal3.right @@ -0,0 +1,4 @@ +child sleeps +child got HUP +child exits +parent exits diff --git a/release/src/router/busybox/shell/ash_test/ash-signals/signal3.tests b/release/src/router/busybox/shell/ash_test/ash-signals/signal3.tests new file mode 100755 index 00000000..b56c2d97 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-signals/signal3.tests @@ -0,0 +1,17 @@ +#!/bin/sh + +$THIS_SH -c ' +hup() { + echo "child got HUP" +} +trap hup HUP +echo "child sleeps" +sleep 1 +echo "child exits" +' & + +child=$! +sleep 0.1 # let child install handler first +kill -HUP $child +wait +echo "parent exits" diff --git a/release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right b/release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right new file mode 100644 index 00000000..8522dff3 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.right @@ -0,0 +1,4 @@ +VAR7=VAL +0 +VAR8=VAL +0 diff --git a/release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests b/release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests new file mode 100755 index 00000000..0d347bdc --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-standalone/noexec_gets_no_env.tests @@ -0,0 +1,5 @@ +export VAR7=VAL +env | grep ^VAR7= +echo $? +VAR8=VAL env | grep ^VAR8= +echo $? diff --git a/release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.right b/release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.right new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.right @@ -0,0 +1 @@ +0 diff --git a/release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.tests b/release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.tests new file mode 100755 index 00000000..f42c5073 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-standalone/nofork_trashes_getopt.tests @@ -0,0 +1,6 @@ +# In this test, rm is NOFORK and it modifies getopt internal state +rm -f non_existent_file +# Subsequent hexdump is run as NOEXEC, and thus still uses this state +hexdump &1 +echo "should be empty: '$VAR'" diff --git a/release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.right b/release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.right new file mode 100644 index 00000000..55f35798 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.right @@ -0,0 +1,17 @@ +abcdcd +abcdcd +abcdcd +cdcd +babcdcd +babcdcd +ababcdcd + +ababcd +ababcd +ababcd +abab +ababcdc +ababcdc +ababcdcd + +end diff --git a/release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.tests b/release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.tests new file mode 100755 index 00000000..4139e2cc --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/ash-vars/var_posix1.tests @@ -0,0 +1,21 @@ +var=ababcdcd + +echo ${var#ab} +echo ${var##ab} +echo ${var#a*b} +echo ${var##a*b} +echo ${var#?} +echo ${var##?} +echo ${var#*} +echo ${var##*} + +echo ${var%cd} +echo ${var%%cd} +echo ${var%c*d} +echo ${var%%c*d} +echo ${var%?} +echo ${var%%?} +echo ${var%*} +echo ${var%%*} + +echo end diff --git a/release/src/router/busybox/shell/ash_test/printenv.c b/release/src/router/busybox/shell/ash_test/printenv.c new file mode 100644 index 00000000..c4ccda8a --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/printenv.c @@ -0,0 +1,67 @@ +/* printenv -- minimal clone of BSD printenv(1). + + usage: printenv [varname] + + Chet Ramey + chet@po.cwru.edu +*/ + +/* Copyright (C) 1997-2002 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License along + with Bash; see the file COPYING. If not, write to the Free Software + Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + +#include +#include + +extern char **environ; + +int +main (argc, argv) + int argc; + char **argv; +{ + register char **envp, *eval; + int len; + + argv++; + argc--; + + /* printenv */ + if (argc == 0) + { + for (envp = environ; *envp; envp++) + puts (*envp); + exit(EXIT_SUCCESS); + } + + /* printenv varname */ + len = strlen (*argv); + for (envp = environ; *envp; envp++) + { + if (**argv == **envp && strncmp (*envp, *argv, len) == 0) + { + eval = *envp + len; + /* If the environment variable doesn't have an `=', ignore it. */ + if (*eval == '=') + { + puts (eval + 1); + exit(EXIT_SUCCESS); + } + } + } + exit(EXIT_FAILURE); +} diff --git a/release/src/router/busybox/shell/ash_test/recho.c b/release/src/router/busybox/shell/ash_test/recho.c new file mode 100644 index 00000000..fb48d9c4 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/recho.c @@ -0,0 +1,63 @@ +/* + recho -- really echo args, bracketed with <> and with invisible chars + made visible. + + Chet Ramey + chet@po.cwru.edu +*/ + +/* Copyright (C) 2002-2005 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License along + with Bash; see the file COPYING. If not, write to the Free Software + Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + +#include +#include + +void strprint(); + +int +main(argc, argv) +int argc; +char **argv; +{ + register int i; + + for (i = 1; i < argc; i++) { + printf("argv[%d] = <", i); + strprint(argv[i]); + printf(">\n"); + } + exit(EXIT_SUCCESS); +} + +void +strprint(str) +char *str; +{ + register unsigned char *s; + + for (s = (unsigned char *)str; s && *s; s++) { + if (*s < ' ') { + putchar('^'); + putchar(*s+64); + } else if (*s == 127) { + putchar('^'); + putchar('?'); + } else + putchar(*s); + } +} diff --git a/release/src/router/busybox/shell/ash_test/run-all b/release/src/router/busybox/shell/ash_test/run-all new file mode 100755 index 00000000..4d0f39a4 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/run-all @@ -0,0 +1,74 @@ +#!/bin/sh + +TOPDIR=$PWD + +test -x ash || { + echo "No ./ash - creating a link to ../../busybox" + ln -s ../../busybox ash +} +test -x printenv || gcc -O2 -o printenv printenv.c || exit $? +test -x recho || gcc -O2 -o recho recho.c || exit $? +test -x zecho || gcc -O2 -o zecho zecho.c || exit $? + +PATH="$PWD:$PATH" # for ash and recho/zecho/printenv +export PATH + +THIS_SH="$PWD/ash" +export THIS_SH + +do_test() +{ + test -d "$1" || return 0 + echo do_test "$1" + # $1 but with / replaced by # so that it can be used as filename part + noslash=`echo "$1" | sed 's:/:#:g'` + ( + 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" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \ + { echo "$1/$x: ok"; rm "$TOPDIR/$noslash-$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 + { + "$THIS_SH" "./$x" >"$name.xx" 2>&1 + diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \ + && rm -f "$name.xx" "$TOPDIR/$noslash-$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 ash-*` + # If you want to test ash against hush and msh testsuites + # (have to copy hush_test and msh_test dirs to current dir first): + #modules=`ls -d ash-* hush_test/hush-* msh_test/msh-*` + + 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 diff --git a/release/src/router/busybox/shell/ash_test/zecho.c b/release/src/router/busybox/shell/ash_test/zecho.c new file mode 100644 index 00000000..bf876f64 --- /dev/null +++ b/release/src/router/busybox/shell/ash_test/zecho.c @@ -0,0 +1,39 @@ +/* zecho - bare-bones echo */ + +/* Copyright (C) 1996-2002 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any later + version. + + Bash is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License along + with Bash; see the file COPYING. If not, write to the Free Software + Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + +#include +#include + +int +main(argc, argv) +int argc; +char **argv; +{ + argv++; + + while (*argv) { + (void)printf("%s", *argv); + if (*++argv) + putchar(' '); + } + + putchar('\n'); + exit(EXIT_SUCCESS); +} -- cgit v1.2.3-54-g00ecf