Skip to content

Commit e34dbc4

Browse files
author
Denys Vlasenko
committed
ash: add all hush parsing tests to ast tests
All pass. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
1 parent 0675b03 commit e34dbc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+331
-4
lines changed
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OK
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if test $# = 0; then
2+
exec "$THIS_SH" "$0" arg
3+
fi
4+
echo OK
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{abc}
2+
{
3+
}
4+
./brace1.tests: line 4: {cmd: not found
5+
./brace1.tests: line 5: {: not found
6+
./brace1.tests: line 6: {: not found
7+
Done: 127
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
echo {abc}
2+
echo {
3+
echo }
4+
{cmd
5+
""{
6+
{""
7+
echo Done: $?
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{q,w}
2+
{q,w}
3+
Done
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
v='{q,w}'
2+
# Should not brace-expand v value
3+
echo $v
4+
echo "$v"
5+
echo Done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Nothing:
2+
String: #should-be-echoed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo Nothing: #should-not-be-echoed
2+
echo String: ""#should-be-echoed

shell/ash_test/ash-parsing/eol1.right

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Done:0

shell/ash_test/ash-parsing/eol1.tests

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# bug was that we treated <newline> as ';' in this line:
2+
true || echo foo |
3+
echo BAD1 | cat
4+
5+
# variation on the same theme
6+
true || echo foo |
7+
# comment
8+
echo BAD2 | cat
9+
10+
# variation on the same theme
11+
true || echo foo |
12+
13+
echo BAD3 | cat
14+
15+
# this should error out, but currently works in hush:
16+
#true || echo foo |;
17+
18+
echo Done:$?
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
\
2+
a\b
3+
\\
4+
c\\d
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
test "$CONFIG_FEATURE_FANCY_ECHO" = "y" || exit 77
2+
3+
echo "\\"
4+
echo a"\\"b
5+
echo '\\'
6+
echo c'\\'d
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*?[a]*
2+
a*?[a]*b
3+
*?[a]*
4+
c*?[a]*d
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
echo "*?[a]*"
2+
echo a"*?[a]*"b
3+
echo '*?[a]*'
4+
echo c'*?[a]*'d
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
v: a \ b \\ c \\\ d \\\\ e
2+
v: a \ b \\ c \\\ d \\\\ e
3+
Unquoted:
4+
.a.
5+
.\.
6+
.b.
7+
.\\.
8+
.c.
9+
.\\\.
10+
.d.
11+
.\\\\.
12+
.e.
13+
Quoted:
14+
.a.
15+
.\.
16+
.b.
17+
.\\.
18+
.c.
19+
.\\\.
20+
.d.
21+
.\\\\.
22+
.e.
23+
done
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
test "$CONFIG_FEATURE_FANCY_ECHO" = "y" || exit 77
2+
3+
v='a \ b \\ c \\\ d \\\\ e'
4+
echo v: $v
5+
echo v: "$v"
6+
echo Unquoted:
7+
for a in $v; do echo .$a.; done
8+
echo Quoted:
9+
for a in $v; do echo ".$a."; done
10+
echo done
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ok
2+
End
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
i\
2+
f tr\
3+
ue; th\
4+
en echo "O\
5+
k"; fi; echo "\
6+
End"
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
a\nb\nc\n
2+
a
3+
b
4+
c
5+
a\nb\nc\n
6+
a
7+
b
8+
c
9+
Done
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v="a\nb\nc\n"
2+
echo "$v"
3+
printf "$v"
4+
v='a\nb\nc\n'
5+
echo "$v"
6+
printf "$v"
7+
echo Done
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
word} }
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ echo word} }; }
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
got TERM
2+
Done: 0
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Bug was in handling of "}&" without space
2+
{ trap "echo got TERM" TERM; sleep 2; }& sleep 1; kill $!; wait
3+
echo Done: $?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Semicolons after } can be omitted 1:
2+
foo
3+
bar
4+
Semicolons after } can be omitted 2:
5+
foo
6+
bar
7+
Semicolons after fi can be omitted:
8+
foo
9+
bar
10+
baz
11+
Done:0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
echo "Semicolons after } can be omitted 1:"
2+
if { echo foo; } then { echo bar; } fi
3+
4+
echo "Semicolons after } can be omitted 2:"
5+
while { echo foo; } do { echo bar; break; } done
6+
7+
echo "Semicolons after fi can be omitted:"
8+
while if echo foo; then echo bar; fi do echo baz; break; done
9+
10+
echo Done:$?
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
! printing !
2+
0
3+
1
4+
1
5+
0
6+
0
7+
0
8+
!
9+
a
10+
b
11+
c
12+
! 1
13+
a 1
14+
b 1
15+
c 1
16+
! 1
17+
a 1
18+
b 1
19+
c 1
20+
0
21+
0
22+
0
23+
0
24+
1
25+
1
26+
1
27+
1
28+
0
29+
0
30+
0
31+
0
32+
1
33+
1
34+
1
35+
1
36+
Done
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
echo ! printing !
2+
! false
3+
echo $?
4+
! true
5+
echo $?
6+
if ! false; then false; echo $?; fi
7+
echo $?
8+
if ! false; then ! false; echo $?; fi
9+
echo $?
10+
PRINTF=`which printf`
11+
for a in ! a b c; do echo $a; done
12+
for a in ! a b c; do ! printf "$a "; echo $?; done
13+
test x"$PRINTF" = x"" && exit 1
14+
for a in ! a b c; do ! "$PRINTF" "$a "; echo $?; done
15+
for a in ! a b c; do ! printf "$a " | false; echo $?; done
16+
for a in ! a b c; do ! printf "$a " | true; echo $?; done
17+
for a in ! a b c; do ! { printf "$a " | false; }; echo $?; done
18+
for a in ! a b c; do ! { printf "$a " | true; }; echo $?; done
19+
echo Done
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HELLO
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# next line has no EOL!
2+
echo HELLO
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# last line has no EOL!
2+
if true
3+
then
4+
echo 1
5+
else
6+
echo 2
7+
fi
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./noeol3.tests: line 2: syntax error: unterminated quoted string
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# last line has no EOL!
2+
echo "unterminated
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TESTzzBEST
2+
TEST$(echo zz)BEST
3+
TEST'BEST
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
echo "TEST`echo zz;echo;echo`BEST"
2+
echo "TEST`echo '$(echo zz)'`BEST"
3+
echo "TEST`echo "'"`BEST"
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'1'
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
a=1
2+
echo "'$a'"
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
>1
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
a=1
2+
echo ">$a"
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Testing: in ""
2+
..
3+
Testing: in ''
4+
..
5+
Testing: in $empty
6+
Testing: in $empty""
7+
..
8+
Testing: in $empty''
9+
..
10+
Testing: in "$empty"
11+
..
12+
Finished
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
empty=''
2+
3+
echo 'Testing: in ""'
4+
for a in ""; do echo ".$a."; done
5+
6+
echo 'Testing: in '"''"
7+
for a in ''; do echo ".$a."; done
8+
9+
echo 'Testing: in $empty'
10+
for a in $empty; do echo ".$a."; done
11+
12+
echo 'Testing: in $empty""'
13+
for a in $empty""; do echo ".$a."; done
14+
15+
echo 'Testing: in $empty'"''"
16+
for a in $empty''; do echo ".$a."; done
17+
18+
echo 'Testing: in "$empty"'
19+
for a in "$empty"; do echo ".$a."; done
20+
21+
echo Finished
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a b
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
a_b='a b'
2+
echo "$a_b"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.1 abc d e f.
2+
.1.
3+
.abc.
4+
.d e f.
5+
.-1 abc d e f-.
6+
.-1.
7+
.abc.
8+
.d e f-.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if test $# = 0; then
2+
exec "$THIS_SH" "$0" 1 abc 'd e f'
3+
fi
4+
5+
for a in "$*"; do echo ".$a."; done
6+
for a in "$@"; do echo ".$a."; done
7+
for a in "-$*-"; do echo ".$a."; done
8+
for a in "-$@-"; do echo ".$a."; done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Should be printed
2+
Would not be printed by bash
3+
Would not be printed by bash
4+
Would not be printed by bash
5+
Should be printed
6+
Empty:
7+
Empty:
8+
Empty:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
if test $# != 0; then
2+
exec "$THIS_SH" "$0"
3+
fi
4+
5+
# No params!
6+
for a in "$*"; do echo Should be printed; done
7+
for a in "$@"; do echo Should not be printed; done
8+
# Yes, believe it or not, bash is mesmerized by "$@" and stops
9+
# treating "" as "this word cannot be expanded to nothing,
10+
# but must be at least null string". Now it can be expanded to nothing.
11+
for a in "$@"""; do echo Would not be printed by bash; done
12+
for a in """$@"; do echo Would not be printed by bash; done
13+
for a in """$@"''"$@"''; do echo Would not be printed by bash; done
14+
for a in ""; do echo Should be printed; done
15+
16+
# Bug 207: "$@" expands to nothing, and we erroneously glob "%s\n" twice:
17+
printf 'Empty:%s\n' "$@"
18+
printf "Empty:%s\n" "$@"
19+
printf "Empty:%s\\n" "$@"

shell/ash_test/run-all

+18-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,24 @@
22

33
TOPDIR=`pwd`
44

5-
test -x ash || {
6-
echo "No ./ash - creating a link to ../../busybox"
7-
ln -s ../../busybox ash
8-
}
5+
if test ! -x ash; then
6+
if test ! -x ../../busybox; then
7+
echo "Can't run tests. Put ash binary into this directory (`pwd`)"
8+
exit 1
9+
fi
10+
echo "No ./ash - creating a link to ../../busybox"
11+
ln -s ../../busybox ash
12+
fi
13+
if test ! -f .config; then
14+
if test ! -f ../../.config; then
15+
echo "Missing .config file"
16+
exit 1
17+
fi
18+
cp ../../.config . || exit 1
19+
fi
20+
21+
eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
22+
923
test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
1024
test -x recho || gcc -O2 -o recho recho.c || exit $?
1125
test -x zecho || gcc -O2 -o zecho zecho.c || exit $?

0 commit comments

Comments
 (0)