diff options
author | Mark Whitley <markw@lineo.com> | 2001-05-24 17:15:33 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-05-24 17:15:33 +0000 |
commit | 04052f96e1385405787356f0955afadd73d8f029 (patch) | |
tree | 1a95bdf6e1e21bb031b872d032ba2ca0d0664757 | |
parent | a813afc24f864e0055bdd0ef8cde6777a514b212 (diff) | |
download | busybox-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.testcases | 33 | ||||
-rw-r--r-- | tests/testcases | 90 | ||||
-rwxr-xr-x | tests/tester.sh | 14 |
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. | ||
2 | echo `echo -e foo\\\necho bar` | ||
3 | |||
4 | echo THIS IS A TEST >foo | ||
5 | cat $(echo FOO | tr 'A-Z' 'a-z') | ||
6 | cat foo | tr 'A-Z' 'a-z' | ||
7 | cat $(echo FOO | tr 'A-Z' 'a-z') | tr 'A-Z' 'a-z' | ||
8 | |||
9 | cat foo | if true; then tr 'A-Z' 'a-z'; else echo bar1; fi | ||
10 | cat foo | if false; then tr 'A-Z' 'a-z'; else echo bar2; fi | ||
11 | if true; then tr 'A-Z' 'a-z'; else echo bar3; fi <foo | ||
12 | if false; then tr 'A-Z' 'a-z'; else echo bar4; fi <foo | ||
13 | if true || false; then echo foo; else echo bar5; fi | ||
14 | if 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. | ||
18 | unset TMP | ||
19 | rm -f fish | ||
20 | TMP=fish >$TMP | ||
21 | ls fish | ||
22 | |||
23 | # The following example shows that hush's parser is | ||
24 | # not _really_ Bourne compatible | ||
25 | echo "echo Hello World" >"a=b" | ||
26 | unset a | ||
27 | chmod a+x "a=b" | ||
28 | PATH=$PATH:. | ||
29 | "a=b" | ||
30 | echo $a | ||
31 | |||
32 | # assuming the shell wasn't too buggy, clean up the mess | ||
33 | 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` | |||
30 | 30 | ||
31 | # cat | 31 | # cat |
32 | cat tester.sh | 32 | cat tester.sh |
33 | echo 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 |
45 | echo "1234" | cut -c1 | 45 | echo "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. | 105 | expr 1 \\| 1 |
106 | #expr 1 \| 1 | 106 | expr 1 \\| 0 |
107 | #expr 1 \| 0 | 107 | expr 0 \\| 1 |
108 | #expr 0 \| 1 | 108 | expr 0 \\| 0 |
109 | #expr 0 \| 0 | 109 | |
110 | # | 110 | expr 1 \\& 1 |
111 | #expr 1 \& 1 | 111 | expr 1 \\& 0 |
112 | #expr 1 \& 0 | 112 | expr 0 \\& 1 |
113 | #expr 0 \& 1 | 113 | expr 0 \\& 0 |
114 | #expr 0 \& 0 | 114 | |
115 | # | 115 | expr 0 \\< 1 |
116 | #expr 0 \< 1 | 116 | expr 1 \\< 0 |
117 | #expr 1 \< 0 | 117 | |
118 | # | 118 | expr 1 \\> 0 |
119 | #expr 1 \> 0 | 119 | expr 0 \\> 1 |
120 | #expr 0 \> 1 | 120 | |
121 | # | 121 | expr 0 \\<= 1 |
122 | #expr 0 \<= 1 | 122 | expr 1 \\<= 0 |
123 | #expr 1 \<= 0 | 123 | expr 1 \\<= 1 |
124 | #expr 1 \<= 1 | 124 | |
125 | # | 125 | expr 1 \\>= 0 |
126 | #expr 1 \>= 0 | 126 | expr 0 \\>= 1 |
127 | #expr 0 \>= 1 | 127 | expr 1 \\>= 1 |
128 | #expr 1 \>= 1 | 128 | |
129 | # | 129 | expr 1 + 2 |
130 | #expr 1 + 2 | 130 | expr 2 - 1 |
131 | #expr 2 - 1 | 131 | expr 2 \\* 3 |
132 | #expr 2 \* 3 | 132 | expr 12 / 2 |
133 | #expr 12 / 2 | 133 | expr 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 | |||
156 | grep -cv strdup ../*.c | 155 | grep -cv strdup ../*.c |
157 | 156 | ||
158 | # gunzip | 157 | # gunzip |
158 | |||
159 | # gzip | 159 | # gzip |
160 | echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz | ||
161 | echo 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 |
189 | ifconfig | ||
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 |
276 | route | ||
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 | |||
282 | sh -c "echo a b c" | 289 | sh -c "echo a b c" |
283 | sh -c ">" | 290 | sh -c ">" |
284 | sh -c "a" | 291 | sh -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 |
324 | touch tmpfile1; ls tmpfile1; rm -f tmpfile1 | ||
325 | touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1 | ||
326 | |||
314 | # tr | 327 | # tr |
328 | echo "cbaab" | tr abc zyx | ||
329 | echo "TESTING A B C" | tr [A-Z] [a-z] | ||
330 | # not GNU compatible | ||
331 | echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m] | ||
332 | echo abc[] | tr a[b AXB | ||
333 | echo testing | tr -d aeiou | ||
334 | |||
335 | # true | ||
315 | true ; echo $? | 336 | true ; echo $? |
337 | |||
338 | # false | ||
316 | false ; echo $? | 339 | false ; 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) |
90 | if [ ! -z $SETUP ] | 90 | if [ ! -z "$SETUP" ] |
91 | then | 91 | then |
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) |
150 | if [ ! -z $CLEANUP ] | 154 | if [ ! -z "$CLEANUP" ] |
151 | then | 155 | then |
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 |