From: Yuri Schaeffer Date: Tue, 17 Sep 2013 14:08:38 +0000 (+0000) Subject: Start with vdg unit test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dd505eab07914cfde8ef2f69429e2c4e04d4d30;p=thirdparty%2Funbound.git Start with vdg unit test git-svn-id: file:///svn/unbound/branches/edns-subnet@2957 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/Makefile.in b/Makefile.in index 801e6ac8d..1888e9877 100644 --- a/Makefile.in +++ b/Makefile.in @@ -133,10 +133,11 @@ COMPAT_OBJ_WITHOUT_CTIME=$(LIBOBJ_WITHOUT_CTIME:.o=.lo) UNITTEST_SRC=testcode/unitanchor.c testcode/unitdname.c \ testcode/unitlruhash.c testcode/unitmain.c testcode/unitmsgparse.c \ testcode/unitneg.c testcode/unitregional.c testcode/unitslabhash.c \ -testcode/unitverify.c testcode/readhex.c testcode/ldns-testpkts.c +testcode/unitverify.c testcode/readhex.c testcode/ldns-testpkts.c \ +testcode/unitvandergaast.c UNITTEST_OBJ=unitanchor.lo unitdname.lo unitlruhash.lo unitmain.lo \ unitmsgparse.lo unitneg.lo unitregional.lo unitslabhash.lo unitverify.lo \ -readhex.lo ldns-testpkts.lo +readhex.lo ldns-testpkts.lo unitvandergaast.lo UNITTEST_OBJ_LINK=$(UNITTEST_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) DAEMON_SRC=daemon/acl_list.c daemon/cachedump.c daemon/daemon.c \ daemon/remote.c daemon/stats.c daemon/unbound.c daemon/worker.c @WIN_DAEMON_SRC@ @@ -937,6 +938,8 @@ unitmsgparse.lo unitmsgparse.o: $(srcdir)/testcode/unitmsgparse.c config.h \ $(srcdir)/util/locks.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \ $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h $(srcdir)/util/alloc.h $(srcdir)/util/regional.h \ $(srcdir)/util/net_help.h $(srcdir)/testcode/readhex.h +unitvandergaast.lo unitvandergaast.o: $(srcdir)/testcode/unitvandergaast.c \ + config.h $(srcdir)/util/log.h $(srcdir)/testcode/unitmain.h unitneg.lo unitneg.o: $(srcdir)/testcode/unitneg.c config.h $(srcdir)/util/log.h \ $(srcdir)/util/net_help.h \ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \ diff --git a/edns-subnet/addrtree.c b/edns-subnet/addrtree.c index 433695c29..242fad66b 100644 --- a/edns-subnet/addrtree.c +++ b/edns-subnet/addrtree.c @@ -318,3 +318,19 @@ addrtree_find(const struct addrtree* tree, const addrkey_t* addr, node = edge->node; } } + +/** Wrappers for static functions to unit test */ +int unittest_wrapper_addrtree_cmpbit(const addrkey_t* key1, + const addrkey_t* key2, addrlen_t n) { + return cmpbit(key1, key2, n); +} +addrlen_t unittest_wrapper_addrtree_bits_common(const addrkey_t* s1, + addrlen_t l1, const addrkey_t* s2, addrlen_t l2, addrlen_t skip) { + return bits_common(s1, l1, s2, l2, skip); +} + + +//~ static struct addredge* edge_create(struct addrnode* node, const addrkey_t* addr, addrlen_t addrlen) +//~ static struct addrnode* node_create(struct reply_info* elem, addrlen_t scope) +//~ static void freenode_recursive(struct addrtree* tree, struct addrnode* node) +//~ static int issub(const addrkey_t* s1, addrlen_t l1, const addrkey_t* s2, addrlen_t l2, addrlen_t skip) diff --git a/edns-subnet/addrtree.h b/edns-subnet/addrtree.h index 4685bf927..c7d5efb30 100644 --- a/edns-subnet/addrtree.h +++ b/edns-subnet/addrtree.h @@ -107,4 +107,9 @@ void addrtree_insert(struct addrtree* tree, const addrkey_t* addr, struct addrnode* addrtree_find(const struct addrtree* tree, const addrkey_t* addr, addrlen_t sourcemask); +/** Wrappers for static functions to unit test */ +int unittest_wrapper_addrtree_cmpbit(const addrkey_t* key1, + const addrkey_t* key2, addrlen_t n); +addrlen_t unittest_wrapper_addrtree_bits_common(const addrkey_t* s1, + addrlen_t l1, const addrkey_t* s2, addrlen_t l2, addrlen_t skip); #endif /* ADDRTREE_H */ diff --git a/testcode/unitmain.c b/testcode/unitmain.c index 122f09b86..30316a6f7 100644 --- a/testcode/unitmain.c +++ b/testcode/unitmain.c @@ -588,6 +588,7 @@ main(int argc, char* argv[]) slabhash_test(); infra_test(); msgparse_test(); + vandergaast_test(); checklock_stop(); printf("%d checks ok.\n", testcount); #ifdef HAVE_SSL diff --git a/testcode/unitmain.h b/testcode/unitmain.h index 6cfad3eb5..456ddddad 100644 --- a/testcode/unitmain.h +++ b/testcode/unitmain.h @@ -72,5 +72,8 @@ void verify_test(void); void neg_test(void); /** unit test for regional allocator functions */ void regional_test(void); - +#ifdef CLIENT_SUBNET +/** - */ +void vandergaast_test(void); +#endif /* CLIENT_SUBNET */ #endif /* TESTCODE_UNITMAIN_H */