Some new testcases, some improvements to the tester.sh script.

This commit is contained in:
Mark Whitley 2001-03-13 23:30:18 +00:00
parent b3d6e2df95
commit c75f83d874
2 changed files with 146 additions and 70 deletions

View File

@ -52,7 +52,10 @@ date -u
date +%d/%m/%y date +%d/%m/%y
# dc - needs an input file # dc - needs an input file
# dd # dd
dd if=/dev/urandom of=O bs=1k count=1 ; ls -l O ; rm O
# deallocvt # deallocvt
# df # df
@ -93,35 +96,36 @@ echo -n "no newline"
# expr # expr
expr 1 \| 1 # XXX: something's wrong with the way I'm doing these. Figure it out later.
expr 1 \| 0 #expr 1 \| 1
expr 0 \| 1 #expr 1 \| 0
expr 0 \| 0 #expr 0 \| 1
#expr 0 \| 0
expr 1 \& 1 #
expr 1 \& 0 #expr 1 \& 1
expr 0 \& 1 #expr 1 \& 0
expr 0 \& 0 #expr 0 \& 1
#expr 0 \& 0
expr 0 \< 1 #
expr 1 \< 0 #expr 0 \< 1
#expr 1 \< 0
expr 1 \> 0 #
expr 0 \> 1 #expr 1 \> 0
#expr 0 \> 1
expr 0 \<= 1 #
expr 1 \<= 0 #expr 0 \<= 1
expr 1 \<= 1 #expr 1 \<= 0
#expr 1 \<= 1
expr 1 \>= 0 #
expr 0 \>= 1 #expr 1 \>= 0
expr 1 \>= 1 #expr 0 \>= 1
#expr 1 \>= 1
expr 1 + 2 #
expr 2 - 1 #expr 1 + 2
expr 2 \* 3 #expr 2 - 1
expr 12 / 2 #expr 2 \* 3
expr 12 % 5 #expr 12 / 2
#expr 12 % 5
# somebody else can do all the string stuff # somebody else can do all the string stuff
@ -167,6 +171,7 @@ id -un
# ifconfig # ifconfig
#ifconfig #ifconfig
#ifconfig -a
#ifconfig eth0 #ifconfig eth0
#ifconfig lo #ifconfig lo
@ -184,12 +189,13 @@ id -un
# loadkmap # loadkmap
# logger # logger
# logname # logname
# ls # ls
ls ls ../e*
ls -l ls -l ../e*
ls -s ls -s ../e*
ls -h ls -h ../e*
ls -1 ls -1 ../e*
# lsmod # lsmod
lsmod lsmod
@ -200,7 +206,16 @@ lsmod
md5sum tester.sh md5sum tester.sh
# mkdir # mkdir
mkdir D ; ls -ld D ; rmdir D
# mkfifo # mkfifo
#
# we will test making one. actually testing pushing data through it requires
# more interaction than we can manage here.
# (these lines turn up an existing ls bug)
mkfifo F ; ls -l F ; rm F
mkfifo -m 0600 F ; ls -l F ; rm F
# mkfs.minix - won't test # mkfs.minix - won't test
# mknod # mknod
# mkswap - won't test # mkswap - won't test
@ -215,7 +230,8 @@ mount
# nc # nc
# nfsmount # nfsmount
# nslookup # nslookup
# ping - can't test: interactive (needs ^C) # ping
ping -c 3 yahoo.com
# pivot_root # pivot_root
# poweroff - won't test # poweroff - won't test
# printf # printf
@ -227,14 +243,15 @@ pwd
# rdate - won't test # rdate - won't test
# readlink # readlink
ln -sf tester.sh LINKFILE ln -sf tester.sh L ; readlink L ; rm -f L
readlink LINKFILE
rm -f LINKFILE
# reboot - won't test # reboot - won't test
# renice - won't test # renice - won't test
# reset - can't test: no output # reset - can't test: no output
# rm # rm
touch F ; rm F
# rmdir # rmdir
# rmmod - won't test: dangerous # rmmod - won't test: dangerous
# route # route
@ -243,20 +260,30 @@ rm -f LINKFILE
# setkeycodes # setkeycodes
# sh - this should probably have it's own testcase or input file # sh - this should probably have it's own testcase or input file
# sleep - can't test: produces no output # sleep - can't test: produces no output
# sort # sort
sort tester.sh
sort -n tester.sh
sort -r tester.sh
# stty # stty
# swapon - won't test: dangerous # swapon - won't test: dangerous
# swapoff - won't test: dangerous # swapoff - won't test: dangerous
# sync - can't test: no output # sync - can't test: no output
# syslogd # syslogd - won't test: too involved
# tail # tail
tail tester.sh tail tester.sh
tail -n 2 tester.sh tail -n 2 tester.sh
# tar # tar
# tee # tee
# telnet echo "please tee me!" | tee A B C ; cat A B C
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
# telnet - can't test: interactive
# test # test
# tftp # tftp
# touch # touch
@ -270,6 +297,7 @@ false ; echo $?
# unix2dos # unix2dos
# update # update
# uptime
uptime uptime
# usleep # usleep
@ -293,9 +321,7 @@ which ls
whoami whoami
# xargs # xargs
# (for some reason, the > redirection isn't working) ls -1 ../e* | xargs
#ls -1 > TMPFILE ls -1 ../e* | xargs md5sum
#xargs md5sum < TMPFILE
#rm -f TMPFILE
# yes - can't test: interactive (needs ^C) # yes - can't test: interactive (needs ^C)

