mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2024-11-24 20:29:55 +00:00
Numerous new testcases from Larry Doolittle and a patch to tester.sh to avoid
a bash2-ism and quote variables that contain strings.
This commit is contained in:
parent
a813afc24f
commit
04052f96e1
33
tests/sh.testcases
Normal file
33
tests/sh.testcases
Normal file
@ -0,0 +1,33 @@
|
||||
# try running this with bash, ksh, ash, and hush.
|
||||
echo `echo -e foo\\\necho bar`
|
||||
|
||||
echo THIS IS A TEST >foo
|
||||
cat $(echo FOO | tr 'A-Z' 'a-z')
|
||||
cat foo | tr 'A-Z' 'a-z'
|
||||
cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z'
|
||||
|
||||
cat foo | if true; then tr 'A-Z' 'a-z'; else echo bar1; fi
|
||||
cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi
|
||||
if true; then tr 'A-Z' 'a-z'; else echo bar3; fi <foo
|
||||
if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo
|
||||
if true || false; then echo foo; else echo bar5; fi
|
||||
if true && false; then echo bar6; else echo foo; fi
|
||||
|
||||
# ash, lash, and hush do not create fish; bash and ksh do. Tough.
|
||||
# Thanks to Tapani Tarvainen <tt@mit.jyu.fi> for this stress test.
|
||||
unset TMP
|
||||
rm -f fish
|
||||
TMP=fish >$TMP
|
||||
ls fish
|
||||
|
||||
# The following example shows that hush's parser is
|
||||
# not _really_ Bourne compatible
|
||||
echo "echo Hello World" >"a=b"
|
||||
unset a
|
||||
chmod a+x "a=b"
|
||||
PATH=$PATH:.
|
||||
"a=b"
|
||||
echo $a
|
||||
|
||||
# assuming the shell wasn't too buggy, clean up the mess
|
||||
rm -f a=b fish foo
|
@ -30,6 +30,7 @@ basename `pwd`
|
||||
|
||||
# cat
|
||||
cat tester.sh
|
||||
echo hello there | cat tester.sh -
|
||||
|
||||
# chmod
|
||||
# chown
|
||||
@ -39,7 +40,6 @@ cat tester.sh
|
||||
# clear - can't be tested here
|
||||
# cmp
|
||||
# cp
|
||||
# mv
|
||||
|
||||
# cut
|
||||
echo "1234" | cut -c1
|
||||
@ -102,36 +102,35 @@ echo -n "no newline"
|
||||
|
||||
|
||||
# expr
|
||||
# XXX: something's wrong with the way I'm doing these. Figure it out later.
|
||||
#expr 1 \| 1
|
||||
#expr 1 \| 0
|
||||
#expr 0 \| 1
|
||||
#expr 0 \| 0
|
||||
#
|
||||
#expr 1 \& 1
|
||||
#expr 1 \& 0
|
||||
#expr 0 \& 1
|
||||
#expr 0 \& 0
|
||||
#
|
||||
#expr 0 \< 1
|
||||
#expr 1 \< 0
|
||||
#
|
||||
#expr 1 \> 0
|
||||
#expr 0 \> 1
|
||||
#
|
||||
#expr 0 \<= 1
|
||||
#expr 1 \<= 0
|
||||
#expr 1 \<= 1
|
||||
#
|
||||
#expr 1 \>= 0
|
||||
#expr 0 \>= 1
|
||||
#expr 1 \>= 1
|
||||
#
|
||||
#expr 1 + 2
|
||||
#expr 2 - 1
|
||||
#expr 2 \* 3
|
||||
#expr 12 / 2
|
||||
#expr 12 % 5
|
||||
expr 1 \\| 1
|
||||
expr 1 \\| 0
|
||||
expr 0 \\| 1
|
||||
expr 0 \\| 0
|
||||
|
||||
expr 1 \\& 1
|
||||
expr 1 \\& 0
|
||||
expr 0 \\& 1
|
||||
expr 0 \\& 0
|
||||
|
||||
expr 0 \\< 1
|
||||
expr 1 \\< 0
|
||||
|
||||
expr 1 \\> 0
|
||||
expr 0 \\> 1
|
||||
|
||||
expr 0 \\<= 1
|
||||
expr 1 \\<= 0
|
||||
expr 1 \\<= 1
|
||||
|
||||
expr 1 \\>= 0
|
||||
expr 0 \\>= 1
|
||||
expr 1 \\>= 1
|
||||
|
||||
expr 1 + 2
|
||||
expr 2 - 1
|
||||
expr 2 \\* 3
|
||||
expr 12 / 2
|
||||
expr 12 % 5
|
||||
|
||||
# somebody else can do all the string stuff
|
||||
|
||||
@ -156,7 +155,10 @@ grep -lc strdup ../*.c
|
||||
grep -cv strdup ../*.c
|
||||
|
||||
# gunzip
|
||||
|
||||
# gzip
|
||||
echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
|
||||
echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz
|
||||
# halt
|
||||
|
||||
# head
|
||||
@ -183,7 +185,8 @@ id -un
|
||||
|
||||
|
||||
# ifconfig
|
||||
#ifconfig
|
||||
# requires BB_FEATURE_IFCONFIG_STATUS
|
||||
ifconfig
|
||||
#ifconfig -a
|
||||
#ifconfig eth0
|
||||
#ifconfig lo
|
||||
@ -196,7 +199,7 @@ id -un
|
||||
# not going to do any more
|
||||
|
||||
# length
|
||||
# ln
|
||||
# ln - see ln_tests.mk
|
||||
# loadacm
|
||||
# loadfont
|
||||
# loadkmap
|
||||
@ -240,6 +243,7 @@ mount
|
||||
# not going to test any more
|
||||
|
||||
# mt
|
||||
# mv - see mv_tests.mk
|
||||
# nc
|
||||
# nfsmount
|
||||
# nslookup
|
||||
@ -267,7 +271,10 @@ touch F ; rm F
|
||||
|
||||
# rmdir
|
||||
# rmmod - won't test: dangerous
|
||||
|
||||
# route
|
||||
route
|
||||
|
||||
# rpmunpack
|
||||
|
||||
# sed - we can do some one-liners here; probably needs it's own input file
|
||||
@ -282,6 +289,8 @@ sed -e '/test/s/dangerous/PELIGROSO/' testcases
|
||||
sh -c "echo a b c"
|
||||
sh -c ">"
|
||||
sh -c "a"
|
||||
#sh sh.testcases
|
||||
|
||||
|
||||
# sleep - can't test: produces no output
|
||||
|
||||
@ -310,10 +319,25 @@ echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B
|
||||
|
||||
# test
|
||||
# tftp
|
||||
|
||||
# touch
|
||||
touch tmpfile1; ls tmpfile1; rm -f tmpfile1
|
||||
touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
|
||||
|
||||
# tr
|
||||
echo "cbaab" | tr abc zyx
|
||||
echo "TESTING A B C" | tr [A-Z] [a-z]
|
||||
# not GNU compatible
|
||||
echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
|
||||
echo abc[] | tr a[b AXB
|
||||
echo testing | tr -d aeiou
|
||||
|
||||
# true
|
||||
true ; echo $?
|
||||
|
||||
# false
|
||||
false ; echo $?
|
||||
|
||||
# tty
|
||||
# umount
|
||||
# uname
|
||||
|
@ -87,7 +87,7 @@ unalias -a # gets rid of aliases that might create different output
|
||||
|
||||
|
||||
# do extra setup (if any)
|
||||
if [ ! -z $SETUP ]
|
||||
if [ ! -z "$SETUP" ]
|
||||
then
|
||||
[ $DEBUG -ge 2 ] && echo "running setup commands in $SETUP"
|
||||
source $SETUP
|
||||
@ -120,8 +120,12 @@ do
|
||||
|
||||
# change line to include "busybox" before every statement
|
||||
line="$BUSYBOX $line"
|
||||
line=${line//;/; $BUSYBOX }
|
||||
line=${line//|/| $BUSYBOX }
|
||||
# is this a bash-2-ism?
|
||||
# line=${line//;/; $BUSYBOX }
|
||||
# line=${line//|/| $BUSYBOX }
|
||||
# assume $BUSYBOX has no commas
|
||||
line=`echo $line | sed -e 's,;,; '$BUSYBOX, \
|
||||
-e 's,|,| '$BUSYBOX,`
|
||||
|
||||
# execute line using busybox programs
|
||||
[ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE
|
||||
@ -143,11 +147,11 @@ done
|
||||
|
||||
|
||||
# do normal cleanup
|
||||
[ $KEEPTMPFILES == "no" ] && rm -f $BB_OUT $GNU_OUT
|
||||
[ "$KEEPTMPFILES" = "no" ] && rm -f $BB_OUT $GNU_OUT
|
||||
|
||||
|
||||
# do extra cleanup (if any)
|
||||
if [ ! -z $CLEANUP ]
|
||||
if [ ! -z "$CLEANUP" ]
|
||||
then
|
||||
[ $DEBUG -ge 2 ] && echo "running cleanup commands in $CLEANUP"
|
||||
source $CLEANUP
|
||||
|
Loading…
Reference in New Issue
Block a user