mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 16:31:24 +00:00
msh: create testsuite (based on hush one)
hush: add TODO (doesn't know ":" command)
This commit is contained in:
parent
444639cc21
commit
a43dba76ea
3
shell/hush_test/zbad
Normal file
3
shell/hush_test/zbad
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# TODO: hush doesn't know ':' null command
|
||||||
|
|
||||||
|
while :; do exit; done
|
1
shell/msh_test/msh-bugs/noeol3.right
Normal file
1
shell/msh_test/msh-bugs/noeol3.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
hush: syntax error: unterminated "
|
2
shell/msh_test/msh-bugs/noeol3.tests
Executable file
2
shell/msh_test/msh-bugs/noeol3.tests
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
# last line has no EOL!
|
||||||
|
echo "unterminated
|
3
shell/msh_test/msh-bugs/process_subst.right
Normal file
3
shell/msh_test/msh-bugs/process_subst.right
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
TESTzzBEST
|
||||||
|
TEST$(echo zz)BEST
|
||||||
|
TEST'BEST
|
3
shell/msh_test/msh-bugs/process_subst.tests
Executable file
3
shell/msh_test/msh-bugs/process_subst.tests
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
echo "TEST`echo zz;echo;echo`BEST"
|
||||||
|
echo "TEST`echo '$(echo zz)'`BEST"
|
||||||
|
echo "TEST`echo "'"`BEST"
|
4
shell/msh_test/msh-bugs/read.right
Normal file
4
shell/msh_test/msh-bugs/read.right
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
read
|
||||||
|
cat
|
||||||
|
echo "REPLY=$REPLY"
|
||||||
|
REPLY=exec <read.tests
|
4
shell/msh_test/msh-bugs/read.tests
Executable file
4
shell/msh_test/msh-bugs/read.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
exec <read.tests
|
||||||
|
read
|
||||||
|
cat
|
||||||
|
echo "REPLY=$REPLY"
|
6
shell/msh_test/msh-bugs/shift.right
Normal file
6
shell/msh_test/msh-bugs/shift.right
Normal file
@ -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
|
14
shell/msh_test/msh-bugs/shift.tests
Executable file
14
shell/msh_test/msh-bugs/shift.tests
Executable file
@ -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
|
8
shell/msh_test/msh-bugs/starquoted.right
Normal file
8
shell/msh_test/msh-bugs/starquoted.right
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.1 abc d e f.
|
||||||
|
.1.
|
||||||
|
.abc.
|
||||||
|
.d e f.
|
||||||
|
.-1 abc d e f-.
|
||||||
|
.-1.
|
||||||
|
.abc.
|
||||||
|
.d e f-.
|
8
shell/msh_test/msh-bugs/starquoted.tests
Executable file
8
shell/msh_test/msh-bugs/starquoted.tests
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" "$0" 1 abc 'd e f'
|
||||||
|
fi
|
||||||
|
|
||||||
|
for a in "$*"; do echo ".$a."; done
|
||||||
|
for a in "$@"; do echo ".$a."; done
|
||||||
|
for a in "-$*-"; do echo ".$a."; done
|
||||||
|
for a in "-$@-"; do echo ".$a."; done
|
2
shell/msh_test/msh-bugs/syntax_err.right
Normal file
2
shell/msh_test/msh-bugs/syntax_err.right
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
shown
|
||||||
|
hush: syntax error: unterminated '
|
3
shell/msh_test/msh-bugs/syntax_err.tests
Executable file
3
shell/msh_test/msh-bugs/syntax_err.tests
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
echo shown
|
||||||
|
echo test `echo 'aa`
|
||||||
|
echo not shown
|
5
shell/msh_test/msh-bugs/var_expand_in_assign.right
Normal file
5
shell/msh_test/msh-bugs/var_expand_in_assign.right
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
. .
|
||||||
|
.abc d e.
|
||||||
|
.abc d e.
|
||||||
|
.abc d e.
|
||||||
|
.abc d e.
|
15
shell/msh_test/msh-bugs/var_expand_in_assign.tests
Executable file
15
shell/msh_test/msh-bugs/var_expand_in_assign.tests
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" "$0" abc "d e"
|
||||||
|
fi
|
||||||
|
|
||||||
|
space=' '
|
||||||
|
echo .$space.
|
||||||
|
|
||||||
|
a=$*
|
||||||
|
echo .$a.
|
||||||
|
a=$@
|
||||||
|
echo .$a.
|
||||||
|
a="$*"
|
||||||
|
echo .$a.
|
||||||
|
a="$@"
|
||||||
|
echo .$a.
|
3
shell/msh_test/msh-bugs/var_expand_in_redir.right
Normal file
3
shell/msh_test/msh-bugs/var_expand_in_redir.right
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
TEST1
|
||||||
|
TEST2
|
||||||
|
TEST3
|
13
shell/msh_test/msh-bugs/var_expand_in_redir.tests
Executable file
13
shell/msh_test/msh-bugs/var_expand_in_redir.tests
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" "$0" abc "d e"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo TEST1 >"$1.out"
|
||||||
|
echo TEST2 >"$2.out"
|
||||||
|
# bash says: "$@.out": ambiguous redirect
|
||||||
|
# ash handles it as if it is '$*' - we do the same
|
||||||
|
echo TEST3 >"$@.out"
|
||||||
|
|
||||||
|
cat abc.out "d e.out" "abc d e.out"
|
||||||
|
|
||||||
|
rm abc.out "d e.out" "abc d e.out"
|
8
shell/msh_test/msh-execution/nested_break.right
Normal file
8
shell/msh_test/msh-execution/nested_break.right
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
A
|
||||||
|
B
|
||||||
|
iteration
|
||||||
|
C
|
||||||
|
A
|
||||||
|
B
|
||||||
|
iteration
|
||||||
|
D
|
12
shell/msh_test/TODO_bug846 → shell/msh_test/msh-execution/nested_break.tests
Normal file → Executable file
12
shell/msh_test/TODO_bug846 → shell/msh_test/msh-execution/nested_break.tests
Normal file → Executable file
@ -1,5 +1,3 @@
|
|||||||
#!/bin/sh
|
|
||||||
# For future msh testsuite:
|
|
||||||
# Testcase for http://bugs.busybox.net/view.php?id=846
|
# Testcase for http://bugs.busybox.net/view.php?id=846
|
||||||
|
|
||||||
n=0
|
n=0
|
||||||
@ -17,13 +15,3 @@ do
|
|||||||
n=`expr $n + 1`
|
n=`expr $n + 1`
|
||||||
done
|
done
|
||||||
echo D
|
echo D
|
||||||
|
|
||||||
# output should be:
|
|
||||||
# A
|
|
||||||
# B
|
|
||||||
# iteration
|
|
||||||
# C
|
|
||||||
# A
|
|
||||||
# B
|
|
||||||
# iteration
|
|
||||||
# D
|
|
2
shell/msh_test/msh-misc/tick.right
Normal file
2
shell/msh_test/msh-misc/tick.right
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
1
|
||||||
|
1
|
4
shell/msh_test/msh-misc/tick.tests
Executable file
4
shell/msh_test/msh-misc/tick.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
true
|
||||||
|
false; echo `echo $?`
|
||||||
|
true
|
||||||
|
{ false; echo `echo $?`; }
|
1
shell/msh_test/msh-parsing/argv0.right
Normal file
1
shell/msh_test/msh-parsing/argv0.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
OK
|
4
shell/msh_test/msh-parsing/argv0.tests
Executable file
4
shell/msh_test/msh-parsing/argv0.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" "$0" arg
|
||||||
|
fi
|
||||||
|
echo OK
|
1
shell/msh_test/msh-parsing/noeol.right
Normal file
1
shell/msh_test/msh-parsing/noeol.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
HELLO
|
2
shell/msh_test/msh-parsing/noeol.tests
Executable file
2
shell/msh_test/msh-parsing/noeol.tests
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
# next line has no EOL!
|
||||||
|
echo HELLO
|
1
shell/msh_test/msh-parsing/noeol2.right
Normal file
1
shell/msh_test/msh-parsing/noeol2.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
7
shell/msh_test/msh-parsing/noeol2.tests
Executable file
7
shell/msh_test/msh-parsing/noeol2.tests
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
# last line has no EOL!
|
||||||
|
if true
|
||||||
|
then
|
||||||
|
echo 1
|
||||||
|
else
|
||||||
|
echo 2
|
||||||
|
fi
|
1
shell/msh_test/msh-parsing/quote1.right
Normal file
1
shell/msh_test/msh-parsing/quote1.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
'1'
|
2
shell/msh_test/msh-parsing/quote1.tests
Executable file
2
shell/msh_test/msh-parsing/quote1.tests
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
a=1
|
||||||
|
echo "'$a'"
|
1
shell/msh_test/msh-parsing/quote2.right
Normal file
1
shell/msh_test/msh-parsing/quote2.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
>1
|
2
shell/msh_test/msh-parsing/quote2.tests
Executable file
2
shell/msh_test/msh-parsing/quote2.tests
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
a=1
|
||||||
|
echo ">$a"
|
3
shell/msh_test/msh-parsing/quote3.right
Normal file
3
shell/msh_test/msh-parsing/quote3.right
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Testing: in $empty""
|
||||||
|
..
|
||||||
|
Finished
|
8
shell/msh_test/msh-parsing/quote3.tests
Executable file
8
shell/msh_test/msh-parsing/quote3.tests
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" quote3.tests abc "d e"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'Testing: in $empty""'
|
||||||
|
empty=''
|
||||||
|
for a in $empty""; do echo ".$a."; done
|
||||||
|
echo Finished
|
1
shell/msh_test/msh-parsing/quote4.right
Normal file
1
shell/msh_test/msh-parsing/quote4.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
a b
|
2
shell/msh_test/msh-parsing/quote4.tests
Executable file
2
shell/msh_test/msh-parsing/quote4.tests
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
a_b='a b'
|
||||||
|
echo "$a_b"
|
6
shell/msh_test/msh-vars/star.right
Normal file
6
shell/msh_test/msh-vars/star.right
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.1.
|
||||||
|
.abc.
|
||||||
|
.d.
|
||||||
|
.e.
|
||||||
|
.f.
|
||||||
|
.1 abc d e f.
|
8
shell/msh_test/msh-vars/star.tests
Executable file
8
shell/msh_test/msh-vars/star.tests
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" star.tests 1 abc 'd e f'
|
||||||
|
fi
|
||||||
|
# 'd e f' should be split into 3 separate args:
|
||||||
|
for a in $*; do echo ".$a."; done
|
||||||
|
|
||||||
|
# must produce .1 abc d e f.
|
||||||
|
for a in "$*"; do echo ".$a."; done
|
4
shell/msh_test/msh-vars/var.right
Normal file
4
shell/msh_test/msh-vars/var.right
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
http://busybox.net
|
||||||
|
http://busybox.net_abc
|
||||||
|
1
|
||||||
|
1
|
9
shell/msh_test/msh-vars/var.tests
Executable file
9
shell/msh_test/msh-vars/var.tests
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
URL=http://busybox.net
|
||||||
|
|
||||||
|
echo $URL
|
||||||
|
echo ${URL}_abc
|
||||||
|
|
||||||
|
true
|
||||||
|
false; echo $?
|
||||||
|
true
|
||||||
|
{ false; echo $?; }
|
40
shell/msh_test/msh-vars/var_subst_in_for.right
Normal file
40
shell/msh_test/msh-vars/var_subst_in_for.right
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
Testing: in x y z
|
||||||
|
.x.
|
||||||
|
.y.
|
||||||
|
.z.
|
||||||
|
Testing: in u $empty v
|
||||||
|
.u.
|
||||||
|
.v.
|
||||||
|
Testing: in u " $empty" v
|
||||||
|
.u.
|
||||||
|
. .
|
||||||
|
.v.
|
||||||
|
Testing: in u $empty $empty$a v
|
||||||
|
.u.
|
||||||
|
.a.
|
||||||
|
.v.
|
||||||
|
Testing: in $a_b
|
||||||
|
.a.
|
||||||
|
.b.
|
||||||
|
Testing: in $*
|
||||||
|
.abc.
|
||||||
|
.d.
|
||||||
|
.e.
|
||||||
|
Testing: in $@
|
||||||
|
.abc.
|
||||||
|
.d.
|
||||||
|
.e.
|
||||||
|
Testing: in -$*-
|
||||||
|
.-abc.
|
||||||
|
.d.
|
||||||
|
.e-.
|
||||||
|
Testing: in -$@-
|
||||||
|
.-abc.
|
||||||
|
.d.
|
||||||
|
.e-.
|
||||||
|
Testing: in $a_b -$a_b-
|
||||||
|
.a.
|
||||||
|
.b.
|
||||||
|
.-a.
|
||||||
|
.b-.
|
||||||
|
Finished
|
40
shell/msh_test/msh-vars/var_subst_in_for.tests
Executable file
40
shell/msh_test/msh-vars/var_subst_in_for.tests
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
if test $# = 0; then
|
||||||
|
exec "$THIS_SH" var_subst_in_for.tests abc "d e"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'Testing: in x y z'
|
||||||
|
for a in x y z; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in u $empty v'
|
||||||
|
empty=''
|
||||||
|
for a in u $empty v; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in u " $empty" v'
|
||||||
|
empty=''
|
||||||
|
for a in u " $empty" v; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in u $empty $empty$a v'
|
||||||
|
a='a'
|
||||||
|
for a in u $empty $empty$a v; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in $a_b'
|
||||||
|
a_b='a b'
|
||||||
|
for a in $a_b; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in $*'
|
||||||
|
for a in $*; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in $@'
|
||||||
|
for a in $@; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in -$*-'
|
||||||
|
for a in -$*-; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in -$@-'
|
||||||
|
for a in -$@-; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo 'Testing: in $a_b -$a_b-'
|
||||||
|
a_b='a b'
|
||||||
|
for a in $a_b -$a_b-; do echo ".$a."; done
|
||||||
|
|
||||||
|
echo Finished
|
64
shell/msh_test/run-all
Executable file
64
shell/msh_test/run-all
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test -x msh || {
|
||||||
|
echo "No ./msh?! Perhaps you want to run 'ln -s ../../busybox msh'"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
PATH="$PWD:$PATH" # for msh
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
THIS_SH="$PWD/msh"
|
||||||
|
export THIS_SH
|
||||||
|
|
||||||
|
do_test()
|
||||||
|
{
|
||||||
|
test -d "$1" || return 0
|
||||||
|
# echo Running tests in directory "$1"
|
||||||
|
(
|
||||||
|
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" >"../$1-$x.fail" 2>&1 && \
|
||||||
|
{ echo "$1/$x: ok"; rm "../$1-$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
|
||||||
|
# echo Running test: "$name.right"
|
||||||
|
{
|
||||||
|
"$THIS_SH" "./$x" >"$name.xx" 2>&1
|
||||||
|
diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$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 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
|
Loading…
Reference in New Issue
Block a user