diff --git a/CHANGES b/CHANGES index 2d2b85e6a2..3a250caa29 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4913. [test] Re-implemented older unit tests in bin/tests as ATF, + removed the lib/tests unit testing library. [GL #115] + 4912. [test] Improved the reliability of the 'cds' system test. [GL #136] diff --git a/bin/Makefile.in b/bin/Makefile.in index 835f5f19d7..f0c504a17e 100644 --- a/bin/Makefile.in +++ b/bin/Makefile.in @@ -7,14 +7,12 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -# $Id: Makefile.in,v 1.29 2009/10/05 12:07:08 fdupont Exp $ - srcdir = @srcdir@ VPATH = @srcdir@ top_srcdir = @top_srcdir@ -SUBDIRS = named rndc dig delv dnssec tools tests nsupdate \ - check confgen @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ +SUBDIRS = named rndc dig delv dnssec tools nsupdate check confgen \ + @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ tests TARGETS = @BIND9_MAKE_RULES@ diff --git a/bin/tests/.gitignore b/bin/tests/.gitignore index cb5d4521d5..fe9052ac52 100644 --- a/bin/tests/.gitignore +++ b/bin/tests/.gitignore @@ -3,25 +3,11 @@ genrandom headerdep_test.sh nxtify sdig -t_journal *_test -t_atomic -t_db gsstest -t_dst -t_hashes -t_master -t_mem -t_names -t_net -t_rbt -t_resolver -t_sockaddr conf.sh dlopen keycreate keydelete gssapi_krb -t_tasks -t_timers makejournal diff --git a/bin/tests/Makefile.in b/bin/tests/Makefile.in index 6e312887a2..cf2e1bf0d4 100644 --- a/bin/tests/Makefile.in +++ b/bin/tests/Makefile.in @@ -32,238 +32,35 @@ ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@ LIBS = @LIBS@ -SUBDIR = atomic db dst master mem hashes names net rbt resolver \ - sockaddr tasks timers system @PKCS11_TOOLS@ - +SUBDIRS = system @PKCS11_TOOLS@ TESTDIRS = system # Test programs that are built by default: # cfg_test is needed for regenerating doc/misc/options # makejournal is needed by system tests +# wire_test is needed for fuzz testing +# other opptional test programs have been moved to ./optional # Alphabetically -TARGETS = @XTARGETS@ cfg_test@EXEEXT@ makejournal@EXEEXT@ \ - wire_test@EXEEXT@ +XTARGETS = all_tests +TARGETS = cfg_test@EXEEXT@ makejournal@EXEEXT@ \ + wire_test@EXEEXT@ @XTARGETS@ -# All the other tests are optional and not built by default. - -# Alphabetically -XTARGETS = adb_test@EXEEXT@ \ - byaddr_test@EXEEXT@ \ - backtrace_test@EXEEXT@ \ - backtrace_test_nosymtbl@EXEEXT@ \ - byname_test@EXEEXT@ \ - db_test@EXEEXT@ \ - entropy_test@EXEEXT@ \ - entropy2_test@EXEEXT@ \ - hash_test@EXEEXT@ \ - fsaccess_test@EXEEXT@ \ - inter_test@EXEEXT@ \ - keyboard_test@EXEEXT@ \ - lex_test@EXEEXT@ \ - lfsr_test@EXEEXT@ \ - log_test@EXEEXT@ \ - master_test@EXEEXT@ \ - mempool_test@EXEEXT@ \ - name_test@EXEEXT@ \ - nsecify@EXEEXT@ \ - ratelimiter_test@EXEEXT@ \ - rbt_test@EXEEXT@ \ - rwlock_test@EXEEXT@ \ - serial_test@EXEEXT@ \ - shutdown_test@EXEEXT@ \ - sig0_test@EXEEXT@ \ - sock_test@EXEEXT@ \ - sym_test@EXEEXT@ \ - task_test@EXEEXT@ \ - timer_test@EXEEXT@ \ - wire_test@EXEEXT@ \ - zone_test@EXEEXT@ - -# Alphabetically -SRCS = cfg_test.c makejournal.c wire_test.c ${XSRCS} - -XSRCS = adb_test.c \ - byaddr_test.c \ - backtrace_test.c \ - byname_test.c \ - db_test.c \ - entropy_test.c \ - entropy2_test.c \ - hash_test.c \ - fsaccess_test.c \ - inter_test.c \ - keyboard_test.c \ - lex_test.c \ - lfsr_test.c \ - log_test.c \ - master_test.c \ - mempool_test.c \ - name_test.c \ - nsecify.c \ - ratelimiter_test.c \ - rbt_test.c \ - rwlock_test.c \ - serial_test.c \ - shutdown_test.c \ - sig0_test.c \ - sock_test.c \ - sym_test.c \ - task_test.c \ - timer_test.c \ - wire_test.c \ - zone_test.c +SRCS = cfg_test.c makejournal.c wire_test.c @BIND9_MAKE_RULES@ -# disable optimization for backtrace test to get the expected result -BTTEST_CFLAGS = ${BACKTRACECFLAGS} ${EXT_CFLAGS} ${ALL_CPPFLAGS} -g \ - ${ALWAYS_WARNINGS} ${STD_CWARNINGS} ${CWARNINGS} +.NOTPARALLEL: -all_tests: ${XTARGETS} - -adb_test@EXEEXT@: adb_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ adb_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -backtrace_test_nosymtbl@EXEEXT@: ${srcdir}/backtrace_test.c ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${BTTEST_CFLAGS} ${LDFLAGS} -o $@ \ - ${srcdir}/backtrace_test.c ${ISCLIBS} ${LIBS} - -backtrace_test@EXEEXT@: ${srcdir}/backtrace_test.c backtrace_test_nosymtbl@EXEEXT@ - #first step: create a first symbol table - rm -f symtbl.c - if test X${MKSYMTBL_PROGRAM} != X; then \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ - backtrace_test_nosymtbl@EXEEXT@; else \ - cp ${top_srcdir}/lib/isc/backtrace-emptytbl.c symtbl.c; fi - #second step: build a binary with the first symbol table - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${BTTEST_CFLAGS} ${LDFLAGS} \ - -o $@0 ${srcdir}/backtrace_test.c symtbl.c \ - ${ISCNOSYMLIBS} ${LIBS} - rm -f symtbl.c - #third step: create a second symbol table - if test X${MKSYMTBL_PROGRAM} != X; then \ - ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl $@0; else \ - cp ${top_srcdir}/lib/isc/backtrace-emptytbl.c symtbl.c; fi - #fourth step: build the final binary - rm -f $@0 - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${BTTEST_CFLAGS} ${LDFLAGS} \ - -o $@ ${srcdir}/backtrace_test.c symtbl.c ${ISCNOSYMLIBS} ${LIBS} - rm -f symtbl.c - -nsecify@EXEEXT@: nsecify.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ nsecify.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -byaddr_test@EXEEXT@: byaddr_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ byaddr_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -byname_test@EXEEXT@: byname_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ byname_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lex_test.@O@ \ - ${ISCLIBS} ${LIBS} - -lfsr_test@EXEEXT@: lfsr_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lfsr_test.@O@ \ - ${ISCLIBS} ${LIBS} - -log_test@EXEEXT@: log_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ log_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -name_test@EXEEXT@: name_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ name_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -hash_test@EXEEXT@: hash_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ hash_test.@O@ \ - ${ISCLIBS} ${LIBS} - -entropy_test@EXEEXT@: entropy_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ entropy_test.@O@ \ - ${ISCLIBS} ${LIBS} - -entropy2_test@EXEEXT@: entropy2_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ entropy2_test.@O@ \ - ${ISCLIBS} ${LIBS} - -sock_test@EXEEXT@: sock_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sock_test.@O@ \ - ${ISCLIBS} ${LIBS} - -sym_test@EXEEXT@: sym_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sym_test.@O@ \ - ${ISCLIBS} ${LIBS} - -task_test@EXEEXT@: task_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ task_test.@O@ \ - ${ISCLIBS} ${LIBS} - -shutdown_test@EXEEXT@: shutdown_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ shutdown_test.@O@ \ - ${ISCLIBS} ${LIBS} - -timer_test@EXEEXT@: timer_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ timer_test.@O@ \ - ${ISCLIBS} ${LIBS} - -ratelimiter_test@EXEEXT@: ratelimiter_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ratelimiter_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -rbt_test@EXEEXT@: rbt_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rbt_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -rwlock_test@EXEEXT@: rwlock_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rwlock_test.@O@ \ - ${ISCLIBS} ${LIBS} +.PHONY: +all_tests: + echo "making depend in `pwd`/optional"; \ + (cd optional; ${MAKE} ${MAKEDEFS} DESTDIR="${DESTDIR}" $@) wire_test@EXEEXT@: wire_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ wire_test.@O@ \ ${DNSLIBS} ${ISCLIBS} ${LIBS} -master_test@EXEEXT@: master_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ master_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -db_test@EXEEXT@: db_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ db_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -mempool_test@EXEEXT@: mempool_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ mempool_test.@O@ \ - ${ISCLIBS} ${LIBS} - -serial_test@EXEEXT@: serial_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ serial_test.@O@ \ - ${ISCLIBS} ${LIBS} - -zone_test@EXEEXT@: zone_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ zone_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -fsaccess_test@EXEEXT@: fsaccess_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ fsaccess_test.@O@ \ - ${ISCLIBS} ${LIBS} - -inter_test@EXEEXT@: inter_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ inter_test.@O@ \ - ${ISCLIBS} ${LIBS} - -keyboard_test@EXEEXT@: keyboard_test.@O@ ${ISCDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ keyboard_test.@O@ \ - ${ISCLIBS} ${LIBS} - -sig0_test@EXEEXT@: sig0_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sig0_test.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - cfg_test@EXEEXT@: cfg_test.@O@ ${ISCCFGDEPLIBS} ${ISCDEPLIBS} ${LIBTOOL_MODE_LINK} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ cfg_test.@O@ \ ${ISCCFGLIBS} ${DNSLIBS} ${ISCLIBS} ${LIBS} @@ -276,9 +73,8 @@ distclean:: rm -f headerdep_test.sh clean distclean:: - rm -f ${TARGETS} ${XTARGETS} - rm -f t_journal - rm -f backtrace_test_symtbl.c + rm -f ${TARGETS} + ( cd optional; $(MAKE) $@) check: test diff --git a/bin/tests/atomic/Makefile.in b/bin/tests/atomic/Makefile.in deleted file mode 100644 index 932a77397d..0000000000 --- a/bin/tests/atomic/Makefile.in +++ /dev/null @@ -1,47 +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} - -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${ISCDEPLIBS} - -LIBS = ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_atomic@EXEEXT@ - -SRCS = t_atomic.c - -@BIND9_MAKE_RULES@ - -t_atomic@EXEEXT@: t_atomic.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_atomic.@O@ ${TLIB} ${LIBS} - -test: t_atomic@EXEEXT@ - -@./t_atomic@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @./t_atomic@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/atomic/win32/t_atomic.vcxproj.filters.in b/bin/tests/atomic/win32/t_atomic.vcxproj.filters.in deleted file mode 100644 index 41df97cd0a..0000000000 --- a/bin/tests/atomic/win32/t_atomic.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/atomic/win32/t_atomic.vcxproj.in b/bin/tests/atomic/win32/t_atomic.vcxproj.in deleted file mode 100644 index eed1870a49..0000000000 --- a/bin/tests/atomic/win32/t_atomic.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {EC6ECB35-58C0-48EC-BAC9-9A652D9406C9} - Win32Proj - t_atomic - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/atomic/win32/t_atomic.vcxproj.user b/bin/tests/atomic/win32/t_atomic.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/atomic/win32/t_atomic.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/b8t.mk b/bin/tests/b8t.mk deleted file mode 100644 index 9b1a88251b..0000000000 --- a/bin/tests/b8t.mk +++ /dev/null @@ -1,57 +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: b8t.mk,v 1.11 2007/06/19 23:46:59 tbox Exp $ - -# -# bind 8 multi-host make -# PLATFORM set in the environment by cron -# - -MODULE = bind -BASE = /build -BDIR = $(BASE)/$(MODULE) -RDIR = /proj/build-reports/bind8/hosts/$(PLATFORM) -SDIR = $(HOME)/b8t/src -CVSROOT = /proj/cvs/isc - -all: clobber populate config build - -clobber: - @echo "CLOBBBER `date`" - @if test ! -d $(BASE) ; then mkdir -p $(BASE) ; fi - @rm -fr $(BDIR) - @echo "DONE `date`" - -populate: - @echo "POPULATE `date`" - @( cd $(BASE) && tar -xvf $(SDIR)/$(MODULE).tar ) > $(RDIR)/.populate 2>&1 - @echo "DONE `date`" - -tarsrc: - @echo "TARSRC `date`" - @rm -fr $(SDIR)/$(MODULE) - @( cd $(SDIR) && cvs -d $(CVSROOT) checkout $(MODULE) ) - @( cd $(SDIR) && tar -cvf $(MODULE).tar $(MODULE) ) - @echo "DONE `date`" - -config: - @echo "CONFIG `date`" - @( cd $(BDIR)/src && make SRC=$(BDIR)/src DST=$(BDIR)/dst links ) > $(RDIR)/.config 2>&1 - @echo "DONE `date`" - -build: - @echo "BUILD `date`" - @( cd $(BDIR)/dst && make -k clean depend all ) > $(RDIR)/.build 2>&1 - @echo "DONE `date`" - -test: - @echo "TEST `date`" - @touch $(RDIR)/.test - @echo "DONE `date`" diff --git a/bin/tests/b9t.mk b/bin/tests/b9t.mk deleted file mode 100644 index 3bd2ae85d4..0000000000 --- a/bin/tests/b9t.mk +++ /dev/null @@ -1,62 +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: b9t.mk,v 1.13 2007/06/19 23:46:59 tbox Exp $ - -# -# makefile to configure, build and test bind9 -# this is run by cron (user wpk) on aa, sol, irix, hp and aix -# $PLATFORM is set in the environment by cron -# - -BASE = /build -BDIR = $(BASE) -MODULE = bind9 -SDIR = $(HOME)/b9t/src - -# as it says -CVSROOT = /proj/cvs/isc - -# where the config, build and test output goes -RDIR = /proj/build-reports/$(MODULE)/hosts/$(PLATFORM) - -all: clobber populate config build test - -clobber: - @echo "CLOBBBER `date`" - @if test ! -d $(BDIR) ; then mkdir -p $(BDIR) > /dev/null 2>&1 ; fi - @( cd $(BDIR) && rm -fr $(MODULE) ) - @echo "DONE `date`" - -populate: - @echo "POPULATE `date`" - @( cd $(BDIR) && tar -xvf $(SDIR)/$(MODULE).tar ) > $(RDIR)/.populate 2>&1 - @echo "DONE `date`" - -config: - @echo "CONFIG `date`" - @( cd $(BDIR)/$(MODULE) && ./configure ) > $(RDIR)/.config 2>&1 - @echo "DONE `date`" - -build: - @echo "BUILD `date`" - @( cd $(BDIR)/$(MODULE) && $(MAKE) -k all ) > $(RDIR)/.build 2>&1 - @echo "DONE `date`" - -test: - @echo "TEST `date`" - -@( cd $(BDIR)/$(MODULE)/bin/tests && $(MAKE) test ) > $(RDIR)/.test 2>&1 - @echo "DONE `date`" - -tarsrc: - @echo "TARSRC `date`" - @rm -fr $(SDIR)/$(MODULE) - @( cd $(SDIR) && cvs -d $(CVSROOT) checkout $(MODULE) && tar -cvf $(MODULE).tar $(MODULE) ) - @echo "DONE `date`" - 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_1.data b/bin/tests/db/dns_db_class_1.data deleted file mode 100644 index ab61c9584c..0000000000 --- a/bin/tests/db/dns_db_class_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_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/bin/tests/dnssec-signzone/run-test.sh b/bin/tests/dnssec-signzone/run-test.sh deleted file mode 100644 index 9a5d53e908..0000000000 --- a/bin/tests/dnssec-signzone/run-test.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# -# 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: run-test.sh,v 1.3 2009/06/04 02:56:47 tbox Exp $ - - -sign="../../dnssec/dnssec-signzone -f signed.zone -o example.com." - -signit() { - rm -f signed.zone - grep '^;' $zone - $sign $zone -} - -expect_success() { - if ! test -f signed.zone ; then - echo "Error: expected success, but sign failed for $zone." - else - echo "Success: Sign succeeded for $zone." - fi -} - -expect_failure() { - if test -f signed.zone ; then - echo "Error: expected failure, but sign succeeded for $zone." - else - echo "Success: Sign failed (expected) for $zone" - fi -} - -zone="test1.zone" ; signit ; expect_success -zone="test2.zone" ; signit ; expect_failure -zone="test3.zone" ; signit ; expect_failure -zone="test4.zone" ; signit ; expect_success -zone="test5.zone" ; signit ; expect_failure -zone="test6.zone" ; signit ; expect_failure -zone="test7.zone" ; signit ; expect_failure -zone="test8.zone" ; signit ; expect_failure diff --git a/bin/tests/dst/.gitignore b/bin/tests/dst/.gitignore deleted file mode 100644 index a46cbd6f20..0000000000 --- a/bin/tests/dst/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -randomfile -Kdh.+002+18602.key -Kdh.+002+18602.private -Kdh.+002+48957.key -Kdh.+002+48957.private -Ktest.+001+00002.key -Ktest.+001+54622.key -Ktest.+001+54622.private -Ktest.+003+23616.key -Ktest.+003+23616.private -Ktest.+003+49667.key -dst_2_data -t2_data_1 -t2_data_2 -t2_dsasig -t2_rsasig diff --git a/bin/tests/dst/Kdh.+002+18602.key.in b/bin/tests/dst/Kdh.+002+18602.key.in deleted file mode 100644 index 09b4cf56aa..0000000000 --- a/bin/tests/dst/Kdh.+002+18602.key.in +++ /dev/null @@ -1 +0,0 @@ -dh. IN KEY 0 2 2 AAEBAAAAYIHI/wjtOagNga9GILSoS02IVelgLilPE/TfhtvShsiDAXqb IfxQcj2JkuOnNLs5ttb2WZXWl5/jsSjIxHMwMF2XY4gwt/lwHBf/vgYH r7aIxnKXov1jk9rymTLHGKIOtg== diff --git a/bin/tests/dst/Kdh.+002+18602.private.in b/bin/tests/dst/Kdh.+002+18602.private.in deleted file mode 100644 index a2245bfa34..0000000000 --- a/bin/tests/dst/Kdh.+002+18602.private.in +++ /dev/null @@ -1,6 +0,0 @@ -Private-key-format: v1.2 -Algorithm: 2 (DH) -Prime(p): ///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjo2IP////////// -Generator(g): Ag== -Private_value(x): bpdsGQ1jbV3f2CGN/0Pk5KM1MlkFmMryPO1J1zoGn585fRmc9Ygw6l/HKmi2ViiDNorvd9/eV9uyYO6lYZC82R3D7rST1mAqCwbg/8gNE5dXBRbRIIq3qIl6GUYYs8mK -Public_value(y): gcj/CO05qA2Br0YgtKhLTYhV6WAuKU8T9N+G29KGyIMBepsh/FByPYmS46c0uzm21vZZldaXn+OxKMjEczAwXZdjiDC3+XAcF/++BgevtojGcpei/WOT2vKZMscYog62 diff --git a/bin/tests/dst/Kdh.+002+48957.key.in b/bin/tests/dst/Kdh.+002+48957.key.in deleted file mode 100644 index 98388295ef..0000000000 --- a/bin/tests/dst/Kdh.+002+48957.key.in +++ /dev/null @@ -1 +0,0 @@ -dh. IN KEY 0 2 2 AAEBAAAAYOuaKjyMXYame2F6/ZFdEmXv0a2edB+69PEZgrExA6SJlivn 4KqAsfBHr/+0BCb+7nfWeMDSh2BXnSzWkXF1wMaCHMuz9EleG1gKFKeV Q9gKli88Cb8/jbovWChrGBNp2w== diff --git a/bin/tests/dst/Kdh.+002+48957.private.in b/bin/tests/dst/Kdh.+002+48957.private.in deleted file mode 100644 index e191235c89..0000000000 --- a/bin/tests/dst/Kdh.+002+48957.private.in +++ /dev/null @@ -1,6 +0,0 @@ -Private-key-format: v1.2 -Algorithm: 2 (DH) -Prime(p): ///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjo2IP////////// -Generator(g): Ag== -Private_value(x): WJG0moh+QoZV+DYhqW7Z6O6TYpYGtSlN0Ym6JV6VRnzeH69OqMUFivqZorj3a3ofR/4zogNVyy5KLLj2NFTaLGP4Hcvt7uETJik6HrjLMhGf40QPXYgVK57Im0rv88Ca -Public_value(y): 65oqPIxdhqZ7YXr9kV0SZe/RrZ50H7r08RmCsTEDpImWK+fgqoCx8Eev/7QEJv7ud9Z4wNKHYFedLNaRcXXAxoIcy7P0SV4bWAoUp5VD2AqWLzwJvz+Nui9YKGsYE2nb diff --git a/bin/tests/dst/Makefile.in b/bin/tests/dst/Makefile.in deleted file mode 100644 index c408d9a009..0000000000 --- a/bin/tests/dst/Makefile.in +++ /dev/null @@ -1,77 +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@ @DST_GSSAPI_INC@ - -CDEFINES = @CRYPTO@ @USE_GSSAPI@ -CWARNINGS = - -DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -DNSDEPLIBS = ../../../lib/dns/libdns.@A@ -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = dst_test@EXEEXT@ t_dst@EXEEXT@ gsstest@EXEEXT@ - -SRCS = dst_test.c t_dst.c gsstest.c - -@BIND9_MAKE_RULES@ - -dst_test@EXEEXT@: dst_test.@O@ ${DEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ - dst_test.@O@ ${LIBS} - -t_dst@EXEEXT@: t_dst.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ - t_dst.@O@ ${TLIB} ${LIBS} - -gsstest@EXEEXT@: gsstest.@O@ ${DEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ - gsstest.@O@ ${LIBS} - -test: t_dst@EXEEXT@ randomfile - ../../tools/genrandom@EXEEXT@ 100 randomfile - -@ ./t_dst@EXEEXT@ -q 1800 -a - -randomfile: - ../../tools/genrandom@EXEEXT@ 100 randomfile - -clean distclean:: - rm -f ${TARGETS} randomfile - -distclean:: - rm -f Kdh.+002+18602.key - rm -f Kdh.+002+18602.private - rm -f Kdh.+002+48957.key - rm -f Kdh.+002+48957.private - rm -f Ktest.+001+00002.key - rm -f Ktest.+001+54622.key - rm -f Ktest.+001+54622.private - rm -f Ktest.+003+23616.key - rm -f Ktest.+003+23616.private - rm -f Ktest.+003+49667.key - rm -f dst_2_data - rm -f t2_data_1 - rm -f t2_data_2 - rm -f t2_dsasig - rm -f t2_rsasig diff --git a/bin/tests/dst/dst_2_data.in b/bin/tests/dst/dst_2_data.in deleted file mode 100644 index a3030651b3..0000000000 --- a/bin/tests/dst/dst_2_data.in +++ /dev/null @@ -1,16 +0,0 @@ -# -# data for signature verification test -# -# format: -# datafile, sigpath, keyname, keyid, alg, exp_result -# -t2_data_1 t2_dsasig test. 23616 DST_ALG_DSA ISC_R_SUCCESS -t2_data_1 t2_rsasig test. 54622 DST_ALG_RSAMD5 ISC_R_SUCCESS -# wrong sig -t2_data_1 t2_dsasig test. 54622 DST_ALG_RSAMD5 !ISC_R_SUCCESS -# wrong key -#t2_data_1 t2_dsasig test. 54622 DST_ALG_DSA !ISC_R_SUCCESS -# wrong alg -#t2_data_1 t2_dsasig test. 23616 DST_ALG_RSAMD5 !ISC_R_SUCCESS -# wrong data -t2_data_2 t2_dsasig test. 23616 DST_ALG_DSA !ISC_R_SUCCESS diff --git a/bin/tests/dst/t_dst.c b/bin/tests/dst/t_dst.c deleted file mode 100644 index b702e4c082..0000000000 --- a/bin/tests/dst/t_dst.c +++ /dev/null @@ -1,1045 +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_dst.c,v 1.60 2011/03/17 23:47:29 tbox Exp $ */ - -#include - -#include -#include -#include -#include - -#ifndef WIN32 -#include /* XXX */ -#else -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#ifndef PATH_MAX -#define PATH_MAX 256 -#endif - -/* - * Adapted from the original dst_test.c program. - */ - -static void -cleandir(char *path) { - isc_dir_t dir; - char fullname[PATH_MAX + 1]; - size_t l; - isc_result_t ret; - - isc_dir_init(&dir); - ret = isc_dir_open(&dir, path); - if (ret != ISC_R_SUCCESS) { - t_info("isc_dir_open(%s) failed %s\n", - path, isc_result_totext(ret)); - return; - } - - while (isc_dir_read(&dir) == ISC_R_SUCCESS) { - if (!strcmp(dir.entry.name, ".")) - continue; - if (!strcmp(dir.entry.name, "..")) - continue; - (void)strlcpy(fullname, path, sizeof(fullname)); - (void)strlcat(fullname, "/", sizeof(fullname)); - l = strlcat(fullname, dir.entry.name, sizeof(fullname)); - if (l < sizeof(fullname)) { - if (remove(fullname)) - t_info("remove(%s) failed %d\n", fullname, - errno); - } else - t_info("unable to remove '%s/%s': path too long\n", - path, dir.entry.name); - - } - isc_dir_close(&dir); - if (rmdir(path)) - t_info("rmdir(%s) failed %d\n", path, errno); - - return; -} - -static void -use(dst_key_t *key, isc_mem_t *mctx, isc_result_t exp_result, int *nfails) { - - isc_result_t ret; - const char *data = "This is some data"; - unsigned char sig[512]; - isc_buffer_t databuf, sigbuf; - isc_region_t datareg, sigreg; - dst_context_t *ctx = NULL; - - isc_buffer_init(&sigbuf, sig, sizeof(sig)); - isc_buffer_constinit(&databuf, data, strlen(data)); - isc_buffer_add(&databuf, strlen(data)); - isc_buffer_usedregion(&databuf, &datareg); - - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_GENERAL, ISC_TRUE, &ctx); - if (ret != exp_result) { - t_info("dst_context_create(%d) returned (%s) expected (%s)\n", - dst_key_alg(key), dst_result_totext(ret), - dst_result_totext(exp_result)); - ++*nfails; - return; - } - if (exp_result != ISC_R_SUCCESS) - return; - ret = dst_context_adddata(ctx, &datareg); - if (ret != ISC_R_SUCCESS) { - t_info("dst_context_adddata(%d) returned (%s)\n", - dst_key_alg(key), dst_result_totext(ret)); - ++*nfails; - dst_context_destroy(&ctx); - return; - } - ret = dst_context_sign(ctx, &sigbuf); - if (ret != ISC_R_SUCCESS) { - t_info("dst_context_sign(%d) returned (%s)\n", - dst_key_alg(key), dst_result_totext(ret)); - ++*nfails; - dst_context_destroy(&ctx); - return; - } - dst_context_destroy(&ctx); - - isc_buffer_remainingregion(&sigbuf, &sigreg); - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_GENERAL, ISC_FALSE, &ctx); - if (ret != ISC_R_SUCCESS) { - t_info("dst_context_create(%d) returned (%s)\n", - dst_key_alg(key), dst_result_totext(ret)); - ++*nfails; - return; - } - ret = dst_context_adddata(ctx, &datareg); - if (ret != ISC_R_SUCCESS) { - t_info("dst_context_adddata(%d) returned (%s)\n", - dst_key_alg(key), dst_result_totext(ret)); - ++*nfails; - dst_context_destroy(&ctx); - return; - } - ret = dst_context_verify(ctx, &sigreg); - if (ret != exp_result) { - t_info("dst_context_verify(%d) returned (%s) expected (%s)\n", - dst_key_alg(key), dst_result_totext(ret), - dst_result_totext(exp_result)); - ++*nfails; - dst_context_destroy(&ctx); - return; - } - dst_context_destroy(&ctx); -} - -static void -dh(dns_name_t *name1, int id1, dns_name_t *name2, int id2, isc_mem_t *mctx, - isc_result_t exp_result, int *nfails, int *nprobs) -{ - dst_key_t *key1 = NULL, *key2 = NULL; - isc_result_t ret; - char current[PATH_MAX + 1]; - char tmp[PATH_MAX + 1]; - char *p; - int alg = DST_ALG_DH; - int type = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE|DST_TYPE_KEY; - unsigned char array1[1024], array2[1024]; - isc_buffer_t b1, b2; - isc_region_t r1, r2; - - UNUSED(exp_result); - - p = getcwd(current, PATH_MAX);; - if (p == NULL) { - t_info("getcwd failed %d\n", errno); - ++*nprobs; - goto cleanup; - } - - ret = dst_key_fromfile(name1, id1, alg, type, current, mctx, &key1); - if (ret != ISC_R_SUCCESS) { - t_info("dst_key_fromfile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - - ret = dst_key_fromfile(name2, id2, alg, type, current, mctx, &key2); - if (ret != ISC_R_SUCCESS) { - t_info("dst_key_fromfile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - -#ifndef WIN32 - ret = isc_file_mktemplate("/tmp/", tmp, sizeof(tmp)); -#else - ret = isc_file_mktemplate(getenv("TEMP"), tmp, sizeof(tmp)); -#endif - if (ret != ISC_R_SUCCESS) { - t_info("isc_file_mktemplate failed %s\n", - isc_result_totext(ret)); - ++*nprobs; - goto cleanup; - } - - ret = isc_dir_createunique(tmp); - if (ret != ISC_R_SUCCESS) { - t_info("isc_dir_createunique failed %s\n", - isc_result_totext(ret)); - ++*nprobs; - goto cleanup; - } - - ret = dst_key_tofile(key1, type, tmp); - if (ret != 0) { - t_info("dst_key_tofile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - - ret = dst_key_tofile(key2, type, tmp); - if (ret != 0) { - t_info("dst_key_tofile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - - cleandir(tmp); - - isc_buffer_init(&b1, array1, sizeof(array1)); - ret = dst_key_computesecret(key1, key2, &b1); - if (ret != 0) { - t_info("dst_computesecret() returned: %s\n", - dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - - isc_buffer_init(&b2, array2, sizeof(array2)); - ret = dst_key_computesecret(key2, key1, &b2); - if (ret != 0) { - t_info("dst_computesecret() returned: %s\n", - dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - - isc_buffer_usedregion(&b1, &r1); - isc_buffer_usedregion(&b2, &r2); - if (r1.length != r2.length || memcmp(r1.base, r2.base, r1.length) != 0) - { - t_info("computed secrets don't match\n"); - ++*nfails; - goto cleanup; - } - - cleanup: - if (key1 != NULL) - dst_key_free(&key1); - if (key2 != NULL) - dst_key_free(&key2); -} - -static void -io(dns_name_t *name, isc_uint16_t id, isc_uint16_t alg, int type, - isc_mem_t *mctx, isc_result_t exp_result, int *nfails, int *nprobs) -{ - dst_key_t *key = NULL; - isc_result_t ret; - char current[PATH_MAX + 1]; - char tmp[PATH_MAX + 1]; - char *p; - - p = getcwd(current, PATH_MAX);; - if (p == NULL) { - t_info("getcwd failed %d\n", errno); - ++*nprobs; - goto failure; - } - - ret = dst_key_fromfile(name, id, alg, type, current, mctx, &key); - if (ret != ISC_R_SUCCESS) { - t_info("dst_key_fromfile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto failure; - } - - if (dst_key_id(key) != id) { - t_info("key ID incorrect\n"); - ++*nfails; - goto failure; - } - - if (dst_key_alg(key) != alg) { - t_info("key algorithm incorrect\n"); - ++*nfails; - goto failure; - } - - if (dst_key_getttl(key) != 0) { - t_info("initial key TTL incorrect\n"); - ++*nfails; - goto failure; - } - -#ifndef WIN32 - ret = isc_file_mktemplate("/tmp/", tmp, sizeof(tmp)); -#else - ret = isc_file_mktemplate(getenv("TEMP"), tmp, sizeof(tmp)); -#endif - if (ret != ISC_R_SUCCESS) { - t_info("isc_file_mktemplate failed %s\n", - isc_result_totext(ret)); - ++*nprobs; - goto failure; - } - - ret = isc_dir_createunique(tmp); - if (ret != ISC_R_SUCCESS) { - t_info("mkdir failed %d\n", errno); - ++*nprobs; - goto failure; - } - - ret = dst_key_tofile(key, type, tmp); - if (ret != 0) { - t_info("dst_key_tofile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto failure; - } - - if (dst_key_alg(key) != DST_ALG_DH) - use(key, mctx, exp_result, nfails); - - /* - * Skip the rest of this test if we weren't expecting - * the read to be successful. - */ - if (exp_result != ISC_R_SUCCESS) - goto cleanup; - - dst_key_setttl(key, 3600); - ret = dst_key_tofile(key, type, tmp); - if (ret != 0) { - t_info("dst_key_tofile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto failure; - } - - /* Reread key to confirm TTL was changed */ - dst_key_free(&key); - ret = dst_key_fromfile(name, id, alg, type, tmp, mctx, &key); - if (ret != ISC_R_SUCCESS) { - t_info("dst_key_fromfile(%d) returned: %s\n", - alg, dst_result_totext(ret)); - ++*nfails; - goto failure; - } - - if (dst_key_getttl(key) != 3600) { - t_info("modified key TTL incorrect\n"); - ++*nfails; - goto failure; - } - - cleanup: - cleandir(tmp); - - failure: - if (key != NULL) - dst_key_free(&key); -} - -static void -generate(int alg, isc_mem_t *mctx, int size, int *nfails) { - isc_result_t ret; - dst_key_t *key = NULL; - - ret = dst_key_generate(dns_rootname, alg, size, 0, 0, 0, - dns_rdataclass_in, mctx, &key); - if (ret != ISC_R_SUCCESS) { - t_info("dst_key_generate(%d) returned: %s\n", alg, - dst_result_totext(ret)); - ++*nfails; - goto cleanup; - } - - if (alg != DST_ALG_DH) - use(key, mctx, ISC_R_SUCCESS, nfails); - cleanup: - if (key != NULL) - dst_key_free(&key); -} - -#define DBUFSIZ 25 - -static const char *a1 = - "the dst module provides the capability to " - "generate, store and retrieve public and private keys, " - "sign and verify data using the RSA, DSA and MD5 algorithms, " - "and compute Diffie-Hellman shared secrets."; -static void -t1(void) { - isc_mem_t *mctx; - isc_entropy_t *ectx; - int nfails; - int nprobs; - int result; - isc_result_t isc_result; - dns_fixedname_t fname; - dns_name_t *name; - isc_buffer_t b; - - t_assert("dst", 1, T_REQUIRED, "%s", a1); - - nfails = 0; - nprobs = 0; - mctx = NULL; - 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)); - t_result(T_UNRESOLVED); - return; - } - ectx = NULL; - 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)); - t_result(T_UNRESOLVED); - return; - } - isc_result = isc_entropy_createfilesource(ectx, "randomfile"); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - t_result(T_UNRESOLVED); - return; - } - isc_result = dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_lib_init failed %s\n", - isc_result_totext(isc_result)); - t_result(T_UNRESOLVED); - return; - } - - if (!dst_algorithm_supported(DST_ALG_RSAMD5)) { - dst_lib_destroy(); - t_info("library built without crypto support\n"); - t_result(T_SKIPPED); - return; - } - - t_info("testing use of stored keys [1]\n"); - - dns_fixedname_init(&fname); - name = dns_fixedname_name(&fname); - isc_buffer_constinit(&b, "test.", 5); - isc_buffer_add(&b, 5); - isc_result = dns_name_fromtext(name, &b, NULL, 0, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - isc_result_totext(isc_result)); - t_result(T_UNRESOLVED); - return; - } - io(name, 23616, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, - mctx, ISC_R_SUCCESS, &nfails, &nprobs); - t_info("testing use of stored keys [2]\n"); - io(name, 54622, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, - mctx, ISC_R_SUCCESS, &nfails, &nprobs); - - t_info("testing use of stored keys [3]\n"); - io(name, 49667, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, - mctx, DST_R_NULLKEY, &nfails, &nprobs); - t_info("testing use of stored keys [4]\n"); - io(name, 2, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, - mctx, DST_R_NULLKEY, &nfails, &nprobs); - - isc_buffer_constinit(&b, "dh.", 3); - isc_buffer_add(&b, 3); - isc_result = dns_name_fromtext(name, &b, NULL, 0, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - isc_result_totext(isc_result)); - t_result(T_UNRESOLVED); - return; - } - - dh(name, 18602, name, 48957, mctx, ISC_R_SUCCESS, &nfails, &nprobs); - - t_info("testing use of generated keys\n"); - generate(DST_ALG_RSAMD5, mctx, 512, &nfails); - generate(DST_ALG_DSA, mctx, 512, &nfails); - generate(DST_ALG_DH, mctx, 512, &nfails); - /* - * This one uses a constant. - */ - generate(DST_ALG_DH, mctx, 768, &nfails); - generate(DST_ALG_HMACMD5, mctx, 512, &nfails); - - dst_lib_destroy(); - - isc_entropy_detach(&ectx); - - isc_mem_destroy(&mctx); - - result = T_UNRESOLVED; - if ((nfails == 0) && (nprobs == 0)) - result = T_PASS; - else if (nfails) - result = T_FAIL; - t_result(result); - -} - -#define T_SIGMAX 512 - -#undef NEWSIG /* Define NEWSIG to generate the original signature file. */ - -#ifdef NEWSIG - -/* - * Write a sig in buf to file at path. - */ -static int -sig_tofile(char *path, isc_buffer_t *buf) { - int rval; - int fd; - int len; - int nprobs; - int cnt; - unsigned char c; - unsigned char val; - - cnt = 0; - nprobs = 0; - len = buf->used - buf->current; - - t_info("buf: current %d used %d len %d\n", - buf->current, buf->used, len); - - fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRWXU|S_IRWXO|S_IRWXG); - if (fd < 0) { - t_info("open %s failed %d\n", path, errno); - return(1); - } - - while (len) { - c = (unsigned char) isc_buffer_getuint8(buf); - val = ((c >> 4 ) & 0x0f); - if ((0 <= val) && (val <= 9)) - val = '0' + val; - else - val = 'A' + val - 10; - rval = write(fd, &val, 1); - if (rval != 1) { - ++nprobs; - t_info("write failed %d %d\n", rval, errno); - break; - } - val = (c & 0x0f); - if ((0 <= val) && (val <= 9)) - val = '0' + val; - else - val = 'A' + val - 10; - rval = write(fd, &val, 1); - if (rval != 1) { - ++nprobs; - t_info("write failed %d %d\n", rval, errno); - break; - } - --len; - ++cnt; - if ((cnt % 16) == 0) { - val = '\n'; - rval = write(fd, &val, 1); - if (rval != 1) { - ++nprobs; - t_info("write failed %d %d\n", rval, errno); - break; - } - } - } - val = '\n'; - rval = write(fd, &val, 1); - if (rval != 1) { - ++nprobs; - t_info("write failed %d %d\n", rval, errno); - } - (void) close(fd); - return(nprobs); -} - -#endif /* NEWSIG */ - -/* - * Read sig in file at path to buf. - */ -static int -sig_fromfile(char *path, isc_buffer_t *iscbuf) { - size_t rval; - size_t len; - FILE *fp; - unsigned char val; - char *p; - char *buf; - isc_result_t isc_result; - off_t size; - - isc_result = isc_stdio_open(path, "rb", &fp); - if (isc_result != ISC_R_SUCCESS) { - t_info("open failed, result: %s\n", - isc_result_totext(isc_result)); - return(1); - } - - isc_result = isc_file_getsizefd(fileno(fp), &size); - if (isc_result != ISC_R_SUCCESS) { - t_info("stat %s failed, result: %s\n", - path, isc_result_totext(isc_result)); - isc_stdio_close(fp); - return(1); - } - - buf = (char *) malloc((size + 1) * sizeof(char)); - if (buf == NULL) { - t_info("malloc failed, errno == %d\n", errno); - isc_stdio_close(fp); - return(1); - } - - len = (size_t)size; - p = buf; - while (len != 0U) { - isc_result = isc_stdio_read(p, 1, len, fp, &rval); - if (isc_result == ISC_R_SUCCESS) { - len -= rval; - p += rval; - } else { - t_info("read failed %d, result: %s\n", - (int)rval, isc_result_totext(isc_result)); - (void) free(buf); - (void) isc_stdio_close(fp); - return(1); - } - } - isc_stdio_close(fp); - - p = buf; - len = size; - while (len > 0U) { - if ((*p == '\r') || (*p == '\n')) { - ++p; - --len; - continue; - } else if (len < 2U) - goto err; - if (('0' <= *p) && (*p <= '9')) - val = *p - '0'; - else if (('A' <= *p) && (*p <= 'F')) - val = *p - 'A' + 10; - else - goto err; - ++p; - val <<= 4; - --len; - if (('0' <= *p) && (*p <= '9')) - val |= (*p - '0'); - else if (('A' <= *p) && (*p <= 'F')) - val |= (*p - 'A' + 10); - else - goto err; - ++p; - --len; - isc_buffer_putuint8(iscbuf, val); - } - (void) free(buf); - return(0); - - err: - (void) free(buf); - return (1); -} - -static void -t2_sigchk(char *datapath, char *sigpath, char *keyname, - int id, int alg, int type, - isc_mem_t *mctx, char *expected_result, - int *nfails, int *nprobs) -{ - size_t rval; - size_t len; - FILE *fp; - int exp_res; - dst_key_t *key = NULL; - unsigned char sig[T_SIGMAX]; - unsigned char *p; - unsigned char *data; - off_t size; - isc_result_t isc_result; - isc_buffer_t databuf; - isc_buffer_t sigbuf; - isc_region_t datareg; - isc_region_t sigreg; - dns_fixedname_t fname; - dns_name_t *name; - isc_buffer_t b; - dst_context_t *ctx = NULL; - - /* - * Read data from file in a form usable by dst_verify. - */ - isc_result = isc_stdio_open(datapath, "rb", &fp); - if (isc_result != ISC_R_SUCCESS) { - t_info("t2_sigchk: open failed %s\n", - isc_result_totext(isc_result)); - ++*nprobs; - return; - } - - isc_result = isc_file_getsizefd(fileno(fp), &size); - if (isc_result != ISC_R_SUCCESS) { - t_info("t2_sigchk: stat (%s) failed %s\n", - datapath, isc_result_totext(isc_result)); - ++*nprobs; - isc_stdio_close(fp); - return; - } - - data = (unsigned char *) malloc(size * sizeof(unsigned char)); - if (data == NULL) { - t_info("t2_sigchk: malloc failed %d\n", errno); - ++*nprobs; - isc_stdio_close(fp); - return; - } - - p = data; - len = (size_t)size; - do { - isc_result = isc_stdio_read(p, 1, len, fp, &rval); - if (isc_result == ISC_R_SUCCESS) { - len -= rval; - p += rval; - } - } while (len); - (void) isc_stdio_close(fp); - - /* - * Read key from file in a form usable by dst_verify. - */ - dns_fixedname_init(&fname); - name = dns_fixedname_name(&fname); - isc_buffer_constinit(&b, keyname, strlen(keyname)); - isc_buffer_add(&b, strlen(keyname)); - isc_result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - isc_result_totext(isc_result)); - (void) free(data); - ++*nprobs; - return; - } - isc_result = dst_key_fromfile(name, id, alg, type, NULL, mctx, &key); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_key_fromfile failed %s\n", - isc_result_totext(isc_result)); - (void) free(data); - ++*nprobs; - return; - } - - isc_buffer_init(&databuf, data, (unsigned int)size); - isc_buffer_add(&databuf, (unsigned int)size); - isc_buffer_usedregion(&databuf, &datareg); - -#ifdef NEWSIG - - /* - * If we're generating a signature for the first time, - * sign the data and save the signature to a file - */ - - memset(sig, 0, sizeof(sig)); - isc_buffer_init(&sigbuf, sig, sizeof(sig)); - - isc_result = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_GENERAL, - ISC_TRUE, &ctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_context_create(%d) failed %s\n", - dst_result_totext(isc_result)); - (void) free(data); - dst_key_free(&key); - ++*nprobs; - return; - } - isc_result = dst_context_adddata(ctx, &datareg); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_context_adddata(%d) failed %s\n", - dst_result_totext(isc_result)); - (void) free(data); - dst_key_free(&key); - dst_context_destroy(&ctx); - ++*nprobs; - return; - } - isc_result = dst_context_sign(ctx, &sigbuf); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_sign(%d) failed %s\n", - dst_result_totext(isc_result)); - (void) free(data); - dst_key_free(&key); - dst_context_destroy(&ctx); - ++*nprobs; - return; - } - dst_context_destroy(&ctx); - - rval = sig_tofile(sigpath, &sigbuf); - if (rval != 0) { - t_info("sig_tofile failed\n"); - ++*nprobs; - (void) free(data); - dst_key_free(&key); - return; - } - -#endif /* NEWSIG */ - - memset(sig, 0, sizeof(sig)); - isc_buffer_init(&sigbuf, sig, sizeof(sig)); - - /* - * Read precomputed signature from file in a form usable by dst_verify. - */ - rval = sig_fromfile(sigpath, &sigbuf); - if (rval != 0U) { - t_info("sig_fromfile failed\n"); - (void) free(data); - dst_key_free(&key); - ++*nprobs; - return; - } - - /* - * Verify that the key signed the data. - */ - isc_buffer_remainingregion(&sigbuf, &sigreg); - - exp_res = 0; - if (strstr(expected_result, "!")) - exp_res = 1; - - isc_result = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_GENERAL, - ISC_FALSE, &ctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_context_create returned %s\n", - isc_result_totext(isc_result)); - (void) free(data); - dst_key_free(&key); - ++*nfails; - return; - } - isc_result = dst_context_adddata(ctx, &datareg); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_context_adddata returned %s\n", - isc_result_totext(isc_result)); - (void) free(data); - dst_context_destroy(&ctx); - dst_key_free(&key); - ++*nfails; - return; - } - isc_result = dst_context_verify(ctx, &sigreg); - if ( ((exp_res == 0) && (isc_result != ISC_R_SUCCESS)) || - ((exp_res != 0) && (isc_result == ISC_R_SUCCESS))) { - - t_info("dst_context_verify returned %s, expected %s\n", - isc_result_totext(isc_result), - expected_result); - ++*nfails; - } - - (void) free(data); - dst_context_destroy(&ctx); - dst_key_free(&key); - return; -} - -/* - * The astute observer will note that t1() signs then verifies data - * during the test but that t2() verifies data that has been - * signed at some earlier time, possibly with an entire different - * version or implementation of the DSA and RSA algorithms - */ - -isc_mem_t *t2_mctx = NULL; -isc_entropy_t *t2_ectx = NULL; - -static int -t2_vfy_init(void) { - isc_result_t isc_result; - - t2_mctx = NULL; - isc_result = isc_mem_create(0, 0, &t2_mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %s\n", - isc_result_totext(isc_result)); - return(0); - } - t2_ectx = NULL; - isc_result = isc_entropy_create(t2_mctx, &t2_ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - return(0); - } - isc_result = isc_entropy_createfilesource(t2_ectx, "randomfile"); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create failed %s\n", - isc_result_totext(isc_result)); - return(0); - } - isc_result = dst_lib_init(t2_mctx, t2_ectx, ISC_ENTROPY_BLOCKING); - if (isc_result != ISC_R_SUCCESS) { - t_info("dst_lib_init failed %s\n", - isc_result_totext(isc_result)); - return(0); - } - return(1); -} - -/* - * av == datafile, sigpath, keyname, keyid, alg, exp_result. - */ -static int -t2_vfy(char **av) { - char *datapath; - char *sigpath; - char *keyname; - char *key; - int keyid; - char *alg; - int algid; - char *exp_result; - int nfails; - int nprobs; - int result; - - datapath = *av++; - sigpath = *av++; - keyname = *av++; - key = *av++; - keyid = atoi(key); - alg = *av++; - exp_result = *av++; - nfails = 0; - nprobs = 0; - - if (! strcasecmp(alg, "DST_ALG_DSA")) - algid = DST_ALG_DSA; - else if (! strcasecmp(alg, "DST_ALG_RSAMD5")) - algid = DST_ALG_RSAMD5; - else { - t_info("Unknown algorithm %s\n", alg); - return(T_UNRESOLVED); - } - - if (!dst_algorithm_supported(DST_ALG_RSAMD5)) { - t_info("library built without crypto support\n"); - return (T_SKIPPED); - } - - t_info("testing %s, %s, %s, %s, %s, %s\n", - datapath, sigpath, keyname, key, alg, exp_result); - t2_sigchk(datapath, sigpath, keyname, keyid, - algid, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, - t2_mctx, exp_result, - &nfails, &nprobs); - - result = T_UNRESOLVED; - if (nfails) - result = T_FAIL; - else if ((nfails == 0) && (nprobs == 0)) - result = T_PASS; - - return(result); -} - -static const char *a2 = - "the dst module provides the capability to " - "verify data signed with the RSA and DSA algorithms"; - -static void -t2(void) { - int result; - t_assert("dst", 2, T_REQUIRED, "%s", a2); - if (!t2_vfy_init()) { - result = T_UNRESOLVED; - } else { - result = t_eval("dst_2_data", t2_vfy, 6); - dst_lib_destroy(); - } - if (t2_ectx) - isc_entropy_detach(&t2_ectx); - if (t2_mctx) - isc_mem_destroy(&t2_mctx); - t_result(result); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "basic dst module verification" }, - { (PFV) t2, "signature ineffability" }, - { (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/dst/win32/REQUIRE_EXTENDED_DIR b/bin/tests/dst/win32/REQUIRE_EXTENDED_DIR deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bin/tests/dst/win32/t_dst.vcxproj.filters.in b/bin/tests/dst/win32/t_dst.vcxproj.filters.in deleted file mode 100644 index d49779dbd6..0000000000 --- a/bin/tests/dst/win32/t_dst.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/dst/win32/t_dst.vcxproj.in b/bin/tests/dst/win32/t_dst.vcxproj.in deleted file mode 100644 index a1aeb00dd8..0000000000 --- a/bin/tests/dst/win32/t_dst.vcxproj.in +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {EE9B94CF-7C33-4F3B-A674-FB756D422C54} - Win32Proj - t_dst - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - cd .. -copy "Kdh.+002+18602.key.in" "Kdh.+002+18602.key" -copy "Kdh.+002+18602.private.in" "Kdh.+002+18602.private" -copy "Kdh.+002+48957.key.in" "Kdh.+002+48957.key" -copy "Kdh.+002+48957.private.in" "Kdh.+002+48957.private" -copy "Ktest.+001+00002.key.in" "Ktest.+001+00002.key" -copy "Ktest.+001+54622.key.in" "Ktest.+001+54622.key" -copy "Ktest.+001+54622.private.in" "Ktest.+001+54622.private" -copy "Ktest.+003+23616.key.in" "Ktest.+003+23616.key" -copy "Ktest.+003+23616.private.in" "Ktest.+003+23616.private" -copy "Ktest.+003+49667.key.in" "Ktest.+003+49667.key" -copy dst_2_data.in dst_2_data -copy t2_data_1.in t2_data_1 -copy t2_data_2.in t2_data_2 -copy t2_dsasig.in t2_dsasig -copy t2_rsasig.in t2_rsasig - - - - - - Level3 - - - MaxSpeed - true - @INTRINSIC@ - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - OnlyExplicitInline - false - true - .\$(Configuration)\$(TargetName).pch - .\$(Configuration)\ - .\$(Configuration)\ - $(OutDir)$(TargetName).pdb - .\;..\..\..\..\;@LIBXML2_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - cd .. -copy "Kdh.+002+18602.key.in" "Kdh.+002+18602.key" -copy "Kdh.+002+18602.private.in" "Kdh.+002+18602.private" -copy "Kdh.+002+48957.key.in" "Kdh.+002+48957.key" -copy "Kdh.+002+48957.private.in" "Kdh.+002+48957.private" -copy "Ktest.+001+00002.key.in" "Ktest.+001+00002.key" -copy "Ktest.+001+54622.key.in" "Ktest.+001+54622.key" -copy "Ktest.+001+54622.private.in" "Ktest.+001+54622.private" -copy "Ktest.+003+23616.key.in" "Ktest.+003+23616.key" -copy "Ktest.+003+23616.private.in" "Ktest.+003+23616.private" -copy "Ktest.+003+49667.key.in" "Ktest.+003+49667.key" -copy dst_2_data.in dst_2_data -copy t2_data_1.in t2_data_1 -copy t2_data_2.in t2_data_2 -copy t2_dsasig.in t2_dsasig -copy t2_rsasig.in t2_rsasig - - - - - - - - - - diff --git a/bin/tests/dst/win32/t_dst.vcxproj.user b/bin/tests/dst/win32/t_dst.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/dst/win32/t_dst.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/hashes/Makefile.in b/bin/tests/hashes/Makefile.in deleted file mode 100644 index a1276ff789..0000000000 --- a/bin/tests/hashes/Makefile.in +++ /dev/null @@ -1,47 +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} ${ISC_INCLUDES} @DST_OPENSSL_INC@ - -CDEFINES = @CRYPTO@ -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${ISCDEPLIBS} - -LIBS = ${ISCLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_hashes@EXEEXT@ - -SRCS = t_hashes.c - -@BIND9_MAKE_RULES@ - -t_hashes@EXEEXT@: t_hashes.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_hashes.@O@ ${TLIB} ${LIBS} - -test: t_hashes@EXEEXT@ - -@./t_hashes@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -q 60 -a - -testhelp: - @./t_hashes@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/hashes/t_hashes.c b/bin/tests/hashes/t_hashes.c deleted file mode 100644 index 279ccff0ad..0000000000 --- a/bin/tests/hashes/t_hashes.c +++ /dev/null @@ -1,495 +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_hashes.c,v 1.5 2010/10/04 22:27:41 marka Exp $ */ - -/* - * -d1 or larger shows hash or HMAC result even if correct - */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - - -static int nprobs; - -typedef void(*HASH_INIT)(void *); -typedef void(*HMAC_INIT)(void *, const unsigned char *, unsigned int); -typedef void(*UPDATE)(void *, const unsigned char *, unsigned int); -typedef void(*FINAL)(void *, const unsigned char *); -typedef void(*SIGN)(void *, const unsigned char *, unsigned int); - -typedef struct { - const char *name; - const unsigned char *key; - const unsigned int key_len; - const unsigned char *str; - const unsigned int str_len; -} IN_; -#define STR_INIT(s) (const unsigned char *)(s), sizeof(s)-1 - - -union { - unsigned char b[1024]; -#ifndef PK11_MD5_DISABLE - unsigned char md5[16]; -#endif - unsigned char sha1[ISC_SHA1_DIGESTLENGTH]; - unsigned char sha224[ISC_SHA224_DIGESTLENGTH]; - unsigned char sha256[ISC_SHA256_DIGESTLENGTH]; - unsigned char sha384[ISC_SHA384_DIGESTLENGTH]; - unsigned char sha512[ISC_SHA512_DIGESTLENGTH]; -} dbuf; -#define DIGEST_FILL 0xdf - -typedef struct { - const char *str; - const unsigned int digest_len; -} OUT_; - - -/* - * two ad hoc hash examples - */ -static IN_ abc = { "\"abc\"", NULL, 0, STR_INIT("abc")}; -static OUT_ abc_sha1 = { - "a9993e364706816aba3e25717850c26c9cd0d89d", - ISC_SHA1_DIGESTLENGTH}; -static OUT_ abc_sha224 = { - "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7", - ISC_SHA224_DIGESTLENGTH}; -#ifndef PK11_MD5_DISABLE -static OUT_ abc_md5 = { - "900150983cd24fb0d6963f7d28e17f72", - 16}; -#endif - -static IN_ abc_blah = { "\"abcdbc...\"", NULL, 0, - STR_INIT("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")}; -static OUT_ abc_blah_sha1 = { - "84983e441c3bd26ebaae4aa1f95129e5e54670f1", - ISC_SHA1_DIGESTLENGTH}; -static OUT_ abc_blah_sha224 = { - "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525", - ISC_SHA224_DIGESTLENGTH}; -#ifndef PK11_MD5_DISABLE -static OUT_ abc_blah_md5 = { - "8215ef0796a20bcaaae116d3876c664a", - 16}; - -/* - * three HMAC-md5 examples from RFC 2104 - */ -static const unsigned char rfc2104_1_key[16] = { - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}; -static IN_ rfc2104_1 = {"RFC 2104 #1", rfc2104_1_key, sizeof(rfc2104_1_key), - STR_INIT("Hi There")}; -static OUT_ rfc2104_1_hmac = { - "9294727a3638bb1c13f48ef8158bfc9d", - 16}; - -static IN_ rfc2104_2 = {"RFC 2104 #2", STR_INIT("Jefe"), - STR_INIT("what do ya want for nothing?")}; -static OUT_ rfc2104_2_hmac = { - "750c783e6ab0b503eaa86e310a5db738", - 16}; - -static const unsigned char rfc2104_3_key[16] = { - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}; -static const unsigned char rfc2104_3_s[50] = { - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD}; -static IN_ rfc2104_3 = {"RFC 2104 #3", rfc2104_3_key, sizeof(rfc2104_3_key), - rfc2104_3_s, sizeof(rfc2104_3_s)}; -static OUT_ rfc2104_3_hmac = { - "56be34521d144c88dbb8c733f0e8b3f6", - 16}; -#endif - -/* - * four three HMAC-SHA tests cut-and-pasted from RFC 4634 starting on page 86 - */ -static const unsigned char rfc4634_1_key[20] = { - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b -}; -static IN_ rfc4634_1 = {"RFC 4634 #1", rfc4634_1_key, sizeof(rfc4634_1_key), - STR_INIT("Hi There")}; -static OUT_ rfc4634_1_sha1 = { - "B617318655057264E28BC0B6FB378C8EF146BE00", - ISC_SHA1_DIGESTLENGTH}; -static OUT_ rfc4634_1_sha224 = { - "896FB1128ABBDF196832107CD49DF33F47B4B1169912BA4F53684B22", - ISC_SHA224_DIGESTLENGTH}; -static OUT_ rfc4634_1_sha256 = { - "B0344C61D8DB38535CA8AFCEAF0BF12B881DC200C9833DA726E9376C2E32" - "CFF7", - ISC_SHA256_DIGESTLENGTH}; -static OUT_ rfc4634_1_sha384 = { - "AFD03944D84895626B0825F4AB46907F15F9DADBE4101EC682AA034C7CEB" - "C59CFAEA9EA9076EDE7F4AF152E8B2FA9CB6", - ISC_SHA384_DIGESTLENGTH}; -static OUT_ rfc4634_1_sha512 = { - "87AA7CDEA5EF619D4FF0B4241A1D6CB02379F4E2CE4EC2787AD0B30545E1" - "7CDEDAA833B7D6B8A702038B274EAEA3F4E4BE9D914EEB61F1702E696C20" - "3A126854", - ISC_SHA512_DIGESTLENGTH}; - -static IN_ rfc4634_2 = {"RFC 4634 #2", STR_INIT("Jefe"), - STR_INIT("what do ya want for nothing?")}; -static OUT_ rfc4634_2_sha1 = { - "EFFCDF6AE5EB2FA2D27416D5F184DF9C259A7C79", - ISC_SHA1_DIGESTLENGTH}; -static OUT_ rfc4634_2_sha224 = { - "A30E01098BC6DBBF45690F3A7E9E6D0F8BBEA2A39E6148008FD05E44", - ISC_SHA224_DIGESTLENGTH}; -static OUT_ rfc4634_2_sha256 = { - "5BDCC146BF60754E6A042426089575C75A003F089D2739839DEC58B964EC" - "3843", - ISC_SHA256_DIGESTLENGTH}; -static OUT_ rfc4634_2_sha384 = { - "AF45D2E376484031617F78D2B58A6B1B9C7EF464F5A01B47E42EC3736322" - "445E8E2240CA5E69E2C78B3239ECFAB21649", - ISC_SHA384_DIGESTLENGTH}; -static OUT_ rfc4634_2_sha512 = { - "164B7A7BFCF819E2E395FBE73B56E0A387BD64222E831FD610270CD7EA25" - "05549758BF75C05A994A6D034F65F8F0E6FDCAEAB1A34D4A6B4B636E070A" - "38BCE737", - ISC_SHA512_DIGESTLENGTH}; - -static const unsigned char rfc4634_3_key[20] = { - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa -}; -static const unsigned char rfc4634_3_s[50] = { - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd -}; -static IN_ rfc4634_3 = {"RFC 4634 #3", rfc4634_3_key, sizeof(rfc4634_3_key), - rfc4634_3_s, sizeof(rfc4634_3_s)}; -static OUT_ rfc4634_3_sha1 = { - "125D7342B9AC11CD91A39AF48AA17B4F63F175D3", - ISC_SHA1_DIGESTLENGTH}; -static OUT_ rfc4634_3_sha224 = { - "7FB3CB3588C6C1F6FFA9694D7D6AD2649365B0C1F65D69D1EC8333EA", - ISC_SHA224_DIGESTLENGTH}; -static OUT_ rfc4634_3_sha256 = { - "773EA91E36800E46854DB8EBD09181A72959098B3EF8C122D9635514CED5" - "65FE", - ISC_SHA256_DIGESTLENGTH}; -static OUT_ rfc4634_3_sha384 = { - "88062608D3E6AD8A0AA2ACE014C8A86F0AA635D947AC9FEBE83EF4E55966" - "144B2A5AB39DC13814B94E3AB6E101A34F27", - ISC_SHA384_DIGESTLENGTH}; -static OUT_ rfc4634_3_sha512 = { - "FA73B0089D56A284EFB0F0756C890BE9B1B5DBDD8EE81A3655F83E33B227" - "9D39BF3E848279A722C806B485A47E67C807B946A337BEE8942674278859" - "E13292FB", - ISC_SHA512_DIGESTLENGTH}; - -static const unsigned char rfc4634_4_key[25] = { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x18, 0x19 -}; -static const unsigned char rfc4634_4_s[50] = { - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, - 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd -}; -static IN_ rfc4634_4 = {"RFC 4634 #3", rfc4634_4_key, sizeof(rfc4634_4_key), - rfc4634_4_s, sizeof(rfc4634_4_s)}; -static OUT_ rfc4634_4_sha1 = { - "4C9007F4026250C6BC8414F9BF50C86C2D7235DA", - ISC_SHA1_DIGESTLENGTH}; -static OUT_ rfc4634_4_sha224 = { - "6C11506874013CAC6A2ABC1BB382627CEC6A90D86EFC012DE7AFEC5A", - ISC_SHA224_DIGESTLENGTH}; -static OUT_ rfc4634_4_sha256 = { - "82558A389A443C0EA4CC819899F2083A85F0FAA3E578F8077A2E3FF46729" - "665B", - ISC_SHA256_DIGESTLENGTH}; -static OUT_ rfc4634_4_sha384 = { - "3E8A69B7783C25851933AB6290AF6CA77A9981480850009CC5577C6E1F57" - "3B4E6801DD23C4A7D679CCF8A386C674CFFB", - ISC_SHA384_DIGESTLENGTH}; -static OUT_ rfc4634_4_sha512 = { - "B0BA465637458C6990E5A8C5F61D4AF7E576D97FF94B872DE76F8050361E" - "E3DBA91CA5C11AA25EB4D679275CC5788063A5F19741120C4F2DE2ADEBEB" - "10A298DD", - ISC_SHA512_DIGESTLENGTH}; - - - -static const char * -d2str(char *buf, unsigned int buf_len, - const unsigned char *d, unsigned int d_len) -{ - unsigned int i, l; - - l = 0; - for (i = 0; i < d_len && l < buf_len-4; ++i) { - l += snprintf(&buf[l], buf_len-l, "%02x", d[i]); - } - if (l >= buf_len-3) { - REQUIRE(buf_len > sizeof("...")); - strcpy(&buf[l-sizeof(" ...")], " ..."); - } - return buf; -} - - - -/* - * Compare binary digest or HMAC to string of hex digits from an RFC - */ -static void -ck(const char *name, const IN_ *in, const OUT_ *out) -{ - char buf[sizeof(dbuf)*2+1]; - const char *str_name; - unsigned int l; - - d2str(buf, sizeof(buf), dbuf.b, out->digest_len); - str_name = in->name != NULL ? in->name : (const char *)in->str; - - if (T_debug != 0) - t_info("%s(%s) = %s\n", name, str_name, buf); - - if (strcasecmp(buf, out->str)) { - t_info("%s(%s)\n%9s %s\n%9s %s\n", - name, str_name, - "is", buf, - "should be", out->str); - ++nprobs; - return; - } - - /* - * check that the hash or HMAC is no longer than we think it is - */ - for (l = out->digest_len; l < sizeof(dbuf); ++l) { - if (dbuf.b[l] != DIGEST_FILL) { - t_info("byte #%d after end of %s(%s) changed to %02x\n", - l-out->digest_len, name, str_name, dbuf.b[l]); - ++nprobs; - break; - } - } -} - - - -static void -t_hash(const char *hname, HASH_INIT init, UPDATE update, FINAL final, - IN_ *in, OUT_ *out) -{ - union { - unsigned char b[1024]; - isc_sha1_t sha1; -#ifndef PK11_MD5_DISABLE - isc_md5_t md5; -#endif - } ctx; - - init(&ctx); - update(&ctx, in->str, in->str_len); - memset(dbuf.b, DIGEST_FILL, sizeof(dbuf)); - final(&ctx, dbuf.b); - ck(hname, in, out); -} - - - -/* - * isc_sha224_final has a different calling sequence - */ -static void -t_sha224(IN_ *in, OUT_ *out) -{ - isc_sha224_t ctx; - - memset(dbuf.b, DIGEST_FILL, sizeof(dbuf)); - isc_sha224_init(&ctx); - isc_sha224_update(&ctx, in->str, in->str_len); - memset(dbuf.b, DIGEST_FILL, sizeof(dbuf)); - isc_sha224_final(dbuf.b, &ctx); - ck("SHA224", in, out); -} - - - -static void -#ifndef PK11_MD5_DISABLE -t_hashes(IN_ *in, OUT_ *out_sha1, OUT_ *out_sha224, OUT_ *out_md5) -#else -t_hashes(IN_ *in, OUT_ *out_sha1, OUT_ *out_sha224) -#endif -{ - t_hash("SHA1", (HASH_INIT)isc_sha1_init, (UPDATE)isc_sha1_update, - (FINAL)isc_sha1_final, in, out_sha1); - t_sha224(in, out_sha224); -#ifndef PK11_MD5_DISABLE - t_hash("md5", (HASH_INIT)isc_md5_init, (UPDATE)isc_md5_update, - (FINAL)isc_md5_final, in, out_md5); -#endif -} - - -#ifndef PK11_MD5_DISABLE -/* - * isc_hmacmd5_sign has a different calling sequence - */ -static void -t_md5hmac(IN_ *in, OUT_ *out) -{ - isc_hmacmd5_t ctx; - - isc_hmacmd5_init(&ctx, in->key, in->key_len); - isc_hmacmd5_update(&ctx, in->str, in->str_len); - memset(dbuf.b, DIGEST_FILL, sizeof(dbuf)); - isc_hmacmd5_sign(&ctx, dbuf.b); - ck("HMAC-md5", in, out); -} -#endif - - -static void -t_hmac(const char *hname, HMAC_INIT init, UPDATE update, SIGN sign, - IN_ *in, OUT_ *out) -{ - union { - unsigned char b[1024]; -#ifndef PK11_MD5_DISABLE - isc_hmacmd5_t hmacmd5; -#endif - isc_hmacsha1_t hmacsha1; - isc_hmacsha224_t hmacsha224; - isc_hmacsha256_t hmacsha256; - isc_hmacsha384_t hmacsha384; - isc_hmacsha512_t hmacsha512; - } ctx; - - init(&ctx, in->key, in->key_len); - update(&ctx, in->str, in->str_len); - memset(dbuf.b, DIGEST_FILL, sizeof(dbuf)); - sign(&ctx, dbuf.b, out->digest_len); - ck(hname, in, out); -} - - - -static void -t_hmacs(IN_ *in, OUT_ *out_sha1, OUT_ *out_sha224, OUT_ *out_sha256, - OUT_ *out_sha384, OUT_ *out_sha512) -{ - t_hmac("HMAC-SHA1", (HMAC_INIT)isc_hmacsha1_init, - (UPDATE)isc_hmacsha1_update, (SIGN)isc_hmacsha1_sign, - in, out_sha1); - t_hmac("HMAC-SHA224", (HMAC_INIT)isc_hmacsha224_init, - (UPDATE)isc_hmacsha224_update, (SIGN)isc_hmacsha224_sign, - in, out_sha224); - t_hmac("HMAC-SHA256", (HMAC_INIT)isc_hmacsha256_init, - (UPDATE)isc_hmacsha256_update, (SIGN)isc_hmacsha256_sign, - in, out_sha256); - t_hmac("HMAC-SHA384", (HMAC_INIT)isc_hmacsha384_init, - (UPDATE)isc_hmacsha384_update, (SIGN)isc_hmacsha384_sign, - in, out_sha384); - t_hmac("HMAC-SHA512", (HMAC_INIT)isc_hmacsha512_init, - (UPDATE)isc_hmacsha512_update, (SIGN)isc_hmacsha512_sign, - in, out_sha512); -} - - - -/* - * This will almost never fail, and so there is no need for the extra noise - * that would come from breaking it into several tests. - */ -static void -t1(void) -{ - /* - * two ad hoc hash examples - */ -#ifndef PK11_MD5_DISABLE - t_hashes(&abc, &abc_sha1, &abc_sha224, &abc_md5); - t_hashes(&abc_blah, &abc_blah_sha1, &abc_blah_sha224, &abc_blah_md5); -#else - t_hashes(&abc, &abc_sha1, &abc_sha224); - t_hashes(&abc_blah, &abc_blah_sha1, &abc_blah_sha224); -#endif - -#ifndef PK11_MD5_DISABLE - /* - * three HMAC-md5 examples from RFC 2104 - */ - t_md5hmac(&rfc2104_1, &rfc2104_1_hmac); - t_md5hmac(&rfc2104_2, &rfc2104_2_hmac); - t_md5hmac(&rfc2104_3, &rfc2104_3_hmac); -#endif - - /* - * four HMAC-SHA tests from RFC 4634 starting on page 86 - */ - t_hmacs(&rfc4634_1, &rfc4634_1_sha1, &rfc4634_1_sha224, - &rfc4634_1_sha256, &rfc4634_1_sha384, &rfc4634_1_sha512); - t_hmacs(&rfc4634_2, &rfc4634_2_sha1, &rfc4634_2_sha224, - &rfc4634_2_sha256, &rfc4634_2_sha384, &rfc4634_2_sha512); - t_hmacs(&rfc4634_3, &rfc4634_3_sha1, &rfc4634_3_sha224, - &rfc4634_3_sha256, &rfc4634_3_sha384, &rfc4634_3_sha512); - t_hmacs(&rfc4634_4, &rfc4634_4_sha1, &rfc4634_4_sha224, - &rfc4634_4_sha256, &rfc4634_4_sha384, &rfc4634_4_sha512); - - if (nprobs != 0) - t_result(T_FAIL); - else - t_result(T_PASS); -} - - -testspec_t T_testlist[] = { - { (PFV) t1, "hashes" }, - { (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/hashes/win32/t_hashes.vcxproj.filters.in b/bin/tests/hashes/win32/t_hashes.vcxproj.filters.in deleted file mode 100644 index 0f4bd9c4b2..0000000000 --- a/bin/tests/hashes/win32/t_hashes.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/hashes/win32/t_hashes.vcxproj.in b/bin/tests/hashes/win32/t_hashes.vcxproj.in deleted file mode 100644 index 6af5cb5176..0000000000 --- a/bin/tests/hashes/win32/t_hashes.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {14071120-84F6-4A6F-BF23-90EC5D0372CE} - Win32Proj - t_hashes - - - - 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\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.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\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/hashes/win32/t_hashes.vcxproj.user b/bin/tests/hashes/win32/t_hashes.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/hashes/win32/t_hashes.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/master/Makefile.in b/bin/tests/master/Makefile.in deleted file mode 100644 index 4764a113e6..0000000000 --- a/bin/tests/master/Makefile.in +++ /dev/null @@ -1,51 +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 = - -# Note that we do not want to use libtool for libt_api -DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -DNSDEPLIBS = ../../../lib/dns/libdns.@A@ -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_master@EXEEXT@ - -SRCS = t_master.c - -@BIND9_MAKE_RULES@ - -t_master@EXEEXT@: t_master.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_master.@O@ ${TLIB} ${LIBS} - -test: t_master@EXEEXT@ - -@ ./t_master@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @ ./t_master@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/master/dns_master_load_10_data b/bin/tests/master/dns_master_load_10_data deleted file mode 100644 index cfaa3fb331..0000000000 --- a/bin/tests/master/dns_master_load_10_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 9 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master10.data test in ISC_R_SUCCESS diff --git a/bin/tests/master/dns_master_load_11_data b/bin/tests/master/dns_master_load_11_data deleted file mode 100644 index 7b667b273b..0000000000 --- a/bin/tests/master/dns_master_load_11_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 11 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master11.data test in ISC_R_SUCCESS diff --git a/bin/tests/master/dns_master_load_1_data b/bin/tests/master/dns_master_load_1_data deleted file mode 100644 index fc92c748a3..0000000000 --- a/bin/tests/master/dns_master_load_1_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 1 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master1.data test in ISC_R_SUCCESS diff --git a/bin/tests/master/dns_master_load_2_data b/bin/tests/master/dns_master_load_2_data deleted file mode 100644 index a6e44b34cc..0000000000 --- a/bin/tests/master/dns_master_load_2_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 2 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master2.data test in ISC_R_UNEXPECTEDEND diff --git a/bin/tests/master/dns_master_load_3_data b/bin/tests/master/dns_master_load_3_data deleted file mode 100644 index 9dbdfb20aa..0000000000 --- a/bin/tests/master/dns_master_load_3_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 3 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master3.data test in DNS_R_NOOWNER diff --git a/bin/tests/master/dns_master_load_4_data b/bin/tests/master/dns_master_load_4_data deleted file mode 100644 index 66ad1ff36a..0000000000 --- a/bin/tests/master/dns_master_load_4_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 4 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master4.data test in ISC_R_SUCCESS diff --git a/bin/tests/master/dns_master_load_5_data b/bin/tests/master/dns_master_load_5_data deleted file mode 100644 index 56e33ba7ad..0000000000 --- a/bin/tests/master/dns_master_load_5_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 5 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master5.data test in DNS_R_BADCLASS diff --git a/bin/tests/master/dns_master_load_6_data b/bin/tests/master/dns_master_load_6_data deleted file mode 100644 index d14aa88892..0000000000 --- a/bin/tests/master/dns_master_load_6_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 6 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master6.data test in ISC_R_SUCCESS diff --git a/bin/tests/master/dns_master_load_7_data b/bin/tests/master/dns_master_load_7_data deleted file mode 100644 index dbe7ef9a64..0000000000 --- a/bin/tests/master/dns_master_load_7_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 7 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master7.data test in ISC_R_SUCCESS diff --git a/bin/tests/master/dns_master_load_8_data b/bin/tests/master/dns_master_load_8_data deleted file mode 100644 index b109d43b8d..0000000000 --- a/bin/tests/master/dns_master_load_8_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 8 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master8.data test in DNS_R_SEENINCLUDE diff --git a/bin/tests/master/dns_master_load_9_data b/bin/tests/master/dns_master_load_9_data deleted file mode 100644 index af36072a8d..0000000000 --- a/bin/tests/master/dns_master_load_9_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_master_load test 9 -# -# format is: -# masterfile origin class expected_result -# where -# masterfile name is the name of a file containing master data -# origin is the origin -# class is the zone's class -# expected_result is a text representation of a dns_result_t -# -master9.data test in DNS_R_BADCLASS diff --git a/bin/tests/master/master1.data b/bin/tests/master/master1.data deleted file mode 100644 index 9b8147407c..0000000000 --- a/bin/tests/master/master1.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 ns2vix.com. -a in ns ns3vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/master/master10.data b/bin/tests/master/master10.data deleted file mode 100644 index 9ee052fca9..0000000000 --- a/bin/tests/master/master10.data +++ /dev/null @@ -1,7 +0,0 @@ -; -; the following black line contains spaces - -; -@ 300 IN A 10.0.0.1 - ; -; diff --git a/bin/tests/master/master11.data b/bin/tests/master/master11.data deleted file mode 100644 index 0aaec25ecf..0000000000 --- a/bin/tests/master/master11.data +++ /dev/null @@ -1,6 +0,0 @@ -; -; The following serial number contains a leading 0 and a 9 so the -; we can catch cases where it is incorrectly treated as a octal -; number. -; -@ 300 IN SOA ns hostmaster 00090000 1200 3600 604800 300 diff --git a/bin/tests/master/master2.data b/bin/tests/master/master2.data deleted file mode 100644 index b8ca38dd0d..0000000000 --- a/bin/tests/master/master2.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 -a in ns ns2vix.com. -a in ns ns3vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/master/master3.data b/bin/tests/master/master3.data deleted file mode 100644 index 7283af61b6..0000000000 --- a/bin/tests/master/master3.data +++ /dev/null @@ -1,11 +0,0 @@ -$TTL 1000 - in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - in ns ns.vix.com - in ns ns2vix.com. -a in ns ns3vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/master/master4.data b/bin/tests/master/master4.data deleted file mode 100644 index 3a694ea5e3..0000000000 --- a/bin/tests/master/master4.data +++ /dev/null @@ -1,11 +0,0 @@ - -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum -a in ns ns.vix.com. -a in ns ns2vix.com. -a in ns ns3vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/master/master5.data b/bin/tests/master/master5.data deleted file mode 100644 index 95234bdafd..0000000000 --- a/bin/tests/master/master5.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 any ns ns.vix.com. -a in ns ns2vix.com. -a in ns ns3vix.com. -b in a 1.2.3.4 diff --git a/bin/tests/master/master6.data b/bin/tests/master/master6.data deleted file mode 100644 index a9a37bbf8e..0000000000 --- a/bin/tests/master/master6.data +++ /dev/null @@ -1,33 +0,0 @@ - -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - -secure1 3600 IN DNSKEY ( - FLAG2|FLAG4|FLAG5|NTYP3|FLAG8|FLAG9|FLAG10|FLAG11|SIG15 - 3 3 - ArT0a8FtOZWEONG2YQVl9+RA34op30JPz4NPEroCxm2yImT2 - 2OYggnPIzrgayyepgKU1PfTTypnJDTwrSrtISyEsj7tjM7/n - 03DP8VWSn0aLwpUuc7Sx9vtM1Wi+YeiA4Bv2Oz1VB9de4qql - sIq+KLn8J4wz95bGnJ0mHUB7oTDJ3Hl1zeaCMdX69Kr46yAY - AvGJJdGGDYxYgxzx2zNdzypkYSkxpdsNqUt38tabSfdvCn12 - pnmSWjlVJsjHhsaYnrPhouN5acOXMNbxNVbGU5LZ8Es6EYbV - /7YMt8VUkA8/8UCszBBT7XAJ3OFjiMO8mvxrZZFzvwJlPBQ1 - oFq/TNZlSe+N ) - -secure2 3600 in DNSKEY ( - flag2|flag4|flag5|ntyp3|flag8|flag9|flag10|flag11|sig15 - 3 3 - ArT0a8FtOZWEONG2YQVl9+RA34op30JPz4NPEroCxm2yImT2 - 2OYggnPIzrgayyepgKU1PfTTypnJDTwrSrtISyEsj7tjM7/n - 03DP8VWSn0aLwpUuc7Sx9vtM1Wi+YeiA4Bv2Oz1VB9de4qql - sIq+KLn8J4wz95bGnJ0mHUB7oTDJ3Hl1zeaCMdX69Kr46yAY - AvGJJdGGDYxYgxzx2zNdzypkYSkxpdsNqUt38tabSfdvCn12 - pnmSWjlVJsjHhsaYnrPhouN5acOXMNbxNVbGU5LZ8Es6EYbV - /7YMt8VUkA8/8UCszBBT7XAJ3OFjiMO8mvxrZZFzvwJlPBQ1 - oFq/TNZlSe+N ) - diff --git a/bin/tests/master/master7.data b/bin/tests/master/master7.data deleted file mode 100644 index 2638b5d77b..0000000000 --- a/bin/tests/master/master7.data +++ /dev/null @@ -1,17 +0,0 @@ - -$TTL 1000 -@ in soa localhost. postmaster.localhost. ( - 1993050801 ;serial - 3600 ;refresh - 1800 ;retry - 604800 ;expiration - 3600 ) ;minimum - -secure1 3600 IN DNSKEY ( - NOKEY|FLAG2|FLAG4|FLAG5|NTYP3|FLAG8|FLAG9|FLAG10|FLAG11|SIG15 - 3 3 ) - -secure2 3600 in DNSKEY ( - nokey|flag2|flag4|flag5|ntyp3|flag8|flag9|flag10|flag11|sig15 - 3 3 ) - diff --git a/bin/tests/master/master8.data b/bin/tests/master/master8.data deleted file mode 100644 index 58bded9583..0000000000 --- a/bin/tests/master/master8.data +++ /dev/null @@ -1,4 +0,0 @@ -; -; master7.data contains a good zone file -; -$include master7.data diff --git a/bin/tests/master/master9.data b/bin/tests/master/master9.data deleted file mode 100644 index e7bcf7e2ef..0000000000 --- a/bin/tests/master/master9.data +++ /dev/null @@ -1,4 +0,0 @@ -; -; master5.data is bad -; -$include master5.data diff --git a/bin/tests/master/t_master.c b/bin/tests/master/t_master.c deleted file mode 100644 index 96f1b40313..0000000000 --- a/bin/tests/master/t_master.c +++ /dev/null @@ -1,337 +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_master.c,v 1.41 2011/03/12 04:59:46 tbox Exp $ */ - -#include - -#include -#include - -#include -#include -#include /* Required for HP/UX (and others?) */ -#include - -#include -#include -#include -#include -#include -#include - -#include - -#define BUFLEN 255 -#define BIGBUFLEN (64 * 1024) - -static isc_result_t -t1_add_callback(void *arg, const dns_name_t *owner, dns_rdataset_t *dataset); - -isc_mem_t *T1_mctx; -char *Tokens[T_MAXTOKS + 1]; - -static isc_result_t -t1_add_callback(void *arg, const dns_name_t *owner, dns_rdataset_t *dataset) { - char buf[BIGBUFLEN]; - isc_buffer_t target; - isc_result_t result; - - UNUSED(arg); - - isc_buffer_init(&target, buf, BIGBUFLEN); - result = dns_rdataset_totext(dataset, owner, ISC_FALSE, ISC_FALSE, - &target); - if (result != ISC_R_SUCCESS) - t_info("dns_rdataset_totext: %s\n", dns_result_totext(result)); - - return(result); -} - -static int -test_master(char *testfile, char *origin, char *db_class, - isc_result_t exp_result) -{ - int result; - int len; - isc_result_t isc_result; - isc_result_t dns_result; - dns_name_t dns_origin; - isc_buffer_t source; - isc_buffer_t target; - unsigned char name_buf[BUFLEN]; - dns_rdatacallbacks_t callbacks; - dns_rdataclass_t rdataclass; - isc_textregion_t textregion; - - if (T1_mctx == NULL) - isc_result = isc_mem_create(0, 0, &T1_mctx); - else - isc_result = ISC_R_SUCCESS; - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - len = strlen(origin); - isc_buffer_init(&source, origin, len); - isc_buffer_add(&source, len); - isc_buffer_setactive(&source, len); - isc_buffer_init(&target, name_buf, BUFLEN); - dns_name_init(&dns_origin, NULL); - dns_result = dns_name_fromtext(&dns_origin, &source, dns_rootname, - 0, &target); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(T_UNRESOLVED); - } - - dns_rdatacallbacks_init_stdio(&callbacks); - callbacks.add = t1_add_callback; - - 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); - } - - dns_result = dns_master_loadfile( testfile, - &dns_origin, - &dns_origin, - rdataclass, - ISC_TRUE, - &callbacks, - T1_mctx); - - if (dns_result == exp_result) - result = T_PASS; - else { - t_info("dns_master_loadfile: got %s, expected %s\n", - dns_result_totext(dns_result), - dns_result_totext(exp_result)); - result = T_FAIL; - } - return(result); -} - -static int -test_master_x(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - - result = T_UNRESOLVED; - - fp = fopen(filename, "r"); - if (fp != NULL) { - line = 0; - while ((p = t_fgetbs(fp)) != NULL) { - - ++line; - - /* - * Skip comment lines. - */ - if ((isspace(*p & 0xff)) || (*p == '#')) { - (void)free(p); - continue; - } - - /* - * Name of data file, origin, zclass, expected result. - */ - cnt = t_bustline(p, Tokens); - if (cnt == 4) { - result = test_master(Tokens[0], Tokens[1], - Tokens[2], - t_dns_result_fromtext(Tokens[3])); - } else { - t_info("bad format in %s at line %d\n", - filename, line); - } - - (void)free(p); - } - (void)fclose(fp); - } else { - t_info("Missing datafile %s\n", filename); - } - return(result); -} - -static const char *a1 = "dns_master_loadfile loads a valid master file and " - "returns ISC_R_SUCCESS"; -static void -t1(void) { - int result; - t_assert("dns_master_loadfile", 1, T_REQUIRED, "%s", a1); - result = test_master_x("dns_master_load_1_data"); - t_result(result); -} - -static const char *a2 = - "dns_master_loadfile returns ISC_R_UNEXPECTEDEND when the " - "masterfile input ends unexpectedly"; - -static void -t2(void) { - int result; - t_assert("dns_master_loadfile", 2, T_REQUIRED, "%s", a2); - result = test_master_x("dns_master_load_2_data"); - t_result(result); -} - -static const char *a3 = "dns_master_loadfile returns DNS_R_NOOWNER when the " - "an ownername is not specified"; - -static void -t3() { - int result; - t_assert("dns_master_loadfile", 3, T_REQUIRED, "%s", a3); - result = test_master_x("dns_master_load_3_data"); - t_result(result); -} - -static const char *a4 = "dns_master_loadfile accepts broken zone files " - "where the first record has an undefined TTL, " - "as long as it is a SOA"; - -static void -t4() { - int result; - t_assert("dns_master_loadfile", 4, T_REQUIRED, "%s", a4); - result = test_master_x("dns_master_load_4_data"); - t_result(result); -} - -static const char *a5 = "dns_master_loadfile returns DNS_R_BADCLASS when the " - "the record class did not match the zone class"; - -static void -t5() { - int result; - - t_assert("dns_master_loadfile", 5, T_REQUIRED, "%s", a5); - result = test_master_x("dns_master_load_5_data"); - - t_result(result); -} - -static const char *a6 = - "dns_master_loadfile understands DNSKEY RR specifications " - "containing key material"; - -static void -t6() { - int result; - - t_assert("dns_master_loadfile", 6, T_REQUIRED, "%s", a6); - result = test_master_x("dns_master_load_6_data"); - - t_result(result); -} - -static const char *a7 = - "dns_master_loadfile understands DNSKEY RR specifications " - "containing no key material"; - -static void -t7() { - int result; - - t_assert("dns_master_loadfile", 7, T_REQUIRED, "%s", a7); - result = test_master_x("dns_master_load_7_data"); - - t_result(result); -} - -static const char *a8 = - "dns_master_loadfile understands $INCLUDE"; - -static void -t8() { - int result; - - t_assert("dns_master_loadfile", 8, T_REQUIRED, "%s", a8); - result = test_master_x("dns_master_load_8_data"); - - t_result(result); -} - -static const char *a9 = - "dns_master_loadfile understands $INCLUDE with failure"; - -static void -t9() { - int result; - - t_assert("dns_master_loadfile", 9, T_REQUIRED, "%s", a9); - result = test_master_x("dns_master_load_9_data"); - - t_result(result); -} - -static const char *a10 = - "dns_master_loadfile non-empty blank lines"; - -static void -t10() { - int result; - - t_assert("dns_master_loadfile", 10, T_REQUIRED, "%s", a10); - result = test_master_x("dns_master_load_10_data"); - - t_result(result); -} - -static const char *a11 = - "dns_master_loadfile allow leading zeros in SOA"; - -static void -t11() { - int result; - - t_assert("dns_master_loadfile", 11, T_REQUIRED, "%s", a11); - result = test_master_x("dns_master_load_11_data"); - - t_result(result); -} - - -testspec_t T_testlist[] = { - { (PFV) t1, "ISC_R_SUCCESS" }, - { (PFV) t2, "ISC_R_UNEXPECTEDEND" }, - { (PFV) t3, "DNS_NOOWNER" }, - { (PFV) t4, "DNS_NOTTL" }, - { (PFV) t5, "DNS_BADCLASS" }, - { (PFV) t6, "DNSKEY RR 1" }, - { (PFV) t7, "DNSKEY RR 2" }, - { (PFV) t8, "$INCLUDE" }, - { (PFV) t9, "$INCLUDE w/ DNS_BADCLASS" }, - { (PFV) t10, "non empty blank lines" }, - { (PFV) t11, "leading zeros in serial" }, - { (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/master/win32/t_master.vcxproj.filters.in b/bin/tests/master/win32/t_master.vcxproj.filters.in deleted file mode 100644 index b3a38285a1..0000000000 --- a/bin/tests/master/win32/t_master.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/master/win32/t_master.vcxproj.in b/bin/tests/master/win32/t_master.vcxproj.in deleted file mode 100644 index 2fb1bab813..0000000000 --- a/bin/tests/master/win32/t_master.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {5DC2F8D3-9373-41BB-B3AB-78F2E12F1E5E} - Win32Proj - t_master - - - - 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\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.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\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/master/win32/t_master.vcxproj.user b/bin/tests/master/win32/t_master.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/master/win32/t_master.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/mem/Makefile.in b/bin/tests/mem/Makefile.in deleted file mode 100644 index cd83865005..0000000000 --- a/bin/tests/mem/Makefile.in +++ /dev/null @@ -1,47 +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} ${ISC_INCLUDES} - -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ -TAPILIBS = ../../../lib/tests/libt_api.@A@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ -TAPIDEPLIBS = ../../../lib/tests/libt_api.@A@ - -DEPLIBS = ${TAPIDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${TAPILIBS} ${ISCLIBS} @LIBS@ - -TARGETS = t_mem@EXEEXT@ - -SRCS = t_mem.c - -@BIND9_MAKE_RULES@ - -t_mem@EXEEXT@: t_mem.@O@ ${DEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_mem.@O@ ${LIBS} - -test: t_mem@EXEEXT@ - -@./t_mem@EXEEXT@ -b @srcdir@ -q 450 -a - -testhelp: - @./t_mem@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/mem/t_mem.c b/bin/tests/mem/t_mem.c deleted file mode 100644 index a6081aa287..0000000000 --- a/bin/tests/mem/t_mem.c +++ /dev/null @@ -1,209 +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_mem.c,v 1.15 2009/01/22 23:47:54 tbox Exp $ */ - -#include - -#include - -#include - -/* - * Adapted from the original mempool_test.c program. - */ -isc_mem_t *mctx; - -#define MP1_FREEMAX 10 -#define MP1_FILLCNT 10 -#define MP1_MAXALLOC 30 - -#define MP2_FREEMAX 25 -#define MP2_FILLCNT 25 - -static int -memtest(void) { - int nfails; - void *items1[50]; - void *items2[50]; - void *tmp; - isc_mempool_t *mp1, *mp2; - isc_result_t isc_result; - unsigned int i, j; - int rval; - - - nfails = 0; - mctx = NULL; - 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)); - ++nfails; - return(nfails); - } - - mp1 = NULL; - isc_result = isc_mempool_create(mctx, 24, &mp1); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mempool_create failed %s\n", - isc_result_totext(isc_result)); - ++nfails; - return(nfails); - } - - mp2 = NULL; - isc_result = isc_mempool_create(mctx, 31, &mp2); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mempool_create failed %s\n", - isc_result_totext(isc_result)); - ++nfails; - return(nfails); - } - - if (T_debug) - isc_mem_stats(mctx, stderr); - - t_info("setting freemax to %d\n", MP1_FREEMAX); - isc_mempool_setfreemax(mp1, MP1_FREEMAX); - t_info("setting fillcount to %d\n", MP1_FILLCNT); - isc_mempool_setfillcount(mp1, MP1_FILLCNT); - t_info("setting maxalloc to %d\n", MP1_MAXALLOC); - isc_mempool_setmaxalloc(mp1, MP1_MAXALLOC); - - /* - * Allocate MP1_MAXALLOC items from the pool. This is our max. - */ - for (i = 0; i < MP1_MAXALLOC; i++) { - items1[i] = isc_mempool_get(mp1); - if (items1[i] == NULL) { - t_info("isc_mempool_get unexpectedly failed\n"); - ++nfails; - } - } - - /* - * Try to allocate one more. This should fail. - */ - tmp = isc_mempool_get(mp1); - if (tmp != NULL) { - t_info("isc_mempool_get unexpectedly succeeded\n"); - ++nfails; - } - - /* - * Free the first 11 items. Verify that there are 10 free items on - * the free list (which is our max). - */ - - for (i = 0; i < 11; i++) { - isc_mempool_put(mp1, items1[i]); - items1[i] = NULL; - } - - rval = isc_mempool_getfreecount(mp1); - if (rval != 10) { - t_info("isc_mempool_getfreecount returned %d, expected %d\n", - rval, MP1_FREEMAX); - ++nfails; - } - - rval = isc_mempool_getallocated(mp1); - if (rval != 19) { - t_info("isc_mempool_getallocated returned %d, expected %d\n", - rval, MP1_MAXALLOC - 11); - ++nfails; - } - - if (T_debug) - isc_mem_stats(mctx, stderr); - - /* - * Now, beat up on mp2 for a while. Allocate 50 items, then free - * them, then allocate 50 more, etc. - */ - - t_info("setting freemax to %d\n", MP2_FREEMAX); - isc_mempool_setfreemax(mp2, 25); - t_info("setting fillcount to %d\n", MP2_FILLCNT); - isc_mempool_setfillcount(mp2, 25); - - t_info("exercising the memory pool\n"); - for (j = 0; j < 500000; j++) { - for (i = 0; i < 50; i++) { - items2[i] = isc_mempool_get(mp2); - if (items2[i] == NULL) { - t_info("items2[%d] is unexpectedly null\n", i); - ++nfails; - } - } - for (i = 0; i < 50; i++) { - isc_mempool_put(mp2, items2[i]); - items2[i] = NULL; - } - if (j % 50000 == 0) - t_info("...\n"); - } - - /* - * Free all the other items and blow away this pool. - */ - for (i = 11; i < MP1_MAXALLOC; i++) { - isc_mempool_put(mp1, items1[i]); - items1[i] = NULL; - } - - isc_mempool_destroy(&mp1); - - if (T_debug) - isc_mem_stats(mctx, stderr); - - isc_mempool_destroy(&mp2); - - if (T_debug) - isc_mem_stats(mctx, stderr); - - isc_mem_destroy(&mctx); - - return(nfails); -} - -static const char *a1 = - "the memory module supports the creation of memory contexts " - "and the management of memory pools."; -static void -t1(void) { - int rval; - int result; - - t_assert("mem", 1, T_REQUIRED, "%s", a1); - - rval = memtest(); - - if (rval == 0) - result = T_PASS; - else - result = T_FAIL; - t_result(result); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "basic memory subsystem" }, - { (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/mem/win32/t_mem.vcxproj.filters.in b/bin/tests/mem/win32/t_mem.vcxproj.filters.in deleted file mode 100644 index fc1bf6f77d..0000000000 --- a/bin/tests/mem/win32/t_mem.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/mem/win32/t_mem.vcxproj.in b/bin/tests/mem/win32/t_mem.vcxproj.in deleted file mode 100644 index c4815f1228..0000000000 --- a/bin/tests/mem/win32/t_mem.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {627F32A9-267F-41CA-827C-1FD04DE20A56} - Win32Proj - t_mem - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/mem/win32/t_mem.vcxproj.user b/bin/tests/mem/win32/t_mem.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/mem/win32/t_mem.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/names/Makefile.in b/bin/tests/names/Makefile.in deleted file mode 100644 index 27fc124cdd..0000000000 --- a/bin/tests/names/Makefile.in +++ /dev/null @@ -1,50 +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} - -CDEFINES = -CWARNINGS = - -# Note that we do not want to use libtool for libt_api -DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -DNSDEPLIBS = ../../../lib/dns/libdns.@A@ -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_names@EXEEXT@ - -SRCS = t_names.c - -@BIND9_MAKE_RULES@ - -t_names@EXEEXT@: t_names.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_names.@O@ ${TLIB} ${LIBS} - -test: t_names@EXEEXT@ - -@./t_names@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @./t_names@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/names/dns_name_compare_data b/bin/tests/names/dns_name_compare_data deleted file mode 100644 index 0467fcfeb0..0000000000 --- a/bin/tests/names/dns_name_compare_data +++ /dev/null @@ -1,11 +0,0 @@ -# -# test data for dns_name_compare -# format: -# -# where: exp_order may be one of: -1, 0, 1 -# -# and where: exp_nlabels and exp_nbits are not tested if < 0 -# -c.d a.b.c.d -1 -a.b.c.d c.d 1 -a.b.c a.b.c 0 diff --git a/bin/tests/names/dns_name_countlabels_data b/bin/tests/names/dns_name_countlabels_data deleted file mode 100644 index f11c3873f4..0000000000 --- a/bin/tests/names/dns_name_countlabels_data +++ /dev/null @@ -1,10 +0,0 @@ -# -# test data for dns_name_countlabels -# format: -# -# -c.d 2 -c.d. 3 -a.b.c.d 4 -a.b.c 3 -. 1 diff --git a/bin/tests/names/dns_name_fromregion_data b/bin/tests/names/dns_name_fromregion_data deleted file mode 100644 index 32b4220483..0000000000 --- a/bin/tests/names/dns_name_fromregion_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_name_fromregion -# format: -# -# where: exp_order may be one of: -1, 0, 1 -# -# and where: exp_nlabels and exp_nbits are not tested if < 0 -# -a.b.c.d. -a.b.c.d.[A].[aaa. -Ba\x\aa.b.c\[\[o\\.Z -Ba\x\aa.b.c\[\[o\\\..\.Z diff --git a/bin/tests/names/dns_name_fromtext_data b/bin/tests/names/dns_name_fromtext_data deleted file mode 100644 index 16554a5a59..0000000000 --- a/bin/tests/names/dns_name_fromtext_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_name_fromtext -# format: -# -# -a.b a.b.c.d C.d 1 -a.b a.b.c.d C.d 1 -a.b a.b.C.d C.d 0 -a.b. a.b. C.d 0 diff --git a/bin/tests/names/dns_name_fromwire_1_data b/bin/tests/names/dns_name_fromwire_1_data deleted file mode 100644 index b7ae69bfd8..0000000000 --- a/bin/tests/names/dns_name_fromwire_1_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_1 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test1.data 25 1 DNS_COMPRESS_ALL vix.com. ISC_R_SUCCESS diff --git a/bin/tests/names/dns_name_fromwire_2_data b/bin/tests/names/dns_name_fromwire_2_data deleted file mode 100644 index 90dfec4e71..0000000000 --- a/bin/tests/names/dns_name_fromwire_2_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_2 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test2.data 25 1 DNS_COMPRESS_ALL vix.com. ISC_R_NOSPACE diff --git a/bin/tests/names/dns_name_fromwire_3_data b/bin/tests/names/dns_name_fromwire_3_data deleted file mode 100644 index f4253b475d..0000000000 --- a/bin/tests/names/dns_name_fromwire_3_data +++ /dev/null @@ -1,31 +0,0 @@ -# -# test data for dns_name_fromwire_3 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test3_1.data 25 1 DNS_COMPRESS_ALL vix.com. DNS_R_BADLABELTYPE -wire_test3_2.data 25 1 DNS_COMPRESS_ALL vix.com. DNS_R_BADLABELTYPE diff --git a/bin/tests/names/dns_name_fromwire_4_data b/bin/tests/names/dns_name_fromwire_4_data deleted file mode 100644 index b76b326dbc..0000000000 --- a/bin/tests/names/dns_name_fromwire_4_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_4 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test4.data 550 1 DNS_COMPRESS_ALL vix.com. DNS_R_NAMETOOLONG diff --git a/bin/tests/names/dns_name_fromwire_5_data b/bin/tests/names/dns_name_fromwire_5_data deleted file mode 100644 index 1a4221b648..0000000000 --- a/bin/tests/names/dns_name_fromwire_5_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_5 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test5.data 25 1 DNS_COMPRESS_NONE vix.com. DNS_R_DISALLOWED diff --git a/bin/tests/names/dns_name_fromwire_6_data b/bin/tests/names/dns_name_fromwire_6_data deleted file mode 100644 index e4460cea0c..0000000000 --- a/bin/tests/names/dns_name_fromwire_6_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_6 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test6.data 25 1 DNS_COMPRESS_ALL vix.com. DNS_R_BADPOINTER diff --git a/bin/tests/names/dns_name_fromwire_7_data b/bin/tests/names/dns_name_fromwire_7_data deleted file mode 100644 index 5828bfc884..0000000000 --- a/bin/tests/names/dns_name_fromwire_7_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_7 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test7.data 25 1 DNS_COMPRESS_ALL vix.com. ISC_R_UNEXPECTEDEND diff --git a/bin/tests/names/dns_name_fromwire_8_data b/bin/tests/names/dns_name_fromwire_8_data deleted file mode 100644 index 9ddd3f3da0..0000000000 --- a/bin/tests/names/dns_name_fromwire_8_data +++ /dev/null @@ -1,30 +0,0 @@ -# -# test data for dns_name_fromwire_9 -# format: -# -# -# -# where msgfile contains a DNS message in hex form -# -# and where testname_offset is the byte offset in this message of -# the start of a name -# -# and where downcase is 1 or 0 -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_name is the expected name after any decompression -# or case conversion -# -# and where exp_result may be one of -# ISC_R_NOSPACE -# DNS_R_BADLABELTYPE -# DNS_R_DISALLOWED -# DNS_R_BADPOINTER -# ISC_R_UNEXPECTEDEND -# DNS_R_TOOMANYHOPS -# -wire_test8.data 25 1 DNS_COMPRESS_ALL vix.com. ISC_R_NOSPACE diff --git a/bin/tests/names/dns_name_fullcompare_data b/bin/tests/names/dns_name_fullcompare_data deleted file mode 100644 index f40e7e6998..0000000000 --- a/bin/tests/names/dns_name_fullcompare_data +++ /dev/null @@ -1,10 +0,0 @@ -# -# test data for dns_name_fullcompare -# format: -# -# where: exp_reln may be one of: -# none, equal, contains, subdomain, commonancestor -# and where: exp_nlabels and exp_nbits are not tested if < 0 -# -c.d a.b.c.d contains -1 2 0 -a.b.c.d c.d subdomain 1 2 0 diff --git a/bin/tests/names/dns_name_getlabel_data b/bin/tests/names/dns_name_getlabel_data deleted file mode 100644 index d8dc880a09..0000000000 --- a/bin/tests/names/dns_name_getlabel_data +++ /dev/null @@ -1,10 +0,0 @@ -# -# test data for dns_name_compare -# format: -# -# where: label1_pos and label2_pos identify the label position of -# the common label shared by name1 and name2 respectively -# -c.d 1 a.b.c.d 3 -a.b.c.d 3 c.d 1 -a.b.c. 3 a.b.c. 3 diff --git a/bin/tests/names/dns_name_getlabelsequence_data b/bin/tests/names/dns_name_getlabelsequence_data deleted file mode 100644 index 339604afb0..0000000000 --- a/bin/tests/names/dns_name_getlabelsequence_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_name_getlabelsequence -# format: -# -# -# -c.d 1 a.b.c.d 3 1 -a.b.c.d.e 2 c.d 0 2 -a.b.c 0 a.b.c 0 3 diff --git a/bin/tests/names/dns_name_hash_data b/bin/tests/names/dns_name_hash_data deleted file mode 100644 index bf2fc79e4d..0000000000 --- a/bin/tests/names/dns_name_hash_data +++ /dev/null @@ -1,12 +0,0 @@ -# -# test data for dns_name_hash -# format: -# -# where: -# cshm is 0 if a case sensitive hash of testname1 should match a -# case sensitive hash of testname2, otherwise cshm != 0 -# and: -# cishm is 0 if a case insensitive hash of testname1 should match a -# case insensitive hash of testname2, otherwise cishm != 0 -# -a.b.c.d A.B.C.D 0 1 diff --git a/bin/tests/names/dns_name_isabsolute_data b/bin/tests/names/dns_name_isabsolute_data deleted file mode 100644 index a17c9b8a19..0000000000 --- a/bin/tests/names/dns_name_isabsolute_data +++ /dev/null @@ -1,8 +0,0 @@ -# -# test data for dns_name_isabsolute -# format is: -# -# -x. 1 -a.b.c.d 0 -x.z. 1 diff --git a/bin/tests/names/dns_name_issubdomain_data b/bin/tests/names/dns_name_issubdomain_data deleted file mode 100644 index 102b0721f3..0000000000 --- a/bin/tests/names/dns_name_issubdomain_data +++ /dev/null @@ -1,11 +0,0 @@ -# -# test data for dns_name_issubdomain -# format: -# -# where: issubdomain is 0 if false, else non-zero -# -# and where: exp_nlabels and exp_nbits are not tested if < 0 -# -c.d a.b.c.d 0 -a.b.c.d c.d 1 -a.b.c. a.b.c. 1 diff --git a/bin/tests/names/dns_name_rdatacompare_data b/bin/tests/names/dns_name_rdatacompare_data deleted file mode 100644 index 7f0c6a2109..0000000000 --- a/bin/tests/names/dns_name_rdatacompare_data +++ /dev/null @@ -1,11 +0,0 @@ -# -# test data for dns_name_rdatacompare -# format: -# -# where: exp_order may be one of: -1, 0, 1 -# -# and where: exp_nlabels and exp_nbits are not tested if < 0 -# -c.d. a.b.c.d. 1 -a.b.c.d. c.d. -1 -a.b.c. a.b.c. 0 diff --git a/bin/tests/names/dns_name_toregion_data b/bin/tests/names/dns_name_toregion_data deleted file mode 100644 index 00c10f49f9..0000000000 --- a/bin/tests/names/dns_name_toregion_data +++ /dev/null @@ -1,8 +0,0 @@ -# -# test data for dns_name_toregion -# format: -# -# -a.b.c.d. -a.b.c.d.[A].[aaa. -Ba\x\aa.b.c\[\[o\\.Z diff --git a/bin/tests/names/dns_name_totext_data b/bin/tests/names/dns_name_totext_data deleted file mode 100644 index 9db22aad1e..0000000000 --- a/bin/tests/names/dns_name_totext_data +++ /dev/null @@ -1,9 +0,0 @@ -# -# test data for dns_name_totext -# format: -# -# -a.b.c.d 1 -a.\\[\[.c.d 1 -a.b.C.d 0 -a.b. 0 diff --git a/bin/tests/names/dns_name_towire_1_data b/bin/tests/names/dns_name_towire_1_data deleted file mode 100644 index a45d80a69f..0000000000 --- a/bin/tests/names/dns_name_towire_1_data +++ /dev/null @@ -1,17 +0,0 @@ -# test data for dns_name_towire_1 -# format: -# -# -# -# where testname is the test name to be converted to wire format -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_data is the expected wire format data in hex format -# and where exp_data_len is the length of the expected data in decimal format -# and where exp_result is the expected return value of dns_name_towire -# -a.vix.com. DNS_COMPRESS_NONE 01610376697803636f6d00 11 ISC_R_SUCCESS diff --git a/bin/tests/names/dns_name_towire_2_data b/bin/tests/names/dns_name_towire_2_data deleted file mode 100644 index 35479bea10..0000000000 --- a/bin/tests/names/dns_name_towire_2_data +++ /dev/null @@ -1,17 +0,0 @@ -# test data for dns_name_towire_1 -# format: -# -# -# -# where testname is the test name to be converted to wire format -# -# and where dc_method is one of -# DNS_COMPRESS_ALL -# DNS_COMPRESS_GLOBAL14 -# DNS_COMPRESS_NONE -# -# and where exp_data is the expected wire format data in hex format -# and where exp_data_len is the length of the expected data in decimal format -# and where exp_result is the expected return value of dns_name_towire -# -a.vix.com DNS_COMPRESS_NONE 01610376697803636f6d 10 ISC_R_NOSPACE diff --git a/bin/tests/names/t_names.c b/bin/tests/names/t_names.c deleted file mode 100644 index 59e396b36f..0000000000 --- a/bin/tests/names/t_names.c +++ /dev/null @@ -1,2379 +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_names.c,v 1.52 2011/03/12 04:59:46 tbox Exp $ */ - -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#define MAXTOKS 16 -#define BUFLEN 256 -#define BIGBUFLEN 4096 - -static char *Tokens[MAXTOKS + 1]; - - -#ifdef NEED_PBUF - -/*% - * get a hex formatted dns message from a data - * file into an isc_buffer_t - * caller supplies data storage and the isc_buffer - * we read the file, convert, setup the buffer - * and return the data length - */ - -static char * -ctoh(unsigned char c) { - int val; - static char buf[3]; - - val = (c >> 4) & 0x0f; - if ((0 <= val) && (val <= 9)) - buf[0] = '0' + val; - else if ((10 <= val) && (val <= 16)) - buf[0] = 'a' + val - 10; - val = c & 0x0f; - if ((0 <= val) && (val <= 9)) - buf[1] = '0' + val; - else if ((10 <= val) && (val <= 16)) - buf[1] = 'a' + val - 10; - buf[2] = '\0'; - return (buf); -} - -static void -pbuf(isc_buffer_t *pbuf) { - size_t len; - unsigned char *p; - - len = 0; - p = pbuf->base; - while (len < pbuf->length) { - printf("%s", ctoh(*p)); - ++p; - ++len; - if ((len % 40) == 0) - printf("\n"); - } -} - -#endif /* NEED_PBUF */ - -/*% - * Compare data at buf with data in hex representation at exp_data, - * of length exp_data_len, for equality. - * Return 0 if equal, else non-zero. - */ - -static int -chkdata(unsigned char *buf, size_t buflen, char *exp_data, - size_t exp_data_len) -{ - int result; - unsigned char *p; - unsigned char *v; - char *q; - unsigned char *data; - size_t cnt; - - if (buflen == exp_data_len) { - data = (unsigned char *)malloc(exp_data_len * - sizeof(unsigned char)); - if (data == NULL) { - t_info("malloc failed unexpectedly\n"); - return (-1); - } - - /* - * First convert exp_data from hex format. - */ - p = data; - q = exp_data; - cnt = 0; - while (cnt < exp_data_len) { - - if (('0' <= *q) && (*q <= '9')) - *p = *q - '0'; - else if (('a' <= *q) && (*q <= 'f')) - *p = *q - 'a' + 10; - else if (('A' <= *q) && (*q <= 'F')) - *p = *q - 'A' + 10; - else { - t_info("malformed comparison data\n"); - free(data); - return (-1); - } - ++q; - - *p <<= 4; - - if (('0' <= *q) && (*q <= '9')) - *p |= ((*q - '0') & 0x0f); - else if (('a' <= *q) && (*q <= 'f')) - *p |= ((*q - 'a' + 10) & 0x0f); - else if (('A' <= *q) && (*q <= 'F')) - *p |= ((*q - 'A' + 10) & 0x0f); - else { - t_info("malformed comparison data\n"); - free(data); - return (-1); - } - ++p; - ++q; - ++cnt; - } - - /* - * Now compare data. - */ - p = buf; - v = data; - for (cnt = 0; cnt < exp_data_len; ++cnt) { - if (*p != *v) - break; - ++p; - ++v; - } - if (cnt == exp_data_len) - result = 0; - else { - t_info("bad data at position %lu, " - "got 0x%.2x, expected 0x%.2x\n", - (unsigned long)cnt, *p, *v); - result = (int)cnt + 1; - } - (void)free(data); - } else { - t_info("data length error, expected %lu, got %lu\n", - (unsigned long)exp_data_len, (unsigned long)buflen); - result = (int)(exp_data_len - buflen); - } - return (result); -} - -/*% - * Get a hex formatted dns message from a data file into an isc_buffer_t. - * Caller supplies data storage and the isc_buffer. We read the file, convert, - * setup the buffer and return the data length. - */ -static int -getmsg(char *datafile_name, isc_buffer_t *pbuf) -{ - int c; - unsigned int len; - unsigned int cnt; - unsigned char *p; - FILE *fp; - unsigned int buflen; - - fp = fopen(datafile_name, "r"); - if (fp == NULL) { - t_info("No such file %s\n", datafile_name); - return (0); - } - - p = isc_buffer_used(pbuf); - buflen = isc_buffer_availablelength(pbuf); - cnt = 0; - len = 0; - while ((c = getc(fp)) != EOF) { - unsigned int val; - if ( (c == ' ') || (c == '\t') || - (c == '\r') || (c == '\n')) - continue; - if (c == '#') { - while ((c = getc(fp)) != '\n') - ; - continue; - } - if (('0' <= c) && (c <= '9')) - val = c - '0'; - else if (('a' <= c) && (c <= 'f')) - val = c - 'a' + 10; - else if (('A' <= c) && (c <= 'F')) - val = c - 'A'+ 10; - else { - (void)fclose(fp); - t_info("Bad format in datafile\n"); - return (0); - } - if ((len % 2) == 0) { - *p = (val << 4); - } else { - *p += val; - ++p; - ++cnt; - if (cnt >= buflen) { - /* - * Buffer too small. - */ - (void)fclose(fp); - t_info("Buffer overflow error\n"); - return (0); - } - } - ++len; - } - (void)fclose(fp); - - if (len % 2) { - t_info("Bad format in %s\n", datafile_name); - return (0); - } - - *p = '\0'; - isc_buffer_add(pbuf, cnt); - return (cnt); -} - -static int -bustline(char *line, char **toks) { - int cnt; - char *p; - - cnt = 0; - if (line && *line) { - while ((p = strtok(line, "\t")) && (cnt < MAXTOKS)) { - *toks++ = p; - line = NULL; - ++cnt; - } - } - return (cnt); -} - - -#ifdef NEED_HNAME_TO_TNAME - -/*% - * convert a name from hex representation to text form - * format of hex notation is: - * %xXXXXXXXX - */ - -static int -hname_to_tname(char *src, char *target, size_t len) { - int i; - int c; - unsigned int val; - size_t srclen; - char *p; - char *q; - - p = src; - srclen = strlen(p); - if ((srclen >= 2) && ((*p != '%') || (*(p+1) != 'x'))) { - /* - * No conversion needed. - */ - if (srclen >= len) - return (1); - memmove(target, src, srclen + 1); - return (0); - } - - i = 0; - p += 2; - q = target; - while (*p) { - c = *p; - if (('0' < c) && (c <= '9')) - val = c - '0'; - else if (('a' <= c) && (c <= 'z')) - val = c + 10 - 'a'; - else if (('A' <= c) && (c <= 'Z')) - val = c + 10 - 'A'; - else { - return (1); - } - if (i % 2) { - *q |= val; - ++q; - } else - *q = (val << 4); - ++i; - ++p; - } - if (i % 2) { - return (1); - } else { - *q = '\0'; - return (0); - } -} - -#endif /* NEED_HNAME_TO_TNAME */ - -static const char *a3 = "dns_name_init initializes 'name' to the empty name"; - -static void -t_dns_name_init(void) { - int rval; - int result; - dns_name_t name; - unsigned char offsets[1]; - - rval = 0; - t_assert("dns_name_init", 1, T_REQUIRED, "%s", a3); - - dns_name_init(&name, offsets); - /* magic is hidden in name.c ... - if (name.magic != NAME_MAGIC) { - t_info("name.magic is not set to NAME_MAGIC\n"); - ++rval; - } - */ - if (name.ndata != NULL) { - t_info("name.ndata is not NULL\n"); - ++rval; - } - if (name.length != 0) { - t_info("name.length is not 0\n"); - ++rval; - } - if (name.labels != 0) { - t_info("name.labels is not 0\n"); - ++rval; - } - if (name.attributes != 0) { - t_info("name.attributes is not 0\n"); - ++rval; - } - if (name.offsets != offsets) { - t_info("name.offsets is incorrect\n"); - ++rval; - } - if (name.buffer != NULL) { - t_info("name.buffer is not NULL\n"); - ++rval; - } - - if (rval == 0) - result = T_PASS; - else - result = T_FAIL; - t_result(result); -} - -static const char *a4 = "dns_name_invalidate invalidates 'name'"; - -static void -t_dns_name_invalidate(void) { - int rval; - int result; - dns_name_t name; - unsigned char offsets[1]; - - t_assert("dns_name_invalidate", 1, T_REQUIRED, "%s", a4); - - rval = 0; - dns_name_init(&name, offsets); - dns_name_invalidate(&name); - - /* magic is hidden in name.c ... - if (name.magic != 0) { - t_info("name.magic is not set to NAME_MAGIC\n"); - ++rval; - } - */ - if (name.ndata != NULL) { - t_info("name.ndata is not NULL\n"); - ++rval; - } - if (name.length != 0) { - t_info("name.length is not 0\n"); - ++rval; - } - if (name.labels != 0) { - t_info("name.labels is not 0\n"); - ++rval; - } - if (name.attributes != 0) { - t_info("name.attributes is not 0\n"); - ++rval; - } - if (name.offsets != NULL) { - t_info("name.offsets is not NULL\n"); - ++rval; - } - if (name.buffer != NULL) { - t_info("name.buffer is not NULL\n"); - ++rval; - } - - if (rval == 0) - result = T_PASS; - else - result = T_FAIL; - t_result(result); -} - -static const char *a5 = "dns_name_setbuffer dedicates a buffer for use " - "with 'name'"; - -static void -t_dns_name_setbuffer(void) { - int result; - unsigned char junk[BUFLEN]; - dns_name_t name; - isc_buffer_t buffer; - - t_assert("dns_name_setbuffer", 1, T_REQUIRED, "%s", a5); - - isc_buffer_init(&buffer, junk, BUFLEN); - dns_name_init(&name, NULL); - dns_name_setbuffer(&name, &buffer); - if (name.buffer == &buffer) - result = T_PASS; - else - result = T_FAIL; - - t_result(result); -} - -static const char *a6 = "dns_name_hasbuffer returns ISC_TRUE if 'name' has a " - "dedicated buffer, otherwise it returns ISC_FALSE"; - -static void -t_dns_name_hasbuffer(void) { - int result; - int rval; - unsigned char junk[BUFLEN]; - dns_name_t name; - isc_buffer_t buffer; - - t_assert("dns_name_hasbuffer", 1, T_REQUIRED, "%s", a6); - - rval = 0; - isc_buffer_init(&buffer, junk, BUFLEN); - dns_name_init(&name, NULL); - if (dns_name_hasbuffer(&name) != ISC_FALSE) - ++rval; - dns_name_setbuffer(&name, &buffer); - if (dns_name_hasbuffer(&name) != ISC_TRUE) - ++rval; - if (rval == 0) - result = T_PASS; - else - result = T_FAIL; - - t_result(result); -} - -static const char *a7 = "dns_name_isabsolute returns ISC_TRUE if 'name' ends " - "in the root label"; - -static int -test_dns_name_isabsolute(char *test_name, isc_boolean_t expected) { - dns_name_t name; - isc_buffer_t buf; - isc_buffer_t binbuf; - unsigned char junk[BUFLEN]; - int len; - int rval; - isc_boolean_t isabs_p; - isc_result_t result; - - rval = T_UNRESOLVED; - - t_info("testing name %s\n", test_name); - len = strlen(test_name); - isc_buffer_init(&buf, test_name, len); - isc_buffer_add(&buf, len); - isc_buffer_init(&binbuf, &junk[0], BUFLEN); - dns_name_init(&name, NULL); - dns_name_setbuffer(&name, &binbuf); - result = dns_name_fromtext(&name, &buf, NULL, 0, NULL); - if (result == ISC_R_SUCCESS) { - isabs_p = dns_name_isabsolute(&name); - if (isabs_p == expected) - rval = T_PASS; - else - rval = T_FAIL; - } else { - t_info("dns_name_fromtext %s failed, result = %s\n", - test_name, dns_result_totext(result)); - } - return (rval); -} - -static void -t_dns_name_isabsolute(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_isabsolute", 1, T_REQUIRED, "%s", a7); - - result = T_UNRESOLVED; - fp = fopen("dns_name_isabsolute_data", "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 = bustline(p, Tokens); - if (cnt == 2) { - /* - * label, bitpos, expected value. - */ - result = test_dns_name_isabsolute(Tokens[0], - atoi(Tokens[1]) - == 0 ? - ISC_FALSE : - ISC_TRUE); - } else { - t_info("bad datafile format at line %d\n", - line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_isabsolute_data\n"); - t_result(result); - } -} - -static const char *a8 = "dns_name_hash(name, case_sensitive) returns " - "a hash of 'name' which is case_sensitive if case_sensitive " - "is true"; - -/*% - * a9 merged with a8. - */ - -static int -test_dns_name_hash(char *test_name1, char *test_name2, - isc_boolean_t csh_match, isc_boolean_t cish_match) { - int rval; - int failures; - isc_boolean_t match; - unsigned int hash1; - unsigned int hash2; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - isc_result_t result; - - rval = T_UNRESOLVED; - failures = 0; - - t_info("testing names %s and %s\n", test_name1, test_name2); - - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - result = dns_name_fromstring2(dns_name1, test_name1, NULL, 0, NULL); - if (result == ISC_R_SUCCESS) { - result = dns_name_fromstring2(dns_name2, test_name2, NULL, - 0, NULL); - if (result == ISC_R_SUCCESS) { - hash1 = dns_name_hash(dns_name1, ISC_TRUE); - hash2 = dns_name_hash(dns_name2, ISC_TRUE); - match = ISC_FALSE; - if (hash1 == hash2) - match = ISC_TRUE; - if (match != csh_match) { - ++failures; - t_info("hash mismatch when ISC_TRUE\n"); - } - hash1 = dns_name_hash(dns_name1, ISC_FALSE); - hash2 = dns_name_hash(dns_name2, ISC_FALSE); - match = ISC_FALSE; - if (hash1 == hash2) - match = ISC_TRUE; - if (match != cish_match) { - ++failures; - t_info("hash mismatch when ISC_FALSE\n"); - } - if (failures == 0) - rval = T_PASS; - else - rval = T_FAIL; - } else { - t_info("dns_name_fromstring2 %s failed, result = %s\n", - test_name2, dns_result_totext(result)); - } - } else { - t_info("dns_name_fromstring2 %s failed, result = %s\n", - test_name1, dns_result_totext(result)); - } - return (rval); -} - -static void -t_dns_name_hash(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_hash", 1, T_REQUIRED, "%s", a8); - - result = T_UNRESOLVED; - fp = fopen("dns_name_hash_data", "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 = bustline(p, Tokens); - if (cnt == 4) { - /* - * name1, name2, exp match value if - * case_sensitive true, - * exp match value of case_sensitive false - */ - result = test_dns_name_hash( - Tokens[0], - Tokens[1], - atoi(Tokens[2]) == 0 ? - ISC_FALSE : ISC_TRUE, - atoi(Tokens[3]) == 0 ? - ISC_FALSE : ISC_TRUE); - } else { - t_info("bad datafile format at line %d\n", - line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_hash_data\n"); - t_result(result); - } -} - -static const char *a10 = - "dns_name_fullcompare(name1, name2, orderp, nlabelsp) " - "returns the DNSSEC ordering relationship between name1 and " - "name2, sets orderp to -1 if name1 < name2, to 0 if " - "name1 == name2, or to 1 if name1 > name2, sets nlabelsp " - "to the number of labels name1 and name2 have in common, " - "and sets nbitsp to the number of bits name1 and name2 " - "have in common"; - -/*% - * a11 thru a22 merged into a10. - */ -static const char * -dns_namereln_to_text(dns_namereln_t reln) { - const char *p; - - if (reln == dns_namereln_contains) - p = "contains"; - else if (reln == dns_namereln_subdomain) - p = "subdomain"; - else if (reln == dns_namereln_equal) - p = "equal"; - else if (reln == dns_namereln_none) - p = "none"; - else if (reln == dns_namereln_commonancestor) - p = "commonancestor"; - else - p = "unknown"; - - return (p); -} - -static int -test_dns_name_fullcompare(char *name1, char *name2, - dns_namereln_t exp_dns_reln, - int exp_order, int exp_nlabels) -{ - int result; - int nfails; - int order; - unsigned int nlabels; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - isc_result_t dns_result; - dns_namereln_t dns_reln; - - nfails = 0; - result = T_UNRESOLVED; - - - t_info("testing names %s and %s for relation %s\n", name1, name2, - dns_namereln_to_text(exp_dns_reln)); - - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_result = dns_name_fromstring2(dns_name2, name2, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_reln = dns_name_fullcompare(dns_name1, dns_name2, - &order, &nlabels); - - if (dns_reln != exp_dns_reln) { - ++nfails; - t_info("expected relationship of %s, got %s\n", - dns_namereln_to_text(exp_dns_reln), - dns_namereln_to_text(dns_reln)); - } - /* - * Normalize order. - */ - if (order < 0) - order = -1; - else if (order > 0) - order = 1; - if (order != exp_order) { - ++nfails; - t_info("expected ordering %d, got %d\n", - exp_order, order); - } - if ((exp_nlabels >= 0) && - (nlabels != (unsigned int)exp_nlabels)) { - ++nfails; - t_info("expecting %d labels, got %d\n", - exp_nlabels, nlabels); - } - if (nfails == 0) - result = T_PASS; - else - result = T_FAIL; - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - - return (result); -} - -static void -t_dns_name_fullcompare(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - dns_namereln_t reln; - - t_assert("dns_name_fullcompare", 1, T_REQUIRED, "%s", a10); - - result = T_UNRESOLVED; - fp = fopen("dns_name_fullcompare_data", "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 = bustline(p, Tokens); - if (cnt == 6) { - /* - * name1, name2, exp_reln, exp_order, - * exp_nlabels - */ - if (!strcmp(Tokens[2], "none")) - reln = dns_namereln_none; - else if (!strcmp(Tokens[2], "contains")) - reln = dns_namereln_contains; - else if (!strcmp(Tokens[2], "subdomain")) - reln = dns_namereln_subdomain; - else if (!strcmp(Tokens[2], "equal")) - reln = dns_namereln_equal; - else if (!strcmp(Tokens[2], "commonancestor")) - reln = dns_namereln_commonancestor; - else { - t_info("bad format at line %d\n", line); - (void)free(p); - continue; - } - result = test_dns_name_fullcompare( - Tokens[0], - Tokens[1], - reln, - atoi(Tokens[3]), - atoi(Tokens[4])); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_fullcompare_data\n"); - t_result(result); - } -} - -static const char *a23 = - "dns_name_compare(name1, name2) returns information about " - "the relative ordering under the DNSSEC ordering relationship " - "of name1 and name2"; - -/*% - * a24 thru a29 merged into a23. - */ - -static int -test_dns_name_compare(char *name1, char *name2, int exp_order) { - int result; - int order; - isc_result_t dns_result; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - - result = T_UNRESOLVED; - - t_info("testing %s %s %s\n", name1, - exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), - name2); - - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_result = dns_name_fromstring2(dns_name2, name2, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - order = dns_name_compare(dns_name1, dns_name2); - /* - * Normalize order. - */ - if (order < 0) - order = -1; - else if (order > 0) - order = 1; - if (order != exp_order) { - t_info("expected order of %d, got %d\n", - exp_order, order); - result = T_FAIL; - } else - result = T_PASS; - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - - return (result); -} - -static void -t_dns_name_compare(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_compare", 1, T_REQUIRED, "%s", a23); - - result = T_UNRESOLVED; - fp = fopen("dns_name_compare_data", "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 = bustline(p, Tokens); - if (cnt == 3) { - /* - * name1, name2, order. - */ - result = test_dns_name_compare( - Tokens[0], - Tokens[1], - atoi(Tokens[2])); - } else { - t_info("bad datafile format at line %d\n", - line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_compare_data\n"); - t_result(result); - } -} - -static const char *a30 = - "dns_name_rdatacompare(name1, name2) returns information " - "about the relative ordering of name1 and name2 as if they " - "are part of rdata in DNSSEC canonical form"; - -/*% - * a31, a32 merged into a30. - */ - -static int -test_dns_name_rdatacompare(char *name1, char *name2, int exp_order) { - int result; - int order; - isc_result_t dns_result; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - - result = T_UNRESOLVED; - - t_info("testing %s %s %s\n", name1, - exp_order == 0 ? "==": (exp_order == -1 ? "<" : ">"), name2); - - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_result = dns_name_fromstring2(dns_name2, name2, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - order = dns_name_rdatacompare(dns_name1, dns_name2); - /* - * Normalize order. - */ - if (order < 0) - order = -1; - else if (order > 0) - order = 1; - if (order != exp_order) { - t_info("expected order of %d, got %d\n", - exp_order, order); - result = T_FAIL; - } else - result = T_PASS; - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - - return (result); -} - -static void -t_dns_name_rdatacompare(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_rdatacompare", 1, T_REQUIRED, "%s", a30); - - result = T_UNRESOLVED; - fp = fopen("dns_name_rdatacompare_data", "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 = bustline(p, Tokens); - if (cnt == 3) { - /* - * name1, name2, order. - */ - result = test_dns_name_rdatacompare( - Tokens[0], - Tokens[1], - atoi(Tokens[2])); - } else { - t_info("bad datafile format at line %d\n", - line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_rdatacompare_data\n"); - t_result(result); - } -} - - -static const char *a33 = - "when name1 is a subdomain of name2, " - "dns_name_issubdomain(name1, name2) returns true, " - "otherwise it returns false."; - -/*% - * a34 merged into a33. - */ - -static int -test_dns_name_issubdomain(char *name1, char *name2, isc_boolean_t exp_rval) { - int result; - isc_boolean_t rval; - isc_result_t dns_result; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - - result = T_UNRESOLVED; - - t_info("testing %s %s a subdomain of %s\n", name1, - exp_rval == 0 ? "is not" : "is", name2); - - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name1, name1, NULL, 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_result = dns_name_fromstring2(dns_name2, name2, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - rval = dns_name_issubdomain(dns_name1, dns_name2); - - if (rval != exp_rval) { - t_info("expected return value of %s, got %s\n", - exp_rval == ISC_TRUE ? "true" : "false", - rval == ISC_TRUE ? "true" : "false"); - result = T_FAIL; - } else - result = T_PASS; - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - - return (result); -} - -static void -t_dns_name_issubdomain(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_issubdomain", 1, T_REQUIRED, "%s", a33); - - result = T_UNRESOLVED; - fp = fopen("dns_name_issubdomain_data", "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 = bustline(p, Tokens); - if (cnt == 3) { - /* - * name1, name2, issubdomain_p. - */ - result = test_dns_name_issubdomain( - Tokens[0], - Tokens[1], - atoi(Tokens[2]) == 0 ? - ISC_FALSE : ISC_TRUE); - } else { - t_info("bad datafile format at line %d\n", - line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_issubdomain_data\n"); - t_result(result); - } -} - -static const char *a35 = - "dns_name_countlabels(name) returns the number " - "of labels in name"; - -static int -test_dns_name_countlabels(char *test_name, unsigned int exp_nlabels) { - int result; - unsigned int nlabels; - isc_result_t dns_result; - dns_fixedname_t fixed; - dns_name_t *dns_name; - - result = T_UNRESOLVED; - - t_info("testing %s\n", test_name); - - dns_fixedname_init(&fixed); - dns_name = dns_fixedname_name(&fixed); - dns_result = dns_name_fromstring2(dns_name, test_name, NULL, 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - nlabels = dns_name_countlabels(dns_name); - - if (nlabels != exp_nlabels) { - t_info("expected %d, got %d\n", exp_nlabels, nlabels); - result = T_FAIL; - } else - result = T_PASS; - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(dns_result)); - } - - return (result); -} - -static void -t_dns_name_countlabels(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_countlabels", 1, T_REQUIRED, "%s", a35); - - result = T_UNRESOLVED; - fp = fopen("dns_name_countlabels_data", "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 = bustline(p, Tokens); - if (cnt == 2) { - /* - * name, nlabels. - */ - result = test_dns_name_countlabels(Tokens[0], - atoi(Tokens[1])); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_countlabels_data\n"); - t_result(result); - } -} - -static const char *a36 = - "when n is less than the number of labels in name, " - "dns_name_getlabel(name, n, labelp) initializes labelp " - "to point to the nth label in name"; - -/*% - * The strategy here is two take two dns names with a shared label in - * different positions, get the two labels and compare them for equality. - * If they don't match, dns_name_getlabel failed. - */ - -static int -test_dns_name_getlabel(char *test_name1, int label1_pos, char *test_name2, - int label2_pos) -{ - int result; - int nfails; - unsigned int cnt; - unsigned char *p; - unsigned char *q; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - dns_label_t dns_label1; - dns_label_t dns_label2; - isc_result_t dns_result; - - nfails = 0; - result = T_UNRESOLVED; - - t_info("testing with %s and %s\n", test_name1, test_name2); - - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name1, test_name1, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_result = dns_name_fromstring2(dns_name2, test_name2, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_name_getlabel(dns_name1, label1_pos, &dns_label1); - dns_name_getlabel(dns_name2, label2_pos, &dns_label2); - if (dns_label1.length != dns_label2.length) { - t_info("label lengths differ\n"); - ++nfails; - } - p = dns_label1.base; - q = dns_label2.base; - for (cnt = 0; cnt < dns_label1.length; ++cnt) { - if (*p++ != *q++) { - t_info("labels differ at position %d", - cnt); - ++nfails; - } - } - if (nfails == 0) - result = T_PASS; - else - result = T_FAIL; - } else { - t_info("dns_name_fromstring2 failed, result == %s", - dns_result_totext(result)); - } - } else { - t_info("dns_name_fromstring2 failed, result == %s", - dns_result_totext(result)); - } - return (result); -} - -static void -t_dns_name_getlabel(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_getlabel", 1, T_REQUIRED, "%s", a36); - - result = T_UNRESOLVED; - fp = fopen("dns_name_getlabel_data", "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 = bustline(p, Tokens); - if (cnt == 4) { - /* - * name1, name2, nlabels. - */ - result = test_dns_name_getlabel(Tokens[0], - atoi(Tokens[1]), - Tokens[2], - atoi(Tokens[3])); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_getlabel_data\n"); - t_result(result); - } -} - -static const char *a37 = - "when source contains at least first + n labels, " - "dns_name_getlabelsequence(source, first, n, target) " - "initializes target to point to the n label sequence of " - "labels in source starting with first"; - -/*% - * We adopt a similiar strategy to that used by the dns_name_getlabel test. - */ - -static int -test_dns_name_getlabelsequence(char *test_name1, int label1_start, - char *test_name2, int label2_start, int range) -{ - int result; - int nfails; - unsigned int cnt; - unsigned char *p; - unsigned char *q; - dns_fixedname_t fixed1; - dns_fixedname_t fixed2; - dns_name_t *dns_name1; - dns_name_t *dns_name2; - dns_name_t dns_targetname1; - dns_name_t dns_targetname2; - isc_result_t dns_result; - isc_buffer_t buffer1; - isc_buffer_t buffer2; - unsigned char junk1[BUFLEN]; - unsigned char junk2[BUFLEN]; - - nfails = 0; - result = T_UNRESOLVED; - dns_fixedname_init(&fixed1); - dns_fixedname_init(&fixed2); - dns_name1 = dns_fixedname_name(&fixed1); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name1, test_name1, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_result = dns_name_fromstring2(dns_name2, test_name2, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - t_info("testing %s %s\n", test_name1, test_name2); - dns_name_init(&dns_targetname1, NULL); - dns_name_init(&dns_targetname2, NULL); - dns_name_getlabelsequence(dns_name1, label1_start, - range, &dns_targetname1); - dns_name_getlabelsequence(dns_name2, label2_start, - range, &dns_targetname2); - - /* - * Now convert both targets to text for comparison. - */ - isc_buffer_init(&buffer1, junk1, BUFLEN); - isc_buffer_init(&buffer2, junk2, BUFLEN); - dns_name_totext(&dns_targetname1, ISC_TRUE, &buffer1); - dns_name_totext(&dns_targetname2, ISC_TRUE, &buffer2); - if (buffer1.used == buffer2.used) { - p = buffer1.base; - q = buffer2.base; - for (cnt = 0; cnt < buffer1.used; ++cnt) { - if (*p != *q) { - ++nfails; - t_info("names differ at %d\n", - cnt); - break; - } - ++p; ++q; - } - } else { - ++nfails; - t_info("lengths differ\n"); - } - if (nfails == 0) - result = T_PASS; - else - result = T_FAIL; - } else { - t_info("dns_name_fromstring2 failed, result == %s", - dns_result_totext(dns_result)); - } - } else { - t_info("dns_name_fromstring2 failed, result == %s", - dns_result_totext(dns_result)); - } - return (result); -} - -static void -t_dns_name_getlabelsequence(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_getlabelsequence", 1, T_REQUIRED, "%s", a37); - - result = T_UNRESOLVED; - fp = fopen("dns_name_getlabelsequence_data", "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 = bustline(p, Tokens); - if (cnt == 5) { - /* - * name1, name2, nlabels. - */ - result = test_dns_name_getlabelsequence( - Tokens[0], - atoi(Tokens[1]), - Tokens[2], - atoi(Tokens[3]), - atoi(Tokens[4])); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_getlabelsequence_data\n"); - t_result(result); - } -} - -static const char *a38 = - "dns_name_fromregion(name, region) converts a DNS name " - "from a region representation to a name representation"; - -static int -test_dns_name_fromregion(char *test_name) { - int result; - int order; - unsigned int nlabels; - isc_result_t dns_result; - dns_fixedname_t fixed1; - dns_name_t *dns_name1; - dns_name_t dns_name2; - dns_namereln_t dns_namereln; - isc_region_t region; - - result = T_UNRESOLVED; - - t_info("testing %s\n", test_name); - - dns_fixedname_init(&fixed1); - dns_name1 = dns_fixedname_name(&fixed1); - dns_result = dns_name_fromstring2(dns_name1, test_name, NULL, 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - - dns_name_toregion(dns_name1, ®ion); - - dns_name_init(&dns_name2, NULL); - dns_name_fromregion(&dns_name2, ®ion); - dns_namereln = dns_name_fullcompare(dns_name1, &dns_name2, - &order, &nlabels); - if (dns_namereln == dns_namereln_equal) - result = T_PASS; - else - result = T_FAIL; - } else { - t_info("dns_name_fromstring2 failed, result == %s\n", - dns_result_totext(result)); - } - return (result); -} - -static void -t_dns_name_fromregion(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_fromregion", 1, T_REQUIRED, "%s", a38); - - result = T_UNRESOLVED; - fp = fopen("dns_name_fromregion_data", "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 = bustline(p, Tokens); - if (cnt == 1) { - /* - * test_name. - */ - result = test_dns_name_fromregion(Tokens[0]); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_fromregion_data\n"); - t_result(result); - } -} - -static const char *a39 = - "dns_name_toregion(name, region) converts a DNS name " - "from a region representation to a name representation"; - -static void -t_dns_name_toregion(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_toregion", 1, T_REQUIRED, "%s", a39); - - result = T_UNRESOLVED; - fp = fopen("dns_name_toregion_data", "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 = bustline(p, Tokens); - if (cnt == 1) { - /* - * test_name. - */ - result = test_dns_name_fromregion(Tokens[0]); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_toregion_data\n"); - t_result(result); - } -} - -static const char *a40 = - "dns_name_fromtext(name, source, origin, downcase, target) " - "converts the textual representation of a DNS name at source " - "into uncompressed wire form at target, appending origin to " - "the converted name if origin is non-NULL and converting " - "upper case to lower case during conversion " - "if downcase is true."; - -static int -test_dns_name_fromtext(char *test_name1, char *test_name2, char *test_origin, - unsigned int downcase) -{ - int result; - int order; - unsigned int nlabels; - unsigned char junk1[BUFLEN]; - unsigned char junk2[BUFLEN]; - unsigned char junk3[BUFLEN]; - isc_buffer_t binbuf1; - isc_buffer_t binbuf2; - isc_buffer_t binbuf3; - isc_buffer_t txtbuf1; - isc_buffer_t txtbuf2; - isc_buffer_t txtbuf3; - dns_name_t dns_name1; - dns_name_t dns_name2; - dns_name_t dns_name3; - isc_result_t dns_result; - dns_namereln_t dns_namereln; - - t_info("testing %s %s %s\n", test_name1, test_name2, test_origin); - - isc_buffer_init(&binbuf1, junk1, BUFLEN); - isc_buffer_init(&binbuf2, junk2, BUFLEN); - isc_buffer_init(&binbuf3, junk3, BUFLEN); - - isc_buffer_init(&txtbuf1, test_name1, strlen(test_name1)); - isc_buffer_add(&txtbuf1, strlen(test_name1)); - - isc_buffer_init(&txtbuf2, test_name2, strlen(test_name2)); - isc_buffer_add(&txtbuf2, strlen(test_name2)); - - isc_buffer_init(&txtbuf3, test_origin, strlen(test_origin)); - isc_buffer_add(&txtbuf3, strlen(test_origin)); - dns_name_init(&dns_name1, NULL); - dns_name_init(&dns_name2, NULL); - dns_name_init(&dns_name3, NULL); - dns_name_setbuffer(&dns_name1, &binbuf1); - dns_name_setbuffer(&dns_name2, &binbuf2); - dns_name_setbuffer(&dns_name3, &binbuf3); - - dns_result = dns_name_fromtext(&dns_name3, &txtbuf3, NULL, 0, - &binbuf3); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext(dns_name3) failed, result == %s\n", - dns_result_totext(dns_result)); - return (T_FAIL); - } - - dns_result = dns_name_fromtext(&dns_name1, &txtbuf1, &dns_name3, - downcase, &binbuf1); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext(dns_name1) failed, result == %s\n", - dns_result_totext(dns_result)); - return (T_FAIL); - } - - dns_result = dns_name_fromtext(&dns_name2, &txtbuf2, NULL, 0, - &binbuf2); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext(dns_name2) failed, result == %s\n", - dns_result_totext(dns_result)); - return (T_FAIL); - } - - dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, &order, - &nlabels); - - if (dns_namereln == dns_namereln_equal) - result = T_PASS; - else { - t_info("dns_name_fullcompare returned %s\n", - dns_namereln_to_text(dns_namereln)); - result = T_FAIL; - } - - return (result); -} - -static void -t_dns_name_fromtext(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_fromtext", 1, T_REQUIRED, "%s", a40); - - result = T_UNRESOLVED; - fp = fopen("dns_name_fromtext_data", "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 = bustline(p, Tokens); - if (cnt == 4) { - /* - * test_name1, test_name2, test_origin, - * downcase. - */ - result = test_dns_name_fromtext(Tokens[0], - Tokens[1], - Tokens[2], - atoi(Tokens[3]) - == 0 ? - 0 : - DNS_NAME_DOWNCASE); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_fromtext\n"); - t_result(result); - } -} - -static const char *a41 = - "dns_name_totext(name, omit_final_dot, target) converts " - "the DNS name 'name' in wire format to textual format " - "at target, and adds a final '.' to the name if " - "omit_final_dot is false"; - -static int -test_dns_name_totext(char *test_name, isc_boolean_t omit_final) { - int result; - int len; - int order; - unsigned int nlabels; - unsigned char junk1[BUFLEN]; - unsigned char junk2[BUFLEN]; - unsigned char junk3[BUFLEN]; - isc_buffer_t buf1; - isc_buffer_t buf2; - isc_buffer_t buf3; - dns_name_t dns_name1; - dns_name_t dns_name2; - isc_result_t dns_result; - dns_namereln_t dns_namereln; - - t_info("testing %s\n", test_name); - - len = strlen(test_name); - isc_buffer_init(&buf1, test_name, len); - isc_buffer_add(&buf1, len); - - dns_name_init(&dns_name1, NULL); - isc_buffer_init(&buf2, junk2, BUFLEN); - - /* - * Out of the data file to dns_name1. - */ - dns_result = dns_name_fromtext(&dns_name1, &buf1, NULL, 0, &buf2); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed, result == %s\n", - dns_result_totext(dns_result)); - return (T_UNRESOLVED); - } - - /* - * From dns_name1 into a text buffer. - */ - isc_buffer_invalidate(&buf1); - isc_buffer_init(&buf1, junk1, BUFLEN); - dns_result = dns_name_totext(&dns_name1, omit_final, &buf1); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_totext failed, result == %s\n", - dns_result_totext(dns_result)); - return (T_FAIL); - } - - /* - * From the text buffer into dns_name2. - */ - dns_name_init(&dns_name2, NULL); - isc_buffer_init(&buf3, junk3, BUFLEN); - dns_result = dns_name_fromtext(&dns_name2, &buf1, NULL, 0, &buf3); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed, result == %s\n", - dns_result_totext(dns_result)); - return (T_UNRESOLVED); - } - - dns_namereln = dns_name_fullcompare(&dns_name1, &dns_name2, - &order, &nlabels); - if (dns_namereln == dns_namereln_equal) - result = T_PASS; - else { - t_info("dns_name_fullcompare returned %s\n", - dns_namereln_to_text(dns_namereln)); - result = T_FAIL; - } - - return (result); -} - -static void -t_dns_name_totext(void) { - int line; - int cnt; - int result; - char *p; - FILE *fp; - - t_assert("dns_name_totext", 1, T_REQUIRED, "%s", a41); - - result = T_UNRESOLVED; - fp = fopen("dns_name_totext_data", "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 = bustline(p, Tokens); - if (cnt == 2) { - /* - * test_name, omit_final. - */ - result = test_dns_name_totext(Tokens[0], - atoi(Tokens[1]) == 0 ? - ISC_FALSE : - ISC_TRUE); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile dns_name_totext\n"); - t_result(result); - } -} - -static const char *a42 = - "dns_name_fromwire(name, source, dctx, downcase, target) " - "converts the possibly compressed DNS name 'name' in wire " - "format to canonicalized form at target, performing upper to " - "lower case conversion if downcase is true, and returns " - "ISC_R_SUCCESS"; - -#if 0 - /* - * XXXRTH these tests appear to be broken, so I have - * disabled them. - */ -static const char *a43 = - "when a label length is invalid, dns_name_fromwire() " - "returns DNS_R_FORMERR"; - -static const char *a44 = - "when a label type is invalid, dns_name_fromwire() " - "returns DNS_R_BADLABELTYPE"; -#endif - -static const char *a45 = - "when a name length is invalid, dns_name_fromwire() " - "returns DNS_R_FORMERR"; - -static const char *a46 = - "when a compression type is invalid, dns_name_fromwire() " - "returns DNS_R_DISALLOWED"; - -static const char *a47 = - "when a bad compression pointer is encountered, " - "dns_name_fromwire() returns DNS_R_BADPOINTER"; - -static const char *a48 = - "when input ends unexpected, dns_name_fromwire() " - "returns ISC_R_UNEXPECTEDEND"; - -static const char *a49 = - "when there is not enough space in target, " - "dns_name_fromwire(name, source, dcts, downcase, target) " - "returns ISC_R_NOSPACE"; - -static int -test_dns_name_fromwire(char *datafile_name, int testname_offset, int downcase, - unsigned int dc_method, char *exp_name, - isc_result_t exp_result, size_t buflen) -{ - int result; - int order; - unsigned int nlabels; - int len; - unsigned char buf1[BIGBUFLEN]; - char buf2[BUFLEN]; - isc_buffer_t iscbuf1; - isc_buffer_t iscbuf2; - dns_fixedname_t fixed2; - dns_name_t dns_name1; - dns_name_t *dns_name2; - isc_result_t dns_result; - dns_namereln_t dns_namereln; - dns_decompress_t dctx; - - t_info("testing using %s\n", datafile_name); - isc_buffer_init(&iscbuf1, buf1, sizeof(buf1)); - len = getmsg(datafile_name, &iscbuf1); - if (len == 0) - return (T_FAIL); - - isc_buffer_setactive(&iscbuf1, len); - iscbuf1.current = testname_offset; - - isc_buffer_init(&iscbuf2, buf2, (unsigned int)buflen); - dns_name_init(&dns_name1, NULL); - dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT); - dns_decompress_setmethods(&dctx, dc_method); - dns_result = dns_name_fromwire(&dns_name1, &iscbuf1, - &dctx, downcase ? ISC_TRUE : ISC_FALSE, - &iscbuf2); - - if ((dns_result == exp_result) && (exp_result == ISC_R_SUCCESS)) { - - dns_fixedname_init(&fixed2); - dns_name2 = dns_fixedname_name(&fixed2); - dns_result = dns_name_fromstring2(dns_name2, exp_name, NULL, - 0, NULL); - if (dns_result == ISC_R_SUCCESS) { - dns_namereln = dns_name_fullcompare(&dns_name1, - dns_name2, - &order, &nlabels); - if (dns_namereln != dns_namereln_equal) { - t_info("dns_name_fullcompare returned %s\n", - dns_namereln_to_text(dns_namereln)); - result = T_FAIL; - } else { - result = T_PASS; - } - } else { - t_info("dns_name_fromtext %s failed, result = %s\n", - exp_name, dns_result_totext(dns_result)); - result = T_UNRESOLVED; - } - } else if (dns_result == exp_result) { - result = T_PASS; - } else { - t_info("dns_name_fromwire returned %s\n", - dns_result_totext(dns_result)); - result = T_FAIL; - } - - return (result); -} - -static void -t_dns_name_fromwire_x(const char *testfile, size_t buflen) { - int line; - int cnt; - int result; - unsigned int dc_method; - isc_result_t exp_result; - char *p; - char *tok; - FILE *fp; - - result = T_UNRESOLVED; - fp = fopen(testfile, "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 = bustline(p, Tokens); - if (cnt == 6) { - /* - * datafile_name, testname_offset, - * downcase, dc_method, - * exp_name, exp_result. - */ - - tok = Tokens[5]; - exp_result = ISC_R_SUCCESS; - if (! strcmp(tok, "ISC_R_SUCCESS")) - exp_result = ISC_R_SUCCESS; - else if (! strcmp(tok, "ISC_R_NOSPACE")) - exp_result = ISC_R_NOSPACE; - else if (! strcmp(tok, "DNS_R_BADLABELTYPE")) - exp_result = DNS_R_BADLABELTYPE; - else if (! strcmp(tok, "DNS_R_FORMERR")) - exp_result = DNS_R_FORMERR; - else if (! strcmp(tok, "DNS_R_BADPOINTER")) - exp_result = DNS_R_BADPOINTER; - else if (! strcmp(tok, "ISC_R_UNEXPECTEDEND")) - exp_result = ISC_R_UNEXPECTEDEND; - else if (! strcmp(tok, "DNS_R_TOOMANYHOPS")) - exp_result = DNS_R_TOOMANYHOPS; - else if (! strcmp(tok, "DNS_R_DISALLOWED")) - exp_result = DNS_R_DISALLOWED; - else if (! strcmp(tok, "DNS_R_NAMETOOLONG")) - exp_result = DNS_R_NAMETOOLONG; - - tok = Tokens[3]; - dc_method = DNS_COMPRESS_NONE; - if (! strcmp(tok, "DNS_COMPRESS_GLOBAL14")) - dc_method = DNS_COMPRESS_GLOBAL14; - else if (! strcmp(tok, "DNS_COMPRESS_ALL")) - dc_method = DNS_COMPRESS_ALL; - - result = test_dns_name_fromwire(Tokens[0], - atoi(Tokens[1]), - atoi(Tokens[2]), - dc_method, - Tokens[4], - exp_result, - buflen); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile %s\n", testfile); - t_result(result); - } -} - -static void -t_dns_name_fromwire(void) { - t_assert("dns_name_fromwire", 1, T_REQUIRED, "%s", a42); - t_dns_name_fromwire_x("dns_name_fromwire_1_data", BUFLEN); - -#if 0 - /* - * XXXRTH these tests appear to be broken, so I have - * disabled them. - */ - t_assert("dns_name_fromwire", 2, T_REQUIRED, "%s", a43); - t_dns_name_fromwire_x("dns_name_fromwire_2_data", BUFLEN); - - t_assert("dns_name_fromwire", 3, T_REQUIRED, "%s", a44); - t_dns_name_fromwire_x("dns_name_fromwire_3_data", BUFLEN); -#endif - - t_assert("dns_name_fromwire", 4, T_REQUIRED, "%s", a45); - t_dns_name_fromwire_x("dns_name_fromwire_4_data", BUFLEN); - - t_assert("dns_name_fromwire", 5, T_REQUIRED, "%s", a46); - t_dns_name_fromwire_x("dns_name_fromwire_5_data", BUFLEN); - - t_assert("dns_name_fromwire", 6, T_REQUIRED, "%s", a47); - t_dns_name_fromwire_x("dns_name_fromwire_6_data", BUFLEN); - - t_assert("dns_name_fromwire", 7, T_REQUIRED, "%s", a48); - t_dns_name_fromwire_x("dns_name_fromwire_7_data", BUFLEN); - - t_assert("dns_name_fromwire", 9, T_REQUIRED, "%s", a49); - t_dns_name_fromwire_x("dns_name_fromwire_8_data", 2); -} - - -static const char *a51 = - "dns_name_towire(name, cctx, target) converts the DNS name " - "'name' into wire format, compresses it as specified " - "by the compression context cctx, stores the result in " - "target and returns DNS_SUCCESS"; - -static const char *a52 = - "when not enough space exists in target, " - "dns_name_towire(name, cctx, target) returns ISC_R_NOSPACE"; - -static int -test_dns_name_towire(char *testname, unsigned int dc_method, char *exp_data, - size_t exp_data_len, isc_result_t exp_result, - size_t buflen) -{ - int result; - int val; - int len; - unsigned char buf2[BUFLEN]; - unsigned char buf3[BUFLEN]; - isc_buffer_t iscbuf1; - isc_buffer_t iscbuf2; - isc_buffer_t iscbuf3; - dns_name_t dns_name; - isc_result_t dns_result; - isc_result_t isc_result; - dns_compress_t cctx; - isc_mem_t *mctx; - - t_info("testing using %s\n", testname); - - result = T_UNRESOLVED; - mctx = NULL; - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed\n"); - return (result); - } - dns_compress_init(&cctx, -1, mctx); - dns_compress_setmethods(&cctx, dc_method); - dns_name_init(&dns_name, NULL); - len = strlen(testname); - isc_buffer_init(&iscbuf1, testname, len); - isc_buffer_add(&iscbuf1, len); - isc_buffer_init(&iscbuf2, buf2, BUFLEN); - dns_result = dns_name_fromtext(&dns_name, &iscbuf1, NULL, 0, &iscbuf2); - if (dns_result == ISC_R_SUCCESS) { - isc_buffer_init(&iscbuf3, buf3, (unsigned int)buflen); - dns_result = dns_name_towire(&dns_name, &cctx, &iscbuf3); - if (dns_result == exp_result) { - if (exp_result == ISC_R_SUCCESS) { - /* - * Compare results with expected data. - */ - val = chkdata(buf3, iscbuf3.used, exp_data, - exp_data_len); - if (val == 0) - result = T_PASS; - else - result = T_FAIL; - } else - result = T_PASS; - } else { - t_info("dns_name_towire unexpectedly returned %s\n", - dns_result_totext(dns_result)); - result = T_FAIL; - } - } else { - t_info("dns_name_fromtext %s failed, result = %s\n", - testname, dns_result_totext(dns_result)); - } - return (result); -} - -static void -t_dns_name_towire_x(const char *testfile, size_t buflen) { - int line; - int cnt; - int result; - unsigned int dc_method; - isc_result_t exp_result; - size_t exp_data_len; - char *p; - FILE *fp; - - result = T_UNRESOLVED; - fp = fopen(testfile, "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 = bustline(p, Tokens); - if (cnt == 5) { - /* - * testname, dc_method, - * exp_data, exp_data_len, - * exp_result. - */ - - dc_method = t_dc_method_fromtext(Tokens[3]); - exp_result = t_dns_result_fromtext(Tokens[4]); - exp_data_len = strtoul(Tokens[3], NULL, 10); - - result = test_dns_name_towire(Tokens[0], - dc_method, - Tokens[2], - exp_data_len, - exp_result, - buflen); - } else { - t_info("bad format at line %d\n", line); - } - - (void)free(p); - t_result(result); - } - (void)fclose(fp); - } else { - t_info("Missing datafile %s\n", testfile); - t_result(result); - } -} - -static void -t_dns_name_towire_1(void) { - t_assert("dns_name_towire", 1, T_REQUIRED, "%s", a51); - t_dns_name_towire_x("dns_name_towire_1_data", BUFLEN); -} - -static void -t_dns_name_towire_2(void) { - t_assert("dns_name_towire", 2, T_REQUIRED, "%s", a52); - t_dns_name_towire_x("dns_name_towire_2_data", 2); -} - -static void -t_dns_name_towire(void) { - t_dns_name_towire_1(); - t_dns_name_towire_2(); -} - -#if 0 /* This is silly. A test should either exist, or not, but not - * one that just returns "UNTESTED." - */ -static const char *a53 = - "dns_name_concatenate(prefix, suffix, name, target) " - "concatenates prefix and suffix, stores the result " - "in target, canonicalizes any bitstring labels " - "and returns ISC_R_SUCCESS"; - -static void -t_dns_name_concatenate(void) { - t_assert("dns_name_concatenate", 1, T_REQUIRED, "%s", a53); - t_result(T_UNTESTED); -} -#endif - -testspec_t T_testlist[] = { - { (PFV) t_dns_name_init, "dns_name_init" }, - { (PFV) t_dns_name_invalidate, "dns_name_invalidate" }, - { (PFV) t_dns_name_setbuffer, "dns_name_setbuffer" }, - { (PFV) t_dns_name_hasbuffer, "dns_name_hasbuffer" }, - { (PFV) t_dns_name_isabsolute, "dns_name_isabsolute" }, - { (PFV) t_dns_name_hash, "dns_name_hash" }, - { (PFV) t_dns_name_fullcompare, "dns_name_fullcompare" }, - { (PFV) t_dns_name_compare, "dns_name_compare" }, - { (PFV) t_dns_name_rdatacompare, "dns_name_rdatacompare" }, - { (PFV) t_dns_name_issubdomain, "dns_name_issubdomain" }, - { (PFV) t_dns_name_countlabels, "dns_name_countlabels" }, - { (PFV) t_dns_name_getlabel, "dns_name_getlabel" }, - { (PFV) t_dns_name_getlabelsequence, "dns_name_getlabelsequence" }, - { (PFV) t_dns_name_fromregion, "dns_name_fromregion" }, - { (PFV) t_dns_name_toregion, "dns_name_toregion" }, - { (PFV) t_dns_name_fromwire, "dns_name_fromwire" }, - { (PFV) t_dns_name_towire, "dns_name_towire" }, - { (PFV) t_dns_name_fromtext, "dns_name_fromtext" }, - { (PFV) t_dns_name_totext, "dns_name_totext" }, -#if 0 - { (PFV) t_dns_name_concatenate, "dns_name_concatenate" }, -#endif - { (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/names/win32/t_names.vcxproj.filters.in b/bin/tests/names/win32/t_names.vcxproj.filters.in deleted file mode 100644 index 8520c64b10..0000000000 --- a/bin/tests/names/win32/t_names.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/names/win32/t_names.vcxproj.in b/bin/tests/names/win32/t_names.vcxproj.in deleted file mode 100644 index 5be43c2ffd..0000000000 --- a/bin/tests/names/win32/t_names.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {124DC0D3-3096-41D2-B490-CE85E890FF33} - Win32Proj - t_names - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/names/win32/t_names.vcxproj.user b/bin/tests/names/win32/t_names.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/names/win32/t_names.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/names/wire_test1.data b/bin/tests/names/wire_test1.data deleted file mode 100644 index 505134acfa..0000000000 --- a/bin/tests/names/wire_test1.data +++ /dev/null @@ -1,13 +0,0 @@ -# -# a global14 compression pointer -# -000a85800001000300000003 -0376697803636f6d0000020001c00c00 -02000100000e10000b05697372763102 -7061c00cc00c0002000100000e100009 -066e732d657874c00cc00c0002000100 -000e10000e036e733104676e61630363 -6f6d00c0250001000100000e100004cc -98b886c03c0001000100000e100004cc -98b840c051000100010002a14a0004c6 -97f8f6 diff --git a/bin/tests/names/wire_test2.data b/bin/tests/names/wire_test2.data deleted file mode 100644 index ea03557da7..0000000000 --- a/bin/tests/names/wire_test2.data +++ /dev/null @@ -1,13 +0,0 @@ -# -# a global14 compression pointer -# -000a85800001000300000003 -8376697803636f6d0000020001c00c00 -02000100000e10000b05697372763102 -7061c00cc00c0002000100000e100009 -066e732d657874c00cc00c0002000100 -000e10000e036e733104676e61630363 -6f6d00c0250001000100000e100004cc -98b886c03c0001000100000e100004cc -98b840c051000100010002a14a0004c6 -97f8f6 diff --git a/bin/tests/names/wire_test3_1.data b/bin/tests/names/wire_test3_1.data deleted file mode 100644 index 5f5ec59061..0000000000 --- a/bin/tests/names/wire_test3_1.data +++ /dev/null @@ -1,11 +0,0 @@ -# -# a bad compression pointer starting with the bits 1111 -# -000a85800001000300000003 -03766978 03636f6d 00 0002 0001 -f00c 0002 0001 0000 0e10 000b 056973727631 027061 c00c -c00c 0002 0001 0000 0e10 0009 066e732d657874 c00c -c00c 0002 0001 0000 0e10 000e 036e7331 04676e6163 03636f6d 00 -c025 0001 0001 0000 0e10 0004 cc98b886 -c03c 0001 0001 0000 0e10 0004 cc98b840 -c051 0001 0001 0002 a14a 0004 c697f8f6 diff --git a/bin/tests/names/wire_test3_2.data b/bin/tests/names/wire_test3_2.data deleted file mode 100644 index fae2fe25ec..0000000000 --- a/bin/tests/names/wire_test3_2.data +++ /dev/null @@ -1,12 +0,0 @@ -# -# a bad compression pointer due to forward reference of 0x30 to -# another compression pointer with a valid backreference -# -000a85800001000300000003 -03766978 03636f6d 00 0002 0001 -c030 0002 0001 0000 0e10 000b 056973727631 027061 c00c -c00c 0002 0001 0000 0e10 0009 066e732d657874 c00c -c00c 0002 0001 0000 0e10 000e 036e7331 04676e6163 03636f6d 00 -c025 0001 0001 0000 0e10 0004 cc98b886 -c03c 0001 0001 0000 0e10 0004 cc98b840 -c051 0001 0001 0002 a14a 0004 c697f8f6 diff --git a/bin/tests/names/wire_test4.data b/bin/tests/names/wire_test4.data deleted file mode 100644 index dba6035ab5..0000000000 --- a/bin/tests/names/wire_test4.data +++ /dev/null @@ -1,45 +0,0 @@ -# -# invalid name length, pointer at offset 0x0226 points to -# long name at offset 0x25 -# -000a 8580 0001 0003 0000 0001 -03 766978 03 636f6d 00 0002 0001 -c00c 0002 0001 00000e10 -0101 -# long name starts here -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a -03616263 0358595a 03616263 0358595a -03414243 0378797a 03414243 0378797a 00 -# compression pointer start here and refers back to long name -c023 0002 0001 00000e10 0009 066e732d657874 c00c -c00c 0002 0001 00000e10 000e 036e733104676e616303636f6d00 -c025 0001 0001 00000e10 0004 cc98b886 diff --git a/bin/tests/names/wire_test5.data b/bin/tests/names/wire_test5.data deleted file mode 100644 index 505134acfa..0000000000 --- a/bin/tests/names/wire_test5.data +++ /dev/null @@ -1,13 +0,0 @@ -# -# a global14 compression pointer -# -000a85800001000300000003 -0376697803636f6d0000020001c00c00 -02000100000e10000b05697372763102 -7061c00cc00c0002000100000e100009 -066e732d657874c00cc00c0002000100 -000e10000e036e733104676e61630363 -6f6d00c0250001000100000e100004cc -98b886c03c0001000100000e100004cc -98b840c051000100010002a14a0004c6 -97f8f6 diff --git a/bin/tests/names/wire_test6.data b/bin/tests/names/wire_test6.data deleted file mode 100644 index 1a05d264e8..0000000000 --- a/bin/tests/names/wire_test6.data +++ /dev/null @@ -1,13 +0,0 @@ -# -# a bad pointer -# -000a85800001000300000003 -0376697803636f6d0000020001f00c00 -02000100000e10000b05697372763102 -7061c00cc00c0002000100000e100009 -066e732d657874c00cc00c0002000100 -000e10000e036e733104676e61630363 -6f6d00c0250001000100000e100004cc -98b886c03c0001000100000e100004cc -98b840c051000100010002a14a0004c6 -97f8f6 diff --git a/bin/tests/names/wire_test7.data b/bin/tests/names/wire_test7.data deleted file mode 100644 index 40fbbed615..0000000000 --- a/bin/tests/names/wire_test7.data +++ /dev/null @@ -1,5 +0,0 @@ -# -# input ends unexpectedly -# -000a85800001000300000003 -0376697803636f6d0000020001c0 diff --git a/bin/tests/names/wire_test8.data b/bin/tests/names/wire_test8.data deleted file mode 100644 index beabbf7b28..0000000000 --- a/bin/tests/names/wire_test8.data +++ /dev/null @@ -1,28 +0,0 @@ -# -# too many hops DNS_POINTER_MAXHOPS is defined as 16 -# in lib/dns/include/dns/name.h -# -000a85800001000300000013 -03 766978 03 636f6d 00 0002 0001 -c00c 0002 0001 00000e10 000b 056973727631027061 c00c -c019 0002 0001 00000e10 0009 066e732d657874 c00c -c030 0002 0001 00000e10 000e 036e7331 04676e6163 03636f6d 00 -c045 0001 0001 00000e10 0004 cc98b886 -c05f 0001 0001 00000e10 0004 cc98b840 -c06f 0001 0001 0002a14a 0004 c697f8f6 -c07f 0001 0001 0002a14a 0004 c697f8f6 -c08f 0001 0001 0002a14a 0004 c697f8f6 -c09f 0001 0001 0002a14a 0004 c697f8f6 -c0af 0001 0001 0002a14a 0004 c697f8f6 -c0bf 0001 0001 0002a14a 0004 c697f8f6 -c0cf 0001 0001 0002a14a 0004 c697f8f6 -c0df 0001 0001 0002a14a 0004 c697f8f6 -c0ef 0001 0001 0002a14a 0004 c697f8f6 -c0ff 0001 0001 0002a14a 0004 c697f8f6 -c10f 0001 0001 0002a14a 0004 c697f8f6 -c11f 0001 0001 0002a14a 0004 c697f8f6 -c12f 0001 0001 0002a14a 0004 c697f8f6 -c13f 0001 0001 0002a14a 0004 c697f8f6 -c14f 0001 0001 0002a14a 0004 c697f8f6 -c15f 0001 0001 0002a14a 0004 c697f8f6 -c16f 0001 0001 0002a14a 0004 c697f8f6 diff --git a/bin/tests/ndc.conf b/bin/tests/ndc.conf deleted file mode 100644 index aa06c3eda3..0000000000 --- a/bin/tests/ndc.conf +++ /dev/null @@ -1,30 +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: ndc.conf,v 1.11 2007/06/19 23:46:59 tbox Exp $ */ - -options { - default-server "velo.jab.fr" ; -# [ default-key key_name; ] -}; - -server "velo.jab.fr" { - key "akey"; - host "1.2.3.4"; -}; - -include "ndc.conf-include"; - -key "akey" { - algorithm "algo"; - secret "c2Vj"; -}; - diff --git a/bin/tests/ndc.conf-include b/bin/tests/ndc.conf-include deleted file mode 100644 index 8884d75ffa..0000000000 --- a/bin/tests/ndc.conf-include +++ /dev/null @@ -1,19 +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: ndc.conf-include,v 1.6 2007/06/19 23:46:59 tbox Exp $ */ - -key "another-key" { - algorithm "al-gore-rhythm"; - secret "R29yZSBpbiAyMDA0IQo"; # "Gore in 2004!" -}; - - diff --git a/bin/tests/net/Makefile.in b/bin/tests/net/Makefile.in deleted file mode 100644 index d34e1e6254..0000000000 --- a/bin/tests/net/Makefile.in +++ /dev/null @@ -1,45 +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} - -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${ISCDEPLIBS} - -LIBS = ${ISCLIBS} @LIBS@ - -TARGETS = t_net@EXEEXT@ - -SRCS = driver.c netaddr_multicast.c sockaddr_multicast.c - -OBJS = driver.@O@ netaddr_multicast.@O@ sockaddr_multicast.@O@ - -@BIND9_MAKE_RULES@ - -t_net@EXEEXT@: ${OBJS} ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${TLIB} ${LIBS} - -test: t_net@EXEEXT@ - -@./t_net@EXEEXT@ - -clean distclean:: - rm -f ${TARGETS} - rm -f ${OBJS} diff --git a/bin/tests/net/driver.c b/bin/tests/net/driver.c deleted file mode 100644 index 69ad6dd9a2..0000000000 --- a/bin/tests/net/driver.c +++ /dev/null @@ -1,106 +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: driver.c,v 1.11 2007/06/19 23:47:00 tbox Exp $ */ - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "driver.h" - -#include "testsuite.h" - -#define NTESTS (sizeof(tests) / sizeof(test_t)) - -const char *gettime(void); -const char *test_result_totext(test_result_t); - -const char * -gettime(void) { - static char now[512]; - time_t t; -#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32) - struct tm tm; -#endif - - (void)time(&t); - -#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32) - strftime(now, sizeof(now) - 1, "%A %d %B %H:%M:%S %Y", - localtime_r(&t, &tm)); -#else - strftime(now, sizeof(now) - 1, "%A %d %B %H:%M:%S %Y", localtime(&t)); -#endif - - return (now); -} - -const char * -test_result_totext(test_result_t result) { - const char *s; - switch (result) { - case PASSED: - s = "PASS"; - break; - case FAILED: - s = "FAIL"; - break; - case UNTESTED: - s = "UNTESTED"; - break; - case UNKNOWN: - default: - s = "UNKNOWN"; - break; - } - - return (s); -} - -int -main(int argc, char **argv) { - test_t *test; - test_result_t result; - unsigned int n_failed; - unsigned int testno; - - UNUSED(argc); - UNUSED(argv); - - printf("S:%s:%s\n", SUITENAME, gettime()); - - n_failed = 0; - for (testno = 0; testno < NTESTS; testno++) { - test = &tests[testno]; - printf("T:%s:%u:A\n", test->tag, testno + 1); - printf("A:%s\n", test->description); - result = test->func(); - printf("R:%s\n", test_result_totext(result)); - if (result != PASSED) - n_failed++; - } - - printf("E:%s:%s\n", SUITENAME, gettime()); - - if (n_failed > 0) - exit(1); - - return (0); -} - diff --git a/bin/tests/net/driver.h b/bin/tests/net/driver.h deleted file mode 100644 index 23c256b748..0000000000 --- a/bin/tests/net/driver.h +++ /dev/null @@ -1,42 +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: driver.h,v 1.8 2007/06/19 23:47:00 tbox Exp $ */ - -/* - * PASSED and FAILED mean the particular test passed or failed. - * - * UNKNOWN means that for one reason or another, the test process itself - * failed. For instance, missing files, error when parsing files or - * IP addresses, etc. That is, the test itself is broken, not what is - * being tested. - * - * UNTESTED means the test was unable to be run because a prerequisite test - * failed, the test is disabled, or the test needs a system component - * (for instance, Perl) and cannot run. - */ -typedef enum { - PASSED = 0, - FAILED = 1, - UNKNOWN = 2, - UNTESTED = 3 -} test_result_t; - -typedef test_result_t (*test_func_t)(void); - -typedef struct { - const char *tag; - const char *description; - test_func_t func; -} test_t; - -#define TESTDECL(name) test_result_t name(void) - diff --git a/bin/tests/net/netaddr_multicast.c b/bin/tests/net/netaddr_multicast.c deleted file mode 100644 index 9fb21ec5fc..0000000000 --- a/bin/tests/net/netaddr_multicast.c +++ /dev/null @@ -1,107 +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: netaddr_multicast.c,v 1.12 2007/06/19 23:47:00 tbox Exp $ */ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "driver.h" - -TESTDECL(netaddr_multicast); - -typedef struct { - int family; - const char *addr; - isc_boolean_t is_multicast; -} t_addr_t; - -static t_addr_t addrs[] = { - { AF_INET, "1.2.3.4", ISC_FALSE }, - { AF_INET, "4.3.2.1", ISC_FALSE }, - { AF_INET, "224.1.1.1", ISC_TRUE }, - { AF_INET, "1.1.1.244", ISC_FALSE }, - { AF_INET6, "::1", ISC_FALSE }, - { AF_INET6, "ff02::1", ISC_TRUE } -}; -#define NADDRS (sizeof(addrs) / sizeof(t_addr_t)) - -static isc_result_t to_netaddr(t_addr_t *, isc_netaddr_t *); - -static isc_result_t -to_netaddr(t_addr_t *addr, isc_netaddr_t *na) { - int r; - struct in_addr in; - struct in6_addr in6; - - switch (addr->family) { - case AF_INET: - r = inet_pton(AF_INET, addr->addr, (unsigned char *)&in); - if (r != 1) - return (ISC_R_FAILURE); - isc_netaddr_fromin(na, &in); - break; - case AF_INET6: - r = inet_pton(AF_INET6, addr->addr, (unsigned char *)&in6); - if (r != 1) - return (ISC_R_FAILURE); - isc_netaddr_fromin6(na, &in6); - break; - default: - return (ISC_R_UNEXPECTED); - } - - return (ISC_R_SUCCESS); -} - -test_result_t -netaddr_multicast(void) { - isc_netaddr_t na; - unsigned int n_fail; - t_addr_t *addr; - unsigned int i; - isc_result_t result; - isc_boolean_t tf; - - n_fail = 0; - for (i = 0; i < NADDRS; i++) { - addr = &addrs[i]; - result = to_netaddr(addr, &na); - if (result != ISC_R_SUCCESS) { - printf("I:to_netaddr() returned %s on item %u\n", - isc_result_totext(result), i); - return (UNKNOWN); - } - tf = isc_netaddr_ismulticast(&na); - if (tf == addr->is_multicast) { - printf("I:%s is%s multicast (PASSED)\n", - (addr->addr), (tf ? "" : " not")); - } else { - printf("I:%s is%s multicast (FAILED)\n", - (addr->addr), (tf ? "" : " not")); - n_fail++; - } - } - - if (n_fail > 0) - return (FAILED); - - return (PASSED); -} diff --git a/bin/tests/net/sockaddr_multicast.c b/bin/tests/net/sockaddr_multicast.c deleted file mode 100644 index de216e390a..0000000000 --- a/bin/tests/net/sockaddr_multicast.c +++ /dev/null @@ -1,30 +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: sockaddr_multicast.c,v 1.8 2007/06/19 23:47:00 tbox Exp $ */ - -#include - -#include -#include - -#include -#include - -#include "driver.h" - -TESTDECL(sockaddr_multicast); - -test_result_t -sockaddr_multicast(void) { - - return (PASSED); -} diff --git a/bin/tests/net/testsuite.h b/bin/tests/net/testsuite.h deleted file mode 100644 index cb06b19e4f..0000000000 --- a/bin/tests/net/testsuite.h +++ /dev/null @@ -1,27 +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: testsuite.h,v 1.7 2007/06/19 23:47:00 tbox Exp $ */ - -#define SUITENAME "net" - -TESTDECL(netaddr_multicast); -TESTDECL(sockaddr_multicast); - -static test_t tests[] = { - { "isc_netaddr_ismulticast", - "Checking to see if multicast addresses are detected properly", - netaddr_multicast }, - { "isc_sockaddr_ismulticast", - "Checking to see if multicast addresses are detected properly", - sockaddr_multicast }, - -}; diff --git a/bin/tests/Kchild.example.+003+04017.key b/bin/tests/optional/Kchild.example.+003+04017.key similarity index 100% rename from bin/tests/Kchild.example.+003+04017.key rename to bin/tests/optional/Kchild.example.+003+04017.key diff --git a/bin/tests/Kchild.example.+003+04017.private b/bin/tests/optional/Kchild.example.+003+04017.private similarity index 100% rename from bin/tests/Kchild.example.+003+04017.private rename to bin/tests/optional/Kchild.example.+003+04017.private diff --git a/bin/tests/optional/Makefile.in b/bin/tests/optional/Makefile.in new file mode 100644 index 0000000000..8cefb5a916 --- /dev/null +++ b/bin/tests/optional/Makefile.in @@ -0,0 +1,273 @@ +# 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 = ${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \ + @DST_OPENSSL_INC@ @DST_GSSAPI_INC@ + +CDEFINES = @CRYPTO@ @USE_GSSAPI@ + +CWARNINGS = +BACKTRACECFLAGS = @BACKTRACECFLAGS@ + +DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ +ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ +ISCNOSYMLIBS = ../../../lib/isc/libisc-nosymtbl.@A@ @ISC_OPENSSL_LIBS@ +ISCCFGLIBS = ../../../lib/isccfg/libisccfg.@A@ + +DNSDEPLIBS = ../../../lib/dns/libdns.@A@ +ISCDEPLIBS = ../../../lib/isc/libisc.@A@ +ISCDEPNOSYMLIBS = ../../../lib/isc/libisc-nosymtbl.@A@ +ISCCFGDEPLIBS = ../../../lib/isccfg/libisccfg.@A@ + +LIBS = @LIBS@ + +SUBDIRS = + +# These programs are not built by default, but only when +# configured with --enable-developer or built explicitly with +# "make all_tests" + +TARGETS = @XTARGETS@ +XTARGETS = adb_test@EXEEXT@ \ + byaddr_test@EXEEXT@ \ + backtrace_test@EXEEXT@ \ + backtrace_test_nosymtbl@EXEEXT@ \ + byname_test@EXEEXT@ \ + db_test@EXEEXT@ \ + dst_test@EXEEXT@ \ + entropy_test@EXEEXT@ \ + entropy2_test@EXEEXT@ \ + gsstest@EXEEXT@ \ + hash_test@EXEEXT@ \ + fsaccess_test@EXEEXT@ \ + inter_test@EXEEXT@ \ + keyboard_test@EXEEXT@ \ + lex_test@EXEEXT@ \ + lfsr_test@EXEEXT@ \ + log_test@EXEEXT@ \ + master_test@EXEEXT@ \ + mempool_test@EXEEXT@ \ + name_test@EXEEXT@ \ + nsecify@EXEEXT@ \ + ratelimiter_test@EXEEXT@ \ + rbt_test@EXEEXT@ \ + rwlock_test@EXEEXT@ \ + serial_test@EXEEXT@ \ + shutdown_test@EXEEXT@ \ + sig0_test@EXEEXT@ \ + sock_test@EXEEXT@ \ + sym_test@EXEEXT@ \ + task_test@EXEEXT@ \ + timer_test@EXEEXT@ \ + zone_test@EXEEXT@ + +SRCS = ${XSRCS} +XSRCS = adb_test.c \ + byaddr_test.c \ + backtrace_test.c \ + byname_test.c \ + db_test.c \ + dst_test.c \ + entropy_test.c \ + entropy2_test.c \ + hash_test.c \ + fsaccess_test.c \ + gsstest.c \ + inter_test.c \ + keyboard_test.c \ + lex_test.c \ + lfsr_test.c \ + log_test.c \ + master_test.c \ + mempool_test.c \ + name_test.c \ + nsecify.c \ + ratelimiter_test.c \ + rbt_test.c \ + rwlock_test.c \ + serial_test.c \ + shutdown_test.c \ + sig0_test.c \ + sock_test.c \ + sym_test.c \ + task_test.c \ + timer_test.c \ + zone_test.c + +@BIND9_MAKE_RULES@ + +# disable optimization for backtrace test to get the expected result +BTTEST_CFLAGS = ${BACKTRACECFLAGS} ${EXT_CFLAGS} ${ALL_CPPFLAGS} -g \ + ${ALWAYS_WARNINGS} ${STD_CWARNINGS} ${CWARNINGS} + +all_tests: ${XTARGETS} + +adb_test@EXEEXT@: adb_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ adb_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +backtrace_test_nosymtbl@EXEEXT@: ${srcdir}/backtrace_test.c ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${BTTEST_CFLAGS} ${LDFLAGS} -o $@ \ + ${srcdir}/backtrace_test.c ${ISCLIBS} ${LIBS} + +backtrace_test@EXEEXT@: ${srcdir}/backtrace_test.c backtrace_test_nosymtbl@EXEEXT@ + #first step: create a first symbol table + rm -f symtbl.c + if test X${MKSYMTBL_PROGRAM} != X; then \ + ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl \ + backtrace_test_nosymtbl@EXEEXT@; else \ + cp ${top_srcdir}/lib/isc/backtrace-emptytbl.c symtbl.c; fi + #second step: build a binary with the first symbol table + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${BTTEST_CFLAGS} ${LDFLAGS} \ + -o $@0 ${srcdir}/backtrace_test.c symtbl.c \ + ${ISCNOSYMLIBS} ${LIBS} + rm -f symtbl.c + #third step: create a second symbol table + if test X${MKSYMTBL_PROGRAM} != X; then \ + ${MKSYMTBL_PROGRAM} ${top_srcdir}/util/mksymtbl.pl $@0; else \ + cp ${top_srcdir}/lib/isc/backtrace-emptytbl.c symtbl.c; fi + #fourth step: build the final binary + rm -f $@0 + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${BTTEST_CFLAGS} ${LDFLAGS} \ + -o $@ ${srcdir}/backtrace_test.c symtbl.c ${ISCNOSYMLIBS} ${LIBS} + rm -f symtbl.c + +nsecify@EXEEXT@: nsecify.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ nsecify.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +byaddr_test@EXEEXT@: byaddr_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ byaddr_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +byname_test@EXEEXT@: byname_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ byname_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lex_test.@O@ \ + ${ISCLIBS} ${LIBS} + +lfsr_test@EXEEXT@: lfsr_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ lfsr_test.@O@ \ + ${ISCLIBS} ${LIBS} + +log_test@EXEEXT@: log_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ log_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +name_test@EXEEXT@: name_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ name_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +hash_test@EXEEXT@: hash_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ hash_test.@O@ \ + ${ISCLIBS} ${LIBS} + +entropy_test@EXEEXT@: entropy_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ entropy_test.@O@ \ + ${ISCLIBS} ${LIBS} + +entropy2_test@EXEEXT@: entropy2_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ entropy2_test.@O@ \ + ${ISCLIBS} ${LIBS} + +sock_test@EXEEXT@: sock_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sock_test.@O@ \ + ${ISCLIBS} ${LIBS} + +sym_test@EXEEXT@: sym_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sym_test.@O@ \ + ${ISCLIBS} ${LIBS} + +task_test@EXEEXT@: task_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ task_test.@O@ \ + ${ISCLIBS} ${LIBS} + +shutdown_test@EXEEXT@: shutdown_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ shutdown_test.@O@ \ + ${ISCLIBS} ${LIBS} + +timer_test@EXEEXT@: timer_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ timer_test.@O@ \ + ${ISCLIBS} ${LIBS} + +ratelimiter_test@EXEEXT@: ratelimiter_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ratelimiter_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +rbt_test@EXEEXT@: rbt_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rbt_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +rwlock_test@EXEEXT@: rwlock_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rwlock_test.@O@ \ + ${ISCLIBS} ${LIBS} + +master_test@EXEEXT@: master_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ master_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +db_test@EXEEXT@: db_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ db_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +mempool_test@EXEEXT@: mempool_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ mempool_test.@O@ \ + ${ISCLIBS} ${LIBS} + +serial_test@EXEEXT@: serial_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ serial_test.@O@ \ + ${ISCLIBS} ${LIBS} + +zone_test@EXEEXT@: zone_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ zone_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +fsaccess_test@EXEEXT@: fsaccess_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ fsaccess_test.@O@ \ + ${ISCLIBS} ${LIBS} + +inter_test@EXEEXT@: inter_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ inter_test.@O@ \ + ${ISCLIBS} ${LIBS} + +keyboard_test@EXEEXT@: keyboard_test.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ keyboard_test.@O@ \ + ${ISCLIBS} ${LIBS} + +sig0_test@EXEEXT@: sig0_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ sig0_test.@O@ \ + ${DNSLIBS} ${ISCLIBS} ${LIBS} + +dst_test@EXEEXT@: dst_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} \ + -o $@ dst_test.@O@ ${DNSLIBS} ${ISCLIBS} ${LIBS} + +gsstest@EXEEXT@: gsstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} \ + -o $@ gsstest.@O@ ${DNSLIBS} ${ISCLIBS} ${LIBS} + +clean distclean:: + rm -f ${TARGETS} ${XTARGETS} + rm -f backtrace_test_symtbl.c + +check: test + +test: + @for dir in $(TESTDIRS) ;\ + do \ + ( cd $$dir; $(MAKE) test ) ;\ + done diff --git a/bin/tests/adb_test.c b/bin/tests/optional/adb_test.c similarity index 99% rename from bin/tests/adb_test.c rename to bin/tests/optional/adb_test.c index 4f0b3b34ed..9cd96a4a7a 100644 --- a/bin/tests/adb_test.c +++ b/bin/tests/optional/adb_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: adb_test.c,v 1.73 2011/08/30 23:46:51 tbox Exp $ */ - /*! \file */ #include diff --git a/bin/tests/backtrace_test.c b/bin/tests/optional/backtrace_test.c similarity index 96% rename from bin/tests/backtrace_test.c rename to bin/tests/optional/backtrace_test.c index f18d9ed1a6..cd89a68b5f 100644 --- a/bin/tests/backtrace_test.c +++ b/bin/tests/optional/backtrace_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: backtrace_test.c,v 1.4 2009/09/02 23:48:01 tbox Exp $ */ - #include #include diff --git a/bin/tests/byaddr_test.c b/bin/tests/optional/byaddr_test.c similarity index 98% rename from bin/tests/byaddr_test.c rename to bin/tests/optional/byaddr_test.c index ba3ab02a7c..39b8b253e9 100644 --- a/bin/tests/byaddr_test.c +++ b/bin/tests/optional/byaddr_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: byaddr_test.c,v 1.28 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file * \author * Principal Author: Bob Halley diff --git a/bin/tests/byname_test.c b/bin/tests/optional/byname_test.c similarity index 99% rename from bin/tests/byname_test.c rename to bin/tests/optional/byname_test.c index c5458a77ab..d4853c4760 100644 --- a/bin/tests/byname_test.c +++ b/bin/tests/optional/byname_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: byname_test.c,v 1.33 2009/09/02 23:48:01 tbox Exp $ */ - /*! \file * \author * Principal Author: Bob Halley diff --git a/bin/tests/db_test.c b/bin/tests/optional/db_test.c similarity index 99% rename from bin/tests/db_test.c rename to bin/tests/optional/db_test.c index f22cde5d64..bc5d08f9e1 100644 --- a/bin/tests/db_test.c +++ b/bin/tests/optional/db_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: db_test.c,v 1.70 2011/08/29 23:46:44 tbox Exp $ */ - /*! \file * \author * Principal Author: Bob Halley diff --git a/bin/tests/dst/dst_test.c b/bin/tests/optional/dst_test.c similarity index 99% rename from bin/tests/dst/dst_test.c rename to bin/tests/optional/dst_test.c index 867668b791..f2b1bc15bf 100644 --- a/bin/tests/dst/dst_test.c +++ b/bin/tests/optional/dst_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: dst_test.c,v 1.46 2009/09/01 00:22:25 jinmei Exp $ */ - #include #include diff --git a/bin/tests/entropy2_test.c b/bin/tests/optional/entropy2_test.c similarity index 98% rename from bin/tests/entropy2_test.c rename to bin/tests/optional/entropy2_test.c index b1208e3e0d..d7ae39e4bd 100644 --- a/bin/tests/entropy2_test.c +++ b/bin/tests/optional/entropy2_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: entropy2_test.c,v 1.16 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include @@ -167,4 +165,3 @@ main(int argc, char **argv) { return (0); } - diff --git a/bin/tests/entropy_test.c b/bin/tests/optional/entropy_test.c similarity index 97% rename from bin/tests/entropy_test.c rename to bin/tests/optional/entropy_test.c index e2656403df..ffe2a47b18 100644 --- a/bin/tests/entropy_test.c +++ b/bin/tests/optional/entropy_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: entropy_test.c,v 1.23 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include @@ -132,4 +130,3 @@ main(int argc, char **argv) { return (0); } - diff --git a/bin/tests/fsaccess_test.c b/bin/tests/optional/fsaccess_test.c similarity index 95% rename from bin/tests/fsaccess_test.c rename to bin/tests/optional/fsaccess_test.c index d2bd440453..f2e4c24f64 100644 --- a/bin/tests/fsaccess_test.c +++ b/bin/tests/optional/fsaccess_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: fsaccess_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include diff --git a/bin/tests/dst/gsstest.c b/bin/tests/optional/gsstest.c similarity index 100% rename from bin/tests/dst/gsstest.c rename to bin/tests/optional/gsstest.c diff --git a/bin/tests/hash_test.c b/bin/tests/optional/hash_test.c similarity index 99% rename from bin/tests/hash_test.c rename to bin/tests/optional/hash_test.c index 20d2dd3922..bf2891ad4c 100644 --- a/bin/tests/hash_test.c +++ b/bin/tests/optional/hash_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: hash_test.c,v 1.19 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include diff --git a/bin/tests/inter_test.c b/bin/tests/optional/inter_test.c similarity index 100% rename from bin/tests/inter_test.c rename to bin/tests/optional/inter_test.c diff --git a/bin/tests/keyboard_test.c b/bin/tests/optional/keyboard_test.c similarity index 95% rename from bin/tests/keyboard_test.c rename to bin/tests/optional/keyboard_test.c index ab4be5ffac..085b314e02 100644 --- a/bin/tests/keyboard_test.c +++ b/bin/tests/optional/keyboard_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: keyboard_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include @@ -67,4 +65,3 @@ main(int argc, char **argv) { return (0); } - diff --git a/bin/tests/lex_test.c b/bin/tests/optional/lex_test.c similarity index 98% rename from bin/tests/lex_test.c rename to bin/tests/optional/lex_test.c index 4c9221b0a2..4631242602 100644 --- a/bin/tests/lex_test.c +++ b/bin/tests/optional/lex_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: lex_test.c,v 1.23 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include diff --git a/bin/tests/lfsr_test.c b/bin/tests/optional/lfsr_test.c similarity index 97% rename from bin/tests/lfsr_test.c rename to bin/tests/optional/lfsr_test.c index adf2858265..af55a31abe 100644 --- a/bin/tests/lfsr_test.c +++ b/bin/tests/optional/lfsr_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: lfsr_test.c,v 1.16 2007/06/19 23:46:59 tbox Exp $ */ - /*! \file */ #include diff --git a/bin/tests/log_test.c b/bin/tests/optional/log_test.c similarity index 99% rename from bin/tests/log_test.c rename to bin/tests/optional/log_test.c index 93fb6b78e4..50807e8c02 100644 --- a/bin/tests/log_test.c +++ b/bin/tests/optional/log_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: log_test.c,v 1.29 2011/08/28 23:46:51 marka Exp $ */ - /* Principal Authors: DCL */ #include diff --git a/bin/tests/master_test.c b/bin/tests/optional/master_test.c similarity index 97% rename from bin/tests/master_test.c rename to bin/tests/optional/master_test.c index ae7c0a6518..8d021842ae 100644 --- a/bin/tests/master_test.c +++ b/bin/tests/optional/master_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: master_test.c,v 1.32 2009/09/02 23:48:01 tbox Exp $ */ - #include #include diff --git a/bin/tests/mempool_test.c b/bin/tests/optional/mempool_test.c similarity index 97% rename from bin/tests/mempool_test.c rename to bin/tests/optional/mempool_test.c index 7074450f95..6a878f449c 100644 --- a/bin/tests/mempool_test.c +++ b/bin/tests/optional/mempool_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: mempool_test.c,v 1.17 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/name_test.c b/bin/tests/optional/name_test.c similarity index 100% rename from bin/tests/name_test.c rename to bin/tests/optional/name_test.c diff --git a/bin/tests/nsecify.c b/bin/tests/optional/nsecify.c similarity index 98% rename from bin/tests/nsecify.c rename to bin/tests/optional/nsecify.c index 4b06d1e085..5371bc4d44 100644 --- a/bin/tests/nsecify.c +++ b/bin/tests/optional/nsecify.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: nsecify.c,v 1.12 2011/08/29 23:46:44 tbox Exp $ */ - #include #include diff --git a/bin/tests/ratelimiter_test.c b/bin/tests/optional/ratelimiter_test.c similarity index 98% rename from bin/tests/ratelimiter_test.c rename to bin/tests/optional/ratelimiter_test.c index 5fa5ed55dc..02eadace52 100644 --- a/bin/tests/ratelimiter_test.c +++ b/bin/tests/optional/ratelimiter_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: ratelimiter_test.c,v 1.18 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/rbt_test.c b/bin/tests/optional/rbt_test.c similarity index 99% rename from bin/tests/rbt_test.c rename to bin/tests/optional/rbt_test.c index 4bec961b18..055586d747 100644 --- a/bin/tests/rbt_test.c +++ b/bin/tests/optional/rbt_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: rbt_test.c,v 1.52 2011/08/28 23:46:41 tbox Exp $ */ - #include #include diff --git a/bin/tests/rbt_test.out b/bin/tests/optional/rbt_test.out similarity index 100% rename from bin/tests/rbt_test.out rename to bin/tests/optional/rbt_test.out diff --git a/bin/tests/rbt_test.txt b/bin/tests/optional/rbt_test.txt similarity index 94% rename from bin/tests/rbt_test.txt rename to bin/tests/optional/rbt_test.txt index 2acee1ee6c..4821c34c0f 100644 --- a/bin/tests/rbt_test.txt +++ b/bin/tests/optional/rbt_test.txt @@ -7,81 +7,79 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -# $Id: rbt_test.txt,v 1.17 2007/06/19 23:46:59 tbox Exp $ - -add a.vix.com -add b.vix.com -add c.vix.com -print -add a.b.c.d.e.f.vix.com -add b.b.c.d.e.f.vix.com -add c.b.c.d.e.f.vix.com -print -add a.d.e.f.vix.com -add q.d.e.f.vix.com -add d.e.f.vix.com -print -add g.h.vix.com -print -search q.d.e.f.vix.com -search just-parent.a.vix.com -search no-real-parent.vix.com -search does.not.exist.at.all -forward -backward -# existing name -check vix.com. -# greater than stop node, which has down pointer -check zzz.com. -# less than lowest in level (would be left link from stop node) -check 0.vix.com -# greater than stop node, no down pointer -check d.vix.com -# superdomain stored in existing node -check f.vix.com -# common ancestor stored in existing node; existing is successor -check a.e.f.vix.com -# common ancestor stored in existing node; existing is less but not predecessor -check z.e.f.vix.com -# -check g.vix.com -# -check i.vix.com -# -check b.c.vix.com -nuke d.e.f.vix.com -print -add x.a.vix.com -add y.x.a.vix.com -print -delete a.vix.com -delete x.a.vix.com -print -delete b.vix.com -delete c.vix.com -print -delete y.x.a.vix.com -print -delete g.h.vix.com. -add \[b100000].vix.com. -add \[b010000].vix.com. -add \[b001000].vix.com. -add \[b000100].vix.com. -add \[b000010].vix.com. -add \[b000001].vix.com. -p -search \[b000100].vix.com. -# zap the entire tree -add vix.com. -nuke vix.com. -add a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w. -add b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w. -print -add . -# zap it again -nuke . -# test splitting of maximal bitstring -add \[xFFFF/16].\[xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF/256].com -add \[xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF/128].com -print -quit +add a.vix.com +add b.vix.com +add c.vix.com +print +add a.b.c.d.e.f.vix.com +add b.b.c.d.e.f.vix.com +add c.b.c.d.e.f.vix.com +print +add a.d.e.f.vix.com +add q.d.e.f.vix.com +add d.e.f.vix.com +print +add g.h.vix.com +print +search q.d.e.f.vix.com +search just-parent.a.vix.com +search no-real-parent.vix.com +search does.not.exist.at.all +forward +backward +# existing name +check vix.com. +# greater than stop node, which has down pointer +check zzz.com. +# less than lowest in level (would be left link from stop node) +check 0.vix.com +# greater than stop node, no down pointer +check d.vix.com +# superdomain stored in existing node +check f.vix.com +# common ancestor stored in existing node; existing is successor +check a.e.f.vix.com +# common ancestor stored in existing node; existing is less but not predecessor +check z.e.f.vix.com +# +check g.vix.com +# +check i.vix.com +# +check b.c.vix.com +nuke d.e.f.vix.com +print +add x.a.vix.com +add y.x.a.vix.com +print +delete a.vix.com +delete x.a.vix.com +print +delete b.vix.com +delete c.vix.com +print +delete y.x.a.vix.com +print +delete g.h.vix.com. +add \[b100000].vix.com. +add \[b010000].vix.com. +add \[b001000].vix.com. +add \[b000100].vix.com. +add \[b000010].vix.com. +add \[b000001].vix.com. +p +search \[b000100].vix.com. +# zap the entire tree +add vix.com. +nuke vix.com. +add a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w. +add b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w. +print +add . +# zap it again +nuke . +# test splitting of maximal bitstring +add \[xFFFF/16].\[xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF/256].com +add \[xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF/128].com +print +quit diff --git a/bin/tests/rwlock_test.c b/bin/tests/optional/rwlock_test.c similarity index 98% rename from bin/tests/rwlock_test.c rename to bin/tests/optional/rwlock_test.c index a3178908a3..a540e3cd50 100644 --- a/bin/tests/rwlock_test.c +++ b/bin/tests/optional/rwlock_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: rwlock_test.c,v 1.26 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/serial_test.c b/bin/tests/optional/serial_test.c similarity index 93% rename from bin/tests/serial_test.c rename to bin/tests/optional/serial_test.c index 61b31c8b41..2c8715722c 100644 --- a/bin/tests/serial_test.c +++ b/bin/tests/optional/serial_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: serial_test.c,v 1.15 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/shutdown_test.c b/bin/tests/optional/shutdown_test.c similarity index 98% rename from bin/tests/shutdown_test.c rename to bin/tests/optional/shutdown_test.c index f4f041197f..3e98b2de7f 100644 --- a/bin/tests/shutdown_test.c +++ b/bin/tests/optional/shutdown_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: shutdown_test.c,v 1.25 2011/08/28 23:46:41 tbox Exp $ */ - #include #include diff --git a/bin/tests/sig0_test.c b/bin/tests/optional/sig0_test.c similarity index 99% rename from bin/tests/sig0_test.c rename to bin/tests/optional/sig0_test.c index 343f023a60..b64e1ada2d 100644 --- a/bin/tests/sig0_test.c +++ b/bin/tests/optional/sig0_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: sig0_test.c,v 1.19 2009/09/02 23:48:01 tbox Exp $ */ - #include #include diff --git a/bin/tests/sock_test.c b/bin/tests/optional/sock_test.c similarity index 99% rename from bin/tests/sock_test.c rename to bin/tests/optional/sock_test.c index 22c4ee7bf0..f13a3ffe64 100644 --- a/bin/tests/sock_test.c +++ b/bin/tests/optional/sock_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: sock_test.c,v 1.55 2008/07/23 23:27:54 marka Exp $ */ - #include #include diff --git a/bin/tests/sym_test.c b/bin/tests/optional/sym_test.c similarity index 97% rename from bin/tests/sym_test.c rename to bin/tests/optional/sym_test.c index 6ff95d8bba..1191d2ae63 100644 --- a/bin/tests/sym_test.c +++ b/bin/tests/optional/sym_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: sym_test.c,v 1.28 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/task_test.c b/bin/tests/optional/task_test.c similarity index 98% rename from bin/tests/task_test.c rename to bin/tests/optional/task_test.c index 8ec77c0746..1088010349 100644 --- a/bin/tests/task_test.c +++ b/bin/tests/optional/task_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: task_test.c,v 1.51 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/timer_test.c b/bin/tests/optional/timer_test.c similarity index 98% rename from bin/tests/timer_test.c rename to bin/tests/optional/timer_test.c index d2f10737ab..6fa112417c 100644 --- a/bin/tests/timer_test.c +++ b/bin/tests/optional/timer_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: timer_test.c,v 1.40 2007/06/19 23:46:59 tbox Exp $ */ - #include #include diff --git a/bin/tests/zone_test.c b/bin/tests/optional/zone_test.c similarity index 99% rename from bin/tests/zone_test.c rename to bin/tests/optional/zone_test.c index f4658e8aac..c7af967431 100644 --- a/bin/tests/zone_test.c +++ b/bin/tests/optional/zone_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: zone_test.c,v 1.35 2009/09/02 23:48:01 tbox Exp $ */ - #include #include diff --git a/bin/tests/rbt/Makefile.in b/bin/tests/rbt/Makefile.in deleted file mode 100644 index 3322da3a17..0000000000 --- a/bin/tests/rbt/Makefile.in +++ /dev/null @@ -1,50 +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} - -CDEFINES = -CWARNINGS = - -# Note that we do not want to use libtool for libt_api -DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -DNSDEPLIBS = ../../../lib/dns/libdns.@A@ -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_rbt@EXEEXT@ - -SRCS = t_rbt.c - -@BIND9_MAKE_RULES@ - -t_rbt@EXEEXT@: t_rbt.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_rbt.@O@ ${TLIB} ${LIBS} - -test: t_rbt@EXEEXT@ - -@./t_rbt@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @./t_rbt@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/rbt/dns_rbt.data b/bin/tests/rbt/dns_rbt.data deleted file mode 100644 index e58eb45911..0000000000 --- a/bin/tests/rbt/dns_rbt.data +++ /dev/null @@ -1,14 +0,0 @@ -a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w. -a.b.c.d.e.f.vix.com -a.d.e.f.vix.com -a.vix.com -b.b.c.d.e.f.vix.com -b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w. -b.vix.com -c.b.c.d.e.f.vix.com -c.vix.com -d.e.f.vix.com -g.h.vix.com -q.d.e.f.vix.com -x.a.vix.com -y.x.a.vix.com diff --git a/bin/tests/rbt/dns_rbt_addname_1_data b/bin/tests/rbt/dns_rbt_addname_1_data deleted file mode 100644 index 89dca408eb..0000000000 --- a/bin/tests/rbt/dns_rbt_addname_1_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_addname assertion 1 -# -# format is: -# -dns_rbt.data add new.name ISC_R_SUCCESS diff --git a/bin/tests/rbt/dns_rbt_addname_2_data b/bin/tests/rbt/dns_rbt_addname_2_data deleted file mode 100644 index 762bd8bc53..0000000000 --- a/bin/tests/rbt/dns_rbt_addname_2_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_addname assertion 2 -# -# format is: -# -dns_rbt.data add a.vix.com ISC_R_EXISTS diff --git a/bin/tests/rbt/dns_rbt_bitstring.data b/bin/tests/rbt/dns_rbt_bitstring.data deleted file mode 100644 index 2b34cc6328..0000000000 --- a/bin/tests/rbt/dns_rbt_bitstring.data +++ /dev/null @@ -1,10 +0,0 @@ -a.vix.com -b.vix.com -c.vix.com -a.a.vix.com -a.a.a.vix.com -a.a.a.a.vix.com -a.a.a.a.a.vix.com -a.a.a.a.a.a.vix.com -a.a.a.a.a.a.a.vix.com -a.a.a.a.a.a.a.a.vix.com diff --git a/bin/tests/rbt/dns_rbt_create_1_data b/bin/tests/rbt/dns_rbt_create_1_data deleted file mode 100644 index 72f8dc4b5c..0000000000 --- a/bin/tests/rbt/dns_rbt_create_1_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_rbt_create assertion 1 -# -# format is: -# -dns_rbt.data create not.used ISC_R_SUCCESS -dns_rbt_bitstring.data create not.used ISC_R_SUCCESS diff --git a/bin/tests/rbt/dns_rbt_deletename_1_data b/bin/tests/rbt/dns_rbt_deletename_1_data deleted file mode 100644 index 2e00e502ab..0000000000 --- a/bin/tests/rbt/dns_rbt_deletename_1_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_delete assertion 1 -# -# format is: -# -dns_rbt.data delete a.vix.com ISC_R_SUCCESS diff --git a/bin/tests/rbt/dns_rbt_deletename_2_data b/bin/tests/rbt/dns_rbt_deletename_2_data deleted file mode 100644 index 0b1fdb7b6c..0000000000 --- a/bin/tests/rbt/dns_rbt_deletename_2_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_delete assertion 2 -# -# format is: -# -dns_rbt.data delete new.name ISC_R_NOTFOUND diff --git a/bin/tests/rbt/dns_rbt_findname_1_data b/bin/tests/rbt/dns_rbt_findname_1_data deleted file mode 100644 index 2a3728dd08..0000000000 --- a/bin/tests/rbt/dns_rbt_findname_1_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_findname assertion 1 -# -# format is: -# -dns_rbt.data search a.vix.com ISC_R_SUCCESS diff --git a/bin/tests/rbt/dns_rbt_findname_2_data b/bin/tests/rbt/dns_rbt_findname_2_data deleted file mode 100644 index eb3d467b30..0000000000 --- a/bin/tests/rbt/dns_rbt_findname_2_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_findname assertion 2 -# -# format is: -# -dns_rbt.data search not.used.here ISC_R_NOTFOUND diff --git a/bin/tests/rbt/dns_rbt_findname_3_data b/bin/tests/rbt/dns_rbt_findname_3_data deleted file mode 100644 index 4ea2db301a..0000000000 --- a/bin/tests/rbt/dns_rbt_findname_3_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbt_findname assertion 3 -# -# format is: -# -dns_rbt.data search a.b.vix.com DNS_R_PARTIALMATCH diff --git a/bin/tests/rbt/dns_rbtnodechain_first_1.data b/bin/tests/rbt/dns_rbtnodechain_first_1.data deleted file mode 100644 index 85bd8c2e18..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_first_1.data +++ /dev/null @@ -1,13 +0,0 @@ -b.com -a.vix.com -b.vix.com -c.vix.com -a.a.vix.com -b.a.vix.com -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -iengines.net -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_first_2.data b/bin/tests/rbt/dns_rbtnodechain_first_2.data deleted file mode 100644 index 268376b93c..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_first_2.data +++ /dev/null @@ -1,9 +0,0 @@ -a.a.vix.com -b.a.vix.com -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -iengines.net -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_first_data b/bin/tests/rbt/dns_rbtnodechain_first_data deleted file mode 100644 index 057a1d66b5..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_first_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_rbtnodechain_first -# -# format is: -# -dns_rbtnodechain_first_1.data @ . com . -dns_rbtnodechain_first_2.data @ . vix.com . diff --git a/bin/tests/rbt/dns_rbtnodechain_init.data b/bin/tests/rbt/dns_rbtnodechain_init.data deleted file mode 100644 index 1e0bfc9c0a..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_init.data +++ /dev/null @@ -1,13 +0,0 @@ -vix.com -a.vix.com -b.vix.com -c.vix.com -a.a.vix.com -b.a.vix.com -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -iengines.net -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_init_data b/bin/tests/rbt/dns_rbtnodechain_init_data deleted file mode 100644 index f1a6aa4032..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_init_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbtnodechain_init -# -# format is: -# -dns_rbtnodechain_init.data b.vix.com. a b.vix.com. b a.vix.com. @ . isc.org . diff --git a/bin/tests/rbt/dns_rbtnodechain_last_1.data b/bin/tests/rbt/dns_rbtnodechain_last_1.data deleted file mode 100644 index 1e0bfc9c0a..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_last_1.data +++ /dev/null @@ -1,13 +0,0 @@ -vix.com -a.vix.com -b.vix.com -c.vix.com -a.a.vix.com -b.a.vix.com -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -iengines.net -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_last_2.data b/bin/tests/rbt/dns_rbtnodechain_last_2.data deleted file mode 100644 index 4d0c76d0fe..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_last_2.data +++ /dev/null @@ -1,7 +0,0 @@ -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -vayu.com -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_last_data b/bin/tests/rbt/dns_rbtnodechain_last_data deleted file mode 100644 index bf06a216ba..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_last_data +++ /dev/null @@ -1,7 +0,0 @@ -# -# test data for dns_rbtnodechain_last -# -# format is: -# -dns_rbtnodechain_last_1.data isc.org . iengines.net . -dns_rbtnodechain_last_2.data isc.org . b c.vix.com. diff --git a/bin/tests/rbt/dns_rbtnodechain_next.data b/bin/tests/rbt/dns_rbtnodechain_next.data deleted file mode 100644 index 1e0bfc9c0a..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_next.data +++ /dev/null @@ -1,13 +0,0 @@ -vix.com -a.vix.com -b.vix.com -c.vix.com -a.a.vix.com -b.a.vix.com -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -iengines.net -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_next_data b/bin/tests/rbt/dns_rbtnodechain_next_data deleted file mode 100644 index a69ab37a5f..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_next_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbtnodechain_next -# -# format is: -# -dns_rbtnodechain_next.data c.vix.com. a c.vix.com. diff --git a/bin/tests/rbt/dns_rbtnodechain_prev.data b/bin/tests/rbt/dns_rbtnodechain_prev.data deleted file mode 100644 index 1e0bfc9c0a..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_prev.data +++ /dev/null @@ -1,13 +0,0 @@ -vix.com -a.vix.com -b.vix.com -c.vix.com -a.a.vix.com -b.a.vix.com -a.b.vix.com -b.b.vix.com -a.c.vix.com -b.c.vix.com -iengines.net -isc.org - diff --git a/bin/tests/rbt/dns_rbtnodechain_prev_data b/bin/tests/rbt/dns_rbtnodechain_prev_data deleted file mode 100644 index 4c8450dc67..0000000000 --- a/bin/tests/rbt/dns_rbtnodechain_prev_data +++ /dev/null @@ -1,6 +0,0 @@ -# -# test data for dns_rbtnodechain_prev -# -# format is: -# -dns_rbtnodechain_prev.data a.b.vix.com. b vix.com. diff --git a/bin/tests/rbt/t_rbt.c b/bin/tests/rbt/t_rbt.c deleted file mode 100644 index 7398914b42..0000000000 --- a/bin/tests/rbt/t_rbt.c +++ /dev/null @@ -1,1868 +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_rbt.c,v 1.35 2011/03/12 04:59:46 tbox Exp $ */ - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#define BUFLEN 1024 -#define DNSNAMELEN 255 - -char *progname; -char *Tokens[T_MAXTOKS]; - -static int -t_dns_rbtnodechain_init(char *dbfile, char *findname, - char *nextname, char *nextorigin, - char *prevname, char *prevorigin, - char *firstname, char *firstorigin, - char *lastname, char *lastorigin); -static char * -fixedname_totext(dns_fixedname_t *name); - -static int -fixedname_cmp(dns_fixedname_t *dns_name, char *txtname); - -static char * -dnsname_totext(dns_name_t *name); - -static int -t_namechk(isc_result_t dns_result, dns_fixedname_t *dns_name, char *exp_name, - dns_fixedname_t *dns_origin, char *exp_origin, - isc_result_t exp_result); - -/* - * Parts adapted from the original rbt_test.c. - */ -static int -fixedname_cmp(dns_fixedname_t *dns_name, char *txtname) { - char *name; - - name = dnsname_totext(dns_fixedname_name(dns_name)); - if (strcmp(txtname, "NULL") == 0) { - if ((name == NULL) || (*name == '\0')) - return(0); - return(1); - } else { - return(strcmp(name, txtname)); - } -} - -static char * -dnsname_totext(dns_name_t *name) { - static char buf[BUFLEN]; - isc_buffer_t target; - - isc_buffer_init(&target, buf, BUFLEN); - dns_name_totext(name, ISC_FALSE, &target); - *((char *)(target.base) + target.used) = '\0'; - return(target.base); -} - -static char * -fixedname_totext(dns_fixedname_t *name) { - static char buf[BUFLEN]; - isc_buffer_t target; - - memset(buf, 0, BUFLEN); - isc_buffer_init(&target, buf, BUFLEN); - dns_name_totext(dns_fixedname_name(name), ISC_FALSE, &target); - *((char *)(target.base) + target.used) = '\0'; - return(target.base); -} - -#ifdef NEED_PRINT_DATA - -static isc_result_t -print_data(void *data) { - isc_result_t dns_result; - isc_buffer_t target; - char *buffer[DNSNAMELEN]; - - isc_buffer_init(&target, buffer, sizeof(buffer)); - - dns_result = dns_name_totext(data, ISC_FALSE, &target); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_totext failed %s\n", - dns_result_totext(dns_result)); - } - return(dns_result); -} - -#endif /* NEED_PRINT_DATA */ - -static int -create_name(char *s, isc_mem_t *mctx, dns_name_t **dns_name) { - int nfails; - int length; - isc_result_t result; - isc_buffer_t source; - isc_buffer_t target; - dns_name_t *name; - - nfails = 0; - - if (s && *s) { - - length = strlen(s); - - isc_buffer_init(&source, s, length); - isc_buffer_add(&source, length); - - /* - * The buffer for the actual name will immediately follow the - * name structure. - */ - name = isc_mem_get(mctx, sizeof(*name) + DNSNAMELEN); - if (name == NULL) { - t_info("isc_mem_get failed\n"); - ++nfails; - } else { - - dns_name_init(name, NULL); - isc_buffer_init(&target, name + 1, DNSNAMELEN); - - result = dns_name_fromtext(name, &source, dns_rootname, - 0, &target); - - if (result != ISC_R_SUCCESS) { - ++nfails; - t_info("dns_name_fromtext(%s) failed %s\n", - s, dns_result_totext(result)); - isc_mem_put(mctx, name, - sizeof(*name) + DNSNAMELEN); - } else - *dns_name = name; - } - } else { - ++nfails; - t_info("create_name: empty name\n"); - } - - return(nfails); -} - -static void -delete_name(void *data, void *arg) { - isc_mem_put((isc_mem_t *)arg, data, sizeof(dns_name_t) + DNSNAMELEN); -} - - -/* - * Adapted from the original rbt_test.c. - */ -static int -t1_add(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, isc_result_t *dns_result) { - int nprobs; - dns_name_t *dns_name; - - nprobs = 0; - if (name && dns_result) { - if (create_name(name, mctx, &dns_name) == 0) { - if (T_debug) - t_info("dns_rbt_addname succeeded\n"); - *dns_result = dns_rbt_addname(rbt, dns_name, dns_name); - if (*dns_result != ISC_R_SUCCESS) { - delete_name(dns_name, mctx); - t_info("dns_rbt_addname failed %s\n", - dns_result_totext(*dns_result)); - ++nprobs; - } - } else { - ++nprobs; - } - } else { - ++nprobs; - } - return(nprobs); -} - -static int -t1_delete(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, - isc_result_t *dns_result) -{ - int nprobs; - dns_name_t *dns_name; - - nprobs = 0; - if (name && dns_result) { - if (create_name(name, mctx, &dns_name) == 0) { - *dns_result = dns_rbt_deletename(rbt, dns_name, - ISC_FALSE); - delete_name(dns_name, mctx); - } else { - ++nprobs; - } - } else { - ++nprobs; - } - return(nprobs); -} - -static int -t1_search(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, - isc_result_t *dns_result) -{ - int nprobs; - dns_name_t *dns_searchname; - dns_name_t *dns_foundname; - dns_fixedname_t dns_fixedname; - void *data; - - nprobs = 0; - if (name && dns_result) { - if (create_name(name, mctx, &dns_searchname) == 0) { - dns_fixedname_init(&dns_fixedname); - dns_foundname = dns_fixedname_name(&dns_fixedname); - data = NULL; - *dns_result = dns_rbt_findname(rbt, dns_searchname, 0, - dns_foundname, &data); - delete_name(dns_searchname, mctx); - } else { - ++nprobs; - } - } else { - ++nprobs; - } - return(nprobs); -} - -/* - * Initialize a database from filename. - */ -static int -rbt_init(char *filename, dns_rbt_t **rbt, isc_mem_t *mctx) { - int rval; - isc_result_t dns_result; - char *p; - FILE *fp; - - fp = fopen(filename, "r"); - if (fp == NULL) { - t_info("No such file %s\n", filename); - return(1); - } - - dns_result = dns_rbt_create(mctx, delete_name, mctx, rbt); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rbt_create failed %s\n", - dns_result_totext(dns_result)); - fclose(fp); - return(1); - } - - while ((p = t_fgetbs(fp)) != NULL) { - - /* - * Skip any comment lines. - */ - if ((*p == '#') || (*p == '\0') || (*p == ' ')) { - (void)free(p); - continue; - } - - if (T_debug) - t_info("adding name %s to the rbt\n", p); - - rval = t1_add(p, *rbt, mctx, &dns_result); - if ((rval != 0) || (dns_result != ISC_R_SUCCESS)) { - t_info("add of %s failed\n", p); - dns_rbt_destroy(rbt); - (void) free(p); - fclose(fp); - return(1); - } - (void) free(p); - } - fclose(fp); - return(0); -} - -static int -test_rbt_gen(char *filename, char *command, char *testname, - isc_result_t exp_result) -{ - int rval; - int result; - dns_rbt_t *rbt; - isc_result_t isc_result; - isc_result_t dns_result; - isc_mem_t *mctx; - isc_entropy_t *ectx; - dns_name_t *dns_name; - - result = T_UNRESOLVED; - - if (strcmp(command, "create") != 0) - t_info("testing using name %s\n", testname); - - mctx = NULL; - ectx = NULL; - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create: %s: exiting\n", - dns_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: %s: exiting\n", - dns_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: %s: exiting\n", - dns_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - rbt = NULL; - if (rbt_init(filename, &rbt, mctx) != 0) { - if (strcmp(command, "create") == 0) - result = T_FAIL; - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - } - - /* - * Now try the database command. - */ - if (strcmp(command, "create") == 0) { - result = T_PASS; - } else if (strcmp(command, "add") == 0) { - if (create_name(testname, mctx, &dns_name) == 0) { - dns_result = dns_rbt_addname(rbt, dns_name, dns_name); - - if (dns_result != ISC_R_SUCCESS) - delete_name(dns_name, mctx); - - if (dns_result == exp_result) { - if (dns_result == ISC_R_SUCCESS) { - rval = t1_search(testname, rbt, mctx, - &dns_result); - if (rval == 0) { - if (dns_result == ISC_R_SUCCESS) { - result = T_PASS; - } else { - result = T_FAIL; - } - } else { - t_info("t1_search failed\n"); - result = T_UNRESOLVED; - } - } else { - result = T_PASS; - } - } else { - t_info("dns_rbt_addname returned %s, " - "expected %s\n", - dns_result_totext(dns_result), - dns_result_totext(exp_result)); - result = T_FAIL; - } - } else { - t_info("create_name failed\n"); - result = T_UNRESOLVED; - } - } else if ((strcmp(command, "delete") == 0) || - (strcmp(command, "nuke") == 0)) { - rval = t1_delete(testname, rbt, mctx, &dns_result); - if (rval == 0) { - if (dns_result == exp_result) { - rval = t1_search(testname, rbt, mctx, - &dns_result); - if (rval == 0) { - if (dns_result == ISC_R_SUCCESS) { - t_info("dns_rbt_deletename " - "didn't delete " - "the name"); - result = T_FAIL; - } else { - result = T_PASS; - } - } - } else { - t_info("delete returned %s, expected %s\n", - dns_result_totext(dns_result), - dns_result_totext(exp_result)); - result = T_FAIL; - } - } - } else if (strcmp(command, "search") == 0) { - rval = t1_search(testname, rbt, mctx, &dns_result); - if (rval == 0) { - if (dns_result == exp_result) { - result = T_PASS; - } else { - t_info("find returned %s, expected %s\n", - dns_result_totext(dns_result), - dns_result_totext(exp_result)); - result = T_FAIL; - } - } - } - - dns_rbt_destroy(&rbt); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); -} - -static int -test_dns_rbt_x(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - - 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; - } - - /* - * Name of db file, command, testname, - * expected result. - */ - cnt = t_bustline(p, Tokens); - if (cnt == 4) { - result = test_rbt_gen(Tokens[0], Tokens[1], - Tokens[2], - t_dns_result_fromtext(Tokens[3])); - if (result != T_PASS) - ++nfails; - } 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 const char *a1 = "dns_rbt_create creates a rbt and returns " - "ISC_R_SUCCESS on success"; - -static void -t1() { - int result; - - t_assert("dns_rbt_create", 1, T_REQUIRED, "%s", a1); - result = test_dns_rbt_x("dns_rbt_create_1_data"); - t_result(result); -} - -static const char *a2 = "dns_rbt_addname adds a name to a database and " - "returns ISC_R_SUCCESS on success"; - -static void -t2() { - int result; - - t_assert("dns_rbt_addname", 2, T_REQUIRED, "%s", a2); - result = test_dns_rbt_x("dns_rbt_addname_1_data"); - t_result(result); -} - -static const char *a3 = "when name already exists, dns_rbt_addname() " - "returns ISC_R_EXISTS"; - -static void -t3() { - int result; - - t_assert("dns_rbt_addname", 3, T_REQUIRED, "%s", a3); - result = test_dns_rbt_x("dns_rbt_addname_2_data"); - t_result(result); -} - -static const char *a4 = "when name exists, dns_rbt_deletename() returns " - "ISC_R_SUCCESS"; - -static void -t4() { - int result; - - t_assert("dns_rbt_deletename", 4, T_REQUIRED, "%s", a4); - result = test_dns_rbt_x("dns_rbt_deletename_1_data"); - t_result(result); -} - -static const char *a5 = "when name does not exist, dns_rbt_deletename() " - "returns ISC_R_NOTFOUND"; -static void -t5() { - int result; - - t_assert("dns_rbt_deletename", 5, T_REQUIRED, "%s", a5); - result = test_dns_rbt_x("dns_rbt_deletename_2_data"); - t_result(result); -} - -static const char *a6 = "when name exists and exactly matches the " - "search name dns_rbt_findname() returns ISC_R_SUCCESS"; - -static void -t6() { - int result; - - t_assert("dns_rbt_findname", 6, T_REQUIRED, "%s", a6); - result = test_dns_rbt_x("dns_rbt_findname_1_data"); - t_result(result); -} - -static const char *a7 = "when a name does not exist, " - "dns_rbt_findname returns ISC_R_NOTFOUND"; - -static void -t7() { - int result; - - t_assert("dns_rbt_findname", 7, T_REQUIRED, "%s", a7); - result = test_dns_rbt_x("dns_rbt_findname_2_data"); - t_result(result); -} - -static const char *a8 = "when a superdomain is found with data matching name, " - "dns_rbt_findname returns DNS_R_PARTIALMATCH"; - -static void -t8() { - int result; - - t_assert("dns_rbt_findname", 8, T_REQUIRED, "%s", a8); - result = test_dns_rbt_x("dns_rbt_findname_3_data"); - t_result(result); -} - - -static const char *a9 = "a call to dns_rbtnodechain_init(chain, mctx) " - "initializes chain"; - -static int -t9_walkchain(dns_rbtnodechain_t *chain, dns_rbt_t *rbt) { - int cnt; - int order; - unsigned int nlabels; - int nprobs; - isc_result_t dns_result; - - dns_fixedname_t name; - dns_fixedname_t origin; - dns_fixedname_t fullname1; - dns_fixedname_t fullname2; - - cnt = 0; - nprobs = 0; - - do { - - if (cnt == 0) { - dns_fixedname_init(&name); - dns_fixedname_init(&origin); - dns_result = dns_rbtnodechain_first(chain, rbt, - dns_fixedname_name(&name), - dns_fixedname_name(&origin)); - if (dns_result != DNS_R_NEWORIGIN) { - t_info("dns_rbtnodechain_first returned %s, " - "expecting DNS_R_NEWORIGIN\n", - dns_result_totext(dns_result)); - ++nprobs; - break; - } - t_info("first name:\t<%s>\n", fixedname_totext(&name)); - t_info("first origin:\t<%s>\n", - fixedname_totext(&origin)); - } else { - dns_fixedname_init(&fullname1); - dns_result = dns_name_concatenate( - dns_fixedname_name(&name), - dns_name_isabsolute(dns_fixedname_name(&name)) ? - NULL : dns_fixedname_name(&origin), - dns_fixedname_name(&fullname1), NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_concatenate failed %s\n", - dns_result_totext(dns_result)); - ++nprobs; - break; - } - - /* - * Expecting origin not to get touched if next - * doesn't return NEWORIGIN. - */ - dns_fixedname_init(&name); - dns_result = dns_rbtnodechain_next(chain, - dns_fixedname_name(&name), - dns_fixedname_name(&origin)); - if ((dns_result != ISC_R_SUCCESS) && - (dns_result != DNS_R_NEWORIGIN)) { - if (dns_result != ISC_R_NOMORE) { - t_info("dns_rbtnodechain_next " - "failed %s\n", - dns_result_totext(dns_result)); - ++nprobs; - } - break; - } - - t_info("next name:\t<%s>\n", fixedname_totext(&name)); - t_info("next origin:\t<%s>\n", - fixedname_totext(&origin)); - - dns_fixedname_init(&fullname2); - dns_result = dns_name_concatenate( - dns_fixedname_name(&name), - dns_name_isabsolute(dns_fixedname_name(&name)) ? - NULL : dns_fixedname_name(&origin), - dns_fixedname_name(&fullname2), NULL); - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_concatenate failed %s\n", - dns_result_totext(dns_result)); - ++nprobs; - break; - } - - t_info("comparing\t<%s>\n", - fixedname_totext(&fullname1)); - t_info("\twith\t<%s>\n", fixedname_totext(&fullname2)); - - (void)dns_name_fullcompare( - dns_fixedname_name(&fullname1), - dns_fixedname_name(&fullname2), - &order, &nlabels); - - if (order >= 0) { - t_info("unexpected order %s %s %s\n", - dnsname_totext(dns_fixedname_name(&fullname1)), - order == 0 ? "==" : ">", - dnsname_totext(dns_fixedname_name(&fullname2))); - ++nprobs; - } - } - - ++cnt; - } while (1); - - return (nprobs); -} - -/* - * Test by exercising the first|last|next|prev funcs in useful ways. - */ - -static int -t_namechk(isc_result_t dns_result, dns_fixedname_t *dns_name, char *exp_name, - dns_fixedname_t *dns_origin, char *exp_origin, - isc_result_t exp_result) -{ - int nfails; - - nfails = 0; - - if (fixedname_cmp(dns_name, exp_name)) { - t_info("\texpected name of %s, got %s\n", - exp_name, fixedname_totext(dns_name)); - ++nfails; - } - if (exp_origin != NULL) { - t_info("checking for DNS_R_NEWORIGIN\n"); - if (dns_result == exp_result) { - if (fixedname_cmp(dns_origin, exp_origin)) { - t_info("\torigin %s, expected %s\n", - fixedname_totext(dns_origin), - exp_origin); - ++nfails; - } - } else { - t_info("\tgot %s\n", dns_result_totext(dns_result)); - ++nfails; - } - } - return(nfails); -} - -static int -t_dns_rbtnodechain_init(char *dbfile, char *findname, - char *nextname, char *nextorigin, - char *prevname, char *prevorigin, - char *firstname, char *firstorigin, - char *lastname, char *lastorigin) -{ - int result; - int len; - int nfails; - dns_rbt_t *rbt; - dns_rbtnode_t *node; - dns_rbtnodechain_t chain; - isc_mem_t *mctx; - isc_entropy_t *ectx; - isc_result_t isc_result; - isc_result_t dns_result; - dns_fixedname_t dns_findname; - dns_fixedname_t dns_foundname; - dns_fixedname_t dns_firstname; - dns_fixedname_t dns_lastname; - dns_fixedname_t dns_prevname; - dns_fixedname_t dns_nextname; - dns_fixedname_t dns_origin; - isc_buffer_t isc_buffer; - - result = T_UNRESOLVED; - - nfails = 0; - mctx = NULL; - ectx = NULL; - - 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(result); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create: %s: exiting\n", - dns_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: %s: exiting\n", - dns_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rbtnodechain_init(&chain, mctx); - - rbt = NULL; - if (rbt_init(dbfile, &rbt, mctx)) { - t_info("rbt_init %s failed\n", dbfile); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - } - - len = strlen(findname); - isc_buffer_init(&isc_buffer, findname, len); - isc_buffer_add(&isc_buffer, len); - - dns_fixedname_init(&dns_foundname); - dns_fixedname_init(&dns_findname); - dns_fixedname_init(&dns_firstname); - dns_fixedname_init(&dns_origin); - dns_fixedname_init(&dns_lastname); - dns_fixedname_init(&dns_prevname); - dns_fixedname_init(&dns_nextname); - - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), - &isc_buffer, NULL, 0, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Set the starting node. - */ - node = NULL; - dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), - dns_fixedname_name(&dns_foundname), - &node, &chain, DNS_RBTFIND_EMPTYDATA, - NULL, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rbt_findnode failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Check next. - */ - t_info("checking for next name of %s and new origin of %s\n", - nextname, nextorigin); - dns_result = dns_rbtnodechain_next(&chain, - dns_fixedname_name(&dns_nextname), - dns_fixedname_name(&dns_origin)); - - if ((dns_result != ISC_R_SUCCESS) && - (dns_result != DNS_R_NEWORIGIN)) { - t_info("dns_rbtnodechain_next unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - - nfails += t_namechk(dns_result, &dns_nextname, nextname, &dns_origin, - nextorigin, DNS_R_NEWORIGIN); - - /* - * Set the starting node again. - */ - node = NULL; - dns_fixedname_init(&dns_foundname); - dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), - dns_fixedname_name(&dns_foundname), - &node, &chain, DNS_RBTFIND_EMPTYDATA, - NULL, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("\tdns_rbt_findnode failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Check previous. - */ - t_info("checking for previous name of %s and new origin of %s\n", - prevname, prevorigin); - dns_fixedname_init(&dns_origin); - dns_result = dns_rbtnodechain_prev(&chain, - dns_fixedname_name(&dns_prevname), - dns_fixedname_name(&dns_origin)); - - if ((dns_result != ISC_R_SUCCESS) && - (dns_result != DNS_R_NEWORIGIN)) { - t_info("dns_rbtnodechain_prev unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - nfails += t_namechk(dns_result, &dns_prevname, prevname, &dns_origin, - prevorigin, DNS_R_NEWORIGIN); - - /* - * Check first. - */ - t_info("checking for first name of %s and new origin of %s\n", - firstname, firstorigin); - dns_result = dns_rbtnodechain_first(&chain, rbt, - dns_fixedname_name(&dns_firstname), - dns_fixedname_name(&dns_origin)); - - if (dns_result != DNS_R_NEWORIGIN) { - t_info("dns_rbtnodechain_first unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - nfails += t_namechk(dns_result, &dns_firstname, firstname, - &dns_origin, firstorigin, DNS_R_NEWORIGIN); - - /* - * Check last. - */ - t_info("checking for last name of %s\n", lastname); - dns_result = dns_rbtnodechain_last(&chain, rbt, - dns_fixedname_name(&dns_lastname), - dns_fixedname_name(&dns_origin)); - - if (dns_result != DNS_R_NEWORIGIN) { - t_info("dns_rbtnodechain_last unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - nfails += t_namechk(dns_result, &dns_lastname, lastname, &dns_origin, - lastorigin, DNS_R_NEWORIGIN); - - /* - * Check node ordering. - */ - t_info("checking node ordering\n"); - nfails += t9_walkchain(&chain, rbt); - - if (nfails) - result = T_FAIL; - else - result = T_PASS; - - dns_rbtnodechain_invalidate(&chain); - dns_rbt_destroy(&rbt); - - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static int -test_dns_rbtnodechain_init(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - - 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 == 10) { - result = t_dns_rbtnodechain_init( - Tokens[0], /* dbfile */ - Tokens[1], /* startname */ - Tokens[2], /* nextname */ - Tokens[3], /* nextorigin */ - Tokens[4], /* prevname */ - Tokens[5], /* prevorigin */ - Tokens[6], /* firstname */ - Tokens[7], /* firstorigin */ - Tokens[8], /* lastname */ - Tokens[9]); /* lastorigin */ - 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 -t9() { - int result; - - t_assert("dns_rbtnodechain_init", 9, T_REQUIRED, "%s", a9); - result = test_dns_rbtnodechain_init("dns_rbtnodechain_init_data"); - t_result(result); -} - -static int -t_dns_rbtnodechain_first(char *dbfile, char *expected_firstname, - char *expected_firstorigin, - char *expected_nextname, - char *expected_nextorigin) -{ - int result; - int nfails; - dns_rbt_t *rbt; - dns_rbtnodechain_t chain; - isc_mem_t *mctx; - isc_entropy_t *ectx; - isc_result_t isc_result; - isc_result_t dns_result; - dns_fixedname_t dns_name; - dns_fixedname_t dns_origin; - isc_result_t expected_result; - - REQUIRE(dbfile != NULL); - REQUIRE(expected_firstname != NULL); - REQUIRE(expected_firstorigin != NULL); - REQUIRE(expected_nextname != NULL); - REQUIRE(expected_nextorigin != NULL); - - result = T_UNRESOLVED; - - nfails = 0; - mctx = NULL; - ectx = NULL; - - dns_fixedname_init(&dns_name); - dns_fixedname_init(&dns_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(result); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create: %s: exiting\n", - dns_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: %s: exiting\n", - dns_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rbtnodechain_init(&chain, mctx); - - rbt = NULL; - if (rbt_init(dbfile, &rbt, mctx)) { - t_info("rbt_init %s failed\n", dbfile); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - } - - t_info("testing for first name of %s, origin of %s\n", - expected_firstname, expected_firstorigin); - - dns_result = dns_rbtnodechain_first(&chain, rbt, - dns_fixedname_name(&dns_name), - dns_fixedname_name(&dns_origin)); - - if (dns_result != DNS_R_NEWORIGIN) - t_info("dns_rbtnodechain_first unexpectedly returned %s\n", - dns_result_totext(dns_result)); - - nfails += t_namechk(dns_result, &dns_name, expected_firstname, - &dns_origin, expected_firstorigin, DNS_R_NEWORIGIN); - - dns_fixedname_init(&dns_name); - dns_result = dns_rbtnodechain_next(&chain, - dns_fixedname_name(&dns_name), - dns_fixedname_name(&dns_origin)); - - t_info("testing for next name of %s, origin of %s\n", - expected_nextname, expected_nextorigin); - - if ((dns_result != ISC_R_SUCCESS) && (dns_result != DNS_R_NEWORIGIN)) - t_info("dns_rbtnodechain_next unexpectedly returned %s\n", - dns_result_totext(dns_result)); - - if (strcasecmp(expected_firstorigin, expected_nextorigin) == 0) - expected_result = ISC_R_SUCCESS; - else - expected_result = DNS_R_NEWORIGIN; - nfails += t_namechk(dns_result, &dns_name, expected_nextname, - &dns_origin, expected_nextorigin, expected_result); - - if (nfails) - result = T_FAIL; - else - result = T_PASS; - - dns_rbtnodechain_invalidate(&chain); - - dns_rbt_destroy(&rbt); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); -} - -static int -test_dns_rbtnodechain_first(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - - 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 == 5) { - result = t_dns_rbtnodechain_first( - Tokens[0], /* dbfile */ - Tokens[1], /* firstname */ - Tokens[2], /* firstorigin */ - Tokens[3], /* nextname */ - Tokens[4]); /* nextorigin */ - 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 const char *a10 = "a call to " - "dns_rbtnodechain_first(chain, rbt, name, origin) " - "sets name to point to the root of the tree, " - "origin to point to the origin, " - "and returns DNS_R_NEWORIGIN"; - -static void -t10() { - int result; - - t_assert("dns_rbtnodechain_first", 10, T_REQUIRED, "%s", a10); - result = test_dns_rbtnodechain_first("dns_rbtnodechain_first_data"); - t_result(result); -} - -static int -t_dns_rbtnodechain_last(char *dbfile, char *expected_lastname, - char *expected_lastorigin, - char *expected_prevname, - char *expected_prevorigin) -{ - - int result; - int nfails; - dns_rbt_t *rbt; - dns_rbtnodechain_t chain; - isc_mem_t *mctx; - isc_entropy_t *ectx; - isc_result_t isc_result; - isc_result_t dns_result; - dns_fixedname_t dns_name; - dns_fixedname_t dns_origin; - isc_result_t expected_result; - - REQUIRE(dbfile != NULL); - REQUIRE(expected_lastname != NULL); - REQUIRE(expected_lastorigin != NULL); - REQUIRE(expected_prevname != NULL); - REQUIRE(expected_prevorigin != NULL); - - result = T_UNRESOLVED; - - nfails = 0; - mctx = NULL; - ectx = NULL; - - dns_fixedname_init(&dns_name); - dns_fixedname_init(&dns_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(result); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create: %s: exiting\n", - dns_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: %s: exiting\n", - dns_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rbtnodechain_init(&chain, mctx); - - rbt = NULL; - if (rbt_init(dbfile, &rbt, mctx)) { - t_info("rbt_init %s failed\n", dbfile); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - } - - t_info("testing for last name of %s, origin of %s\n", - expected_lastname, expected_lastorigin); - - dns_result = dns_rbtnodechain_last(&chain, rbt, - dns_fixedname_name(&dns_name), - dns_fixedname_name(&dns_origin)); - - if (dns_result != DNS_R_NEWORIGIN) { - t_info("dns_rbtnodechain_last unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - nfails += t_namechk(dns_result, &dns_name, expected_lastname, - &dns_origin, expected_lastorigin, DNS_R_NEWORIGIN); - - t_info("testing for previous name of %s, origin of %s\n", - expected_prevname, expected_prevorigin); - - dns_fixedname_init(&dns_name); - dns_result = dns_rbtnodechain_prev(&chain, - dns_fixedname_name(&dns_name), - dns_fixedname_name(&dns_origin)); - - if ((dns_result != ISC_R_SUCCESS) && - (dns_result != DNS_R_NEWORIGIN)) { - t_info("dns_rbtnodechain_prev unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - if (strcasecmp(expected_lastorigin, expected_prevorigin) == 0) - expected_result = ISC_R_SUCCESS; - else - expected_result = DNS_R_NEWORIGIN; - nfails += t_namechk(dns_result, &dns_name, expected_prevname, - &dns_origin, expected_prevorigin, expected_result); - - if (nfails) - result = T_FAIL; - else - result = T_PASS; - - dns_rbtnodechain_invalidate(&chain); - dns_rbt_destroy(&rbt); - - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static int -test_dns_rbtnodechain_last(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - - 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 == 5) { - result = t_dns_rbtnodechain_last( - Tokens[0], /* dbfile */ - Tokens[1], /* lastname */ - Tokens[2], /* lastorigin */ - Tokens[3], /* prevname */ - Tokens[4]); /* prevorigin */ - 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 const char *a11 = "a call to " - "dns_rbtnodechain_last(chain, rbt, name, origin) " - "sets name to point to the last node of the megatree, " - "origin to the name of the level above it, " - "and returns DNS_R_NEWORIGIN"; - -static void -t11() { - int result; - - t_assert("dns_rbtnodechain_last", 11, T_REQUIRED, "%s", a11); - result = test_dns_rbtnodechain_last("dns_rbtnodechain_last_data"); - t_result(result); -} - -static int -t_dns_rbtnodechain_next(char *dbfile, char *findname, - char *nextname, char *nextorigin) -{ - - int result; - int len; - int nfails; - dns_rbt_t *rbt; - dns_rbtnode_t *node; - dns_rbtnodechain_t chain; - isc_mem_t *mctx; - isc_entropy_t *ectx; - isc_result_t isc_result; - isc_result_t dns_result; - dns_fixedname_t dns_findname; - dns_fixedname_t dns_foundname; - dns_fixedname_t dns_nextname; - dns_fixedname_t dns_origin; - isc_buffer_t isc_buffer; - - result = T_UNRESOLVED; - - nfails = 0; - mctx = NULL; - ectx = NULL; - - 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(result); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create: %s: exiting\n", - dns_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: %s: exiting\n", - dns_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rbtnodechain_init(&chain, mctx); - - rbt = NULL; - if (rbt_init(dbfile, &rbt, mctx)) { - t_info("rbt_init %s failed\n", dbfile); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - } - - len = strlen(findname); - isc_buffer_init(&isc_buffer, findname, len); - isc_buffer_add(&isc_buffer, len); - - dns_fixedname_init(&dns_foundname); - dns_fixedname_init(&dns_findname); - dns_fixedname_init(&dns_nextname); - dns_fixedname_init(&dns_origin); - - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), - &isc_buffer, NULL, 0, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Set the starting node. - */ - node = NULL; - dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), - dns_fixedname_name(&dns_foundname), - &node, &chain, DNS_RBTFIND_EMPTYDATA, - NULL, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rbt_findnode failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Check next. - */ - t_info("checking for next name of %s and new origin of %s\n", - nextname, nextorigin); - dns_result = dns_rbtnodechain_next(&chain, - dns_fixedname_name(&dns_nextname), - dns_fixedname_name(&dns_origin)); - - if ((dns_result != ISC_R_SUCCESS) && (dns_result != DNS_R_NEWORIGIN)) { - t_info("dns_rbtnodechain_next unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - - nfails += t_namechk(dns_result, &dns_nextname, nextname, &dns_origin, - nextorigin, DNS_R_NEWORIGIN); - - if (nfails) - result = T_FAIL; - else - result = T_PASS; - - dns_rbtnodechain_invalidate(&chain); - dns_rbt_destroy(&rbt); - - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static int -test_dns_rbtnodechain_next(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - - 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_rbtnodechain_next( - Tokens[0], /* dbfile */ - Tokens[1], /* findname */ - Tokens[2], /* nextname */ - Tokens[3]); /* nextorigin */ - 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 const char *a12 = "a call to " - "dns_rbtnodechain_next(chain, name, origin) " - "sets name to point to the next node of the tree " - "and returns ISC_R_SUCCESS or " - "DNS_R_NEWORIGIN on success"; - - -static void -t12() { - int result; - - t_assert("dns_rbtnodechain_next", 12, T_REQUIRED, "%s", a12); - result = test_dns_rbtnodechain_next("dns_rbtnodechain_next_data"); - t_result(result); -} - -static int -t_dns_rbtnodechain_prev(char *dbfile, char *findname, char *prevname, - char *prevorigin) -{ - int result; - int len; - int nfails; - dns_rbt_t *rbt; - dns_rbtnode_t *node; - dns_rbtnodechain_t chain; - isc_mem_t *mctx; - isc_entropy_t *ectx = NULL; - isc_result_t isc_result; - isc_result_t dns_result; - dns_fixedname_t dns_findname; - dns_fixedname_t dns_foundname; - dns_fixedname_t dns_prevname; - dns_fixedname_t dns_origin; - isc_buffer_t isc_buffer; - - result = T_UNRESOLVED; - - nfails = 0; - mctx = NULL; - ectx = NULL; - - 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(result); - } - - isc_result = isc_entropy_create(mctx, &ectx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_entropy_create: %s: exiting\n", - dns_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: %s: exiting\n", - dns_result_totext(isc_result)); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - dns_rbtnodechain_init(&chain, mctx); - - rbt = NULL; - if (rbt_init(dbfile, &rbt, mctx)) { - t_info("rbt_init %s failed\n", dbfile); - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - return(result); - } - - len = strlen(findname); - isc_buffer_init(&isc_buffer, findname, len); - isc_buffer_add(&isc_buffer, len); - - dns_fixedname_init(&dns_foundname); - dns_fixedname_init(&dns_findname); - dns_fixedname_init(&dns_prevname); - dns_fixedname_init(&dns_origin); - - dns_result = dns_name_fromtext(dns_fixedname_name(&dns_findname), - &isc_buffer, NULL, 0, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_name_fromtext failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Set the starting node. - */ - node = NULL; - dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), - dns_fixedname_name(&dns_foundname), - &node, &chain, DNS_RBTFIND_EMPTYDATA, - NULL, NULL); - - if (dns_result != ISC_R_SUCCESS) { - t_info("dns_rbt_findnode failed %s\n", - dns_result_totext(dns_result)); - return(result); - } - - /* - * Check next. - */ - t_info("checking for next name of %s and new origin of %s\n", - prevname, prevorigin); - dns_result = dns_rbtnodechain_prev(&chain, - dns_fixedname_name(&dns_prevname), - dns_fixedname_name(&dns_origin)); - - if ((dns_result != ISC_R_SUCCESS) && (dns_result != DNS_R_NEWORIGIN)) { - t_info("dns_rbtnodechain_prev unexpectedly returned %s\n", - dns_result_totext(dns_result)); - } - - nfails += t_namechk(dns_result, &dns_prevname, prevname, &dns_origin, - prevorigin, DNS_R_NEWORIGIN); - - if (nfails) - result = T_FAIL; - else - result = T_PASS; - - dns_rbtnodechain_invalidate(&chain); - dns_rbt_destroy(&rbt); - - isc_hash_destroy(); - isc_entropy_detach(&ectx); - isc_mem_destroy(&mctx); - - return(result); -} - -static int -test_dns_rbtnodechain_prev(const char *filename) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int nfails; - int nprobs; - - 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_rbtnodechain_prev( - Tokens[0], /* dbfile */ - Tokens[1], /* findname */ - Tokens[2], /* prevname */ - Tokens[3]); /* prevorigin */ - 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 const char *a13 = "a call to " - "dns_rbtnodechain_prev(chain, name, origin) " - "sets name to point to the previous node of the tree " - "and returns ISC_R_SUCCESS or " - "DNS_R_NEWORIGIN on success"; - -static void -t13() { - int result; - - t_assert("dns_rbtnodechain_prev", 13, T_REQUIRED, "%s", a13); - result = test_dns_rbtnodechain_prev("dns_rbtnodechain_prev_data"); - t_result(result); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "dns_rbt_create" }, - { (PFV) t2, "dns_rbt_addname 1" }, - { (PFV) t3, "dns_rbt_addname 2" }, - { (PFV) t4, "dns_rbt_deletename 1" }, - { (PFV) t5, "dns_rbt_deletename 2" }, - { (PFV) t6, "dns_rbt_findname 1" }, - { (PFV) t7, "dns_rbt_findname 2" }, - { (PFV) t8, "dns_rbt_findname 3" }, - { (PFV) t9, "dns_rbtnodechain_init" }, - { (PFV) t10, "dns_rbtnodechain_first" }, - { (PFV) t11, "dns_rbtnodechain_last" }, - { (PFV) t12, "dns_rbtnodechain_next" }, - { (PFV) t13, "dns_rbtnodechain_prev" }, - { (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/rbt/win32/t_rbt.vcxproj.filters.in b/bin/tests/rbt/win32/t_rbt.vcxproj.filters.in deleted file mode 100644 index d85dd49f07..0000000000 --- a/bin/tests/rbt/win32/t_rbt.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/rbt/win32/t_rbt.vcxproj.in b/bin/tests/rbt/win32/t_rbt.vcxproj.in deleted file mode 100644 index cd4034d6a7..0000000000 --- a/bin/tests/rbt/win32/t_rbt.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {39F714D4-FEFB-4E23-91DB-1F6FC80A98B5} - Win32Proj - t_rbt - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/rbt/win32/t_rbt.vcxproj.user b/bin/tests/rbt/win32/t_rbt.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/rbt/win32/t_rbt.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/resolv.conf.sample b/bin/tests/resolv.conf.sample deleted file mode 100644 index 35b210a293..0000000000 --- a/bin/tests/resolv.conf.sample +++ /dev/null @@ -1,32 +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: resolv.conf.sample,v 1.11 2007/06/19 23:46:59 tbox Exp $ - -domain jab.fr -nameserver 194.150.1.2 ; ignore that - -; ignore this comment - -nameserver 194.150.1.1 # ignore this comment too - -a-bad-entry-that-will be ignored - -option debug ; foo -option ndots:10 - -sortlist 10.0.0.0/255.244.33.0 11.0.0.0 - -search aaa bbb ccc ddd ; blank stuff -# search eee fff ggg hhh - -# -# Bar -### bar bar bar -# diff --git a/bin/tests/resolver/Makefile.in b/bin/tests/resolver/Makefile.in deleted file mode 100644 index e29b0df715..0000000000 --- a/bin/tests/resolver/Makefile.in +++ /dev/null @@ -1,51 +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 = - -# Note that we do not want to use libtool for libt_api -DNSLIBS = ../../../lib/dns/libdns.@A@ @DNS_CRYPTO_LIBS@ -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -DNSDEPLIBS = ../../../lib/dns/libdns.@A@ -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_resolver@EXEEXT@ - -SRCS = t_resolver.c - -@BIND9_MAKE_RULES@ - -t_resolver@EXEEXT@: t_resolver.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_resolver.@O@ ${TLIB} ${LIBS} - -test: t_resolver@EXEEXT@ - -@./t_resolver@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @./t_resolver@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/resolver/t_resolver.c b/bin/tests/resolver/t_resolver.c deleted file mode 100644 index 738b7203df..0000000000 --- a/bin/tests/resolver/t_resolver.c +++ /dev/null @@ -1,235 +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_resolver.c,v 1.3 2011/02/03 12:18:11 tbox Exp $ */ - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -char *progname; - -#define CHECK(x) RUNTIME_CHECK(ISC_R_SUCCESS == (x)) - - -isc_mem_t *mctx = NULL; -isc_timermgr_t *timer_manager = NULL; -isc_socketmgr_t *socket_manager = NULL; -isc_taskmgr_t *task_manager = NULL; -dns_dispatchmgr_t *dispatch_manager = NULL; -dns_view_t *view = NULL; -dns_dispatch_t *dispatch_v4 = NULL; - -static void -setup_create_dispatch_v4(void) -{ - isc_sockaddr_t local_address; - isc_sockaddr_any(&local_address); - - CHECK(dns_dispatch_getudp(dispatch_manager, socket_manager, - task_manager, &local_address, - 4096, 100, 100, 100, 500, 0, 0, - &dispatch_v4)); -} -static void -setup(void) { - /* 1 */ CHECK(isc_mem_create(0, 0, &mctx)); - /* 2 */ CHECK(isc_timermgr_create(mctx, &timer_manager)); - /* 3 */ CHECK(isc_taskmgr_create(mctx, 1, 0, &task_manager)); - /* 4 */ CHECK(isc_socketmgr_create(mctx, &socket_manager)); - /* 5 */ CHECK(dns_dispatchmgr_create(mctx, NULL, &dispatch_manager)); - /* 6 */ CHECK(dns_view_create(mctx, dns_rdataclass_in, "testview", &view)); - /* 7 */ setup_create_dispatch_v4(); -} - -static void -teardown(void) { - /* 7 */ dns_dispatch_detach(&dispatch_v4); - /* 6 */ dns_view_detach(&view); - /* 5 */ dns_dispatchmgr_destroy(&dispatch_manager); - /* 4 */ isc_socketmgr_destroy(&socket_manager); - /* 3 */ isc_taskmgr_destroy(&task_manager); - /* 2 */ isc_timermgr_destroy(&timer_manager); - /* 1 */ isc_mem_destroy(&mctx); -} - -static isc_result_t -make_resolver(dns_resolver_t **resolverp) { - isc_result_t result; - - result = dns_resolver_create(view, - task_manager, 1, 1, - socket_manager, - timer_manager, - 0, /* unsigned int options, */ - dispatch_manager, - dispatch_v4, - NULL, /* dns_dispatch_t *dispatchv6, */ - resolverp); - - return (result); -} - -static void -destroy_resolver(dns_resolver_t **resolverp) { - dns_resolver_shutdown(*resolverp); - dns_resolver_detach(resolverp); -} - -static void -test_dns_resolver_create(void) { - dns_resolver_t *resolver = NULL; - - t_assert("test_dns_resolver_create", 1, T_REQUIRED, "%s", - "a resolver can be created successfully"); - setup(); - CHECK(make_resolver(&resolver)); - - destroy_resolver(&resolver); - teardown(); - - t_result(T_PASS); -} - -static void -test_dns_resolver_gettimeout(void) { - dns_resolver_t *resolver = NULL; - int test_result; - unsigned int timeout; - - t_assert("test_dns_resolver_gettimeout", 1, T_REQUIRED, "%s", - "The default timeout is returned from _gettimeout()"); - setup(); - CHECK(make_resolver(&resolver)); - - timeout = dns_resolver_gettimeout(resolver); - t_info("The default timeout is %d second%s\n", timeout, (timeout == 1 ? "" : "s")); - test_result = (timeout > 0) ? T_PASS : T_FAIL; - - destroy_resolver(&resolver); - teardown(); - - t_result(test_result); -} - -static void -test_dns_resolver_settimeout(void) { - dns_resolver_t *resolver = NULL; - int test_result; - unsigned int default_timeout, timeout; - - t_assert("test_dns_resolver_settimeout", 1, T_REQUIRED, "%s", - "_settimeout() can change the timeout to a non-default"); - setup(); - CHECK(make_resolver(&resolver)); - - default_timeout = dns_resolver_gettimeout(resolver); - t_info("The default timeout is %d second%s\n", default_timeout, - (default_timeout == 1 ? "" : "s")); - - dns_resolver_settimeout(resolver, default_timeout + 1); - timeout = dns_resolver_gettimeout(resolver); - t_info("The new timeout is %d second%s\n", timeout, - (timeout == 1 ? "" : "s")); - test_result = (timeout == default_timeout + 1) ? T_PASS : T_FAIL; - - destroy_resolver(&resolver); - teardown(); - - t_result(test_result); -} - -static void -test_dns_resolver_settimeout_to_default(void) { - dns_resolver_t *resolver = NULL; - int test_result; - unsigned int default_timeout, timeout; - - t_assert("test_dns_resolver_settimeout_to_default", 1, T_REQUIRED, "%s", - "_settimeout() can change the timeout back to a default value" - " by specifying 0 as the timeout."); - setup(); - CHECK(make_resolver(&resolver)); - - default_timeout = dns_resolver_gettimeout(resolver); - t_info("The default timeout is %d second%s\n", default_timeout, - (default_timeout == 1 ? "" : "s")); - - dns_resolver_settimeout(resolver, default_timeout - 1); - timeout = dns_resolver_gettimeout(resolver); - t_info("The new timeout is %d second%s\n", timeout, - (timeout == 1 ? "" : "s")); - - dns_resolver_settimeout(resolver, 0); - timeout = dns_resolver_gettimeout(resolver); - test_result = (timeout == default_timeout) ? T_PASS : T_FAIL; - - destroy_resolver(&resolver); - teardown(); - - t_result(test_result); -} - -static void -test_dns_resolver_settimeout_over_maximum(void) { - dns_resolver_t *resolver = NULL; - int test_result; - unsigned int timeout; - - t_assert("test_dns_resolver_settimeout_over_maximum", 1, T_REQUIRED, "%s", - "_settimeout() cannot set the value larger than the maximum."); - setup(); - CHECK(make_resolver(&resolver)); - - dns_resolver_settimeout(resolver, 4000000); - timeout = dns_resolver_gettimeout(resolver); - t_info("The new timeout is %d second%s\n", timeout, - (timeout == 1 ? "" : "s")); - - test_result = (timeout < 4000000 && timeout > 0) ? T_PASS : T_FAIL; - - destroy_resolver(&resolver); - teardown(); - - t_result(test_result); -} - - -testspec_t T_testlist[] = { - { (PFV) test_dns_resolver_create, "dns_resolver_create" }, - { (PFV) test_dns_resolver_settimeout, "dns_resolver_settimeout" }, - { (PFV) test_dns_resolver_gettimeout, "dns_resolver_gettimeout" }, - { (PFV) test_dns_resolver_settimeout_to_default, "test_dns_resolver_settimeout_to_default" }, - { (PFV) test_dns_resolver_settimeout_over_maximum, "test_dns_resolver_settimeout_over_maximum" }, - { (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/resolver/win32/t_resolver.vcxproj.filters.in b/bin/tests/resolver/win32/t_resolver.vcxproj.filters.in deleted file mode 100644 index 01714b9941..0000000000 --- a/bin/tests/resolver/win32/t_resolver.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/resolver/win32/t_resolver.vcxproj.in b/bin/tests/resolver/win32/t_resolver.vcxproj.in deleted file mode 100644 index 756da60760..0000000000 --- a/bin/tests/resolver/win32/t_resolver.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {66E58849-A764-44E4-8D32-7C1107246A26} - Win32Proj - t_resolver - - - - 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@@GEOIP_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.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@@GEOIP_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libdns.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/resolver/win32/t_resolver.vcxproj.user b/bin/tests/resolver/win32/t_resolver.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/resolver/win32/t_resolver.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/sockaddr/Makefile.in b/bin/tests/sockaddr/Makefile.in deleted file mode 100644 index 6a1dba16c1..0000000000 --- a/bin/tests/sockaddr/Makefile.in +++ /dev/null @@ -1,47 +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} ${ISC_INCLUDES} - -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ -TAPIDEPLIBS = ../../../lib/tests/libt_api.@A@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ -TAPILIBS = ../../../lib/tests/libt_api.@A@ - -DEPLIBS = ${TAPIDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${TAPILIBS} ${ISCLIBS} @LIBS@ - -TARGETS = t_sockaddr@EXEEXT@ - -SRCS = t_sockaddr.c - -@BIND9_MAKE_RULES@ - -t_sockaddr@EXEEXT@: t_sockaddr.@O@ ${DEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_sockaddr.@O@ ${LIBS} - -test: t_sockaddr@EXEEXT@ - -@./t_sockaddr@EXEEXT@ -b @srcdir@ -a - -testhelp: - @./t_sockaddr@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/sockaddr/t_sockaddr.c b/bin/tests/sockaddr/t_sockaddr.c deleted file mode 100644 index cf1934cf55..0000000000 --- a/bin/tests/sockaddr/t_sockaddr.c +++ /dev/null @@ -1,138 +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_sockaddr.c,v 1.14 2007/06/19 23:47:00 tbox Exp $ */ - -#include - -#include -#include -#include - -#include - -static int -test_isc_sockaddr_eqaddrprefix(void) { - struct in_addr ina_a; - struct in_addr ina_b; - struct in_addr ina_c; - isc_sockaddr_t isa_a; - isc_sockaddr_t isa_b; - isc_sockaddr_t isa_c; - - if (inet_pton(AF_INET, "194.100.32.87", &ina_a) < 0) - return T_FAIL; - if (inet_pton(AF_INET, "194.100.32.80", &ina_b) < 0) - return T_FAIL; - if (inet_pton(AF_INET, "194.101.32.87", &ina_c) < 0) - return T_FAIL; - isc_sockaddr_fromin(&isa_a, &ina_a, 0); - isc_sockaddr_fromin(&isa_b, &ina_b, 42); - isc_sockaddr_fromin(&isa_c, &ina_c, 0); - - if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 0) != ISC_TRUE) - return T_FAIL; - if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 29) != ISC_TRUE) - return T_FAIL; - if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 30) != ISC_FALSE) - return T_FAIL; - if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 32) != ISC_FALSE) - return T_FAIL; - if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_c, 8) != ISC_TRUE) - return T_FAIL; - if (isc_sockaddr_eqaddrprefix(&isa_a, &isa_c, 16) != ISC_FALSE) - return T_FAIL; - - return T_PASS; -} - -static void -t1(void) { - int result; - t_assert("isc_sockaddr_eqaddrprefix", 1, T_REQUIRED, - "isc_sockaddr_eqaddrprefix() returns ISC_TRUE when " - "prefixes of a and b are equal, and ISC_FALSE when " - "they are not equal"); - result = test_isc_sockaddr_eqaddrprefix(); - t_result(result); -} - -static int -test_isc_netaddr_masktoprefixlen(void) { - struct in_addr na_a; - struct in_addr na_b; - struct in_addr na_c; - struct in_addr na_d; - isc_netaddr_t ina_a; - isc_netaddr_t ina_b; - isc_netaddr_t ina_c; - isc_netaddr_t ina_d; - unsigned int plen; - - if (inet_pton(AF_INET, "0.0.0.0", &na_a) < 0) - return T_FAIL; - if (inet_pton(AF_INET, "255.255.255.254", &na_b) < 0) - return T_FAIL; - if (inet_pton(AF_INET, "255.255.255.255", &na_c) < 0) - return T_FAIL; - if (inet_pton(AF_INET, "255.255.255.0", &na_d) < 0) - return T_FAIL; - isc_netaddr_fromin(&ina_a, &na_a); - isc_netaddr_fromin(&ina_b, &na_b); - isc_netaddr_fromin(&ina_c, &na_c); - isc_netaddr_fromin(&ina_d, &na_d); - - if (isc_netaddr_masktoprefixlen(&ina_a, &plen) != ISC_R_SUCCESS) - return T_FAIL; - if (plen != 0) - return T_FAIL; - - if (isc_netaddr_masktoprefixlen(&ina_b, &plen) != ISC_R_SUCCESS) - return T_FAIL; - if (plen != 31) - return T_FAIL; - - if (isc_netaddr_masktoprefixlen(&ina_c, &plen) != ISC_R_SUCCESS) - return T_FAIL; - if (plen != 32) - return T_FAIL; - - if (isc_netaddr_masktoprefixlen(&ina_d, &plen) != ISC_R_SUCCESS) - return T_FAIL; - if (plen != 24) - return T_FAIL; - - return T_PASS; -} - -static void -t2(void) { - int result; - t_assert("isc_netaddr_masktoprefixlen", 1, T_REQUIRED, - "isc_netaddr_masktoprefixlen() calculates " - "correct prefix lengths "); - result = test_isc_netaddr_masktoprefixlen(); - t_result(result); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "isc_sockaddr_eqaddrprefix" }, - { (PFV) t2, "isc_netaddr_masktoprefixlen" }, - { (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/sockaddr/win32/t_sockaddr.vcxproj.filters.in b/bin/tests/sockaddr/win32/t_sockaddr.vcxproj.filters.in deleted file mode 100644 index 7782bfef42..0000000000 --- a/bin/tests/sockaddr/win32/t_sockaddr.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/sockaddr/win32/t_sockaddr.vcxproj.in b/bin/tests/sockaddr/win32/t_sockaddr.vcxproj.in deleted file mode 100644 index af9820c61a..0000000000 --- a/bin/tests/sockaddr/win32/t_sockaddr.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {351D3872-707B-46AD-8BC0-5A668B8C745B} - Win32Proj - t_sockaddr - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/sockaddr/win32/t_sockaddr.vcxproj.user b/bin/tests/sockaddr/win32/t_sockaddr.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/sockaddr/win32/t_sockaddr.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/system/Makefile.in b/bin/tests/system/Makefile.in index e3f1287fe3..ba3972939e 100644 --- a/bin/tests/system/Makefile.in +++ b/bin/tests/system/Makefile.in @@ -39,10 +39,11 @@ TARGETS = feature-test@EXEEXT@ @BIND9_MAKE_RULES@ +subdirs: ${TARGETS} + feature-test@EXEEXT@: feature-test.@O@ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ feature-test.@O@ ${ISCLIBS} ${LIBS} - # Running the scripts below is bypassed when a separate build directory is # used. diff --git a/bin/tests/system/cleanall.sh b/bin/tests/system/cleanall.sh index 7e800b9017..d57d450bf2 100644 --- a/bin/tests/system/cleanall.sh +++ b/bin/tests/system/cleanall.sh @@ -18,7 +18,7 @@ SYSTEMTESTTOP=. find . -type f \( \ - -name 'K*' -o -name '*~' -o -name 'core' -o -name '*.core' \ + -name '*~' -o -name 'core' -o -name '*.core' \ -o -name '*.log' -o -name '*.pid' -o -name '*.keyset' \ -o -name named.run -o -name ans.run \ -o -name '*-valgrind-*.log' \) -print | xargs rm -f diff --git a/bin/tests/system/dnssec/clean.sh b/bin/tests/system/dnssec/clean.sh index 9b79004e19..29ac1695b9 100644 --- a/bin/tests/system/dnssec/clean.sh +++ b/bin/tests/system/dnssec/clean.sh @@ -92,4 +92,7 @@ rm -f signer/example.db.after signer/example.db.before rm -f signer/example.db.changed rm -f signer/nsec3param.out rm -f signer/signer.out.* +rm -f signer/general/signed.zone +rm -f signer/general/signer.out.* +rm -f signer/general/dsset* rm -f signing.out* diff --git a/bin/tests/dnssec-signzone/Kexample.com.+005+07065.key b/bin/tests/system/dnssec/signer/general/Kexample.com.+005+07065.key similarity index 100% rename from bin/tests/dnssec-signzone/Kexample.com.+005+07065.key rename to bin/tests/system/dnssec/signer/general/Kexample.com.+005+07065.key diff --git a/bin/tests/dnssec-signzone/Kexample.com.+005+07065.private b/bin/tests/system/dnssec/signer/general/Kexample.com.+005+07065.private similarity index 100% rename from bin/tests/dnssec-signzone/Kexample.com.+005+07065.private rename to bin/tests/system/dnssec/signer/general/Kexample.com.+005+07065.private diff --git a/bin/tests/dnssec-signzone/Kexample.com.+005+23362.key b/bin/tests/system/dnssec/signer/general/Kexample.com.+005+23362.key similarity index 100% rename from bin/tests/dnssec-signzone/Kexample.com.+005+23362.key rename to bin/tests/system/dnssec/signer/general/Kexample.com.+005+23362.key diff --git a/bin/tests/dnssec-signzone/Kexample.com.+005+23362.private b/bin/tests/system/dnssec/signer/general/Kexample.com.+005+23362.private similarity index 100% rename from bin/tests/dnssec-signzone/Kexample.com.+005+23362.private rename to bin/tests/system/dnssec/signer/general/Kexample.com.+005+23362.private diff --git a/bin/tests/dnssec-signzone/bogus-ksk.key b/bin/tests/system/dnssec/signer/general/bogus-ksk.key similarity index 100% rename from bin/tests/dnssec-signzone/bogus-ksk.key rename to bin/tests/system/dnssec/signer/general/bogus-ksk.key diff --git a/bin/tests/dnssec-signzone/bogus-zsk.key b/bin/tests/system/dnssec/signer/general/bogus-zsk.key similarity index 100% rename from bin/tests/dnssec-signzone/bogus-zsk.key rename to bin/tests/system/dnssec/signer/general/bogus-zsk.key diff --git a/bin/tests/dnssec-signzone/test1.zone b/bin/tests/system/dnssec/signer/general/test1.zone similarity index 100% rename from bin/tests/dnssec-signzone/test1.zone rename to bin/tests/system/dnssec/signer/general/test1.zone diff --git a/bin/tests/dnssec-signzone/test2.zone b/bin/tests/system/dnssec/signer/general/test2.zone similarity index 100% rename from bin/tests/dnssec-signzone/test2.zone rename to bin/tests/system/dnssec/signer/general/test2.zone diff --git a/bin/tests/dnssec-signzone/test3.zone b/bin/tests/system/dnssec/signer/general/test3.zone similarity index 100% rename from bin/tests/dnssec-signzone/test3.zone rename to bin/tests/system/dnssec/signer/general/test3.zone diff --git a/bin/tests/dnssec-signzone/test4.zone b/bin/tests/system/dnssec/signer/general/test4.zone similarity index 98% rename from bin/tests/dnssec-signzone/test4.zone rename to bin/tests/system/dnssec/signer/general/test4.zone index a146736a3d..824e52b513 100644 --- a/bin/tests/dnssec-signzone/test4.zone +++ b/bin/tests/system/dnssec/signer/general/test4.zone @@ -1,6 +1,6 @@ ; ; This is a zone which has three DNSKEY records, two (KSK + ZSK) of -; which have existing private key files available. The third is a +; which have existing private key files available. The third is a ; pre-published ZSK. ; $TTL 3600 diff --git a/bin/tests/dnssec-signzone/test5.zone b/bin/tests/system/dnssec/signer/general/test5.zone similarity index 100% rename from bin/tests/dnssec-signzone/test5.zone rename to bin/tests/system/dnssec/signer/general/test5.zone diff --git a/bin/tests/dnssec-signzone/test6.zone b/bin/tests/system/dnssec/signer/general/test6.zone similarity index 100% rename from bin/tests/dnssec-signzone/test6.zone rename to bin/tests/system/dnssec/signer/general/test6.zone diff --git a/bin/tests/dnssec-signzone/test7.zone b/bin/tests/system/dnssec/signer/general/test7.zone similarity index 98% rename from bin/tests/dnssec-signzone/test7.zone rename to bin/tests/system/dnssec/signer/general/test7.zone index e18e7c603e..e42d5aa1de 100644 --- a/bin/tests/dnssec-signzone/test7.zone +++ b/bin/tests/system/dnssec/signer/general/test7.zone @@ -1,5 +1,5 @@ ; -; This is a zone which has two DNSKEY records, none of which have +; This is a zone which has two DNSKEY records, none of which have ; existing private key files available. The resulting zone should fail ; the consistancy tests. ; diff --git a/bin/tests/dnssec-signzone/test8.zone b/bin/tests/system/dnssec/signer/general/test8.zone similarity index 100% rename from bin/tests/dnssec-signzone/test8.zone rename to bin/tests/system/dnssec/signer/general/test8.zone diff --git a/bin/tests/system/dnssec/tests.sh b/bin/tests/system/dnssec/tests.sh index 7a628c9650..70b69e44c8 100644 --- a/bin/tests/system/dnssec/tests.sh +++ b/bin/tests/system/dnssec/tests.sh @@ -1269,6 +1269,103 @@ n=`expr $n + 1` if [ $ret != 0 ]; then echo_i "failed"; fi status=`expr $status + $ret` +echo_i "basic dnssec-signzone checks:" +echo_i " two DNSKEYs ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test1.zone > signer.out.$n 2>&1 +test -f signed.zone +) || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " one non-KSK DNSKEY ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test2.zone > signer.out.$n 2>&1 +test -f signed.zone +) && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " one KSK DNSKEY ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test3.zone > signer.out.$n 2>&1 +test -f signed.zone +) && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " three DNSKEY ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test4.zone > signer.out.$n 2>&1 +test -f signed.zone +) || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " three DNSKEY, one private key missing ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test5.zone > signer.out.$n 2>&1 +test -f signed.zone +) || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " four DNSKEY ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test6.zone > signer.out.$n 2>&1 +test -f signed.zone +) || ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " two DNSKEY, both private keys missing ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test7.zone > signer.out.$n 2>&1 +test -f signed.zone +) && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i " two DNSKEY, one private key missing ($n)" +ret=0 +( +cd signer/general +rm -f signed.zone +$SIGNER -f signed.zone -o example.com. test8.zone > signer.out.$n 2>&1 +test -f signed.zone +) && ret=1 +n=`expr $n + 1` +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + echo_i "checking that we can sign a zone with out-of-zone records ($n)" ret=0 zone=example diff --git a/bin/tests/t_api.pl b/bin/tests/t_api.pl deleted file mode 100644 index d34eaa7bd5..0000000000 --- a/bin/tests/t_api.pl +++ /dev/null @@ -1,217 +0,0 @@ -#!/usr/local/bin/perl -# -# 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_api.pl,v 1.10 2007/06/19 23:46:59 tbox Exp $ - -require "getopts.pl"; - -# -# a minimalistic test api in perl compatable with the C api -# used for the bind 9 regression tests -# - -sub t_info { - package t_api; - local($format, @rest) = @_; - printf("I:${format}%s", @rest); -} - -sub t_result { - package t_api; - local($result) = @_; - $T_inresult = 1; - printf("R:$result\n"); -} - -sub t_assert { - package t_api; - local($component, $anum, $class, $what, @rest) = @_; - printf("A:%s:%d:%s:$what\n", $component, $anum, $class, @rest); -} - -sub t_getenv { - package t_api; - local($name) = @_; - return($T_env{$name}) if (defined($T_env{$name})); -} - -package t_api; - -$| = 1; - -sub t_on_abort { - $T_aborted = 1; - &t_info("got abort\n"); - die; -} - -sub t_on_alarm { - $T_timedout = 1; - &t_info("got alarm\n"); - die; -} - -sub t_on_int { - $T_terminated = 1; - &t_info("got int\n"); - die; -} - -# initialize the test environment -sub t_initconf { - local($cfile) = @_; - local($name, $value); - - if ((-f $cfile) && (-s _)) { - open(XXX, "< $cfile"); - while () { - next if (/^\#/); - next unless (/=/); - chop; - ($name, $value) = split(/=/, $_, 2); - $T_env{$name} = $value; - } - close(XXX); - } -} - -# dump the configuration to the journal -sub t_dumpconf { - local($name, $value); - - foreach $name (sort keys %T_env) { - &main't_info("%s\t%s\n", $name, $T_env{$name}); - } -} - -# run a test -sub doTestN { - package main; - local($testnumber) = @_; - local($status); - - if (defined($T_testlist[$testnumber])) { - - $t_api'T_inresult = 0; - $t_api'T_aborted = 0; - $t_api'T_timedout = 0; - $t_api'T_terminated = 0; - $t_api'T_unresolved = 0; - - alarm($t_api'T_timeout); - $status = eval($T_testlist[$testnumber]); - alarm(0); - - if (! defined($status)) { - &t_info("The test case timed out\n") if ($t_api'T_timedout); - &t_info("The test case was terminated\n") if ($t_api'T_terminated); - &t_info("The test case was aborted\n") if ($t_api'T_aborted); - &t_result("UNRESOLVED"); - } - elsif (! $t_api'T_inresult) { - &t_result("NORESULT"); - } - } - else { - &t_info("Test %d is not defined\n", $testnumber); - &t_result("UNTESTED"); - } -} - -$T_usage = "Usage: - a : run all tests - b : cd to dir before running tests - c : use configfile instead of t_config - d : set debug level to level - h : print test info (not implemented) - u : print usage info - n : run test number testnumber - t : run test named testname (not implemented) - q : use seconds as the timeout value - x : don't execute tests in a subproc (n/a) -"; - -# get command line args -&main'Getopts('ab:c:d:hun:t:q:x'); - -# if -u, print usage and exit -if (defined($main'opt_u)) { - print $T_usage; - exit(0); -} - -# implement -h and -t after we add test descriptions to T_testlist ZZZ -if (defined($main'opt_h)) { - print "the -h option is not implemented\n"; - exit(0); -} - -if (defined($main'opt_t)) { - print "the -t option is not implemented\n"; - exit(0); -} - -# -# silently ignore the -x option -# this exists in the C version of the api -# to facilitate exception debugging with gdb -# and is not meaningful here -# - -$T_configfile = "t_config"; -$T_debug = 0; -$T_timeout = 10; -$T_testnum = -1; - -$T_dir = $main'opt_b if (defined($main'opt_b)); -$T_debug = $main'opt_d if (defined($main'opt_d)); -$T_configfile = $main'opt_c if (defined($main'opt_c)); -$T_testnum = $main'opt_n if (defined($main'opt_n)); -$T_timeout = $main'opt_q if (defined($main'opt_q)); - -$SIG{'ABRT'} = 't_api\'t_on_abort'; -$SIG{'ALRM'} = 't_api\'t_on_alarm'; -$SIG{'INT'} = 't_api\'t_on_int'; -$SIG{'QUIT'} = 't_api\'t_on_int'; - -# print the start line -$date = `date`; -chop $date; -($cmd = $0) =~ s/\.\///g; -printf("S:$cmd:$date\n"); - -# initialize the test environment -&t_initconf($T_configfile); -&t_dumpconf() if ($T_debug); - -# establish working directory if requested -chdir("$T_dir") if (defined($T_dir) && (-d "$T_dir")); - -# run the tests -if ($T_testnum == -1) { - # run all tests - $T_ntests = $#main'T_testlist + 1; - for ($T_cnt = 0; $T_cnt < $T_ntests; ++$T_cnt) { - &doTestN($T_cnt); - } -} -else { - # otherwise run the specified test - &doTest($T_testnum); -} - -# print the end line -$date = `date`; -chop $date; -printf("E:$cmd:$date\n"); - -1; - diff --git a/bin/tests/tasks/Makefile.in b/bin/tests/tasks/Makefile.in deleted file mode 100644 index ba26d59faa..0000000000 --- a/bin/tests/tasks/Makefile.in +++ /dev/null @@ -1,47 +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} ${ISC_INCLUDES} - -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ -TAPIDEPLIBS = ../../../lib/tests/libt_api.@A@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ -TAPILIBS = ../../../lib/tests/libt_api.@A@ - -DEPLIBS = ${TAPIDEPLIBS} ${ISCDEPLIBS} - -LIBS = ${TAPILIBS} ${ISCLIBS} @LIBS@ - -TARGETS = t_tasks@EXEEXT@ - -SRCS = t_tasks.c - -@BIND9_MAKE_RULES@ - -t_tasks@EXEEXT@: t_tasks.@O@ ${DEPLIBS} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_tasks.@O@ ${LIBS} - -test: t_tasks@EXEEXT@ - -@./t_tasks@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -a - -testhelp: - @./t_tasks@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/tasks/t_tasks.c b/bin/tests/tasks/t_tasks.c deleted file mode 100644 index 4b52e3ba4f..0000000000 --- a/bin/tests/tasks/t_tasks.c +++ /dev/null @@ -1,2386 +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_tasks.c,v 1.49 2011/07/27 07:45:55 marka Exp $ */ - -#include - -#include -#include -#ifdef HAVE_INTTYPES_H -#include /* uintptr_t */ -#endif -#include -#include -#include -#include -#include -#include -#include - -#include - - -#ifdef ISC_PLATFORM_USETHREADS -isc_boolean_t threaded = ISC_TRUE; -#else -isc_boolean_t threaded = ISC_FALSE; -#endif - -static int senders[4]; - -static void -require_threads(void) { - t_info("This test requires threads\n"); - t_result(T_THREADONLY); - return; -} - -static void -t1_callback(isc_task_t *task, isc_event_t *event) { - int i; - int j; - - UNUSED(task); - - j = 0; - - for (i = 0; i < 1000000; i++) - j += 100; - - t_info("task %s\n", (char *)event->ev_arg); - isc_event_free(&event); -} - -static void -t1_shutdown(isc_task_t *task, isc_event_t *event) { - - UNUSED(task); - - t_info("shutdown %s\n", (char *)event->ev_arg); - isc_event_free(&event); -} - -static void -my_tick(isc_task_t *task, isc_event_t *event) { - - UNUSED(task); - - t_info("%s\n", (char *)event->ev_arg); - isc_event_free(&event); -} - -/* - * Adapted from RTH's original task_test program - */ - -static char one[] = "1"; -static char two[] = "2"; -static char three[] = "3"; -static char four[] = "4"; -static char tick[] = "tick"; -static char tock[] = "tock"; - -static int -t_tasks1(void) { - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *manager; - isc_task_t *task1; - isc_task_t *task2; - isc_task_t *task3; - isc_task_t *task4; - isc_event_t *event; - unsigned int workers; - isc_timermgr_t *timgr; - isc_timer_t *ti1; - isc_timer_t *ti2; - isc_result_t isc_result; - isc_time_t absolute; - isc_interval_t interval; - - manager = NULL; - task1 = NULL; - task2 = NULL; - task3 = NULL; - task4 = NULL; - mctx = NULL; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - if (workers < 1) { - t_info("Bad config value for ISC_TASK_WORKERS, %d\n", workers); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - isc_result = isc_taskmgr_create(mctx, workers, 0, &manager); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_create(manager, 0, &task1); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_create(manager, 0, &task2); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_create(manager, 0, &task3); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_create(manager, 0, &task4); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_onshutdown(task1, t1_shutdown, one); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_onshutdown(task2, t1_shutdown, two); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_onshutdown(task3, t1_shutdown, three); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %d\n", isc_result); - return(T_FAIL); - } - - isc_result = isc_task_onshutdown(task4, t1_shutdown, four); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %d\n", isc_result); - return(T_FAIL); - } - - timgr = NULL; - isc_result = isc_timermgr_create(mctx, &timgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timermgr_create %d\n", isc_result); - return(T_UNRESOLVED); - } - - ti1 = NULL; - isc_time_settoepoch(&absolute); - isc_interval_set(&interval, 1, 0); - isc_result = isc_timer_create(timgr, isc_timertype_ticker, - &absolute, &interval, - task1, my_tick, tick, &ti1); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timer_create %d\n", isc_result); - return(T_UNRESOLVED); - } - - ti2 = NULL; - isc_time_settoepoch(&absolute); - isc_interval_set(&interval, 1, 0); - isc_result = isc_timer_create(timgr, isc_timertype_ticker, - &absolute, &interval, - task2, my_tick, tock, &ti2); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timer_create %d\n", isc_result); - return(T_UNRESOLVED); - } - - -#ifndef WIN32 - sleep(2); -#else - Sleep(2000); -#endif - - /* - * Note: (void *)1 is used as a sender here, since some compilers - * don't like casting a function pointer to a (void *). - * - * In a real use, it is more likely the sender would be a - * structure (socket, timer, task, etc) but this is just a test - * program. - */ - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, one, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task1, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, two, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task2, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, three, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task3, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, four, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task4, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, two, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task2, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, three, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task3, &event); - - event = isc_event_allocate(mctx, (void *)1, 1, t1_callback, four, - sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_task_send(task4, &event); - - (void)isc_task_purge(task3, NULL, 0, 0); - - isc_task_detach(&task1); - isc_task_detach(&task2); - isc_task_detach(&task3); - isc_task_detach(&task4); - -#ifndef WIN32 - sleep(10); -#else - Sleep(10000); -#endif - isc_timer_detach(&ti1); - isc_timer_detach(&ti2); - isc_timermgr_destroy(&timgr); - isc_taskmgr_destroy(&manager); - - isc_mem_destroy(&mctx); - return(T_PASS); -} - -static const char *a1 = "The task subsystem can create and manage tasks"; - -static void -t1(void) { - int result; - - t_assert("tasks", 1, T_REQUIRED, "%s", a1); - result = t_tasks1(); - t_result(result); -} - -#define T2_NTASKS 10000 - -static isc_event_t *T2_event; -static isc_taskmgr_t *T2_manager; -static isc_mem_t *T2_mctx; -static isc_condition_t T2_cv; -static isc_mutex_t T2_mx; -static int T2_done; -static int T2_nprobs; -static int T2_nfails; -static int T2_ntasks; - -static void -t2_shutdown(isc_task_t *task, isc_event_t *event) { - - isc_result_t isc_result; - - UNUSED(task); - - if (event->ev_arg != NULL) { - isc_task_destroy((isc_task_t**) &event->ev_arg); - } - else { - isc_result = isc_mutex_lock(&T2_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %d\n", isc_result); - ++T2_nprobs; - } - - T2_done = 1; - - isc_result = isc_condition_signal(&T2_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %d\n", isc_result); - ++T2_nprobs; - } - - isc_result = isc_mutex_unlock(&T2_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %d\n", isc_result); - ++T2_nprobs; - } - - isc_event_free(&T2_event); - isc_taskmgr_destroy(&T2_manager); - isc_mem_destroy(&T2_mctx); - } -} - -static void -t2_callback(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - isc_task_t *newtask; - - ++T2_ntasks; - - if (T_debug && ((T2_ntasks % 100) == 0)) { - t_info("T2_ntasks %d\n", T2_ntasks); - } - - if (event->ev_arg) { - - event->ev_arg = (void *)(((uintptr_t) event->ev_arg) - 1); - - /* - * Create a new task and forward the message. - */ - newtask = NULL; - isc_result = isc_task_create(T2_manager, 0, &newtask); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %d\n", isc_result); - ++T2_nfails; - return; - } - - isc_result = isc_task_onshutdown(newtask, t2_shutdown, - (void *)task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %d\n", - isc_result); - ++T2_nfails; - return; - } - - isc_task_send(newtask, &event); - } else { - /* - * Time to unwind, shutdown should perc back up. - */ - isc_task_destroy(&task); - } -} - -static int -t_tasks2(void) { - uintptr_t ntasks; - int result; - char *p; - unsigned int workers; - isc_result_t isc_result; - - T2_manager = NULL; - T2_done = 0; - T2_nprobs = 0; - T2_nfails = 0; - T2_ntasks = 0; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - if (workers < 1) { - t_info("Bad config value for ISC_TASK_WORKERS, %d\n", workers); - return(T_UNRESOLVED); - } - - p = t_getenv("ISC_TASKS_MIN"); - if (p != NULL) - ntasks = atoi(p); - else - ntasks = T2_NTASKS; - if (ntasks == 0U) { - t_info("Bad config value for ISC_TASKS_MIN, %lu\n", - (unsigned long)ntasks); - return(T_UNRESOLVED); - } - - t_info("Testing with %lu tasks\n", (unsigned long)ntasks); - - isc_result = isc_mutex_init(&T2_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_init(&T2_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &T2_mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - isc_result = isc_taskmgr_create(T2_mctx, workers, 0, &T2_manager); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %d\n", isc_result); - return(T_FAIL); - } - - T2_event = isc_event_allocate(T2_mctx, (void *)1, 1, t2_callback, - (void *)ntasks, sizeof(*T2_event)); - if (T2_event == NULL) { - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - - isc_result = isc_mutex_lock(&T2_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - t2_callback(NULL, T2_event); - - while (T2_done == 0) { - isc_result = isc_condition_wait(&T2_cv, &T2_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_wait failed %d\n", isc_result); - return(T_UNRESOLVED); - } - } - - result = T_UNRESOLVED; - - if ((T2_nfails == 0) && (T2_nprobs == 0)) - result = T_PASS; - else if (T2_nfails != 0) - result = T_FAIL; - - return(result); -} - -static const char *a2 = "The task subsystem can create ISC_TASKS_MIN tasks"; - -static void -t2(void) { - t_assert("tasks", 2, T_REQUIRED, "%s", a2); - - if (threaded) - t_result(t_tasks2()); - else - require_threads(); -} - -#define T3_NEVENTS 256 - -static int T3_flag; -static int T3_nevents; -static int T3_nsdevents; -static isc_mutex_t T3_mx; -static isc_condition_t T3_cv; -static int T3_nfails; -static int T3_nprobs; - -static void -t3_sde1(isc_task_t *task, isc_event_t *event) { - - UNUSED(task); - - if (T3_nevents != T3_NEVENTS) { - t_info("Some events were not processed\n"); - ++T3_nprobs; - } - if (T3_nsdevents == 1) { - ++T3_nsdevents; - } else { - t_info("Shutdown events not processed in LIFO order\n"); - ++T3_nfails; - } - isc_event_free(&event); -} - -static void -t3_sde2(isc_task_t *task, isc_event_t *event) { - - UNUSED(task); - - if (T3_nevents != T3_NEVENTS) { - t_info("Some events were not processed\n"); - ++T3_nprobs; - } - if (T3_nsdevents == 0) { - ++T3_nsdevents; - } else { - t_info("Shutdown events not processed in LIFO order\n"); - ++T3_nfails; - } - isc_event_free(&event); -} - -static void -t3_event1(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T3_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T3_nprobs; - } - while (T3_flag != 1) { - (void) isc_condition_wait(&T3_cv, &T3_mx); - } - - isc_result = isc_mutex_unlock(&T3_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T3_nprobs; - } - isc_event_free(&event); -} - -static void -t3_event2(isc_task_t *task, isc_event_t *event) { - UNUSED(task); - - ++T3_nevents; - isc_event_free(&event); -} - -static int -t_tasks3(void) { - int cnt; - int result; - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - isc_task_t *task; - unsigned int workers; - isc_event_t *event; - isc_result_t isc_result; - isc_eventtype_t event_type; - - T3_flag = 0; - T3_nevents = 0; - T3_nsdevents = 0; - T3_nfails = 0; - T3_nprobs = 0; - - event_type = 3; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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_mutex_init(&T3_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_init(&T3_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_mutex_lock(&T3_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - task = NULL; - isc_result = isc_task_create(tmgr, 0, &task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - (void) isc_mutex_unlock(&T3_mx); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * This event causes the task to wait on T3_cv. - */ - event = isc_event_allocate(mctx, &senders[1], event_type, t3_event1, - NULL, sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - (void) isc_mutex_unlock(&T3_mx); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - isc_task_send(task, &event); - - /* - * Now we fill up the task's event queue with some events. - */ - for (cnt = 0; cnt < T3_NEVENTS; ++cnt) { - event = isc_event_allocate(mctx, &senders[1], event_type, - t3_event2, NULL, sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - (void) isc_mutex_unlock(&T3_mx); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - isc_task_send(task, &event); - } - - /* - * Now we register two shutdown events. - */ - isc_result = isc_task_onshutdown(task, t3_sde1, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_send failed %s\n", - isc_result_totext(isc_result)); - (void) isc_mutex_unlock(&T3_mx); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_task_onshutdown(task, t3_sde2, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_send failed %s\n", - isc_result_totext(isc_result)); - (void) isc_mutex_unlock(&T3_mx); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_task_shutdown(task); - - /* - * Now we free the task by signaling T3_cv. - */ - T3_flag = 1; - isc_result = isc_condition_signal(&T3_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T3_nprobs; - } - - isc_result = isc_mutex_unlock(&T3_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T3_nprobs; - } - - - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - - if (T3_nsdevents != 2) { - t_info("T3_nsdevents == %d, expected 2\n", T3_nsdevents); - ++T3_nfails; - } - - result = T_UNRESOLVED; - - if (T3_nfails != 0) - result = T_FAIL; - else if ((T3_nfails == 0) && (T3_nprobs == 0)) - result = T_PASS; - - return(result); -} - -static const char *a3 = "When isc_task_shutdown() is called, any shutdown " - "events that have been requested via prior " - "isc_task_onshutdown() calls are posted in " - "LIFO order."; -static void -t3(void) { - t_assert("tasks", 3, T_REQUIRED, "%s", a3); - - if (threaded) - t_result(t_tasks3()); - else - require_threads(); -} - -static isc_mutex_t T4_mx; -static isc_condition_t T4_cv; -static int T4_flag; -static int T4_nprobs; -static int T4_nfails; - -static void -t4_event1(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T4_nprobs; - } - while (T4_flag != 1) { - (void) isc_condition_wait(&T4_cv, &T4_mx); - } - - isc_result = isc_mutex_unlock(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T4_nprobs; - } - isc_event_free(&event); -} - -static void -t4_sde(isc_task_t *task, isc_event_t *event) { - UNUSED(task); - - /* - * No-op. - */ - - isc_event_free(&event); -} - -static int -t_tasks4(void) { - int result; - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - isc_task_t *task; - unsigned int workers; - isc_result_t isc_result; - isc_eventtype_t event_type; - isc_event_t *event; - - T4_nprobs = 0; - T4_nfails = 0; - T4_flag = 0; - - event_type = 4; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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_mutex_init(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_init(&T4_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T4_mx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T4_mx); - (void) isc_condition_destroy(&T4_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_mutex_lock(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T4_mx); - (void) isc_condition_destroy(&T4_cv); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - task = NULL; - isc_result = isc_task_create(tmgr, 0, &task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - isc_result = isc_mutex_unlock(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T4_nprobs; - } - DESTROYLOCK(&T4_mx); - (void) isc_condition_destroy(&T4_cv); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - /* - * This event causes the task to wait on T4_cv. - */ - event = isc_event_allocate(mctx, &senders[1], event_type, t4_event1, - NULL, sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - isc_result = isc_mutex_unlock(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T4_nprobs; - } - DESTROYLOCK(&T4_mx); - isc_task_destroy(&task); - (void) isc_condition_destroy(&T4_cv); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - isc_task_send(task, &event); - - isc_task_shutdown(task); - - isc_result = isc_task_onshutdown(task, t4_sde, NULL); - if (isc_result != ISC_R_SHUTTINGDOWN) { - t_info("isc_task_onshutdown returned %s\n", - isc_result_totext(isc_result)); - ++T4_nfails; - } - - /* - * Release the task. - */ - T4_flag = 1; - - isc_result = isc_condition_signal(&T4_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T4_nprobs; - } - - isc_result = isc_mutex_unlock(&T4_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T4_nprobs; - } - - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - (void) isc_condition_destroy(&T4_cv); - DESTROYLOCK(&T4_mx); - - result = T_UNRESOLVED; - - if (T4_nfails != 0) - result = T_FAIL; - else if ((T4_nfails == 0) && (T4_nprobs == 0)) - result = T_PASS; - - return(result); -} - -static const char *a4 = - "After isc_task_shutdown() has been called, any call to " - "isc_task_onshutdown() will return ISC_R_SHUTTINGDOWN."; - -static void -t4(void) { - t_assert("tasks", 4, T_REQUIRED, "%s", a4); - - if (threaded) - t_result(t_tasks4()); - else - require_threads(); -} - -static int T7_nprobs; -static int T7_eflag; -static int T7_sdflag; -static isc_mutex_t T7_mx; -static isc_condition_t T7_cv; - -static int T7_nfails; - -static void -t7_event1(isc_task_t *task, isc_event_t *event) { - UNUSED(task); - - ++T7_eflag; - - isc_event_free(&event); -} - -static void -t7_sde(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T7_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T7_nprobs; - } - - ++T7_sdflag; - - isc_result = isc_condition_signal(&T7_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T7_nprobs; - } - - isc_result = isc_mutex_unlock(&T7_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T7_nprobs; - } - - isc_event_free(&event); -} - -static int -t_tasks7(void) { - int result; - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - isc_task_t *task; - unsigned int workers; - isc_result_t isc_result; - isc_eventtype_t event_type; - isc_event_t *event; - isc_time_t now; - isc_interval_t interval; - - T7_nprobs = 0; - T7_nfails = 0; - T7_sdflag = 0; - T7_eflag = 0; - - event_type = 7; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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_mutex_init(&T7_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_init(&T7_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_mutex_lock(&T7_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - task = NULL; - isc_result = isc_task_create(tmgr, 0, &task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - - isc_result = isc_task_onshutdown(task, t7_sde, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown returned %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - event = isc_event_allocate(mctx, &senders[1], event_type, t7_event1, - NULL, sizeof(*event)); - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - isc_task_send(task, &event); - - isc_task_shutdown(task); - - isc_interval_set(&interval, 5, 0); - - while (T7_sdflag == 0) { - isc_result = isc_time_nowplusinterval(&now, &interval); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_nowplusinterval failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_waituntil(&T7_cv, &T7_mx, &now); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_waituntil returned %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T7_mx); - (void) isc_condition_destroy(&T7_cv); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - return(T_FAIL); - } - } - - isc_result = isc_mutex_unlock(&T7_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T7_nprobs; - } - - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - (void) isc_condition_destroy(&T7_cv); - DESTROYLOCK(&T7_mx); - - result = T_UNRESOLVED; - - if (T7_eflag == 0) - ++T7_nfails; - - if (T7_nfails != 0) - result = T_FAIL; - else if ((T7_nfails == 0) && (T7_nprobs == 0)) - result = T_PASS; - - return(result); -} - -static const char *a7 = "A call to isc_task_create() creates a task that can " - "receive events."; - -static void -t7(void) { - t_assert("tasks", 7, T_REQUIRED, "%s", a7); - - if (threaded) - t_result(t_tasks7()); - else - require_threads(); -} - -#define T10_SENDERCNT 3 -#define T10_TYPECNT 4 -#define T10_TAGCNT 5 -#define T10_NEVENTS (T10_SENDERCNT*T10_TYPECNT*T10_TAGCNT) -#define T_CONTROL 99999 - -static int T10_nprobs; -static int T10_nfails; -static int T10_startflag; -static int T10_shutdownflag; -static int T10_eventcnt; -static isc_mutex_t T10_mx; -static isc_condition_t T10_cv; - -static void *T10_purge_sender; -static isc_eventtype_t T10_purge_type_first; -static isc_eventtype_t T10_purge_type_last; -static void *T10_purge_tag; -static int T10_testrange; - -static void -t10_event1(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T10_nprobs; - } - - while (T10_startflag == 0) { - isc_result = isc_condition_wait(&T10_cv, &T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T10_nprobs; - } - } - - isc_result = isc_mutex_unlock(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T10_nprobs; - } - - isc_event_free(&event); -} - -static void -t10_event2(isc_task_t *task, isc_event_t *event) { - - int sender_match; - int type_match; - int tag_match; - - UNUSED(task); - - sender_match = 0; - type_match = 0; - tag_match = 0; - - if (T_debug) { - t_info("Event %p,%d,%p,%s\n", - event->ev_sender, - (int)event->ev_type, - event->ev_tag, - ((event->ev_attributes & ISC_EVENTATTR_NOPURGE) != 0) ? - "NP" : "P"); - } - - if ((T10_purge_sender == NULL) || - (T10_purge_sender == event->ev_sender)) { - sender_match = 1; - } - if (T10_testrange == 0) { - if (T10_purge_type_first == event->ev_type) { - type_match = 1; - } - } else { - if ((T10_purge_type_first <= event->ev_type) && - (event->ev_type <= T10_purge_type_last)) { - type_match = 1; - } - } - if ((T10_purge_tag == NULL) || - (T10_purge_tag == event->ev_tag)) { - tag_match = 1; - } - - if (sender_match && type_match && tag_match) { - if (event->ev_attributes & ISC_EVENTATTR_NOPURGE) { - t_info("event %p,%d,%p matched but was not purgable\n", - event->ev_sender, (int)event->ev_type, - event->ev_tag); - ++T10_eventcnt; - } else { - t_info("*** event %p,%d,%p not purged\n", - event->ev_sender, (int)event->ev_type, - event->ev_tag); - } - } else { - ++T10_eventcnt; - } - isc_event_free(&event); -} - - -static void -t10_sde(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T10_nprobs; - } - - ++T10_shutdownflag; - - isc_result = isc_condition_signal(&T10_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T10_nprobs; - } - - isc_result = isc_mutex_unlock(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T10_nprobs; - } - - isc_event_free(&event); -} - -static void -t_taskpurge_x(int sender, int type, int tag, void *purge_sender, - int purge_type_first, int purge_type_last, void *purge_tag, - int exp_nevents, int *nfails, int *nprobs, int testrange) -{ - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - isc_task_t *task; - unsigned int workers; - isc_result_t isc_result; - isc_event_t *event; - isc_time_t now; - isc_interval_t interval; - int sender_cnt; - int type_cnt; - int tag_cnt; - int event_cnt; - int cnt; - int nevents; - isc_event_t *eventtab[T10_NEVENTS]; - - - T10_startflag = 0; - T10_shutdownflag = 0; - T10_eventcnt = 0; - T10_purge_sender = purge_sender; - T10_purge_type_first = (isc_eventtype_t) purge_type_first; - T10_purge_type_last = (isc_eventtype_t) purge_type_last; - T10_purge_tag = purge_tag; - T10_testrange = testrange; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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)); - ++*nprobs; - return; - } - - isc_result = isc_mutex_init(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - ++*nprobs; - return; - } - - isc_result = isc_condition_init(&T10_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - ++*nprobs; - return; - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - - task = NULL; - isc_result = isc_task_create(tmgr, 0, &task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - - isc_result = isc_task_onshutdown(task, t10_sde, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown returned %s\n", - isc_result_totext(isc_result)); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - - /* - * Block the task on T10_cv. - */ - event = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)T_CONTROL, - t10_event1, NULL, sizeof(*event)); - - if (event == NULL) { - t_info("isc_event_allocate failed\n"); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - isc_task_send(task, &event); - - /* - * Fill the task's queue with some messages with varying - * sender, type, tag, and purgable attribute values. - */ - - event_cnt = 0; - for (sender_cnt = 0; sender_cnt < T10_SENDERCNT; ++sender_cnt) { - for (type_cnt = 0; type_cnt < T10_TYPECNT; ++type_cnt) { - for (tag_cnt = 0; tag_cnt < T10_TAGCNT; ++tag_cnt) { - eventtab[event_cnt] = - isc_event_allocate(mctx, - &senders[sender + sender_cnt], - (isc_eventtype_t)(type + type_cnt), - t10_event2, NULL, sizeof(*event)); - - if (eventtab[event_cnt] == NULL) { - t_info("isc_event_allocate failed\n"); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - - eventtab[event_cnt]->ev_tag = - (void *)((uintptr_t)tag + tag_cnt); - - /* - * Make all odd message non-purgable. - */ - if ((sender_cnt % 2) && (type_cnt %2) && - (tag_cnt %2)) - eventtab[event_cnt]->ev_attributes |= - ISC_EVENTATTR_NOPURGE; - ++event_cnt; - } - } - } - - for (cnt = 0; cnt < event_cnt; ++cnt) - isc_task_send(task, &eventtab[cnt]); - - if (T_debug) - t_info("%d events queued\n", cnt); - - if (testrange == 0) { - /* - * We're testing isc_task_purge. - */ - nevents = isc_task_purge(task, purge_sender, - (isc_eventtype_t)purge_type_first, - purge_tag); - if (nevents != exp_nevents) { - t_info("*** isc_task_purge returned %d, expected %d\n", - nevents, exp_nevents); - ++*nfails; - } else if (T_debug) - t_info("isc_task_purge returned %d\n", nevents); - } else { - /* - * We're testing isc_task_purgerange. - */ - nevents = isc_task_purgerange(task, purge_sender, - (isc_eventtype_t)purge_type_first, - (isc_eventtype_t)purge_type_last, - purge_tag); - if (nevents != exp_nevents) { - t_info("*** isc_task_purgerange returned %d, " - "expected %d\n", nevents, exp_nevents); - ++*nfails; - } else if (T_debug) - t_info("isc_task_purgerange returned %d\n", nevents); - } - - isc_result = isc_mutex_lock(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - - /* - * Unblock the task, allowing event processing. - */ - T10_startflag = 1; - isc_result = isc_condition_signal(&T10_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++*nprobs; - } - - isc_task_shutdown(task); - - isc_interval_set(&interval, 5, 0); - - /* - * Wait for shutdown processing to complete. - */ - while (T10_shutdownflag == 0) { - isc_result = isc_time_nowplusinterval(&now, &interval); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_nowplusinterval failed %s\n", - isc_result_totext(isc_result)); - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nprobs; - return; - } - - isc_result = isc_condition_waituntil(&T10_cv, &T10_mx, &now); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_waituntil returned %s\n", - isc_result_totext(isc_result)); - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - ++*nfails; - return; - } - } - - isc_result = isc_mutex_unlock(&T10_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++*nprobs; - } - - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T10_mx); - (void) isc_condition_destroy(&T10_cv); - - if (T_debug) - t_info("task processed %d events\n", T10_eventcnt); - - if ((T10_eventcnt + nevents) != event_cnt) { - t_info("*** processed %d, purged %d, total %d\n", - T10_eventcnt, nevents, event_cnt); - ++*nfails; - } -} - -static int -t_tasks10(void) { - int result; - - T10_nprobs = 0; - T10_nfails = 0; - - /* - * Try purging on a specific sender. - */ - t_info("testing purge on 2,4,8 expecting 1\n"); - t_taskpurge_x(1, 4, 7, &senders[2], 4, 4, (void *)8, 1, &T10_nfails, - &T10_nprobs, 0); - - /* - * Try purging on all senders. - */ - t_info("testing purge on 0,4,8 expecting 3\n"); - t_taskpurge_x(1, 4, 7, NULL, 4, 4, (void *)8, 3, &T10_nfails, - &T10_nprobs, 0); - - /* - * Try purging on all senders, specified type, all tags. - */ - t_info("testing purge on 0,4,0 expecting 15\n"); - t_taskpurge_x(1, 4, 7, NULL, 4, 4, NULL, 15, &T10_nfails, - &T10_nprobs, 0); - - /* - * Try purging on a specified tag, no such type. - */ - t_info("testing purge on 0,99,8 expecting 0\n"); - t_taskpurge_x(1, 4, 7, NULL, 99, 99, (void *)8, 0, &T10_nfails, - &T10_nprobs, 0); - - /* - * Try purging on specified sender, type, all tags. - */ - t_info("testing purge on 0,5,0 expecting 5\n"); - t_taskpurge_x(1, 4, 7, &senders[3], 5, 5, NULL, 5, &T10_nfails, - &T10_nprobs, 0); - - result = T_UNRESOLVED; - - if ((T10_nfails == 0) && (T10_nprobs == 0)) - result = T_PASS; - else if (T10_nfails != 0) - result = T_FAIL; - - return(result); -} - -static const char *a10 = - "A call to isc_task_purge(task, sender, type, tag) " - "purges all events of type 'type' and with tag 'tag' " - "not marked as unpurgable from sender from the task's " - "queue and returns the number of events purged."; - -static void -t10(void) { - t_assert("tasks", 10, T_REQUIRED, "%s", a10); - - if (threaded) - t_result(t_tasks10()); - else - require_threads(); -} - -static int T11_nprobs; -static int T11_nfails; -static int T11_startflag; -static int T11_shutdownflag; -static int T11_eventcnt; -static isc_mutex_t T11_mx; -static isc_condition_t T11_cv; - -static void -t11_event1(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - while (T11_startflag == 0) { - isc_result = isc_condition_wait(&T11_cv, &T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - } - - isc_result = isc_mutex_unlock(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - isc_event_free(&event); -} - -static void -t11_event2(isc_task_t *task, isc_event_t *event) { - UNUSED(task); - - ++T11_eventcnt; - isc_event_free(&event); -} - - -static void -t11_sde(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - isc_result = isc_mutex_lock(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - ++T11_shutdownflag; - - isc_result = isc_condition_signal(&T11_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - isc_result = isc_mutex_unlock(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - isc_event_free(&event); -} - -static int -t_tasks11(int purgable) { - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - isc_task_t *task; - isc_boolean_t rval; - unsigned int workers; - isc_result_t isc_result; - isc_event_t *event1; - isc_event_t *event2, *event2_clone; - isc_time_t now; - isc_interval_t interval; - int result; - - T11_startflag = 0; - T11_shutdownflag = 0; - T11_eventcnt = 0; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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_mutex_init(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_init(&T11_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - return(T_UNRESOLVED); - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - (void) isc_condition_destroy(&T11_cv); - return(T_UNRESOLVED); - } - - task = NULL; - isc_result = isc_task_create(tmgr, 0, &task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - (void) isc_condition_destroy(&T11_cv); - return(T_UNRESOLVED); - } - - isc_result = isc_task_onshutdown(task, t11_sde, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown returned %s\n", - isc_result_totext(isc_result)); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - (void) isc_condition_destroy(&T11_cv); - return(T_UNRESOLVED); - } - - /* - * Block the task on T11_cv. - */ - event1 = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)1, - t11_event1, NULL, sizeof(*event1)); - if (event1 == NULL) { - t_info("isc_event_allocate failed\n"); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - (void) isc_condition_destroy(&T11_cv); - return(T_UNRESOLVED); - } - isc_task_send(task, &event1); - - event2 = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)1, - t11_event2, NULL, sizeof(*event2)); - if (event2 == NULL) { - t_info("isc_event_allocate failed\n"); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - (void) isc_condition_destroy(&T11_cv); - return(T_UNRESOLVED); - } - event2_clone = event2; - if (purgable) - event2->ev_attributes &= ~ISC_EVENTATTR_NOPURGE; - else - event2->ev_attributes |= ISC_EVENTATTR_NOPURGE; - - isc_task_send(task, &event2); - - rval = isc_task_purgeevent(task, event2_clone); - if (rval != (purgable ? ISC_TRUE : ISC_FALSE)) { - t_info("isc_task_purgeevent returned %s, expected %s\n", - (rval ? "ISC_TRUE" : "ISC_FALSE"), - (purgable ? "ISC_TRUE" : "ISC_FALSE")); - ++T11_nfails; - } - - isc_result = isc_mutex_lock(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - /* - * Unblock the task, allowing event processing. - */ - T11_startflag = 1; - isc_result = isc_condition_signal(&T11_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - isc_task_shutdown(task); - - isc_interval_set(&interval, 5, 0); - - /* - * Wait for shutdown processing to complete. - */ - while (T11_shutdownflag == 0) { - isc_result = isc_time_nowplusinterval(&now, &interval); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_nowplusinterval failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - isc_result = isc_condition_waituntil(&T11_cv, &T11_mx, &now); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_waituntil returned %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - } - - isc_result = isc_mutex_unlock(&T11_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T11_nprobs; - } - - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_mem_destroy(&mctx); - DESTROYLOCK(&T11_mx); - (void) isc_condition_destroy(&T11_cv); - - if (T11_eventcnt != (purgable ? 0 : 1)) { - t_info("Event was %s purged\n", - (purgable ? "not" : "unexpectedly")); - ++T11_nfails; - } - - result = T_UNRESOLVED; - - if ((T11_nfails == 0) && (T11_nprobs == 0)) - result = T_PASS; - else if (T11_nfails) - result = T_FAIL; - - return(result); -} - -static const char *a11 = - "When the event is marked as purgable, a call to " - "isc_task_purgeevent(task, event) purges the event 'event' " - "from the task's queue and returns ISC_TRUE."; - -static void -t11(void) { - t_assert("tasks", 11, T_REQUIRED, "%s", a11); - - if (threaded) - t_result(t_tasks11(1)); - else - require_threads(); -} - -static const char *a12 = - "When the event is not marked as purgable, a call to " - "isc_task_purgeevent(task, event) does not purge the " - "event 'event' from the task's queue and returns " - "ISC_FALSE."; - -static int -t_tasks12(void) { - return(t_tasks11(0)); -} - -static void -t12(void) { - t_assert("tasks", 12, T_REQUIRED, "%s", a12); - - if (threaded) - t_result(t_tasks12()); - else - require_threads(); -} - -static int T13_nfails; -static int T13_nprobs; - -static const char *a13 = - "A call to " - "isc_event_purgerange(task, sender, first, last, tag) " - "purges all events not marked unpurgable from " - "sender 'sender' and of type within the range 'first' " - "to 'last' inclusive from the task's event queue and " - "returns the number of tasks purged."; - -static int -t_tasks13(void) { - int result; - - T13_nfails = 0; - T13_nprobs = 0; - - /* - * First let's try the same cases we used in t10. - */ - - /* - * Try purging on a specific sender. - */ - t_info("testing purge on 2,4,8 expecting 1\n"); - t_taskpurge_x(1, 4, 7, &senders[2], 4, 4, (void *)8, 1, - &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on all senders. - */ - t_info("testing purge on 0,4,8 expecting 3\n"); - t_taskpurge_x(1, 4, 7, NULL, 4, 4, (void *)8, 3, - &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on all senders, specified type, all tags. - */ - t_info("testing purge on 0,4,0 expecting 15\n"); - t_taskpurge_x(1, 4, 7, NULL, 4, 4, NULL, 15, &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on a specified tag, no such type. - */ - t_info("testing purge on 0,99,8 expecting 0\n"); - t_taskpurge_x(1, 4, 7, NULL, 99, 99, (void *)8, 0, - &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on specified sender, type, all tags. - */ - t_info("testing purge on 3,5,0 expecting 5\n"); - t_taskpurge_x(1, 4, 7, &senders[3], 5, 5, 0, 5, &T13_nfails, &T13_nprobs, 1); - - /* - * Now let's try some ranges. - */ - - t_info("testing purgerange on 2,4-5,8 expecting 2\n"); - t_taskpurge_x(1, 4, 7, &senders[2], 4, 5, (void *)8, 1, - &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on all senders. - */ - t_info("testing purge on 0,4-5,8 expecting 5\n"); - t_taskpurge_x(1, 4, 7, NULL, 4, 5, (void *)8, 5, - &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on all senders, specified type, all tags. - */ - t_info("testing purge on 0,5-6,0 expecting 28\n"); - t_taskpurge_x(1, 4, 7, NULL, 5, 6, NULL, 28, &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on a specified tag, no such type. - */ - t_info("testing purge on 0,99-101,8 expecting 0\n"); - t_taskpurge_x(1, 4, 7, NULL, 99, 101, (void *)8, 0, - &T13_nfails, &T13_nprobs, 1); - - /* - * Try purging on specified sender, type, all tags. - */ - t_info("testing purge on 3,5-6,0 expecting 10\n"); - t_taskpurge_x(1, 4, 7, &senders[3], 5, 6, NULL, 10, &T13_nfails, - &T13_nprobs, 1); - - result = T_UNRESOLVED; - - if ((T13_nfails == 0) && (T13_nprobs == 0)) - result = T_PASS; - else if (T13_nfails) - result = T_FAIL; - - return (result); -} - -static void -t13(void) { - t_assert("tasks", 13, T_REQUIRED, "%s", a13); - - if (threaded) - t_result(t_tasks13()); - else - require_threads(); -} - -#define T14_NTASKS 10 -#define T14_EXCLTASK 6 - -int t14_exclusiveerror = ISC_R_SUCCESS; -int t14_error = 0; -int t14_done = 0; - -int spin(int n); - -int t14_active[T14_NTASKS]; - -static void -t14_callback(isc_task_t *task, isc_event_t *event) { - int taskno = *(int *)(event->ev_arg); - - - t_info("task enter %d\n", taskno); - if (taskno == T14_EXCLTASK) { - int i; - t14_exclusiveerror = isc_task_beginexclusive(task); - if (t14_exclusiveerror == ISC_R_SUCCESS) - t_info("task %d got exclusive access\n", taskno); - else - t_info("task %d failed to got exclusive access: %d\n", - taskno, t14_exclusiveerror); - for (i = 0; i < T14_NTASKS; i++) { - t_info("task %d state %d\n", i , t14_active[i]); - if (t14_active[i]) - t14_error++; - } - isc_task_endexclusive(task); - t14_done = 1; - } else { - t14_active[taskno]++; - (void) spin(10000000); - t14_active[taskno]--; - } - t_info("task exit %d\n", taskno); - if (t14_done) { - isc_mem_put(event->ev_destroy_arg, event->ev_arg, sizeof (int)); - isc_event_free(&event); - } else { - isc_task_send(task, &event); - } -} - -int spin(int n) { - int i; - int r = 0; - for (i = 0; i < n; i++) { - r += i; - if (r > 1000000) - r = 0; - } - return (r); -} - -static int -t_tasks14(void) { - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *manager; - isc_task_t *tasks[T14_NTASKS]; - unsigned int workers; - isc_result_t isc_result; - int i; - - manager = NULL; - mctx = NULL; - - for (i = 0; i < T14_NTASKS; i++) - tasks[i] = NULL; - - workers = 4; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - if (workers < 1) { - t_info("Bad config value for ISC_TASK_WORKERS, %d\n", workers); - return(T_UNRESOLVED); - } - - isc_result = isc_mem_create(0, 0, &mctx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mem_create failed %d\n", isc_result); - return(T_UNRESOLVED); - } - - isc_result = isc_taskmgr_create(mctx, workers, 0, &manager); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %d\n", isc_result); - return(T_FAIL); - } - - for (i = 0; i < T14_NTASKS; i++) { - isc_event_t *event; - int *v; - - isc_result = isc_task_create(manager, 0, &tasks[i]); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %d\n", isc_result); - return(T_FAIL); - } - - v = isc_mem_get(mctx, sizeof *v); - if (v == NULL) { - isc_task_detach(&tasks[i]); - t_info("isc_mem_get failed\n"); - return(T_FAIL); - } - *v = i; - - event = isc_event_allocate(mctx, NULL, 1, t14_callback, - v, sizeof(*event)); - if (event == NULL) { - isc_mem_put(mctx, v, sizeof *v); - t_info("isc_event_allocate failed\n"); - return(T_UNRESOLVED); - } - isc_task_send(tasks[i], &event); - } - - for (i = 0; i < T14_NTASKS; i++) { - isc_task_detach(&tasks[i]); - } - - isc_taskmgr_destroy(&manager); - - if (t14_exclusiveerror != ISC_R_SUCCESS || t14_error) { - if (t14_exclusiveerror != ISC_R_SUCCESS) - t_info("isc_task_beginexclusive() failed\n"); - if (t14_error) - t_info("mutual access occurred\n"); - return(T_FAIL); - } - - isc_mem_destroy(&mctx); - return(T_PASS); -} - -static void -t14(void) { - int result; - - t_assert("tasks", 14, T_REQUIRED, "%s", - "isc_task_beginexclusive() gets exclusive access"); - result = t_tasks14(); - t_result(result); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "basic task subsystem" }, - { (PFV) t2, "maxtasks" }, - { (PFV) t3, "isc_task_shutdown" }, - { (PFV) t4, "isc_task_shutdown" }, - { (PFV) t7, "isc_task_create" }, - { (PFV) t10, "isc_task_purge" }, - { (PFV) t11, "isc_task_purgeevent" }, - { (PFV) t12, "isc_task_purgeevent" }, - { (PFV) t13, "isc_task_purgerange" }, - { (PFV) t14, "isc_task_beginexclusive" }, - { (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/tasks/win32/t_tasks.vcxproj.filters.in b/bin/tests/tasks/win32/t_tasks.vcxproj.filters.in deleted file mode 100644 index 8e18dc8f26..0000000000 --- a/bin/tests/tasks/win32/t_tasks.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/tasks/win32/t_tasks.vcxproj.in b/bin/tests/tasks/win32/t_tasks.vcxproj.in deleted file mode 100644 index 2c6a708da6..0000000000 --- a/bin/tests/tasks/win32/t_tasks.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {2CB7B128-5954-4FAF-B5EA-501B23BB8054} - Win32Proj - t_tasks - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/tasks/win32/t_tasks.vcxproj.user b/bin/tests/tasks/win32/t_tasks.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/tasks/win32/t_tasks.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/bin/tests/wire_test.data b/bin/tests/testdata/wire/wire_test.data similarity index 100% rename from bin/tests/wire_test.data rename to bin/tests/testdata/wire/wire_test.data diff --git a/bin/tests/wire_test.data2 b/bin/tests/testdata/wire/wire_test.data2 similarity index 100% rename from bin/tests/wire_test.data2 rename to bin/tests/testdata/wire/wire_test.data2 diff --git a/bin/tests/wire_test.data3 b/bin/tests/testdata/wire/wire_test.data3 similarity index 100% rename from bin/tests/wire_test.data3 rename to bin/tests/testdata/wire/wire_test.data3 diff --git a/bin/tests/wire_test.data4 b/bin/tests/testdata/wire/wire_test.data4 similarity index 100% rename from bin/tests/wire_test.data4 rename to bin/tests/testdata/wire/wire_test.data4 diff --git a/bin/tests/timers/Makefile.in b/bin/tests/timers/Makefile.in deleted file mode 100644 index 0f2acf1644..0000000000 --- a/bin/tests/timers/Makefile.in +++ /dev/null @@ -1,47 +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} ${ISC_INCLUDES} - -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ - -ISCDEPLIBS = ../../../lib/isc/libisc.@A@ - -DEPLIBS = ${ISCDEPLIBS} - -LIBS = ${ISCLIBS} @LIBS@ - -TLIB = ../../../lib/tests/libt_api.@A@ - -TARGETS = t_timers@EXEEXT@ - -SRCS = t_timers.c - -@BIND9_MAKE_RULES@ - -t_timers@EXEEXT@: t_timers.@O@ ${DEPLIBS} ${TLIB} - ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ t_timers.@O@ ${TLIB} ${LIBS} - -test: t_timers@EXEEXT@ - -@./t_timers@EXEEXT@ -c @top_srcdir@/t_config -b @srcdir@ -q 60 -a - -testhelp: - @./t_timers@EXEEXT@ -h - -clean distclean:: - rm -f ${TARGETS} diff --git a/bin/tests/timers/t_timers.c b/bin/tests/timers/t_timers.c deleted file mode 100644 index 9de8a2a662..0000000000 --- a/bin/tests/timers/t_timers.c +++ /dev/null @@ -1,1127 +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_timers.c,v 1.33 2011/03/14 14:13:10 fdupont Exp $ */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef ISC_PLATFORM_USETHREADS -isc_boolean_t threaded = ISC_TRUE; -#else -isc_boolean_t threaded = ISC_FALSE; -#endif - -#define Tx_FUDGE_SECONDS 0 /* in absence of clock_getres() */ -#define Tx_FUDGE_NANOSECONDS 500000000 /* in absence of clock_getres() */ - -static isc_time_t Tx_endtime; -static isc_time_t Tx_lasttime; -static int Tx_eventcnt; -static int Tx_nevents; -static isc_mutex_t Tx_mx; -static isc_condition_t Tx_cv; -static int Tx_nfails; -static int Tx_nprobs; -static isc_timer_t *Tx_timer; -static int Tx_seconds; -static int Tx_nanoseconds; - -static void -require_threads(void) { - t_info("This test requires threads\n"); - t_result(T_THREADONLY); - return; -} - -static void -tx_sde(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - UNUSED(event); - - /* - * Signal shutdown processing complete. - */ - isc_result = isc_mutex_lock(&Tx_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - isc_result = isc_condition_signal(&Tx_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - isc_result = isc_mutex_unlock(&Tx_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - isc_event_free(&event); -} - -static void -tx_te(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - isc_time_t now; - isc_time_t base; - isc_time_t ulim; - isc_time_t llim; - isc_interval_t interval; - isc_eventtype_t expected_event_type; - - ++Tx_eventcnt; - - t_info("tick %d\n", Tx_eventcnt); - - expected_event_type = ISC_TIMEREVENT_LIFE; - if ((isc_timertype_t) event->ev_arg == isc_timertype_ticker) - expected_event_type = ISC_TIMEREVENT_TICK; - - if (event->ev_type != expected_event_type) { - t_info("expected event type %d, got %d\n", - expected_event_type, (int) event->ev_type); - ++Tx_nfails; - } - - isc_result = isc_time_now(&now); - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, Tx_seconds, Tx_nanoseconds); - isc_result = isc_time_add(&Tx_lasttime, &interval, &base); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_add failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } else { - t_info("isc_time_now failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, - Tx_FUDGE_SECONDS, Tx_FUDGE_NANOSECONDS); - isc_result = isc_time_add(&base, &interval, &ulim); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_add failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - isc_result = isc_time_subtract(&base, &interval, &llim); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_subtract failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - if (isc_time_compare(&llim, &now) > 0) { - t_info("timer range error: early by " - "%lu microseconds\n", - (unsigned long)isc_time_microdiff(&base, &now)); - ++Tx_nfails; - } else if (isc_time_compare(&ulim, &now) < 0) { - t_info("timer range error: late by " - "%lu microseconds\n", - (unsigned long)isc_time_microdiff(&now, &base)); - ++Tx_nfails; - } - Tx_lasttime = now; - } - - if (Tx_eventcnt == Tx_nevents) { - isc_result = isc_time_now(&Tx_endtime); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_now failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - isc_timer_detach(&Tx_timer); - isc_task_shutdown(task); - } - - isc_event_free(&event); -} - -static void -t_timers_x(isc_timertype_t timertype, isc_time_t *expires, - isc_interval_t *interval, - void (*action)(isc_task_t *, isc_event_t *)) -{ - char *p; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - isc_task_t *task; - unsigned int workers; - isc_result_t isc_result; - isc_timermgr_t *timermgr; - - Tx_eventcnt = 0; - isc_time_settoepoch(&Tx_endtime); - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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)); - ++Tx_nprobs; - return; - } - - isc_result = isc_mutex_init(&Tx_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - isc_result = isc_condition_init(&Tx_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&Tx_mx); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - timermgr = NULL; - isc_result = isc_timermgr_create(mctx, &timermgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timermgr_create failed %s\n", - isc_result_totext(isc_result)); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - isc_result = isc_mutex_lock(&Tx_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - task = NULL; - isc_result = isc_task_create(tmgr, 0, &task); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - isc_result = isc_task_onshutdown(task, tx_sde, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - isc_result = isc_time_now(&Tx_lasttime); - if (isc_result != ISC_R_SUCCESS) { - isc_timermgr_destroy(&timermgr); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - Tx_timer = NULL; - isc_result = isc_timer_create(timermgr, timertype, expires, interval, - task, action, (void *)timertype, - &Tx_timer); - - if (isc_result != ISC_R_SUCCESS) { - isc_timermgr_destroy(&timermgr); - isc_task_destroy(&task); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - ++Tx_nprobs; - return; - } - - /* - * Wait for shutdown processing to complete. - */ - while (Tx_eventcnt != Tx_nevents) { - isc_result = isc_condition_wait(&Tx_cv, &Tx_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_waituntil failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - isc_result = isc_mutex_unlock(&Tx_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - isc_task_detach(&task); - isc_taskmgr_destroy(&tmgr); - isc_timermgr_destroy(&timermgr); - DESTROYLOCK(&Tx_mx); - (void) isc_condition_destroy(&Tx_cv); - isc_mem_destroy(&mctx); - -} - -#define T1_SECONDS 2 -#define T1_NANOSECONDS 500000000 - -static const char *a1 = - "When type is isc_timertype_ticker, a call to isc_timer_create() " - "creates a timer that posts an ISC_TIMEREVENT_TICK event to the " - "specified task every 'interval' seconds and returns ISC_R_SUCCESS."; - -static void -t1(void) { - int result; - isc_time_t expires; - isc_interval_t interval; - - t_assert("isc_timer_create", 1, T_REQUIRED, "%s", a1); - - if (threaded) { - Tx_nfails = 0; - Tx_nprobs = 0; - Tx_nevents = 12; - Tx_seconds = T1_SECONDS; - Tx_nanoseconds = T1_NANOSECONDS; - isc_interval_set(&interval, Tx_seconds, Tx_nanoseconds); - isc_time_settoepoch(&expires); - - t_timers_x(isc_timertype_ticker, &expires, &interval, tx_te); - - result = T_UNRESOLVED; - - if ((Tx_nfails == 0) && (Tx_nprobs == 0)) - result = T_PASS; - else if (Tx_nfails) - result = T_FAIL; - - t_result(result); - } else - require_threads(); -} - -#define T2_SECONDS 5 -#define T2_NANOSECONDS 300000000; - -static const char *a2 = - "When type is isc_timertype_once, a call to isc_timer_create() " - "creates a timer that posts an ISC_TIMEEVENT_LIFE event to the " - "specified task when the current time reaches or exceeds the time " - "specified by 'expires'."; - -static void -t2(void) { - int result; - int isc_result; - isc_time_t expires; - isc_interval_t interval; - - t_assert("isc_timer_create", 2, T_REQUIRED, "%s", a2); - - if (threaded) { - Tx_nfails = 0; - Tx_nprobs = 0; - Tx_nevents = 1; - Tx_seconds = T2_SECONDS; - Tx_nanoseconds = T2_NANOSECONDS; - isc_interval_set(&interval, Tx_seconds, Tx_nanoseconds); - - isc_result = isc_time_nowplusinterval(&expires, &interval); - if (isc_result == ISC_R_SUCCESS) { - - isc_interval_set(&interval, 0, 0); - t_timers_x(isc_timertype_once, &expires, &interval, - tx_te); - - } else { - t_info("isc_time_nowplusinterval failed %s\n", - isc_result_totext(isc_result)); - } - - result = T_UNRESOLVED; - - if ((Tx_nfails == 0) && (Tx_nprobs == 0)) - result = T_PASS; - else if (Tx_nfails) - result = T_FAIL; - - t_result(result); - } else - require_threads(); -} - -static void -t3_te(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - isc_time_t now; - isc_time_t base; - isc_time_t ulim; - isc_time_t llim; - isc_interval_t interval; - - ++Tx_eventcnt; - - t_info("tick %d\n", Tx_eventcnt); - - isc_result = isc_time_now(&now); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_now failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, Tx_seconds, Tx_nanoseconds); - isc_result = isc_time_add(&Tx_lasttime, &interval, &base); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_add failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, - Tx_FUDGE_SECONDS, Tx_FUDGE_NANOSECONDS); - isc_result = isc_time_add(&base, &interval, &ulim); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_add failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - isc_result = isc_time_subtract(&base, &interval, &llim); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_subtract failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - if (isc_time_compare(&llim, &now) > 0) { - t_info("timer range error: early by " - "%lu microseconds\n", - (unsigned long)isc_time_microdiff(&base, &now)); - ++Tx_nfails; - } else if (isc_time_compare(&ulim, &now) < 0) { - t_info("timer range error: late by " - "%lu microseconds\n", - (unsigned long)isc_time_microdiff(&now, &base)); - ++Tx_nfails; - } - Tx_lasttime = now; - } - - if (event->ev_type != ISC_TIMEREVENT_IDLE) { - t_info("received event type %d, expected type %d\n", - event->ev_type, ISC_TIMEREVENT_IDLE); - ++Tx_nfails; - } - - isc_timer_detach(&Tx_timer); - isc_task_shutdown(task); - isc_event_free(&event); -} - -#define T3_SECONDS 4 -#define T3_NANOSECONDS 400000000 - -static const char *a3 = - "When type is isc_timertype_once, a call to isc_timer_create() " - "creates a timer that posts an ISC_TIMEEVENT_IDLE event to the " - "specified task when the timer has been idle for 'interval' seconds."; - -static void -t3(void) { - int result; - int isc_result; - isc_time_t expires; - isc_interval_t interval; - - t_assert("isc_timer_create", 3, T_REQUIRED, "%s", a3); - - if (threaded) { - Tx_nfails = 0; - Tx_nprobs = 0; - Tx_nevents = 1; - Tx_seconds = T3_SECONDS; - Tx_nanoseconds = T3_NANOSECONDS; - - isc_interval_set(&interval, Tx_seconds + 1, Tx_nanoseconds); - - isc_result = isc_time_nowplusinterval(&expires, &interval); - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, Tx_seconds, - Tx_nanoseconds); - t_timers_x(isc_timertype_once, &expires, &interval, - t3_te); - } else { - t_info("isc_time_nowplusinterval failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - result = T_UNRESOLVED; - - if ((Tx_nfails == 0) && (Tx_nprobs == 0)) - result = T_PASS; - else if (Tx_nfails) - result = T_FAIL; - - t_result(result); - } else - require_threads(); -} - -#define T4_SECONDS 2 -#define T4_NANOSECONDS 500000000 - -static void -t4_te(isc_task_t *task, isc_event_t *event) { - - isc_result_t isc_result; - isc_time_t now; - isc_time_t base; - isc_time_t ulim; - isc_time_t llim; - isc_time_t expires; - isc_interval_t interval; - - ++Tx_eventcnt; - - t_info("tick %d\n", Tx_eventcnt); - - /* - * Check expired time. - */ - - isc_result = isc_time_now(&now); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_now failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, Tx_seconds, Tx_nanoseconds); - isc_result = isc_time_add(&Tx_lasttime, &interval, &base); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_add failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, - Tx_FUDGE_SECONDS, Tx_FUDGE_NANOSECONDS); - isc_result = isc_time_add(&base, &interval, &ulim); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_add failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - isc_result = isc_time_subtract(&base, &interval, &llim); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_time_subtract failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - - if (isc_result == ISC_R_SUCCESS) { - if (isc_time_compare(&llim, &now) > 0) { - t_info("timer range error: early by " - "%lu microseconds\n", - (unsigned long)isc_time_microdiff(&base, &now)); - ++Tx_nfails; - } else if (isc_time_compare(&ulim, &now) < 0) { - t_info("timer range error: late by " - "%lu microseconds\n", - (unsigned long)isc_time_microdiff(&now, &base)); - ++Tx_nfails; - } - Tx_lasttime = now; - } - - if (Tx_eventcnt < 3) { - if (event->ev_type != ISC_TIMEREVENT_TICK) { - t_info("received event type %d, expected type %d\n", - event->ev_type, ISC_TIMEREVENT_IDLE); - ++Tx_nfails; - } - if (Tx_eventcnt == 2) { - isc_interval_set(&interval, T4_SECONDS, - T4_NANOSECONDS); - isc_result = isc_time_nowplusinterval(&expires, - &interval); - if (isc_result == ISC_R_SUCCESS) { - isc_interval_set(&interval, 0, 0); - isc_result = - isc_timer_reset(Tx_timer, - isc_timertype_once, - &expires, &interval, - ISC_FALSE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timer_reset failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nfails; - } - } else { - t_info("isc_time_nowplusinterval failed %s\n", - isc_result_totext(isc_result)); - ++Tx_nprobs; - } - } - } else { - if (event->ev_type != ISC_TIMEREVENT_LIFE) { - t_info("received event type %d, expected type %d\n", - event->ev_type, ISC_TIMEREVENT_IDLE); - ++Tx_nfails; - } - - isc_timer_detach(&Tx_timer); - isc_task_shutdown(task); - } - - isc_event_free(&event); -} - -static const char *a4 = - "A call to isc_timer_reset() changes the timer's type, expires and " - "interval values to the given values."; - -static void -t4(void) { - int result; - isc_time_t expires; - isc_interval_t interval; - - t_assert("isc_timer_reset", 4, T_REQUIRED, "%s", a4); - - if (threaded) { - Tx_nfails = 0; - Tx_nprobs = 0; - Tx_nevents = 3; - Tx_seconds = T4_SECONDS; - Tx_nanoseconds = T4_NANOSECONDS; - - isc_interval_set(&interval, T4_SECONDS, T4_NANOSECONDS); - isc_time_settoepoch(&expires); - t_timers_x(isc_timertype_ticker, &expires, &interval, t4_te); - - result = T_UNRESOLVED; - - if ((Tx_nfails == 0) && (Tx_nprobs == 0)) - result = T_PASS; - else if (Tx_nfails) - result = T_FAIL; - - t_result(result); - } else - require_threads(); -} - -#define T5_NTICKS 4 -#define T5_SECONDS 3 - -static int T5_startflag; -static int T5_shutdownflag; -static int T5_eventcnt; -static isc_mutex_t T5_mx; -static isc_condition_t T5_cv; -static int T5_nfails; -static int T5_nprobs; -static isc_timer_t *T5_tickertimer; -static isc_timer_t *T5_oncetimer; -static isc_task_t *T5_task1; -static isc_task_t *T5_task2; - -/* - * T5_task1 blocks on T5_mx while events accumulate - * in it's queue, until signaled by T5_task2. - */ - -static void -t5_start_event(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - - UNUSED(task); - - t_info("t5_start_event\n"); - - isc_result = isc_mutex_lock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - while (! T5_startflag) { - (void) isc_condition_wait(&T5_cv, &T5_mx); - } - - isc_result = isc_mutex_unlock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - isc_event_free(&event); -} - -static void -t5_tick_event(isc_task_t *task, isc_event_t *event) { - isc_result_t isc_result; - isc_time_t expires; - isc_interval_t interval; - - UNUSED(task); - - ++T5_eventcnt; - t_info("t5_tick_event %d\n", T5_eventcnt); - - /* - * On the first tick, purge all remaining tick events - * and then shut down the task. - */ - if (T5_eventcnt == 1) { - isc_time_settoepoch(&expires); - isc_interval_set(&interval, T5_SECONDS, 0); - isc_result = isc_timer_reset(T5_tickertimer, - isc_timertype_ticker, &expires, - &interval, ISC_TRUE); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timer_reset failed %s\n", - isc_result_totext(isc_result)); - ++T5_nfails; - } - isc_task_shutdown(task); - } - isc_event_free(&event); -} - -static void -t5_once_event(isc_task_t *task, isc_event_t *event) { - - isc_result_t isc_result; - - t_info("t5_once_event\n"); - - /* - * Allow task1 to start processing events. - */ - isc_result = isc_mutex_lock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - T5_startflag = 1; - - isc_result = isc_condition_broadcast(&T5_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_broadcast failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - isc_result = isc_mutex_unlock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - isc_event_free(&event); - isc_task_shutdown(task); -} - -static void -t5_shutdown_event(isc_task_t *task, isc_event_t *event) { - - isc_result_t isc_result; - - UNUSED(task); - UNUSED(event); - - t_info("t5_shutdown_event\n"); - - /* - * Signal shutdown processing complete. - */ - isc_result = isc_mutex_lock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - T5_shutdownflag = 1; - - isc_result = isc_condition_signal(&T5_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_signal failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - isc_result = isc_mutex_unlock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - isc_event_free(&event); -} - -static int -t_timers5(void) { - char *p; - int result; - isc_mem_t *mctx; - isc_taskmgr_t *tmgr; - unsigned int workers; - isc_result_t isc_result; - isc_timermgr_t *timermgr; - isc_event_t *event; - isc_time_t expires; - isc_interval_t interval; - - T5_startflag = 0; - T5_shutdownflag = 0; - T5_eventcnt = 0; - - workers = 2; - p = t_getenv("ISC_TASK_WORKERS"); - if (p != NULL) - workers = atoi(p); - - mctx = NULL; - 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_mutex_init(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_init failed %s\n", - isc_result_totext(isc_result)); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_condition_init(&T5_cv); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_init failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T5_mx); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - tmgr = NULL; - isc_result = isc_taskmgr_create(mctx, workers, 0, &tmgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_taskmgr_create failed %s\n", - isc_result_totext(isc_result)); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - timermgr = NULL; - isc_result = isc_timermgr_create(mctx, &timermgr); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_timermgr_create failed %s\n", - isc_result_totext(isc_result)); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - T5_task1 = NULL; - isc_result = isc_task_create(tmgr, 0, &T5_task1); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_task_onshutdown(T5_task1, t5_shutdown_event, NULL); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_onshutdown failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_task_destroy(&T5_task1); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - T5_task2 = NULL; - isc_result = isc_task_create(tmgr, 0, &T5_task2); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_task_create failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_task_destroy(&T5_task1); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_result = isc_mutex_lock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_lock failed %s\n", - isc_result_totext(isc_result)); - isc_timermgr_destroy(&timermgr); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - event = isc_event_allocate(mctx, (void *)1 , (isc_eventtype_t)1, - t5_start_event, NULL, sizeof(*event)); - isc_task_send(T5_task1, &event); - - isc_time_settoepoch(&expires); - isc_interval_set(&interval, T5_SECONDS, 0); - - T5_tickertimer = NULL; - isc_result = isc_timer_create(timermgr, isc_timertype_ticker, - &expires, &interval, T5_task1, - t5_tick_event, NULL, &T5_tickertimer); - - if (isc_result != ISC_R_SUCCESS) { - isc_timermgr_destroy(&timermgr); - (void) isc_condition_signal(&T5_cv); - (void) isc_mutex_unlock(&T5_mx); - isc_task_destroy(&T5_task1); - isc_task_destroy(&T5_task2); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - T5_oncetimer = NULL; - isc_interval_set(&interval, (T5_SECONDS * T5_NTICKS) + 2, 0); - isc_result = isc_time_nowplusinterval(&expires, &interval); - if (isc_result != ISC_R_SUCCESS) { - isc_timer_detach(&T5_tickertimer); - isc_timermgr_destroy(&timermgr); - (void)isc_condition_signal(&T5_cv); - (void)isc_mutex_unlock(&T5_mx); - isc_task_destroy(&T5_task1); - isc_task_destroy(&T5_task2); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - return(T_UNRESOLVED); - } - - isc_interval_set(&interval, 0, 0); - isc_result = isc_timer_create(timermgr, isc_timertype_once, - &expires, &interval, T5_task2, - t5_once_event, NULL, &T5_oncetimer); - - if (isc_result != ISC_R_SUCCESS) { - isc_timer_detach(&T5_tickertimer); - isc_timermgr_destroy(&timermgr); - (void) isc_condition_signal(&T5_cv); - (void) isc_mutex_unlock(&T5_mx); - isc_task_destroy(&T5_task1); - isc_task_destroy(&T5_task2); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - ++T5_nprobs; - return(T_UNRESOLVED); - } - - /* - * Wait for shutdown processing to complete. - */ - while (! T5_shutdownflag) { - isc_result = isc_condition_wait(&T5_cv, &T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_condition_waituntil failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - } - - isc_result = isc_mutex_unlock(&T5_mx); - if (isc_result != ISC_R_SUCCESS) { - t_info("isc_mutex_unlock failed %s\n", - isc_result_totext(isc_result)); - ++T5_nprobs; - } - - if (T5_eventcnt != 1) { - t_info("processed %d events\n", T5_eventcnt); - ++T5_nfails; - } - - isc_timer_detach(&T5_tickertimer); - isc_timer_detach(&T5_oncetimer); - isc_timermgr_destroy(&timermgr); - isc_task_destroy(&T5_task1); - isc_task_destroy(&T5_task2); - isc_taskmgr_destroy(&tmgr); - DESTROYLOCK(&T5_mx); - (void) isc_condition_destroy(&T5_cv); - isc_mem_destroy(&mctx); - - result = T_UNRESOLVED; - - if ((T5_nfails == 0) && (T5_nprobs == 0)) - result = T_PASS; - else if (T5_nfails) - result = T_FAIL; - - return (result); -} - -static const char *a5 = - "When 'purge' is TRUE, a call to isc_timer_reset() purges any pending " - "events from 'timer' from the task's event queue."; - -static void -t5(void) { - t_assert("isc_timer_reset", 5, T_REQUIRED, "%s", a5); - - if (threaded) - t_result(t_timers5()); - else - require_threads(); -} - -testspec_t T_testlist[] = { - { (PFV) t1, "timer_create" }, - { (PFV) t2, "timer_create" }, - { (PFV) t3, "timer_create" }, - { (PFV) t4, "timer_reset" }, - { (PFV) t5, "timer_reset" }, - { (PFV) NULL, NULL } -}; - -#ifdef WIN32 -int -main(int argc, char **argv) { - t_settests(T_testlist); - return (t_main(argc, argv)); -} -#endif diff --git a/bin/tests/timers/win32/t_timers.vcxproj.filters.in b/bin/tests/timers/win32/t_timers.vcxproj.filters.in deleted file mode 100644 index f98be97e4a..0000000000 --- a/bin/tests/timers/win32/t_timers.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/timers/win32/t_timers.vcxproj.in b/bin/tests/timers/win32/t_timers.vcxproj.in deleted file mode 100644 index 511a21ad32..0000000000 --- a/bin/tests/timers/win32/t_timers.vcxproj.in +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {4E6F5A7C-89AA-4259-99DB-F89DAE418B3F} - Win32Proj - t_timers - - - - 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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.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@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\tests\include;%(AdditionalIncludeDirectories) - CompileAsC - - - Console - false - true - true - ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - Default - ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\tests\win32\$(Configuration);%(AdditionalLibraryDirectories) - @LIBXML2_LIB@libisc.lib;libtests.lib;ws2_32.lib;%(AdditionalDependencies) - - - - - - - - - diff --git a/bin/tests/timers/win32/t_timers.vcxproj.user b/bin/tests/timers/win32/t_timers.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/bin/tests/timers/win32/t_timers.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/configure b/configure index 06ef2c2ff8..4073acba3b 100755 --- a/configure +++ b/configure @@ -942,6 +942,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -1106,6 +1107,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1358,6 +1360,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1495,7 +1506,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1648,6 +1659,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -24145,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/atomic/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/hashes/Makefile bin/tests/headerdep_test.sh bin/tests/master/Makefile bin/tests/mem/Makefile bin/tests/names/Makefile bin/tests/net/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/rbt/Makefile bin/tests/resolver/Makefile bin/tests/sockaddr/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/tasks/Makefile bin/tests/timers/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/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/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh" # @@ -25184,35 +25196,10 @@ 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/atomic/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/atomic/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" ;; - "bin/tests/dst/Kdh.+002+48957.key") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Kdh.+002+48957.key" ;; - "bin/tests/dst/Kdh.+002+48957.private") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Kdh.+002+48957.private" ;; - "bin/tests/dst/Ktest.+001+00002.key") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Ktest.+001+00002.key" ;; - "bin/tests/dst/Ktest.+001+54622.key") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Ktest.+001+54622.key" ;; - "bin/tests/dst/Ktest.+001+54622.private") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Ktest.+001+54622.private" ;; - "bin/tests/dst/Ktest.+003+23616.key") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Ktest.+003+23616.key" ;; - "bin/tests/dst/Ktest.+003+23616.private") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Ktest.+003+23616.private" ;; - "bin/tests/dst/Ktest.+003+49667.key") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/Ktest.+003+49667.key" ;; - "bin/tests/dst/dst_2_data") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/dst_2_data" ;; - "bin/tests/dst/t2_data_1") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/t2_data_1" ;; - "bin/tests/dst/t2_data_2") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/t2_data_2" ;; - "bin/tests/dst/t2_dsasig") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/t2_dsasig" ;; - "bin/tests/dst/t2_rsasig") CONFIG_FILES="$CONFIG_FILES bin/tests/dst/t2_rsasig" ;; - "bin/tests/hashes/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/hashes/Makefile" ;; "bin/tests/headerdep_test.sh") CONFIG_FILES="$CONFIG_FILES bin/tests/headerdep_test.sh" ;; - "bin/tests/master/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/master/Makefile" ;; - "bin/tests/mem/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/mem/Makefile" ;; - "bin/tests/names/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/names/Makefile" ;; - "bin/tests/net/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/net/Makefile" ;; + "bin/tests/optional/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/optional/Makefile" ;; "bin/tests/pkcs11/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/pkcs11/Makefile" ;; "bin/tests/pkcs11/benchmarks/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/pkcs11/benchmarks/Makefile" ;; - "bin/tests/rbt/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/rbt/Makefile" ;; - "bin/tests/resolver/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/resolver/Makefile" ;; - "bin/tests/sockaddr/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/sockaddr/Makefile" ;; "bin/tests/system/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/system/Makefile" ;; "bin/tests/system/conf.sh") CONFIG_FILES="$CONFIG_FILES bin/tests/system/conf.sh" ;; "bin/tests/system/dlz/prereq.sh") CONFIG_FILES="$CONFIG_FILES bin/tests/system/dlz/prereq.sh" ;; @@ -25226,8 +25213,6 @@ do "bin/tests/system/rpz/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/system/rpz/Makefile" ;; "bin/tests/system/rsabigexponent/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/system/rsabigexponent/Makefile" ;; "bin/tests/system/tkey/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/system/tkey/Makefile" ;; - "bin/tests/tasks/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/tasks/Makefile" ;; - "bin/tests/timers/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/timers/Makefile" ;; "bin/tests/virtual-time/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tests/virtual-time/Makefile" ;; "bin/tests/virtual-time/conf.sh") CONFIG_FILES="$CONFIG_FILES bin/tests/virtual-time/conf.sh" ;; "bin/tools/Makefile") CONFIG_FILES="$CONFIG_FILES bin/tools/Makefile" ;; @@ -25294,9 +25279,6 @@ do "lib/ns/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/ns/include/Makefile" ;; "lib/ns/include/ns/Makefile") CONFIG_FILES="$CONFIG_FILES lib/ns/include/ns/Makefile" ;; "lib/ns/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/ns/tests/Makefile" ;; - "lib/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/tests/Makefile" ;; - "lib/tests/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/tests/include/Makefile" ;; - "lib/tests/include/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/tests/include/tests/Makefile" ;; "lib/samples/Makefile") CONFIG_FILES="$CONFIG_FILES lib/samples/Makefile" ;; "lib/samples/Makefile-postinstall") CONFIG_FILES="$CONFIG_FILES lib/samples/Makefile-postinstall" ;; "unit/Makefile") CONFIG_FILES="$CONFIG_FILES unit/Makefile" ;; diff --git a/configure.in b/configure.in index b94b1d593f..f2acb659fb 100644 --- a/configure.in +++ b/configure.in @@ -5313,35 +5313,10 @@ AC_CONFIG_FILES([ bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile - bin/tests/atomic/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/hashes/Makefile bin/tests/headerdep_test.sh - bin/tests/master/Makefile - bin/tests/mem/Makefile - bin/tests/names/Makefile - bin/tests/net/Makefile + bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile - bin/tests/rbt/Makefile - bin/tests/resolver/Makefile - bin/tests/sockaddr/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh @@ -5355,8 +5330,6 @@ AC_CONFIG_FILES([ bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile - bin/tests/tasks/Makefile - bin/tests/timers/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile @@ -5423,9 +5396,6 @@ AC_CONFIG_FILES([ 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 diff --git a/lib/Makefile.in b/lib/Makefile.in index ff7c0eb9f9..ffa2d5a524 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -15,7 +15,7 @@ top_srcdir = @top_srcdir@ # Attempt to disable parallel processing. .NOTPARALLEL: .NO_PARALLEL: -SUBDIRS = isc isccc dns ns isccfg bind9 irs tests samples +SUBDIRS = isc isccc dns ns isccfg bind9 irs samples TARGETS = @BIND9_MAKE_RULES@ diff --git a/lib/dns/tests/Atffile b/lib/dns/tests/Atffile index 58d0515630..e13b2dc396 100644 --- a/lib/dns/tests/Atffile +++ b/lib/dns/tests/Atffile @@ -10,6 +10,7 @@ tp: dbversion_test tp: dh_test tp: dispatch_test tp: dnstap_test +tp: dst_test tp: dstrandom_test tp: geoip_test tp: gost_test @@ -24,6 +25,7 @@ tp: rbt_test tp: rdata_test tp: rdataset_test tp: rdatasetstats_test +tp: resolver_test tp: rsa_test tp: time_test tp: tsig_test diff --git a/lib/dns/tests/Kyuafile b/lib/dns/tests/Kyuafile index 221fb54ffe..52bd99a4c1 100644 --- a/lib/dns/tests/Kyuafile +++ b/lib/dns/tests/Kyuafile @@ -9,6 +9,7 @@ atf_test_program{name='dbversion_test'} atf_test_program{name='dh_test'} atf_test_program{name='dispatch_test'} atf_test_program{name='dnstap_test'} +atf_test_program{name='dst_test'} atf_test_program{name='dstrandom_test'} atf_test_program{name='geoip_test'} atf_test_program{name='gost_test'} @@ -23,6 +24,7 @@ atf_test_program{name='rbt_test'} atf_test_program{name='rdata_test'} atf_test_program{name='rdataset_test'} atf_test_program{name='rdatasetstats_test'} +atf_test_program{name='resolver_test'} atf_test_program{name='rsa_test'} atf_test_program{name='time_test'} atf_test_program{name='tsig_test'} diff --git a/lib/dns/tests/Makefile.in b/lib/dns/tests/Makefile.in index 955c0b2418..cfc33a0766 100644 --- a/lib/dns/tests/Makefile.in +++ b/lib/dns/tests/Makefile.in @@ -38,6 +38,7 @@ SRCS = acl_test.c \ dh_test.c \ dispatch_test.c \ dnstap_test.c \ + dst_test.c \ dnstest.c \ dstrandom_test.c \ geoip_test.c \ @@ -53,6 +54,7 @@ SRCS = acl_test.c \ rdata_test.c \ rdataset_test.c \ rdatasetstats_test.c \ + resolver_test.c \ rsa_test.c \ time_test.c \ tsig_test.c \ @@ -69,6 +71,7 @@ TARGETS = acl_test@EXEEXT@ \ dh_test@EXEEXT@ \ dispatch_test@EXEEXT@ \ dnstap_test@EXEEXT@ \ + dst_test@EXEEXT@ \ dstrandom_test@EXEEXT@ \ geoip_test@EXEEXT@ \ gost_test@EXEEXT@ \ @@ -83,6 +86,7 @@ TARGETS = acl_test@EXEEXT@ \ rdata_test@EXEEXT@ \ rdataset_test@EXEEXT@ \ rdatasetstats_test@EXEEXT@ \ + resolver_test@EXEEXT@ \ rsa_test@EXEEXT@ \ time_test@EXEEXT@ \ tsig_test@EXEEXT@ \ @@ -99,7 +103,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} @@ -132,6 +136,11 @@ dnstap_test@EXEEXT@: dnstap_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} dnstap_test.@O@ dnstest.@O@ ${DNSLIBS} \ ${ISCLIBS} ${LIBS} +dst_test@EXEEXT@: dst_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + dst_test.@O@ dnstest.@O@ ${DNSLIBS} \ + ${ISCLIBS} ${LIBS} + geoip_test@EXEEXT@: geoip_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ geoip_test.@O@ dnstest.@O@ ${DNSLIBS} \ @@ -205,6 +214,12 @@ rdatasetstats_test@EXEEXT@: rdatasetstats_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${D rdatasetstats_test.@O@ dnstest.@O@ ${DNSLIBS} \ ${ISCLIBS} ${LIBS} +resolver_test@EXEEXT@: resolver_test.@O@ dnstest.@O@ \ + ${ISCDEPLIBS} ${DNSDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + resolver_test.@O@ dnstest.@O@ ${DNSLIBS} \ + ${ISCLIBS} ${LIBS} + rsa_test@EXEEXT@: rsa_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ rsa_test.@O@ dnstest.@O@ ${DNSLIBS} \ 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/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index 861cebb02b..e9ccf8dfa8 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -493,3 +493,25 @@ dns_test_rdata_fromstring(dns_rdata_t *rdata, dns_rdataclass_t rdclass, return (result); } + +void +dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname) { + size_t length; + isc_buffer_t *b = NULL; + isc_result_t result; + dns_name_t *name; + + length = strlen(namestr); + + result = isc_buffer_allocate(mctx, &b, length); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + isc_buffer_putmem(b, (const unsigned char *) namestr, length); + + dns_fixedname_init(fname); + name = dns_fixedname_name(fname); + ATF_REQUIRE(name != NULL); + result = dns_name_fromtext(name, b, dns_rootname, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_buffer_free(&b); +} diff --git a/lib/dns/tests/dnstest.h b/lib/dns/tests/dnstest.h index 3329ff5cb0..e9f48097b8 100644 --- a/lib/dns/tests/dnstest.h +++ b/lib/dns/tests/dnstest.h @@ -93,3 +93,6 @@ isc_result_t dns_test_rdata_fromstring(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t rdtype, unsigned char *dst, size_t dstlen, const char *src); + +void +dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname); diff --git a/lib/dns/tests/dst_test.c b/lib/dns/tests/dst_test.c new file mode 100644 index 0000000000..284249b65f --- /dev/null +++ b/lib/dns/tests/dst_test.c @@ -0,0 +1,263 @@ +/* + * 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. + */ + +/* ! \file */ + +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include "../dst_internal.h" + +#include "dnstest.h" + +ATF_TC(sig); +ATF_TC_HEAD(sig, tc) { + atf_tc_set_md_var(tc, "descr", "signature ineffability"); +} + +/* + * Read sig in file at path to buf. + */ +static isc_result_t +sig_fromfile(const char *path, isc_buffer_t *buf) { + isc_result_t result; + size_t rval, len; + FILE *fp = NULL; + unsigned char val; + char *p, *data; + off_t size; + + result = isc_stdio_open(path, "rb", &fp); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_file_getsizefd(fileno(fp), &size); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + data = isc_mem_get(mctx, (size + 1)); + ATF_REQUIRE(data != NULL); + + len = (size_t)size; + p = data; + while (len != 0U) { + result = isc_stdio_read(p, 1, len, fp, &rval); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + len -= rval; + p += rval; + } + isc_stdio_close(fp); + + p = data; + len = size; + while (len > 0U) { + if ((*p == '\r') || (*p == '\n')) { + ++p; + --len; + continue; + } else if (len < 2U) + goto err; + if (('0' <= *p) && (*p <= '9')) { + val = *p - '0'; + } else if (('A' <= *p) && (*p <= 'F')) { + val = *p - 'A' + 10; + } else { + result = ISC_R_BADHEX; + goto err; + } + ++p; + val <<= 4; + --len; + if (('0' <= *p) && (*p <= '9')) { + val |= (*p - '0'); + } else if (('A' <= *p) && (*p <= 'F')) { + val |= (*p - 'A' + 10); + } else { + result = ISC_R_BADHEX; + goto err; + } + ++p; + --len; + isc_buffer_putuint8(buf, val); + } + + result = ISC_R_SUCCESS; + + err: + isc_mem_put(mctx, data, size + 1); + return (result); +} + +static void +check_sig(const char *datapath, const char *sigpath, const char *keyname, + dns_keytag_t id, dns_secalg_t alg, int type, isc_boolean_t expect) +{ + isc_result_t result; + size_t rval, len; + FILE *fp; + dst_key_t *key = NULL; + unsigned char sig[512]; + unsigned char *p; + unsigned char *data; + off_t size; + isc_buffer_t b; + isc_buffer_t databuf, sigbuf; + isc_region_t datareg, sigreg; + dns_fixedname_t fname; + dns_name_t *name; + dst_context_t *ctx = NULL; + + /* + * Read data from file in a form usable by dst_verify. + */ + result = isc_stdio_open(datapath, "rb", &fp); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_file_getsizefd(fileno(fp), &size); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + data = isc_mem_get(mctx, (size + 1)); + ATF_REQUIRE(data != NULL); + + p = data; + len = (size_t)size; + do { + result = isc_stdio_read(p, 1, len, fp, &rval); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + len -= rval; + p += rval; + } while (len); + isc_stdio_close(fp); + + /* + * Read key from file in a form usable by dst_verify. + */ + dns_fixedname_init(&fname); + name = dns_fixedname_name(&fname); + isc_buffer_constinit(&b, keyname, strlen(keyname)); + isc_buffer_add(&b, strlen(keyname)); + result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dst_key_fromfile(name, id, alg, type, "testdata/dst", + mctx, &key); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_buffer_init(&databuf, data, (unsigned int)size); + isc_buffer_add(&databuf, (unsigned int)size); + isc_buffer_usedregion(&databuf, &datareg); + + memset(sig, 0, sizeof(sig)); + isc_buffer_init(&sigbuf, sig, sizeof(sig)); + + /* + * Read precomputed signature from file in a form usable by dst_verify. + */ + result = sig_fromfile(sigpath, &sigbuf); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * Verify that the key signed the data. + */ + isc_buffer_remainingregion(&sigbuf, &sigreg); + + result = dst_context_create3(key, mctx, DNS_LOGCATEGORY_GENERAL, + ISC_FALSE, &ctx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dst_context_adddata(ctx, &datareg); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dst_context_verify(ctx, &sigreg); + + ATF_REQUIRE((expect && (result == ISC_R_SUCCESS)) || + (!expect && (result != ISC_R_SUCCESS))); + + + isc_mem_put(mctx, data, size + 1); + dst_context_destroy(&ctx); + dst_key_free(&key); + + return; +} + +ATF_TC_BODY(sig, tc) { + isc_result_t result; + + UNUSED(tc); + + result = dns_test_begin(NULL, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + struct { + const char *datapath; + const char *sigpath; + const char *keyname; + dns_keytag_t keyid; + dns_secalg_t alg; + isc_boolean_t expect; + } testcases[] = { + { + "testdata/dst/test1.data", + "testdata/dst/test1.dsasig", + "test.", 23616, DST_ALG_DSA, ISC_TRUE + }, + { + "testdata/dst/test1.data", + "testdata/dst/test1.rsasig", + "test.", 54622, DST_ALG_RSAMD5, ISC_TRUE + }, + { + /* wrong sig */ + "testdata/dst/test1.data", + "testdata/dst/test1.dsasig", + "test.", 54622, DST_ALG_RSAMD5, ISC_FALSE + }, + { + /* wrong data */ + "testdata/dst/test2.data", + "testdata/dst/test1.dsasig", + "test.", 23616, DST_ALG_DSA, ISC_FALSE + }, + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + if (!dst_algorithm_supported(testcases[i].alg)) { + continue; + } + + check_sig(testcases[i].datapath, + testcases[i].sigpath, + testcases[i].keyname, + testcases[i].keyid, + testcases[i].alg, + DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, + testcases[i].expect); + } + + dns_test_end(); +} + +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, sig); + + return (atf_no_error()); +} diff --git a/lib/dns/tests/name_test.c b/lib/dns/tests/name_test.c index bab9d4a0d3..77d4ab46d0 100644 --- a/lib/dns/tests/name_test.c +++ b/lib/dns/tests/name_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -328,6 +326,338 @@ ATF_TC_BODY(istat, tc) { } } +ATF_TC(init); +ATF_TC_HEAD(init, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_init"); +} +ATF_TC_BODY(init, tc) { + dns_name_t name; + unsigned char offsets[1]; + + dns_name_init(&name, offsets); + + ATF_CHECK_EQ(name.ndata, NULL); + ATF_CHECK_EQ(name.length, 0); + ATF_CHECK_EQ(name.labels, 0); + ATF_CHECK_EQ(name.attributes, 0); + ATF_CHECK_EQ(name.offsets, offsets); + ATF_CHECK_EQ(name.buffer, NULL); +} + +ATF_TC(invalidate); +ATF_TC_HEAD(invalidate, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_invalidate"); +} +ATF_TC_BODY(invalidate, tc) { + dns_name_t name; + unsigned char offsets[1]; + + dns_name_init(&name, offsets); + dns_name_invalidate(&name); + + ATF_CHECK_EQ(name.ndata, NULL); + ATF_CHECK_EQ(name.length, 0); + ATF_CHECK_EQ(name.labels, 0); + ATF_CHECK_EQ(name.attributes, 0); + ATF_CHECK_EQ(name.offsets, NULL); + ATF_CHECK_EQ(name.buffer, NULL); +} + +ATF_TC(buffer); +ATF_TC_HEAD(buffer, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_setbuffer/hasbuffer"); +} +ATF_TC_BODY(buffer, tc) { + dns_name_t name; + unsigned char buf[BUFSIZ]; + isc_buffer_t b; + + isc_buffer_init(&b, buf, BUFSIZ); + dns_name_init(&name, NULL); + dns_name_setbuffer(&name, &b); + ATF_CHECK_EQ(name.buffer, &b); + ATF_CHECK(dns_name_hasbuffer(&name)); +} + +ATF_TC(isabsolute); +ATF_TC_HEAD(isabsolute, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_isabsolute"); +} +ATF_TC_BODY(isabsolute, tc) { + struct { + const char *namestr; + isc_boolean_t expect; + } testcases[] = { + { "x", ISC_FALSE }, + { "a.b.c.d.", ISC_TRUE }, + { "x.z", ISC_FALSE} + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + isc_result_t result; + dns_name_t name; + unsigned char data[BUFSIZ]; + isc_buffer_t b, nb; + size_t len; + + len = strlen(testcases[i].namestr); + isc_buffer_constinit(&b, testcases[i].namestr, len); + isc_buffer_add(&b, len); + + dns_name_init(&name, NULL); + isc_buffer_init(&nb, data, BUFSIZ); + dns_name_setbuffer(&name, &nb); + result = dns_name_fromtext(&name, &b, NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + ATF_CHECK_EQ(dns_name_isabsolute(&name), testcases[i].expect); + } +} + +ATF_TC(hash); +ATF_TC_HEAD(hash, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_hash"); +} +ATF_TC_BODY(hash, tc) { + struct { + const char *name1; + const char *name2; + isc_boolean_t expect; + isc_boolean_t expecti; + } testcases[] = { + { "a.b.c.d", "A.B.C.D", ISC_TRUE, ISC_FALSE }, + { "a.b.c.d.", "A.B.C.D.", ISC_TRUE, ISC_FALSE }, + { "a.b.c.d", "a.b.c.d", ISC_TRUE, ISC_TRUE }, + { "A.B.C.D.", "A.B.C.D.", ISC_TRUE, ISC_FALSE }, + { "x.y.z.w", "a.b.c.d", ISC_FALSE, ISC_FALSE }, + { "x.y.z.w.", "a.b.c.d.", ISC_FALSE, ISC_FALSE }, + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + isc_result_t result; + dns_fixedname_t f1, f2; + dns_name_t *n1, *n2; + unsigned int h1, h2; + + dns_fixedname_init(&f1); + n1 = dns_fixedname_name(&f1); + dns_fixedname_init(&f2); + n2 = dns_fixedname_name(&f2); + + result = dns_name_fromstring2(n1, testcases[i].name1, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dns_name_fromstring2(n2, testcases[i].name2, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* Check case-insensitive hashing first */ + h1 = dns_name_hash(n1, ISC_FALSE); + h2 = dns_name_hash(n2, ISC_FALSE); + + printf("%s hashes to %u, %s to %u, case insensitive\n", + testcases[i].name1, h1, testcases[i].name2, h2); + + ATF_REQUIRE_EQ(ISC_TF(h1 == h2), testcases[i].expect); + + /* Now case-sensitive */ + h1 = dns_name_hash(n1, ISC_FALSE); + h2 = dns_name_hash(n2, ISC_FALSE); + + printf("%s hashes to %u, %s to %u, case sensitive\n", + testcases[i].name1, h1, testcases[i].name2, h2); + + ATF_REQUIRE_EQ(ISC_TF(h1 == h2), testcases[i].expect); + } +} + +ATF_TC(issubdomain); +ATF_TC_HEAD(issubdomain, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_issubdomain"); +} +ATF_TC_BODY(issubdomain, tc) { + struct { + const char *name1; + const char *name2; + isc_boolean_t expect; + } testcases[] = { + { "c.d", "a.b.c.d", ISC_FALSE }, + { "c.d.", "a.b.c.d.", ISC_FALSE }, + { "b.c.d", "c.d", ISC_TRUE }, + { "a.b.c.d.", "c.d.", ISC_TRUE }, + { "a.b.c", "a.b.c", ISC_TRUE }, + { "a.b.c.", "a.b.c.", ISC_TRUE }, + { "x.y.z", "a.b.c", ISC_FALSE} + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + isc_result_t result; + dns_fixedname_t f1, f2; + dns_name_t *n1, *n2; + + dns_fixedname_init(&f1); + n1 = dns_fixedname_name(&f1); + dns_fixedname_init(&f2); + n2 = dns_fixedname_name(&f2); + + result = dns_name_fromstring2(n1, testcases[i].name1, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dns_name_fromstring2(n2, testcases[i].name2, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + printf("check: %s %s a subdomain of %s\n", + testcases[i].name1, + testcases[i].expect ? "is" : "is not", + testcases[i].name2); + + ATF_CHECK_EQ(dns_name_issubdomain(n1, n2), + testcases[i].expect); + } +} + +ATF_TC(countlabels); +ATF_TC_HEAD(countlabels, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_countlabels"); +} +ATF_TC_BODY(countlabels, tc) { + struct { + const char *namestr; + unsigned int expect; + } testcases[] = { + { "c.d", 2 }, + { "c.d.", 3 }, + { "a.b.c.d.", 5 }, + { "a.b.c.d", 4 }, + { "a.b.c", 3 }, + { ".", 1 }, + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + isc_result_t result; + dns_fixedname_t fname; + dns_name_t *name; + + dns_fixedname_init(&fname); + name = dns_fixedname_name(&fname); + + result = dns_name_fromstring2(name, testcases[i].namestr, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + printf("%s: expect %d labels\n", + testcases[i].namestr, testcases[i].expect); + + ATF_REQUIRE_EQ(dns_name_countlabels(name), + testcases[i].expect); + } +} + +ATF_TC(getlabel); +ATF_TC_HEAD(getlabel, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_getlabel"); +} +ATF_TC_BODY(getlabel, tc) { + struct { + const char *name1; + unsigned int pos1; + const char *name2; + unsigned int pos2; + } testcases[] = { + { "c.d", 1, "a.b.c.d", 3 }, + { "a.b.c.d", 3, "c.d", 1 }, + { "a.b.c.", 3, "A.B.C.", 3 }, + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + isc_result_t result; + dns_fixedname_t f1, f2; + dns_name_t *n1, *n2; + dns_label_t l1, l2; + unsigned char *p1, *p2; + unsigned int j; + + dns_fixedname_init(&f1); + n1 = dns_fixedname_name(&f1); + dns_fixedname_init(&f2); + n2 = dns_fixedname_name(&f2); + + result = dns_name_fromstring2(n1, testcases[i].name1, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dns_name_fromstring2(n2, testcases[i].name2, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + dns_name_getlabel(n1, testcases[i].pos1, &l1); + dns_name_getlabel(n2, testcases[i].pos2, &l2); + ATF_CHECK_EQ(l1.length, l2.length); + + p1 = l1.base; + p2 = l2.base; + for (j = 0; j < l1.length; j++) { + ATF_REQUIRE_EQ(*p1++, *p2++); + } + } +} + +ATF_TC(getlabelsequence); +ATF_TC_HEAD(getlabelsequence, tc) { + atf_tc_set_md_var(tc, "descr", "dns_nane_getlabelsequence"); +} +ATF_TC_BODY(getlabelsequence, tc) { + struct { + const char *name1; + unsigned int pos1; + const char *name2; + unsigned int pos2; + unsigned int range; + } testcases[] = { + { "c.d", 1, "a.b.c.d", 3, 1 }, + { "a.b.c.d.e", 2, "c.d", 0, 2 }, + { "a.b.c", 0, "a.b.c", 0, 3 }, + + }; + unsigned int i; + + for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) { + isc_result_t result; + dns_name_t t1, t2; + dns_fixedname_t f1, f2; + dns_name_t *n1, *n2; + + /* target names */ + dns_name_init(&t1, NULL); + dns_name_init(&t2, NULL); + + /* source names */ + dns_fixedname_init(&f1); + n1 = dns_fixedname_name(&f1); + dns_fixedname_init(&f2); + n2 = dns_fixedname_name(&f2); + + result = dns_name_fromstring2(n1, testcases[i].name1, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = dns_name_fromstring2(n2, testcases[i].name2, + NULL, 0, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + dns_name_getlabelsequence(n1, testcases[i].pos1, + testcases[i].range, &t1); + dns_name_getlabelsequence(n2, testcases[i].pos2, + testcases[i].range, &t2); + + ATF_REQUIRE(dns_name_equal(&t1, &t2)); + } +} + #ifdef ISC_PLATFORM_USETHREADS #ifdef DNS_BENCHMARK_TESTS @@ -433,6 +763,15 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fullcompare); ATF_TP_ADD_TC(tp, compression); ATF_TP_ADD_TC(tp, istat); + ATF_TP_ADD_TC(tp, init); + ATF_TP_ADD_TC(tp, invalidate); + ATF_TP_ADD_TC(tp, buffer); + ATF_TP_ADD_TC(tp, isabsolute); + ATF_TP_ADD_TC(tp, hash); + ATF_TP_ADD_TC(tp, issubdomain); + ATF_TP_ADD_TC(tp, countlabels); + ATF_TP_ADD_TC(tp, getlabel); + ATF_TP_ADD_TC(tp, getlabelsequence); #ifdef ISC_PLATFORM_USETHREADS #ifdef DNS_BENCHMARK_TESTS ATF_TP_ADD_TC(tp, benchmark); diff --git a/lib/dns/tests/rbt_test.c b/lib/dns/tests/rbt_test.c index 32718f029c..271952aa42 100644 --- a/lib/dns/tests/rbt_test.c +++ b/lib/dns/tests/rbt_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: rbt_test.c,v 1.1.14.8 2012/02/10 16:24:37 ckb Exp $ */ - /* ! \file */ #include @@ -27,6 +25,7 @@ #include #include +#include #include #include #include "dnstest.h" @@ -136,28 +135,6 @@ delete_data(void *data, void *arg) { isc_mem_put(mctx, data, sizeof(size_t)); } -static void -build_name_from_str(const char *namestr, dns_fixedname_t *fname) { - size_t length; - isc_buffer_t *b = NULL; - isc_result_t result; - dns_name_t *name; - - length = strlen(namestr); - - result = isc_buffer_allocate(mctx, &b, length); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - isc_buffer_putmem(b, (const unsigned char *) namestr, length); - - dns_fixedname_init(fname); - name = dns_fixedname_name(fname); - ATF_REQUIRE(name != NULL); - result = dns_name_fromtext(name, b, dns_rootname, 0, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - isc_buffer_free(&b); -} - static test_context_t * test_context_setup(void) { test_context_t *ctx; @@ -180,7 +157,7 @@ test_context_setup(void) { dns_fixedname_t fname; dns_name_t *name; - build_name_from_str(domain_names[i], &fname); + dns_test_namefromstring(domain_names[i], &fname); name = dns_fixedname_name(&fname); @@ -224,7 +201,7 @@ check_test_data(dns_rbt_t *rbt) { dns_name_t *name; size_t *n; - build_name_from_str(domain_names[i], &fname); + dns_test_namefromstring(domain_names[i], &fname); name = dns_fixedname_name(&fname); n = NULL; @@ -310,7 +287,7 @@ ATF_TC_BODY(rbtnode_get_distance, tc) { ctx = test_context_setup(); - build_name_from_str(name_str, &fname); + dns_test_namefromstring(name_str, &fname); name = dns_fixedname_name(&fname); dns_rbtnodechain_init(&chain, mctx); @@ -397,7 +374,7 @@ ATF_TC_BODY(rbt_check_distance_random, tc) { namebuf[32] = '.'; namebuf[33] = 0; - build_name_from_str(namebuf, &fname); + dns_test_namefromstring(namebuf, &fname); name = dns_fixedname_name(&fname); result = dns_rbt_addname(mytree, name, n); @@ -471,7 +448,7 @@ ATF_TC_BODY(rbt_check_distance_ordered, tc) { *n = i + 1; snprintf(namebuf, sizeof(namebuf), "name%08x.", i); - build_name_from_str(namebuf, &fname); + dns_test_namefromstring(namebuf, &fname); name = dns_fixedname_name(&fname); result = dns_rbt_addname(mytree, name, n); @@ -500,7 +477,7 @@ insert_helper(dns_rbt_t *rbt, const char *namestr, dns_rbtnode_t **node) { dns_fixedname_t fname; dns_name_t *name; - build_name_from_str(namestr, &fname); + dns_test_namefromstring(namestr, &fname); name = dns_fixedname_name(&fname); return (dns_rbt_addnode(rbt, name, node)); @@ -739,7 +716,7 @@ ATF_TC_BODY(rbt_remove, tc) { dns_fixedname_t fname; dns_name_t *name; - build_name_from_str(ordered_names[i], &fname); + dns_test_namefromstring(ordered_names[i], &fname); name = dns_fixedname_name(&fname); node = NULL; @@ -764,7 +741,7 @@ ATF_TC_BODY(rbt_remove, tc) { dns_fixedname_t fname; dns_name_t *name; - build_name_from_str(ordered_names[j], &fname); + dns_test_namefromstring(ordered_names[j], &fname); name = dns_fixedname_name(&fname); @@ -787,7 +764,7 @@ ATF_TC_BODY(rbt_remove, tc) { dns_fixedname_t fname; dns_name_t *name; - build_name_from_str(ordered_names[0], &fname); + dns_test_namefromstring(ordered_names[0], &fname); name = dns_fixedname_name(&fname); node = NULL; result = dns_rbt_findnode(mytree, name, NULL, @@ -796,7 +773,7 @@ ATF_TC_BODY(rbt_remove, tc) { NULL, NULL); ATF_CHECK_EQ(result, ISC_R_NOTFOUND); - build_name_from_str(ordered_names[1], &fname); + dns_test_namefromstring(ordered_names[1], &fname); name = dns_fixedname_name(&fname); node = NULL; result = dns_rbt_findnode(mytree, name, NULL, @@ -810,7 +787,7 @@ ATF_TC_BODY(rbt_remove, tc) { dns_fixedname_t fname; dns_name_t *name; - build_name_from_str(ordered_names[0], &fname); + dns_test_namefromstring(ordered_names[0], &fname); name = dns_fixedname_name(&fname); node = NULL; result = dns_rbt_findnode(mytree, name, NULL, @@ -829,9 +806,9 @@ ATF_TC_BODY(rbt_remove, tc) { dns_fixedname_t fname_j, fname_i; dns_name_t *name_j, *name_i; - build_name_from_str(ordered_names[j], &fname_j); + dns_test_namefromstring(ordered_names[j], &fname_j); name_j = dns_fixedname_name(&fname_j); - build_name_from_str(ordered_names[i], &fname_i); + dns_test_namefromstring(ordered_names[i], &fname_i); name_i = dns_fixedname_name(&fname_i); if (dns_name_equal(name_i, name_j)) { @@ -922,7 +899,7 @@ insert_nodes(dns_rbt_t *mytree, char **names, namebuf[32] = '.'; namebuf[33] = 0; - build_name_from_str(namebuf, &fname); + dns_test_namefromstring(namebuf, &fname); name = dns_fixedname_name(&fname); node = NULL; @@ -956,7 +933,7 @@ remove_nodes(dns_rbt_t *mytree, char **names, node %= *names_count; - build_name_from_str(names[node], &fname); + dns_test_namefromstring(names[node], &fname); name = dns_fixedname_name(&fname); result = dns_rbt_deletename(mytree, name, ISC_FALSE); @@ -1081,6 +1058,213 @@ ATF_TC_BODY(rbt_insert_and_remove, tc) { dns_test_end(); } +ATF_TC(rbt_findname); +ATF_TC_HEAD(rbt_findname, tc) { + atf_tc_set_md_var(tc, "descr", "findname return values"); +} +ATF_TC_BODY(rbt_findname, tc) { + isc_result_t result; + test_context_t *ctx = NULL; + dns_fixedname_t fname, found; + dns_name_t *name = NULL, *foundname = NULL; + size_t *n = NULL; + + UNUSED(tc); + + isc_mem_debugging = ISC_MEM_DEBUGRECORD; + + result = dns_test_begin(NULL, ISC_TRUE); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + ctx = test_context_setup(); + + /* Try to find a name that exists. */ + dns_test_namefromstring("d.e.f", &fname); + name = dns_fixedname_name(&fname); + + dns_fixedname_init(&found); + foundname = dns_fixedname_name(&found); + + result = dns_rbt_findname(ctx->rbt, name, + DNS_RBTFIND_EMPTYDATA, + foundname, (void *) &n); + ATF_CHECK(dns_name_equal(foundname, name)); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + /* Now without EMPTYDATA */ + result = dns_rbt_findname(ctx->rbt, name, 0, + foundname, (void *) &n); + ATF_CHECK_EQ(result, ISC_R_NOTFOUND); + + /* Now one that partially matches */ + dns_test_namefromstring("d.e.f.g.h.i.j", &fname); + name = dns_fixedname_name(&fname); + result = dns_rbt_findname(ctx->rbt, name, + DNS_RBTFIND_EMPTYDATA, + foundname, (void *) &n); + ATF_CHECK_EQ(result, DNS_R_PARTIALMATCH); + + /* Now one that doesn't match */ + dns_test_namefromstring("1.2", &fname); + name = dns_fixedname_name(&fname); + result = dns_rbt_findname(ctx->rbt, name, + DNS_RBTFIND_EMPTYDATA, + foundname, (void *) &n); + ATF_CHECK_EQ(result, DNS_R_PARTIALMATCH); + ATF_CHECK(dns_name_equal(foundname, dns_rootname)); + + test_context_teardown(ctx); + + dns_test_end(); +} + +ATF_TC(rbt_addname); +ATF_TC_HEAD(rbt_addname, tc) { + atf_tc_set_md_var(tc, "descr", "addname return values"); +} +ATF_TC_BODY(rbt_addname, tc) { + isc_result_t result; + test_context_t *ctx = NULL; + dns_fixedname_t fname; + dns_name_t *name = NULL; + size_t *n; + + UNUSED(tc); + + isc_mem_debugging = ISC_MEM_DEBUGRECORD; + + result = dns_test_begin(NULL, ISC_TRUE); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + ctx = test_context_setup(); + + n = isc_mem_get(mctx, sizeof(size_t)); + *n = 1; + + dns_test_namefromstring("d.e.f.g.h.i.j.k", &fname); + name = dns_fixedname_name(&fname); + + /* Add a name that doesn't exist */ + result = dns_rbt_addname(ctx->rbt, name, n); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* Now add again, should get ISC_R_EXISTS */ + n = isc_mem_get(mctx, sizeof(size_t)); + *n = 2; + result = dns_rbt_addname(ctx->rbt, name, n); + ATF_REQUIRE_EQ(result, ISC_R_EXISTS); + isc_mem_put(mctx, n, sizeof(size_t)); + + test_context_teardown(ctx); + + dns_test_end(); +} + +ATF_TC(rbt_deletename); +ATF_TC_HEAD(rbt_deletename, tc) { + atf_tc_set_md_var(tc, "descr", "deletename return values"); +} +ATF_TC_BODY(rbt_deletename, tc) { + isc_result_t result; + test_context_t *ctx = NULL; + dns_fixedname_t fname; + dns_name_t *name = NULL; + + UNUSED(tc); + + isc_mem_debugging = ISC_MEM_DEBUGRECORD; + + result = dns_test_begin(NULL, ISC_TRUE); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + ctx = test_context_setup(); + + /* Delete a name that doesn't exist */ + dns_test_namefromstring("z.x.y.w", &fname); + name = dns_fixedname_name(&fname); + result = dns_rbt_deletename(ctx->rbt, name, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND); + + /* Now one that does */ + dns_test_namefromstring("d.e.f", &fname); + name = dns_fixedname_name(&fname); + result = dns_rbt_deletename(ctx->rbt, name, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_NOTFOUND); + + test_context_teardown(ctx); + + dns_test_end(); +} + +ATF_TC(rbt_nodechain); +ATF_TC_HEAD(rbt_nodechain, tc) { + atf_tc_set_md_var(tc, "descr", "nodechain"); +} +ATF_TC_BODY(rbt_nodechain, tc) { + isc_result_t result; + test_context_t *ctx; + dns_fixedname_t fname, found, expect; + dns_name_t *name, *foundname, *expected; + dns_rbtnode_t *node = NULL; + dns_rbtnodechain_t chain; + + UNUSED(tc); + + isc_mem_debugging = ISC_MEM_DEBUGRECORD; + + result = dns_test_begin(NULL, ISC_TRUE); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + ctx = test_context_setup(); + + dns_rbtnodechain_init(&chain, mctx); + + dns_test_namefromstring("a", &fname); + name = dns_fixedname_name(&fname); + + result = dns_rbt_findnode(ctx->rbt, name, NULL, + &node, &chain, 0, NULL, NULL); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + dns_fixedname_init(&found); + foundname = dns_fixedname_name(&found); + + dns_test_namefromstring("a", &expect); + expected = dns_fixedname_name(&expect); + UNUSED(expected); + + result = dns_rbtnodechain_first(&chain, ctx->rbt, foundname, NULL); + ATF_CHECK_EQ(result, DNS_R_NEWORIGIN); + ATF_CHECK_EQ(dns_name_countlabels(foundname), 0); + + result = dns_rbtnodechain_prev(&chain, NULL, NULL); + ATF_CHECK_EQ(result, ISC_R_NOMORE); + + result = dns_rbtnodechain_next(&chain, NULL, NULL); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + result = dns_rbtnodechain_next(&chain, NULL, NULL); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + result = dns_rbtnodechain_last(&chain, ctx->rbt, NULL, NULL); + ATF_CHECK_EQ(result, DNS_R_NEWORIGIN); + + result = dns_rbtnodechain_next(&chain, NULL, NULL); + ATF_CHECK_EQ(result, ISC_R_NOMORE); + + result = dns_rbtnodechain_last(&chain, ctx->rbt, NULL, NULL); + ATF_CHECK_EQ(result, DNS_R_NEWORIGIN); + + result = dns_rbtnodechain_prev(&chain, NULL, NULL); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + dns_rbtnodechain_invalidate(&chain); + + test_context_teardown(ctx); + + dns_test_end(); +} + #ifdef ISC_PLATFORM_USETHREADS #ifdef DNS_BENCHMARK_TESTS @@ -1156,7 +1340,7 @@ ATF_TC_BODY(benchmark, tc) { for (i = 0; i < 4000000; i++) { r = ((unsigned long) random()) % maxvalue; snprintf(namestr, sizeof(namestr), "name%u.example.org.", r); - build_name_from_str(namestr, &fnames[i]); + dns_test_namefromstring(namestr, &fnames[i]); names[i] = dns_fixedname_name(&fnames[i]); values[i] = r; } @@ -1223,6 +1407,10 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, rbt_insert); ATF_TP_ADD_TC(tp, rbt_remove); ATF_TP_ADD_TC(tp, rbt_insert_and_remove); + ATF_TP_ADD_TC(tp, rbt_findname); + ATF_TP_ADD_TC(tp, rbt_addname); + ATF_TP_ADD_TC(tp, rbt_deletename); + ATF_TP_ADD_TC(tp, rbt_nodechain); #ifdef ISC_PLATFORM_USETHREADS #ifdef DNS_BENCHMARK_TESTS ATF_TP_ADD_TC(tp, benchmark); diff --git a/lib/dns/tests/resolver_test.c b/lib/dns/tests/resolver_test.c new file mode 100644 index 0000000000..1bb34f24a1 --- /dev/null +++ b/lib/dns/tests/resolver_test.c @@ -0,0 +1,228 @@ +/* + * 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. + */ + +/*! \file */ + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "dnstest.h" + +static dns_dispatchmgr_t *dispatchmgr = NULL; +static dns_dispatch_t *dispatch = NULL; +static dns_view_t *view = NULL; + + +static void +setup(void) { + isc_result_t result; + isc_sockaddr_t local; + + result = dns_test_begin(NULL, ISC_TRUE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dns_dispatchmgr_create(mctx, NULL, &dispatchmgr); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = dns_test_makeview("view", &view); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_sockaddr_any(&local); + result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &local, + 4096, 100, 100, 100, 500, 0, 0, + &dispatch); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); +} + +static void +teardown(void) { + dns_dispatch_detach(&dispatch); + dns_view_detach(&view); + dns_dispatchmgr_destroy(&dispatchmgr); + dns_test_end(); +} + + +static void +mkres(dns_resolver_t **resolverp) { + isc_result_t result; + + result = dns_resolver_create(view, taskmgr, 1, 1, + socketmgr, timermgr, 0, + dispatchmgr, dispatch, NULL, resolverp); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); +} + +static void +destroy_resolver(dns_resolver_t **resolverp) { + dns_resolver_shutdown(*resolverp); + dns_resolver_detach(resolverp); +} + +ATF_TC(create); +ATF_TC_HEAD(create, tc) { + atf_tc_set_md_var(tc, "descr", "dns_resolver_create"); +} +ATF_TC_BODY(create, tc) { + dns_resolver_t *resolver = NULL; + + UNUSED(tc); + + setup(); + mkres(&resolver); + destroy_resolver(&resolver); + teardown(); +} + +ATF_TC(gettimeout); +ATF_TC_HEAD(gettimeout, tc) { + atf_tc_set_md_var(tc, "descr", "dns_resolver_gettimeout"); +} +ATF_TC_BODY(gettimeout, tc) { + dns_resolver_t *resolver = NULL; + unsigned int timeout; + + UNUSED(tc); + + setup(); + mkres(&resolver); + + timeout = dns_resolver_gettimeout(resolver); + ATF_CHECK(timeout > 0); + + destroy_resolver(&resolver); + teardown(); +} + +ATF_TC(settimeout); +ATF_TC_HEAD(settimeout, tc) { + atf_tc_set_md_var(tc, "descr", "dns_resolver_settimeout"); +} +ATF_TC_BODY(settimeout, tc) { + dns_resolver_t *resolver = NULL; + unsigned int default_timeout, timeout; + + UNUSED(tc); + + setup(); + + mkres(&resolver); + + default_timeout = dns_resolver_gettimeout(resolver); + dns_resolver_settimeout(resolver, default_timeout + 1); + timeout = dns_resolver_gettimeout(resolver); + ATF_CHECK(timeout == default_timeout + 1); + + destroy_resolver(&resolver); + teardown(); +} + +ATF_TC(settimeout_default); +ATF_TC_HEAD(settimeout_default, tc) { + atf_tc_set_md_var(tc, "descr", "dns_resolver_settimeout to default"); +} +ATF_TC_BODY(settimeout_default, tc) { + dns_resolver_t *resolver = NULL; + unsigned int default_timeout, timeout; + + UNUSED(tc); + + setup(); + + mkres(&resolver); + + default_timeout = dns_resolver_gettimeout(resolver); + dns_resolver_settimeout(resolver, default_timeout + 100); + + timeout = dns_resolver_gettimeout(resolver); + ATF_CHECK_EQ(timeout, default_timeout + 100); + + dns_resolver_settimeout(resolver, 0); + timeout = dns_resolver_gettimeout(resolver); + ATF_CHECK_EQ(timeout, default_timeout); + + destroy_resolver(&resolver); + teardown(); +} + +ATF_TC(settimeout_belowmin); +ATF_TC_HEAD(settimeout_belowmin, tc) { + atf_tc_set_md_var(tc, "descr", + "dns_resolver_settimeout below minimum"); +} +ATF_TC_BODY(settimeout_belowmin, tc) { + dns_resolver_t *resolver = NULL; + unsigned int default_timeout, timeout; + + UNUSED(tc); + + setup(); + + mkres(&resolver); + + default_timeout = dns_resolver_gettimeout(resolver); + dns_resolver_settimeout(resolver, 9000); + + timeout = dns_resolver_gettimeout(resolver); + ATF_CHECK_EQ(timeout, default_timeout); + + destroy_resolver(&resolver); + teardown(); +} + +ATF_TC(settimeout_overmax); +ATF_TC_HEAD(settimeout_overmax, tc) { + atf_tc_set_md_var(tc, "descr", "dns_resolver_settimeout over maximum"); +} +ATF_TC_BODY(settimeout_overmax, tc) { + dns_resolver_t *resolver = NULL; + unsigned int timeout; + + UNUSED(tc); + + setup(); + + mkres(&resolver); + + dns_resolver_settimeout(resolver, 4000000); + timeout = dns_resolver_gettimeout(resolver); + ATF_CHECK(timeout < 4000000 && timeout > 0); + + destroy_resolver(&resolver); + teardown(); +} + +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, create); + ATF_TP_ADD_TC(tp, gettimeout); + ATF_TP_ADD_TC(tp, settimeout); + ATF_TP_ADD_TC(tp, settimeout_default); + ATF_TP_ADD_TC(tp, settimeout_belowmin); + ATF_TP_ADD_TC(tp, settimeout_overmax); + return (atf_no_error()); +} diff --git a/lib/dns/tests/testdata/db/data.db b/lib/dns/tests/testdata/db/data.db new file mode 100644 index 0000000000..9ac043eb2f --- /dev/null +++ b/lib/dns/tests/testdata/db/data.db @@ -0,0 +1,20 @@ +; 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. + +$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/dst/Ktest.+001+00002.key.in b/lib/dns/tests/testdata/dst/Ktest.+001+00002.key similarity index 100% rename from bin/tests/dst/Ktest.+001+00002.key.in rename to lib/dns/tests/testdata/dst/Ktest.+001+00002.key diff --git a/bin/tests/dst/Ktest.+001+54622.key.in b/lib/dns/tests/testdata/dst/Ktest.+001+54622.key similarity index 100% rename from bin/tests/dst/Ktest.+001+54622.key.in rename to lib/dns/tests/testdata/dst/Ktest.+001+54622.key diff --git a/bin/tests/dst/Ktest.+001+54622.private.in b/lib/dns/tests/testdata/dst/Ktest.+001+54622.private similarity index 100% rename from bin/tests/dst/Ktest.+001+54622.private.in rename to lib/dns/tests/testdata/dst/Ktest.+001+54622.private diff --git a/bin/tests/dst/Ktest.+003+23616.key.in b/lib/dns/tests/testdata/dst/Ktest.+003+23616.key similarity index 100% rename from bin/tests/dst/Ktest.+003+23616.key.in rename to lib/dns/tests/testdata/dst/Ktest.+003+23616.key diff --git a/bin/tests/dst/Ktest.+003+23616.private.in b/lib/dns/tests/testdata/dst/Ktest.+003+23616.private similarity index 100% rename from bin/tests/dst/Ktest.+003+23616.private.in rename to lib/dns/tests/testdata/dst/Ktest.+003+23616.private diff --git a/bin/tests/dst/Ktest.+003+49667.key.in b/lib/dns/tests/testdata/dst/Ktest.+003+49667.key similarity index 100% rename from bin/tests/dst/Ktest.+003+49667.key.in rename to lib/dns/tests/testdata/dst/Ktest.+003+49667.key diff --git a/bin/tests/dst/t2_data_1.in b/lib/dns/tests/testdata/dst/test1.data similarity index 100% rename from bin/tests/dst/t2_data_1.in rename to lib/dns/tests/testdata/dst/test1.data diff --git a/bin/tests/dst/t2_dsasig.in b/lib/dns/tests/testdata/dst/test1.dsasig similarity index 100% rename from bin/tests/dst/t2_dsasig.in rename to lib/dns/tests/testdata/dst/test1.dsasig diff --git a/bin/tests/dst/t2_rsasig.in b/lib/dns/tests/testdata/dst/test1.rsasig similarity index 99% rename from bin/tests/dst/t2_rsasig.in rename to lib/dns/tests/testdata/dst/test1.rsasig index 5f59ef3701..5ba62b4a14 100644 --- a/bin/tests/dst/t2_rsasig.in +++ b/lib/dns/tests/testdata/dst/test1.rsasig @@ -3,4 +3,3 @@ FF66AB866EF0BDB0F515001E234E699B F5CD6FB41FB15D4213705ABE9B563896 2196228648E0F8AA7F2F4EED3C19165C 1B4C70C9D69B93A1F2BE5B2F948CE023 - diff --git a/bin/tests/dst/t2_data_2.in b/lib/dns/tests/testdata/dst/test2.data similarity index 100% rename from bin/tests/dst/t2_data_2.in rename to lib/dns/tests/testdata/dst/test2.data diff --git a/lib/isc/tests/Atffile b/lib/isc/tests/Atffile index 5ed35d264b..506c656e8f 100644 --- a/lib/isc/tests/Atffile +++ b/lib/isc/tests/Atffile @@ -3,6 +3,7 @@ Content-Type: application/X-atf-atffile; version="1" prop: test-suite = bind9 tp: aes_test +tp: atomic_test tp: buffer_test tp: counter_test tp: errno_test @@ -28,4 +29,5 @@ tp: socket_test tp: symtab_test tp: task_test tp: taskpool_test +tp: timer_test tp: time_test diff --git a/lib/isc/tests/Kyuafile b/lib/isc/tests/Kyuafile index fce8cfbfa9..1c510c1211 100644 --- a/lib/isc/tests/Kyuafile +++ b/lib/isc/tests/Kyuafile @@ -2,6 +2,7 @@ syntax(2) test_suite('bind9') atf_test_program{name='aes_test'} +atf_test_program{name='atomic_test'} atf_test_program{name='buffer_test'} atf_test_program{name='counter_test'} atf_test_program{name='errno_test'} @@ -28,3 +29,4 @@ atf_test_program{name='symtab_test'} atf_test_program{name='task_test'} atf_test_program{name='taskpool_test'} atf_test_program{name='time_test'} +atf_test_program{name='timer_test'} diff --git a/lib/isc/tests/Makefile.in b/lib/isc/tests/Makefile.in index f9cb409388..ff22d22462 100644 --- a/lib/isc/tests/Makefile.in +++ b/lib/isc/tests/Makefile.in @@ -28,29 +28,33 @@ ISCDEPLIBS = ../libisc.@A@ LIBS = @LIBS@ @ATFLIBS@ OBJS = isctest.@O@ -SRCS = isctest.c aes_test.c buffer_test.c counter_test.c \ - errno_test.c file_test.c hash_test.c heap_test.c \ - ht_test.c inet_ntop_test.c lex_test.c mem_test.c \ - netaddr_test.c parse_test.c pool_test.c print_test.c \ - queue_test.c radix_test.c random_test.c regex_test.c \ - result_test.c safe_test.c sockaddr_test.c \ +SRCS = isctest.c aes_test.c atomic_test.c buffer_test.c \ + counter_test.c errno_test.c file_test.c hash_test.c \ + heap_test.c ht_test.c inet_ntop_test.c lex_test.c \ + mem_test.c netaddr_test.c parse_test.c pool_test.c \ + print_test.c queue_test.c radix_test.c random_test.c \ + regex_test.c result_test.c safe_test.c sockaddr_test.c \ socket_test.c socket_test.c symtab_test.c task_test.c \ - taskpool_test.c time_test.c + taskpool_test.c time_test.c timer_test.c SUBDIRS = -TARGETS = aes_test@EXEEXT@ buffer_test@EXEEXT@ counter_test@EXEEXT@ \ - errno_test@EXEEXT@ file_test@EXEEXT@ hash_test@EXEEXT@ \ - heap_test@EXEEXT@ ht_test@EXEEXT@ inet_ntop_test@EXEEXT@ \ - lex_test@EXEEXT@ mem_test@EXEEXT@ netaddr_test@EXEEXT@ \ - parse_test@EXEEXT@ pool_test@EXEEXT@ print_test@EXEEXT@ \ - queue_test@EXEEXT@ radix_test@EXEEXT@ random_test@EXEEXT@ \ - regex_test@EXEEXT@ result_test@EXEEXT@ safe_test@EXEEXT@ \ - sockaddr_test@EXEEXT@ socket_test@EXEEXT@ \ +TARGETS = aes_test@EXEEXT@ atomic_test@EXEEXT@ buffer_test@EXEEXT@ \ + counter_test@EXEEXT@ errno_test@EXEEXT@ file_test@EXEEXT@ \ + hash_test@EXEEXT@ heap_test@EXEEXT@ ht_test@EXEEXT@ \ + inet_ntop_test@EXEEXT@ lex_test@EXEEXT@ mem_test@EXEEXT@ \ + netaddr_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \ + print_test@EXEEXT@ queue_test@EXEEXT@ radix_test@EXEEXT@ \ + random_test@EXEEXT@ regex_test@EXEEXT@ result_test@EXEEXT@ \ + safe_test@EXEEXT@ sockaddr_test@EXEEXT@ socket_test@EXEEXT@ \ socket_test@EXEEXT@ symtab_test@EXEEXT@ task_test@EXEEXT@ \ - taskpool_test@EXEEXT@ time_test@EXEEXT@ + taskpool_test@EXEEXT@ time_test@EXEEXT@ timer_test@EXEEXT@ @BIND9_MAKE_RULES@ +atomic_test@EXEEXT@: atomic_test.@O@ isctest.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + atomic_test.@O@ isctest.@O@ ${ISCLIBS} ${LIBS} + aes_test@EXEEXT@: aes_test.@O@ ${ISCDEPLIBS} ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ aes_test.@O@ ${ISCLIBS} ${LIBS} @@ -161,6 +165,10 @@ time_test@EXEEXT@: time_test.@O@ ${ISCDEPLIBS} ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ time_test.@O@ ${ISCLIBS} ${LIBS} +timer_test@EXEEXT@: timer_test.@O@ isctest.@O@ ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + timer_test.@O@ isctest.@O@ ${ISCLIBS} ${LIBS} + unit:: sh ${top_builddir}/unit/unittest.sh diff --git a/bin/tests/atomic/t_atomic.c b/lib/isc/tests/atomic_test.c similarity index 59% rename from bin/tests/atomic/t_atomic.c rename to lib/isc/tests/atomic_test.c index 2e46503924..9bb6cc943b 100644 --- a/bin/tests/atomic/t_atomic.c +++ b/lib/isc/tests/atomic_test.c @@ -10,45 +10,17 @@ */ #include - -#include #include +#include + #include -#include -#include -#include -#include -#include -#include +#include -#include - -char *progname; - -#define CHECK(x) RUNTIME_CHECK(ISC_R_SUCCESS == (x)) - -isc_mem_t *mctx = NULL; -isc_taskmgr_t *task_manager = NULL; - -#if defined(ISC_PLATFORM_HAVEXADD) || defined(ISC_PLATFORM_HAVEXADDQ) || \ - defined(ISC_PLATFORM_HAVEATOMICSTORE) || \ - defined(ISC_PLATFORM_HAVEATOMICSTOREQ) -static void -setup(void) { - /* 1 */ CHECK(isc_mem_create(0, 0, &mctx)); - /* 2 */ CHECK(isc_taskmgr_create(mctx, 32, 0, &task_manager)); -} - -static void -teardown(void) { - /* 2 */ isc_taskmgr_destroy(&task_manager); - /* 1 */ isc_mem_destroy(&mctx); -} -#endif +#include "isctest.h" #define TASKS 32 -#define ITERATIONS 10000 +#define ITERATIONS 1000 #define COUNTS_PER_ITERATION 1000 #define INCREMENT_64 (isc_int64_t)0x0000000010000000 #define EXPECTED_COUNT_32 (TASKS * ITERATIONS * COUNTS_PER_ITERATION) @@ -80,17 +52,20 @@ do_xadd(isc_task_t *task, isc_event_t *ev) { } } -static void -test_atomic_xadd() { - int test_result; +ATF_TC(atomic_xadd); +ATF_TC_HEAD(atomic_xadd, tc) { + atf_tc_set_md_var(tc, "descr", "atomic XADD"); +} +ATF_TC_BODY(atomic_xadd, tc) { + isc_result_t result; isc_task_t *tasks[TASKS]; - isc_event_t *event; + isc_event_t *event = NULL; int i; - t_assert("test_atomic_xadd", 1, T_REQUIRED, "%s", - "ensure that isc_atomic_xadd() works."); + UNUSED(tc); - setup(); + result = isc_test_begin(NULL, ISC_TRUE, 0); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); memset(counters, 0, sizeof(counters)); counter_32 = 0; @@ -100,20 +75,21 @@ test_atomic_xadd() { */ for (i = 0 ; i < TASKS ; i++) { tasks[i] = NULL; - CHECK(isc_task_create(task_manager, 0, &tasks[i])); + ATF_REQUIRE_EQ(isc_task_create(taskmgr, 0, &tasks[i]), + ISC_R_SUCCESS); event = isc_event_allocate(mctx, NULL, 1000, do_xadd, - &counters[i], sizeof(struct isc_event)); + &counters[i], + sizeof(struct isc_event)); + ATF_REQUIRE(event != NULL); isc_task_sendanddetach(&tasks[i], &event); } - teardown(); + isc_test_end(); - test_result = T_PASS; - t_info("32-bit counter %d, expected %d\n", counter_32, EXPECTED_COUNT_32); - if (counter_32 != EXPECTED_COUNT_32) - test_result = T_FAIL; - t_result(test_result); + printf("32-bit counter %d, expected %d\n", + counter_32, EXPECTED_COUNT_32); + ATF_CHECK_EQ(counter_32, EXPECTED_COUNT_32); counter_32 = 0; } #endif @@ -138,17 +114,20 @@ do_xaddq(isc_task_t *task, isc_event_t *ev) { } } -static void -test_atomic_xaddq() { - int test_result; +ATF_TC(atomic_xaddq); +ATF_TC_HEAD(atomic_xaddq, tc) { + atf_tc_set_md_var(tc, "descr", "atomic XADDQ"); +} +ATF_TC_BODY(atomic_xaddq, tc) { + isc_result_t result; isc_task_t *tasks[TASKS]; - isc_event_t *event; + isc_event_t *event = NULL; int i; - t_assert("test_atomic_xaddq", 1, T_REQUIRED, "%s", - "ensure that isc_atomic_xaddq() works."); + UNUSED(tc); - setup(); + result = isc_test_begin(NULL, ISC_TRUE, 0); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); memset(counters, 0, sizeof(counters)); counter_64 = 0; @@ -158,26 +137,27 @@ test_atomic_xaddq() { */ for (i = 0 ; i < TASKS ; i++) { tasks[i] = NULL; - CHECK(isc_task_create(task_manager, 0, &tasks[i])); + ATF_REQUIRE_EQ(isc_task_create(taskmgr, 0, &tasks[i]), + ISC_R_SUCCESS); event = isc_event_allocate(mctx, NULL, 1000, do_xaddq, - &counters[i], sizeof(struct isc_event)); + &counters[i], + sizeof(struct isc_event)); + ATF_REQUIRE(event != NULL); isc_task_sendanddetach(&tasks[i], &event); } - teardown(); + isc_test_end(); - test_result = T_PASS; - t_info("64-bit counter %"ISC_PRINT_QUADFORMAT"d, expected %"ISC_PRINT_QUADFORMAT"d\n", + printf("64-bit counter %"ISC_PRINT_QUADFORMAT"d, " + "expected %"ISC_PRINT_QUADFORMAT"d\n", counter_64, EXPECTED_COUNT_64); - if (counter_64 != EXPECTED_COUNT_64) - test_result = T_FAIL; - t_result(test_result); - counter_64 = 0; + ATF_CHECK_EQ(counter_64, EXPECTED_COUNT_64); + counter_32 = 0; } #endif -#ifdef ISC_PLATFORM_HAVEATOMICSTORE +#if defined(ISC_PLATFORM_HAVEATOMICSTORE) static isc_int32_t store_32; static void @@ -202,19 +182,22 @@ do_store(isc_task_t *task, isc_event_t *ev) { } } -static void -test_atomic_store() { - int test_result; +ATF_TC(atomic_store); +ATF_TC_HEAD(atomic_store, tc) { + atf_tc_set_md_var(tc, "descr", "atomic STORE"); +} +ATF_TC_BODY(atomic_store, tc) { + isc_result_t result; isc_task_t *tasks[TASKS]; - isc_event_t *event; - int i; - isc_uint32_t r; + isc_event_t *event = NULL; isc_uint32_t val; + isc_uint32_t r; + int i; - t_assert("test_atomic_store", 1, T_REQUIRED, "%s", - "ensure that isc_atomic_store() works."); + UNUSED(tc); - setup(); + result = isc_test_begin(NULL, ISC_TRUE, 0); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); memset(counters, 0, sizeof(counters)); store_32 = 0; @@ -225,24 +208,24 @@ test_atomic_store() { */ for (i = 0 ; i < TASKS ; i++) { tasks[i] = NULL; - CHECK(isc_task_create(task_manager, 0, &tasks[i])); + ATF_REQUIRE_EQ(isc_task_create(taskmgr, 0, &tasks[i]), + ISC_R_SUCCESS); event = isc_event_allocate(mctx, NULL, 1000, do_store, &counters[i], sizeof(struct isc_event)); + ATF_REQUIRE(event != NULL); isc_task_sendanddetach(&tasks[i], &event); } - teardown(); + isc_test_end(); - test_result = T_PASS; r = store_32 & 0xff; val = (r << 24) | (r << 16) | (r << 8) | r; - t_info("32-bit store 0x%x, expected 0x%x\n", - (isc_uint32_t) store_32, val); - if ((isc_uint32_t) store_32 != val) - test_result = T_FAIL; - t_result(test_result); + printf("32-bit store 0x%x, expected 0x%x\n", + (isc_uint32_t) store_32, val); + + ATF_CHECK_EQ((isc_uint32_t) store_32, val); store_32 = 0; } #endif @@ -276,73 +259,74 @@ do_storeq(isc_task_t *task, isc_event_t *ev) { } } -static void -test_atomic_storeq() { - int test_result; +ATF_TC(atomic_storeq); +ATF_TC_HEAD(atomic_storeq, tc) { + atf_tc_set_md_var(tc, "descr", "atomic STOREQ"); +} +ATF_TC_BODY(atomic_storeq, tc) { + isc_result_t result; isc_task_t *tasks[TASKS]; - isc_event_t *event; - int i; - isc_uint8_t r; + isc_event_t *event = NULL; isc_uint64_t val; + isc_uint32_t r; + int i; - t_assert("test_atomic_storeq", 1, T_REQUIRED, "%s", - "ensure that isc_atomic_storeq() works."); + UNUSED(tc); - setup(); + result = isc_test_begin(NULL, ISC_TRUE, 0); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); memset(counters, 0, sizeof(counters)); store_64 = 0; /* - * Create our tasks, and allocate an event to get the counters going. + * Create our tasks, and allocate an event to get the counters + * going. */ for (i = 0 ; i < TASKS ; i++) { tasks[i] = NULL; - CHECK(isc_task_create(task_manager, 0, &tasks[i])); + ATF_REQUIRE_EQ(isc_task_create(taskmgr, 0, &tasks[i]), + ISC_R_SUCCESS); event = isc_event_allocate(mctx, NULL, 1000, do_storeq, - &counters[i], sizeof(struct isc_event)); + &counters[i], + sizeof(struct isc_event)); + ATF_REQUIRE(event != NULL); isc_task_sendanddetach(&tasks[i], &event); } - teardown(); + isc_test_end(); - test_result = T_PASS; r = store_64 & 0xff; val = (((isc_uint64_t) r << 24) | ((isc_uint64_t) r << 16) | ((isc_uint64_t) r << 8) | (isc_uint64_t) r); val |= ((isc_uint64_t) val << 32); - t_info("64-bit store 0x%"ISC_PRINT_QUADFORMAT"x, expected 0x%"ISC_PRINT_QUADFORMAT"x\n", - (isc_uint64_t) store_64, val); - if ((isc_uint64_t) store_64 != val) - test_result = T_FAIL; - t_result(test_result); + printf("64-bit store 0x%"ISC_PRINT_QUADFORMAT"x, " + "expected 0x%"ISC_PRINT_QUADFORMAT"x\n", + (isc_uint64_t) store_64, val); + + ATF_CHECK_EQ((isc_uint64_t) store_64, val); store_64 = 0; } -#endif /* ISC_PLATFORM_HAVEATOMICSTOREQ */ +#endif -testspec_t T_testlist[] = { +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { #if defined(ISC_PLATFORM_HAVEXADD) - { (PFV) test_atomic_xadd, "test_atomic_xadd" }, + ATF_TP_ADD_TC(tp, atomic_xadd); #endif #if defined(ISC_PLATFORM_HAVEXADDQ) - { (PFV) test_atomic_xaddq, "test_atomic_xaddq" }, + ATF_TP_ADD_TC(tp, atomic_xaddq); #endif #ifdef ISC_PLATFORM_HAVEATOMICSTORE - { (PFV) test_atomic_store, "test_atomic_store" }, + ATF_TP_ADD_TC(tp, atomic_store); #endif #if defined(ISC_PLATFORM_HAVEATOMICSTOREQ) - { (PFV) test_atomic_storeq, "test_atomic_storeq" }, + ATF_TP_ADD_TC(tp, atomic_storeq); #endif - { (PFV) 0, NULL } -}; - -#ifdef WIN32 -int -main(int argc, char **argv) { - t_settests(T_testlist); - return (t_main(argc, argv)); + return (atf_no_error()); } -#endif diff --git a/lib/isc/tests/buffer_test.c b/lib/isc/tests/buffer_test.c index 0c17eb63af..9fead36a0e 100644 --- a/lib/isc/tests/buffer_test.c +++ b/lib/isc/tests/buffer_test.c @@ -31,7 +31,7 @@ ATF_TC_BODY(isc_buffer_reserve, tc) { isc_result_t result; isc_buffer_t *b; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); b = NULL; @@ -105,7 +105,7 @@ ATF_TC_BODY(isc_buffer_reallocate, tc) { isc_result_t result; isc_buffer_t *b; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); b = NULL; @@ -142,7 +142,7 @@ ATF_TC_BODY(isc_buffer_dynamic, tc) { size_t last_length = 10; int i; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); b = NULL; @@ -205,7 +205,7 @@ ATF_TC_BODY(isc_buffer_printf, tc) { isc_buffer_t *b, sb; char buf[8]; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); /* diff --git a/lib/isc/tests/counter_test.c b/lib/isc/tests/counter_test.c index d24557241c..f2a5bcd031 100644 --- a/lib/isc/tests/counter_test.c +++ b/lib/isc/tests/counter_test.c @@ -28,7 +28,7 @@ ATF_TC_BODY(isc_counter, tc) { isc_counter_t *counter = NULL; int i; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_counter_create(mctx, 0, &counter); diff --git a/lib/isc/tests/ht_test.c b/lib/isc/tests/ht_test.c index c64b1edfed..4b069ef68a 100644 --- a/lib/isc/tests/ht_test.c +++ b/lib/isc/tests/ht_test.c @@ -298,12 +298,12 @@ static void test_ht_iterator() { ATF_TC(isc_ht_20); ATF_TC_HEAD(isc_ht_20, tc) { - atf_tc_set_md_var(tc, "descr", "20 bit, 2M elements test"); + atf_tc_set_md_var(tc, "descr", "20 bit, 200K elements test"); } ATF_TC_BODY(isc_ht_20, tc) { UNUSED(tc); - test_ht_full(20, 2000000); + test_ht_full(20, 200000); } diff --git a/lib/isc/tests/isctest.c b/lib/isc/tests/isctest.c index 29c50d7e44..bb1a6245b2 100644 --- a/lib/isc/tests/isctest.c +++ b/lib/isc/tests/isctest.c @@ -9,12 +9,11 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include +#include #include #include @@ -70,15 +69,24 @@ cleanup_managers(void) { } static isc_result_t -create_managers(void) { +create_managers(unsigned int workers) { isc_result_t result; -#ifdef ISC_PLATFORM_USETHREADS - ncpus = isc_os_ncpus(); -#else - ncpus = 1; -#endif + char *p; - CHECK(isc_taskmgr_create(mctx, ncpus, 0, &taskmgr)); + if (workers == 0) { +#ifdef ISC_PLATFORM_USETHREADS + workers = isc_os_ncpus(); +#else + workers = 1; +#endif + } + + p = getenv("ISC_TASK_WORKERS"); + if (p != NULL) { + workers = atoi(p); + } + + CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr)); CHECK(isc_task_create(taskmgr, 0, &maintask)); isc_taskmgr_setexcltask(taskmgr, maintask); @@ -92,7 +100,9 @@ create_managers(void) { } isc_result_t -isc_test_begin(FILE *logfile, isc_boolean_t start_managers) { +isc_test_begin(FILE *logfile, isc_boolean_t start_managers, + unsigned int workers) +{ isc_result_t result; isc_mem_debugging |= ISC_MEM_DEBUGRECORD; @@ -127,8 +137,9 @@ isc_test_begin(FILE *logfile, isc_boolean_t start_managers) { ncpus = 1; #endif - if (start_managers) - CHECK(create_managers()); + if (start_managers) { + CHECK(create_managers(workers)); + } return (ISC_R_SUCCESS); diff --git a/lib/isc/tests/isctest.h b/lib/isc/tests/isctest.h index caf1c3c749..b596993ccb 100644 --- a/lib/isc/tests/isctest.h +++ b/lib/isc/tests/isctest.h @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -43,7 +41,18 @@ extern isc_socketmgr_t *socketmgr; extern int ncpus; isc_result_t -isc_test_begin(FILE *logfile, isc_boolean_t start_managers); +isc_test_begin(FILE *logfile, isc_boolean_t start_managers, + unsigned int workers); +/*%< + * Begin test, logging to 'logfile' or default if not specified. + * + * If 'start_managers' is set, start a task manager, timer manager, + * and socket manager. + * + * If 'workers' is zero, use the number of CPUs on the system as a default; + * otherwise, set up the task manager with the specified number of worker + * threads. The environment variable ISC_TASK_WORKERS overrides this value. + */ void isc_test_end(void); diff --git a/lib/isc/tests/mem_test.c b/lib/isc/tests/mem_test.c index f551509818..60aa07e2f7 100644 --- a/lib/isc/tests/mem_test.c +++ b/lib/isc/tests/mem_test.c @@ -38,6 +38,108 @@ default_memfree(void *arg, void *ptr) { free(ptr); } +ATF_TC(isc_mem); +ATF_TC_HEAD(isc_mem, tc) { + atf_tc_set_md_var(tc, "descr", "general memory system tests"); +} + +#define MP1_FREEMAX 10 +#define MP1_FILLCNT 10 +#define MP1_MAXALLOC 30 + +#define MP2_FREEMAX 25 +#define MP2_FILLCNT 25 + +ATF_TC_BODY(isc_mem, tc) { + isc_result_t result; + void *items1[50]; + void *items2[50]; + void *tmp; + isc_mem_t *localmctx = NULL; + isc_mempool_t *mp1 = NULL, *mp2 = NULL; + unsigned int i, j; + int rval; + + result = isc_test_begin(NULL, ISC_TRUE, 0); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mem_create(0, 0, &localmctx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mempool_create(localmctx, 24, &mp1); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mempool_create(localmctx, 31, &mp2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_mempool_setfreemax(mp1, MP1_FREEMAX); + isc_mempool_setfillcount(mp1, MP1_FILLCNT); + isc_mempool_setmaxalloc(mp1, MP1_MAXALLOC); + + /* + * Allocate MP1_MAXALLOC items from the pool. This is our max. + */ + for (i = 0; i < MP1_MAXALLOC; i++) { + items1[i] = isc_mempool_get(mp1); + ATF_CHECK(items1[i] != NULL); + } + + /* + * Try to allocate one more. This should fail. + */ + tmp = isc_mempool_get(mp1); + ATF_CHECK_EQ(tmp, NULL); + + /* + * Free the first 11 items. Verify that there are 10 free items on + * the free list (which is our max). + */ + for (i = 0; i < 11; i++) { + isc_mempool_put(mp1, items1[i]); + items1[i] = NULL; + } + + rval = isc_mempool_getfreecount(mp1); + ATF_CHECK_EQ(rval, 10); + + rval = isc_mempool_getallocated(mp1); + ATF_CHECK_EQ(rval, 19); + + /* + * Now, beat up on mp2 for a while. Allocate 50 items, then free + * them, then allocate 50 more, etc. + */ + + isc_mempool_setfreemax(mp2, 25); + isc_mempool_setfillcount(mp2, 25); + + for (j = 0; j < 500000; j++) { + for (i = 0; i < 50; i++) { + items2[i] = isc_mempool_get(mp2); + ATF_CHECK(items2[i] != NULL); + } + for (i = 0; i < 50; i++) { + isc_mempool_put(mp2, items2[i]); + items2[i] = NULL; + } + } + + /* + * Free all the other items and blow away this pool. + */ + for (i = 11; i < MP1_MAXALLOC; i++) { + isc_mempool_put(mp1, items1[i]); + items1[i] = NULL; + } + + isc_mempool_destroy(&mp1); + isc_mempool_destroy(&mp2); + + isc_mem_destroy(&localmctx); + + isc_test_end(); +} + ATF_TC(isc_mem_total); ATF_TC_HEAD(isc_mem_total, tc) { atf_tc_set_md_var(tc, "descr", "test TotalUse calculation"); @@ -50,7 +152,7 @@ ATF_TC_BODY(isc_mem_total, tc) { ssize_t diff; int i; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); /* Local alloc, free */ @@ -117,7 +219,7 @@ ATF_TC_BODY(isc_mem_inuse, tc) { ssize_t diff; void *ptr; - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); mctx2 = NULL; @@ -162,7 +264,7 @@ ATF_TC_BODY(isc_mem_noflags, tc) { result = isc_stdio_open("mem.output", "w", &f); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_mem_createx2(0, 0, default_memalloc, default_memfree, @@ -214,7 +316,7 @@ ATF_TC_BODY(isc_mem_recordflag, tc) { result = isc_stdio_open("mem.output", "w", &f); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = isc_test_begin(NULL, ISC_FALSE); + result = isc_test_begin(NULL, ISC_FALSE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_mem_createx2(0, 0, default_memalloc, default_memfree, @@ -264,7 +366,7 @@ ATF_TC_BODY(isc_mem_traceflag, tc) { f = freopen("mem.output", "w", stderr); ATF_REQUIRE(f != NULL); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_mem_createx2(0, 0, default_memalloc, default_memfree, @@ -311,6 +413,7 @@ ATF_TC_BODY(isc_mem_traceflag, tc) { * Main */ ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, isc_mem); ATF_TP_ADD_TC(tp, isc_mem_total); ATF_TP_ADD_TC(tp, isc_mem_inuse); #if ISC_MEM_TRACKLINES diff --git a/lib/isc/tests/netaddr_test.c b/lib/isc/tests/netaddr_test.c index ecd80f3c86..adfb48cfaa 100644 --- a/lib/isc/tests/netaddr_test.c +++ b/lib/isc/tests/netaddr_test.c @@ -19,12 +19,14 @@ #include #include +#include +#include -ATF_TC(isc_netaddr_isnetzero); -ATF_TC_HEAD(isc_netaddr_isnetzero, tc) { - atf_tc_set_md_var(tc, "descr", "test isc_netaddr_isnetzero"); +ATF_TC(netaddr_isnetzero); +ATF_TC_HEAD(netaddr_isnetzero, tc) { + atf_tc_set_md_var(tc, "descr", "test netaddr_isnetzero"); } -ATF_TC_BODY(isc_netaddr_isnetzero, tc) { +ATF_TC_BODY(netaddr_isnetzero, tc) { unsigned int i; struct in_addr ina; struct { @@ -54,12 +56,101 @@ ATF_TC_BODY(isc_netaddr_isnetzero, tc) { } } +ATF_TC(netaddr_masktoprefixlen); +ATF_TC_HEAD(netaddr_masktoprefixlen, tc) { + atf_tc_set_md_var(tc, "descr", + "isc_netaddr_masktoprefixlen() " + "calculates correct prefix lengths "); +} +ATF_TC_BODY(netaddr_masktoprefixlen, tc) { + struct in_addr na_a; + struct in_addr na_b; + struct in_addr na_c; + struct in_addr na_d; + isc_netaddr_t ina_a; + isc_netaddr_t ina_b; + isc_netaddr_t ina_c; + isc_netaddr_t ina_d; + unsigned int plen; + + UNUSED(tc); + + ATF_CHECK(inet_pton(AF_INET, "0.0.0.0", &na_a) >= 0); + ATF_CHECK(inet_pton(AF_INET, "255.255.255.254", &na_b) >= 0); + ATF_CHECK(inet_pton(AF_INET, "255.255.255.255", &na_c) >= 0); + ATF_CHECK(inet_pton(AF_INET, "255.255.255.0", &na_d) >= 0); + + isc_netaddr_fromin(&ina_a, &na_a); + isc_netaddr_fromin(&ina_b, &na_b); + isc_netaddr_fromin(&ina_c, &na_c); + isc_netaddr_fromin(&ina_d, &na_d); + + ATF_CHECK_EQ(isc_netaddr_masktoprefixlen(&ina_a, &plen), + ISC_R_SUCCESS); + ATF_CHECK_EQ(plen, 0); + + ATF_CHECK_EQ(isc_netaddr_masktoprefixlen(&ina_b, &plen), + ISC_R_SUCCESS); + ATF_CHECK_EQ(plen, 31); + + ATF_CHECK_EQ(isc_netaddr_masktoprefixlen(&ina_c, &plen), + ISC_R_SUCCESS); + ATF_CHECK_EQ(plen, 32); + + ATF_CHECK_EQ(isc_netaddr_masktoprefixlen(&ina_d, &plen), + ISC_R_SUCCESS); + ATF_CHECK_EQ(plen, 24); +} + +ATF_TC(netaddr_multicast); +ATF_TC_HEAD(netaddr_multicast, tc) { + atf_tc_set_md_var(tc, "descr", + "check multicast addresses are detected properly"); +} +ATF_TC_BODY(netaddr_multicast, tc) { + unsigned int i; + struct { + int family; + const char *addr; + isc_boolean_t is_multicast; + } tests[] = { + { AF_INET, "1.2.3.4", ISC_FALSE }, + { AF_INET, "4.3.2.1", ISC_FALSE }, + { AF_INET, "224.1.1.1", ISC_TRUE }, + { AF_INET, "1.1.1.244", ISC_FALSE }, + { AF_INET6, "::1", ISC_FALSE }, + { AF_INET6, "ff02::1", ISC_TRUE } + }; + + for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + isc_netaddr_t na; + struct in_addr in; + struct in6_addr in6; + int r; + + if (tests[i].family == AF_INET) { + r = inet_pton(AF_INET, tests[i].addr, + (unsigned char *)&in); + ATF_REQUIRE_EQ(r, 1); + isc_netaddr_fromin(&na, &in); + } else { + r = inet_pton(AF_INET6, tests[i].addr, + (unsigned char *)&in6); + ATF_REQUIRE_EQ(r, 1); + isc_netaddr_fromin6(&na, &in6); + } + + ATF_CHECK_EQ(isc_netaddr_ismulticast(&na), + tests[i].is_multicast); + } +} /* * Main */ ATF_TP_ADD_TCS(tp) { - - ATF_TP_ADD_TC(tp, isc_netaddr_isnetzero); + ATF_TP_ADD_TC(tp, netaddr_isnetzero); + ATF_TP_ADD_TC(tp, netaddr_masktoprefixlen); + ATF_TP_ADD_TC(tp, netaddr_multicast); return (atf_no_error()); } diff --git a/lib/isc/tests/parse_test.c b/lib/isc/tests/parse_test.c index 7f7f4ad330..9409dd0e90 100644 --- a/lib/isc/tests/parse_test.c +++ b/lib/isc/tests/parse_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -38,7 +36,7 @@ ATF_TC_BODY(parse_overflow, tc) { isc_uint32_t output; UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_parse_uint32(&output, "1234567890", 10); diff --git a/lib/isc/tests/pool_test.c b/lib/isc/tests/pool_test.c index 45ad3dee20..0d24779920 100644 --- a/lib/isc/tests/pool_test.c +++ b/lib/isc/tests/pool_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -60,7 +58,7 @@ ATF_TC_BODY(create_pool, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_pool_create(mctx, 8, poolfree, poolinit, taskmgr, &pool); @@ -84,7 +82,7 @@ ATF_TC_BODY(expand_pool, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_pool_create(mctx, 10, poolfree, poolinit, taskmgr, &pool1); @@ -138,7 +136,7 @@ ATF_TC_BODY(get_objects, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_pool_create(mctx, 2, poolfree, poolinit, taskmgr, &pool); diff --git a/lib/isc/tests/queue_test.c b/lib/isc/tests/queue_test.c index 388aa873b1..36bdb9fa50 100644 --- a/lib/isc/tests/queue_test.c +++ b/lib/isc/tests/queue_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -63,7 +61,7 @@ ATF_TC_BODY(queue_valid, tc) { item_init(&four, 4); item_init(&five, 5); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); ATF_CHECK(ISC_QUEUE_EMPTY(queue)); diff --git a/lib/isc/tests/radix_test.c b/lib/isc/tests/radix_test.c index a89e6cc293..6ca730dff5 100644 --- a/lib/isc/tests/radix_test.c +++ b/lib/isc/tests/radix_test.c @@ -38,7 +38,7 @@ ATF_TC_BODY(isc_radix_search, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_radix_create(mctx, &radix, 32); diff --git a/lib/isc/tests/random_test.c b/lib/isc/tests/random_test.c index 201889bfde..ed4551ba8a 100644 --- a/lib/isc/tests/random_test.c +++ b/lib/isc/tests/random_test.c @@ -9,6 +9,13 @@ * information regarding copyright ownership. */ +/* + * IMPORTANT NOTE: + * These tests work by generating a large number of pseudo-random numbers + * and then statistically analyzing them to determine whether they seem + * random. The test is expected to fail on occasion by random happenstance. + */ + #include #include @@ -23,6 +30,8 @@ #include #include +#define REPS 25000 + typedef double (pvalue_func_t)(isc_mem_t *mctx, isc_uint16_t *values, size_t length); @@ -272,18 +281,18 @@ random_test(pvalue_func_t *func, isc_boolean_t word_sized) { for (j = 0; j < m; j++) { isc_uint32_t i; - isc_uint16_t values[128000]; + isc_uint16_t values[REPS]; double p_value; if (word_sized) { - for (i = 0; i < 128000; i++) + for (i = 0; i < REPS; i++) isc_rng_randombytes(rng, &values[i], sizeof(values[i])); } else { isc_rng_randombytes(rng, values, sizeof(values)); } - p_value = (*func)(mctx, values, 128000); + p_value = (*func)(mctx, values, REPS); if (p_value >= 0.01) passed++; @@ -402,7 +411,7 @@ runs(isc_mem_t *mctx, isc_uint16_t *values, size_t length) { numbits = length * 16; bcount = 0; - for (i = 0; i < 128000; i++) + for (i = 0; i < REPS; i++) bcount += bitcounts_table[values[i]]; /* Debug message, not displayed when running via atf-run */ diff --git a/lib/isc/tests/sockaddr_test.c b/lib/isc/tests/sockaddr_test.c index 98cb68d8fb..59b7275211 100644 --- a/lib/isc/tests/sockaddr_test.c +++ b/lib/isc/tests/sockaddr_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -19,6 +17,7 @@ #include +#include #include #include @@ -42,7 +41,7 @@ ATF_TC_BODY(sockaddr_hash, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); in.s_addr = inet_addr("127.0.0.1"); @@ -120,12 +119,47 @@ ATF_TC_BODY(sockaddr_isnetzero, tc) { } } +ATF_TC(sockaddr_eqaddrprefix); +ATF_TC_HEAD(sockaddr_eqaddrprefix, tc) { + atf_tc_set_md_var(tc, "descr", + "isc_sockaddr_eqaddrprefix() returns ISC_TRUE when " + "prefixes of a and b are equal, and ISC_FALSE when " + "they are not equal"); +} +ATF_TC_BODY(sockaddr_eqaddrprefix, tc) { + struct in_addr ina_a; + struct in_addr ina_b; + struct in_addr ina_c; + isc_sockaddr_t isa_a; + isc_sockaddr_t isa_b; + isc_sockaddr_t isa_c; + + UNUSED(tc); + + ATF_CHECK(inet_pton(AF_INET, "194.100.32.87", &ina_a) >= 0); + ATF_CHECK(inet_pton(AF_INET, "194.100.32.80", &ina_b) >= 0); + ATF_CHECK(inet_pton(AF_INET, "194.101.32.87", &ina_c) >= 0); + + isc_sockaddr_fromin(&isa_a, &ina_a, 0); + isc_sockaddr_fromin(&isa_b, &ina_b, 42); + isc_sockaddr_fromin(&isa_c, &ina_c, 0); + + ATF_CHECK(isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 0)); + ATF_CHECK(isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 29)); + ATF_CHECK(isc_sockaddr_eqaddrprefix(&isa_a, &isa_c, 8)); + + ATF_CHECK(! isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 30)); + ATF_CHECK(! isc_sockaddr_eqaddrprefix(&isa_a, &isa_b, 32)); + ATF_CHECK(! isc_sockaddr_eqaddrprefix(&isa_a, &isa_c, 16)); +} + /* * Main */ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sockaddr_hash); ATF_TP_ADD_TC(tp, sockaddr_isnetzero); + ATF_TP_ADD_TC(tp, sockaddr_eqaddrprefix); return (atf_no_error()); } diff --git a/lib/isc/tests/socket_test.c b/lib/isc/tests/socket_test.c index 750ad2d703..06a8b5ea42 100644 --- a/lib/isc/tests/socket_test.c +++ b/lib/isc/tests/socket_test.c @@ -157,7 +157,7 @@ ATF_TC_BODY(udp_sendto, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); in.s_addr = inet_addr("127.0.0.1"); @@ -232,7 +232,7 @@ ATF_TC_BODY(udp_dup, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); in.s_addr = inet_addr("127.0.0.1"); @@ -334,7 +334,7 @@ ATF_TC_BODY(udp_dscp_v4, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); in.s_addr = inet_addr("127.0.0.1"); @@ -439,7 +439,7 @@ ATF_TC_BODY(udp_dscp_v6, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); n = inet_pton(AF_INET6, "::1", &in6.s6_addr); @@ -544,7 +544,7 @@ ATF_TC_BODY(tcp_dscp_v4, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); in.s_addr = inet_addr("127.0.0.1"); @@ -644,7 +644,7 @@ ATF_TC_BODY(tcp_dscp_v6, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); n = inet_pton(AF_INET6, "::1", &in6.s6_addr); diff --git a/lib/isc/tests/symtab_test.c b/lib/isc/tests/symtab_test.c index db412136ab..41b7bd6308 100644 --- a/lib/isc/tests/symtab_test.c +++ b/lib/isc/tests/symtab_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -50,7 +48,7 @@ ATF_TC_BODY(symtab_grow, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_symtab_create(mctx, 3, undefine, NULL, ISC_FALSE, &st); diff --git a/lib/isc/tests/task_test.c b/lib/isc/tests/task_test.c index 029009e0e9..c742dc3839 100644 --- a/lib/isc/tests/task_test.c +++ b/lib/isc/tests/task_test.c @@ -15,9 +15,18 @@ #include +#ifdef HAVE_INTTYPES_H +#include /* uintptr_t */ +#endif +#include #include +#include +#include +#include #include +#include +#include #include #include "isctest.h" @@ -26,9 +35,11 @@ * Helper functions */ -/* task event handler, sets a boolean to true */ +static isc_mutex_t lock; +static isc_condition_t cv; int counter = 0; -isc_mutex_t set_lock; +static int active[10]; +static isc_boolean_t done = ISC_FALSE; static void set(isc_task_t *task, isc_event_t *event) { @@ -37,9 +48,9 @@ set(isc_task_t *task, isc_event_t *event) { UNUSED(task); isc_event_free(&event); - LOCK(&set_lock); + LOCK(&lock); *value = counter++; - UNLOCK(&set_lock); + UNLOCK(&lock); } static void @@ -49,10 +60,10 @@ set_and_drop(isc_task_t *task, isc_event_t *event) { UNUSED(task); isc_event_free(&event); - LOCK(&set_lock); + LOCK(&lock); *value = (int) isc_taskmgr_mode(taskmgr); counter++; - UNLOCK(&set_lock); + UNLOCK(&lock); isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_normal); } @@ -71,7 +82,7 @@ ATF_TC_BODY(create_task, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_task_create(taskmgr, 0, &task); @@ -91,7 +102,7 @@ ATF_TC_HEAD(all_events, tc) { ATF_TC_BODY(all_events, tc) { isc_result_t result; isc_task_t *task = NULL; - isc_event_t *event; + isc_event_t *event = NULL; int a = 0, b = 0; int i = 0; @@ -99,10 +110,10 @@ ATF_TC_BODY(all_events, tc) { counter = 1; - result = isc_mutex_init(&set_lock); + result = isc_mutex_init(&lock); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_task_create(taskmgr, 0, &task); @@ -148,17 +159,17 @@ ATF_TC_HEAD(privileged_events, tc) { ATF_TC_BODY(privileged_events, tc) { isc_result_t result; isc_task_t *task1 = NULL, *task2 = NULL; - isc_event_t *event; + isc_event_t *event = NULL; int a = 0, b = 0, c = 0, d = 0, e = 0; int i = 0; UNUSED(tc); counter = 1; - result = isc_mutex_init(&set_lock); + result = isc_mutex_init(&lock); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); #ifdef ISC_PLATFORM_USETHREADS @@ -277,17 +288,17 @@ ATF_TC_HEAD(privilege_drop, tc) { ATF_TC_BODY(privilege_drop, tc) { isc_result_t result; isc_task_t *task1 = NULL, *task2 = NULL; - isc_event_t *event; + isc_event_t *event = NULL; int a = -1, b = -1, c = -1, d = -1, e = -1; /* non valid states */ int i = 0; UNUSED(tc); counter = 1; - result = isc_mutex_init(&set_lock); + result = isc_mutex_init(&lock); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); #ifdef ISC_PLATFORM_USETHREADS @@ -394,6 +405,1041 @@ ATF_TC_BODY(privilege_drop, tc) { isc_test_end(); } +/* + * Basic task functions: + */ +static void +basic_cb(isc_task_t *task, isc_event_t *event) { + int i; + int j; + + UNUSED(task); + + j = 0; + for (i = 0; i < 1000000; i++) { + j += 100; + } + + printf("task %s\n", (char *)event->ev_arg); + isc_event_free(&event); +} + +static void +basic_shutdown(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + printf("shutdown %s\n", (char *)event->ev_arg); + isc_event_free(&event); +} + +static void +basic_tick(isc_task_t *task, isc_event_t *event) { + + UNUSED(task); + + printf("%s\n", (char *)event->ev_arg); + isc_event_free(&event); +} + +static char one[] = "1"; +static char two[] = "2"; +static char three[] = "3"; +static char four[] = "4"; +static char tick[] = "tick"; +static char tock[] = "tock"; + + +ATF_TC(basic); +ATF_TC_HEAD(basic, tc) { + atf_tc_set_md_var(tc, "descr", "basic task system check"); +} +ATF_TC_BODY(basic, tc) { + isc_result_t result; + isc_task_t *task1 = NULL; + isc_task_t *task2 = NULL; + isc_task_t *task3 = NULL; + isc_task_t *task4 = NULL; + isc_event_t *event = NULL; + isc_timer_t *ti1 = NULL; + isc_timer_t *ti2 = NULL; + isc_time_t absolute; + isc_interval_t interval; + char *testarray[] = { + one, one, one, one, one, one, one, one, one, + two, three, four, two, three, four, NULL + }; + int i; + + UNUSED(tc); + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_create(taskmgr, 0, &task1); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = isc_task_create(taskmgr, 0, &task2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = isc_task_create(taskmgr, 0, &task3); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = isc_task_create(taskmgr, 0, &task4); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(task1, basic_shutdown, one); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = isc_task_onshutdown(task2, basic_shutdown, two); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = isc_task_onshutdown(task3, basic_shutdown, three); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + result = isc_task_onshutdown(task4, basic_shutdown, four); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_time_settoepoch(&absolute); + isc_interval_set(&interval, 1, 0); + result = isc_timer_create(timermgr, isc_timertype_ticker, + &absolute, &interval, + task1, basic_tick, tick, &ti1); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + ti2 = NULL; + isc_time_settoepoch(&absolute); + isc_interval_set(&interval, 1, 0); + result = isc_timer_create(timermgr, isc_timertype_ticker, + &absolute, &interval, + task2, basic_tick, tock, &ti2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + +#ifndef WIN32 + sleep(2); +#else + Sleep(2000); +#endif + + for (i = 0; testarray[i] != NULL; i++) { + /* + * Note: (void *)1 is used as a sender here, since some + * compilers don't like casting a function pointer to a + * (void *). + * + * In a real use, it is more likely the sender would be a + * structure (socket, timer, task, etc) but this is just a + * test program. + */ + event = isc_event_allocate(mctx, (void *)1, 1, basic_cb, + testarray[i], sizeof(*event)); + ATF_REQUIRE(event != NULL); + isc_task_send(task1, &event); + } + + (void)isc_task_purge(task3, NULL, 0, 0); + + isc_task_detach(&task1); + isc_task_detach(&task2); + isc_task_detach(&task3); + isc_task_detach(&task4); + +#ifndef WIN32 + sleep(10); +#else + Sleep(10000); +#endif + isc_timer_detach(&ti1); + isc_timer_detach(&ti2); + + isc_test_end(); +} + +/* + * Exclusive mode test: + * When one task enters exclusive mode, all other active + * tasks complete first. + */ +static +int spin(int n) { + int i; + int r = 0; + for (i = 0; i < n; i++) { + r += i; + if (r > 1000000) + r = 0; + } + return (r); +} + +static void +exclusive_cb(isc_task_t *task, isc_event_t *event) { + int taskno = *(int *)(event->ev_arg); + + printf("task enter %d\n", taskno); + + /* task chosen from the middle of the range */ + if (taskno == 6) { + isc_result_t result; + int i; + + result = isc_task_beginexclusive(task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + for (i = 0; i < 10; i++) { + ATF_CHECK(active[i] == 0); + } + + isc_task_endexclusive(task); + done = ISC_TRUE; + } else { + active[taskno]++; + (void) spin(10000000); + active[taskno]--; + } + + printf("task exit %d\n", taskno); + + if (done) { + isc_mem_put(event->ev_destroy_arg, event->ev_arg, sizeof (int)); + isc_event_free(&event); + } else { + isc_task_send(task, &event); + } +} + +ATF_TC(task_exclusive); +ATF_TC_HEAD(task_exclusive, tc) { + atf_tc_set_md_var(tc, "descr", "test exclusive mode"); +} +ATF_TC_BODY(task_exclusive, tc) { + isc_task_t *tasks[10]; + isc_result_t result; + int i; + + UNUSED(tc); + + result = isc_test_begin(NULL, ISC_TRUE, 4); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + for (i = 0; i < 10; i++) { + isc_event_t *event = NULL; + int *v; + + tasks[i] = NULL; + + result = isc_task_create(taskmgr, 0, &tasks[i]); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + v = isc_mem_get(mctx, sizeof *v); + ATF_REQUIRE(v != NULL); + + *v = i; + + event = isc_event_allocate(mctx, NULL, 1, exclusive_cb, + v, sizeof(*event)); + ATF_REQUIRE(event != NULL); + + isc_task_send(tasks[i], &event); + } + + for (i = 0; i < 10; i++) { + isc_task_detach(&tasks[i]); + } + isc_test_end(); +} + +/* + * Max tasks test: + * The task system can create and execute many tasks. Tests with 10000. + */ +static void +maxtask_shutdown(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + if (event->ev_arg != NULL) { + isc_task_destroy((isc_task_t**) &event->ev_arg); + } else { + LOCK(&lock); + done = ISC_TRUE; + SIGNAL(&cv); + UNLOCK(&lock); + + isc_event_free(&event); + isc_taskmgr_destroy(&taskmgr); + isc_mem_destroy(&mctx); + + isc_condition_destroy(&cv); + DESTROYLOCK(&lock); + } +} + +static void +maxtask_cb(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + + if (event->ev_arg != NULL) { + isc_task_t *newtask = NULL; + + event->ev_arg = (void *)(((uintptr_t) event->ev_arg) - 1); + + /* + * Create a new task and forward the message. + */ + result = isc_task_create(taskmgr, 0, &newtask); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(newtask, maxtask_shutdown, + (void *)task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_task_send(newtask, &event); + } else if (task != NULL) { + isc_task_destroy(&task); + } +} + +ATF_TC(manytasks); +ATF_TC_HEAD(manytasks, tc) { + atf_tc_set_md_var(tc, "descr", "many tasks"); +} +ATF_TC_BODY(manytasks, tc) { + isc_result_t result; + isc_event_t *event = NULL; + uintptr_t ntasks = 10000; + + UNUSED(tc); + + printf("Testing with %lu tasks\n", (unsigned long)ntasks); + + result = isc_mutex_init(&lock); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mem_create(0, 0, &mctx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_taskmgr_create(mctx, 4, 0, &taskmgr); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + event = isc_event_allocate(mctx, (void *)1, 1, maxtask_cb, + (void *)ntasks, sizeof(*event)); + ATF_REQUIRE(event != NULL); + + LOCK(&lock); + maxtask_cb(NULL, event); + while (!done) { + WAIT(&cv, &lock); + } +} + + +/* + * Shutdown test: + * When isc_task_shutdown() is called, shutdown events are posted + * in LIFO order. + */ + +static int senders[4]; +static int nevents = 0; +static int nsdevents = 0; + +static void +sd_sde1(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + ATF_CHECK_EQ(nevents, 256); + ATF_REQUIRE_EQ(nsdevents, 1); + ++nsdevents; + printf("shutdown 1\n"); + + isc_event_free(&event); +} + +static void +sd_sde2(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + ATF_CHECK_EQ(nevents, 256); + ATF_REQUIRE_EQ(nsdevents, 0); + ++nsdevents; + printf("shutdown 2\n"); + + isc_event_free(&event); +} + +static void +sd_event1(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + LOCK(&lock); + while (!done) { + WAIT(&cv, &lock); + } + + printf("event 1\n"); + + isc_event_free(&event); +} + +static void +sd_event2(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + ++nevents; + + printf("event 2\n"); + + isc_event_free(&event); +} + +ATF_TC(shutdown); +ATF_TC_HEAD(shutdown, tc) { + atf_tc_set_md_var(tc, "descr", "task shutdown"); +} +ATF_TC_BODY(shutdown, tc) { + isc_result_t result; + isc_eventtype_t event_type; + isc_event_t *event = NULL; + isc_task_t *task = NULL; + int i; + + nevents = nsdevents = 0; + done = ISC_FALSE; + + event_type = 3; + + result = isc_test_begin(NULL, ISC_TRUE, 4); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mutex_init(&lock); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + LOCK(&lock); + + task = NULL; + result = isc_task_create(taskmgr, 0, &task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * This event causes the task to wait on cv. + */ + event = isc_event_allocate(mctx, &senders[1], event_type, sd_event1, + NULL, sizeof(*event)); + ATF_REQUIRE(event != NULL); + isc_task_send(task, &event); + + /* + * Now we fill up the task's event queue with some events. + */ + for (i = 0; i < 256; ++i) { + event = isc_event_allocate(mctx, &senders[1], event_type, + sd_event2, NULL, sizeof(*event)); + ATF_REQUIRE(event != NULL); + isc_task_send(task, &event); + } + + /* + * Now we register two shutdown events. + */ + result = isc_task_onshutdown(task, sd_sde1, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(task, sd_sde2, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_task_shutdown(task); + + /* + * Now we free the task by signaling cv. + */ + done = ISC_TRUE; + SIGNAL(&cv); + UNLOCK(&lock); + + isc_task_detach(&task); + + isc_test_end(); + + ATF_REQUIRE_EQ(nsdevents, 2); +} + +/* + * Post-shutdown test: + * After isc_task_shutdown() has been called, any call to + * isc_task_onshutdown() will return ISC_R_SHUTTINGDOWN. + */ +static void +psd_event1(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + LOCK(&lock); + + while (!done) { + WAIT(&cv, &lock); + } + + UNLOCK(&lock); + + isc_event_free(&event); +} + +static void +psd_sde(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + isc_event_free(&event); +} + +ATF_TC(post_shutdown); +ATF_TC_HEAD(post_shutdown, tc) { + atf_tc_set_md_var(tc, "descr", "post-shutdown"); +} +ATF_TC_BODY(post_shutdown, tc) { + isc_result_t result; + isc_eventtype_t event_type; + isc_event_t *event; + isc_task_t *task; + + done = ISC_FALSE; + event_type = 4; + + result = isc_mutex_init(&lock); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + LOCK(&lock); + + task = NULL; + result = isc_task_create(taskmgr, 0, &task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * This event causes the task to wait on cv. + */ + event = isc_event_allocate(mctx, &senders[1], event_type, psd_event1, + NULL, sizeof(*event)); + ATF_REQUIRE(event != NULL); + isc_task_send(task, &event); + + isc_task_shutdown(task); + + result = isc_task_onshutdown(task, psd_sde, NULL); + ATF_CHECK_EQ(result, ISC_R_SHUTTINGDOWN); + + /* + * Release the task. + */ + done = ISC_TRUE; + + SIGNAL(&cv); + UNLOCK(&lock); + + isc_task_detach(&task); + isc_test_end(); + + (void) isc_condition_destroy(&cv); + DESTROYLOCK(&lock); +} + +/* + * Helper for the purge tests below: + */ + +#define SENDERCNT 3 +#define TYPECNT 4 +#define TAGCNT 5 +#define NEVENTS (SENDERCNT * TYPECNT * TAGCNT) + +static isc_boolean_t testrange; +static void *purge_sender; +static isc_eventtype_t purge_type_first; +static isc_eventtype_t purge_type_last; +static void *purge_tag; +static int eventcnt; + +isc_boolean_t started = ISC_FALSE; + +static void +pg_event1(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + LOCK(&lock); + while (!started) { + WAIT(&cv, &lock); + } + UNLOCK(&lock); + + isc_event_free(&event); +} + +static void +pg_event2(isc_task_t *task, isc_event_t *event) { + isc_boolean_t sender_match = ISC_FALSE; + isc_boolean_t type_match = ISC_FALSE; + isc_boolean_t tag_match = ISC_FALSE; + + UNUSED(task); + + if ((purge_sender == NULL) || (purge_sender == event->ev_sender)) { + sender_match = ISC_TRUE; + } + + if (testrange) { + if ((purge_type_first <= event->ev_type) && + (event->ev_type <= purge_type_last)) + { + type_match = ISC_TRUE; + } + } else { + if (purge_type_first == event->ev_type) { + type_match = ISC_TRUE; + } + } + + if ((purge_tag == NULL) || (purge_tag == event->ev_tag)) { + tag_match = ISC_TRUE; + } + + if (sender_match && type_match && tag_match) { + if (event->ev_attributes & ISC_EVENTATTR_NOPURGE) { + printf("event %p,%d,%p matched but was not purgeable\n", + event->ev_sender, (int)event->ev_type, + event->ev_tag); + ++eventcnt; + } else { + printf("*** event %p,%d,%p not purged\n", + event->ev_sender, (int)event->ev_type, + event->ev_tag); + } + } else { + ++eventcnt; + } + + isc_event_free(&event); +} + +static void +pg_sde(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + LOCK(&lock); + done = ISC_TRUE; + SIGNAL(&cv); + UNLOCK(&lock); + + isc_event_free(&event); +} + +static void +test_purge(int sender, int type, int tag, int exp_purged) { + isc_result_t result; + isc_task_t *task = NULL; + isc_event_t *eventtab[NEVENTS]; + isc_event_t *event = NULL; + isc_interval_t interval; + isc_time_t now; + int sender_cnt, type_cnt, tag_cnt, event_cnt, i; + int purged = 0; + + started = ISC_FALSE; + done = ISC_FALSE; + eventcnt = 0; + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mutex_init(&lock); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_create(taskmgr, 0, &task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(task, pg_sde, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * Block the task on cv. + */ + event = isc_event_allocate(mctx, (void *)1, 9999, + pg_event1, NULL, sizeof(*event)); + + ATF_REQUIRE(event != NULL); + isc_task_send(task, &event); + + /* + * Fill the task's queue with some messages with varying + * sender, type, tag, and purgeable attribute values. + */ + event_cnt = 0; + for (sender_cnt = 0; sender_cnt < SENDERCNT; ++sender_cnt) { + for (type_cnt = 0; type_cnt < TYPECNT; ++type_cnt) { + for (tag_cnt = 0; tag_cnt < TAGCNT; ++tag_cnt) { + eventtab[event_cnt] = + isc_event_allocate(mctx, + &senders[sender + sender_cnt], + (isc_eventtype_t)(type + type_cnt), + pg_event2, NULL, sizeof(*event)); + + ATF_REQUIRE(eventtab[event_cnt] != NULL); + + eventtab[event_cnt]->ev_tag = + (void *)((uintptr_t)tag + tag_cnt); + + /* + * Mark events as non-purgeable if + * sender, type and tag are all + * odd-numbered. (There should be 4 + * of these out of 60 events total.) + */ + if (((sender_cnt % 2) != 0) && + ((type_cnt % 2) != 0) && + ((tag_cnt % 2) != 0)) + { + eventtab[event_cnt]->ev_attributes |= + ISC_EVENTATTR_NOPURGE; + } + ++event_cnt; + } + } + } + + for (i = 0; i < event_cnt; ++i) { + isc_task_send(task, &eventtab[i]); + } + + if (testrange) { + /* + * We're testing isc_task_purgerange. + */ + purged = isc_task_purgerange(task, purge_sender, + (isc_eventtype_t)purge_type_first, + (isc_eventtype_t)purge_type_last, + purge_tag); + ATF_CHECK_EQ(purged, exp_purged); + } else { + /* + * We're testing isc_task_purge. + */ + printf("purge events %p,%d,%p\n", + purge_sender, purge_type_first, purge_tag); + purged = isc_task_purge(task, purge_sender, + (isc_eventtype_t)purge_type_first, + purge_tag); + printf("purged %d expected %d\n", purged, exp_purged); + ATF_CHECK_EQ(purged, exp_purged); + } + + /* + * Unblock the task, allowing event processing. + */ + LOCK(&lock); + started = ISC_TRUE; + SIGNAL(&cv); + + isc_task_shutdown(task); + + isc_interval_set(&interval, 5, 0); + + /* + * Wait for shutdown processing to complete. + */ + while (!done) { + result = isc_time_nowplusinterval(&now, &interval); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + WAITUNTIL(&cv, &lock, &now); + } + + UNLOCK(&lock); + + isc_task_detach(&task); + + isc_test_end(); + DESTROYLOCK(&lock); + (void) isc_condition_destroy(&cv); + + ATF_CHECK_EQ(eventcnt, event_cnt - exp_purged); +} + +/* + * Purge test: + * A call to isc_task_purge(task, sender, type, tag) purges all events of + * type 'type' and with tag 'tag' not marked as unpurgeable from sender + * from the task's " queue and returns the number of events purged. + */ +ATF_TC(purge); +ATF_TC_HEAD(purge, tc) { + atf_tc_set_md_var(tc, "descr", "purge"); +} +ATF_TC_BODY(purge, tc) { + /* Try purging on a specific sender. */ + printf("testing purge on 2,4,8 expecting 1\n"); + purge_sender = &senders[2]; + purge_type_first = 4; + purge_type_last = 4; + purge_tag = (void *)8; + testrange = ISC_FALSE; + test_purge(1, 4, 7, 1); + + /* Try purging on all senders. */ + printf("testing purge on 0,4,8 expecting 3\n"); + purge_sender = NULL; + purge_type_first = 4; + purge_type_last = 4; + purge_tag = (void *)8; + testrange = ISC_FALSE; + test_purge(1, 4, 7, 3); + + /* Try purging on all senders, specified type, all tags. */ + printf("testing purge on 0,4,0 expecting 15\n"); + purge_sender = NULL; + purge_type_first = 4; + purge_type_last = 4; + purge_tag = NULL; + testrange = ISC_FALSE; + test_purge(1, 4, 7, 15); + + /* Try purging on a specified tag, no such type. */ + printf("testing purge on 0,99,8 expecting 0\n"); + purge_sender = NULL; + purge_type_first = 99; + purge_type_last = 99; + purge_tag = (void *)8; + testrange = ISC_FALSE; + test_purge(1, 4, 7, 0); + + /* + * Try purging on specified sender, type, all tags. + */ + printf("testing purge on 3,5,0 expecting 5\n"); + purge_sender = &senders[3]; + purge_type_first = 5; + purge_type_last = 5; + purge_tag = NULL; + testrange = ISC_FALSE; + test_purge(1, 4, 7, 5); +} + +/* + * Purge range test: + * A call to isc_event_purgerange(task, sender, first, last, tag) purges + * all events not marked unpurgeable from sender 'sender' and of type within + * the range 'first' to 'last' inclusive from the task's event queue and + * returns the number of tasks purged. + */ + +ATF_TC(purgerange); +ATF_TC_HEAD(purgerange, tc) { + atf_tc_set_md_var(tc, "descr", "purge-range"); +} +ATF_TC_BODY(purgerange, tc) { + /* Now let's try some ranges. */ + printf("testing purgerange on 2,4-5,8 expecting 1\n"); + purge_sender = &senders[2]; + purge_type_first = 4; + purge_type_last = 5; + purge_tag = (void *)8; + testrange = ISC_TRUE; + test_purge(1, 4, 7, 1); + + /* Try purging on all senders. */ + printf("testing purge on 0,4-5,8 expecting 5\n"); + purge_sender = NULL; + purge_type_first = 4; + purge_type_last = 5; + purge_tag = (void *)8; + testrange = ISC_TRUE; + test_purge(1, 4, 7, 5); + + /* Try purging on all senders, specified type, all tags. */ + printf("testing purge on 0,5-6,0 expecting 28\n"); + purge_sender = NULL; + purge_type_first = 5; + purge_type_last = 6; + purge_tag = NULL; + testrange = ISC_TRUE; + test_purge(1, 4, 7, 28); + + /* Try purging on a specified tag, no such type. */ + printf("testing purge on 0,99-101,8 expecting 0\n"); + purge_sender = NULL; + purge_type_first = 99; + purge_type_last = 101; + purge_tag = (void *)8; + testrange = ISC_TRUE; + test_purge(1, 4, 7, 0); + + /* Try purging on specified sender, type, all tags. */ + printf("testing purge on 3,5-6,0 expecting 10\n"); + purge_sender = &senders[3]; + purge_type_first = 5; + purge_type_last = 6; + purge_tag = NULL; + testrange = ISC_TRUE; + test_purge(1, 4, 7, 10); +} + +/* + * Helpers for purge event tests + */ +static void +pge_event1(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + LOCK(&lock); + while (!started) { + WAIT(&cv, &lock); + } + UNLOCK(&lock); + + isc_event_free(&event); +} + +static void +pge_event2(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + ++eventcnt; + isc_event_free(&event); +} + + +static void +pge_sde(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + LOCK(&lock); + done = ISC_TRUE; + SIGNAL(&cv); + UNLOCK(&lock); + + isc_event_free(&event); +} + +static void +try_purgeevent(isc_boolean_t purgeable) { + isc_result_t result; + isc_task_t *task = NULL; + isc_boolean_t purged; + isc_event_t *event1 = NULL; + isc_event_t *event2 = NULL; + isc_event_t *event2_clone = NULL;; + isc_time_t now; + isc_interval_t interval; + + started = ISC_FALSE; + done = ISC_FALSE; + eventcnt = 0; + + result = isc_mutex_init(&lock); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_create(taskmgr, 0, &task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(task, pge_sde, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * Block the task on cv. + */ + event1 = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)1, + pge_event1, NULL, sizeof(*event1)); + ATF_REQUIRE(event1 != NULL); + isc_task_send(task, &event1); + + event2 = isc_event_allocate(mctx, (void *)1, (isc_eventtype_t)1, + pge_event2, NULL, sizeof(*event2)); + ATF_REQUIRE(event2 != NULL); + + event2_clone = event2; + + if (purgeable) { + event2->ev_attributes &= ~ISC_EVENTATTR_NOPURGE; + } else { + event2->ev_attributes |= ISC_EVENTATTR_NOPURGE; + } + + isc_task_send(task, &event2); + + purged = isc_task_purgeevent(task, event2_clone); + ATF_CHECK_EQ(purgeable, purged); + + /* + * Unblock the task, allowing event processing. + */ + LOCK(&lock); + started = ISC_TRUE; + SIGNAL(&cv); + + isc_task_shutdown(task); + + isc_interval_set(&interval, 5, 0); + + /* + * Wait for shutdown processing to complete. + */ + while (!done) { + result = isc_time_nowplusinterval(&now, &interval); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + WAITUNTIL(&cv, &lock, &now); + } + + UNLOCK(&lock); + + isc_task_detach(&task); + + isc_test_end(); + DESTROYLOCK(&lock); + (void) isc_condition_destroy(&cv); + + ATF_REQUIRE_EQ(eventcnt, (purgeable ? 0 : 1)); +} + +/* + * Purge event test: + * When the event is marked as purgeable, a call to + * isc_task_purgeevent(task, event) purges the event 'event' from the + * task's queue and returns ISC_TRUE. + */ + +ATF_TC(purgeevent); +ATF_TC_HEAD(purgeevent, tc) { + atf_tc_set_md_var(tc, "descr", "purge-event"); +} +ATF_TC_BODY(purgeevent, tc) { + try_purgeevent(ISC_TRUE); +} + +/* + * Purge event not purgeable test: + * When the event is not marked as purgable, a call to + * isc_task_purgeevent(task, event) does not purge the event + * 'event' from the task's queue and returns ISC_FALSE. + */ + +ATF_TC(purgeevent_notpurge); +ATF_TC_HEAD(purgeevent_notpurge, tc) { + atf_tc_set_md_var(tc, "descr", "purge-event"); +} +ATF_TC_BODY(purgeevent_notpurge, tc) { + try_purgeevent(ISC_FALSE); +} + /* * Main */ @@ -402,6 +1448,18 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, all_events); ATF_TP_ADD_TC(tp, privileged_events); ATF_TP_ADD_TC(tp, privilege_drop); + ATF_TP_ADD_TC(tp, basic); + ATF_TP_ADD_TC(tp, task_exclusive); + +#ifdef ISC_PLATFORM_USETHREADS + ATF_TP_ADD_TC(tp, manytasks); + ATF_TP_ADD_TC(tp, shutdown); + ATF_TP_ADD_TC(tp, post_shutdown); + ATF_TP_ADD_TC(tp, purge); + ATF_TP_ADD_TC(tp, purgerange); + ATF_TP_ADD_TC(tp, purgeevent); + ATF_TP_ADD_TC(tp, purgeevent_notpurge); +#endif return (atf_no_error()); } diff --git a/lib/isc/tests/taskpool_test.c b/lib/isc/tests/taskpool_test.c index e019468d03..e89da377f5 100644 --- a/lib/isc/tests/taskpool_test.c +++ b/lib/isc/tests/taskpool_test.c @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id$ */ - /*! \file */ #include @@ -39,7 +37,7 @@ ATF_TC_BODY(create_pool, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_taskpool_create(taskmgr, mctx, 8, 2, &pool); @@ -63,7 +61,7 @@ ATF_TC_BODY(expand_pool, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_taskpool_create(taskmgr, mctx, 10, 2, &pool1); @@ -116,7 +114,7 @@ ATF_TC_BODY(get_tasks, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_taskpool_create(taskmgr, mctx, 2, 2, &pool); @@ -155,7 +153,7 @@ ATF_TC_BODY(set_privilege, tc) { UNUSED(tc); - result = isc_test_begin(NULL, ISC_TRUE); + result = isc_test_begin(NULL, ISC_TRUE, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_taskpool_create(taskmgr, mctx, 2, 2, &pool); diff --git a/lib/isc/tests/timer_test.c b/lib/isc/tests/timer_test.c new file mode 100644 index 0000000000..0355ab9ae3 --- /dev/null +++ b/lib/isc/tests/timer_test.c @@ -0,0 +1,575 @@ +/* + * 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. + */ + +/*! \file */ + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "isctest.h" + +/* + * Helper functions + */ +#define FUDGE_SECONDS 0 /* in absence of clock_getres() */ +#define FUDGE_NANOSECONDS 500000000 /* in absence of clock_getres() */ + +static isc_timer_t *timer = NULL; +static isc_condition_t cv; +static isc_mutex_t mx; +static isc_time_t endtime; +static isc_time_t lasttime; +static int seconds; +static int nanoseconds; +static int eventcnt; +static int nevents; + +static void +shutdown(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + + UNUSED(task); + + /* + * Signal shutdown processing complete. + */ + result = isc_mutex_lock(&mx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_signal(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_mutex_unlock(&mx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_event_free(&event); +} + +static void +setup_test(isc_timertype_t timertype, isc_time_t *expires, + isc_interval_t *interval, + void (*action)(isc_task_t *, isc_event_t *)) +{ + isc_result_t result; + isc_task_t *task = NULL; + isc_time_settoepoch(&endtime); + eventcnt = 0; + + result = isc_mutex_init(&mx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + LOCK(&mx); + + result = isc_task_create(taskmgr, 0, &task); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(task, shutdown, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_time_now(&lasttime); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_timer_create(timermgr, timertype, expires, interval, + task, action, (void *)timertype, + &timer); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * Wait for shutdown processing to complete. + */ + while (eventcnt != nevents) { + result = isc_condition_wait(&cv, &mx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + } + + UNLOCK(&mx); + + isc_task_detach(&task); + DESTROYLOCK(&mx); + (void) isc_condition_destroy(&cv); +} + +static void +ticktock(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + isc_time_t now; + isc_time_t base; + isc_time_t ulim; + isc_time_t llim; + isc_interval_t interval; + isc_eventtype_t expected_event_type; + + ++eventcnt; + + printf("tick %d\n", eventcnt); + + expected_event_type = ISC_TIMEREVENT_LIFE; + if ((isc_timertype_t) event->ev_arg == isc_timertype_ticker) { + expected_event_type = ISC_TIMEREVENT_TICK; + } + + if (event->ev_type != expected_event_type) { + printf("expected event type %d, got %d\n", + expected_event_type, (int) event->ev_type); + } + + result = isc_time_now(&now); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds, nanoseconds); + result = isc_time_add(&lasttime, &interval, &base); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, FUDGE_SECONDS, FUDGE_NANOSECONDS); + result = isc_time_add(&base, &interval, &ulim); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_time_subtract(&base, &interval, &llim); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + ATF_CHECK(isc_time_compare(&llim, &now) <= 0); + ATF_CHECK(isc_time_compare(&ulim, &now) >= 0); + lasttime = now; + + if (eventcnt == nevents) { + result = isc_time_now(&endtime); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + isc_timer_detach(&timer); + isc_task_shutdown(task); + } + + isc_event_free(&event); +} + +/* + * Individual unit tests + */ + +ATF_TC(ticker); +ATF_TC_HEAD(ticker, tc) { + atf_tc_set_md_var(tc, "descr", "timer type ticker"); +} +ATF_TC_BODY(ticker, tc) { + isc_result_t result; + isc_time_t expires; + isc_interval_t interval; + + UNUSED(tc); + + nevents = 12; + seconds = 0; + nanoseconds = 500000000; + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds, nanoseconds); + isc_time_settoepoch(&expires); + + setup_test(isc_timertype_ticker, &expires, &interval, ticktock); + + isc_test_end(); +} + +ATF_TC(once_life); +ATF_TC_HEAD(once_life, tc) { + atf_tc_set_md_var(tc, "descr", "timer type once reaches lifetime"); +} +ATF_TC_BODY(once_life, tc) { + isc_result_t result; + isc_time_t expires; + isc_interval_t interval; + + UNUSED(tc); + + nevents = 1; + seconds = 1; + nanoseconds = 100000000; + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds, nanoseconds); + result = isc_time_nowplusinterval(&expires, &interval); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, 0, 0); + + setup_test(isc_timertype_once, &expires, &interval, ticktock); + + isc_test_end(); +} + + +static void +test_idle(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + isc_time_t now; + isc_time_t base; + isc_time_t ulim; + isc_time_t llim; + isc_interval_t interval; + + ++eventcnt; + + printf("tick %d\n", eventcnt); + + result = isc_time_now(&now); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds, nanoseconds); + result = isc_time_add(&lasttime, &interval, &base); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, FUDGE_SECONDS, FUDGE_NANOSECONDS); + result = isc_time_add(&base, &interval, &ulim); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_time_subtract(&base, &interval, &llim); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + ATF_CHECK(isc_time_compare(&llim, &now) <= 0); + ATF_CHECK(isc_time_compare(&ulim, &now) >= 0); + lasttime = now; + + ATF_CHECK_EQ(event->ev_type, ISC_TIMEREVENT_IDLE); + + isc_timer_detach(&timer); + isc_task_shutdown(task); + isc_event_free(&event); +} + +ATF_TC(once_idle); +ATF_TC_HEAD(once_idle, tc) { + atf_tc_set_md_var(tc, "descr", "timer type once idles out"); +} +ATF_TC_BODY(once_idle, tc) { + isc_result_t result; + isc_time_t expires; + isc_interval_t interval; + + UNUSED(tc); + + nevents = 1; + seconds = 1; + nanoseconds = 200000000; + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds + 1, nanoseconds); + result = isc_time_nowplusinterval(&expires, &interval); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds, nanoseconds); + + setup_test(isc_timertype_once, &expires, &interval, test_idle); + + isc_test_end(); +} + +static void +test_reset(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + isc_time_t now; + isc_time_t base; + isc_time_t ulim; + isc_time_t llim; + isc_time_t expires; + isc_interval_t interval; + + ++eventcnt; + + printf("tick %d\n", eventcnt); + + /* + * Check expired time. + */ + + result = isc_time_now(&now); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, seconds, nanoseconds); + result = isc_time_add(&lasttime, &interval, &base); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, FUDGE_SECONDS, FUDGE_NANOSECONDS); + result = isc_time_add(&base, &interval, &ulim); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_time_subtract(&base, &interval, &llim); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + ATF_CHECK(isc_time_compare(&llim, &now) <= 0); + ATF_CHECK(isc_time_compare(&ulim, &now) >= 0); + lasttime = now; + + if (eventcnt < 3) { + ATF_CHECK_EQ(event->ev_type, ISC_TIMEREVENT_TICK); + + if (eventcnt == 2) { + isc_interval_set(&interval, seconds, nanoseconds); + result = isc_time_nowplusinterval(&expires, &interval); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, 0, 0); + result = isc_timer_reset(timer, isc_timertype_once, + &expires, &interval, + ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + } + } else { + ATF_CHECK_EQ(event->ev_type, ISC_TIMEREVENT_LIFE); + + isc_timer_detach(&timer); + isc_task_shutdown(task); + } + + isc_event_free(&event); +} + +ATF_TC(reset); +ATF_TC_HEAD(reset, tc) { + atf_tc_set_md_var(tc, "descr", "timer reset"); +} +ATF_TC_BODY(reset, tc) { + isc_result_t result; + isc_time_t expires; + isc_interval_t interval; + + UNUSED(tc); + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + nevents = 3; + seconds = 0; + nanoseconds = 750000000; + + isc_interval_set(&interval, seconds, nanoseconds); + isc_time_settoepoch(&expires); + + setup_test(isc_timertype_ticker, &expires, &interval, test_reset); + + isc_test_end(); +} + +static int startflag; +static int shutdownflag; +static isc_timer_t *tickertimer = NULL; +static isc_timer_t *oncetimer = NULL; +static isc_task_t *task1 = NULL; +static isc_task_t *task2 = NULL; + +/* + * task1 blocks on mx while events accumulate + * in its queue, until signaled by task2. + */ + +static void +start_event(isc_task_t *task, isc_event_t *event) { + UNUSED(task); + + printf("start_event\n"); + + LOCK(&mx); + while (! startflag) { + (void) isc_condition_wait(&cv, &mx); + } + UNLOCK(&mx); + + isc_event_free(&event); +} + +static void +tick_event(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + isc_time_t expires; + isc_interval_t interval; + + UNUSED(task); + + ++eventcnt; + printf("tick_event %d\n", eventcnt); + + /* + * On the first tick, purge all remaining tick events + * and then shut down the task. + */ + if (eventcnt == 1) { + isc_time_settoepoch(&expires); + isc_interval_set(&interval, seconds, 0); + result = isc_timer_reset(tickertimer, isc_timertype_ticker, + &expires, &interval, ISC_TRUE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_task_shutdown(task); + } + + isc_event_free(&event); +} + +static void +once_event(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + + printf("once_event\n"); + + /* + * Allow task1 to start processing events. + */ + LOCK(&mx); + startflag = 1; + + result = isc_condition_broadcast(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNLOCK(&mx); + + isc_event_free(&event); + isc_task_shutdown(task); +} + +static void +shutdown_purge(isc_task_t *task, isc_event_t *event) { + isc_result_t result; + + UNUSED(task); + UNUSED(event); + + printf("shutdown_event\n"); + + /* + * Signal shutdown processing complete. + */ + LOCK(&mx); + shutdownflag = 1; + + result = isc_condition_signal(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNLOCK(&mx); + + isc_event_free(&event); +} + +ATF_TC(purge); +ATF_TC_HEAD(purge, tc) { + atf_tc_set_md_var(tc, "descr", "timer events purged"); +} +ATF_TC_BODY(purge, tc) { + isc_result_t result; + isc_event_t *event = NULL; + isc_time_t expires; + isc_interval_t interval; + + UNUSED(tc); + + result = isc_test_begin(NULL, ISC_TRUE, 2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + startflag = 0; + shutdownflag = 0; + eventcnt = 0; + seconds = 1; + nanoseconds = 0; + + result = isc_mutex_init(&mx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_condition_init(&cv); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_create(taskmgr, 0, &task1); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_onshutdown(task1, shutdown_purge, NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + result = isc_task_create(taskmgr, 0, &task2); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + LOCK(&mx); + + event = isc_event_allocate(mctx, (void *)1 , (isc_eventtype_t)1, + start_event, NULL, sizeof(*event)); + ATF_REQUIRE(event != NULL); + isc_task_send(task1, &event); + + isc_time_settoepoch(&expires); + isc_interval_set(&interval, seconds, 0); + + tickertimer = NULL; + result = isc_timer_create(timermgr, isc_timertype_ticker, + &expires, &interval, task1, + tick_event, NULL, &tickertimer); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + oncetimer = NULL; + + isc_interval_set(&interval, (seconds * 2) + 1, 0); + result = isc_time_nowplusinterval(&expires, &interval); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + isc_interval_set(&interval, 0, 0); + result = isc_timer_create(timermgr, isc_timertype_once, + &expires, &interval, task2, + once_event, NULL, &oncetimer); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * Wait for shutdown processing to complete. + */ + while (! shutdownflag) { + result = isc_condition_wait(&cv, &mx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + } + + UNLOCK(&mx); + + ATF_CHECK_EQ(eventcnt, 1); + + isc_timer_detach(&tickertimer); + isc_timer_detach(&oncetimer); + isc_task_destroy(&task1); + isc_task_destroy(&task2); + DESTROYLOCK(&mx); + + isc_test_end(); +} + +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { +#ifdef ISC_PLATFORM_USETHREADS + ATF_TP_ADD_TC(tp, ticker); + ATF_TP_ADD_TC(tp, once_life); + ATF_TP_ADD_TC(tp, once_idle); + ATF_TP_ADD_TC(tp, reset); + ATF_TP_ADD_TC(tp, purge); +#endif + + return (atf_no_error()); +} diff --git a/lib/tests/Makefile.in b/lib/tests/Makefile.in deleted file mode 100644 index eddf6a527f..0000000000 --- a/lib/tests/Makefile.in +++ /dev/null @@ -1,48 +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 = ${DNS_INCLUDES} ${ISC_INCLUDES} ${TEST_INCLUDES} -CDEFINES = -CWARNINGS = - -ISCLIBS = ../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@ -ISCCCLIBS = ../../lib/isccc/libisccc.@A@ - -ISCDEPLIBS = ../../lib/isc/libisc.@A@ -ISCCCDEPLIBS = libisccc.@A@ - -OBJS = t_api.@O@ - -SRCS = t_api.c - -SUBDIRS = include -TARGETS = timestamp - -@BIND9_MAKE_RULES@ - -libt_api.@SA@: ${OBJS} - ${AR} ${ARFLAGS} $@ ${OBJS} - ${RANLIB} $@ - -libt_api.la: ${OBJS} - ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libt_api.la -rpath ${libdir} \ - ${OBJS} ${ISCLIBS} ${LIBS} @LIBTOOL_ALLOW_UNDEFINED@ @LIBTOOL_IN_MAIN@ - -timestamp: libt_api.@A@ - touch timestamp - -clean distclean:: - rm -f t_api.@O@ libt_api.@A@ timestamp diff --git a/lib/tests/T_testlist.imp b/lib/tests/T_testlist.imp deleted file mode 100644 index 722caff25e..0000000000 --- a/lib/tests/T_testlist.imp +++ /dev/null @@ -1,3 +0,0 @@ -#! . - -T_testlist diff --git a/lib/tests/include/Makefile.in b/lib/tests/include/Makefile.in deleted file mode 100644 index 10d1c05cc1..0000000000 --- a/lib/tests/include/Makefile.in +++ /dev/null @@ -1,19 +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: Makefile.in,v 1.11 2007/06/19 23:47:24 tbox Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = tests -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/tests/include/tests/Makefile.in b/lib/tests/include/tests/Makefile.in deleted file mode 100644 index bdae8c8d5a..0000000000 --- a/lib/tests/include/tests/Makefile.in +++ /dev/null @@ -1,21 +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: Makefile.in,v 1.9 2007/06/19 23:47:24 tbox Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/tests/include/tests/t_api.h b/lib/tests/include/tests/t_api.h deleted file mode 100644 index b33608a8dc..0000000000 --- a/lib/tests/include/tests/t_api.h +++ /dev/null @@ -1,109 +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_api.h,v 1.24 2010/06/08 23:50:24 tbox Exp $ */ - -#ifndef TESTS_T_API_H -#define TESTS_T_API_H 1 - -/*! \file tests/t_api.h */ - -#include - -#include -#include -#include -#include - -/* - * - * Result codes. - * - */ - -#define T_PASS 0x1 -#define T_FAIL 0x2 -#define T_UNRESOLVED 0x3 -#define T_SKIPPED 0x4 -#define T_UNTESTED 0x5 -#define T_THREADONLY 0x6 -#define T_PKCS11ONLY 0x7 - -/* - * - * Assertion class codes. - * - */ - -#define T_OPTIONAL 0x0 -#define T_REQUIRED 0x1 - -/* - * Misc - */ - -#define T_MAXTOKS 16 -#define T_ARG(n) (*(av + (n))) - -typedef void (*PFV)(void); - -typedef struct { - PFV pfv; - const char *func_name; -} testspec_t; - -LIBTESTS_EXTERNAL_DATA extern int T_debug; -#ifndef WIN32 -extern testspec_t T_testlist[]; -#endif - -ISC_LANG_BEGINDECLS - -#ifdef WIN32 -void -t_settests(const testspec_t list[]); - -int -t_main(int argc, char **argv); -#endif - -void -t_assert(const char *component, int anum, int tclass, const char *what, ...) - ISC_FORMAT_PRINTF(4, 5); - -void -t_info(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); - -void -t_result(int result); - -char * -t_getenv(const char *name); - -char * -t_fgetbs(FILE *fp); - -isc_result_t -t_dns_result_fromtext(char *result); - -unsigned int -t_dc_method_fromtext(char *dc_method); - -int -t_bustline(char *line, char **toks); - -int -t_eval(const char *filename, int (*func)(char **), int nargs); - -ISC_LANG_ENDDECLS - -#endif /* TESTS_T_API_H */ - diff --git a/lib/tests/t_api.c b/lib/tests/t_api.c deleted file mode 100644 index 70a219579e..0000000000 --- a/lib/tests/t_api.c +++ /dev/null @@ -1,851 +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_api.c,v 1.68 2010/12/21 04:20:23 marka Exp $ */ - -/*! \file */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef WIN32 -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "include/tests/t_api.h" - -static const char *Usage = - "\t-a : run all tests\n" - "\t-b : chdir to dir before running tests" - "\t-c : use specified config file\n" - "\t-d : set debug level to debug_level\n" - "\t-h : print test info\n" - "\t-u : print usage info\n" - "\t-n : run specified test name\n" - "\t-t : run specified test number\n" - "\t-x : don't execute tests in a subproc\n" - "\t-q : use 'timeout' as the timeout value\n"; -/*!< - * -a --> run all tests - * -b dir --> chdir to dir before running tests - * -c config --> use config file 'config' - * -d --> turn on api debugging - * -h --> print out available test names - * -u --> print usage info - * -n name --> run test named name - * -tn --> run test n - * -x --> don't execute testcases in a subproc - * -q timeout --> use 'timeout' as the timeout value - */ - -#define T_MAXTESTS 256 /*% must be 0 mod 8 */ -#define T_MAXENV 256 -#define T_DEFAULT_CONFIG "t_config" -#define T_BUFSIZ 256 -#define T_BIGBUF 4096 - -#define T_TCTOUT 60 - -int T_debug; -int T_timeout; -pid_t T_pid; -static const char * T_config; -static char T_tvec[T_MAXTESTS / 8]; -static char * T_env[T_MAXENV + 1]; -static char T_buf[T_BIGBUF]; -static char * T_dir; -#ifdef WIN32 -static testspec_t T_testlist[T_MAXTESTS]; -#endif - -static int -t_initconf(const char *path); - -static int -t_dumpconf(const char *path); - -static int -t_putinfo(const char *key, const char *info); - -static char * -t_getdate(char *buf, size_t buflen); - -static void -printhelp(void); - -static void -printusage(void); - -static int T_int; - -static void -t_sighandler(int sig) { - T_int = sig; -} - -int -#ifndef WIN32 -main(int argc, char **argv) -#else -t_main(int argc, char **argv) -#endif -{ - int c; - int tnum; -#ifndef WIN32 - int subprocs; - pid_t deadpid; - int status; -#endif - int len; - isc_boolean_t first; - testspec_t *pts; -#ifndef WIN32 - struct sigaction sa; -#endif - - isc_mem_debugging = ISC_MEM_DEBUGRECORD; - first = ISC_TRUE; -#ifndef WIN32 - subprocs = 1; -#endif - T_timeout = T_TCTOUT; - - /* - * -a option is now default. - */ - memset(T_tvec, 0xff, sizeof(T_tvec)); - - /* - * Parse args. - */ - while ((c = isc_commandline_parse(argc, argv, ":at:c:d:n:huxq:b:")) - != -1) { - if (c == 'a') { - /* - * Flag all tests to be run. - */ - memset(T_tvec, 0xff, sizeof(T_tvec)); - } - else if (c == 'b') { - T_dir = isc_commandline_argument; - } - else if (c == 't') { - tnum = atoi(isc_commandline_argument); - if ((tnum > 0) && (tnum < T_MAXTESTS)) { - if (first) { - /* - * Turn off effect of -a default - * and allow multiple -t and -n - * options. - */ - memset(T_tvec, 0, sizeof(T_tvec)); - first = ISC_FALSE; - } - /* - * Flag test tnum to be run. - */ - tnum -= 1; - T_tvec[tnum / 8] |= (0x01 << (tnum % 8)); - } - } - else if (c == 'c') { - T_config = isc_commandline_argument; - } - else if (c == 'd') { - T_debug = atoi(isc_commandline_argument); - } - else if (c == 'n') { - pts = &T_testlist[0]; - tnum = 0; - while (pts->pfv != NULL) { - if (! strcmp(pts->func_name, - isc_commandline_argument)) { - if (first) { - memset(T_tvec, 0, - sizeof(T_tvec)); - first = ISC_FALSE; - } - T_tvec[tnum/8] |= (0x01 << (tnum%8)); - break; - } - ++pts; - ++tnum; - } - if (pts->pfv == NULL) { - fprintf(stderr, "no such test %s\n", - isc_commandline_argument); - exit(1); - } - } - else if (c == 'h') { - printhelp(); - exit(0); - } - else if (c == 'u') { - printusage(); - exit(0); - } - else if (c == 'x') { -#ifndef WIN32 - subprocs = 0; -#endif - } - else if (c == 'q') { - T_timeout = atoi(isc_commandline_argument); - } - else if (c == ':') { - fprintf(stderr, "Option -%c requires an argument\n", - isc_commandline_option); - exit(1); - } - else if (c == '?') { - fprintf(stderr, "Unrecognized option -%c\n", - isc_commandline_option); - exit(1); - } - } - - /* - * Set cwd. - */ - - if (T_dir != NULL && chdir(T_dir) != 0) { - fprintf(stderr, "chdir %s failed\n", T_dir); - exit(1); - } - - /* - * We don't want buffered output. - */ - - (void)setbuf(stdout, NULL); - (void)setbuf(stderr, NULL); - - /* - * Setup signals. - */ - -#ifndef WIN32 - sa.sa_flags = 0; - sigfillset(&sa.sa_mask); - - sa.sa_handler = t_sighandler; - (void)sigaction(SIGINT, &sa, NULL); - (void)sigaction(SIGALRM, &sa, NULL); -#endif - - /* - * Output start stanza to journal. - */ - - snprintf(T_buf, sizeof(T_buf), "%s:", argv[0]); - len = strlen(T_buf); - (void) t_getdate(T_buf + len, T_BIGBUF - len); - t_putinfo("S", T_buf); - - /* - * Setup the test environment using the config file. - */ - - if (T_config == NULL) - T_config = T_DEFAULT_CONFIG; - - t_initconf(T_config); - if (T_debug) - t_dumpconf(T_config); - - /* - * Now invoke all the test cases. - */ - - tnum = 0; - pts = &T_testlist[0]; - while (pts->pfv != NULL) { - if (T_tvec[tnum / 8] & (0x01 << (tnum % 8))) { -#ifndef WIN32 - if (subprocs) { - T_pid = fork(); - if (T_pid == 0) { - (*pts->pfv)(); - exit(0); - } else if (T_pid > 0) { - - T_int = 0; - sa.sa_handler = t_sighandler; - (void)sigaction(SIGALRM, &sa, NULL); - alarm(T_timeout); - - deadpid = (pid_t) -1; - while (deadpid != T_pid) { - deadpid = - waitpid(T_pid, &status, 0); - if (deadpid == T_pid) { - if (WIFSIGNALED(status)) { - if (WTERMSIG(status) == - SIGTERM) - t_info( - "the test case timed out\n"); - else - t_info( - "the test case caused exception %d\n", - WTERMSIG(status)); - t_result(T_UNRESOLVED); - } - } else if ((deadpid == -1) && - (errno == EINTR) && - T_int) { - kill(T_pid, SIGTERM); - T_int = 0; - } - else if ((deadpid == -1) && - ((errno == ECHILD) || - (errno == ESRCH))) - break; - } - - alarm(0); - sa.sa_handler = SIG_IGN; - (void)sigaction(SIGALRM, &sa, NULL); - } else { - t_info("fork failed, errno == %d\n", - errno); - t_result(T_UNRESOLVED); - } - } - else { - (*pts->pfv)(); - } -#else - (*pts->pfv)(); -#endif - } - ++pts; - ++tnum; - } - - snprintf(T_buf, sizeof(T_buf), "%s:", argv[0]); - len = strlen(T_buf); - (void) t_getdate(T_buf + len, T_BIGBUF - len); - t_putinfo("E", T_buf); - - return(0); -} - -void -t_assert(const char *component, int anum, int tclass, const char *what, ...) { - va_list args; - char buf[T_BIGBUF]; - - (void)printf("T:%s:%d:%s\n", component, anum, tclass == T_REQUIRED ? - "A" : "C"); - - /* - * Format text to a buffer. - */ - va_start(args, what); - (void)vsnprintf(buf, sizeof(buf), what, args); - va_end(args); - - (void)t_putinfo("A", buf); - (void)printf("\n"); -} - -void -t_info(const char *format, ...) { - va_list args; - char buf[T_BIGBUF]; - - va_start(args, format); - (void) vsnprintf(buf, sizeof(buf), format, args); - va_end(args); - (void) t_putinfo("I", buf); -} - -void -t_result(int result) { - const char *p; - - switch (result) { - case T_PASS: - p = "PASS"; - break; - case T_FAIL: - p = "FAIL"; - break; - case T_UNRESOLVED: - p = "UNRESOLVED"; - break; - case T_SKIPPED: - p = "SKIPPED"; - break; - case T_UNTESTED: - p = "UNTESTED"; - break; - case T_THREADONLY: - p = "THREADONLY"; - break; - case T_PKCS11ONLY: - p = "PKCS11ONLY"; - break; - default: - p = "UNKNOWN"; - break; - } - printf("R:%s\n", p); -} - -char * -t_getenv(const char *name) { - char *n; - char **p; - size_t len; - - n = NULL; - if (name && *name) { - - p = &T_env[0]; - len = strlen(name); - - while (*p != NULL) { - if (strncmp(*p, name, len) == 0) { - if ( *(*p + len) == '=') { - n = *p + len + 1; - break; - } - } - ++p; - } - } - return(n); -} - -/* - * - * Read in the config file at path, initializing T_env. - * - * note: no format checking for now ... - * - */ - -static int -t_initconf(const char *path) { - - int n; - int rval; - char **p; - FILE *fp; - - rval = -1; - - fp = fopen(path, "r"); - if (fp != NULL) { - n = 0; - p = &T_env[0]; - while (n < T_MAXENV) { - *p = t_fgetbs(fp); - if (*p == NULL) - break; - if ((**p == '#') || (strchr(*p, '=') == NULL)) { - /* - * Skip comments and other junk. - */ - (void)free(*p); - continue; - } - ++p; ++n; - } - (void)fclose(fp); - rval = 0; - } - - return (rval); -} - -/* - * - * Dump T_env to stdout. - * - */ - -static int -t_dumpconf(const char *path) { - int rval; - char **p; - FILE *fp; - - rval = -1; - fp = fopen(path, "r"); - if (fp != NULL) { - p = &T_env[0]; - while (*p != NULL) { - printf("C:%s\n", *p); - ++p; - } - (void) fclose(fp); - rval = 0; - } - return(rval); -} - -/* - * - * Read a newline or EOF terminated string from fp. - * On success: - * return a malloc'd buf containing the string with - * the newline converted to a '\0'. - * On error: - * return NULL. - * - * Caller is responsible for freeing buf. - * - */ - -char * -t_fgetbs(FILE *fp) { - int c; - size_t n; - size_t size; - char *buf, *old; - char *p; - - n = 0; - size = T_BUFSIZ; - old = buf = (char *) malloc(T_BUFSIZ * sizeof(char)); - - if (buf != NULL) { - p = buf; - while ((c = fgetc(fp)) != EOF) { - - if ((c == '\r') || (c == '\n')) - break; - - *p++ = c; - ++n; - if ( n >= size ) { - size += T_BUFSIZ; - buf = (char *)realloc(buf, - size * sizeof(char)); - if (buf == NULL) - goto err; - old = buf; - p = buf + n; - } - } - *p = '\0'; - if (c == EOF && n == 0U) { - free(buf); - return (NULL); - } - return (buf); - } else { - err: - if (old != NULL) - free(old); - fprintf(stderr, "malloc/realloc failed %d", errno); - return(NULL); - } -} - -/* - * - * Put info to log, using key. - * For now, just dump it out. - * Later format into pretty lines. - * - */ - -static int -t_putinfo(const char *key, const char *info) { - int rval; - - /* - * For now. - */ - rval = printf("%s:%s", key, info); - return(rval); -} - -static char * -t_getdate(char *buf, size_t buflen) { - size_t n; - time_t t; - struct tm *p; -#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32) - struct tm tm; -#endif - - t = time(NULL); -#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32) - p = localtime_r(&t, &tm); -#else - p = localtime(&t); -#endif - n = strftime(buf, buflen - 1, "%A %d %B %H:%M:%S %Y\n", p); - return(n != 0U ? buf : NULL); -} - -/* - * Some generally used utilities. - */ -static const struct dns_errormap { - isc_result_t result; - const char *text; -} dns_errormap[] = { - { ISC_R_SUCCESS, "ISC_R_SUCCESS" }, - { ISC_R_EXISTS, "ISC_R_EXISTS" }, - { ISC_R_NOTFOUND, "ISC_R_NOTFOUND" }, - { ISC_R_NOSPACE, "ISC_R_NOSPACE" }, - { ISC_R_UNEXPECTED, "ISC_R_UNEXPECTED" }, - { ISC_R_UNEXPECTEDEND, "ISC_R_UNEXPECTEDEND" }, - { ISC_R_RANGE, "ISC_R_RANGE" }, - { DNS_R_LABELTOOLONG, "DNS_R_LABELTOOLONG" }, - { DNS_R_BADESCAPE, "DNS_R_BADESCAPE" }, - /* { DNS_R_BADBITSTRING, "DNS_R_BADBITSTRING" }, */ - /* { DNS_R_BITSTRINGTOOLONG, "DNS_R_BITSTRINGTOOLONG"}, */ - { DNS_R_EMPTYLABEL, "DNS_R_EMPTYLABEL" }, - { DNS_R_BADDOTTEDQUAD, "DNS_R_BADDOTTEDQUAD" }, - { DNS_R_UNKNOWN, "DNS_R_UNKNOWN" }, - { DNS_R_BADLABELTYPE, "DNS_R_BADLABELTYPE" }, - { DNS_R_BADPOINTER, "DNS_R_BADPOINTER" }, - { DNS_R_TOOMANYHOPS, "DNS_R_TOOMANYHOPS" }, - { DNS_R_DISALLOWED, "DNS_R_DISALLOWED" }, - { DNS_R_EXTRATOKEN, "DNS_R_EXTRATOKEN" }, - { DNS_R_EXTRADATA, "DNS_R_EXTRADATA" }, - { DNS_R_TEXTTOOLONG, "DNS_R_TEXTTOOLONG" }, - { DNS_R_SYNTAX, "DNS_R_SYNTAX" }, - { DNS_R_BADCKSUM, "DNS_R_BADCKSUM" }, - { DNS_R_BADAAAA, "DNS_R_BADAAAA" }, - { DNS_R_NOOWNER, "DNS_R_NOOWNER" }, - { DNS_R_NOTTL, "DNS_R_NOTTL" }, - { DNS_R_BADCLASS, "DNS_R_BADCLASS" }, - { DNS_R_PARTIALMATCH, "DNS_R_PARTIALMATCH" }, - { DNS_R_NEWORIGIN, "DNS_R_NEWORIGIN" }, - { DNS_R_UNCHANGED, "DNS_R_UNCHANGED" }, - { DNS_R_BADTTL, "DNS_R_BADTTL" }, - { DNS_R_NOREDATA, "DNS_R_NOREDATA" }, - { DNS_R_CONTINUE, "DNS_R_CONTINUE" }, - { DNS_R_DELEGATION, "DNS_R_DELEGATION" }, - { DNS_R_GLUE, "DNS_R_GLUE" }, - { DNS_R_DNAME, "DNS_R_DNAME" }, - { DNS_R_CNAME, "DNS_R_CNAME" }, - { DNS_R_NXDOMAIN, "DNS_R_NXDOMAIN" }, - { DNS_R_NXRRSET, "DNS_R_NXRRSET" }, - { DNS_R_BADDB, "DNS_R_BADDB" }, - { DNS_R_ZONECUT, "DNS_R_ZONECUT" }, - { DNS_R_NOTZONETOP, "DNS_R_NOTZONETOP" }, - { DNS_R_SEENINCLUDE, "DNS_R_SEENINCLUDE" }, - { DNS_R_SINGLETON, "DNS_R_SINGLETON" }, - { (isc_result_t)0, NULL } -}; - -isc_result_t -t_dns_result_fromtext(char *name) { - - isc_result_t result; - const struct dns_errormap *pmap; - - result = ISC_R_UNEXPECTED; - - pmap = dns_errormap; - while (pmap->text != NULL) { - if (strcmp(name, pmap->text) == 0) - break; - ++pmap; - } - - if (pmap->text != NULL) - result = pmap->result; - - return (result); -} - -static const struct dc_method_map { - unsigned int dc_method; - const char *text; -} dc_method_map[] = { - - { DNS_COMPRESS_NONE, "DNS_COMPRESS_NONE" }, - { DNS_COMPRESS_GLOBAL14, "DNS_COMPRESS_GLOBAL14" }, - { DNS_COMPRESS_ALL, "DNS_COMPRESS_ALL" }, - { 0, NULL } -}; - -unsigned int -t_dc_method_fromtext(char *name) { - unsigned int dc_method; - const struct dc_method_map *pmap; - - dc_method = DNS_COMPRESS_NONE; - - pmap = dc_method_map; - while (pmap->text != NULL) { - if (strcmp(name, pmap->text) == 0) - break; - ++pmap; - } - - if (pmap->text != NULL) - dc_method = pmap->dc_method; - - return(dc_method); -} - -int -t_bustline(char *line, char **toks) { - int cnt; - char *p; - - cnt = 0; - if (line && *line) { - while ((p = strtok(line, "\t")) && (cnt < T_MAXTOKS)) { - *toks++ = p; - line = NULL; - ++cnt; - } - } - return(cnt); -} - -static void -printhelp(void) { - int cnt; - testspec_t *pts; - - cnt = 1; - pts = &T_testlist[0]; - - printf("Available tests:\n"); - while (pts->func_name) { - printf("\t%d\t%s\n", cnt, pts->func_name); - ++pts; - ++cnt; - } -} - -static void -printusage(void) { - printf("Usage:\n%s\n", Usage); -} - -int -t_eval(const char *filename, int (*func)(char **), int nargs) { - FILE *fp; - char *p; - int line; - int cnt; - int result; - int tresult; - int nfails; - int nprobs; - int npass; - char *tokens[T_MAXTOKS + 1]; - - tresult = T_UNTESTED; - npass = 0; - 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 == nargs) { - tresult = func(tokens); - switch (tresult) { - case T_PASS: - ++npass; - break; - case T_FAIL: - ++nfails; - break; - case T_SKIPPED: - case T_UNTESTED: - break; - default: - ++nprobs; - break; - } - } 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 && npass > 0) - result = T_PASS; - else if (nfails > 0) - result = T_FAIL; - else if (npass == 0) - result = tresult; - - return (result); -} - -#ifdef WIN32 -void -t_settests(const testspec_t list[]) { - int tnum; - const testspec_t *pts; - - memset(T_testlist, 0, sizeof(T_testlist)); - - pts = &list[0]; - for (tnum = 0; tnum < T_MAXTESTS - 1; pts++, tnum++) { - if (pts->pfv == NULL) - break; - T_testlist[tnum] = *pts; - } -} -#endif diff --git a/lib/tests/win32/DLLMain.c b/lib/tests/win32/DLLMain.c deleted file mode 100644 index 03246be49b..0000000000 --- a/lib/tests/win32/DLLMain.c +++ /dev/null @@ -1,51 +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$ */ - -#include -#include - -/* - * Called when we enter the DLL - */ -__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, - DWORD fdwReason, LPVOID lpvReserved) -{ - switch (fdwReason) { - /* - * The DLL is loading due to process - * initialization or a call to LoadLibrary. - */ - case DLL_PROCESS_ATTACH: - break; - - /* The attached process creates a new thread. */ - case DLL_THREAD_ATTACH: - break; - - /* The thread of the attached process terminates. */ - case DLL_THREAD_DETACH: - break; - - /* - * The DLL is unloading from a process due to - * process termination or a call to FreeLibrary. - */ - case DLL_PROCESS_DETACH: - break; - - default: - break; - } - return (TRUE); -} - diff --git a/lib/tests/win32/libtests.def b/lib/tests/win32/libtests.def deleted file mode 100644 index ed11153cec..0000000000 --- a/lib/tests/win32/libtests.def +++ /dev/null @@ -1,15 +0,0 @@ -LIBRARY libtests - -; Exported Functions -EXPORTS -t_assert -t_bustline -t_dc_method_fromtext -t_dns_result_fromtext -t_eval -t_fgetbs -t_getenv -t_info -t_main -t_result -t_settests diff --git a/lib/tests/win32/libtests.vcxproj.filters.in b/lib/tests/win32/libtests.vcxproj.filters.in deleted file mode 100644 index d8af4d9262..0000000000 --- a/lib/tests/win32/libtests.vcxproj.filters.in +++ /dev/null @@ -1,33 +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 - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/lib/tests/win32/libtests.vcxproj.in b/lib/tests/win32/libtests.vcxproj.in deleted file mode 100644 index e4a58496f1..0000000000 --- a/lib/tests/win32/libtests.vcxproj.in +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Debug - @PLATFORM@ - - - Release - @PLATFORM@ - - - - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - Win32Proj - libtests - - - - DynamicLibrary - true - MultiByte - - - DynamicLibrary - false - true - MultiByte - - - - - - - - - - - - - true - ..\..\..\Build\$(Configuration)\ - .\$(Configuration)\ - - - false - ..\..\..\Build\$(Configuration)\ - .\$(Configuration)\ - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTESTS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions) - ./;../../../;include;../include;../../isc/win32;../../isc/win32/include;../../isc/include;../../dns/include;@LIBXML2_INC@%(AdditionalIncludeDirectories) - true - .\$(Configuration)\$(TargetName).pch - .\$(Configuration)\ - .\$(Configuration)\ - $(OutDir)$(TargetName).pdb - true - CompileAsC - - - Console - true - ../../isc/win32/$(Configuration);../../dns/win32/$(Configuration);%(AdditionalLibraryDirectories) - libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies) - .\libtests.def - .\$(Configuration)\$(ProjectName).lib - ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - - - - - Level3 - - - MaxSpeed - true - @INTRINSIC@ - WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBTESTS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions) - ./;../../../;include;../include;../../isc/win32;../../isc/win32/include;../../isc/include;../../dns/include;@LIBXML2_INC@%(AdditionalIncludeDirectories) - OnlyExplicitInline - false - true - .\$(Configuration)\$(TargetName).pch - .\$(Configuration)\ - .\$(Configuration)\ - $(OutDir)$(TargetName).pdb - CompileAsC - - - Console - false - true - true - ../../isc/win32/$(Configuration);../../dns/win32/$(Configuration);%(AdditionalLibraryDirectories) - libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies) - .\libtests.def - .\$(Configuration)\$(ProjectName).lib - Default - ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) - - - - - - - - - - - - - - - - diff --git a/lib/tests/win32/libtests.vcxproj.user b/lib/tests/win32/libtests.vcxproj.user deleted file mode 100644 index 695b5c78b9..0000000000 --- a/lib/tests/win32/libtests.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/util/copyrights b/util/copyrights index a43fa006ba..6fb3ae7552 100644 --- a/util/copyrights +++ b/util/copyrights @@ -331,220 +331,54 @@ ./bin/rndc/win32/rndcutil.vcxproj.in X 2013,2015,2016,2017,2018 ./bin/rndc/win32/rndcutil.vcxproj.user X 2013,2018 ./bin/tests/.gitignore X 2012,2013,2017,2018 -./bin/tests/Kchild.example.+003+04017.key X 2000,2001,2018 -./bin/tests/Kchild.example.+003+04017.private X 2000,2001,2018 ./bin/tests/Makefile.in MAKE 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018 -./bin/tests/adb_test.c C 1999,2000,2001,2004,2005,2007,2009,2011,2012,2013,2015,2016,2018 -./bin/tests/atomic/Makefile.in MAKE 2011,2012,2014,2016,2017,2018 -./bin/tests/atomic/t_atomic.c C 2011,2013,2015,2016,2017,2018 -./bin/tests/atomic/win32/t_atomic.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/atomic/win32/t_atomic.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/atomic/win32/t_atomic.vcxproj.user X 2013,2018 -./bin/tests/b8t.mk MAKE 1999,2000,2001,2004,2007,2012,2016,2018 -./bin/tests/b9t.mk MAKE 1999,2000,2001,2004,2007,2012,2016,2018 -./bin/tests/backtrace_test.c C 2009,2013,2015,2016,2018 ./bin/tests/bigtest/README TXT.BRIEF 2013,2016,2018 ./bin/tests/bigtest/buildzones.sh SH 2013,2016,2018 ./bin/tests/bigtest/rndc.key X 2013,2018 ./bin/tests/bigtest/tests.sh SH 2013,2016,2018 ./bin/tests/bigtest/zones X 2013,2018 -./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/dnssec-signzone/Kexample.com.+005+07065.key X 2009,2018 -./bin/tests/dnssec-signzone/Kexample.com.+005+07065.private X 2009,2018 -./bin/tests/dnssec-signzone/Kexample.com.+005+23362.key X 2009,2018 -./bin/tests/dnssec-signzone/Kexample.com.+005+23362.private X 2009,2018 -./bin/tests/dnssec-signzone/bogus-ksk.key X 2009,2018 -./bin/tests/dnssec-signzone/bogus-zsk.key X 2009,2018 -./bin/tests/dnssec-signzone/run-test.sh SH 2009,2012,2016,2018 -./bin/tests/dnssec-signzone/test1.zone X 2009,2018 -./bin/tests/dnssec-signzone/test2.zone X 2009,2018 -./bin/tests/dnssec-signzone/test3.zone X 2009,2018 -./bin/tests/dnssec-signzone/test4.zone X 2009,2018 -./bin/tests/dnssec-signzone/test5.zone X 2009,2018 -./bin/tests/dnssec-signzone/test6.zone X 2009,2018 -./bin/tests/dnssec-signzone/test7.zone X 2009,2018 -./bin/tests/dnssec-signzone/test8.zone X 2009,2018 -./bin/tests/dst/.gitignore X 2012,2013,2018 -./bin/tests/dst/Kdh.+002+18602.key.in X 2001,2013,2018 -./bin/tests/dst/Kdh.+002+18602.private.in X 2001,2013,2018 -./bin/tests/dst/Kdh.+002+48957.key.in X 2001,2013,2018 -./bin/tests/dst/Kdh.+002+48957.private.in X 2001,2013,2018 -./bin/tests/dst/Ktest.+001+00002.key.in X 2001,2004,2013,2018 -./bin/tests/dst/Ktest.+001+54622.key.in X 1999,2000,2001,2004,2013,2018 -./bin/tests/dst/Ktest.+001+54622.private.in X 1999,2000,2001,2013,2018 -./bin/tests/dst/Ktest.+003+23616.key.in X 2001,2004,2013,2018 -./bin/tests/dst/Ktest.+003+23616.private.in X 2001,2013,2018 -./bin/tests/dst/Ktest.+003+49667.key.in X 2001,2004,2013,2018 -./bin/tests/dst/Makefile.in MAKE 1999,2000,2001,2002,2004,2006,2007,2008,2009,2010,2012,2013,2014,2016,2017,2018 -./bin/tests/dst/dst_2_data.in X 1999,2000,2001,2013,2018 -./bin/tests/dst/dst_test.c C 1999,2000,2001,2004,2005,2007,2009,2012,2014,2015,2016,2018 -./bin/tests/dst/gsstest.c C 2006,2007,2009,2010,2011,2013,2014,2015,2016,2018 -./bin/tests/dst/t2_data_1.in X 1999,2000,2001,2013,2018 -./bin/tests/dst/t2_data_2.in X 1999,2000,2001,2013,2018 -./bin/tests/dst/t2_dsasig.in X 1999,2000,2001,2013,2018 -./bin/tests/dst/t2_rsasig.in X 1999,2000,2001,2013,2018 -./bin/tests/dst/t_dst.c C 1999,2000,2001,2004,2005,2007,2008,2009,2011,2012,2013,2014,2016,2017,2018 -./bin/tests/dst/win32/REQUIRE_EXTENDED_DIR X 2013,2018 -./bin/tests/dst/win32/t_dst.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/dst/win32/t_dst.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/dst/win32/t_dst.vcxproj.user X 2013,2018 -./bin/tests/entropy2_test.c C 2000,2001,2004,2005,2007,2015,2016,2018 -./bin/tests/entropy_test.c C 2000,2001,2004,2005,2007,2015,2016,2018 ./bin/tests/fromhex.pl PERL 2015,2016,2018 -./bin/tests/fsaccess_test.c C 2000,2001,2004,2005,2007,2012,2015,2016,2018 -./bin/tests/hash_test.c C 2000,2001,2004,2005,2006,2007,2014,2015,2016,2017,2018 -./bin/tests/hashes/Makefile.in MAKE 2010,2012,2014,2016,2017,2018 -./bin/tests/hashes/t_hashes.c C 2010,2013,2016,2018 -./bin/tests/hashes/win32/t_hashes.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/hashes/win32/t_hashes.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/hashes/win32/t_hashes.vcxproj.user X 2013,2018 ./bin/tests/headerdep_test.sh.in SH 2000,2001,2004,2007,2012,2016,2018 -./bin/tests/inter_test.c C 2000,2001,2003,2004,2005,2007,2008,2015,2016,2018 -./bin/tests/keyboard_test.c C 2000,2001,2004,2005,2007,2015,2016,2018 -./bin/tests/lex_test.c C 1998,1999,2000,2001,2004,2005,2007,2015,2016,2018 -./bin/tests/lfsr_test.c C 1999,2000,2001,2004,2005,2007,2015,2016,2018 -./bin/tests/log_test.c C 1999,2000,2001,2004,2007,2011,2014,2015,2016,2018 ./bin/tests/makejournal.c C 2013,2015,2016,2017,2018 -./bin/tests/master/Makefile.in MAKE 1999,2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/master/dns_master_load_10_data X 2000,2001,2018 -./bin/tests/master/dns_master_load_11_data X 2000,2001,2018 -./bin/tests/master/dns_master_load_1_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_2_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_3_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_4_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_5_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_6_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_7_data X 1999,2000,2001,2018 -./bin/tests/master/dns_master_load_8_data X 2000,2001,2018 -./bin/tests/master/dns_master_load_9_data X 2000,2001,2018 -./bin/tests/master/master1.data X 1999,2000,2001,2018 -./bin/tests/master/master10.data X 2000,2001,2018 -./bin/tests/master/master11.data X 2000,2001,2018 -./bin/tests/master/master2.data X 1999,2000,2001,2018 -./bin/tests/master/master3.data X 1999,2000,2001,2018 -./bin/tests/master/master4.data X 1999,2000,2001,2018 -./bin/tests/master/master5.data X 1999,2000,2001,2018 -./bin/tests/master/master6.data X 1999,2000,2001,2003,2018 -./bin/tests/master/master7.data X 1999,2000,2001,2003,2018 -./bin/tests/master/master8.data X 2000,2001,2018 -./bin/tests/master/master9.data X 2000,2001,2018 -./bin/tests/master/t_master.c C 1998,1999,2000,2001,2003,2004,2005,2007,2009,2011,2013,2016,2017,2018 -./bin/tests/master/win32/t_master.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/master/win32/t_master.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/master/win32/t_master.vcxproj.user X 2013,2018 -./bin/tests/master_test.c C 1999,2000,2001,2004,2007,2009,2015,2016,2017,2018 -./bin/tests/mem/Makefile.in MAKE 1998,1999,2000,2001,2002,2004,2005,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/mem/t_mem.c C 1999,2000,2001,2004,2007,2009,2013,2016,2018 -./bin/tests/mem/win32/t_mem.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/mem/win32/t_mem.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/mem/win32/t_mem.vcxproj.user X 2013,2018 -./bin/tests/mempool_test.c C 1999,2000,2001,2004,2007,2016,2018 -./bin/tests/name_test.c C 1998,1999,2000,2001,2003,2004,2005,2007,2009,2015,2016,2017,2018 ./bin/tests/named.conf CONF-C 1999,2000,2001,2004,2007,2011,2015,2016,2018 -./bin/tests/names/Makefile.in MAKE 1999,2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/names/dns_name_compare_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_countlabels_data X 1999,2000,2001,2003,2018 -./bin/tests/names/dns_name_fromregion_data X 1999,2000,2001,2003,2018 -./bin/tests/names/dns_name_fromtext_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_1_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_2_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_3_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_4_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_5_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_6_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_7_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_fromwire_8_data X 1999,2000,2001,2006,2018 -./bin/tests/names/dns_name_fullcompare_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_getlabel_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_getlabelsequence_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_hash_data X 1999,2000,2001,2003,2012,2018 -./bin/tests/names/dns_name_isabsolute_data X 1999,2000,2001,2003,2018 -./bin/tests/names/dns_name_issubdomain_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_rdatacompare_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_toregion_data X 1999,2000,2001,2003,2018 -./bin/tests/names/dns_name_totext_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_towire_1_data X 1999,2000,2001,2018 -./bin/tests/names/dns_name_towire_2_data X 1999,2000,2001,2018 -./bin/tests/names/t_names.c C 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2018 -./bin/tests/names/win32/t_names.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/names/win32/t_names.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/names/win32/t_names.vcxproj.user X 2013,2018 -./bin/tests/names/wire_test1.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test2.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test3_1.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test3_2.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test4.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test5.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test6.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test7.data X 1999,2000,2001,2018 -./bin/tests/names/wire_test8.data X 1999,2000,2001,2018 -./bin/tests/ndc.conf CONF-C 2000,2001,2004,2007,2016,2018 ./bin/tests/ndc.conf-include CONF-C 2001,2004,2007,2016,2018 -./bin/tests/net/Makefile.in MAKE 2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/net/driver.c C 2000,2001,2004,2007,2015,2016,2017,2018 -./bin/tests/net/driver.h C 2000,2001,2004,2007,2016,2018 -./bin/tests/net/netaddr_multicast.c C 2000,2001,2004,2007,2015,2016,2018 -./bin/tests/net/sockaddr_multicast.c C 2000,2001,2004,2007,2016,2018 -./bin/tests/net/testsuite.h C 2000,2001,2004,2007,2016,2018 -./bin/tests/nsecify.c C 1999,2000,2001,2003,2004,2007,2008,2009,2011,2015,2016,2017,2018 +./bin/tests/optional/Kchild.example.+003+04017.key X 2000,2001,2018 +./bin/tests/optional/Kchild.example.+003+04017.private X 2000,2001,2018 +./bin/tests/optional/Makefile.in MAKE 2018 +./bin/tests/optional/adb_test.c C 1999,2000,2001,2004,2005,2007,2009,2011,2012,2013,2015,2016,2018 +./bin/tests/optional/backtrace_test.c C 2009,2013,2015,2016,2018 +./bin/tests/optional/byaddr_test.c C 2000,2001,2002,2004,2005,2007,2012,2015,2016,2018 +./bin/tests/optional/byname_test.c C 2000,2001,2004,2005,2007,2009,2012,2015,2016,2017,2018 +./bin/tests/optional/db_test.c C 1999,2000,2001,2004,2005,2007,2008,2009,2011,2012,2013,2015,2016,2017,2018 +./bin/tests/optional/dst_test.c C 2018 +./bin/tests/optional/entropy2_test.c C 2000,2001,2004,2005,2007,2015,2016,2018 +./bin/tests/optional/entropy_test.c C 2000,2001,2004,2005,2007,2015,2016,2018 +./bin/tests/optional/fsaccess_test.c C 2000,2001,2004,2005,2007,2012,2015,2016,2018 +./bin/tests/optional/gsstest.c C 2018 +./bin/tests/optional/hash_test.c C 2000,2001,2004,2005,2006,2007,2014,2015,2016,2017,2018 +./bin/tests/optional/inter_test.c C 2000,2001,2003,2004,2005,2007,2008,2015,2016,2018 +./bin/tests/optional/keyboard_test.c C 2000,2001,2004,2005,2007,2015,2016,2018 +./bin/tests/optional/lex_test.c C 1998,1999,2000,2001,2004,2005,2007,2015,2016,2018 +./bin/tests/optional/lfsr_test.c C 1999,2000,2001,2004,2005,2007,2015,2016,2018 +./bin/tests/optional/log_test.c C 1999,2000,2001,2004,2007,2011,2014,2015,2016,2018 +./bin/tests/optional/master_test.c C 1999,2000,2001,2004,2007,2009,2015,2016,2017,2018 +./bin/tests/optional/mempool_test.c C 1999,2000,2001,2004,2007,2016,2018 +./bin/tests/optional/name_test.c C 1998,1999,2000,2001,2003,2004,2005,2007,2009,2015,2016,2017,2018 +./bin/tests/optional/nsecify.c C 1999,2000,2001,2003,2004,2007,2008,2009,2011,2015,2016,2017,2018 +./bin/tests/optional/ratelimiter_test.c C 1999,2000,2001,2004,2007,2015,2016,2018 +./bin/tests/optional/rbt_test.c C 1999,2000,2001,2004,2005,2007,2009,2011,2012,2014,2015,2016,2018 +./bin/tests/optional/rbt_test.out X 1999,2000,2001,2018 +./bin/tests/optional/rbt_test.txt SH 1999,2000,2001,2004,2007,2012,2016,2018 +./bin/tests/optional/rwlock_test.c C 1998,1999,2000,2001,2004,2005,2007,2013,2016,2017,2018 +./bin/tests/optional/serial_test.c C 1999,2000,2001,2003,2004,2007,2015,2016,2018 +./bin/tests/optional/shutdown_test.c C 1998,1999,2000,2001,2004,2007,2011,2013,2016,2017,2018 +./bin/tests/optional/sig0_test.c C 2000,2001,2004,2005,2007,2008,2009,2012,2015,2016,2018 +./bin/tests/optional/sock_test.c C 1998,1999,2000,2001,2004,2007,2008,2012,2013,2014,2015,2016,2017,2018 +./bin/tests/optional/sym_test.c C 1998,1999,2000,2001,2004,2005,2007,2015,2016,2018 +./bin/tests/optional/task_test.c C 1998,1999,2000,2001,2004,2007,2013,2014,2015,2016,2018 +./bin/tests/optional/timer_test.c C 1998,1999,2000,2001,2004,2007,2013,2014,2015,2016,2018 +./bin/tests/optional/zone_test.c C 1999,2000,2001,2002,2004,2005,2007,2009,2012,2014,2015,2016,2018 ./bin/tests/pkcs11/.gitignore X 2014,2018 ./bin/tests/pkcs11/Makefile.in MAKE 2014,2016,2018 ./bin/tests/pkcs11/README X 2014,2016,2018 @@ -562,60 +396,12 @@ ./bin/tests/pkcs11/benchmarks/verify.c C 2014,2015,2016,2018 ./bin/tests/pkcs11/pkcs11-hmacmd5.c C 2014,2015,2016,2018 ./bin/tests/pkcs11/pkcs11-md5sum.c C 2014,2015,2016,2018 -./bin/tests/ratelimiter_test.c C 1999,2000,2001,2004,2007,2015,2016,2018 -./bin/tests/rbt/Makefile.in MAKE 1999,2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/rbt/dns_rbt.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbt_addname_1_data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbt_addname_2_data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbt_bitstring.data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbt_create_1_data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbt_deletename_1_data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbt_deletename_2_data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbt_findname_1_data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbt_findname_2_data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbt_findname_3_data X 1999,2000,2001,2003,2018 -./bin/tests/rbt/dns_rbtnodechain_first_1.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_first_2.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_first_data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_init.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_init_data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_last_1.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_last_2.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_last_data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_next.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_next_data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_prev.data X 1999,2000,2001,2018 -./bin/tests/rbt/dns_rbtnodechain_prev_data X 1999,2000,2001,2018 -./bin/tests/rbt/t_rbt.c C 1998,1999,2000,2001,2003,2004,2005,2007,2009,2011,2012,2013,2015,2016,2018 -./bin/tests/rbt/win32/t_rbt.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/rbt/win32/t_rbt.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/rbt/win32/t_rbt.vcxproj.user X 2013,2018 -./bin/tests/rbt_test.c C 1999,2000,2001,2004,2005,2007,2009,2011,2012,2014,2015,2016,2018 -./bin/tests/rbt_test.out X 1999,2000,2001,2018 -./bin/tests/rbt_test.txt SH 1999,2000,2001,2004,2007,2012,2016,2018 -./bin/tests/resolv.conf.sample CONF-SH 2000,2001,2004,2007,2012,2016,2018 -./bin/tests/resolver/Makefile.in MAKE 2011,2012,2014,2016,2017,2018 -./bin/tests/resolver/t_resolver.c C 2011,2012,2013,2014,2016,2018 -./bin/tests/resolver/win32/t_resolver.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/resolver/win32/t_resolver.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/resolver/win32/t_resolver.vcxproj.user X 2013,2018 -./bin/tests/rwlock_test.c C 1998,1999,2000,2001,2004,2005,2007,2013,2016,2017,2018 -./bin/tests/serial_test.c C 1999,2000,2001,2003,2004,2007,2015,2016,2018 -./bin/tests/shutdown_test.c C 1998,1999,2000,2001,2004,2007,2011,2013,2016,2017,2018 -./bin/tests/sig0_test.c C 2000,2001,2004,2005,2007,2008,2009,2012,2015,2016,2018 -./bin/tests/sock_test.c C 1998,1999,2000,2001,2004,2007,2008,2012,2013,2014,2015,2016,2017,2018 -./bin/tests/sockaddr/Makefile.in MAKE 1999,2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/sockaddr/t_sockaddr.c C 1999,2000,2001,2004,2007,2013,2016,2018 -./bin/tests/sockaddr/win32/t_sockaddr.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/sockaddr/win32/t_sockaddr.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/sockaddr/win32/t_sockaddr.vcxproj.user X 2013,2018 ./bin/tests/startperf/README X 2011,2018 ./bin/tests/startperf/clean.sh SH 2011,2012,2016,2018 ./bin/tests/startperf/makenames.pl PERL 2011,2012,2016,2018 ./bin/tests/startperf/mkzonefile.pl PERL 2011,2012,2016,2018 ./bin/tests/startperf/setup.sh SH 2011,2012,2016,2018 ./bin/tests/startperf/smallzone.db ZONE 2011,2016,2018 -./bin/tests/sym_test.c C 1998,1999,2000,2001,2004,2005,2007,2015,2016,2018 ./bin/tests/system/.gitignore X 2012,2016,2018 ./bin/tests/system/Makefile.in MAKE 2000,2001,2004,2007,2008,2010,2011,2012,2013,2014,2015,2016,2017,2018 ./bin/tests/system/README TXT.BRIEF 2000,2001,2004,2010,2011,2013,2015,2016,2017,2018 @@ -1296,6 +1082,20 @@ ./bin/tests/system/dnssec/prereq.sh SH 2000,2001,2002,2004,2006,2007,2009,2012,2014,2015,2016,2018 ./bin/tests/system/dnssec/setup.sh SH 2000,2001,2004,2007,2009,2011,2012,2013,2014,2015,2016,2017,2018 ./bin/tests/system/dnssec/signer/example.db.in ZONE 2010,2016,2018 +./bin/tests/system/dnssec/signer/general/Kexample.com.+005+07065.key X 2018 +./bin/tests/system/dnssec/signer/general/Kexample.com.+005+07065.private X 2018 +./bin/tests/system/dnssec/signer/general/Kexample.com.+005+23362.key X 2018 +./bin/tests/system/dnssec/signer/general/Kexample.com.+005+23362.private X 2018 +./bin/tests/system/dnssec/signer/general/bogus-ksk.key X 2018 +./bin/tests/system/dnssec/signer/general/bogus-zsk.key X 2018 +./bin/tests/system/dnssec/signer/general/test1.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test2.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test3.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test4.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test5.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test6.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test7.zone ZONE 2018 +./bin/tests/system/dnssec/signer/general/test8.zone ZONE 2018 ./bin/tests/system/dnssec/signer/remove.db.in ZONE 2016,2018 ./bin/tests/system/dnssec/signer/remove2.db.in ZONE 2016,2018 ./bin/tests/system/dnssec/tests.sh SH 2000,2001,2002,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018 @@ -2533,19 +2333,10 @@ ./bin/tests/system/zonechecks/prereq.sh SH 2014,2016,2018 ./bin/tests/system/zonechecks/setup.sh SH 2012,2013,2014,2015,2016,2017,2018 ./bin/tests/system/zonechecks/tests.sh SH 2004,2007,2009,2012,2013,2014,2015,2016,2018 -./bin/tests/t_api.pl PERL 1999,2000,2001,2004,2007,2012,2016,2018 -./bin/tests/task_test.c C 1998,1999,2000,2001,2004,2007,2013,2014,2015,2016,2018 -./bin/tests/tasks/Makefile.in MAKE 1998,1999,2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/tasks/t_tasks.c C 1998,1999,2000,2001,2004,2005,2007,2009,2011,2013,2014,2015,2016,2018 -./bin/tests/tasks/win32/t_tasks.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/tasks/win32/t_tasks.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/tasks/win32/t_tasks.vcxproj.user X 2013,2015,2018 -./bin/tests/timer_test.c C 1998,1999,2000,2001,2004,2007,2013,2014,2015,2016,2018 -./bin/tests/timers/Makefile.in MAKE 1999,2000,2001,2002,2004,2007,2009,2012,2014,2016,2017,2018 -./bin/tests/timers/t_timers.c C 1999,2000,2001,2004,2007,2008,2009,2011,2013,2016,2018 -./bin/tests/timers/win32/t_timers.vcxproj.filters.in X 2013,2015,2018 -./bin/tests/timers/win32/t_timers.vcxproj.in X 2013,2015,2016,2017,2018 -./bin/tests/timers/win32/t_timers.vcxproj.user X 2013,2018 +./bin/tests/testdata/wire/wire_test.data X 1999,2000,2001,2018 +./bin/tests/testdata/wire/wire_test.data2 X 1999,2000,2001,2018 +./bin/tests/testdata/wire/wire_test.data3 X 1999,2000,2001,2018 +./bin/tests/testdata/wire/wire_test.data4 X 1999,2000,2001,2018 ./bin/tests/virtual-time/Makefile.in MAKE 2010,2012,2016,2018 ./bin/tests/virtual-time/README TXT.BRIEF 2010,2016,2018 ./bin/tests/virtual-time/autosign-ksk/clean.sh SH 2010,2012,2015,2016,2018 @@ -2610,11 +2401,6 @@ ./bin/tests/win32/timer_test.vcxproj.in X 2013,2015,2016,2017,2018 ./bin/tests/win32/timer_test.vcxproj.user X 2013,2018 ./bin/tests/wire_test.c C 1999,2000,2001,2004,2005,2007,2015,2016,2018 -./bin/tests/wire_test.data X 1999,2000,2001,2018 -./bin/tests/wire_test.data2 X 1999,2000,2001,2018 -./bin/tests/wire_test.data3 X 1999,2000,2001,2018 -./bin/tests/wire_test.data4 X 1999,2000,2001,2018 -./bin/tests/zone_test.c C 1999,2000,2001,2002,2004,2005,2007,2009,2012,2014,2015,2016,2018 ./bin/tools/.gitignore X 2012,2014,2015,2016,2017,2018 ./bin/tools/Makefile.in MAKE 2009,2010,2012,2013,2014,2015,2016,2017,2018 ./bin/tools/arpaname.1 MAN DOCBOOK @@ -3686,6 +3472,7 @@ ./lib/dns/tests/dnstap_test.c C 2015,2016,2017,2018 ./lib/dns/tests/dnstest.c C 2011,2012,2013,2014,2015,2016,2017,2018 ./lib/dns/tests/dnstest.h C 2011,2012,2014,2015,2016,2017,2018 +./lib/dns/tests/dst_test.c C 2018 ./lib/dns/tests/dstrandom_test.c C 2017,2018 ./lib/dns/tests/geoip_test.c C 2013,2014,2015,2016,2017,2018 ./lib/dns/tests/gost_test.c C 2014,2015,2016,2017,2018 @@ -3701,7 +3488,9 @@ ./lib/dns/tests/rdata_test.c C 2012,2013,2015,2016,2017,2018 ./lib/dns/tests/rdataset_test.c C 2012,2016,2018 ./lib/dns/tests/rdatasetstats_test.c C 2012,2015,2016,2018 +./lib/dns/tests/resolver_test.c C 2018 ./lib/dns/tests/rsa_test.c C 2016,2018 +./lib/dns/tests/testdata/db/data.db ZONE 2018 ./lib/dns/tests/testdata/dbiterator/zone1.data ZONE 2011,2012,2016,2018 ./lib/dns/tests/testdata/dbiterator/zone2.data X 2011,2018 ./lib/dns/tests/testdata/diff/zone1.data ZONE 2011,2012,2016,2018 @@ -3713,6 +3502,16 @@ ./lib/dns/tests/testdata/dnstap/query.recursive X 2015,2018 ./lib/dns/tests/testdata/dnstap/response.auth X 2015,2018 ./lib/dns/tests/testdata/dnstap/response.recursive X 2015,2018 +./lib/dns/tests/testdata/dst/Ktest.+001+00002.key X 2018 +./lib/dns/tests/testdata/dst/Ktest.+001+54622.key X 2018 +./lib/dns/tests/testdata/dst/Ktest.+001+54622.private X 2018 +./lib/dns/tests/testdata/dst/Ktest.+003+23616.key X 2018 +./lib/dns/tests/testdata/dst/Ktest.+003+23616.private X 2018 +./lib/dns/tests/testdata/dst/Ktest.+003+49667.key X 2018 +./lib/dns/tests/testdata/dst/test1.data X 2018 +./lib/dns/tests/testdata/dst/test1.dsasig X 2018 +./lib/dns/tests/testdata/dst/test1.rsasig X 2018 +./lib/dns/tests/testdata/dst/test2.data X 2018 ./lib/dns/tests/testdata/dstrandom/random.data X 2017,2018 ./lib/dns/tests/testdata/master/.gitignore X 2012,2018 ./lib/dns/tests/testdata/master/master1.data X 2011,2018 @@ -4039,6 +3838,7 @@ ./lib/isc/tests/Kyuafile X 2017,2018 ./lib/isc/tests/Makefile.in MAKE 2011,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/tests/aes_test.c C 2014,2016,2018 +./lib/isc/tests/atomic_test.c C 2018 ./lib/isc/tests/buffer_test.c C 2014,2015,2016,2017,2018 ./lib/isc/tests/counter_test.c C 2014,2016,2018 ./lib/isc/tests/errno_test.c C 2016,2018 @@ -4068,6 +3868,7 @@ ./lib/isc/tests/taskpool_test.c C 2011,2012,2016,2018 ./lib/isc/tests/testdata/file/keep X 2014,2018 ./lib/isc/tests/time_test.c C 2014,2015,2016,2018 +./lib/isc/tests/timer_test.c C 2018 ./lib/isc/timer.c C 1998,1999,2000,2001,2002,2004,2005,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/timer_p.h C 2000,2001,2004,2005,2007,2009,2016,2017,2018 ./lib/isc/tm.c C 2014,2016,2018 @@ -4329,17 +4130,6 @@ ./lib/samples/win32/update.vcxproj.filters.in X 2014,2015,2018 ./lib/samples/win32/update.vcxproj.in X 2014,2015,2016,2017,2018 ./lib/samples/win32/update.vcxproj.user X 2014,2018 -./lib/tests/Makefile.in MAKE 1998,1999,2000,2001,2003,2004,2007,2009,2012,2016,2017,2018 -./lib/tests/T_testlist.imp X 2004,2018 -./lib/tests/include/Makefile.in MAKE 1998,1999,2000,2001,2004,2007,2012,2016,2018 -./lib/tests/include/tests/Makefile.in MAKE 1999,2000,2001,2004,2007,2012,2015,2016,2018 -./lib/tests/include/tests/t_api.h C 1999,2000,2001,2004,2005,2006,2007,2010,2013,2014,2016,2017,2018 -./lib/tests/t_api.c C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010,2013,2014,2016,2017,2018 -./lib/tests/win32/DLLMain.c C 2013,2016,2018 -./lib/tests/win32/libtests.def X 2013,2018 -./lib/tests/win32/libtests.vcxproj.filters.in X 2013,2015,2018 -./lib/tests/win32/libtests.vcxproj.in X 2013,2015,2016,2017,2018 -./lib/tests/win32/libtests.vcxproj.user X 2013,2018 ./lib/win32/bindevt/bindevt.c C 2000,2001,2004,2007,2016,2018 ./lib/win32/bindevt/bindevt.mc MC 2001,2004,2007,2016,2018 ./lib/win32/bindevt/bindevt.vcxproj.filters.in X 2013,2015,2018 diff --git a/win32utils/Configure b/win32utils/Configure index 915cece5d1..c519788157 100644 --- a/win32utils/Configure +++ b/win32utils/Configure @@ -116,26 +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\\atomic\\win32\\t_atomic.vcxproj", - "..\\bin\\tests\\atomic\\win32\\t_atomic.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\\master\\win32\\t_master.vcxproj", - "..\\bin\\tests\\master\\win32\\t_master.vcxproj.filters", - "..\\bin\\tests\\mem\\win32\\t_mem.vcxproj", - "..\\bin\\tests\\mem\\win32\\t_mem.vcxproj.filters", - "..\\bin\\tests\\hashes\\win32\\t_hashes.vcxproj", - "..\\bin\\tests\\hashes\\win32\\t_hashes.vcxproj.filters", - "..\\bin\\tests\\names\\win32\\t_names.vcxproj", - "..\\bin\\tests\\names\\win32\\t_names.vcxproj.filters", - "..\\bin\\tests\\rbt\\win32\\t_rbt.vcxproj", - "..\\bin\\tests\\rbt\\win32\\t_rbt.vcxproj.filters", - "..\\bin\\tests\\resolver\\win32\\t_resolver.vcxproj", - "..\\bin\\tests\\resolver\\win32\\t_resolver.vcxproj.filters", - "..\\bin\\tests\\sockaddr\\win32\\t_sockaddr.vcxproj", - "..\\bin\\tests\\sockaddr\\win32\\t_sockaddr.vcxproj.filters", "..\\bin\\tests\\system\\win32\\bigkey.vcxproj", "..\\bin\\tests\\system\\win32\\bigkey.vcxproj.filters", "..\\bin\\tests\\system\\win32\\feature-test.vcxproj", @@ -148,10 +128,6 @@ my @projectlist = ("..\\bin\\check\\win32\\checkconf.vcxproj", "..\\bin\\tests\\system\\win32\\keydelete.vcxproj.filters", "..\\bin\\tests\\system\\win32\\pipequeries.vcxproj", "..\\bin\\tests\\system\\win32\\pipequeries.vcxproj.filters", - "..\\bin\\tests\\tasks\\win32\\t_tasks.vcxproj", - "..\\bin\\tests\\tasks\\win32\\t_tasks.vcxproj.filters", - "..\\bin\\tests\\timers\\win32\\t_timers.vcxproj", - "..\\bin\\tests\\timers\\win32\\t_timers.vcxproj.filters", "..\\bin\\tests\\win32\\backtrace_test.vcxproj", "..\\bin\\tests\\win32\\backtrace_test.vcxproj.filters", "..\\bin\\tests\\win32\\inter_test.vcxproj", diff --git a/win32utils/bind9.sln.in b/win32utils/bind9.sln.in index 8230983a2c..6119af1b0a 100644 --- a/win32utils/bind9.sln.in +++ b/win32utils/bind9.sln.in @@ -496,97 +496,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pk11tokens", "..\bin\pkcs11 EndProjectSection EndProject @END PKCS11 -@IF TESTS -@IF ATOMIC -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_atomic", "..\bin\tests\atomic\win32\t_atomic.vcxproj", "{EC6ECB35-58C0-48EC-BAC9-9A652D9406C9}" - 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} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -@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} - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A} = {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - {B4AC7F81-E3DC-43E9-B339-4FA5149FA8F7} = {B4AC7F81-E3DC-43E9-B339-4FA5149FA8F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_master", "..\bin\tests\master\win32\t_master.vcxproj", "{5DC2F8D3-9373-41BB-B3AB-78F2E12F1E5E}" - 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} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_mem", "..\bin\tests\mem\win32\t_mem.vcxproj", "{627F32A9-267F-41CA-827C-1FD04DE20A56}" - ProjectSection(ProjectDependencies) = postProject - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_hashes", "..\bin\tests\hashes\win32\t_hashes.vcxproj", "{14071120-84F6-4A6F-BF23-90EC5D0372CE}" - ProjectSection(ProjectDependencies) = postProject - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_names", "..\bin\tests\names\win32\t_names.vcxproj", "{124DC0D3-3096-41D2-B490-CE85E890FF33}" - 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} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_rbt", "..\bin\tests\rbt\win32\t_rbt.vcxproj", "{39F714D4-FEFB-4E23-91DB-1F6FC80A98B5}" - 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} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_resolver", "..\bin\tests\resolver\win32\t_resolver.vcxproj", "{66E58849-A764-44E4-8D32-7C1107246A26}" - 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} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_sockaddr", "..\bin\tests\sockaddr\win32\t_sockaddr.vcxproj", "{351D3872-707B-46AD-8BC0-5A668B8C745B}" - ProjectSection(ProjectDependencies) = postProject - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_tasks", "..\bin\tests\tasks\win32\t_tasks.vcxproj", "{2CB7B128-5954-4FAF-B5EA-501B23BB8054}" - ProjectSection(ProjectDependencies) = postProject - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t_timers", "..\bin\tests\timers\win32\t_timers.vcxproj", "{4E6F5A7C-89AA-4259-99DB-F89DAE418B3F}" - ProjectSection(ProjectDependencies) = postProject - {3840E563-D180-4761-AA9C-E6155F02EAFF} = {3840E563-D180-4761-AA9C-E6155F02EAFF} - {F6F08940-7597-4FEE-9CE0-E09A009C45A3} = {F6F08940-7597-4FEE-9CE0-E09A009C45A3} - EndProjectSection -EndProject -@END TESTS @IF XTESTS Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "backtrace_test", "..\bin\tests\win32\backtrace_test.vcxproj", "{14751171-C40E-40EE-A2F0-37FFC3CCD4A2}" ProjectSection(ProjectDependencies) = postProject