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 /tests/tester.sh | |
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.)
Diffstat (limited to 'tests/tester.sh')
-rwxr-xr-x | tests/tester.sh | 104 |
1 files changed, 104 insertions, 0 deletions
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 | ||