diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
commit | ea648e70a989cca190cd7403fe892fd2dcc290b4 (patch) | |
tree | e2b6b1c647da68b0d4d66082835e256eb30970e8 /lib/irs/tests | |
parent | Initial commit. (diff) | |
download | bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.tar.xz bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.zip |
Adding upstream version 1:9.11.5.P4+dfsg.upstream/1%9.11.5.P4+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/irs/tests')
-rw-r--r-- | lib/irs/tests/Atffile | 5 | ||||
-rw-r--r-- | lib/irs/tests/Kyuafile | 4 | ||||
-rw-r--r-- | lib/irs/tests/Makefile.in | 53 | ||||
-rw-r--r-- | lib/irs/tests/resconf_test.c | 139 | ||||
-rw-r--r-- | lib/irs/tests/testdata/domain.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/nameserver-v4.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/nameserver-v6.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options-bad-ndots.conf | 11 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options-debug.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options-empty.conf | 11 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options-ndots.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options-timeout.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options-unknown.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/options.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/port.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/resolv.conf | 17 | ||||
-rw-r--r-- | lib/irs/tests/testdata/search.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/sortlist-v4.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/timeout.conf | 10 | ||||
-rw-r--r-- | lib/irs/tests/testdata/unknown.conf | 10 |
20 files changed, 370 insertions, 0 deletions
diff --git a/lib/irs/tests/Atffile b/lib/irs/tests/Atffile new file mode 100644 index 0000000..90f6d60 --- /dev/null +++ b/lib/irs/tests/Atffile @@ -0,0 +1,5 @@ +Content-Type: application/X-atf-atffile; version="1" + +prop: test-suite = bind9 + +tp: resconf_test diff --git a/lib/irs/tests/Kyuafile b/lib/irs/tests/Kyuafile new file mode 100644 index 0000000..4ef7136 --- /dev/null +++ b/lib/irs/tests/Kyuafile @@ -0,0 +1,4 @@ +syntax(2) +test_suite('bind9') + +atf_test_program{name='resconf_test'} diff --git a/lib/irs/tests/Makefile.in b/lib/irs/tests/Makefile.in new file mode 100644 index 0000000..1a51aa9 --- /dev/null +++ b/lib/irs/tests/Makefile.in @@ -0,0 +1,53 @@ +# 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@ + +# Attempt to disable parallel processing. +.NOTPARALLEL: +.NO_PARALLEL: + +VERSION=@BIND9_VERSION@ + +@BIND9_MAKE_INCLUDES@ + +CINCLUDES = -I. -Iinclude -I../include ${ISC_INCLUDES} ${IRS_INCLUDES} +CDEFINES = -DTESTS="\"${top_builddir}/lib/irs/tests/\"" + +CFGLIBS = ../../isccfg/libisccfg.@A@ +CFGDEPLIBS = ../../isccfg/libisccfg.@A@ +DNSLIBS = ../../dns/libdns.@A@ @DNS_CRYPTO_LIBS@ +DNSDEPLIBS = ../../dns/libdns.@A@ +ISCLIBS = ../../isc/libisc.@A@ +ISCDEPLIBS = ../../isc/libisc.@A@ +IRSLIBS = ../libirs.@A@ +IRSDEPLIBS = ../libirs.@A@ + +LIBS = ${IRSLIBS} ${CFGLIBS} ${DNSLIBS} ${ISCLIBS} @LIBS@ @ATFLIBS@ + +OBJS = +SRCS = resconf_test.c + +SUBDIRS = +TARGETS = resconf_test@EXEEXT@ + +@BIND9_MAKE_RULES@ + +resconf_test@EXEEXT@: resconf_test.@O@ ${CFGDEPLIBS} ${DNSDEPLIBS} ${IRSDEPLIBS} ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + resconf_test.@O@ ${LIBS} + +unit:: + sh ${top_builddir}/unit/unittest.sh + +clean distclean:: + rm -f ${TARGETS} + rm -f atf.out diff --git a/lib/irs/tests/resconf_test.c b/lib/irs/tests/resconf_test.c new file mode 100644 index 0000000..488ed5b --- /dev/null +++ b/lib/irs/tests/resconf_test.c @@ -0,0 +1,139 @@ +/* + * 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. + */ + +#include <config.h> + +#include <atf-c.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <isc/mem.h> +#include <isc/util.h> + +#include <irs/types.h> +#include <irs/resconf.h> + +static isc_mem_t *mctx = NULL; + +static void +setup_test() { + isc_result_t result; + + result = isc_mem_create(0, 0, &mctx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * atf-run changes us to a /tmp directory, so tests + * that access test data files must first chdir to the proper + * location. + */ + ATF_REQUIRE(chdir(TESTS) != -1); +} + +ATF_TC(irs_resconf_load); +ATF_TC_HEAD(irs_resconf_load, tc) { + atf_tc_set_md_var(tc, "descr", "irs_resconf_load"); +} +ATF_TC_BODY(irs_resconf_load, tc) { + isc_result_t result; + irs_resconf_t *resconf = NULL; + unsigned int i; + struct { + const char *file; + isc_result_t loadres; + isc_result_t (*check)(irs_resconf_t *resconf); + isc_result_t checkres; + } tests[] = { + { + "testdata/domain.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/nameserver-v4.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/nameserver-v6.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-debug.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-ndots.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-timeout.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-unknown.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-bad-ndots.conf", ISC_R_RANGE, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-empty.conf", ISC_R_UNEXPECTEDEND, + NULL, ISC_R_SUCCESS + }, { + "testdata/port.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/resolv.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/search.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/sortlist-v4.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/timeout.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/unknown.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + } + + }; + + UNUSED(tc); + + setup_test(); + + for (i = 0; i < sizeof(tests)/sizeof(tests[1]); i++) { + result = irs_resconf_load(mctx, tests[i].file, &resconf); + ATF_CHECK_EQ_MSG(result, tests[i].loadres, "%s", tests[i].file); + if (result == ISC_R_SUCCESS) + ATF_CHECK_MSG(resconf != NULL, "%s", tests[i].file); + else + ATF_CHECK_MSG(resconf == NULL, "%s", tests[i].file); + if (resconf != NULL && tests[i].check != NULL) { + result = (tests[i].check)(resconf); + ATF_CHECK_EQ_MSG(result, tests[i].checkres, "%s", + tests[i].file); + } + if (resconf != NULL) + irs_resconf_destroy(&resconf); + } + + isc_mem_detach(&mctx); +} + +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, irs_resconf_load); + return (atf_no_error()); +} diff --git a/lib/irs/tests/testdata/domain.conf b/lib/irs/tests/testdata/domain.conf new file mode 100644 index 0000000..6aef473 --- /dev/null +++ b/lib/irs/tests/testdata/domain.conf @@ -0,0 +1,10 @@ +# 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. + +domain example.com diff --git a/lib/irs/tests/testdata/nameserver-v4.conf b/lib/irs/tests/testdata/nameserver-v4.conf new file mode 100644 index 0000000..871d011 --- /dev/null +++ b/lib/irs/tests/testdata/nameserver-v4.conf @@ -0,0 +1,10 @@ +# 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. + +nameserver 10.0.0.1 diff --git a/lib/irs/tests/testdata/nameserver-v6.conf b/lib/irs/tests/testdata/nameserver-v6.conf new file mode 100644 index 0000000..9147462 --- /dev/null +++ b/lib/irs/tests/testdata/nameserver-v6.conf @@ -0,0 +1,10 @@ +# 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. + +nameserver 2001:DB8::1 diff --git a/lib/irs/tests/testdata/options-bad-ndots.conf b/lib/irs/tests/testdata/options-bad-ndots.conf new file mode 100644 index 0000000..5c104c7 --- /dev/null +++ b/lib/irs/tests/testdata/options-bad-ndots.conf @@ -0,0 +1,11 @@ +# 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. + +search example.com example.net +options ndots:256 diff --git a/lib/irs/tests/testdata/options-debug.conf b/lib/irs/tests/testdata/options-debug.conf new file mode 100644 index 0000000..b6e14c7 --- /dev/null +++ b/lib/irs/tests/testdata/options-debug.conf @@ -0,0 +1,10 @@ +# 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. + +options debug diff --git a/lib/irs/tests/testdata/options-empty.conf b/lib/irs/tests/testdata/options-empty.conf new file mode 100644 index 0000000..e8b902e --- /dev/null +++ b/lib/irs/tests/testdata/options-empty.conf @@ -0,0 +1,11 @@ +# 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. + +domain example.com +options diff --git a/lib/irs/tests/testdata/options-ndots.conf b/lib/irs/tests/testdata/options-ndots.conf new file mode 100644 index 0000000..2f143e1 --- /dev/null +++ b/lib/irs/tests/testdata/options-ndots.conf @@ -0,0 +1,10 @@ +# 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. + +option ndots:2 diff --git a/lib/irs/tests/testdata/options-timeout.conf b/lib/irs/tests/testdata/options-timeout.conf new file mode 100644 index 0000000..e211bba --- /dev/null +++ b/lib/irs/tests/testdata/options-timeout.conf @@ -0,0 +1,10 @@ +# 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. + +options timeout:1 diff --git a/lib/irs/tests/testdata/options-unknown.conf b/lib/irs/tests/testdata/options-unknown.conf new file mode 100644 index 0000000..f5df6bf --- /dev/null +++ b/lib/irs/tests/testdata/options-unknown.conf @@ -0,0 +1,10 @@ +# 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. + +options unknown diff --git a/lib/irs/tests/testdata/options.conf b/lib/irs/tests/testdata/options.conf new file mode 100644 index 0000000..0d4dfa0 --- /dev/null +++ b/lib/irs/tests/testdata/options.conf @@ -0,0 +1,10 @@ +# 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. + +options unknown debug timeout:1 ndots:2 diff --git a/lib/irs/tests/testdata/port.conf b/lib/irs/tests/testdata/port.conf new file mode 100644 index 0000000..04ed3e7 --- /dev/null +++ b/lib/irs/tests/testdata/port.conf @@ -0,0 +1,10 @@ +# 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. + +port 5300 diff --git a/lib/irs/tests/testdata/resolv.conf b/lib/irs/tests/testdata/resolv.conf new file mode 100644 index 0000000..ddf93ff --- /dev/null +++ b/lib/irs/tests/testdata/resolv.conf @@ -0,0 +1,17 @@ +# 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. + +port 5300 +nameserver 10.0.0.1 +nameserver 2001:DB8::1 +search example.com example.net +sortlist 130.155.160.0/255.255.240.0 130.155.0.0 +timeout 10 +unknown directive +options unknown debug timeout:1 ndots:2 diff --git a/lib/irs/tests/testdata/search.conf b/lib/irs/tests/testdata/search.conf new file mode 100644 index 0000000..5717006 --- /dev/null +++ b/lib/irs/tests/testdata/search.conf @@ -0,0 +1,10 @@ +# 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. + +search example.com example.net diff --git a/lib/irs/tests/testdata/sortlist-v4.conf b/lib/irs/tests/testdata/sortlist-v4.conf new file mode 100644 index 0000000..e903e37 --- /dev/null +++ b/lib/irs/tests/testdata/sortlist-v4.conf @@ -0,0 +1,10 @@ +# 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. + +sortlist 130.155.160.0/255.255.240.0 130.155.0.0 diff --git a/lib/irs/tests/testdata/timeout.conf b/lib/irs/tests/testdata/timeout.conf new file mode 100644 index 0000000..2b87b25 --- /dev/null +++ b/lib/irs/tests/testdata/timeout.conf @@ -0,0 +1,10 @@ +# 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. + +timeout 10 diff --git a/lib/irs/tests/testdata/unknown.conf b/lib/irs/tests/testdata/unknown.conf new file mode 100644 index 0000000..bfb9d7f --- /dev/null +++ b/lib/irs/tests/testdata/unknown.conf @@ -0,0 +1,10 @@ +# 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. + +unknown directive |