From f58ac8ada36e24e7cc14c0ca83528ce35df2a8f9 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 28 Feb 2018 20:18:27 -0800 Subject: [PATCH] migrate t_db to lib/dns/tests/db_test --- bin/tests/.gitignore | 1 - bin/tests/Makefile.in | 2 +- bin/tests/db/Makefile.in | 52 - bin/tests/db/dns_db_class_data | 9 - bin/tests/db/dns_db_closeversion_1.data | 11 - bin/tests/db/dns_db_closeversion_1_data | 7 - bin/tests/db/dns_db_closeversion_2.data | 11 - bin/tests/db/dns_db_closeversion_2_data | 7 - bin/tests/db/dns_db_currentversion.data | 11 - bin/tests/db/dns_db_currentversion_data | 7 - bin/tests/db/dns_db_expirenode.data | 11 - bin/tests/db/dns_db_expirenode_data | 7 - bin/tests/db/dns_db_find_1.data | 12 - bin/tests/db/dns_db_find_10.data | 10 - bin/tests/db/dns_db_find_10_data | 8 - bin/tests/db/dns_db_find_1_data | 7 - bin/tests/db/dns_db_find_2.data | 9 - bin/tests/db/dns_db_find_2_data | 9 - bin/tests/db/dns_db_find_3.data | 10 - bin/tests/db/dns_db_find_3_data | 9 - bin/tests/db/dns_db_find_4.data | 9 - bin/tests/db/dns_db_find_4_data | 7 - bin/tests/db/dns_db_find_5.data | 10 - bin/tests/db/dns_db_find_5_data | 8 - bin/tests/db/dns_db_find_6.data | 10 - bin/tests/db/dns_db_find_6_data | 8 - bin/tests/db/dns_db_find_7.data | 12 - bin/tests/db/dns_db_find_7_data | 7 - bin/tests/db/dns_db_find_8.data | 13 - bin/tests/db/dns_db_find_8_data | 7 - bin/tests/db/dns_db_find_9.data | 13 - bin/tests/db/dns_db_find_9_data | 7 - bin/tests/db/dns_db_findnode_1.data | 11 - bin/tests/db/dns_db_findnode_1_data | 9 - bin/tests/db/dns_db_findnode_2.data | 11 - bin/tests/db/dns_db_findnode_2_data | 7 - bin/tests/db/dns_db_iscache_1.data | 11 - bin/tests/db/dns_db_iscache_1_data | 7 - bin/tests/db/dns_db_iscache_2.data | 11 - bin/tests/db/dns_db_iscache_2_data | 7 - bin/tests/db/dns_db_iszone_1.data | 11 - bin/tests/db/dns_db_iszone_1_data | 7 - bin/tests/db/dns_db_iszone_2.data | 11 - bin/tests/db/dns_db_iszone_2_data | 7 - bin/tests/db/dns_db_load_1.data | 11 - bin/tests/db/dns_db_load_25.data | 6 - bin/tests/db/dns_db_load_data | 7 - bin/tests/db/dns_db_load_soa_not_top | 7 - bin/tests/db/dns_db_newversion.data | 11 - bin/tests/db/dns_db_newversion_data | 7 - bin/tests/db/dns_db_origin_1.data | 11 - bin/tests/db/dns_db_origin_data | 8 - bin/tests/db/t_db.c | 3143 ----------------- bin/tests/db/win32/t_db.vcxproj.filters.in | 22 - bin/tests/db/win32/t_db.vcxproj.in | 110 - bin/tests/db/win32/t_db.vcxproj.user | 3 - configure | 3 +- configure.in | 1 - lib/dns/tests/Makefile.in | 2 +- lib/dns/tests/db_test.c | 137 +- .../dns/tests/testdata/db/data.db | 0 util/copyrights | 55 - win32utils/Configure | 2 - win32utils/bind9.sln.in | 8 - 64 files changed, 138 insertions(+), 3847 deletions(-) delete mode 100644 bin/tests/db/Makefile.in delete mode 100644 bin/tests/db/dns_db_class_data delete mode 100644 bin/tests/db/dns_db_closeversion_1.data delete mode 100644 bin/tests/db/dns_db_closeversion_1_data delete mode 100644 bin/tests/db/dns_db_closeversion_2.data delete mode 100644 bin/tests/db/dns_db_closeversion_2_data delete mode 100644 bin/tests/db/dns_db_currentversion.data delete mode 100644 bin/tests/db/dns_db_currentversion_data delete mode 100644 bin/tests/db/dns_db_expirenode.data delete mode 100644 bin/tests/db/dns_db_expirenode_data delete mode 100644 bin/tests/db/dns_db_find_1.data delete mode 100644 bin/tests/db/dns_db_find_10.data delete mode 100644 bin/tests/db/dns_db_find_10_data delete mode 100644 bin/tests/db/dns_db_find_1_data delete mode 100644 bin/tests/db/dns_db_find_2.data delete mode 100644 bin/tests/db/dns_db_find_2_data delete mode 100644 bin/tests/db/dns_db_find_3.data delete mode 100644 bin/tests/db/dns_db_find_3_data delete mode 100644 bin/tests/db/dns_db_find_4.data delete mode 100644 bin/tests/db/dns_db_find_4_data delete mode 100644 bin/tests/db/dns_db_find_5.data delete mode 100644 bin/tests/db/dns_db_find_5_data delete mode 100644 bin/tests/db/dns_db_find_6.data delete mode 100644 bin/tests/db/dns_db_find_6_data delete mode 100644 bin/tests/db/dns_db_find_7.data delete mode 100644 bin/tests/db/dns_db_find_7_data delete mode 100644 bin/tests/db/dns_db_find_8.data delete mode 100644 bin/tests/db/dns_db_find_8_data delete mode 100644 bin/tests/db/dns_db_find_9.data delete mode 100644 bin/tests/db/dns_db_find_9_data delete mode 100644 bin/tests/db/dns_db_findnode_1.data delete mode 100644 bin/tests/db/dns_db_findnode_1_data delete mode 100644 bin/tests/db/dns_db_findnode_2.data delete mode 100644 bin/tests/db/dns_db_findnode_2_data delete mode 100644 bin/tests/db/dns_db_iscache_1.data delete mode 100644 bin/tests/db/dns_db_iscache_1_data delete mode 100644 bin/tests/db/dns_db_iscache_2.data delete mode 100644 bin/tests/db/dns_db_iscache_2_data delete mode 100644 bin/tests/db/dns_db_iszone_1.data delete mode 100644 bin/tests/db/dns_db_iszone_1_data delete mode 100644 bin/tests/db/dns_db_iszone_2.data delete mode 100644 bin/tests/db/dns_db_iszone_2_data delete mode 100644 bin/tests/db/dns_db_load_1.data delete mode 100644 bin/tests/db/dns_db_load_25.data delete mode 100644 bin/tests/db/dns_db_load_data delete mode 100644 bin/tests/db/dns_db_load_soa_not_top delete mode 100644 bin/tests/db/dns_db_newversion.data delete mode 100644 bin/tests/db/dns_db_newversion_data delete mode 100644 bin/tests/db/dns_db_origin_1.data delete mode 100644 bin/tests/db/dns_db_origin_data delete mode 100644 bin/tests/db/t_db.c delete mode 100644 bin/tests/db/win32/t_db.vcxproj.filters.in delete mode 100644 bin/tests/db/win32/t_db.vcxproj.in delete mode 100644 bin/tests/db/win32/t_db.vcxproj.user rename bin/tests/db/dns_db_class_1.data => lib/dns/tests/testdata/db/data.db (100%) diff --git a/bin/tests/.gitignore b/bin/tests/.gitignore index 8cf880b9cf..ec63c56fa2 100644 --- a/bin/tests/.gitignore +++ b/bin/tests/.gitignore @@ -4,7 +4,6 @@ headerdep_test.sh nxtify sdig *_test -t_db gsstest t_dst conf.sh diff --git a/bin/tests/Makefile.in b/bin/tests/Makefile.in index 98b9c2bc7e..f4605f3ff1 100644 --- a/bin/tests/Makefile.in +++ b/bin/tests/Makefile.in @@ -32,7 +32,7 @@ ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@ LIBS = @LIBS@ -SUBDIR = db dst system @PKCS11_TOOLS@ optional +SUBDIR = dst system @PKCS11_TOOLS@ optional TESTDIRS = system diff --git a/bin/tests/db/Makefile.in b/bin/tests/db/Makefile.in deleted file mode 100644 index 3ec4b3542b..0000000000 --- a/bin/tests/db/Makefile.in +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# See the COPYRIGHT file distributed with this work for additional -# information regarding copyright ownership. - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -@BIND9_MAKE_INCLUDES@ - -CINCLUDES = ${TEST_INCLUDES} ${DNS_INCLUDES} \ - ${ISC_INCLUDES} @DST_OPENSSL_INC@ - -CDEFINES = @CRYPTO@ -CWARNINGS = - -DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ -ISCCFGLIBS = ../../../lib/isccfg/libisccfg.@A@ - -DNSDEPLIBS = ../../../lib/dns/libdns.@A@ -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ -ISCCFGDEPLIBS = ../../../lib/isccfg/libisccfg.@A@ - -DEPLIBS = ${DNSDEPLIBS} ${ISCCFGDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${DNSLIBS} ${ISCCFGLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -SRCS = t_db.c - -TARGETS = t_db@EXEEXT@ - -@BIND9_MAKE_RULES@ - -t_db@EXEEXT@: t_db.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_db.@O@ ${TLIB} ${LIBS} - -test: t_db@EXEEXT@ - -@./t_db@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @./t_db -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/db/dns_db_class_data b/bin/tests/db/dns_db_class_data deleted file mode 100644 index 55a0cf8fe6..0000000000 --- a/bin/tests/db/dns_db_class_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_db_class -# -# format: -# filename class -# -# -dns_db_class_1.data in -# dns_db_class_1.data any diff --git a/bin/tests/db/dns_db_closeversion_1.data b/bin/tests/db/dns_db_closeversion_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_closeversion_1.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_closeversion_1_data b/bin/tests/db/dns_db_closeversion_1_data deleted file mode 100644 index 7bfd5b0fd6..0000000000 --- a/bin/tests/db/dns_db_closeversion_1_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_closeversion test 1 -# -# format: -# filename type origin class cache new_name new_type existing_name existing_type -# -dns_db_closeversion_1.data rbt vix.com. in zone a.b.c.vix.com. A a.vix.com. NS diff --git a/bin/tests/db/dns_db_closeversion_2.data b/bin/tests/db/dns_db_closeversion_2.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_closeversion_2.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_closeversion_2_data b/bin/tests/db/dns_db_closeversion_2_data deleted file mode 100644 index e5bcf4da7b..0000000000 --- a/bin/tests/db/dns_db_closeversion_2_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_closeversion test 2 -# -# format: -# filename type origin class cache new_name new_type existing_name existing_type -# -dns_db_closeversion_1.data rbt vix.com. in zone a.b.c.vix.com. A a.vix.com. NS diff --git a/bin/tests/db/dns_db_currentversion.data b/bin/tests/db/dns_db_currentversion.data deleted file mode 100644 index b7cb868bb1..0000000000 --- a/bin/tests/db/dns_db_currentversion.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a.b.c.vix.com. a 1.2.3.4 -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_currentversion_data b/bin/tests/db/dns_db_currentversion_data deleted file mode 100644 index e4a095e0e6..0000000000 --- a/bin/tests/db/dns_db_currentversion_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_currentversion -# -# format: -# filename findname findtype -# -dns_db_currentversion.data rbt vix.com. IN zone a.b.c.vix.com. A diff --git a/bin/tests/db/dns_db_expirenode.data b/bin/tests/db/dns_db_expirenode.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_expirenode.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_expirenode_data b/bin/tests/db/dns_db_expirenode_data deleted file mode 100644 index f51858a297..0000000000 --- a/bin/tests/db/dns_db_expirenode_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_expirenode -# -# format: -# filename type origin class existing_name existing_type -# -dns_db_expirenode.data rbt vix.com. in a.vix.com. 10000 0 ISC_R_NOTFOUND diff --git a/bin/tests/db/dns_db_find_1.data b/bin/tests/db/dns_db_find_1.data deleted file mode 100644 index 8cfc69cca2..0000000000 --- a/bin/tests/db/dns_db_find_1.data +++ /dev/null @@ -1,12 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 -a.b.c in ns b diff --git a/bin/tests/db/dns_db_find_10.data b/bin/tests/db/dns_db_find_10.data deleted file mode 100644 index ca1fc5e76b..0000000000 --- a/bin/tests/db/dns_db_find_10.data +++ /dev/null @@ -1,10 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - -a.b.c in NS ns1.vix.com. -a.b.c in A 1.2.3.4 diff --git a/bin/tests/db/dns_db_find_10_data b/bin/tests/db/dns_db_find_10_data deleted file mode 100644 index d1ab1d3b5d..0000000000 --- a/bin/tests/db/dns_db_find_10_data +++ /dev/null @@ -1,8 +0,0 @@ -# -# test data for dns_db_find expiration time handling -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_10.data rbt vix.com. in cache a.b.c.vix.com. NS 0 1010 ISC_R_NOTFOUND -dns_db_find_10.data rbt vix.com. in cache a.b.c.vix.com. NS 0 0 ISC_R_SUCCESS diff --git a/bin/tests/db/dns_db_find_1_data b/bin/tests/db/dns_db_find_1_data deleted file mode 100644 index e1664cfacd..0000000000 --- a/bin/tests/db/dns_db_find_1_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_find best match -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_1.data rbt vix.com. in zone a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_2.data b/bin/tests/db/dns_db_find_2.data deleted file mode 100644 index ab4b4356fb..0000000000 --- a/bin/tests/db/dns_db_find_2.data +++ /dev/null @@ -1,9 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -fx in ns a.fx.vix.com. -a.fx in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_find_2_data b/bin/tests/db/dns_db_find_2_data deleted file mode 100644 index 0e3ffca3b9..0000000000 --- a/bin/tests/db/dns_db_find_2_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_db_find DNS_R_GLUE -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_2.data rbt vix.com. in zone a.fx.vix.com. A DNS_DBFIND_GLUEOK 0 DNS_R_GLUE -dns_db_find_2.data rbt vix.com. in zone fx.vix.com. NS DNS_DBFIND_GLUEOK 0 DNS_R_GLUE -dns_db_find_2.data rbt vix.com. in zone a.fx.vix.com. NS DNS_DBFIND_GLUEOK 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_3.data b/bin/tests/db/dns_db_find_3.data deleted file mode 100644 index d126e91b96..0000000000 --- a/bin/tests/db/dns_db_find_3.data +++ /dev/null @@ -1,10 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a.b.c in ns b -a.a.b.c in a 10.0.0.1 -b in a 10.0.0.2 diff --git a/bin/tests/db/dns_db_find_3_data b/bin/tests/db/dns_db_find_3_data deleted file mode 100644 index a8e1223a29..0000000000 --- a/bin/tests/db/dns_db_find_3_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_db_find DNS_R_DELAGATION -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_3.data rbt vix.com. in zone a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION -dns_db_find_3.data rbt vix.com. in zone a.a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION -dns_db_find_3.data rbt vix.com. in zone a.a.b.c.vix.com. A DNS_DB_GLUEOK 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_4.data b/bin/tests/db/dns_db_find_4.data deleted file mode 100644 index 4c3b5e9e2e..0000000000 --- a/bin/tests/db/dns_db_find_4.data +++ /dev/null @@ -1,9 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a.b.c in ns b -b.a.b.c in a 10.0.0.2 diff --git a/bin/tests/db/dns_db_find_4_data b/bin/tests/db/dns_db_find_4_data deleted file mode 100644 index b0326a6985..0000000000 --- a/bin/tests/db/dns_db_find_4_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_find DNS_R_DELEGATION -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_4.data rbt vix.com. in zone a.b.c.vix.com. ANY 0 0 DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_find_5.data b/bin/tests/db/dns_db_find_5.data deleted file mode 100644 index e33f631a36..0000000000 --- a/bin/tests/db/dns_db_find_5.data +++ /dev/null @@ -1,10 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a.b.c in DNAME x.y.z -a.x.y.z in A 1.2.3.4 - diff --git a/bin/tests/db/dns_db_find_5_data b/bin/tests/db/dns_db_find_5_data deleted file mode 100644 index dab47c80f7..0000000000 --- a/bin/tests/db/dns_db_find_5_data +++ /dev/null @@ -1,8 +0,0 @@ -# -# test data for dns_db_find DNS_R_DNAME -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_5.data rbt vix.com. in zone x.a.b.c.vix.com. ANY 0 0 DNS_R_DNAME -dns_db_find_5.data rbt vix.com. in zone a.a.b.c.vix.com. ANY 0 0 DNS_R_DNAME diff --git a/bin/tests/db/dns_db_find_6.data b/bin/tests/db/dns_db_find_6.data deleted file mode 100644 index 108f043ec0..0000000000 --- a/bin/tests/db/dns_db_find_6.data +++ /dev/null @@ -1,10 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -exploder in CNAME mx -mx in A 1.2.3.4 - diff --git a/bin/tests/db/dns_db_find_6_data b/bin/tests/db/dns_db_find_6_data deleted file mode 100644 index 47de0e661c..0000000000 --- a/bin/tests/db/dns_db_find_6_data +++ /dev/null @@ -1,8 +0,0 @@ -# -# test data for dns_db_find DNS_R_CNAME -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_6.data rbt vix.com. in zone exploder.vix.com. A 0 0 DNS_R_CNAME -dns_db_find_6.data rbt vix.com. in zone exploder.vix.com. ANY 0 0 ISC_R_SUCCESS diff --git a/bin/tests/db/dns_db_find_7.data b/bin/tests/db/dns_db_find_7.data deleted file mode 100644 index f0ec22bd7d..0000000000 --- a/bin/tests/db/dns_db_find_7.data +++ /dev/null @@ -1,12 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - -a.b.c.d in A 1.2.3.4 -a.b in A 1.2.3.4 -a in NS ns1.vix.com. - diff --git a/bin/tests/db/dns_db_find_7_data b/bin/tests/db/dns_db_find_7_data deleted file mode 100644 index 6592758a49..0000000000 --- a/bin/tests/db/dns_db_find_7_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_find DNS_R_NXDOMAIN -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_7.data rbt vix.com. in zone a.b.c.vix.com. ANY 0 0 DNS_R_NXDOMAIN diff --git a/bin/tests/db/dns_db_find_8.data b/bin/tests/db/dns_db_find_8.data deleted file mode 100644 index 66e61ff3e6..0000000000 --- a/bin/tests/db/dns_db_find_8.data +++ /dev/null @@ -1,13 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - -a.b.c.d in A 1.2.3.4 -a.b.c in A 1.2.3.4 -a.b in A 1.2.3.4 -a in NS ns1.vix.com. - diff --git a/bin/tests/db/dns_db_find_8_data b/bin/tests/db/dns_db_find_8_data deleted file mode 100644 index 4ad0c83cbe..0000000000 --- a/bin/tests/db/dns_db_find_8_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_find DNS_R_NXRRSET -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_8.data rbt vix.com. in zone a.b.c.vix.com. NS 0 0 DNS_R_NXRRSET diff --git a/bin/tests/db/dns_db_find_9.data b/bin/tests/db/dns_db_find_9.data deleted file mode 100644 index 54a6d5f160..0000000000 --- a/bin/tests/db/dns_db_find_9.data +++ /dev/null @@ -1,13 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - -a.b.c.d in NS ns1.vix.com. -a.b.c in A 1.2.3.4 -a.b in NS ns1.vix.com. -a in NS ns1.vix.com. - diff --git a/bin/tests/db/dns_db_find_9_data b/bin/tests/db/dns_db_find_9_data deleted file mode 100644 index d80795cf08..0000000000 --- a/bin/tests/db/dns_db_find_9_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_find ISC_R_NOTFOUND -# -# format: -# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results -# -dns_db_find_9.data rbt vix.com. in cache a.b.c.vix.com. NS 0 0 ISC_R_NOTFOUND diff --git a/bin/tests/db/dns_db_findnode_1.data b/bin/tests/db/dns_db_findnode_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_findnode_1.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_findnode_1_data b/bin/tests/db/dns_db_findnode_1_data deleted file mode 100644 index a73c42545b..0000000000 --- a/bin/tests/db/dns_db_findnode_1_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_db_findnode, case ISC_R_SUCCESS -# -# format: -# filename type origin class cache existingname rdatatype -# -dns_db_findnode_1.data rbt vix.com. in zone a.vix.com. NS ISC_R_SUCCESS -dns_db_findnode_1.data rbt vix.com. in zone b.vix.com. A ISC_R_SUCCESS -dns_db_findnode_1.data rbt vix.com. in zone c.vix.com. A ISC_R_NOTFOUND diff --git a/bin/tests/db/dns_db_findnode_2.data b/bin/tests/db/dns_db_findnode_2.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_findnode_2.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_findnode_2_data b/bin/tests/db/dns_db_findnode_2_data deleted file mode 100644 index db69d209fc..0000000000 --- a/bin/tests/db/dns_db_findnode_2_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_findnode 2 -# -# format: -# filename type origin class cache newname -# -dns_db_findnode_2.data rbt vix.com. in zone a.b.c.vix.com. diff --git a/bin/tests/db/dns_db_iscache_1.data b/bin/tests/db/dns_db_iscache_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_iscache_1.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iscache_1_data b/bin/tests/db/dns_db_iscache_1_data deleted file mode 100644 index af591f9a19..0000000000 --- a/bin/tests/db/dns_db_iscache_1_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_iscache test 1 -# -# format: -# filename db_type origin class -# -dns_db_iscache_1.data rbt . in diff --git a/bin/tests/db/dns_db_iscache_2.data b/bin/tests/db/dns_db_iscache_2.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_iscache_2.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iscache_2_data b/bin/tests/db/dns_db_iscache_2_data deleted file mode 100644 index e859ef7ce5..0000000000 --- a/bin/tests/db/dns_db_iscache_2_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_iscache test 1 -# -# format: -# filename db_type origin class -# -dns_db_iscache_2.data rbt . in diff --git a/bin/tests/db/dns_db_iszone_1.data b/bin/tests/db/dns_db_iszone_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_iszone_1.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iszone_1_data b/bin/tests/db/dns_db_iszone_1_data deleted file mode 100644 index 02862d710d..0000000000 --- a/bin/tests/db/dns_db_iszone_1_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_iszone test 1 -# -# format: -# filename db_type origin class -# -dns_db_iszone_1.data rbt . in diff --git a/bin/tests/db/dns_db_iszone_2.data b/bin/tests/db/dns_db_iszone_2.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_iszone_2.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_iszone_2_data b/bin/tests/db/dns_db_iszone_2_data deleted file mode 100644 index 02d3dc277f..0000000000 --- a/bin/tests/db/dns_db_iszone_2_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_iszone test 2 -# -# format: -# filename db_type origin class -# -dns_db_iszone_2.data rbt . in diff --git a/bin/tests/db/dns_db_load_1.data b/bin/tests/db/dns_db_load_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_load_1.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_load_25.data b/bin/tests/db/dns_db_load_25.data deleted file mode 100644 index 6e21bdacd4..0000000000 --- a/bin/tests/db/dns_db_load_25.data +++ /dev/null @@ -1,6 +0,0 @@ -$TTL 5 -@ IN SOA ns1 hostmaster 1 3600 1200 3600000 3600 -@ IN NS ns1 -ns1 IN A 10.0.0.1 -sub IN SOA ns2 hostmaster 1 3600 1200 3600000 3600 -ns2 IN A 10.0.0.2 diff --git a/bin/tests/db/dns_db_load_data b/bin/tests/db/dns_db_load_data deleted file mode 100644 index 0684c625aa..0000000000 --- a/bin/tests/db/dns_db_load_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_load -# -# format: -# filename type origin cache class findname expected_result -# -dns_db_load_1.data rbt . zone in ISC_R_SUCCESS a. A DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_load_soa_not_top b/bin/tests/db/dns_db_load_soa_not_top deleted file mode 100644 index fbb8dcc61d..0000000000 --- a/bin/tests/db/dns_db_load_soa_not_top +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_load_soa_not_top -# -# format: -# filename type origin cache class findname expected_result -# -dns_db_load_25.data rbt . zone in DNS_R_NOTZONETOP a. A DNS_R_DELEGATION diff --git a/bin/tests/db/dns_db_newversion.data b/bin/tests/db/dns_db_newversion.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_newversion.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_newversion_data b/bin/tests/db/dns_db_newversion_data deleted file mode 100644 index be0c042974..0000000000 --- a/bin/tests/db/dns_db_newversion_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_db_newversion -# -# format: -# filename type origin class cache newname newtype -# -dns_db_newversion.data rbt vix.com. in zone a.b.c.vix.com. A diff --git a/bin/tests/db/dns_db_origin_1.data b/bin/tests/db/dns_db_origin_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_origin_1.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2.vix.com. -a in ns ns3.vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/db/dns_db_origin_data b/bin/tests/db/dns_db_origin_data deleted file mode 100644 index 9c3b458782..0000000000 --- a/bin/tests/db/dns_db_origin_data +++ /dev/null @@ -1,8 +0,0 @@ -# -# test data for dns_db_origin -# -# format: -# filename origin -# -dns_db_origin_1.data . -dns_db_origin_1.data vix.com. diff --git a/bin/tests/db/t_db.c b/bin/tests/db/t_db.c deleted file mode 100644 index 917fb902df..0000000000 --- a/bin/tests/db/t_db.c +++ /dev/null @@ -1,3143 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/* $Id: t_db.c,v 1.41 2011/03/12 04:59:46 tbox Exp $ */ - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static isc_result_t -t_create(const char *db_type, const char *origin, const char *classname, - const char *model, isc_mem_t *mctx, dns_db_t **db) -{ - int len; - isc_result_t dns_result; - dns_dbtype_t dbtype; - isc_textregion_t region; - isc_buffer_t origin_buffer; - dns_fixedname_t dns_origin; - dns_rdataclass_t rdataclass; - - - dbtype = dns_dbtype_zone; - if (strcasecmp(model, "cache") == 0) - dbtype = dns_dbtype_cache; - - dns_fixedname_init(&dns_origin); - len = strlen(origin); - isc_buffer_constinit(&origin_buffer, origin, len); - isc_buffer_add(&origin_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), - &origin_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(dns_result); - } - - DE_CONST(classname, region.base); - region.length = strlen(classname); - dns_result = dns_rdataclass_fromtext(&rdataclass, ®ion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(dns_result); - } - - dns_result = dns_db_create(mctx, db_type, - dns_fixedname_name(&dns_origin), - dbtype, rdataclass, 0, NULL, db); - if (dns_result != ISC_R_SUCCESS) - t_info("dns_db_create failed %s\n", - dns_result_totext(dns_result)); - - return(dns_result); - -} - -static int -t_dns_db_load(char **av) { - char *filename; - char *db_type; - char *origin; - char *model; - char *db_class; - char *expected_load_result; - char *findname; - char *find_type; - char *expected_find_result; - - int result; - int len; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_textregion_t textregion; - isc_buffer_t findname_buffer; - dns_fixedname_t dns_findname; - dns_fixedname_t dns_foundname; - dns_rdataset_t rdataset; - dns_rdatatype_t rdatatype; - dns_dbversion_t *versionp; - isc_result_t exp_load_result; - isc_result_t exp_find_result; - - db = NULL; - mctx = NULL; - ectx = NULL; - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - model = T_ARG(3); - db_class = T_ARG(4); - expected_load_result = T_ARG(5); - findname = T_ARG(6); - find_type = T_ARG(7); - expected_find_result = T_ARG(8); - - t_info("testing using file %s and name %s\n", filename, findname); - - exp_load_result = t_dns_result_fromtext(expected_load_result); - exp_find_result = t_dns_result_fromtext(expected_find_result); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != exp_load_result) { - t_info("dns_db_load returned %s, expected %s\n", - dns_result_totext(dns_result), - dns_result_totext(exp_load_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - if (dns_result != ISC_R_SUCCESS) { - result = T_PASS; - goto cleanup_db; - } - - dns_fixedname_init(&dns_findname); - len = strlen(findname); - isc_buffer_init(&findname_buffer, findname, len); - isc_buffer_add(&findname_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), - &findname_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = find_type; - textregion.length = strlen(find_type); - dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - find_type, - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - versionp = NULL; - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&rdataset); - if (dns_db_iszone(db)) - dns_db_currentversion(db, &versionp); - nodep = NULL; - - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_findname), - versionp, - rdatatype, - DNS_DBFIND_GLUEOK, - 0, - &nodep, - dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - - if (dns_result != exp_find_result) { - t_info("dns_db_find returned %s, expected %s\n", - dns_result_totext(dns_result), - dns_result_totext(exp_find_result)); - result = T_FAIL; - } else { - result = T_PASS; - } - - if (dns_result != ISC_R_NOTFOUND) { - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&rdataset)) - dns_rdataset_disassociate(&rdataset); - } - - if (dns_db_iszone(db)) - dns_db_closeversion(db, &versionp, ISC_FALSE); - cleanup_db: - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); -} - -static const char *a1 = - "A call to dns_db_load(db, filename) loads the contents of " - "the database in filename into db."; - -static void -t1(void) { - int result; - - t_assert("dns_db_load", 1, T_REQUIRED, "%s", a1); - result = t_eval("dns_db_load_data", t_dns_db_load, 9); - t_result(result); -} - - -static const char *a2 = - "When the database db has cache semantics, a call to " - "dns_db_iscache(db) returns ISC_TRUE."; - -static int -t_dns_db_zc_x(char *filename, char *db_type, char *origin, char *db_class, - dns_dbtype_t dbtype, isc_boolean_t(*cf)(dns_db_t *), - isc_boolean_t exp_result) -{ - int result; - int len; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_rdataclass_t rdataclass; - isc_textregion_t textregion; - isc_buffer_t origin_buffer; - dns_fixedname_t dns_origin; - - db = NULL; - mctx = NULL; - ectx = NULL; - - t_info("testing using file %s\n", filename); - - dns_fixedname_init(&dns_origin); - len = strlen(origin); - isc_buffer_init(&origin_buffer, origin, len); - isc_buffer_add(&origin_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), - &origin_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); - } - - textregion.base = db_class; - textregion.length = strlen(db_class); - dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_create(mctx, db_type, - dns_fixedname_name(&dns_origin), - dbtype, rdataclass, 0, NULL, &db); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_create failed %s\n", - dns_result_totext(dns_result)); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result == ISC_R_SUCCESS) { - if ((*cf)(db) == exp_result) - result = T_PASS; - else - result = T_FAIL; - } else { - t_info("dns_db_load failed %s\n", - dns_result_totext(dns_result)); - result = T_FAIL; - } - - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); -} - -static int -test_dns_db_zc_x(const char *filename, dns_dbtype_t dbtype, - isc_boolean_t(*cf)(dns_db_t *), isc_boolean_t exp_result) -{ - - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - char *tokens[T_MAXTOKS]; - - nfails = 0; - nprobs = 0; - - fp = fopen(filename, "r"); - if (fp != NULL) { - line = 0; - while ((p = t_fgetbs(fp)) != NULL) { - - ++line; - - /* - * Skip comment lines. - */ - if ((isspace((unsigned char)*p)) || (*p == '#')) { - (void)free(p); - continue; - } - - cnt = t_bustline(p, tokens); - if (cnt == 4) { - result = t_dns_db_zc_x(tokens[0], /* file */ - tokens[1], /* type */ - tokens[2], /* origin */ - tokens[3], /* class */ - dbtype, /* cache */ - cf, /* check func */ - exp_result);/* expect */ - if (result != T_PASS) { - if (result == T_FAIL) - ++nfails; - else - ++nprobs; - } - } else { - t_info("bad format in %s at line %d\n", - filename, line); - ++nprobs; - } - - (void)free(p); - } - (void)fclose(fp); - } else { - t_info("Missing datafile %s\n", filename); - ++nprobs; - } - - result = T_UNRESOLVED; - - if (nfails == 0 && nprobs == 0) - result = T_PASS; - else if (nfails) - result = T_FAIL; - - return(result); -} - -static void -t2(void) { - int result; - - t_assert("dns_db_iscache", 2, T_REQUIRED, "%s", a2); - result = test_dns_db_zc_x("dns_db_iscache_1_data", - dns_dbtype_cache, dns_db_iscache, ISC_TRUE); - t_result(result); -} - - -static const char *a3 = - "When the database db has zone semantics, a call to " - "dns_db_iscache(db) returns ISC_FALSE."; - - -static void -t3(void) { - int result; - - t_assert("dns_db_iscache", 3, T_REQUIRED, "%s", a3); - result = test_dns_db_zc_x("dns_db_iscache_2_data", - dns_dbtype_zone, dns_db_iscache, ISC_FALSE); - t_result(result); -} - - -static const char *a4 = - "When the database db has zone semantics, a call to " - "dns_db_iszone(db) returns ISC_TRUE."; - - -static void -t4(void) { - int result; - - t_assert("dns_db_iszone", 4, T_REQUIRED, "%s", a4); - result = test_dns_db_zc_x("dns_db_iszone_1_data", - dns_dbtype_zone, dns_db_iszone, ISC_TRUE); - t_result(result); -} - - -static const char *a5 = - "When the database db has cache semantics, a call to " - "dns_db_iszone(db) returns ISC_FALSE."; - -static void -t5(void) { - int result; - - t_assert("dns_db_iszone", 5, T_REQUIRED, "%s", a5); - result = test_dns_db_zc_x("dns_db_iszone_2_data", - dns_dbtype_cache, dns_db_iszone, ISC_FALSE); - t_result(result); -} - -static int -t_dns_db_origin(char **av) { - - char *filename; - char *origin; - - int result; - int len; - int order; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_db_t *db; - dns_fixedname_t dns_origin; - dns_fixedname_t dns_dborigin; - isc_buffer_t origin_buffer; - - db = NULL; - mctx = NULL; - ectx = NULL; - - filename = T_ARG(0); - origin = T_ARG(1); - - t_info("testing with database %s and origin %s\n", - filename, origin); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create("rbt", origin, "in", "isc_true", mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - t_info("t_create failed %s\n", - dns_result_totext(dns_result)); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - dns_fixedname_init(&dns_origin); - dns_fixedname_init(&dns_dborigin); - - len = strlen(origin); - isc_buffer_init(&origin_buffer, origin, len); - isc_buffer_add(&origin_buffer, len); - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), - &origin_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - order = dns_name_compare(dns_fixedname_name(&dns_origin), - dns_db_origin(db)); - if (order == 0) { - result = T_PASS; - } else { - t_info("dns_name_compare returned %d\n", order); - result = T_FAIL; - } - - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - -} - -static const char *a6 = - "A call to dns_db_origin(db) returns the origin of the database."; - -static void -t6(void) { - int result; - - t_assert("dns_db_origin", 6, T_REQUIRED, "%s", a6); - result = t_eval("dns_db_origin_data", t_dns_db_origin, 2); - t_result(result); -} - - -static const char *a7 = - "A call to dns_db_class(db) returns the class of the database."; - - -#define CLASSBUFLEN 256 - -static int -t_dns_db_class(char **av) { - - char *filename; - char *db_class; - - int result; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_db_t *db; - dns_rdataclass_t rdataclass; - dns_rdataclass_t db_rdataclass; - isc_textregion_t textregion; - - filename = T_ARG(0); - db_class = T_ARG(1); - db = NULL; - mctx = NULL; - ectx = NULL; - - t_info("testing with database %s and class %s\n", - filename, db_class); - - textregion.base = db_class; - textregion.length = strlen(db_class); - dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create("rbt", ".", db_class, "isc_true", mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - t_info("t_create failed %s\n", - dns_result_totext(dns_result)); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - db_rdataclass = dns_db_class(db); - if (db_rdataclass == rdataclass) - result = T_PASS; - else { - char classbuf[DNS_RDATACLASS_FORMATSIZE]; - dns_rdataclass_format(db_rdataclass, - classbuf, sizeof(classbuf)); - t_info("dns_db_class returned %s, expected %s\n", - classbuf, db_class); - result = T_FAIL; - } - - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - -} -static void -t7(void) { - int result; - - t_assert("dns_db_class", 7, T_REQUIRED, "%s", a7); - result = t_eval("dns_db_class_data", t_dns_db_class, 2); - t_result(result); -} - - -static const char *a8 = - "A call to dns_db_currentversion() opens the current " - "version for reading."; - -static int -t_dns_db_currentversion(char **av) { - char *filename; - char *db_type; - char *origin; - char *db_class; - char *model; - char *findname; - char *findtype; - - int result; - int len; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_textregion_t textregion; - isc_buffer_t findname_buffer; - dns_fixedname_t dns_findname; - dns_fixedname_t dns_foundname; - dns_rdataset_t rdataset; - dns_rdatatype_t rdatatype; - dns_dbversion_t *cversionp; - dns_dbversion_t *nversionp; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - model = T_ARG(4); - findname = T_ARG(5); - findtype = T_ARG(6); - db = NULL; - mctx = NULL; - ectx = NULL; - - t_info("testing using file %s and name %s\n", filename, findname); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_fixedname_init(&dns_findname); - len = strlen(findname); - isc_buffer_init(&findname_buffer, findname, len); - isc_buffer_add(&findname_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), - &findname_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = findtype; - textregion.length = strlen(findtype); - dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - findtype, - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * find a name we know is there - */ - - cversionp = NULL; - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&rdataset); - dns_db_currentversion(db, &cversionp); - nodep = NULL; - - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_findname), - cversionp, - rdatatype, - 0, - 0, - &nodep, - dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("unable to find %s using current version\n", findname); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * create a new version - * delete the found rdataset in the new version - * attempt to find the rdataset again and expect the find to fail - * close/commit the new version - * attempt to find the rdataset in the current version and - * expect the find to succeed - */ - - nversionp = NULL; - dns_result = dns_db_newversion(db, &nversionp); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_newversion failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_rdataset_disassociate(&rdataset); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Delete the found rdataset in the new version. - */ - dns_result = dns_db_deleterdataset(db, nodep, nversionp, rdatatype, 0); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_deleterdataset failed %s\n", - dns_result_totext(dns_result)); - dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &nodep); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Don't need these now. - */ - dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &nodep); - nodep = NULL; - - /* - * Find the deleted rdataset and expect it to fail. - */ - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_findname), - nversionp, - rdatatype, - 0, - 0, - &nodep, - dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - - if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { - t_info("unexpectedly found %s using current version\n", - findname); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * Close/commit the new version. - */ - dns_db_closeversion(db, &nversionp, ISC_TRUE); - - /* - * Find the deleted rdata in the current version. - */ - dns_result = dns_db_find(db, dns_fixedname_name(&dns_findname), - cversionp, rdatatype, DNS_DBFIND_GLUEOK, - 0, &nodep, dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - - /* - * And expect it to succeed. - */ - if (dns_result == ISC_R_SUCCESS) { - result = T_PASS; - } else { - t_info("cound not find %s using current version\n", findname); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - result = T_FAIL; - } - - dns_db_detachnode(db, &nodep); - dns_rdataset_disassociate(&rdataset); - - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static void -t8(void) { - int result; - - t_assert("dns_db_currentversion", 8, T_REQUIRED, "%s", a8); - result = t_eval("dns_db_currentversion_data", - t_dns_db_currentversion, 7); - t_result(result); -} - -static const char *a9 = - "A call to dns_db_newversion() opens a new version for " - "reading and writing."; - -static int -t_dns_db_newversion(char **av) { - - char *filename; - char *db_type; - char *origin; - char *db_class; - char *model; - char *newname; - char *newtype; - - int result; - int len; - int rval; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - dns_dbnode_t *found_nodep; - isc_textregion_t textregion; - isc_buffer_t newname_buffer; - dns_fixedname_t dns_newname; - dns_fixedname_t dns_foundname; - dns_rdata_t added_rdata = DNS_RDATA_INIT; - const char * added_rdata_data; - dns_rdataset_t added_rdataset; - dns_rdata_t found_rdata = DNS_RDATA_INIT; - dns_rdataset_t found_rdataset; - dns_rdatatype_t rdatatype; - dns_rdataclass_t rdataclass; - dns_dbversion_t *nversionp; - dns_rdatalist_t rdatalist; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - model = T_ARG(4); - newname = T_ARG(5); - newtype = T_ARG(6); - db = NULL; - mctx = NULL; - ectx = NULL; - - /* - * Open a new version, add some data, commit it, - * close it, open a new version, and check that changes - * are present. - */ - - t_info("testing using file %s and name %s\n", filename, newname); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Add a new name. - */ - - dns_fixedname_init(&dns_newname); - len = strlen(newname); - isc_buffer_init(&newname_buffer, newname, len); - isc_buffer_add(&newname_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname), - &newname_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nodep = NULL; - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_newname), - ISC_TRUE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_findnode failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Open a new version and associate some rdata with the new name. - */ - - textregion.base = newtype; - textregion.length = strlen(newtype); - dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - newtype, - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = db_class; - textregion.length = strlen(db_class); - dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rdata_init(&added_rdata); - added_rdata_data = "\x10\x00\x00\x01"; - DE_CONST(added_rdata_data, added_rdata.data); - added_rdata.length = 4; - added_rdata.rdclass = rdataclass; - added_rdata.type = rdatatype; - - dns_rdatalist_init(&rdatalist); - rdatalist.type = rdatatype; - rdatalist.rdclass = rdataclass; - ISC_LIST_APPEND(rdatalist.rdata, &added_rdata, link); - - dns_rdataset_init(&added_rdataset); - dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatalist_tordataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nversionp = NULL; - dns_result = dns_db_newversion(db, &nversionp); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_newversion failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_addrdataset(db, nodep, nversionp, 0, - &added_rdataset, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_addrdataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Close and commit the version. - */ - dns_db_closeversion(db, &nversionp, ISC_TRUE); - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&added_rdataset)) - dns_rdataset_disassociate(&added_rdataset); - nodep = NULL; - - /* - * Open a new version and find the data we added. - */ - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&found_rdataset); - nversionp = NULL; - found_nodep = NULL; - dns_db_newversion(db, &nversionp); - - /* - * Find the recently added name and rdata. - */ - dns_result = dns_db_find(db, dns_fixedname_name(&dns_newname), - nversionp, rdatatype, 0, 0, &found_nodep, - dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - if (dns_result != ISC_R_SUCCESS) { - /* XXXWPK - NXRRSET ??? reference counts ??? */ - t_info("dns_db_find failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &found_nodep); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - dns_result = dns_rdataset_first(&found_rdataset); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataset_first failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * Now make sure its what we expect. - */ - dns_rdata_init(&found_rdata); - dns_rdataset_current(&found_rdataset, &found_rdata); - rval = dns_rdata_compare(&added_rdata, &found_rdata); - if (rval == 0) { - result = T_PASS; - } else { - t_info("dns_rdata_compare returned %d\n", rval); - result = T_FAIL; - } - - /* - * Don't need these now. - */ - dns_db_closeversion(db, &nversionp, ISC_FALSE); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_detachnode(db, &found_nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static void -t9(void) { - int result; - - t_assert("dns_db_newversion", 9, T_REQUIRED, "%s", a9); - result = t_eval("dns_db_newversion_data", t_dns_db_newversion, 7); - t_result(result); -} - -static const char *a10 = - "When versionp points to a read-write version and commit is " - "ISC_TRUE, a call to dns_db_closeversion(db, versionp, commit) " - "causes all changes made in the version to take effect, " - "and returns ISC_R_SUCCESS."; - -static int -t_dns_db_closeversion_1(char **av) { - char *filename; - char *db_type; - char *origin; - char *db_class; - char *model; - char *new_name; - char *new_type; - char *existing_name; - char *existing_type; - - int result; - int len; - int rval; - int nfails; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_textregion_t textregion; - isc_buffer_t name_buffer; - dns_fixedname_t dns_newname; - dns_fixedname_t dns_foundname; - dns_fixedname_t dns_existingname; - dns_rdata_t added_rdata = DNS_RDATA_INIT; - const char * added_rdata_data; - dns_rdataset_t added_rdataset; - dns_rdata_t found_rdata = DNS_RDATA_INIT; - dns_rdataset_t found_rdataset; - dns_rdatatype_t new_rdatatype; - dns_rdatatype_t existing_rdatatype; - dns_rdataclass_t rdataclass; - dns_dbversion_t *nversionp; - dns_dbversion_t *cversionp; - dns_rdatalist_t rdatalist; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - model = T_ARG(4); - new_name = T_ARG(5); - new_type = T_ARG(6); - existing_name = T_ARG(7); - existing_type = T_ARG(8); - - nfails = 0; - db = NULL; - mctx = NULL; - ectx = NULL; - - /* - * Open a new version, add some data, - * remove some data, close with commit, open the current - * version and check that changes are present. - */ - - t_info("testing using file %s and name %s\n", filename, new_name); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Remove all rdata for an existing name. - */ - - dns_fixedname_init(&dns_existingname); - len = strlen(existing_name); - isc_buffer_init(&name_buffer, existing_name, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = existing_type; - textregion.length = strlen(existing_type); - dns_result = dns_rdatatype_fromtext(&existing_rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - existing_type, - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nodep = NULL; - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_existingname), - ISC_FALSE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_findnode %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* open a new version */ - nversionp = NULL; - dns_result = dns_db_newversion(db, &nversionp); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_newversion failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_deleterdataset(db, nodep, nversionp, - existing_rdatatype, 0); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_deleterdataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * add a new name and associate some rdata with it - */ - - dns_db_detachnode(db, &nodep); - nodep = NULL; - - dns_fixedname_init(&dns_newname); - len = strlen(new_name); - isc_buffer_init(&name_buffer, new_name, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_newname), - ISC_TRUE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_findnode failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * associate some rdata with the new name - */ - - textregion.base = new_type; - textregion.length = strlen(new_type); - dns_result = dns_rdatatype_fromtext(&new_rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - new_type, - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = db_class; - textregion.length = strlen(db_class); - dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rdata_init(&added_rdata); - added_rdata_data = "\x10\x00\x00\x01"; - DE_CONST(added_rdata_data, added_rdata.data); - added_rdata.length = 4; - added_rdata.rdclass = rdataclass; - added_rdata.type = new_rdatatype; - - dns_rdatalist_init(&rdatalist); - rdatalist.type = new_rdatatype; - rdatalist.rdclass = rdataclass; - ISC_LIST_APPEND(rdatalist.rdata, &added_rdata, link); - - dns_rdataset_init(&added_rdataset); - dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatalist_tordataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_addrdataset(db, nodep, nversionp, 0, - &added_rdataset, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_addrdataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* close and commit the version */ - dns_db_closeversion(db, &nversionp, ISC_TRUE); - dns_db_detachnode(db, &nodep); - nodep = NULL; - - /* open the current version and check changes */ - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&found_rdataset); - cversionp = NULL; - dns_db_currentversion(db, &cversionp); - - /* find the recently added name and rdata */ - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_newname), - cversionp, - new_rdatatype, - 0, - 0, - &nodep, - dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - if (dns_result != ISC_R_SUCCESS) { - /* XXXWPK NXRRSET ??? reference counting ??? */ - t_info("dns_db_find failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - dns_result = dns_rdataset_first(&found_rdataset); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataset_first failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * Now make sure its what we expect. - */ - dns_rdata_init(&found_rdata); - dns_rdataset_current(&found_rdataset, &found_rdata); - rval = dns_rdata_compare(&added_rdata, &found_rdata); - if (rval != 0) { - t_info("dns_rdata_compare returned %d\n", rval); - ++nfails; - } - - /* - * Now check the rdata deletion. - */ - - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_rdataset_init(&found_rdataset); - dns_db_detachnode(db, &nodep); - nodep = NULL; - dns_fixedname_init(&dns_foundname); - - dns_result = dns_db_find(db, dns_fixedname_name(&dns_existingname), - cversionp, existing_rdatatype, - 0, 0, &nodep, - dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - - if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { - dns_rdataset_disassociate(&found_rdataset); - dns_db_detachnode(db, &nodep); - t_info("dns_db_find %s returned %s\n", existing_name, - dns_result_totext(dns_result)); - ++nfails; - } - - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - if (nfails == 0) - result = T_PASS; - else - result = T_FAIL; - - return(result); -} - -static void -t10(void) { - int result; - - t_assert("dns_db_closeversion", 10, T_REQUIRED, "%s", a10); - result = t_eval("dns_db_closeversion_1_data", - t_dns_db_closeversion_1, 9); - t_result(result); -} - -static const char *a11 = - "When versionp points to a read-write version and commit is " - "ISC_FALSE, a call to dns_db_closeversion(db, versionp, commit) " - "causes all changes made in the version to to be rolled back, " - "and returns ISC_R_SUCCESS."; - -static int -t_dns_db_closeversion_2(char **av) { - char *filename; - char *db_type; - char *origin; - char *db_class; - char *model; - char *new_name; - char *new_type; - char *existing_name; - char *existing_type; - - int result; - int len; - int rval; - int nfails; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_textregion_t textregion; - isc_buffer_t name_buffer; - dns_fixedname_t dns_newname; - dns_fixedname_t dns_foundname; - dns_fixedname_t dns_existingname; - dns_rdata_t added_rdata = DNS_RDATA_INIT; - const char * added_rdata_data; - dns_rdataset_t added_rdataset; - dns_rdata_t found_rdata = DNS_RDATA_INIT; - dns_rdataset_t found_rdataset; - dns_rdatatype_t new_rdatatype; - dns_rdatatype_t existing_rdatatype; - dns_rdataclass_t rdataclass; - dns_dbversion_t *nversionp; - dns_dbversion_t *cversionp; - dns_rdatalist_t rdatalist; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - model = T_ARG(4); - new_name = T_ARG(5); - new_type = T_ARG(6); - existing_name = T_ARG(7); - existing_type = T_ARG(8); - - nfails = 0; - db = NULL; - mctx = NULL; - ectx = NULL; - - /* - * Open a new version, add some data, - * remove some data, close with commit, open the current - * version and check that changes are present. - */ - - t_info("testing using file %s and name %s\n", filename, new_name); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Remove all rdata for an existing name. - */ - - dns_fixedname_init(&dns_existingname); - len = strlen(existing_name); - isc_buffer_init(&name_buffer, existing_name, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = existing_type; - textregion.length = strlen(existing_type); - dns_result = dns_rdatatype_fromtext(&existing_rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - existing_type, - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nodep = NULL; - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_existingname), - ISC_FALSE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_findnode %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Open a new version. - */ - nversionp = NULL; - dns_result = dns_db_newversion(db, &nversionp); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_newversion failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_deleterdataset(db, nodep, nversionp, - existing_rdatatype, 0); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_deleterdataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * add a new name and associate some rdata with it - */ - - dns_db_detachnode(db, &nodep); - nodep = NULL; - - dns_fixedname_init(&dns_newname); - len = strlen(new_name); - isc_buffer_init(&name_buffer, new_name, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_newname), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_newname), - ISC_TRUE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_findnode failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = new_type; - textregion.length = strlen(new_type); - dns_result = dns_rdatatype_fromtext(&new_rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - new_type, dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = db_class; - textregion.length = strlen(db_class); - dns_result = dns_rdataclass_fromtext(&rdataclass, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataclass_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rdata_init(&added_rdata); - added_rdata_data = "\x10\x00\x00\x01"; - DE_CONST(added_rdata_data, added_rdata.data); - added_rdata.length = 4; - added_rdata.rdclass = rdataclass; - added_rdata.type = new_rdatatype; - - dns_rdatalist_init(&rdatalist); - rdatalist.type = new_rdatatype; - rdatalist.rdclass = rdataclass; - ISC_LIST_APPEND(rdatalist.rdata, &added_rdata, link); - - dns_rdataset_init(&added_rdataset); - dns_result = dns_rdatalist_tordataset(&rdatalist, &added_rdataset); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatalist_tordataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_addrdataset(db, nodep, nversionp, 0, - &added_rdataset, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_addrdataset failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Check that our changes took. - */ - dns_db_detachnode(db, &nodep); - nodep = NULL; - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&found_rdataset); - - /* - * Find the recently added name and rdata. - */ - dns_result = dns_db_find(db, dns_fixedname_name(&dns_newname), - nversionp, new_rdatatype, 0, 0, &nodep, - dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - if ((dns_result == ISC_R_NOTFOUND) || - (dns_result == DNS_R_NXDOMAIN) || - (dns_result == DNS_R_NXRRSET)) { - - t_info("dns_db_find failed %s\n", - dns_result_totext(dns_result)); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - dns_result = dns_rdataset_first(&found_rdataset); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdataset_first failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_closeversion(db, &nversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * Now make sure its what we expect. - */ - dns_rdata_init(&found_rdata); - dns_rdataset_current(&found_rdataset, &found_rdata); - rval = dns_rdata_compare(&added_rdata, &found_rdata); - if (rval != 0) { - t_info("dns_rdata_compare returned %d\n", rval); - ++nfails; - } - - /* - * Now check the rdata deletion. - */ - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_rdataset_init(&found_rdataset); - dns_db_detachnode(db, &nodep); - nodep = NULL; - dns_fixedname_init(&dns_foundname); - - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_existingname), - nversionp, - existing_rdatatype, - 0, - 0, - &nodep, - dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - - if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { - t_info("dns_db_find %s returned %s\n", existing_name, - dns_result_totext(dns_result)); - if (dns_rdataset_isassociated(&found_rdataset)) - dns_rdataset_disassociate(&found_rdataset); - dns_db_detachnode(db, &nodep); - ++nfails; - } - - - /* - * Close the version without a commit. - */ - dns_db_closeversion(db, &nversionp, ISC_FALSE); - - /* - * Open the current version and check changes. - */ - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&found_rdataset); - cversionp = NULL; - dns_db_currentversion(db, &cversionp); - - /* - * Find the recently added name and rdata. - */ - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_newname), - cversionp, - new_rdatatype, - 0, - 0, - &nodep, - dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { - t_info("dns_db_find %s returned %s\n", new_name, - dns_result_totext(dns_result)); - dns_rdataset_disassociate(&found_rdataset); - dns_db_detachnode(db, &nodep); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * Now check the rdata deletion. - */ - nodep = NULL; - dns_rdataset_init(&found_rdataset); - dns_fixedname_init(&dns_foundname); - - dns_result = dns_db_find(db, dns_fixedname_name(&dns_existingname), - cversionp, existing_rdatatype, 0, 0, - &nodep, dns_fixedname_name(&dns_foundname), - &found_rdataset, NULL); - - - if ((dns_result == ISC_R_NOTFOUND) || - (dns_result == DNS_R_NXDOMAIN) || - (dns_result == DNS_R_NXRRSET)) { - - t_info("dns_db_find %s returned %s\n", existing_name, - dns_result_totext(dns_result)); - dns_rdataset_disassociate(&found_rdataset); - dns_db_detachnode(db, &nodep); - ++nfails; - } - - dns_db_detachnode(db, &nodep); - dns_rdataset_disassociate(&found_rdataset); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - if (nfails == 0) - result = T_PASS; - else - result = T_FAIL; - - return(result); -} - -static void -t11(void) { - int result; - - t_assert("dns_db_closeversion", 11, T_REQUIRED, "%s", a11); - result = t_eval("dns_db_closeversion_2_data", - t_dns_db_closeversion_2, 9); - t_result(result); -} - -static const char *a12 = - "A call to dns_db_expirenode() marks as stale all records at node " - "which expire at or before 'now'. If 'now' is zero, then the current " - "time will be used."; - -static int -t_dns_db_expirenode(char **av) { - char *filename; - char *db_type; - char *origin; - char *db_class; - char *existing_name; - char *node_xtime; - char *find_xtime; - char *exp_find_result; - - int result; - int len; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t exp_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_buffer_t name_buffer; - dns_fixedname_t dns_foundname; - dns_fixedname_t dns_existingname; - isc_stdtime_t node_expire_time; - isc_stdtime_t find_expire_time; - isc_stdtime_t now; - dns_rdataset_t rdataset; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - existing_name = T_ARG(4); - node_xtime = T_ARG(5); - find_xtime = T_ARG(6); - exp_find_result = T_ARG(7); - mctx = NULL; - ectx = NULL; - - /* - * Find a node, mark it as stale, do a dns_db_find on the name and - * expect it to fail. - */ - - t_info("testing using file %s and name %s\n", filename, existing_name); - - node_expire_time = (isc_stdtime_t) strtol(node_xtime, NULL, 10); - find_expire_time = (isc_stdtime_t) strtol(find_xtime, NULL, 10); - exp_result = t_dns_result_fromtext(exp_find_result); - - isc_stdtime_get(&now); - - dns_fixedname_init(&dns_existingname); - len = strlen(existing_name); - isc_buffer_init(&name_buffer, existing_name, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_existingname), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - db = NULL; - dns_result = t_create(db_type, origin, db_class, "cache", mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nodep = NULL; - - /* - * Check that the node is there. - */ - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_existingname), - ISC_FALSE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("unable to find %s\n", existing_name); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Expire it. - */ - if (node_expire_time != 0) - node_expire_time += now; - - dns_result = dns_db_expirenode(db, nodep, node_expire_time); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_expirenode failed %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&rdataset); - dns_db_detachnode(db, &nodep); - nodep = NULL; - - if (find_expire_time != 0) - find_expire_time += now; - - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_existingname), - NULL, - dns_rdatatype_any, - 0, - find_expire_time, - &nodep, - dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - - if (dns_result == exp_result) { - result = T_PASS; - } else { - t_info("dns_db_find %s returned %s\n", existing_name, - dns_result_totext(dns_result)); - result = T_FAIL; - } - - if ((dns_result != ISC_R_NOTFOUND) && - (dns_result != DNS_R_NXDOMAIN) && - (dns_result != DNS_R_NXRRSET)) { - - /* - * Don't need to disassociate the rdataset because - * we're searching with dns_rdatatype_any. - */ - dns_db_detachnode(db, &nodep); - } - - - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static void -t12(void) { - int result; - - t_assert("dns_db_expirenode", 12, T_REQUIRED, "%s", a12); - result = t_eval("dns_db_expirenode_data", t_dns_db_expirenode, 8); - t_result(result); -} - -static const char *a13 = - "If the node name exists, then a call to " - "dns_db_findnode(db, name, ISC_FALSE, nodep) initializes nodep " - "to point to the node and returns ISC_R_SUCCESS, otherwise " - "it returns ISC_R_NOTFOUND."; - -static int -t_dns_db_findnode_1(char **av) { - char *filename; - char *db_type; - char *origin; - char *db_class; - char *model; - char *find_name; - char *find_type; - char *expected_result; - - int result; - int len; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_buffer_t name_buffer; - dns_rdataset_t rdataset; - dns_rdatatype_t rdatatype; - isc_textregion_t textregion; - dns_fixedname_t dns_name; - dns_dbversion_t *cversionp; - isc_result_t exp_result; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - model = T_ARG(4); - find_name = T_ARG(5); - find_type = T_ARG(6); - expected_result = T_ARG(7); - - db = NULL; - mctx = NULL; - ectx = NULL; - - t_info("testing using file %s and name %s\n", filename, find_name); - - exp_result = t_dns_result_fromtext(expected_result); - - textregion.base = find_type; - textregion.length = strlen(find_type); - dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - find_type, - dns_result_totext(dns_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nodep = NULL; - dns_fixedname_init(&dns_name); - - len = strlen(find_name); - isc_buffer_init(&name_buffer, find_name, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_name), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), - ISC_FALSE, &nodep); - if (dns_result != exp_result) { - t_info("dns_db_findnode failed %s\n", - dns_result_totext(dns_result)); - if (dns_result == ISC_R_SUCCESS) - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * if we're expecting the find to succeed and it did, - * check that the node has been initialized - * by checking for the specified type of rdata - * and expecting the search to succeed - */ - - if (dns_result == ISC_R_SUCCESS) { - cversionp = NULL; - dns_db_currentversion(db, &cversionp); - dns_rdataset_init(&rdataset); - - dns_result = dns_db_findrdataset(db, nodep, cversionp, - rdatatype, 0, - 0, &rdataset, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_rdataset_disassociate(&rdataset); - result = T_PASS; - } else { - t_info("dns_db_findrdataset failed %s\n", - dns_result_totext(dns_result)); - result = T_FAIL; - } - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detachnode(db, &nodep); - } else { - result = T_PASS; - } - - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static void -t13(void) { - int result; - - t_assert("dns_db_findnode", 13, T_REQUIRED, "%s", a13); - result = t_eval("dns_db_findnode_1_data", t_dns_db_findnode_1, 8); - t_result(result); -} - -static const char *a14 = - "If the node name does not exist and create is ISC_TRUE, " - "then a call to dns_db_findnode(db, name, create, nodep) " - "creates the node, initializes nodep to point to the node, " - "and returns ISC_R_SUCCESS."; - -static int -t_dns_db_findnode_2(char **av) { - char *filename; - char *db_type; - char *origin; - char *db_class; - char *model; - char *newname; - - int nfails; - int result; - int len; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - dns_dbnode_t *newnodep; - isc_buffer_t name_buffer; - dns_rdataset_t rdataset; - dns_fixedname_t dns_name; - dns_fixedname_t dns_foundname; - dns_dbversion_t *cversionp; - - filename = T_ARG(0); - db_type = T_ARG(1); - origin = T_ARG(2); - db_class = T_ARG(3); - model = T_ARG(4); - newname = T_ARG(5); - - db = NULL; - mctx = NULL; - ectx = NULL; - nfails = 0; - - t_info("testing using file %s and name %s\n", filename, newname); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - dns_result = t_create(db_type, origin, db_class, model, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, filename); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - nodep = NULL; - dns_fixedname_init(&dns_name); - - /* - * Make sure the name isn't there - */ - len = strlen(newname); - isc_buffer_init(&name_buffer, newname, len); - isc_buffer_add(&name_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_name), - &name_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), - ISC_FALSE, &nodep); - if ((dns_result != ISC_R_NOTFOUND) && - (dns_result != DNS_R_NXDOMAIN) && - (dns_result != DNS_R_NXRRSET)) { - t_info("dns_db_findnode %s\n", - dns_result_totext(dns_result)); - dns_db_detachnode(db, &nodep); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * Add it. - */ - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), - ISC_TRUE, &nodep); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_findnode %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - /* - * Check it. - */ - newnodep = NULL; - dns_rdataset_init(&rdataset); - dns_fixedname_init(&dns_foundname); - cversionp = NULL; - dns_db_currentversion(db, &cversionp); - - /* - * First try dns_db_find DNS_R_NXDOMAIN. - */ - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_name), - cversionp, - dns_rdatatype_any, - 0, - 0, - &newnodep, - dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { - dns_db_detachnode(db, &newnodep); - } - - if (dns_result != DNS_R_NXDOMAIN) { - t_info("dns_db_find %s\n", - dns_result_totext(dns_result)); - ++nfails; - } - - /* - * Then try dns_db_findnode ISC_R_SUCCESS. - */ - dns_result = dns_db_findnode(db, dns_fixedname_name(&dns_name), - ISC_FALSE, &newnodep); - t_info("dns_db_findnode %s\n", dns_result_totext(dns_result)); - if (dns_result == ISC_R_SUCCESS) { - dns_db_detachnode(db, &newnodep); - } else { - t_info("dns_db_findnode %s failed %s\n", newname, - dns_result_totext(dns_result)); - ++nfails; - } - - - dns_db_detachnode(db, &nodep); - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - if (nfails == 0) - result = T_PASS; - else - result = T_FAIL; - - return(result); -} - -static void -t14(void) { - int result; - - t_assert("dns_db_findnode", 14, T_REQUIRED, "%s", a14); - result = t_eval("dns_db_findnode_2_data", t_dns_db_findnode_2, 6); - t_result(result); -} - -static int -t_dns_db_find_x(char **av) { - char *dbfile; - char *dbtype; - char *dborigin; - char *dbclass; - char *dbmodel; - char *findname; - char *findtype; - char *findopts; - char *findtime; - char *expected_result; - - int result; - int len; - int opts; - dns_db_t *db; - isc_result_t dns_result; - isc_result_t isc_result; - isc_stdtime_t ftime; - isc_stdtime_t now; - isc_result_t exp_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_dbnode_t *nodep; - isc_textregion_t textregion; - isc_buffer_t findname_buffer; - dns_fixedname_t dns_findname; - dns_fixedname_t dns_foundname; - dns_rdataset_t rdataset; - dns_rdatatype_t rdatatype; - dns_dbversion_t *cversionp; - - dbfile = T_ARG(0); - dbtype = T_ARG(1); - dborigin = T_ARG(2); - dbclass = T_ARG(3); - dbmodel = T_ARG(4); - findname = T_ARG(5); - findtype = T_ARG(6); - findopts = T_ARG(7); - findtime = T_ARG(8); - expected_result = T_ARG(9); - db = NULL; - mctx = NULL; - ectx = NULL; - opts = 0; - - t_info("testing using %s, name %s, type %s\n", dbfile, findname, - findtype); - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(T_UNRESOLVED); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_hash_create failed %s\n", - isc_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = t_create(dbtype, dborigin, dbclass, dbmodel, mctx, &db); - if (dns_result != ISC_R_SUCCESS) { - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_result = dns_db_load(db, dbfile); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_db_load returned %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - exp_result = t_dns_result_fromtext(expected_result); - - dns_fixedname_init(&dns_findname); - len = strlen(findname); - isc_buffer_init(&findname_buffer, findname, len); - isc_buffer_add(&findname_buffer, len); - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), - &findname_buffer, NULL, 0, NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - textregion.base = findtype; - textregion.length = strlen(findtype); - dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rdatatype_fromtext %s failed %s\n", - findtype, - dns_result_totext(dns_result)); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - if (strstr(findopts, "DNS_DBFIND_GLUEOK")) - opts |= DNS_DBFIND_GLUEOK; - if (strstr(findopts, "DNS_DBFIND_VALIDATEGLUE")) - opts |= DNS_DBFIND_VALIDATEGLUE; - - isc_stdtime_get(&now); - - ftime = strtol(findtime, NULL, 10); - if (ftime != 0) - ftime += now; - - cversionp = NULL; - dns_fixedname_init(&dns_foundname); - dns_rdataset_init(&rdataset); - if (dns_db_iszone(db)) - dns_db_currentversion(db, &cversionp); - nodep = NULL; - - dns_result = dns_db_find(db, - dns_fixedname_name(&dns_findname), - cversionp, - rdatatype, - opts, - ftime, - &nodep, - dns_fixedname_name(&dns_foundname), - &rdataset, NULL); - - if (dns_result != exp_result) { - t_info("dns_db_find %s %s unexpectedly returned %s, " - "expected %s\n", - findname, findtype, dns_result_totext(dns_result), - dns_result_totext(exp_result)); - result = T_FAIL; - } else { - result = T_PASS; - } - - if ((dns_result != ISC_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { - - if ((dns_result != DNS_R_NXRRSET) && - (dns_result != DNS_R_ZONECUT)) - if (dns_rdataset_isassociated(&rdataset)) - dns_rdataset_disassociate(&rdataset); - dns_db_detachnode(db, &nodep); - } - - if (dns_db_iszone(db)) - dns_db_closeversion(db, &cversionp, ISC_FALSE); - dns_db_detach(&db); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static const char *a15 = - "A call to dns_db_find(db, name, version, type, options, now, ...) " - "finds the best match for 'name' and 'type' in version 'version' " - "of 'db'."; - -static void -t15(void) { - int result; - - t_assert("dns_db_find", 15, T_REQUIRED, "%s", a15); - result = t_eval("dns_db_find_1_data", t_dns_db_find_x, 10); - t_result(result); -} - - -static const char *a16 = - "When the desired node and type were found, but are glue, " - "and the DNS_DBFIND_GLUEOK option is set, a call to " - "dns_db_find(db, name, version, type, options, now, ...) " - "returns DNS_R_GLUE."; - -static void -t16(void) { - int result; - - t_assert("dns_db_find", 16, T_REQUIRED, "%s", a16); - result = t_eval("dns_db_find_2_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a17 = - "A call to dns_db_find() returns DNS_R_DELEGATION when the data " - "requested is beneath a zone cut."; - -static void -t17(void) { - int result; - - t_assert("dns_db_find", 17, T_REQUIRED, "%s", a17); - result = t_eval("dns_db_find_3_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a18 = - "A call to dns_db_find() returns DNS_R_DELEGATION when type is " - "dns_rdatatype_any and the desired node is a zone cut."; - -static void -t18(void) { - int result; - - t_assert("dns_db_find", 18, T_REQUIRED, "%s", a18); - result = t_eval("dns_db_find_4_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a19 = - "A call to dns_db_find() returns DNS_R_DNAME when the data " - "requested is beneath a DNAME."; - -static void -t19(void) { - int result; - - t_assert("dns_db_find", 19, T_REQUIRED, "%s", a19); - result = t_eval("dns_db_find_5_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a20 = - "A call to dns_db_find() returns DNS_R_CNAME when the requested " - "rdataset was not found but there is a CNAME at the desired name."; - -static void -t20(void) { - int result; - - t_assert("dns_db_find", 20, T_REQUIRED, "%s", a20); - result = t_eval("dns_db_find_6_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a21 = - "A call to dns_db_find() returns DNS_R_NXDOMAIN when name " - "does not exist."; - -static void -t21(void) { - int result; - - t_assert("dns_db_find", 21, T_REQUIRED, "%s", a21); - result = t_eval("dns_db_find_7_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a22 = - "A call to dns_db_find() returns DNS_R_NXRRSET when " - "the desired name exists, but the desired type does not."; - -static void -t22(void) { - int result; - - t_assert("dns_db_find", 22, T_REQUIRED, "%s", a22); - result = t_eval("dns_db_find_8_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a23 = - "When db is a cache database, a call to dns_db_find() " - "returns ISC_R_NOTFOUND when the desired name does not exist, " - "and no delegation could be found."; - -static void -t23(void) { - int result; - - t_assert("dns_db_find", 23, T_REQUIRED, "%s", a23); - result = t_eval("dns_db_find_9_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a24 = - "When db is a cache database, an rdataset will be found only " - "if at least one rdataset at the found node expires after 'now'."; - -static void -t24(void) { - int result; - - t_assert("dns_db_find", 24, T_REQUIRED, "%s", a24); - result = t_eval("dns_db_find_10_data", t_dns_db_find_x, 10); - t_result(result); -} - -static const char *a25 = - "A call to dns_db_load(db, filename) returns DNS_R_NOTZONETOP " - "when the zone data contains a SOA not at the zone apex."; - -static void -t25(void) { - int result; - - t_assert("dns_db_load", 25, T_REQUIRED, "%s", a25); - result = t_eval("dns_db_load_soa_not_top", t_dns_db_load, 9); - t_result(result); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "dns_db_load" }, - { (PFV) t2, "dns_db_iscache" }, - { (PFV) t3, "dns_db_iscache" }, - { (PFV) t4, "dns_db_iszone" }, - { (PFV) t5, "dns_db_iszone" }, - { (PFV) t6, "dns_db_origin" }, - { (PFV) t7, "dns_db_class" }, - { (PFV) t8, "dns_db_currentversion" }, - { (PFV) t9, "dns_db_newversion" }, - { (PFV) t10, "dns_db_closeversion" }, - { (PFV) t11, "dns_db_closeversion" }, - { (PFV) t12, "dns_db_expirenode" }, - { (PFV) t13, "dns_db_findnode" }, - { (PFV) t14, "dns_db_findnode" }, - { (PFV) t15, "dns_db_find" }, - { (PFV) t16, "dns_db_find" }, - { (PFV) t17, "dns_db_find" }, - { (PFV) t18, "dns_db_find" }, - { (PFV) t19, "dns_db_find" }, - { (PFV) t20, "dns_db_find" }, - { (PFV) t21, "dns_db_find" }, - { (PFV) t22, "dns_db_find" }, - { (PFV) t23, "dns_db_find" }, - { (PFV) t24, "dns_db_find" }, - { (PFV) t25, "dns_db_load" }, - { (PFV) 0, NULL } -}; - -#ifdef WIN32 -int -main(int argc, char **argv) { - t_settests(T_testlist); - return (t_main(argc, argv)); -} -#endif diff --git a/bin/tests/db/win32/t_db.vcxproj.filters.in b/bin/tests/db/win32/t_db.vcxproj.filters.in deleted file mode 100644 index cc32b99ab3..0000000000 --- a/bin/tests/db/win32/t_db.vcxproj.filters.in +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/bin/tests/db/win32/t_db.vcxproj.in b/bin/tests/db/win32/t_db.vcxproj.in deleted file mode 100644 index 1a5b1cd18b..0000000000 --- a/bin/tests/db/win32/t_db.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {E6338E67-3224-4E66-9463-7AD719DA9346} - Win32Proj - t_db - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - true - ..\..\..\..\Build\$(Configuration)\ - .\$(Configuration)\ - - - false - ..\..\..\..\Build\$(Configuration)\ - .\$(Configuration)\ - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - .\$(Configuration)\$(TargetName).pch - .\$(Configuration)\ - .\$(Configuration)\ - $(OutDir)$(TargetName).pdb - true - .\;..\..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\isccfg\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\isccfg\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libisccfg.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - @INTRINSIC@ - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - OnlyExplicitInline - false - true - .\$(Configuration)\$(TargetName).pch - .\$(Configuration)\ - .\$(Configuration)\ - $(OutDir)$(TargetName).pdb - .\;..\..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\isccfg\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\isccfg\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libisccfg.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/db/win32/t_db.vcxproj.user b/bin/tests/db/win32/t_db.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/db/win32/t_db.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/configure b/configure index 4027917423..358cbd581f 100755 --- a/configure +++ b/configure @@ -24157,7 +24157,7 @@ ac_config_commands="$ac_config_commands chmod" # elsewhere if there's a good reason for doing so. # -ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/python/Makefile bin/python/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile bin/tests/db/Makefile bin/tests/dst/Makefile bin/tests/dst/Kdh.+002+18602.key bin/tests/dst/Kdh.+002+18602.private bin/tests/dst/Kdh.+002+48957.key bin/tests/dst/Kdh.+002+48957.private bin/tests/dst/Ktest.+001+00002.key bin/tests/dst/Ktest.+001+54622.key bin/tests/dst/Ktest.+001+54622.private bin/tests/dst/Ktest.+003+23616.key bin/tests/dst/Ktest.+003+23616.private bin/tests/dst/Ktest.+003+49667.key bin/tests/dst/dst_2_data bin/tests/dst/t2_data_1 bin/tests/dst/t2_data_2 bin/tests/dst/t2_dsasig bin/tests/dst/t2_rsasig bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/inline/checkdsa.sh bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/$thread_dir/Makefile lib/isc/$thread_dir/include/Makefile lib/isc/$thread_dir/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/tests/Makefile lib/tests/include/Makefile lib/tests/include/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh" +ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/python/Makefile bin/python/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile bin/tests/dst/Makefile bin/tests/dst/Kdh.+002+18602.key bin/tests/dst/Kdh.+002+18602.private bin/tests/dst/Kdh.+002+48957.key bin/tests/dst/Kdh.+002+48957.private bin/tests/dst/Ktest.+001+00002.key bin/tests/dst/Ktest.+001+54622.key bin/tests/dst/Ktest.+001+54622.private bin/tests/dst/Ktest.+003+23616.key bin/tests/dst/Ktest.+003+23616.private bin/tests/dst/Ktest.+003+49667.key bin/tests/dst/dst_2_data bin/tests/dst/t2_data_1 bin/tests/dst/t2_data_2 bin/tests/dst/t2_dsasig bin/tests/dst/t2_rsasig bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/inline/checkdsa.sh bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/$thread_dir/Makefile lib/isc/$thread_dir/include/Makefile lib/isc/$thread_dir/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/tests/Makefile lib/tests/include/Makefile lib/tests/include/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh" # @@ -25196,7 +25196,6 @@ do "bin/python/isc/tests/policy_test.py") CONFIG_FILES="$CONFIG_FILES bin/python/isc/tests/policy_test.py" ;; "bin/rndc/Makefile") CONFIG_FILES="$CONFIG_FILES bin/rndc/Makefile" ;; "bin/tests/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/Makefile" ;; - "bin/tests/db/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/db/Makefile" ;; "bin/tests/dst/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Makefile" ;; "bin/tests/dst/Kdh.+002+18602.key") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Kdh.+002+18602.key" ;; "bin/tests/dst/Kdh.+002+18602.private") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Kdh.+002+18602.private" ;; diff --git a/configure.in b/configure.in index beb84e5afe..280584b682 100644 --- a/configure.in +++ b/configure.in @@ -5313,7 +5313,6 @@ AC_CONFIG_FILES([ bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile - bin/tests/db/Makefile bin/tests/dst/Makefile bin/tests/dst/Kdh.+002+18602.key bin/tests/dst/Kdh.+002+18602.private diff --git a/lib/dns/tests/Makefile.in b/lib/dns/tests/Makefile.in index 38118d9698..425cc0e8b9 100644 --- a/lib/dns/tests/Makefile.in +++ b/lib/dns/tests/Makefile.in @@ -101,7 +101,7 @@ acl_test@EXEEXT@: acl_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} db_test@EXEEXT@: db_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ - db_test.@O@ ${DNSLIBS} \ + db_test.@O@ dnstest.@O@ ${DNSLIBS} \ ${ISCLIBS} ${LIBS} dbdiff_test@EXEEXT@: dbdiff_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} diff --git a/lib/dns/tests/db_test.c b/lib/dns/tests/db_test.c index 551e09cc5f..96456e6cff 100644 --- a/lib/dns/tests/db_test.c +++ b/lib/dns/tests/db_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -276,6 +274,137 @@ ATF_TC_BODY(dns_dbfind_staleok, tc) { isc_mem_detach(&mymctx); } +ATF_TC(class); +ATF_TC_HEAD(class, tc) { + atf_tc_set_md_var(tc, "descr", "database class"); +} +ATF_TC_BODY(class, tc) { + isc_result_t result; + dns_db_t *db = NULL; + + result = dns_test_begin(NULL, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone, + dns_rdataclass_in, 0, NULL, &db); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dns_db_load(db, "testdata/db/data.db"); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + ATF_CHECK_EQ(dns_db_class(db), dns_rdataclass_in); + + dns_db_detach(&db); +} + +ATF_TC(dbtype); +ATF_TC_HEAD(dbtype, tc) { + atf_tc_set_md_var(tc, "descr", "database type"); +} +ATF_TC_BODY(dbtype, tc) { + isc_result_t result; + dns_db_t *db = NULL; + + result = dns_test_begin(NULL, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* DB has zone semantics */ + result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone, + dns_rdataclass_in, 0, NULL, &db); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dns_db_load(db, "testdata/db/data.db"); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + ATF_CHECK(dns_db_iszone(db)); + ATF_CHECK(!dns_db_iscache(db)); + dns_db_detach(&db); + + /* DB has cache semantics */ + result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache, + dns_rdataclass_in, 0, NULL, &db); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dns_db_load(db, "testdata/db/data.db"); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + ATF_CHECK(dns_db_iscache(db)); + ATF_CHECK(!dns_db_iszone(db)); + dns_db_detach(&db); + + dns_test_end(); +} + +ATF_TC(version); +ATF_TC_HEAD(version, tc) { + atf_tc_set_md_var(tc, "descr", "database versions"); +} +ATF_TC_BODY(version, tc) { + isc_result_t result; + dns_fixedname_t fname, ffound; + dns_name_t *name, *foundname; + dns_db_t *db = NULL; + dns_dbversion_t *ver = NULL, *new = NULL; + dns_dbnode_t *node = NULL; + dns_rdataset_t rdataset; + + result = dns_test_begin(NULL, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dns_test_loaddb(&db, dns_dbtype_zone, "test.test", + "testdata/db/data.db"); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* Open current version for reading */ + dns_db_currentversion(db, &ver); + dns_test_namefromstring("b.test.test", &fname); + name = dns_fixedname_name(&fname); + dns_fixedname_init(&ffound); + foundname = dns_fixedname_name(&ffound); + dns_rdataset_init(&rdataset); + result = dns_db_find(db, name , ver, dns_rdatatype_a, 0, 0, &node, + foundname, &rdataset, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &node); + dns_db_closeversion(db, &ver, ISC_FALSE); + + /* Open new version for writing */ + dns_db_currentversion(db, &ver); + dns_test_namefromstring("b.test.test", &fname); + name = dns_fixedname_name(&fname); + dns_fixedname_init(&ffound); + foundname = dns_fixedname_name(&ffound); + dns_rdataset_init(&rdataset); + result = dns_db_find(db, name , ver, dns_rdatatype_a, 0, 0, &node, + foundname, &rdataset, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dns_db_newversion(db, &new); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* Delete the rdataset from the new verison */ + result = dns_db_deleterdataset(db, node, new, dns_rdatatype_a, 0); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &node); + + /* This should fail now */ + result = dns_db_find(db, name, new, dns_rdatatype_a, 0, 0, &node, + foundname, &rdataset, NULL); + ATF_REQUIRE_EQ(result, DNS_R_NXDOMAIN); + + dns_db_closeversion(db, &new, ISC_TRUE); + + /* But this should still succeed */ + result = dns_db_find(db, name, ver, dns_rdatatype_a, 0, 0, &node, + foundname, &rdataset, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + dns_rdataset_disassociate(&rdataset); + dns_db_detachnode(db, &node); + dns_db_closeversion(db, &ver, ISC_FALSE); + + dns_db_detach(&db); + dns_test_end(); +} + /* * Main */ @@ -283,5 +412,9 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, getoriginnode); ATF_TP_ADD_TC(tp, getsetservestalettl); ATF_TP_ADD_TC(tp, dns_dbfind_staleok); + ATF_TP_ADD_TC(tp, class); + ATF_TP_ADD_TC(tp, dbtype); + ATF_TP_ADD_TC(tp, version); + return (atf_no_error()); } diff --git a/bin/tests/db/dns_db_class_1.data b/lib/dns/tests/testdata/db/data.db similarity index 100% rename from bin/tests/db/dns_db_class_1.data rename to lib/dns/tests/testdata/db/data.db diff --git a/util/copyrights b/util/copyrights index c50e9ab733..5a9c217167 100644 --- a/util/copyrights +++ b/util/copyrights @@ -344,61 +344,6 @@ ./bin/tests/byaddr_test.c C 2000,2001,2002,2004,2005,2007,2012,2015,2016,2018 ./bin/tests/byname_test.c C 2000,2001,2004,2005,2007,2009,2012,2015,2016,2017,2018 ./bin/tests/cfg_test.c C 2001,2002,2004,2005,2007,2009,2010,2011,2015,2016,2018 -./bin/tests/db/Makefile.in MAKE 1999,2000,2001,2002,2004,2007,2009,2010,2012,2014,2016,2017,2018 -./bin/tests/db/dns_db_class_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_class_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_closeversion_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_closeversion_1_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_closeversion_2.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_closeversion_2_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_currentversion.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_currentversion_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_expirenode.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_expirenode_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_10.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_10_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_1_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_2.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_2_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_3.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_3_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_4.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_4_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_5.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_5_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_6.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_6_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_7.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_7_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_8.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_8_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_9.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_find_9_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_findnode_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_findnode_1_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_findnode_2.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_findnode_2_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iscache_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iscache_1_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iscache_2.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iscache_2_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iszone_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iszone_1_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iszone_2.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_iszone_2_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_load_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_load_25.data X 2000,2001,2018 -./bin/tests/db/dns_db_load_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_load_soa_not_top X 2000,2001,2018 -./bin/tests/db/dns_db_newversion.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_newversion_data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_origin_1.data X 1999,2000,2001,2018 -./bin/tests/db/dns_db_origin_data X 1999,2000,2001,2018 -./bin/tests/db/t_db.c C 1999,2000,2001,2004,2005,2007,2009,2011,2012,2013,2015,2016,2017,2018 -./bin/tests/db/win32/t_db.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/db/win32/t_db.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/db/win32/t_db.vcxproj.user X 2013,2018 ./bin/tests/db_test.c C 1999,2000,2001,2004,2005,2007,2008,2009,2011,2012,2013,2015,2016,2017,2018 ./bin/tests/dst/.gitignore X 2012,2013,2018 ./bin/tests/dst/Kdh.+002+18602.key.in X 2001,2013,2018 diff --git a/win32utils/Configure b/win32utils/Configure index 689fdcf96c..7c670e5c07 100644 --- a/win32utils/Configure +++ b/win32utils/Configure @@ -116,8 +116,6 @@ my @projectlist = ("..\\bin\\check\\win32\\checkconf.vcxproj", "..\\bin\\tools\\win32\\nsec3hash.vcxproj.filters", "..\\bin\\tools\\win32\\rrchecker.vcxproj", "..\\bin\\tools\\win32\\rrchecker.vcxproj.filters", - "..\\bin\\tests\\db\\win32\\t_db.vcxproj", - "..\\bin\\tests\\db\\win32\\t_db.vcxproj.filters", "..\\bin\\tests\\dst\\win32\\t_dst.vcxproj", "..\\bin\\tests\\dst\\win32\\t_dst.vcxproj.filters", "..\\bin\\tests\\system\\win32\\bigkey.vcxproj", diff --git a/win32utils/bind9.sln.in b/win32utils/bind9.sln.in index 771e961768..a8ff894a01 100644 --- a/win32utils/bind9.sln.in +++ b/win32utils/bind9.sln.in @@ -499,14 +499,6 @@ EndProject @IF TESTS @IF ATOMIC @END ATOMIC -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_db", "..\bin\tests\db\win32\t_db.vcxproj", "{E6338E67-3224-4E66-9463-7AD719DA9346}" - ProjectSection(ProjectDependencies) = postProject - {A3F71D12-F38A-4C77-8D87-8E8854CA74A1} = {A3F71D12-F38A-4C77-8D87-8E8854CA74A1} - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A} = {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A} - {B2DFA58C-6347-478E-81E8-01E06999D4F1} = {B2DFA58C-6347-478E-81E8-01E06999D4F1} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_dst", "..\bin\tests\dst\win32\t_dst.vcxproj", "{EE9B94CF-7C33-4F3B-A674-FB756D422C54}" ProjectSection(ProjectDependencies) = postProject {A3F71D12-F38A-4C77-8D87-8E8854CA74A1} = {A3F71D12-F38A-4C77-8D87-8E8854CA74A1}