diff options
-rw-r--r-- | tests/testcases | 114 | ||||
-rwxr-xr-x | tests/tester.sh | 102 |
2 files changed, 146 insertions, 70 deletions
diff --git a/tests/testcases b/tests/testcases index 1838fa0fc..822030621 100644 --- a/tests/testcases +++ b/tests/testcases | |||
@@ -52,7 +52,10 @@ date -u | |||
52 | date +%d/%m/%y | 52 | date +%d/%m/%y |
53 | 53 | ||
54 | # dc - needs an input file | 54 | # dc - needs an input file |
55 | |||
55 | # dd | 56 | # dd |
57 | dd if=/dev/urandom of=O bs=1k count=1 ; ls -l O ; rm O | ||
58 | |||
56 | # deallocvt | 59 | # deallocvt |
57 | 60 | ||
58 | # df | 61 | # df |
@@ -93,35 +96,36 @@ echo -n "no newline" | |||
93 | 96 | ||
94 | 97 | ||
95 | # expr | 98 | # expr |
96 | expr 1 \| 1 | 99 | # XXX: something's wrong with the way I'm doing these. Figure it out later. |
97 | expr 1 \| 0 | 100 | #expr 1 \| 1 |
98 | expr 0 \| 1 | 101 | #expr 1 \| 0 |
99 | expr 0 \| 0 | 102 | #expr 0 \| 1 |
100 | 103 | #expr 0 \| 0 | |
101 | expr 1 \& 1 | 104 | # |
102 | expr 1 \& 0 | 105 | #expr 1 \& 1 |
103 | expr 0 \& 1 | 106 | #expr 1 \& 0 |
104 | expr 0 \& 0 | 107 | #expr 0 \& 1 |
105 | 108 | #expr 0 \& 0 | |
106 | expr 0 \< 1 | 109 | # |
107 | expr 1 \< 0 | 110 | #expr 0 \< 1 |
108 | 111 | #expr 1 \< 0 | |
109 | expr 1 \> 0 | 112 | # |
110 | expr 0 \> 1 | 113 | #expr 1 \> 0 |
111 | 114 | #expr 0 \> 1 | |
112 | expr 0 \<= 1 | 115 | # |
113 | expr 1 \<= 0 | 116 | #expr 0 \<= 1 |
114 | expr 1 \<= 1 | 117 | #expr 1 \<= 0 |
115 | 118 | #expr 1 \<= 1 | |
116 | expr 1 \>= 0 | 119 | # |
117 | expr 0 \>= 1 | 120 | #expr 1 \>= 0 |
118 | expr 1 \>= 1 | 121 | #expr 0 \>= 1 |
119 | 122 | #expr 1 \>= 1 | |
120 | expr 1 + 2 | 123 | # |
121 | expr 2 - 1 | 124 | #expr 1 + 2 |
122 | expr 2 \* 3 | 125 | #expr 2 - 1 |
123 | expr 12 / 2 | 126 | #expr 2 \* 3 |
124 | expr 12 % 5 | 127 | #expr 12 / 2 |
128 | #expr 12 % 5 | ||
125 | 129 | ||
126 | # somebody else can do all the string stuff | 130 | # somebody else can do all the string stuff |
127 | 131 | ||
@@ -167,6 +171,7 @@ id -un | |||
167 | 171 | ||
168 | # ifconfig | 172 | # ifconfig |
169 | #ifconfig | 173 | #ifconfig |
174 | #ifconfig -a | ||
170 | #ifconfig eth0 | 175 | #ifconfig eth0 |
171 | #ifconfig lo | 176 | #ifconfig lo |
172 | 177 | ||
@@ -184,12 +189,13 @@ id -un | |||
184 | # loadkmap | 189 | # loadkmap |
185 | # logger | 190 | # logger |
186 | # logname | 191 | # logname |
192 | |||
187 | # ls | 193 | # ls |
188 | ls | 194 | ls ../e* |
189 | ls -l | 195 | ls -l ../e* |
190 | ls -s | 196 | ls -s ../e* |
191 | ls -h | 197 | ls -h ../e* |
192 | ls -1 | 198 | ls -1 ../e* |
193 | 199 | ||
194 | # lsmod | 200 | # lsmod |
195 | lsmod | 201 | lsmod |
@@ -200,7 +206,16 @@ lsmod | |||
200 | md5sum tester.sh | 206 | md5sum tester.sh |
201 | 207 | ||
202 | # mkdir | 208 | # mkdir |
209 | mkdir D ; ls -ld D ; rmdir D | ||
210 | |||
203 | # mkfifo | 211 | # mkfifo |
212 | # | ||
213 | # we will test making one. actually testing pushing data through it requires | ||
214 | # more interaction than we can manage here. | ||
215 | # (these lines turn up an existing ls bug) | ||
216 | mkfifo F ; ls -l F ; rm F | ||
217 | mkfifo -m 0600 F ; ls -l F ; rm F | ||
218 | |||
204 | # mkfs.minix - won't test | 219 | # mkfs.minix - won't test |
205 | # mknod | 220 | # mknod |
206 | # mkswap - won't test | 221 | # mkswap - won't test |
@@ -215,7 +230,8 @@ mount | |||
215 | # nc | 230 | # nc |
216 | # nfsmount | 231 | # nfsmount |
217 | # nslookup | 232 | # nslookup |
218 | # ping - can't test: interactive (needs ^C) | 233 | # ping |
234 | ping -c 3 yahoo.com | ||
219 | # pivot_root | 235 | # pivot_root |
220 | # poweroff - won't test | 236 | # poweroff - won't test |
221 | # printf | 237 | # printf |
@@ -227,14 +243,15 @@ pwd | |||
227 | # rdate - won't test | 243 | # rdate - won't test |
228 | 244 | ||
229 | # readlink | 245 | # readlink |
230 | ln -sf tester.sh LINKFILE | 246 | ln -sf tester.sh L ; readlink L ; rm -f L |
231 | readlink LINKFILE | ||
232 | rm -f LINKFILE | ||
233 | 247 | ||
234 | # reboot - won't test | 248 | # reboot - won't test |
235 | # renice - won't test | 249 | # renice - won't test |
236 | # reset - can't test: no output | 250 | # reset - can't test: no output |
251 | |||
237 | # rm | 252 | # rm |
253 | touch F ; rm F | ||
254 | |||
238 | # rmdir | 255 | # rmdir |
239 | # rmmod - won't test: dangerous | 256 | # rmmod - won't test: dangerous |
240 | # route | 257 | # route |
@@ -243,20 +260,30 @@ rm -f LINKFILE | |||
243 | # setkeycodes | 260 | # setkeycodes |
244 | # sh - this should probably have it's own testcase or input file | 261 | # sh - this should probably have it's own testcase or input file |
245 | # sleep - can't test: produces no output | 262 | # sleep - can't test: produces no output |
263 | |||
246 | # sort | 264 | # sort |
265 | sort tester.sh | ||
266 | sort -n tester.sh | ||
267 | sort -r tester.sh | ||
268 | |||
247 | # stty | 269 | # stty |
248 | # swapon - won't test: dangerous | 270 | # swapon - won't test: dangerous |
249 | # swapoff - won't test: dangerous | 271 | # swapoff - won't test: dangerous |
250 | # sync - can't test: no output | 272 | # sync - can't test: no output |
251 | # syslogd | 273 | # syslogd - won't test: too involved |
252 | 274 | ||
253 | # tail | 275 | # tail |
254 | tail tester.sh | 276 | tail tester.sh |
255 | tail -n 2 tester.sh | 277 | tail -n 2 tester.sh |
256 | 278 | ||
257 | # tar | 279 | # tar |
280 | |||
258 | # tee | 281 | # tee |
259 | # telnet | 282 | echo "please tee me!" | tee A B C ; cat A B C |
283 | echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B C ; rm A B C | ||
284 | |||
285 | # telnet - can't test: interactive | ||
286 | |||
260 | # test | 287 | # test |
261 | # tftp | 288 | # tftp |
262 | # touch | 289 | # touch |
@@ -270,6 +297,7 @@ false ; echo $? | |||
270 | # unix2dos | 297 | # unix2dos |
271 | # update | 298 | # update |
272 | 299 | ||
300 | # uptime | ||
273 | uptime | 301 | uptime |
274 | 302 | ||
275 | # usleep | 303 | # usleep |
@@ -293,9 +321,7 @@ which ls | |||
293 | whoami | 321 | whoami |
294 | 322 | ||
295 | # xargs | 323 | # xargs |
296 | # (for some reason, the > redirection isn't working) | 324 | ls -1 ../e* | xargs |
297 | #ls -1 > TMPFILE | 325 | ls -1 ../e* | xargs md5sum |
298 | #xargs md5sum < TMPFILE | ||
299 | #rm -f TMPFILE | ||
300 | 326 | ||
301 | # yes - can't test: interactive (needs ^C) | 327 | # yes - can't test: interactive (needs ^C) |
diff --git a/tests/tester.sh b/tests/tester.sh index bb49609c3..a4fa38d34 100755 --- a/tests/tester.sh +++ b/tests/tester.sh | |||
@@ -3,6 +3,8 @@ | |||
3 | # tester.sh - reads testcases from file and tests busybox applets vs GNU | 3 | # tester.sh - reads testcases from file and tests busybox applets vs GNU |
4 | # counterparts | 4 | # counterparts |
5 | # | 5 | # |
6 | # This should be run from within the tests/ directory. Before you run it, you | ||
7 | # should compile up a busybox that has all applets and all features turned on. | ||
6 | 8 | ||
7 | # set up defaults (can be changed with cmd-line options) | 9 | # set up defaults (can be changed with cmd-line options) |
8 | BUSYBOX=../busybox | 10 | BUSYBOX=../busybox |
@@ -12,32 +14,38 @@ BB_OUT=bb.out | |||
12 | GNU_OUT=gnu.out | 14 | GNU_OUT=gnu.out |
13 | SETUP="" | 15 | SETUP="" |
14 | CLEANUP="" | 16 | CLEANUP="" |
17 | KEEPTMPFILES="no" | ||
18 | DEBUG=2 | ||
15 | 19 | ||
16 | # internal-use vars | ||
17 | fail_only=0 | ||
18 | 20 | ||
19 | 21 | #while getopts 'p:t:l:b:g:s:c:kd:' opt | |
20 | while getopts 'p:t:l:b:g:s:c:f' opt | 22 | while getopts 'p:t:l:s:c:kd:' opt |
21 | do | 23 | do |
22 | case $opt in | 24 | case $opt in |
23 | p) BUSYBOX=$OPTARG; ;; | 25 | p) BUSYBOX=$OPTARG; ;; |
24 | t) TESTCASES=$OPTARG; ;; | 26 | t) TESTCASES=$OPTARG; ;; |
25 | l) LOGFILE=$OPTARG; ;; | 27 | l) LOGFILE=$OPTARG; ;; |
26 | b) BB_OUT=$OPTARG; ;; | 28 | # b) BB_OUT=$OPTARG; ;; |
27 | g) GNU_OUT=$OPTARG; ;; | 29 | # g) GNU_OUT=$OPTARG; ;; |
28 | s) SETUP=$OPTARG; ;; | 30 | s) SETUP=$OPTARG; ;; |
29 | c) CLEANUP=$OPTARG; ;; | 31 | c) CLEANUP=$OPTARG; ;; |
30 | f) fail_only=1; ;; | 32 | k) KEEPTMPFILES="yes"; ;; |
33 | d) DEBUG=$OPTARG; ;; | ||
31 | *) | 34 | *) |
32 | echo "usage: $0 [-ptlbgsc]" | 35 | echo "usage: $0 [-ptlbgsc]" |
33 | echo " -p PATH path to busybox executable" | 36 | echo " -p PATH path to busybox executable (default=$BUSYBOX)" |
34 | echo " -t FILE run testcases in FILE" | 37 | echo " -t FILE run testcases in FILE (default=$TESTCASES)" |
35 | echo " -l FILE log test results in FILE" | 38 | echo " -l FILE log test results in FILE (default=$LOGFILE)" |
36 | echo " -b FILE store temporary busybox output in FILE" | 39 | # echo " -b FILE store temporary busybox output in FILE" |
37 | echo " -g FILE store temporary GNU output in FILE" | 40 | # echo " -g FILE store temporary GNU output in FILE" |
38 | echo " -s FILE (setup) run commands in FILE before testcases" | 41 | echo " -s FILE (setup) run commands in FILE before testcases" |
39 | echo " -c FILE (cleanup) run commands in FILE after testcases" | 42 | echo " -c FILE (cleanup) run commands in FILE after testcases" |
40 | echo " -f display only testcases that fail" | 43 | echo " -k keep temporary output files (don't delete them)" |
44 | echo " -d NUM set level of debugging output" | ||
45 | echo " 0 = no output" | ||
46 | echo " 1 = output failures / whoops lines only" | ||
47 | echo " 2 = (default) output setup / cleanup msgs and testcase lines" | ||
48 | echo " 3+= other debug noise (internal stuff)" | ||
41 | exit 1 | 49 | exit 1 |
42 | ;; | 50 | ;; |
43 | esac | 51 | esac |
@@ -45,16 +53,44 @@ done | |||
45 | #shift `expr $OPTIND - 1` | 53 | #shift `expr $OPTIND - 1` |
46 | 54 | ||
47 | 55 | ||
56 | # maybe print some debug output | ||
57 | if [ $DEBUG -ge 3 ] | ||
58 | then | ||
59 | echo "BUSYBOX=$BUSYBOX" | ||
60 | echo "TESTCASES=$TESTCASES" | ||
61 | echo "LOGFILE=$LOGFILE" | ||
62 | echo "BB_OUT=$BB_OUT" | ||
63 | echo "GNU_OUT=$GNU_OUT" | ||
64 | echo "SETUP=$SETUP" | ||
65 | echo "CLEANUP=$CLEANUP" | ||
66 | echo "DEBUG=$DEBUG" | ||
67 | fi | ||
68 | |||
69 | |||
70 | # do sanity checks | ||
71 | if [ ! -e $BUSYBOX ] | ||
72 | then | ||
73 | echo "Busybox executable: $BUSYBOX not found!" | ||
74 | exit 1 | ||
75 | fi | ||
76 | |||
77 | if [ ! -e $TESTCASES ] | ||
78 | then | ||
79 | echo "Testcases file: $TESTCASES not found!" | ||
80 | exit 1 | ||
81 | fi | ||
82 | |||
83 | |||
48 | # do normal setup | 84 | # do normal setup |
49 | [ -e $LOGFILE ] && rm $LOGFILE | 85 | [ -e $LOGFILE ] && rm $LOGFILE |
50 | unalias -a # gets rid of aliases that might create different output | 86 | unalias -a # gets rid of aliases that might create different output |
51 | 87 | ||
88 | |||
52 | # do extra setup (if any) | 89 | # do extra setup (if any) |
53 | if [ ! -z $SETUP ] | 90 | if [ ! -z $SETUP ] |
54 | then | 91 | then |
55 | echo "running setup commands in $SETUP" | 92 | [ $DEBUG -ge 2 ] && echo "running setup commands in $SETUP" |
56 | sh $SETUP | 93 | source $SETUP |
57 | # XXX: Would 'eval' or 'source' work better instead of 'sh'? | ||
58 | fi | 94 | fi |
59 | 95 | ||
60 | 96 | ||
@@ -67,21 +103,35 @@ do | |||
67 | then | 103 | then |
68 | if [ `echo "$line" | cut -c1` != "#" ] | 104 | if [ `echo "$line" | cut -c1` != "#" ] |
69 | then | 105 | then |
70 | [ $fail_only -eq 0 ] && echo "testing: $line" | tee -a $LOGFILE | ||
71 | 106 | ||
72 | # test if the applet was compiled into busybox | 107 | # test if the applet was compiled into busybox |
73 | applet=`echo $line | cut -d' ' -f1` | 108 | # (this only tests the applet at the beginning of the line) |
109 | #applet=`echo $line | cut -d' ' -f1` | ||
110 | applet=`echo $line | sed 's/\(^[^ ;]*\)[ ;].*/\1/'` | ||
74 | $BUSYBOX 2>&1 | grep -qw $applet | 111 | $BUSYBOX 2>&1 | grep -qw $applet |
75 | if [ $? -eq 1 ] | 112 | if [ $? -eq 1 ] |
76 | then | 113 | then |
77 | echo "WHOOPS: $applet not compiled into busybox" | tee -a $LOGFILE | 114 | echo "WHOOPS: $applet not compiled into busybox" | tee -a $LOGFILE |
78 | else | 115 | else |
79 | $BUSYBOX $line > $BB_OUT | 116 | |
80 | $line > $GNU_OUT | 117 | # execute line using gnu / system programs |
118 | [ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE | ||
119 | sh -c "$line" > $GNU_OUT | ||
120 | |||
121 | # change line to include "busybox" before every statement | ||
122 | line="$BUSYBOX $line" | ||
123 | line=${line//;/; $BUSYBOX } | ||
124 | line=${line//|/| $BUSYBOX } | ||
125 | |||
126 | # execute line using busybox programs | ||
127 | [ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE | ||
128 | sh -c "$line" > $BB_OUT | ||
129 | |||
130 | # see if they match | ||
81 | diff -q $BB_OUT $GNU_OUT > /dev/null | 131 | diff -q $BB_OUT $GNU_OUT > /dev/null |
82 | if [ $? -eq 1 ] | 132 | if [ $? -eq 1 ] |
83 | then | 133 | then |
84 | echo "FAILED: $line" | tee -a $LOGFILE | 134 | [ $DEBUG -ge 1 ] && echo "FAILED: $line" | tee -a $LOGFILE |
85 | diff -u $BB_OUT $GNU_OUT >> $LOGFILE | 135 | diff -u $BB_OUT $GNU_OUT >> $LOGFILE |
86 | fi | 136 | fi |
87 | fi | 137 | fi |
@@ -89,16 +139,16 @@ do | |||
89 | fi | 139 | fi |
90 | done | 140 | done |
91 | 141 | ||
92 | echo "Finished. Results are in $LOGFILE" | 142 | [ $DEBUG -gt 0 ] && echo "Finished. Results are in $LOGFILE" |
93 | 143 | ||
94 | 144 | ||
95 | # do normal cleanup | 145 | # do normal cleanup |
96 | rm -f $BB_OUT $GNU_OUT | 146 | [ $KEEPTMPFILES == "no" ] && rm -f $BB_OUT $GNU_OUT |
147 | |||
97 | 148 | ||
98 | # do extra cleanup (if any) | 149 | # do extra cleanup (if any) |
99 | if [ ! -z $CLEANUP ] | 150 | if [ ! -z $CLEANUP ] |
100 | then | 151 | then |
101 | echo "running cleanup commands in $CLEANUP" | 152 | [ $DEBUG -ge 2 ] && echo "running cleanup commands in $CLEANUP" |
102 | sh $CLEANUP | 153 | source $CLEANUP |
103 | # XXX: Would 'eval' or 'source' work better instead of 'sh'? | ||
104 | fi | 154 | fi |