summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2001-05-24 17:15:33 +0000
committerMark Whitley <markw@lineo.com>2001-05-24 17:15:33 +0000
commit04052f96e1385405787356f0955afadd73d8f029 (patch)
tree1a95bdf6e1e21bb031b872d032ba2ca0d0664757
parenta813afc24f864e0055bdd0ef8cde6777a514b212 (diff)
Numerous new testcases from Larry Doolittle and a patch to tester.sh to avoid
a bash2-ism and quote variables that contain strings.
-rw-r--r--tests/sh.testcases33
-rw-r--r--tests/testcases90
-rwxr-xr-xtests/tester.sh14
3 files changed, 99 insertions, 38 deletions
diff --git a/tests/sh.testcases b/tests/sh.testcases
new file mode 100644
index 000000000..85d72a200
--- /dev/null
+++ b/tests/sh.testcases
@@ -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
diff --git a/tests/testcases b/tests/testcases
index 24d491c5b..8f4e14765 100644
--- a/tests/testcases
+++ b/tests/testcases
@@ -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
diff --git a/tests/tester.sh b/tests/tester.sh
index a4fa38d34..92090068d 100755
--- a/tests/tester.sh
+++ b/tests/tester.sh
@@ -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