View File

@ -3,6 +3,8 @@
# tester.sh - reads testcases from file and tests busybox applets vs GNU # tester.sh - reads testcases from file and tests busybox applets vs GNU
# counterparts # counterparts
# #
# This should be run from within the tests/ directory. Before you run it, you
# should compile up a busybox that has all applets and all features turned on.
# set up defaults (can be changed with cmd-line options) # set up defaults (can be changed with cmd-line options)
BUSYBOX=../busybox BUSYBOX=../busybox
@ -12,32 +14,38 @@ BB_OUT=bb.out
GNU_OUT=gnu.out GNU_OUT=gnu.out
SETUP="" SETUP=""
CLEANUP="" CLEANUP=""
KEEPTMPFILES="no"
# internal-use vars DEBUG=2
fail_only=0
while getopts 'p:t:l:b:g:s:c:f' opt #while getopts 'p:t:l:b:g:s:c:kd:' opt
while getopts 'p:t:l:s:c:kd:' opt
do do
case $opt in case $opt in
p) BUSYBOX=$OPTARG; ;; p) BUSYBOX=$OPTARG; ;;
t) TESTCASES=$OPTARG; ;; t) TESTCASES=$OPTARG; ;;
l) LOGFILE=$OPTARG; ;; l) LOGFILE=$OPTARG; ;;
b) BB_OUT=$OPTARG; ;; # b) BB_OUT=$OPTARG; ;;
g) GNU_OUT=$OPTARG; ;; # g) GNU_OUT=$OPTARG; ;;
s) SETUP=$OPTARG; ;; s) SETUP=$OPTARG; ;;
c) CLEANUP=$OPTARG; ;; c) CLEANUP=$OPTARG; ;;
f) fail_only=1; ;; k) KEEPTMPFILES="yes"; ;;
d) DEBUG=$OPTARG; ;;
*) *)
echo "usage: $0 [-ptlbgsc]" echo "usage: $0 [-ptlbgsc]"
echo " -p PATH path to busybox executable" echo " -p PATH path to busybox executable (default=$BUSYBOX)"
echo " -t FILE run testcases in FILE" echo " -t FILE run testcases in FILE (default=$TESTCASES)"
echo " -l FILE log test results in FILE" echo " -l FILE log test results in FILE (default=$LOGFILE)"
echo " -b FILE store temporary busybox output in FILE" # echo " -b FILE store temporary busybox output in FILE"
echo " -g FILE store temporary GNU output in FILE" # echo " -g FILE store temporary GNU output in FILE"
echo " -s FILE (setup) run commands in FILE before testcases" echo " -s FILE (setup) run commands in FILE before testcases"
echo " -c FILE (cleanup) run commands in FILE after testcases" echo " -c FILE (cleanup) run commands in FILE after testcases"
echo " -f display only testcases that fail" echo " -k keep temporary output files (don't delete them)"
echo " -d NUM set level of debugging output"
echo " 0 = no output"
echo " 1 = output failures / whoops lines only"
echo " 2 = (default) output setup / cleanup msgs and testcase lines"
echo " 3+= other debug noise (internal stuff)"
exit 1 exit 1
;; ;;
esac esac
@ -45,16 +53,44 @@ done
#shift `expr $OPTIND - 1` #shift `expr $OPTIND - 1`
# maybe print some debug output
if [ $DEBUG -ge 3 ]
then
echo "BUSYBOX=$BUSYBOX"
echo "TESTCASES=$TESTCASES"
echo "LOGFILE=$LOGFILE"
echo "BB_OUT=$BB_OUT"
echo "GNU_OUT=$GNU_OUT"
echo "SETUP=$SETUP"
echo "CLEANUP=$CLEANUP"
echo "DEBUG=$DEBUG"
fi
# do sanity checks
if [ ! -e $BUSYBOX ]
then
echo "Busybox executable: $BUSYBOX not found!"
exit 1
fi
if [ ! -e $TESTCASES ]
then
echo "Testcases file: $TESTCASES not found!"
exit 1
fi
# do normal setup # do normal setup
[ -e $LOGFILE ] && rm $LOGFILE [ -e $LOGFILE ] && rm $LOGFILE
unalias -a # gets rid of aliases that might create different output unalias -a # gets rid of aliases that might create different output
# do extra setup (if any) # do extra setup (if any)
if [ ! -z $SETUP ] if [ ! -z $SETUP ]
then then
echo "running setup commands in $SETUP" [ $DEBUG -ge 2 ] && echo "running setup commands in $SETUP"
sh $SETUP source $SETUP
# XXX: Would 'eval' or 'source' work better instead of 'sh'?
fi fi
@ -67,21 +103,35 @@ do
then then
if [ `echo "$line" | cut -c1` != "#" ] if [ `echo "$line" | cut -c1` != "#" ]
then then
[ $fail_only -eq 0 ] && echo "testing: $line" | tee -a $LOGFILE
# test if the applet was compiled into busybox # test if the applet was compiled into busybox
applet=`echo $line | cut -d' ' -f1` # (this only tests the applet at the beginning of the line)
#applet=`echo $line | cut -d' ' -f1`
applet=`echo $line | sed 's/\(^[^ ;]*\)[ ;].*/\1/'`
$BUSYBOX 2>&1 | grep -qw $applet $BUSYBOX 2>&1 | grep -qw $applet
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
echo "WHOOPS: $applet not compiled into busybox" | tee -a $LOGFILE echo "WHOOPS: $applet not compiled into busybox" | tee -a $LOGFILE
else else
$BUSYBOX $line > $BB_OUT
$line > $GNU_OUT # execute line using gnu / system programs
[ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE
sh -c "$line" > $GNU_OUT
# change line to include "busybox" before every statement
line="$BUSYBOX $line"
line=${line//;/; $BUSYBOX }
line=${line//|/| $BUSYBOX }
# execute line using busybox programs
[ $DEBUG -ge 2 ] && echo "testing: $line" | tee -a $LOGFILE
sh -c "$line" > $BB_OUT
# see if they match
diff -q $BB_OUT $GNU_OUT > /dev/null diff -q $BB_OUT $GNU_OUT > /dev/null
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
echo "FAILED: $line" | tee -a $LOGFILE [ $DEBUG -ge 1 ] && echo "FAILED: $line" | tee -a $LOGFILE
diff -u $BB_OUT $GNU_OUT >> $LOGFILE diff -u $BB_OUT $GNU_OUT >> $LOGFILE
fi fi
fi fi
@ -89,16 +139,16 @@ do
fi fi
done done
echo "Finished. Results are in $LOGFILE" [ $DEBUG -gt 0 ] && echo "Finished. Results are in $LOGFILE"
# do normal cleanup # do normal cleanup
rm -f $BB_OUT $GNU_OUT [ $KEEPTMPFILES == "no" ] && rm -f $BB_OUT $GNU_OUT
# do extra cleanup (if any) # do extra cleanup (if any)
if [ ! -z $CLEANUP ] if [ ! -z $CLEANUP ]
then then
echo "running cleanup commands in $CLEANUP" [ $DEBUG -ge 2 ] && echo "running cleanup commands in $CLEANUP"
sh $CLEANUP source $CLEANUP
# XXX: Would 'eval' or 'source' work better instead of 'sh'?
fi fi