From: Denys Vlasenko Date: Fri, 4 Sep 2015 01:27:08 +0000 (+0200) Subject: ash: add tests adapted from hush glob tests. glob2.tests currently fails X-Git-Tag: 1_24_0~53 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=66a781acb9c3a78f3063d1e691a1b18a5f9f68ab;p=oweals%2Fbusybox.git ash: add tests adapted from hush glob tests. glob2.tests currently fails Signed-off-by: Denys Vlasenko --- diff --git a/shell/ash_test/ash-glob/glob1.right b/shell/ash_test/ash-glob/glob1.right new file mode 100644 index 000000000..f29ab4e65 --- /dev/null +++ b/shell/ash_test/ash-glob/glob1.right @@ -0,0 +1,2 @@ +glob1.tests +glob1.tests diff --git a/shell/ash_test/ash-glob/glob1.tests b/shell/ash_test/ash-glob/glob1.tests new file mode 100755 index 000000000..f980ce064 --- /dev/null +++ b/shell/ash_test/ash-glob/glob1.tests @@ -0,0 +1,2 @@ +echo *glob1?t[e]sts* +echo "glob1"?'t'[e]s* diff --git a/shell/ash_test/ash-glob/glob2.right b/shell/ash_test/ash-glob/glob2.right new file mode 100644 index 000000000..7a70c2263 --- /dev/null +++ b/shell/ash_test/ash-glob/glob2.right @@ -0,0 +1,18 @@ +Expected Actual +Z\* : Z\* +Z* : Z* +Z\f : Z\f +Z\* : Z\* + +Z\z : Z\z +Zz : Zz +Z\z : Z\z +Z\z : Z\z + +Z\ : Z\ +Z\ : Z\ + +Z\f Zf : Z\f Zf +Z\f Zf : Z\f Zf + +Done: 0 diff --git a/shell/ash_test/ash-glob/glob2.tests b/shell/ash_test/ash-glob/glob2.tests new file mode 100755 index 000000000..00618b9db --- /dev/null +++ b/shell/ash_test/ash-glob/glob2.tests @@ -0,0 +1,27 @@ +# This test demonstrates that in unquoted $v, backslashes expand by this rule: +# \z -> \\\z; \ -> \\ (for any z, special or not), +# and subsequently globbing converts \\ to \ and treats \z as literal z +# even if it is a special char. + +>'Zf' +>'Z\f' + echo 'Expected' 'Actual' +v='\*'; echo 'Z\* :' Z$v # ash is buggy here: prints 'Z\f' + echo 'Z* :' Z\* + echo 'Z\f :' Z\\* + echo 'Z\* :' Z\\\* # NB! only this matches Z$v output +echo +v='\z'; echo 'Z\z :' Z$v + echo 'Zz :' Z\z + echo 'Z\z :' Z\\z + echo 'Z\z :' Z\\\z +echo +v='\'; echo 'Z\ :' Z$v + echo 'Z\ :' Z\\ +echo +v='*'; echo 'Z\f Zf :' Z$v + echo 'Z\f Zf :' Z* +echo + +rm 'Z\f' 'Zf' +echo Done: $? diff --git a/shell/ash_test/ash-glob/glob_and_assign.right b/shell/ash_test/ash-glob/glob_and_assign.right new file mode 100644 index 000000000..d46e44363 --- /dev/null +++ b/shell/ash_test/ash-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/ash_test/ash-glob/glob_and_assign.tests b/shell/ash_test/ash-glob/glob_and_assign.tests new file mode 100755 index 000000000..0b158f20f --- /dev/null +++ b/shell/ash_test/ash-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/ash_test/ash-glob/glob_redir.right b/shell/ash_test/ash-glob/glob_redir.right new file mode 100644 index 000000000..fbd0309b0 --- /dev/null +++ b/shell/ash_test/ash-glob/glob_redir.right @@ -0,0 +1,2 @@ +z.tmp: +?.tmp: TEST diff --git a/shell/ash_test/ash-glob/glob_redir.tests b/shell/ash_test/ash-glob/glob_redir.tests new file mode 100755 index 000000000..621d12017 --- /dev/null +++ b/shell/ash_test/ash-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'