aboutsummaryrefslogtreecommitdiff
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)
downloadbusybox-w32-04052f96e1385405787356f0955afadd73d8f029.tar.gz
busybox-w32-04052f96e1385405787356f0955afadd73d8f029.tar.bz2
busybox-w32-04052f96e1385405787356f0955afadd73d8f029.zip
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 @@
1# try running this with bash, ksh, ash, and hush.
2echo `echo -e foo\\\necho bar`
3
4echo THIS IS A TEST >foo
5cat $(echo FOO | tr 'A-Z' 'a-z')
6cat foo | tr 'A-Z' 'a-z'
7cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z'
8
9cat foo | if true; then tr 'A-Z' 'a-z'; else echo bar1; fi
10cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi
11if true; then tr 'A-Z' 'a-z'; else echo bar3; fi <foo
12if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo
13if true || false; then echo foo; else echo bar5; fi
14if true && false; then echo bar6; else echo foo; fi
15
16# ash, lash, and hush do not create fish; bash and ksh do. Tough.
17# Thanks to Tapani Tarvainen <tt@mit.jyu.fi> for this stress test.
18unset TMP
19rm -f fish
20TMP=fish >$TMP
21ls fish
22
23# The following example shows that hush's parser is
24# not _really_ Bourne compatible
25echo "echo Hello World" >"a=b"
26unset a
27chmod a+x "a=b"
28PATH=$PATH:.
29"a=b"
30echo $a
31
32# assuming the shell wasn't too buggy, clean up the mess
33rm -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`
30 30
31# cat 31# cat
32cat tester.sh 32cat tester.sh
33echo hello there | cat tester.sh -
33 34
34# chmod 35# chmod
35# chown 36# chown
@@ -39,7 +40,6 @@ cat tester.sh
39# clear - can't be tested here 40# clear - can't be tested here
40# cmp 41# cmp
41# cp 42# cp
42# mv
43 43
44# cut 44# cut
45echo "1234" | cut -c1 45echo "1234" | cut -c1
@@ -102,36 +102,35 @@ echo -n "no newline"
102 102
103 103
104# expr 104# expr
105# XXX: something's wrong with the way I'm doing these. Figure it out later. 105expr 1 \\| 1
106#expr 1 \| 1 106expr 1 \\| 0
107#expr 1 \| 0 107expr 0 \\| 1
108#expr 0 \| 1 108expr 0 \\| 0
109#expr 0 \| 0 109
110# 110expr 1 \\& 1
111#expr 1 \& 1 111expr 1 \\& 0
112#expr 1 \& 0 112expr 0 \\& 1
113#expr 0 \& 1 113expr 0 \\& 0
114#expr 0 \& 0 114
115# 115expr 0 \\< 1
116#expr 0 \< 1 116expr 1 \\< 0
117#expr 1 \< 0 117
118# 118expr 1 \\> 0
119#expr 1 \> 0 119expr 0 \\> 1
120#expr 0 \> 1 120
121# 121expr 0 \\<= 1
122#expr 0 \<= 1 122expr 1 \\<= 0
123#expr 1 \<= 0 123expr 1 \\<= 1
124#expr 1 \<= 1 124
125# 125expr 1 \\>= 0
126#expr 1 \>= 0 126expr 0 \\>= 1
127#expr 0 \>= 1 127expr 1 \\>= 1
128#expr 1 \>= 1 128
129# 129expr 1 + 2
130#expr 1 + 2 130expr 2 - 1
131#expr 2 - 1 131expr 2 \\* 3
132#expr 2 \* 3 132expr 12 / 2
133#expr 12 / 2 133expr 12 % 5
134#expr 12 % 5
135 134
136# somebody else can do all the string stuff 135# somebody else can do all the string stuff
137 136
@@ -156,7 +155,10 @@ grep -lc strdup ../*.c
156grep -cv strdup ../*.c 155grep -cv strdup ../*.c
157 156
158# gunzip 157# gunzip
158
159# gzip 159# gzip
160echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
161echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz
160# halt 162# halt
161 163
162# head 164# head
@@ -183,7 +185,8 @@ id -un
183 185
184 186
185# ifconfig 187# ifconfig
186#ifconfig 188# requires BB_FEATURE_IFCONFIG_STATUS
189ifconfig
187#ifconfig -a 190#ifconfig -a
188#ifconfig eth0 191#ifconfig eth0
189#ifconfig lo 192#ifconfig lo
@@ -196,7 +199,7 @@ id -un
196# not going to do any more 199# not going to do any more
197 200
198# length 201# length
199# ln 202# ln - see ln_tests.mk
200# loadacm 203# loadacm
201# loadfont 204# loadfont
202# loadkmap 205# loadkmap
@@ -240,6 +243,7 @@ mount
240# not going to test any more 243# not going to test any more
241 244
242# mt 245# mt
246# mv - see mv_tests.mk
243# nc 247# nc
244# nfsmount 248# nfsmount
245# nslookup 249# nslookup
@@ -267,7 +271,10 @@ touch F ; rm F
267 271
268# rmdir 272# rmdir
269# rmmod - won't test: dangerous 273# rmmod - won't test: dangerous
274
270# route 275# route
276route
277
271# rpmunpack 278# rpmunpack
272 279
273# sed - we can do some one-liners here; probably needs it's own input file 280# 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
282sh -c "echo a b c" 289sh -c "echo a b c"
283sh -c ">" 290sh -c ">"
284sh -c "a" 291sh -c "a"
292#sh sh.testcases
293
285 294
286# sleep - can't test: produces no output 295# sleep - can't test: produces no output
287 296
@@ -310,10 +319,25 @@ echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B
310 319
311# test 320# test
312# tftp 321# tftp
322
313# touch 323# touch
324touch tmpfile1; ls tmpfile1; rm -f tmpfile1
325touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
326
314# tr 327# tr
328echo "cbaab" | tr abc zyx
329echo "TESTING A B C" | tr [A-Z] [a-z]
330# not GNU compatible
331echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
332echo abc[] | tr a[b AXB
333echo testing | tr -d aeiou
334
335# true
315true ; echo $? 336true ; echo $?
337
338# false
316false ; echo $? 339false ; echo $?
340
317# tty 341# tty
318# umount 342# umount
319# uname 343# 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
87 87
88 88
89# do extra setup (if any) 89# do extra setup (if any)
90if [ ! -z $SETUP ] 90if [ ! -z "$SETUP" ]
91then 91then
92 [ $DEBUG -ge 2 ] && echo "running setup commands in $SETUP" 92 [ $DEBUG -ge 2 ] && echo "running setup commands in $SETUP"
93 source $SETUP 93 source $SETUP
@@ -120,8 +120,12 @@ do
120 120
121 # change line to include "busybox" before every statement 121 # change line to include "busybox" before every statement
122 line="$BUSYBOX $line" 122 line="$BUSYBOX $line"
123 line=${line//;/; $BUSYBOX } 123 # is this a bash-2-ism?
124 line=${line//|/| $BUSYBOX } 124 # line=${line//;/; $BUSYBOX }
125 # line=${line//|/| $BUSYBOX }
126 # assume $BUSYBOX has no commas
127 line=`echo $line | sed -e 's,;,; '$BUSYBOX, \
128 -e 's,|,| '$BUSYBOX,`
125 129
126 # execute line using busybox programs 130 # execute line using busybox programs
127 [ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE 131 [ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE
@@ -143,11 +147,11 @@ done
143 147
144 148
145# do normal cleanup 149# do normal cleanup
146[ $KEEPTMPFILES == "no" ] && rm -f $BB_OUT $GNU_OUT 150[ "$KEEPTMPFILES" = "no" ] && rm -f $BB_OUT $GNU_OUT
147 151
148 152
149# do extra cleanup (if any) 153# do extra cleanup (if any)
150if [ ! -z $CLEANUP ] 154if [ ! -z "$CLEANUP" ]
151then 155then
152 [ $DEBUG -ge 2 ] && echo "running cleanup commands in $CLEANUP" 156 [ $DEBUG -ge 2 ] && echo "running cleanup commands in $CLEANUP"
153 source $CLEANUP 157 source $CLEANUP