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/lwres/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/lwres/tests')
-rw-r--r-- | lib/lwres/tests/Atffile | 5 | ||||
-rw-r--r-- | lib/lwres/tests/Kyuafile | 4 | ||||
-rw-r--r-- | lib/lwres/tests/Makefile.in | 49 | ||||
-rw-r--r-- | lib/lwres/tests/config_test.c | 68 | ||||
-rw-r--r-- | lib/lwres/tests/testdata/link-local.conf | 1 |
5 files changed, 127 insertions, 0 deletions
diff --git a/lib/lwres/tests/Atffile b/lib/lwres/tests/Atffile new file mode 100644 index 0000000..69a7eba --- /dev/null +++ b/lib/lwres/tests/Atffile @@ -0,0 +1,5 @@ +Content-Type: application/X-atf-atffile; version="1" + +prop: test-suite = bind9 + +tp: config_test diff --git a/lib/lwres/tests/Kyuafile b/lib/lwres/tests/Kyuafile new file mode 100644 index 0000000..6d373e8 --- /dev/null +++ b/lib/lwres/tests/Kyuafile @@ -0,0 +1,4 @@ +syntax(2) +test_suite('bind9') + +atf_test_program{name='config_test'} diff --git a/lib/lwres/tests/Makefile.in b/lib/lwres/tests/Makefile.in new file mode 100644 index 0000000..b0e989d --- /dev/null +++ b/lib/lwres/tests/Makefile.in @@ -0,0 +1,49 @@ +# 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$ + +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 ${LWRES_INCLUDES} +CDEFINES = -DTESTS="\"${top_builddir}/lib/lwres/tests/\"" + +LWRESLIBS = ../liblwres.@A@ +LWRESDEPLIBS = ../liblwres.@A@ + +LIBS = @LIBS@ @ATFLIBS@ + +OBJS = +SRCS = config_test.c + +SUBDIRS = +TARGETS = config_test@EXEEXT@ + +@BIND9_MAKE_RULES@ + +config_test@EXEEXT@: config_test.@O@ ${LWRESDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + config_test.@O@ ${LWRESLIBS} ${LIBS} + +unit:: + sh ${top_srcdir}/unit/unittest.sh + +clean distclean:: + rm -f ${TARGETS} + rm -f atf.out diff --git a/lib/lwres/tests/config_test.c b/lib/lwres/tests/config_test.c new file mode 100644 index 0000000..0a6d66a --- /dev/null +++ b/lib/lwres/tests/config_test.c @@ -0,0 +1,68 @@ +/* + * 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 "../lwconfig.c" + +static void +setup_test() { + /* + * atf-run changes us to a /tmp directory, so tests + * that access test data files must first chdir to the proper + * location. + */ + ATF_CHECK(chdir(TESTS) != -1); +} + +ATF_TC(parse_linklocal); +ATF_TC_HEAD(parse_linklocal, tc) { + atf_tc_set_md_var(tc, "descr", "lwres_conf_parse link-local nameserver"); +} +ATF_TC_BODY(parse_linklocal, tc) { + lwres_result_t result; + lwres_context_t *ctx = NULL; + unsigned char addr[16] = { 0xfe, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01 }; + + UNUSED(tc); + + setup_test(); + + lwres_context_create(&ctx, NULL, NULL, NULL, + LWRES_CONTEXT_USEIPV4 | LWRES_CONTEXT_USEIPV6); + ATF_CHECK_EQ(ctx->confdata.nsnext, 0); + ATF_CHECK_EQ(ctx->confdata.nameservers[0].zone, 0); + + result = lwres_conf_parse(ctx, "testdata/link-local.conf"); + ATF_CHECK_EQ(result, LWRES_R_SUCCESS); + ATF_CHECK_EQ(ctx->confdata.nsnext, 1); + ATF_CHECK_EQ(ctx->confdata.nameservers[0].zone, 1); + ATF_CHECK_EQ(memcmp(ctx->confdata.nameservers[0].address, addr, 16), 0); + lwres_context_destroy(&ctx); +} + +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, parse_linklocal); + return (atf_no_error()); +} diff --git a/lib/lwres/tests/testdata/link-local.conf b/lib/lwres/tests/testdata/link-local.conf new file mode 100644 index 0000000..8a37963 --- /dev/null +++ b/lib/lwres/tests/testdata/link-local.conf @@ -0,0 +1 @@ +nameserver fe80::1%1 |