aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-02 19:57:53 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-02 19:57:53 +0000
commita43dba76ea394d789de67c6322b51e1d65bdba3b (patch)
treec99cde48cb834d4310ec06b3d377783029103ae1
parent444639cc2134d483bf0845416e9b6ce8935af795 (diff)
downloadbusybox-w32-a43dba76ea394d789de67c6322b51e1d65bdba3b.tar.gz
busybox-w32-a43dba76ea394d789de67c6322b51e1d65bdba3b.tar.bz2
busybox-w32-a43dba76ea394d789de67c6322b51e1d65bdba3b.zip
msh: create testsuite (based on hush one)
hush: add TODO (doesn't know ":" command)
-rw-r--r--shell/hush_test/zbad3
-rw-r--r--shell/msh_test/msh-bugs/noeol3.right1
-rwxr-xr-xshell/msh_test/msh-bugs/noeol3.tests2
-rw-r--r--shell/msh_test/msh-bugs/process_subst.right3
-rwxr-xr-xshell/msh_test/msh-bugs/process_subst.tests3
-rw-r--r--shell/msh_test/msh-bugs/read.right4
-rwxr-xr-xshell/msh_test/msh-bugs/read.tests4
-rw-r--r--shell/msh_test/msh-bugs/shift.right6
-rwxr-xr-xshell/msh_test/msh-bugs/shift.tests14
-rw-r--r--shell/msh_test/msh-bugs/starquoted.right8
-rwxr-xr-xshell/msh_test/msh-bugs/starquoted.tests8
-rw-r--r--shell/msh_test/msh-bugs/syntax_err.right2
-rwxr-xr-xshell/msh_test/msh-bugs/syntax_err.tests3
-rw-r--r--shell/msh_test/msh-bugs/var_expand_in_assign.right5
-rwxr-xr-xshell/msh_test/msh-bugs/var_expand_in_assign.tests15
-rw-r--r--shell/msh_test/msh-bugs/var_expand_in_redir.right3
-rwxr-xr-xshell/msh_test/msh-bugs/var_expand_in_redir.tests13
-rw-r--r--shell/msh_test/msh-execution/nested_break.right8
-rwxr-xr-x[-rw-r--r--]shell/msh_test/msh-execution/nested_break.tests (renamed from shell/msh_test/TODO_bug846)12
-rw-r--r--shell/msh_test/msh-misc/tick.right2
-rwxr-xr-xshell/msh_test/msh-misc/tick.tests4
-rw-r--r--shell/msh_test/msh-parsing/argv0.right1
-rwxr-xr-xshell/msh_test/msh-parsing/argv0.tests4
-rw-r--r--shell/msh_test/msh-parsing/noeol.right1
-rwxr-xr-xshell/msh_test/msh-parsing/noeol.tests2
-rw-r--r--shell/msh_test/msh-parsing/noeol2.right1
-rwxr-xr-xshell/msh_test/msh-parsing/noeol2.tests7
-rw-r--r--shell/msh_test/msh-parsing/quote1.right1
-rwxr-xr-xshell/msh_test/msh-parsing/quote1.tests2
-rw-r--r--shell/msh_test/msh-parsing/quote2.right1
-rwxr-xr-xshell/msh_test/msh-parsing/quote2.tests2
-rw-r--r--shell/msh_test/msh-parsing/quote3.right3
-rwxr-xr-xshell/msh_test/msh-parsing/quote3.tests8
-rw-r--r--shell/msh_test/msh-parsing/quote4.right1
-rwxr-xr-xshell/msh_test/msh-parsing/quote4.tests2
-rw-r--r--shell/msh_test/msh-vars/star.right6
-rwxr-xr-xshell/msh_test/msh-vars/star.tests8
-rw-r--r--shell/msh_test/msh-vars/var.right4
-rwxr-xr-xshell/msh_test/msh-vars/var.tests9
-rw-r--r--shell/msh_test/msh-vars/var_subst_in_for.right40
-rwxr-xr-xshell/msh_test/msh-vars/var_subst_in_for.tests40
-rwxr-xr-xshell/msh_test/run-all64
42 files changed, 318 insertions, 12 deletions
diff --git a/shell/hush_test/zbad b/shell/hush_test/zbad
new file mode 100644
index 000000000..e4b5caa61
--- /dev/null
+++ b/shell/hush_test/zbad
@@ -0,0 +1,3 @@
1# TODO: hush doesn't know ':' null command
2
3while :; do exit; done
diff --git a/shell/msh_test/msh-bugs/noeol3.right b/shell/msh_test/msh-bugs/noeol3.right
new file mode 100644
index 000000000..56f8515b7
--- /dev/null
+++ b/shell/msh_test/msh-bugs/noeol3.right
@@ -0,0 +1 @@
hush: syntax error: unterminated "
diff --git a/shell/msh_test/msh-bugs/noeol3.tests b/shell/msh_test/msh-bugs/noeol3.tests
new file mode 100755
index 000000000..ec958ed7a
--- /dev/null
+++ b/shell/msh_test/msh-bugs/noeol3.tests
@@ -0,0 +1,2 @@
1# last line has no EOL!
2echo "unterminated \ No newline at end of file
diff --git a/shell/msh_test/msh-bugs/process_subst.right b/shell/msh_test/msh-bugs/process_subst.right
new file mode 100644
index 000000000..397bc8067
--- /dev/null
+++ b/shell/msh_test/msh-bugs/process_subst.right
@@ -0,0 +1,3 @@
1TESTzzBEST
2TEST$(echo zz)BEST
3TEST'BEST
diff --git a/shell/msh_test/msh-bugs/process_subst.tests b/shell/msh_test/msh-bugs/process_subst.tests
new file mode 100755
index 000000000..21996bc0e
--- /dev/null
+++ b/shell/msh_test/msh-bugs/process_subst.tests
@@ -0,0 +1,3 @@
1echo "TEST`echo zz;echo;echo`BEST"
2echo "TEST`echo '$(echo zz)'`BEST"
3echo "TEST`echo "'"`BEST"
diff --git a/shell/msh_test/msh-bugs/read.right b/shell/msh_test/msh-bugs/read.right
new file mode 100644
index 000000000..0e50e2a23
--- /dev/null
+++ b/shell/msh_test/msh-bugs/read.right
@@ -0,0 +1,4 @@
1read
2cat
3echo "REPLY=$REPLY"
4REPLY=exec <read.tests
diff --git a/shell/msh_test/msh-bugs/read.tests b/shell/msh_test/msh-bugs/read.tests
new file mode 100755
index 000000000..ff1acbde1
--- /dev/null
+++ b/shell/msh_test/msh-bugs/read.tests
@@ -0,0 +1,4 @@
1exec <read.tests
2read
3cat
4echo "REPLY=$REPLY"
diff --git a/shell/msh_test/msh-bugs/shift.right b/shell/msh_test/msh-bugs/shift.right
new file mode 100644
index 000000000..d281e358c
--- /dev/null
+++ b/shell/msh_test/msh-bugs/shift.right
@@ -0,0 +1,6 @@
1./shift.tests abc d e
2./shift.tests d e 123
3./shift.tests d e 123
4./shift.tests
5./shift.tests
6./shift.tests
diff --git a/shell/msh_test/msh-bugs/shift.tests b/shell/msh_test/msh-bugs/shift.tests
new file mode 100755
index 000000000..53ef249f2
--- /dev/null
+++ b/shell/msh_test/msh-bugs/shift.tests
@@ -0,0 +1,14 @@
1if test $# = 0; then
2 exec "$THIS_SH" $0 abc "d e" 123
3fi
4echo $0 $1 $2
5shift
6echo $0 $1 $2
7shift 999
8echo $0 $1 $2
9shift 2
10echo $0 $1 $2
11shift 2
12echo $0 $1 $2
13shift
14echo $0 $1 $2
diff --git a/shell/msh_test/msh-bugs/starquoted.right b/shell/msh_test/msh-bugs/starquoted.right
new file mode 100644
index 000000000..b56323fe1
--- /dev/null
+++ b/shell/msh_test/msh-bugs/starquoted.right
@@ -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-.
diff --git a/shell/msh_test/msh-bugs/starquoted.tests b/shell/msh_test/msh-bugs/starquoted.tests
new file mode 100755
index 000000000..2fe49b1cd
--- /dev/null
+++ b/shell/msh_test/msh-bugs/starquoted.tests
@@ -0,0 +1,8 @@
1if test $# = 0; then
2 exec "$THIS_SH" "$0" 1 abc 'd e f'
3fi
4
5for a in "$*"; do echo ".$a."; done
6for a in "$@"; do echo ".$a."; done
7for a in "-$*-"; do echo ".$a."; done
8for a in "-$@-"; do echo ".$a."; done
diff --git a/shell/msh_test/msh-bugs/syntax_err.right b/shell/msh_test/msh-bugs/syntax_err.right
new file mode 100644
index 000000000..08a270c31
--- /dev/null
+++ b/shell/msh_test/msh-bugs/syntax_err.right
@@ -0,0 +1,2 @@
1shown
2hush: syntax error: unterminated '
diff --git a/shell/msh_test/msh-bugs/syntax_err.tests b/shell/msh_test/msh-bugs/syntax_err.tests
new file mode 100755
index 000000000..d10ed42e9
--- /dev/null
+++ b/shell/msh_test/msh-bugs/syntax_err.tests
@@ -0,0 +1,3 @@
1echo shown
2echo test `echo 'aa`
3echo not shown
diff --git a/shell/msh_test/msh-bugs/var_expand_in_assign.right b/shell/msh_test/msh-bugs/var_expand_in_assign.right
new file mode 100644
index 000000000..352210d7e
--- /dev/null
+++ b/shell/msh_test/msh-bugs/var_expand_in_assign.right
@@ -0,0 +1,5 @@
1. .
2.abc d e.
3.abc d e.
4.abc d e.
5.abc d e.
diff --git a/shell/msh_test/msh-bugs/var_expand_in_assign.tests b/shell/msh_test/msh-bugs/var_expand_in_assign.tests
new file mode 100755
index 000000000..18cdc74c0
--- /dev/null
+++ b/shell/msh_test/msh-bugs/var_expand_in_assign.tests
@@ -0,0 +1,15 @@
1if test $# = 0; then
2 exec "$THIS_SH" "$0" abc "d e"
3fi
4
5space=' '
6echo .$space.
7
8a=$*
9echo .$a.
10a=$@
11echo .$a.
12a="$*"
13echo .$a.
14a="$@"
15echo .$a.
diff --git a/shell/msh_test/msh-bugs/var_expand_in_redir.right b/shell/msh_test/msh-bugs/var_expand_in_redir.right
new file mode 100644
index 000000000..423299c97
--- /dev/null
+++ b/shell/msh_test/msh-bugs/var_expand_in_redir.right
@@ -0,0 +1,3 @@
1TEST1
2TEST2
3TEST3
diff --git a/shell/msh_test/msh-bugs/var_expand_in_redir.tests b/shell/msh_test/msh-bugs/var_expand_in_redir.tests
new file mode 100755
index 000000000..bda6bdd7f
--- /dev/null
+++ b/shell/msh_test/msh-bugs/var_expand_in_redir.tests
@@ -0,0 +1,13 @@
1if test $# = 0; then
2 exec "$THIS_SH" "$0" abc "d e"
3fi
4
5echo TEST1 >"$1.out"
6echo TEST2 >"$2.out"
7# bash says: "$@.out": ambiguous redirect
8# ash handles it as if it is '$*' - we do the same
9echo TEST3 >"$@.out"
10
11cat abc.out "d e.out" "abc d e.out"
12
13rm abc.out "d e.out" "abc d e.out"
diff --git a/shell/msh_test/msh-execution/nested_break.right b/shell/msh_test/msh-execution/nested_break.right
new file mode 100644
index 000000000..4e8b6b0f2
--- /dev/null
+++ b/shell/msh_test/msh-execution/nested_break.right
@@ -0,0 +1,8 @@
1A
2B
3iteration
4C
5A
6B
7iteration
8D
diff --git a/shell/msh_test/TODO_bug846 b/shell/msh_test/msh-execution/nested_break.tests
index 5c777fedb..f2e6f81ae 100644..100755
--- a/shell/msh_test/TODO_bug846
+++ b/shell/msh_test/msh-execution/nested_break.tests
@@ -1,5 +1,3 @@
1#!/bin/sh
2# For future msh testsuite:
3# Testcase for http://bugs.busybox.net/view.php?id=846 1# Testcase for http://bugs.busybox.net/view.php?id=846
4 2
5n=0 3n=0
@@ -17,13 +15,3 @@ do
17 n=`expr $n + 1` 15 n=`expr $n + 1`
18done 16done
19echo D 17echo D
20
21# output should be:
22# A
23# B
24# iteration
25# C
26# A
27# B
28# iteration
29# D
diff --git a/shell/msh_test/msh-misc/tick.right b/shell/msh_test/msh-misc/tick.right
new file mode 100644
index 000000000..6ed281c75
--- /dev/null
+++ b/shell/msh_test/msh-misc/tick.right
@@ -0,0 +1,2 @@
11
21
diff --git a/shell/msh_test/msh-misc/tick.tests b/shell/msh_test/msh-misc/tick.tests
new file mode 100755
index 000000000..1f749a9cd
--- /dev/null
+++ b/shell/msh_test/msh-misc/tick.tests
@@ -0,0 +1,4 @@
1true
2false; echo `echo $?`
3true
4{ false; echo `echo $?`; }
diff --git a/shell/msh_test/msh-parsing/argv0.right b/shell/msh_test/msh-parsing/argv0.right
new file mode 100644
index 000000000..d86bac9de
--- /dev/null
+++ b/shell/msh_test/msh-parsing/argv0.right
@@ -0,0 +1 @@
OK
diff --git a/shell/msh_test/msh-parsing/argv0.tests b/shell/msh_test/msh-parsing/argv0.tests
new file mode 100755
index 000000000..f5c40f6fe
--- /dev/null
+++ b/shell/msh_test/msh-parsing/argv0.tests
@@ -0,0 +1,4 @@
1if test $# = 0; then
2 exec "$THIS_SH" "$0" arg
3fi
4echo OK
diff --git a/shell/msh_test/msh-parsing/noeol.right b/shell/msh_test/msh-parsing/noeol.right
new file mode 100644
index 000000000..e427984d4
--- /dev/null
+++ b/shell/msh_test/msh-parsing/noeol.right
@@ -0,0 +1 @@
HELLO
diff --git a/shell/msh_test/msh-parsing/noeol.tests b/shell/msh_test/msh-parsing/noeol.tests
new file mode 100755
index 000000000..a93113a03
--- /dev/null
+++ b/shell/msh_test/msh-parsing/noeol.tests
@@ -0,0 +1,2 @@
1# next line has no EOL!
2echo HELLO \ No newline at end of file
diff --git a/shell/msh_test/msh-parsing/noeol2.right b/shell/msh_test/msh-parsing/noeol2.right
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/shell/msh_test/msh-parsing/noeol2.right
@@ -0,0 +1 @@
1
diff --git a/shell/msh_test/msh-parsing/noeol2.tests b/shell/msh_test/msh-parsing/noeol2.tests
new file mode 100755
index 000000000..1220f056f
--- /dev/null
+++ b/shell/msh_test/msh-parsing/noeol2.tests
@@ -0,0 +1,7 @@
1# last line has no EOL!
2if true
3then
4 echo 1
5else
6 echo 2
7fi \ No newline at end of file
diff --git a/shell/msh_test/msh-parsing/quote1.right b/shell/msh_test/msh-parsing/quote1.right
new file mode 100644
index 000000000..cb382054c
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote1.right
@@ -0,0 +1 @@
'1'
diff --git a/shell/msh_test/msh-parsing/quote1.tests b/shell/msh_test/msh-parsing/quote1.tests
new file mode 100755
index 000000000..f55895466
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote1.tests
@@ -0,0 +1,2 @@
1a=1
2echo "'$a'"
diff --git a/shell/msh_test/msh-parsing/quote2.right b/shell/msh_test/msh-parsing/quote2.right
new file mode 100644
index 000000000..3bc9edcd6
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote2.right
@@ -0,0 +1 @@
>1
diff --git a/shell/msh_test/msh-parsing/quote2.tests b/shell/msh_test/msh-parsing/quote2.tests
new file mode 100755
index 000000000..bd966f30b
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote2.tests
@@ -0,0 +1,2 @@
1a=1
2echo ">$a"
diff --git a/shell/msh_test/msh-parsing/quote3.right b/shell/msh_test/msh-parsing/quote3.right
new file mode 100644
index 000000000..069a46e8f
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote3.right
@@ -0,0 +1,3 @@
1Testing: in $empty""
2..
3Finished
diff --git a/shell/msh_test/msh-parsing/quote3.tests b/shell/msh_test/msh-parsing/quote3.tests
new file mode 100755
index 000000000..075e78570
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote3.tests
@@ -0,0 +1,8 @@
1if test $# = 0; then
2 exec "$THIS_SH" quote3.tests abc "d e"
3fi
4
5echo 'Testing: in $empty""'
6empty=''
7for a in $empty""; do echo ".$a."; done
8echo Finished
diff --git a/shell/msh_test/msh-parsing/quote4.right b/shell/msh_test/msh-parsing/quote4.right
new file mode 100644
index 000000000..b2901ea97
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote4.right
@@ -0,0 +1 @@
a b
diff --git a/shell/msh_test/msh-parsing/quote4.tests b/shell/msh_test/msh-parsing/quote4.tests
new file mode 100755
index 000000000..f1dabfa54
--- /dev/null
+++ b/shell/msh_test/msh-parsing/quote4.tests
@@ -0,0 +1,2 @@
1a_b='a b'
2echo "$a_b"
diff --git a/shell/msh_test/msh-vars/star.right b/shell/msh_test/msh-vars/star.right
new file mode 100644
index 000000000..0ecc55bc2
--- /dev/null
+++ b/shell/msh_test/msh-vars/star.right
@@ -0,0 +1,6 @@
1.1.
2.abc.
3.d.
4.e.
5.f.
6.1 abc d e f.
diff --git a/shell/msh_test/msh-vars/star.tests b/shell/msh_test/msh-vars/star.tests
new file mode 100755
index 000000000..5554c4090
--- /dev/null
+++ b/shell/msh_test/msh-vars/star.tests
@@ -0,0 +1,8 @@
1if test $# = 0; then
2 exec "$THIS_SH" star.tests 1 abc 'd e f'
3fi
4# 'd e f' should be split into 3 separate args:
5for a in $*; do echo ".$a."; done
6
7# must produce .1 abc d e f.
8for a in "$*"; do echo ".$a."; done
diff --git a/shell/msh_test/msh-vars/var.right b/shell/msh_test/msh-vars/var.right
new file mode 100644
index 000000000..14b2314d9
--- /dev/null
+++ b/shell/msh_test/msh-vars/var.right
@@ -0,0 +1,4 @@
1http://busybox.net
2http://busybox.net_abc
31
41
diff --git a/shell/msh_test/msh-vars/var.tests b/shell/msh_test/msh-vars/var.tests
new file mode 100755
index 000000000..0a63696c9
--- /dev/null
+++ b/shell/msh_test/msh-vars/var.tests
@@ -0,0 +1,9 @@
1URL=http://busybox.net
2
3echo $URL
4echo ${URL}_abc
5
6true
7false; echo $?
8true
9{ false; echo $?; }
diff --git a/shell/msh_test/msh-vars/var_subst_in_for.right b/shell/msh_test/msh-vars/var_subst_in_for.right
new file mode 100644
index 000000000..c8aca1c12
--- /dev/null
+++ b/shell/msh_test/msh-vars/var_subst_in_for.right
@@ -0,0 +1,40 @@
1Testing: in x y z
2.x.
3.y.
4.z.
5Testing: in u $empty v
6.u.
7.v.
8Testing: in u " $empty" v
9.u.
10. .
11.v.
12Testing: in u $empty $empty$a v
13.u.
14.a.
15.v.
16Testing: in $a_b
17.a.
18.b.
19Testing: in $*
20.abc.
21.d.
22.e.
23Testing: in $@
24.abc.
25.d.
26.e.
27Testing: in -$*-
28.-abc.
29.d.
30.e-.
31Testing: in -$@-
32.-abc.
33.d.
34.e-.
35Testing: in $a_b -$a_b-
36.a.
37.b.
38.-a.
39.b-.
40Finished
diff --git a/shell/msh_test/msh-vars/var_subst_in_for.tests b/shell/msh_test/msh-vars/var_subst_in_for.tests
new file mode 100755
index 000000000..4d1c11201
--- /dev/null
+++ b/shell/msh_test/msh-vars/var_subst_in_for.tests
@@ -0,0 +1,40 @@
1if test $# = 0; then
2 exec "$THIS_SH" var_subst_in_for.tests abc "d e"
3fi
4
5echo 'Testing: in x y z'
6for a in x y z; do echo ".$a."; done
7
8echo 'Testing: in u $empty v'
9empty=''
10for a in u $empty v; do echo ".$a."; done
11
12echo 'Testing: in u " $empty" v'
13empty=''
14for a in u " $empty" v; do echo ".$a."; done
15
16echo 'Testing: in u $empty $empty$a v'
17a='a'
18for a in u $empty $empty$a v; do echo ".$a."; done
19
20echo 'Testing: in $a_b'
21a_b='a b'
22for a in $a_b; do echo ".$a."; done
23
24echo 'Testing: in $*'
25for a in $*; do echo ".$a."; done
26
27echo 'Testing: in $@'
28for a in $@; do echo ".$a."; done
29
30echo 'Testing: in -$*-'
31for a in -$*-; do echo ".$a."; done
32
33echo 'Testing: in -$@-'
34for a in -$@-; do echo ".$a."; done
35
36echo 'Testing: in $a_b -$a_b-'
37a_b='a b'
38for a in $a_b -$a_b-; do echo ".$a."; done
39
40echo Finished
diff --git a/shell/msh_test/run-all b/shell/msh_test/run-all
new file mode 100755
index 000000000..43bc9fc0b
--- /dev/null
+++ b/shell/msh_test/run-all
@@ -0,0 +1,64 @@
1#!/bin/sh
2
3test -x msh || {
4 echo "No ./msh?! Perhaps you want to run 'ln -s ../../busybox msh'"
5 exit
6}
7
8PATH="$PWD:$PATH" # for msh
9export PATH
10
11THIS_SH="$PWD/msh"
12export THIS_SH
13
14do_test()
15{
16 test -d "$1" || return 0
17# echo Running tests in directory "$1"
18 (
19 cd "$1" || { echo "cannot cd $1!"; exit 1; }
20 for x in run-*; do
21 test -f "$x" || continue
22 case "$x" in
23 "$0"|run-minimal|run-gprof) ;;
24 *.orig|*~) ;;
25 #*) echo $x ; sh $x ;;
26 *)
27 sh "$x" >"../$1-$x.fail" 2>&1 && \
28 { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
29 ;;
30 esac
31 done
32 # Many bash run-XXX scripts just do this,
33 # no point in duplication it all over the place
34 for x in *.tests; do
35 test -x "$x" || continue
36 name="${x%%.tests}"
37 test -f "$name.right" || continue
38# echo Running test: "$name.right"
39 {
40 "$THIS_SH" "./$x" >"$name.xx" 2>&1
41 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
42 } && echo "$1/$x: ok" || echo "$1/$x: fail"
43 done
44 )
45}
46
47# Main part of this script
48# Usage: run-all [directories]
49
50if [ $# -lt 1 ]; then
51 # All sub directories
52 modules=`ls -d msh-*`
53
54 for module in $modules; do
55 do_test $module
56 done
57else
58 while [ $# -ge 1 ]; do
59 if [ -d $1 ]; then
60 do_test $1
61 fi
62 shift
63 done
64fi