From 2a5bcffcc208cf385038fcb198f584d2b68ca095 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 24 Sep 2007 08:04:05 +0000 Subject: [PATCH] Make test command. git-svn-id: file:///svn/unbound/trunk@635 be551aaa-1e26-0410-a405-d3ace91eadb9 --- Makefile.in | 9 +++- doc/Changelog | 4 ++ doc/README | 3 ++ doc/plan | 1 + testcode/do-tests.sh | 10 +++- testcode/mini_tpkg.sh | 110 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 134 insertions(+), 3 deletions(-) create mode 100755 testcode/mini_tpkg.sh diff --git a/Makefile.in b/Makefile.in index 3cf9dc837..64ed245c8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -90,9 +90,14 @@ $(BUILD)%.o: $(srcdir)/%.c @if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi $Q$(COMPILE) -c $< -o $@ -.PHONY: clean realclean doc lint all install uninstall +.PHONY: clean realclean doc lint all install uninstall tests test -all: $(COMMON_OBJ) unbound unittest testbound lock-verify pktview signit memstats +all: $(COMMON_OBJ) unbound + +tests: unittest testbound lock-verify pktview signit memstats + +test: tests + bash testcode/do-tests.sh unbound: $(DAEMON_OBJ) $(INFO) Link $@ diff --git a/doc/Changelog b/doc/Changelog index 737e95e66..c14385e8d 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +24 September 2007: Wouter + - do not make test programs by default. + - But 'make test' will perform all of the tests. + 21 September 2007: Wouter - fixup empty_DS_name allocated in wrong region (port DEC Alpha). - fixup testcode lock safety (port FreeBSD). diff --git a/doc/README b/doc/README index af05c88b0..85ba0fcca 100644 --- a/doc/README +++ b/doc/README @@ -37,6 +37,9 @@ This software is under BSD license, see LICENSE for details. the amount of memory it thinks it should be using, and reports memory usage in detail. +* 'make test' attempts to run a series of tests, depending on the support + programs that are installed. + Known issues ------------ o If libevent is older (before 1.3c), unbound will exit instead of reload diff --git a/doc/plan b/doc/plan index 57d533473..709b70236 100644 --- a/doc/plan +++ b/doc/plan @@ -161,6 +161,7 @@ Styleguide: linked list cleanup list. unit test on this. do not call region to avoid name-collision with nsd regions, 'regional'. * read root hints from file. +* failover to next server in 1 second, instead of 100 seconds on one server. * failure to return answer, w. reason (donotq, noanswer servers, cannot find servers, validationfail w.classification, error), with threadno, starttime and endtime and qname/type/class, prime/qflags, diff --git a/testcode/do-tests.sh b/testcode/do-tests.sh index b1fcd040d..2685caea1 100755 --- a/testcode/do-tests.sh +++ b/testcode/do-tests.sh @@ -2,8 +2,10 @@ NEED_SPLINT='00-lint.tpkg' NEED_DOXYGEN='01-doc.tpkg' +NEED_LDNS_TESTNS='fwd_no_edns.tpkg fwd_tcp_tc.tpkg fwd_tcp.tpkg fwd_three_service.tpkg fwd_three.tpkg fwd_ttlexpire.tpkg fwd_udp.tpkg' cd testdata; +sh ../testcode/mini_tpkg.sh clean for test in `ls *.tpkg`; do SKIP=0 if echo $NEED_SPLINT | grep $test >/dev/null; then @@ -16,10 +18,16 @@ for test in `ls *.tpkg`; do SKIP=1; fi fi + if echo $NEED_LDNS_TESTNS | grep $test >/dev/null; then + if test ! -x "`which ldns-testns`"; then + SKIP=1; + fi + fi if test $SKIP -eq 0; then echo $test - tpkg -a ../.. exe $test + sh ../testcode/mini_tpkg.sh -a ../.. exe $test else echo "skip $test" fi done +sh ../testcode/mini_tpkg.sh report diff --git a/testcode/mini_tpkg.sh b/testcode/mini_tpkg.sh new file mode 100755 index 000000000..283581ff9 --- /dev/null +++ b/testcode/mini_tpkg.sh @@ -0,0 +1,110 @@ +# tpkg that only exes the files. +args="../.." +if test "$1" = "-a"; then + args=$2 + shift + shift +fi + +if test "$1" = "clean"; then + echo "rm -f result.* .done* .tpkg.var.master .tpkg.var.test" + rm -f result.* .done* .tpkg.var.master .tpkg.var.test + exit 0 +fi +if test "$1" = "fake"; then + echo "minitpkg fake $2" + echo "fake" > .done-`basename $2 .tpkg` + exit 0 +fi +if test "$1" = "report" || test "$2" = "report"; then + echo "Minitpkg Report" + for result in result.*; do + name=`echo $result | sed -e 's/result\.//'` + if test -f ".done-$name"; then + if test "$1" != "-q"; then + echo "** PASSED ** : $name" + fi + else + echo "!! FAILED !! : $name" + fi + done + exit 0 +fi + +if test "$1" != 'exe'; then + # usage + echo "mini tpkg. Reduced functionality for old shells." + echo " tpkg exe " + echo " tpkg fake " + echo " tpkg clean" + echo " tpkg [-q] report" + exit 1 +fi +shift + +# do not execute if the disk is too full +DISKLIMIT=100000 +avail=`df . | tail -1 | awk '{print $4}'` +if test "$avail" -lt "$DISKLIMIT"; then + echo "minitpkg: The disk is too full! Only $avail." + exit 1 +fi + +name=`basename $1 .tpkg` +dir=$name.$$ +result=result.$name +done=.done-$name +success="no" +shell="bash" + +# check already done +if test -f .done-$name; then + echo "minitpkg .done-$name exists. skip test." + exit 0 +fi + +# Extract +echo "minitpkg extract $1 to $dir" +mkdir $dir +gzip -cd $name.tpkg | (cd $dir; tar xf -) +cd $dir +mv $name.dir/* . + +# EXE +echo "minitpkg exe $name" +echo "minitpkg exe $name" > $result +if test -f $name.pre; then + echo "minitpkg exe $name.pre" + echo "minitpkg exe $name.pre" >> $result + $shell $name.pre $args >> $result + if test $? -ne 0; then + echo "Warning: $name.pre did not exit successfully" + fi +fi +if test -f $name.test; then + echo "minitpkg exe $name.test" + echo "minitpkg exe $name.test" >> $result + $shell $name.test $args >>$result 2>&1 + if test $? -ne 0; then + echo "$name: FAILED" >> $result + echo "$name: FAILED" + success="no" + else + echo "$name: PASSED" >> $result + echo "$name: PASSED" > ../.done-$name + echo "$name: PASSED" + success="yes" + fi +fi +if test -f $name.post; then + echo "minitpkg exe $name.post" + echo "minitpkg exe $name.post" >> $result + $shell $name.post $args >> $result + if test $? -ne 0; then + echo "Warning: $name.post did not exit successfully" + fi +fi + +mv $result .. +cd .. +rm -rf $dir -- 2.47.2