diff options
author | Mark Whitley <markw@lineo.com> | 2001-03-13 23:30:18 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-03-13 23:30:18 +0000 |
commit | c75f83d8740c57cd498056d43170cbdca0729275 (patch) | |
tree | 4b8fbaf458aebf36bb336dffcb904a62e2524c56 /tests/tester.sh | |
parent | b3d6e2df95a21034e41d46a18c71dd1c4e07e987 (diff) | |
download | busybox-w32-c75f83d8740c57cd498056d43170cbdca0729275.tar.gz busybox-w32-c75f83d8740c57cd498056d43170cbdca0729275.tar.bz2 busybox-w32-c75f83d8740c57cd498056d43170cbdca0729275.zip |
Some new testcases, some improvements to the tester.sh script.
Diffstat (limited to 'tests/tester.sh')
-rwxr-xr-x | tests/tester.sh | 102 |
1 files changed, 76 insertions, 26 deletions
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 |