diff options
author | Mark Whitley <markw@lineo.com> | 2001-03-10 00:51:29 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-03-10 00:51:29 +0000 |
commit | d2117e9c828e02bfc1da38768fc3f6198cab9340 (patch) | |
tree | 37469d39aa87f07a02cbc72ae4b166ed34826fc0 | |
parent | 09f4af5afd12569fd813ae4701f6936fd5712553 (diff) | |
download | busybox-w32-d2117e9c828e02bfc1da38768fc3f6198cab9340.tar.gz busybox-w32-d2117e9c828e02bfc1da38768fc3f6198cab9340.tar.bz2 busybox-w32-d2117e9c828e02bfc1da38768fc3f6198cab9340.zip |
Created new regression testing framework with a number of testcases (many more
can be added). Also changed 'test' target in makefile to run the new
tester.sh. (Hopefully, we should be able to remove all the tests/*.mk files
soon.)
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | tests/testcases | 301 | ||||
-rwxr-xr-x | tests/tester.sh | 104 |
3 files changed, 409 insertions, 1 deletions
@@ -317,7 +317,10 @@ loop.h: mk_loop_h.sh | |||
317 | @ $(SHELL) $< > $@ | 317 | @ $(SHELL) $< > $@ |
318 | 318 | ||
319 | test tests: | 319 | test tests: |
320 | cd tests && $(MAKE) all | 320 | # old way of doing it |
321 | #cd tests && $(MAKE) all | ||
322 | # new way of doing it | ||
323 | cd tests && ./tester.sh | ||
321 | 324 | ||
322 | clean: | 325 | clean: |
323 | - cd tests && $(MAKE) clean | 326 | - cd tests && $(MAKE) clean |
diff --git a/tests/testcases b/tests/testcases new file mode 100644 index 000000000..1838fa0fc --- /dev/null +++ b/tests/testcases | |||
@@ -0,0 +1,301 @@ | |||
1 | # testcases | ||
2 | # | ||
3 | # This file should be filled with test cases to test applets that: | ||
4 | # | ||
5 | # - can somehow produce output (we can't test sync or sleep) | ||
6 | # - have a GNU (or other) counterpart | ||
7 | # - are not interactive (don't require a ^C or anything) | ||
8 | # - don't require extensive setup or cleanup (a litte setup is fine) | ||
9 | # - don't have huge and possibly damaging effects (fsck, swapoff) | ||
10 | # | ||
11 | # If possible, a test case should be made that tests each option the applet | ||
12 | # supports. When a new option is added, a new test case should be written for | ||
13 | # it. When somebody reports a bug with a testcase, that testcase should be | ||
14 | # added here as well. | ||
15 | # | ||
16 | # Some other guidelines to follow: | ||
17 | # | ||
18 | # - please try to keep applets alphabetized, it will make life easier | ||
19 | # - use the file tester.sh or testcases when you need to do a non-destructive | ||
20 | # test on a file (i.e. cat, md5sum) | ||
21 | # - try to make the applet you're testing the first thing on the line (this | ||
22 | # not always possible) | ||
23 | # - (???) if you have to create a temporary file, call it TMPFILE | ||
24 | |||
25 | |||
26 | # ar | ||
27 | |||
28 | # basename | ||
29 | basename `pwd` | ||
30 | |||
31 | # cat | ||
32 | cat tester.sh | ||
33 | |||
34 | # chmod | ||
35 | # chown | ||
36 | # chgrp | ||
37 | # chroot | ||
38 | # chvt - can't be tested here | ||
39 | # clear - can't be tested here | ||
40 | # cmp | ||
41 | # cp | ||
42 | # mv | ||
43 | |||
44 | # cut | ||
45 | echo "1234" | cut -c1 | ||
46 | echo "f1 f2" | cut -f2 | ||
47 | |||
48 | # date | ||
49 | date | ||
50 | date -R | ||
51 | date -u | ||
52 | date +%d/%m/%y | ||
53 | |||
54 | # dc - needs an input file | ||
55 | # dd | ||
56 | # deallocvt | ||
57 | |||
58 | # df | ||
59 | df | ||
60 | df . | ||
61 | df -k | ||
62 | df -h | ||
63 | df -m | ||
64 | |||
65 | # dirname | ||
66 | dirname `pwd` | ||
67 | |||
68 | # dmesg (XXX: change the silly cmd business in the source) | ||
69 | dmesg | ||
70 | dmesg -n 8 | ||
71 | dmesg -s 512 | ||
72 | # I really don't want to do this next one | ||
73 | #dmesg -c | ||
74 | |||
75 | # dos2unix - needs an input file | ||
76 | # dpkg | ||
77 | # dpkg_deb | ||
78 | |||
79 | # du | ||
80 | du | ||
81 | du -s | ||
82 | du -l | ||
83 | du -k | ||
84 | du -h | ||
85 | du -m | ||
86 | |||
87 | # dumpkmap - no counterprt? | ||
88 | # dutmp - no counterprt? | ||
89 | |||
90 | # echo | ||
91 | echo "foo bar baz" | ||
92 | echo -n "no newline" | ||
93 | |||
94 | |||
95 | # expr | ||
96 | expr 1 \| 1 | ||
97 | expr 1 \| 0 | ||
98 | expr 0 \| 1 | ||
99 | expr 0 \| 0 | ||
100 | |||
101 | expr 1 \& 1 | ||
102 | expr 1 \& 0 | ||
103 | expr 0 \& 1 | ||
104 | expr 0 \& 0 | ||
105 | |||
106 | expr 0 \< 1 | ||
107 | expr 1 \< 0 | ||
108 | |||
109 | expr 1 \> 0 | ||
110 | expr 0 \> 1 | ||
111 | |||
112 | expr 0 \<= 1 | ||
113 | expr 1 \<= 0 | ||
114 | expr 1 \<= 1 | ||
115 | |||
116 | expr 1 \>= 0 | ||
117 | expr 0 \>= 1 | ||
118 | expr 1 \>= 1 | ||
119 | |||
120 | expr 1 + 2 | ||
121 | expr 2 - 1 | ||
122 | expr 2 \* 3 | ||
123 | expr 12 / 2 | ||
124 | expr 12 % 5 | ||
125 | |||
126 | # somebody else can do all the string stuff | ||
127 | |||
128 | |||
129 | # fbset - can't be tested here | ||
130 | # fdflush | ||
131 | # find | ||
132 | find . | ||
133 | |||
134 | # free | ||
135 | free | ||
136 | |||
137 | # freeramdisk | ||
138 | # fsck.minix - won't test | ||
139 | # getopt | ||
140 | # grep | ||
141 | # gunzip | ||
142 | # gzip | ||
143 | # halt | ||
144 | |||
145 | # head | ||
146 | head tester.sh | ||
147 | head -n 2 tester.sh | ||
148 | |||
149 | # hostid | ||
150 | hostid | ||
151 | |||
152 | # hostname | ||
153 | hostname | ||
154 | hostname -s | ||
155 | hostname -i | ||
156 | hostname -d | ||
157 | # not going to do this next one | ||
158 | #hostname -F | ||
159 | |||
160 | # id | ||
161 | id | ||
162 | id -u | ||
163 | id -g | ||
164 | id -ur | ||
165 | id -un | ||
166 | |||
167 | |||
168 | # ifconfig | ||
169 | #ifconfig | ||
170 | #ifconfig eth0 | ||
171 | #ifconfig lo | ||
172 | |||
173 | # init - won't test | ||
174 | # insmod - won't test | ||
175 | |||
176 | # kill | ||
177 | #kill -l | ||
178 | # not going to do any more | ||
179 | |||
180 | # length | ||
181 | # ln | ||
182 | # loadacm | ||
183 | # loadfont | ||
184 | # loadkmap | ||
185 | # logger | ||
186 | # logname | ||
187 | # ls | ||
188 | ls | ||
189 | ls -l | ||
190 | ls -s | ||
191 | ls -h | ||
192 | ls -1 | ||
193 | |||
194 | # lsmod | ||
195 | lsmod | ||
196 | |||
197 | # makedevs | ||
198 | |||
199 | # md5sum | ||
200 | md5sum tester.sh | ||
201 | |||
202 | # mkdir | ||
203 | # mkfifo | ||
204 | # mkfs.minix - won't test | ||
205 | # mknod | ||
206 | # mkswap - won't test | ||
207 | # mktemp | ||
208 | # more - can't test: interactive | ||
209 | |||
210 | # mount | ||
211 | mount | ||
212 | # not going to test any more | ||
213 | |||
214 | # mt | ||
215 | # nc | ||
216 | # nfsmount | ||
217 | # nslookup | ||
218 | # ping - can't test: interactive (needs ^C) | ||
219 | # pivot_root | ||
220 | # poweroff - won't test | ||
221 | # printf | ||
222 | # ps - there's lotsa differences between busybox ps and any other ps | ||
223 | |||
224 | # pwd | ||
225 | pwd | ||
226 | |||
227 | # rdate - won't test | ||
228 | |||
229 | # readlink | ||
230 | ln -sf tester.sh LINKFILE | ||
231 | readlink LINKFILE | ||
232 | rm -f LINKFILE | ||
233 | |||
234 | # reboot - won't test | ||
235 | # renice - won't test | ||
236 | # reset - can't test: no output | ||
237 | # rm | ||
238 | # rmdir | ||
239 | # rmmod - won't test: dangerous | ||
240 | # route | ||
241 | # rpmunpack | ||
242 | # sed - we can do some one-liners here; probably needs it's own input file | ||
243 | # setkeycodes | ||
244 | # sh - this should probably have it's own testcase or input file | ||
245 | # sleep - can't test: produces no output | ||
246 | # sort | ||
247 | # stty | ||
248 | # swapon - won't test: dangerous | ||
249 | # swapoff - won't test: dangerous | ||
250 | # sync - can't test: no output | ||
251 | # syslogd | ||
252 | |||
253 | # tail | ||
254 | tail tester.sh | ||
255 | tail -n 2 tester.sh | ||
256 | |||
257 | # tar | ||
258 | # tee | ||
259 | # telnet | ||
260 | # test | ||
261 | # tftp | ||
262 | # touch | ||
263 | # tr | ||
264 | true ; echo $? | ||
265 | false ; echo $? | ||
266 | # tty | ||
267 | # umount | ||
268 | # uname | ||
269 | # uniq | ||
270 | # unix2dos | ||
271 | # update | ||
272 | |||
273 | uptime | ||
274 | |||
275 | # usleep | ||
276 | # uudecode | ||
277 | # uuencode | ||
278 | # watchdog | ||
279 | |||
280 | # wc | ||
281 | wc tester.sh | ||
282 | wc -c tester.sh | ||
283 | wc -w tester.sh | ||
284 | wc -l tester.sh | ||
285 | wc -L tester.sh | ||
286 | |||
287 | # wget | ||
288 | |||
289 | # which | ||
290 | which ls | ||
291 | |||
292 | # whoami | ||
293 | whoami | ||
294 | |||
295 | # xargs | ||
296 | # (for some reason, the > redirection isn't working) | ||
297 | #ls -1 > TMPFILE | ||
298 | #xargs md5sum < TMPFILE | ||
299 | #rm -f TMPFILE | ||
300 | |||
301 | # yes - can't test: interactive (needs ^C) | ||
diff --git a/tests/tester.sh b/tests/tester.sh new file mode 100755 index 000000000..bb49609c3 --- /dev/null +++ b/tests/tester.sh | |||
@@ -0,0 +1,104 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # tester.sh - reads testcases from file and tests busybox applets vs GNU | ||
4 | # counterparts | ||
5 | # | ||
6 | |||
7 | # set up defaults (can be changed with cmd-line options) | ||
8 | BUSYBOX=../busybox | ||
9 | TESTCASES=testcases | ||
10 | LOGFILE=tester.log | ||
11 | BB_OUT=bb.out | ||
12 | GNU_OUT=gnu.out | ||
13 | SETUP="" | ||
14 | CLEANUP="" | ||
15 | |||
16 | # internal-use vars | ||
17 | fail_only=0 | ||
18 | |||
19 | |||
20 | while getopts 'p:t:l:b:g:s:c:f' opt | ||
21 | do | ||
22 | case $opt in | ||
23 | p) BUSYBOX=$OPTARG; ;; | ||
24 | t) TESTCASES=$OPTARG; ;; | ||
25 | l) LOGFILE=$OPTARG; ;; | ||
26 | b) BB_OUT=$OPTARG; ;; | ||
27 | g) GNU_OUT=$OPTARG; ;; | ||
28 | s) SETUP=$OPTARG; ;; | ||
29 | c) CLEANUP=$OPTARG; ;; | ||
30 | f) fail_only=1; ;; | ||
31 | *) | ||
32 | echo "usage: $0 [-ptlbgsc]" | ||
33 | echo " -p PATH path to busybox executable" | ||
34 | echo " -t FILE run testcases in FILE" | ||
35 | echo " -l FILE log test results in FILE" | ||
36 | echo " -b FILE store temporary busybox output in FILE" | ||
37 | echo " -g FILE store temporary GNU output in FILE" | ||
38 | echo " -s FILE (setup) run commands in FILE before testcases" | ||
39 | echo " -c FILE (cleanup) run commands in FILE after testcases" | ||
40 | echo " -f display only testcases that fail" | ||
41 | exit 1 | ||
42 | ;; | ||
43 | esac | ||
44 | done | ||
45 | #shift `expr $OPTIND - 1` | ||
46 | |||
47 | |||
48 | # do normal setup | ||
49 | [ -e $LOGFILE ] && rm $LOGFILE | ||
50 | unalias -a # gets rid of aliases that might create different output | ||
51 | |||
52 | # do extra setup (if any) | ||
53 | if [ ! -z $SETUP ] | ||
54 | then | ||
55 | echo "running setup commands in $SETUP" | ||
56 | sh $SETUP | ||
57 | # XXX: Would 'eval' or 'source' work better instead of 'sh'? | ||
58 | fi | ||
59 | |||
60 | |||
61 | # go through each line in the testcase file | ||
62 | cat $TESTCASES | while read line | ||
63 | do | ||
64 | #echo $line | ||
65 | # only process non-blank lines and non-comment lines | ||
66 | if [ "$line" ] | ||
67 | then | ||
68 | if [ `echo "$line" | cut -c1` != "#" ] | ||
69 | then | ||
70 | [ $fail_only -eq 0 ] && echo "testing: $line" | tee -a $LOGFILE | ||
71 | |||
72 | # test if the applet was compiled into busybox | ||
73 | applet=`echo $line | cut -d' ' -f1` | ||
74 | $BUSYBOX 2>&1 | grep -qw $applet | ||
75 | if [ $? -eq 1 ] | ||
76 | then | ||
77 | echo "WHOOPS: $applet not compiled into busybox" | tee -a $LOGFILE | ||
78 | else | ||
79 | $BUSYBOX $line > $BB_OUT | ||
80 | $line > $GNU_OUT | ||
81 | diff -q $BB_OUT $GNU_OUT > /dev/null | ||
82 | if [ $? -eq 1 ] | ||
83 | then | ||
84 | echo "FAILED: $line" | tee -a $LOGFILE | ||
85 | diff -u $BB_OUT $GNU_OUT >> $LOGFILE | ||
86 | fi | ||
87 | fi | ||
88 | fi | ||
89 | fi | ||
90 | done | ||
91 | |||
92 | echo "Finished. Results are in $LOGFILE" | ||
93 | |||
94 | |||
95 | # do normal cleanup | ||
96 | rm -f $BB_OUT $GNU_OUT | ||
97 | |||
98 | # do extra cleanup (if any) | ||
99 | if [ ! -z $CLEANUP ] | ||
100 | then | ||
101 | echo "running cleanup commands in $CLEANUP" | ||
102 | sh $CLEANUP | ||
103 | # XXX: Would 'eval' or 'source' work better instead of 'sh'? | ||
104 | fi | ||