mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
Merge branch 'ondrej-unit-tests-refactoring' into 'main'
Give the unit tests a big overhaul and move all the unit tests to /tests/<libname>/ See merge request isc-projects/bind9!6243
This commit is contained in:
@@ -58,6 +58,8 @@ IncludeCategories:
|
|||||||
Priority: 55
|
Priority: 55
|
||||||
- Regex: '^".*"'
|
- Regex: '^".*"'
|
||||||
Priority: 99
|
Priority: 99
|
||||||
|
- Regex: '^<tests/'
|
||||||
|
Priority: 100
|
||||||
- Regex: '<openssl/'
|
- Regex: '<openssl/'
|
||||||
Priority: 1
|
Priority: 1
|
||||||
- Regex: '<(mysql|protobuf-c)/'
|
- Regex: '<(mysql|protobuf-c)/'
|
||||||
|
@@ -48,6 +48,8 @@ IncludeCategories:
|
|||||||
Priority: 7
|
Priority: 7
|
||||||
- Regex: '^(<[^/]*)/)'
|
- Regex: '^(<[^/]*)/)'
|
||||||
Priority: 8
|
Priority: 8
|
||||||
|
- Regex: '^<tests/'
|
||||||
|
Priority: 10
|
||||||
- Regex: '<[[:alnum:].]+>'
|
- Regex: '<[[:alnum:].]+>'
|
||||||
Priority: 1
|
Priority: 1
|
||||||
- Regex: '".*"'
|
- Regex: '".*"'
|
||||||
|
@@ -1420,9 +1420,9 @@ gcov:
|
|||||||
# Generate XML file in the Cobertura XML format suitable for use by GitLab
|
# Generate XML file in the Cobertura XML format suitable for use by GitLab
|
||||||
# for the purpose of displaying code coverage information in the diff view
|
# for the purpose of displaying code coverage information in the diff view
|
||||||
# of a given merge request.
|
# of a given merge request.
|
||||||
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --xml -o coverage.xml
|
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude tests --xml -o coverage.xml
|
||||||
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --html-details -o coverage.html
|
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude tests --html-details -o coverage.html
|
||||||
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' -o coverage.txt
|
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude tests -o coverage.txt
|
||||||
- tail -n 3 coverage.txt
|
- tail -n 3 coverage.txt
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
|
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
5895. [test] Add new set of unit test macros and move the unit
|
||||||
|
tests under single namespace in /tests/. [GL !6243]
|
||||||
|
|
||||||
5894. [func] Avoid periodic interface re-scans on Linux by
|
5894. [func] Avoid periodic interface re-scans on Linux by
|
||||||
default, where a reliable event-based mechanism for
|
default, where a reliable event-based mechanism for
|
||||||
detecting interface state changes is available.
|
detecting interface state changes is available.
|
||||||
|
@@ -2,6 +2,10 @@ include $(top_srcdir)/Makefile.top
|
|||||||
|
|
||||||
SUBDIRS = . lib doc bin fuzz
|
SUBDIRS = . lib doc bin fuzz
|
||||||
|
|
||||||
|
if HAVE_CMOCKA
|
||||||
|
SUBDIRS += tests
|
||||||
|
endif HAVE_CMOCKA
|
||||||
|
|
||||||
BUILT_SOURCES = bind.keys.h
|
BUILT_SOURCES = bind.keys.h
|
||||||
CLEANFILES = bind.keys.h
|
CLEANFILES = bind.keys.h
|
||||||
|
|
||||||
|
@@ -3,18 +3,21 @@
|
|||||||
|
|
||||||
unit-local: check
|
unit-local: check
|
||||||
|
|
||||||
|
if HAVE_CMOCKA
|
||||||
TESTS = $(check_PROGRAMS)
|
TESTS = $(check_PROGRAMS)
|
||||||
|
endif HAVE_CMOCKA
|
||||||
|
|
||||||
LOG_COMPILER = $(builddir)/../../unit-test-driver.sh
|
LOG_COMPILER = $(top_builddir)/tests/unit-test-driver.sh
|
||||||
|
|
||||||
AM_CFLAGS += \
|
AM_CFLAGS += \
|
||||||
|
-I$(top_srcdir)/tests/include \
|
||||||
$(TEST_CFLAGS)
|
$(TEST_CFLAGS)
|
||||||
|
|
||||||
AM_CPPFLAGS += \
|
AM_CPPFLAGS += \
|
||||||
$(CMOCKA_CFLAGS) \
|
$(CMOCKA_CFLAGS) \
|
||||||
-DNAMED_PLUGINDIR=\"$(pkglibdir)\" \
|
-DNAMED_PLUGINDIR=\"$(pkglibdir)\" \
|
||||||
-DSKIPPED_TEST_EXIT_CODE=77 \
|
|
||||||
-DTESTS_DIR=\"$(abs_srcdir)\"
|
-DTESTS_DIR=\"$(abs_srcdir)\"
|
||||||
|
|
||||||
LDADD += \
|
LDADD += \
|
||||||
|
$(top_builddir)/tests/libtest/libtest.la \
|
||||||
$(CMOCKA_LIBS)
|
$(CMOCKA_LIBS)
|
||||||
|
16
configure.ac
16
configure.ac
@@ -1581,14 +1581,16 @@ AC_CONFIG_FILES([doc/Makefile
|
|||||||
|
|
||||||
# Unit Tests
|
# Unit Tests
|
||||||
|
|
||||||
AC_CONFIG_FILES([lib/isc/tests/Makefile
|
AC_CONFIG_FILES([tests/Makefile
|
||||||
lib/dns/tests/Makefile
|
tests/isc/Makefile
|
||||||
lib/ns/tests/Makefile
|
tests/dns/Makefile
|
||||||
lib/irs/tests/Makefile
|
tests/ns/Makefile
|
||||||
lib/isccfg/tests/Makefile])
|
tests/irs/Makefile
|
||||||
|
tests/isccfg/Makefile
|
||||||
|
tests/libtest/Makefile])
|
||||||
|
|
||||||
AC_CONFIG_FILES([lib/unit-test-driver.sh],
|
AC_CONFIG_FILES([tests/unit-test-driver.sh],
|
||||||
[chmod +x lib/unit-test-driver.sh])
|
[chmod +x tests/unit-test-driver.sh])
|
||||||
|
|
||||||
# System Tests
|
# System Tests
|
||||||
|
|
||||||
|
@@ -321,7 +321,3 @@ if HAVE_LMDB
|
|||||||
libdns_la_CPPFLAGS += $(LMDB_CFLAGS)
|
libdns_la_CPPFLAGS += $(LMDB_CFLAGS)
|
||||||
libdns_la_LIBADD += $(LMDB_LIBS)
|
libdns_la_LIBADD += $(LMDB_LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_CMOCKA
|
|
||||||
SUBDIRS = tests
|
|
||||||
endif
|
|
||||||
|
1
lib/dns/tests
Symbolic link
1
lib/dns/tests
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../tests/dns
|
@@ -25,7 +25,3 @@ libirs_la_LIBADD = \
|
|||||||
libirs_la_LDFLAGS = \
|
libirs_la_LDFLAGS = \
|
||||||
$(AM_LDFLAGS) \
|
$(AM_LDFLAGS) \
|
||||||
-release "$(PACKAGE_VERSION)"
|
-release "$(PACKAGE_VERSION)"
|
||||||
|
|
||||||
if HAVE_CMOCKA
|
|
||||||
SUBDIRS = tests
|
|
||||||
endif
|
|
||||||
|
1
lib/irs/tests
Symbolic link
1
lib/irs/tests
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../tests/irs
|
@@ -251,7 +251,3 @@ libisc_la_CPPFLAGS += \
|
|||||||
libisc_la_LIBADD += \
|
libisc_la_LIBADD += \
|
||||||
$(LIBXML2_LIBS)
|
$(LIBXML2_LIBS)
|
||||||
endif HAVE_LIBXML2
|
endif HAVE_LIBXML2
|
||||||
|
|
||||||
if HAVE_CMOCKA
|
|
||||||
SUBDIRS = tests
|
|
||||||
endif
|
|
||||||
|
1
lib/isc/tests
Symbolic link
1
lib/isc/tests
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../tests/isc
|
@@ -1,163 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MPL-2.0
|
|
||||||
*
|
|
||||||
* 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 https://mozilla.org/MPL/2.0/.
|
|
||||||
*
|
|
||||||
* See the COPYRIGHT file distributed with this work for additional
|
|
||||||
* information regarding copyright ownership.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*! \file */
|
|
||||||
|
|
||||||
#include "isctest.h"
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <isc/buffer.h>
|
|
||||||
#include <isc/hash.h>
|
|
||||||
#include <isc/managers.h>
|
|
||||||
#include <isc/mem.h>
|
|
||||||
#include <isc/os.h>
|
|
||||||
#include <isc/string.h>
|
|
||||||
#include <isc/task.h>
|
|
||||||
#include <isc/timer.h>
|
|
||||||
#include <isc/util.h>
|
|
||||||
|
|
||||||
isc_mem_t *test_mctx = NULL;
|
|
||||||
isc_log_t *test_lctx = NULL;
|
|
||||||
isc_taskmgr_t *taskmgr = NULL;
|
|
||||||
isc_timermgr_t *timermgr = NULL;
|
|
||||||
isc_nm_t *netmgr = NULL;
|
|
||||||
isc_task_t *maintask = NULL;
|
|
||||||
int ncpus;
|
|
||||||
|
|
||||||
static bool test_running = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Logging categories: this needs to match the list in bin/named/log.c.
|
|
||||||
*/
|
|
||||||
static isc_logcategory_t categories[] = { { "", 0 },
|
|
||||||
{ "client", 0 },
|
|
||||||
{ "network", 0 },
|
|
||||||
{ "update", 0 },
|
|
||||||
{ "queries", 0 },
|
|
||||||
{ "unmatched", 0 },
|
|
||||||
{ "update-security", 0 },
|
|
||||||
{ "query-errors", 0 },
|
|
||||||
{ NULL, 0 } };
|
|
||||||
|
|
||||||
static void
|
|
||||||
cleanup_managers(void) {
|
|
||||||
if (maintask != NULL) {
|
|
||||||
isc_task_detach(&maintask);
|
|
||||||
}
|
|
||||||
isc_managers_destroy(netmgr == NULL ? NULL : &netmgr,
|
|
||||||
taskmgr == NULL ? NULL : &taskmgr,
|
|
||||||
timermgr == NULL ? NULL : &timermgr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static isc_result_t
|
|
||||||
create_managers(unsigned int workers) {
|
|
||||||
isc_result_t result;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (workers == 0) {
|
|
||||||
workers = isc_os_ncpus();
|
|
||||||
}
|
|
||||||
p = getenv("ISC_TASK_WORKERS");
|
|
||||||
if (p != NULL) {
|
|
||||||
workers = atoi(p);
|
|
||||||
}
|
|
||||||
INSIST(workers != 0);
|
|
||||||
|
|
||||||
isc_managers_create(test_mctx, workers, 0, &netmgr, &taskmgr,
|
|
||||||
&timermgr);
|
|
||||||
|
|
||||||
CHECK(isc_task_create(taskmgr, 0, &maintask, 0));
|
|
||||||
isc_taskmgr_setexcltask(taskmgr, maintask);
|
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
cleanup_managers();
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_result_t
|
|
||||||
isc_test_begin(FILE *logfile, bool start_managers, unsigned int workers) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
INSIST(!test_running);
|
|
||||||
test_running = true;
|
|
||||||
|
|
||||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
|
||||||
|
|
||||||
INSIST(test_mctx == NULL);
|
|
||||||
isc_mem_create(&test_mctx);
|
|
||||||
|
|
||||||
if (logfile != NULL) {
|
|
||||||
isc_logdestination_t destination;
|
|
||||||
isc_logconfig_t *logconfig = NULL;
|
|
||||||
|
|
||||||
INSIST(test_lctx == NULL);
|
|
||||||
isc_log_create(test_mctx, &test_lctx, &logconfig);
|
|
||||||
isc_log_registercategories(test_lctx, categories);
|
|
||||||
isc_log_setcontext(test_lctx);
|
|
||||||
|
|
||||||
destination.file.stream = logfile;
|
|
||||||
destination.file.name = NULL;
|
|
||||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
|
||||||
destination.file.maximum_size = 0;
|
|
||||||
isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
|
|
||||||
ISC_LOG_DYNAMIC, &destination, 0);
|
|
||||||
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
ncpus = isc_os_ncpus();
|
|
||||||
|
|
||||||
if (start_managers) {
|
|
||||||
CHECK(create_managers(workers));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
isc_test_end();
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
isc_test_end(void) {
|
|
||||||
if (maintask != NULL) {
|
|
||||||
isc_task_detach(&maintask);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_managers();
|
|
||||||
|
|
||||||
if (test_lctx != NULL) {
|
|
||||||
isc_log_destroy(&test_lctx);
|
|
||||||
}
|
|
||||||
if (test_mctx != NULL) {
|
|
||||||
isc_mem_destroy(&test_mctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
test_running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sleep for 'usec' microseconds.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
isc_test_nap(uint32_t usec) {
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
ts.tv_sec = usec / 1000000;
|
|
||||||
ts.tv_nsec = (usec % 1000000) * 1000;
|
|
||||||
nanosleep(&ts, NULL);
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MPL-2.0
|
|
||||||
*
|
|
||||||
* 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 https://mozilla.org/MPL/2.0/.
|
|
||||||
*
|
|
||||||
* See the COPYRIGHT file distributed with this work for additional
|
|
||||||
* information regarding copyright ownership.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/*! \file */
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include <isc/buffer.h>
|
|
||||||
#include <isc/hash.h>
|
|
||||||
#include <isc/log.h>
|
|
||||||
#include <isc/mem.h>
|
|
||||||
#include <isc/netmgr.h>
|
|
||||||
#include <isc/print.h>
|
|
||||||
#include <isc/result.h>
|
|
||||||
#include <isc/string.h>
|
|
||||||
#include <isc/task.h>
|
|
||||||
#include <isc/timer.h>
|
|
||||||
#include <isc/util.h>
|
|
||||||
|
|
||||||
#define CHECK(r) \
|
|
||||||
do { \
|
|
||||||
result = (r); \
|
|
||||||
if (result != ISC_R_SUCCESS) \
|
|
||||||
goto cleanup; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
extern isc_mem_t *test_mctx;
|
|
||||||
extern isc_log_t *test_lctx;
|
|
||||||
extern isc_taskmgr_t *taskmgr;
|
|
||||||
extern isc_timermgr_t *timermgr;
|
|
||||||
extern isc_nm_t *netmgr;
|
|
||||||
extern int ncpus;
|
|
||||||
|
|
||||||
isc_result_t
|
|
||||||
isc_test_begin(FILE *logfile, bool 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);
|
|
||||||
|
|
||||||
void
|
|
||||||
isc_test_nap(uint32_t usec);
|
|
@@ -33,7 +33,3 @@ libisccfg_la_LIBADD = \
|
|||||||
libisccfg_la_LDFLAGS = \
|
libisccfg_la_LDFLAGS = \
|
||||||
$(AM_LDFLAGS) \
|
$(AM_LDFLAGS) \
|
||||||
-release "$(PACKAGE_VERSION)"
|
-release "$(PACKAGE_VERSION)"
|
||||||
|
|
||||||
if HAVE_CMOCKA
|
|
||||||
SUBDIRS = tests
|
|
||||||
endif
|
|
||||||
|
1
lib/isccfg/tests
Symbolic link
1
lib/isccfg/tests
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../tests/isccfg
|
@@ -55,7 +55,3 @@ libns_la_LIBADD = \
|
|||||||
libns_la_LDFLAGS = \
|
libns_la_LDFLAGS = \
|
||||||
$(AM_LDFLAGS) \
|
$(AM_LDFLAGS) \
|
||||||
-release "$(PACKAGE_VERSION)"
|
-release "$(PACKAGE_VERSION)"
|
||||||
|
|
||||||
if HAVE_CMOCKA
|
|
||||||
SUBDIRS = tests
|
|
||||||
endif
|
|
||||||
|
1
lib/ns/tests
Symbolic link
1
lib/ns/tests
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../tests/ns
|
1
tests/.gitignore
vendored
Normal file
1
tests/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/unit-test-driver.sh
|
16
tests/Makefile.am
Normal file
16
tests/Makefile.am
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
include $(top_srcdir)/Makefile.top
|
||||||
|
|
||||||
|
AM_CPPFLAGS += \
|
||||||
|
$(LIBISC_CFLAGS) \
|
||||||
|
$(LIBDNS_CFLAGS) \
|
||||||
|
$(LIBNS_CFLAGS) \
|
||||||
|
$(LIBUV_CFLAGS) \
|
||||||
|
-I$(top_srcdir)/lib/isc
|
||||||
|
|
||||||
|
LDADD += \
|
||||||
|
$(LIBISC_LIBS) \
|
||||||
|
$(LIBDNS_LIBS) \
|
||||||
|
$(LIBNS_LIBS)
|
||||||
|
|
||||||
|
SUBDIRS = libtest isc dns ns isccfg irs
|
||||||
|
check_PROGRAMS =
|
@@ -6,17 +6,15 @@ AM_CPPFLAGS += \
|
|||||||
$(LIBUV_CFLAGS) \
|
$(LIBUV_CFLAGS) \
|
||||||
$(KRB5_CFLAGS) \
|
$(KRB5_CFLAGS) \
|
||||||
-DSRCDIR=\"$(abs_srcdir)\" \
|
-DSRCDIR=\"$(abs_srcdir)\" \
|
||||||
-DBUILDDIR=\"$(abs_builddir)\"
|
-DBUILDDIR=\"$(abs_builddir)\" \
|
||||||
|
-I$(top_srcdir)/lib/isc \
|
||||||
|
-I$(top_srcdir)/lib/dns
|
||||||
|
|
||||||
LDADD += \
|
LDADD += \
|
||||||
libdnstest.la \
|
|
||||||
$(LIBISC_LIBS) \
|
$(LIBISC_LIBS) \
|
||||||
$(LIBUV_LIBS) \
|
$(LIBUV_LIBS) \
|
||||||
$(LIBDNS_LIBS)
|
$(LIBDNS_LIBS)
|
||||||
|
|
||||||
check_LTLIBRARIES = libdnstest.la
|
|
||||||
libdnstest_la_SOURCES = dnstest.c dnstest.h
|
|
||||||
|
|
||||||
check_PROGRAMS = \
|
check_PROGRAMS = \
|
||||||
acl_test \
|
acl_test \
|
||||||
db_test \
|
db_test \
|
||||||
@@ -75,7 +73,8 @@ check_PROGRAMS += \
|
|||||||
|
|
||||||
geoip_test_CPPFLAGS = \
|
geoip_test_CPPFLAGS = \
|
||||||
$(AM_CPPFLAGS) \
|
$(AM_CPPFLAGS) \
|
||||||
$(MAXMINDDB_CFLAGS)
|
$(MAXMINDDB_CFLAGS) \
|
||||||
|
-DTEST_GEOIP_DATA=\"$(top_srcdir)/bin/tests/system/geoip2/data\"
|
||||||
|
|
||||||
geoip_test_LDADD = \
|
geoip_test_LDADD = \
|
||||||
$(LDADD) \
|
$(LDADD) \
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -31,36 +29,14 @@
|
|||||||
|
|
||||||
#include <dns/acl.h>
|
#include <dns/acl.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BUFLEN 255
|
#define BUFLEN 255
|
||||||
#define BIGBUFLEN (70 * 1024)
|
#define BIGBUFLEN (70 * 1024)
|
||||||
#define TEST_ORIGIN "test"
|
#define TEST_ORIGIN "test"
|
||||||
|
|
||||||
/* test that dns_acl_isinsecure works */
|
/* test that dns_acl_isinsecure works */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_acl_isinsecure) {
|
||||||
dns_acl_isinsecure_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_acl_t *any = NULL;
|
dns_acl_t *any = NULL;
|
||||||
dns_acl_t *none = NULL;
|
dns_acl_t *none = NULL;
|
||||||
@@ -74,16 +50,16 @@ dns_acl_isinsecure_test(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_acl_any(dt_mctx, &any);
|
result = dns_acl_any(mctx, &any);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_acl_none(dt_mctx, &none);
|
result = dns_acl_none(mctx, &none);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_acl_create(dt_mctx, 1, ¬none);
|
result = dns_acl_create(mctx, 1, ¬none);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_acl_create(dt_mctx, 1, ¬any);
|
result = dns_acl_create(mctx, 1, ¬any);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_acl_merge(notnone, none, false);
|
result = dns_acl_merge(notnone, none, false);
|
||||||
@@ -93,7 +69,7 @@ dns_acl_isinsecure_test(void **state) {
|
|||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
#if defined(HAVE_GEOIP2)
|
#if defined(HAVE_GEOIP2)
|
||||||
result = dns_acl_create(dt_mctx, 1, &geoip);
|
result = dns_acl_create(mctx, 1, &geoip);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
de = geoip->elements;
|
de = geoip->elements;
|
||||||
@@ -108,7 +84,7 @@ dns_acl_isinsecure_test(void **state) {
|
|||||||
de->node_num = dns_acl_node_count(geoip);
|
de->node_num = dns_acl_node_count(geoip);
|
||||||
geoip->length++;
|
geoip->length++;
|
||||||
|
|
||||||
result = dns_acl_create(dt_mctx, 1, ¬geoip);
|
result = dns_acl_create(mctx, 1, ¬geoip);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_acl_merge(notgeoip, geoip, false);
|
result = dns_acl_merge(notgeoip, geoip, false);
|
||||||
@@ -135,24 +111,8 @@ dns_acl_isinsecure_test(void **state) {
|
|||||||
#endif /* HAVE_GEOIP2 */
|
#endif /* HAVE_GEOIP2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(dns_acl_isinsecure)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(dns_acl_isinsecure_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -29,28 +27,7 @@
|
|||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
#include <dns/rdatalist.h>
|
#include <dns/rdatalist.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BUFLEN 255
|
#define BUFLEN 255
|
||||||
#define BIGBUFLEN (64 * 1024)
|
#define BIGBUFLEN (64 * 1024)
|
||||||
@@ -61,17 +38,13 @@ _teardown(void **state) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* test multiple calls to dns_db_getoriginnode */
|
/* test multiple calls to dns_db_getoriginnode */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(getoriginnode) {
|
||||||
getoriginnode_test(void **state) {
|
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
isc_mem_t *mctx = NULL;
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
|
||||||
|
|
||||||
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -85,21 +58,16 @@ getoriginnode_test(void **state) {
|
|||||||
dns_db_detachnode(db, &node);
|
dns_db_detachnode(db, &node);
|
||||||
|
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
isc_mem_detach(&mctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test getservestalettl and setservestalettl */
|
/* test getservestalettl and setservestalettl */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(getsetservestalettl) {
|
||||||
getsetservestalettl_test(void **state) {
|
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
isc_mem_t *mctx = NULL;
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_ttl_t ttl;
|
dns_ttl_t ttl;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
|
||||||
|
|
||||||
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache,
|
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -119,12 +87,10 @@ getsetservestalettl_test(void **state) {
|
|||||||
assert_int_equal(ttl, 6 * 3600);
|
assert_int_equal(ttl, 6 * 3600);
|
||||||
|
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
isc_mem_detach(&mctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check DNS_DBFIND_STALEOK works */
|
/* check DNS_DBFIND_STALEOK works */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_dbfind_staleok) {
|
||||||
dns_dbfind_staleok_test(void **state) {
|
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
dns_fixedname_t example_fixed;
|
dns_fixedname_t example_fixed;
|
||||||
@@ -135,14 +101,11 @@ dns_dbfind_staleok_test(void **state) {
|
|||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
int count;
|
int count;
|
||||||
int pass;
|
int pass;
|
||||||
isc_mem_t *mctx = NULL;
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
unsigned char data[] = { 0x0a, 0x00, 0x00, 0x01 };
|
unsigned char data[] = { 0x0a, 0x00, 0x00, 0x01 };
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
|
||||||
|
|
||||||
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache,
|
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -277,18 +240,16 @@ dns_dbfind_staleok_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
isc_mem_detach(&mctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* database class */
|
/* database class */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(class) {
|
||||||
class_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_db_create(dt_mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -302,15 +263,14 @@ class_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* database type */
|
/* database type */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dbtype) {
|
||||||
dbtype_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
/* DB has zone semantics */
|
/* DB has zone semantics */
|
||||||
result = dns_db_create(dt_mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text,
|
result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text,
|
||||||
@@ -321,7 +281,7 @@ dbtype_test(void **state) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
|
|
||||||
/* DB has cache semantics */
|
/* DB has cache semantics */
|
||||||
result = dns_db_create(dt_mctx, "rbt", dns_rootname, dns_dbtype_cache,
|
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text,
|
result = dns_db_load(db, "testdata/db/data.db", dns_masterformat_text,
|
||||||
@@ -333,8 +293,7 @@ dbtype_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* database versions */
|
/* database versions */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(version) {
|
||||||
version_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_fixedname_t fname, ffound;
|
dns_fixedname_t fname, ffound;
|
||||||
dns_name_t *name, *foundname;
|
dns_name_t *name, *foundname;
|
||||||
@@ -400,29 +359,13 @@ version_test(void **state) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(getoriginnode)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(getsetservestalettl)
|
||||||
cmocka_unit_test(getoriginnode_test),
|
ISC_TEST_ENTRY(dns_dbfind_staleok)
|
||||||
cmocka_unit_test(getsetservestalettl_test),
|
ISC_TEST_ENTRY(class)
|
||||||
cmocka_unit_test(dns_dbfind_staleok_test),
|
ISC_TEST_ENTRY(dbtype)
|
||||||
cmocka_unit_test_setup_teardown(class_test, _setup, _teardown),
|
ISC_TEST_ENTRY(version)
|
||||||
cmocka_unit_test_setup_teardown(dbtype_test, _setup, _teardown),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(version_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -31,33 +29,12 @@
|
|||||||
#include <dns/journal.h>
|
#include <dns/journal.h>
|
||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
#define BUFLEN 255
|
#define BUFLEN 255
|
||||||
#define BIGBUFLEN (64 * 1024)
|
#define BIGBUFLEN (64 * 1024)
|
||||||
#define TEST_ORIGIN "test"
|
#define TEST_ORIGIN "test"
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_create(const char *oldfile, dns_db_t **old, const char *newfile,
|
test_create(const char *oldfile, dns_db_t **old, const char *newfile,
|
||||||
dns_db_t **newdb) {
|
dns_db_t **newdb) {
|
||||||
@@ -71,8 +48,7 @@ test_create(const char *oldfile, dns_db_t **old, const char *newfile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_db_diffx of identical content */
|
/* dns_db_diffx of identical content */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(diffx_same) {
|
||||||
diffx_same(void **state) {
|
|
||||||
dns_db_t *newdb = NULL, *olddb = NULL;
|
dns_db_t *newdb = NULL, *olddb = NULL;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_diff_t diff;
|
dns_diff_t diff;
|
||||||
@@ -82,7 +58,7 @@ diffx_same(void **state) {
|
|||||||
test_create("testdata/diff/zone1.data", &olddb,
|
test_create("testdata/diff/zone1.data", &olddb,
|
||||||
"testdata/diff/zone1.data", &newdb);
|
"testdata/diff/zone1.data", &newdb);
|
||||||
|
|
||||||
dns_diff_init(dt_mctx, &diff);
|
dns_diff_init(mctx, &diff);
|
||||||
|
|
||||||
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -95,8 +71,7 @@ diffx_same(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_db_diffx of zone with record added */
|
/* dns_db_diffx of zone with record added */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(diffx_add) {
|
||||||
diffx_add(void **state) {
|
|
||||||
dns_db_t *newdb = NULL, *olddb = NULL;
|
dns_db_t *newdb = NULL, *olddb = NULL;
|
||||||
dns_difftuple_t *tuple;
|
dns_difftuple_t *tuple;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@@ -108,7 +83,7 @@ diffx_add(void **state) {
|
|||||||
test_create("testdata/diff/zone1.data", &olddb,
|
test_create("testdata/diff/zone1.data", &olddb,
|
||||||
"testdata/diff/zone2.data", &newdb);
|
"testdata/diff/zone2.data", &newdb);
|
||||||
|
|
||||||
dns_diff_init(dt_mctx, &diff);
|
dns_diff_init(mctx, &diff);
|
||||||
|
|
||||||
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -128,8 +103,7 @@ diffx_add(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_db_diffx of zone with record removed */
|
/* dns_db_diffx of zone with record removed */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(diffx_remove) {
|
||||||
diffx_remove(void **state) {
|
|
||||||
dns_db_t *newdb = NULL, *olddb = NULL;
|
dns_db_t *newdb = NULL, *olddb = NULL;
|
||||||
dns_difftuple_t *tuple;
|
dns_difftuple_t *tuple;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@@ -141,7 +115,7 @@ diffx_remove(void **state) {
|
|||||||
test_create("testdata/diff/zone1.data", &olddb,
|
test_create("testdata/diff/zone1.data", &olddb,
|
||||||
"testdata/diff/zone3.data", &newdb);
|
"testdata/diff/zone3.data", &newdb);
|
||||||
|
|
||||||
dns_diff_init(dt_mctx, &diff);
|
dns_diff_init(mctx, &diff);
|
||||||
|
|
||||||
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -160,26 +134,10 @@ diffx_remove(void **state) {
|
|||||||
dns_db_detach(&olddb);
|
dns_db_detach(&olddb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(diffx_same)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(diffx_add)
|
||||||
cmocka_unit_test_setup_teardown(diffx_same, _setup, _teardown),
|
ISC_TEST_ENTRY(diffx_remove)
|
||||||
cmocka_unit_test_setup_teardown(diffx_add, _setup, _teardown),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(diffx_remove, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -30,33 +28,12 @@
|
|||||||
#include <dns/dbiterator.h>
|
#include <dns/dbiterator.h>
|
||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
#define BUFLEN 255
|
#define BUFLEN 255
|
||||||
#define BIGBUFLEN (64 * 1024)
|
#define BIGBUFLEN (64 * 1024)
|
||||||
#define TEST_ORIGIN "test"
|
#define TEST_ORIGIN "test"
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
make_name(const char *src, dns_name_t *name) {
|
make_name(const char *src, dns_name_t *name) {
|
||||||
isc_buffer_t b;
|
isc_buffer_t b;
|
||||||
@@ -82,15 +59,13 @@ test_create(const char *filename) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(create) {
|
||||||
create(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_create("testdata/dbiterator/zone1.data");
|
test_create("testdata/dbiterator/zone1.data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(create_nsec3) {
|
||||||
create_nsec3(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_create("testdata/dbiterator/zone2.data");
|
test_create("testdata/dbiterator/zone2.data");
|
||||||
@@ -133,15 +108,13 @@ test_walk(const char *filename, int nodes) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(walk) {
|
||||||
walk(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_walk("testdata/dbiterator/zone1.data", 12);
|
test_walk("testdata/dbiterator/zone1.data", 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(walk_nsec3) {
|
||||||
walk_nsec3(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_walk("testdata/dbiterator/zone2.data", 33);
|
test_walk("testdata/dbiterator/zone2.data", 33);
|
||||||
@@ -184,15 +157,13 @@ test_reverse(const char *filename) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(reverse) {
|
||||||
reverse(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_reverse("testdata/dbiterator/zone1.data");
|
test_reverse("testdata/dbiterator/zone1.data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(reverse_nsec3) {
|
||||||
reverse_nsec3(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_reverse("testdata/dbiterator/zone2.data");
|
test_reverse("testdata/dbiterator/zone2.data");
|
||||||
@@ -241,15 +212,13 @@ test_seek_node(const char *filename, int nodes) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(seek_node) {
|
||||||
seek_node(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_seek_node("testdata/dbiterator/zone1.data", 9);
|
test_seek_node("testdata/dbiterator/zone1.data", 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(seek_node_nsec3) {
|
||||||
seek_node_nsec3(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_seek_node("testdata/dbiterator/zone2.data", 30);
|
test_seek_node("testdata/dbiterator/zone2.data", 30);
|
||||||
@@ -285,15 +254,13 @@ test_seek_empty(const char *filename) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(seek_empty) {
|
||||||
seek_empty(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_seek_empty("testdata/dbiterator/zone1.data");
|
test_seek_empty("testdata/dbiterator/zone1.data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(seek_empty_nsec3) {
|
||||||
seek_empty_nsec3(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_seek_empty("testdata/dbiterator/zone2.data");
|
test_seek_empty("testdata/dbiterator/zone2.data");
|
||||||
@@ -334,15 +301,13 @@ test_seek_nx(const char *filename) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(seek_nx) {
|
||||||
seek_nx(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_seek_nx("testdata/dbiterator/zone1.data");
|
test_seek_nx("testdata/dbiterator/zone1.data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(seek_nx_nsec3) {
|
||||||
seek_nx_nsec3(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
test_seek_nx("testdata/dbiterator/zone2.data");
|
test_seek_nx("testdata/dbiterator/zone2.data");
|
||||||
@@ -356,39 +321,19 @@ seek_nx_nsec3(void **state) {
|
|||||||
* dns_dbiterator_origin
|
* dns_dbiterator_origin
|
||||||
* dns_dbiterator_setcleanmode
|
* dns_dbiterator_setcleanmode
|
||||||
*/
|
*/
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(create)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(create_nsec3)
|
||||||
cmocka_unit_test_setup_teardown(create, _setup, _teardown),
|
ISC_TEST_ENTRY(walk)
|
||||||
cmocka_unit_test_setup_teardown(create_nsec3, _setup,
|
ISC_TEST_ENTRY(walk_nsec3)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(reverse)
|
||||||
cmocka_unit_test_setup_teardown(walk, _setup, _teardown),
|
ISC_TEST_ENTRY(reverse_nsec3)
|
||||||
cmocka_unit_test_setup_teardown(walk_nsec3, _setup, _teardown),
|
ISC_TEST_ENTRY(seek_node)
|
||||||
cmocka_unit_test_setup_teardown(reverse, _setup, _teardown),
|
ISC_TEST_ENTRY(seek_node_nsec3)
|
||||||
cmocka_unit_test_setup_teardown(reverse_nsec3, _setup,
|
ISC_TEST_ENTRY(seek_empty)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(seek_empty_nsec3)
|
||||||
cmocka_unit_test_setup_teardown(seek_node, _setup, _teardown),
|
ISC_TEST_ENTRY(seek_nx)
|
||||||
cmocka_unit_test_setup_teardown(seek_node_nsec3, _setup,
|
ISC_TEST_ENTRY(seek_nx_nsec3)
|
||||||
_teardown),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(seek_empty, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(seek_empty_nsec3, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(seek_nx, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(seek_nx_nsec3, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -37,7 +35,7 @@
|
|||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
#include <dns/rdatasetiter.h>
|
#include <dns/rdatasetiter.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static char tempname[11] = "dtXXXXXXXX";
|
static char tempname[11] = "dtXXXXXXXX";
|
||||||
static dns_db_t *db1 = NULL, *db2 = NULL;
|
static dns_db_t *db1 = NULL, *db2 = NULL;
|
||||||
@@ -72,23 +70,20 @@ local_callback(const char *file, int line, isc_assertiontype_t type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
setup_test(void **state) {
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_assertion_setcallback(local_callback);
|
isc_assertion_setcallback(local_callback);
|
||||||
|
|
||||||
res = dns_test_begin(NULL, false);
|
res = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||||
assert_int_equal(res, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
res = dns_db_create(dt_mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
|
||||||
dns_rdataclass_in, 0, NULL, &db1);
|
dns_rdataclass_in, 0, NULL, &db1);
|
||||||
assert_int_equal(res, ISC_R_SUCCESS);
|
assert_int_equal(res, ISC_R_SUCCESS);
|
||||||
dns_db_newversion(db1, &v1);
|
dns_db_newversion(db1, &v1);
|
||||||
assert_non_null(v1);
|
assert_non_null(v1);
|
||||||
|
|
||||||
res = dns_db_create(dt_mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
res = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||||
dns_rdataclass_in, 0, NULL, &db2);
|
dns_rdataclass_in, 0, NULL, &db2);
|
||||||
assert_int_equal(res, ISC_R_SUCCESS);
|
assert_int_equal(res, ISC_R_SUCCESS);
|
||||||
dns_db_newversion(db2, &v2);
|
dns_db_newversion(db2, &v2);
|
||||||
@@ -98,7 +93,7 @@ _setup(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
teardown_test(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
if (strcmp(tempname, "dtXXXXXXXX") != 0) {
|
if (strcmp(tempname, "dtXXXXXXXX") != 0) {
|
||||||
@@ -123,8 +118,6 @@ _teardown(void **state) {
|
|||||||
assert_null(db2);
|
assert_null(db2);
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,8 +125,7 @@ _teardown(void **state) {
|
|||||||
* Check dns_db_attachversion() passes with matching db and version, and
|
* Check dns_db_attachversion() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(attachversion) {
|
||||||
attachversion(void **state) {
|
|
||||||
dns_dbversion_t *v = NULL;
|
dns_dbversion_t *v = NULL;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -150,8 +142,7 @@ attachversion(void **state) {
|
|||||||
* Check dns_db_closeversion() passes with matching db and version, and
|
* Check dns_db_closeversion() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(closeversion) {
|
||||||
closeversion(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
assert_non_null(v1);
|
assert_non_null(v1);
|
||||||
@@ -165,8 +156,7 @@ closeversion(void **state) {
|
|||||||
* Check dns_db_find() passes with matching db and version, and
|
* Check dns_db_find() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(find) {
|
||||||
find(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
dns_fixedname_t fixed;
|
dns_fixedname_t fixed;
|
||||||
@@ -195,8 +185,7 @@ find(void **state) {
|
|||||||
* Check dns_db_allrdatasets() passes with matching db and version, and
|
* Check dns_db_allrdatasets() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(allrdatasets) {
|
||||||
allrdatasets(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
dns_rdatasetiter_t *iterator = NULL;
|
dns_rdatasetiter_t *iterator = NULL;
|
||||||
@@ -222,8 +211,7 @@ allrdatasets(void **state) {
|
|||||||
* Check dns_db_findrdataset() passes with matching db and version, and
|
* Check dns_db_findrdataset() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(findrdataset) {
|
||||||
findrdataset(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
@@ -254,8 +242,7 @@ findrdataset(void **state) {
|
|||||||
* Check dns_db_deleterdataset() passes with matching db and version, and
|
* Check dns_db_deleterdataset() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(deleterdataset) {
|
||||||
deleterdataset(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
|
|
||||||
@@ -277,8 +264,7 @@ deleterdataset(void **state) {
|
|||||||
* Check dns_db_subtractrdataset() passes with matching db and version, and
|
* Check dns_db_subtractrdataset() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(subtract) {
|
||||||
subtract(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
dns_rdatalist_t rdatalist;
|
dns_rdatalist_t rdatalist;
|
||||||
@@ -319,8 +305,7 @@ subtract(void **state) {
|
|||||||
* Check dns_db_dump() passes with matching db and version, and
|
* Check dns_db_dump() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dump) {
|
||||||
dump(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
|
||||||
@@ -340,8 +325,7 @@ dump(void **state) {
|
|||||||
* Check dns_db_addrdataset() passes with matching db and version, and
|
* Check dns_db_addrdataset() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(addrdataset) {
|
||||||
addrdataset(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
@@ -374,8 +358,7 @@ addrdataset(void **state) {
|
|||||||
* Check dns_db_getnsec3parameters() passes with matching db and version,
|
* Check dns_db_getnsec3parameters() passes with matching db and version,
|
||||||
* and asserts with mis-matching db and version.
|
* and asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(getnsec3parameters) {
|
||||||
getnsec3parameters(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_hash_t hash;
|
dns_hash_t hash;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
@@ -397,8 +380,7 @@ getnsec3parameters(void **state) {
|
|||||||
* Check dns_db_resigned() passes with matching db and version, and
|
* Check dns_db_resigned() passes with matching db and version, and
|
||||||
* asserts with mis-matching db and version.
|
* asserts with mis-matching db and version.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(resigned) {
|
||||||
resigned(void **state) {
|
|
||||||
isc_result_t res;
|
isc_result_t res;
|
||||||
dns_rdataset_t rdataset, added;
|
dns_rdataset_t rdataset, added;
|
||||||
dns_dbnode_t *node = NULL;
|
dns_dbnode_t *node = NULL;
|
||||||
@@ -461,39 +443,18 @@ resigned(void **state) {
|
|||||||
dns_rdataset_disassociate(&added);
|
dns_rdataset_disassociate(&added);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(dump, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY_CUSTOM(find, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(dump, _setup, _teardown),
|
ISC_TEST_ENTRY_CUSTOM(allrdatasets, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(find, _setup, _teardown),
|
ISC_TEST_ENTRY_CUSTOM(findrdataset, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(allrdatasets, _setup,
|
ISC_TEST_ENTRY_CUSTOM(deleterdataset, setup_test, teardown_test)
|
||||||
_teardown),
|
ISC_TEST_ENTRY_CUSTOM(subtract, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(findrdataset, _setup,
|
ISC_TEST_ENTRY_CUSTOM(addrdataset, setup_test, teardown_test)
|
||||||
_teardown),
|
ISC_TEST_ENTRY_CUSTOM(getnsec3parameters, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(deleterdataset, _setup,
|
ISC_TEST_ENTRY_CUSTOM(resigned, setup_test, teardown_test)
|
||||||
_teardown),
|
ISC_TEST_ENTRY_CUSTOM(attachversion, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(subtract, _setup, _teardown),
|
ISC_TEST_ENTRY_CUSTOM(closeversion, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(addrdataset, _setup, _teardown),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(getnsec3parameters, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(resigned, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(attachversion, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(closeversion, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -30,33 +28,36 @@
|
|||||||
|
|
||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
|
|
||||||
#include "../dst_internal.h"
|
#include "dst_internal.h"
|
||||||
#include "dnstest.h"
|
|
||||||
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
setup_test(void **state) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
result = dst_lib_init(mctx, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
teardown_test(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
dns_test_end();
|
dst_lib_destroy();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OpenSSL DH_compute_key() failure */
|
/* OpenSSL DH_compute_key() failure */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dh_computesecret) {
|
||||||
dh_computesecret(void **state) {
|
|
||||||
dst_key_t *key = NULL;
|
dst_key_t *key = NULL;
|
||||||
isc_buffer_t buf;
|
isc_buffer_t buf;
|
||||||
unsigned char array[1024];
|
unsigned char array[1024];
|
||||||
@@ -73,7 +74,7 @@ dh_computesecret(void **state) {
|
|||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dst_key_fromfile(name, 18602, DST_ALG_DH,
|
result = dst_key_fromfile(name, 18602, DST_ALG_DH,
|
||||||
DST_TYPE_PUBLIC | DST_TYPE_KEY, "./", dt_mctx,
|
DST_TYPE_PUBLIC | DST_TYPE_KEY, "./", mctx,
|
||||||
&key);
|
&key);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -86,24 +87,8 @@ dh_computesecret(void **state) {
|
|||||||
dst_key_free(&key);
|
dst_key_free(&key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(dh_computesecret, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(dh_computesecret, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -37,7 +35,7 @@
|
|||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
#include <dns/view.h>
|
#include <dns/view.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
uv_sem_t sem;
|
uv_sem_t sem;
|
||||||
|
|
||||||
@@ -114,15 +112,9 @@ reset_testdata(void);
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
_setup(void **state) {
|
||||||
isc_result_t result;
|
|
||||||
uv_os_sock_t sock = -1;
|
uv_os_sock_t sock = -1;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, true);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
||||||
isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
|
isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
|
||||||
|
|
||||||
@@ -143,8 +135,10 @@ _setup(void **state) {
|
|||||||
}
|
}
|
||||||
close(sock);
|
close(sock);
|
||||||
|
|
||||||
|
setup_managers(state);
|
||||||
|
|
||||||
/* Create a secondary network manager */
|
/* Create a secondary network manager */
|
||||||
isc_managers_create(dt_mctx, ncpus, 0, &connect_nm, NULL, NULL);
|
isc_managers_create(mctx, workers, 0, &connect_nm, NULL, NULL);
|
||||||
|
|
||||||
isc_nm_settimeouts(netmgr, T_SERVER_INIT, T_SERVER_IDLE,
|
isc_nm_settimeouts(netmgr, T_SERVER_INIT, T_SERVER_IDLE,
|
||||||
T_SERVER_KEEPALIVE, T_SERVER_ADVERTISED);
|
T_SERVER_KEEPALIVE, T_SERVER_ADVERTISED);
|
||||||
@@ -166,14 +160,12 @@ _setup(void **state) {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
_teardown(void **state) {
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
uv_sem_destroy(&sem);
|
uv_sem_destroy(&sem);
|
||||||
|
|
||||||
isc_managers_destroy(&connect_nm, NULL, NULL);
|
isc_managers_destroy(&connect_nm, NULL, NULL);
|
||||||
assert_null(connect_nm);
|
assert_null(connect_nm);
|
||||||
|
|
||||||
dns_test_end();
|
teardown_managers(state);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -184,7 +176,7 @@ make_dispatchset(unsigned int ndisps) {
|
|||||||
isc_sockaddr_t any;
|
isc_sockaddr_t any;
|
||||||
dns_dispatch_t *disp = NULL;
|
dns_dispatch_t *disp = NULL;
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, netmgr, &dispatchmgr);
|
result = dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@@ -195,7 +187,7 @@ make_dispatchset(unsigned int ndisps) {
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_dispatchset_create(dt_mctx, disp, &dset, ndisps);
|
result = dns_dispatchset_create(mctx, disp, &dset, ndisps);
|
||||||
dns_dispatch_detach(&disp);
|
dns_dispatch_detach(&disp);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
@@ -212,8 +204,7 @@ reset(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create dispatch set */
|
/* create dispatch set */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatchset_create) {
|
||||||
dispatchset_create(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -228,8 +219,7 @@ dispatchset_create(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* test dispatch set round-robin */
|
/* test dispatch set round-robin */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatchset_get) {
|
||||||
dispatchset_get(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_dispatch_t *d1, *d2, *d3, *d4, *d5;
|
dns_dispatch_t *d1, *d2, *d3, *d4, *d5;
|
||||||
|
|
||||||
@@ -290,9 +280,6 @@ server_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
|
|||||||
UNUSED(eresult);
|
UNUSED(eresult);
|
||||||
UNUSED(cbarg);
|
UNUSED(cbarg);
|
||||||
|
|
||||||
fprintf(stderr, "%s(..., %s, ...)\n", __func__,
|
|
||||||
isc_result_totext(eresult));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,9 +353,6 @@ response(isc_result_t eresult, isc_region_t *region, void *arg) {
|
|||||||
UNUSED(region);
|
UNUSED(region);
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
|
|
||||||
fprintf(stderr, "%s(..., %s, ...)\n", __func__,
|
|
||||||
isc_result_totext(eresult));
|
|
||||||
|
|
||||||
switch (eresult) {
|
switch (eresult) {
|
||||||
case ISC_R_EOF:
|
case ISC_R_EOF:
|
||||||
case ISC_R_CANCELED:
|
case ISC_R_CANCELED:
|
||||||
@@ -387,9 +371,6 @@ response_timeout(isc_result_t eresult, isc_region_t *region, void *arg) {
|
|||||||
UNUSED(region);
|
UNUSED(region);
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
|
|
||||||
fprintf(stderr, "%s(..., %s, ...)\n", __func__,
|
|
||||||
isc_result_totext(eresult));
|
|
||||||
|
|
||||||
atomic_store_relaxed(&testdata.result, eresult);
|
atomic_store_relaxed(&testdata.result, eresult);
|
||||||
|
|
||||||
uv_sem_post(&sem);
|
uv_sem_post(&sem);
|
||||||
@@ -402,9 +383,6 @@ connected(isc_result_t eresult, isc_region_t *region, void *cbarg) {
|
|||||||
UNUSED(eresult);
|
UNUSED(eresult);
|
||||||
UNUSED(region);
|
UNUSED(region);
|
||||||
|
|
||||||
fprintf(stderr, "%s(..., %s, ...)\n", __func__,
|
|
||||||
isc_result_totext(eresult));
|
|
||||||
|
|
||||||
dns_dispatch_send(dispentry, r, -1);
|
dns_dispatch_send(dispentry, r, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,9 +392,6 @@ client_senddone(isc_result_t eresult, isc_region_t *region, void *cbarg) {
|
|||||||
UNUSED(region);
|
UNUSED(region);
|
||||||
UNUSED(cbarg);
|
UNUSED(cbarg);
|
||||||
|
|
||||||
fprintf(stderr, "%s(..., %s, ...)\n", __func__,
|
|
||||||
isc_result_totext(eresult));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,16 +400,12 @@ timeout_connected(isc_result_t eresult, isc_region_t *region, void *cbarg) {
|
|||||||
UNUSED(region);
|
UNUSED(region);
|
||||||
UNUSED(cbarg);
|
UNUSED(cbarg);
|
||||||
|
|
||||||
fprintf(stderr, "%s(..., %s, ...)\n", __func__,
|
|
||||||
isc_result_totext(eresult));
|
|
||||||
|
|
||||||
atomic_store_relaxed(&testdata.result, eresult);
|
atomic_store_relaxed(&testdata.result, eresult);
|
||||||
|
|
||||||
uv_sem_post(&sem);
|
uv_sem_post(&sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatch_timeout_tcp_connect) {
|
||||||
dispatch_timeout_tcp_connect(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_region_t region;
|
isc_region_t region;
|
||||||
unsigned char rbuf[12] = { 0 };
|
unsigned char rbuf[12] = { 0 };
|
||||||
@@ -446,7 +417,7 @@ dispatch_timeout_tcp_connect(void **state) {
|
|||||||
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
||||||
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_blackhole, 0);
|
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_blackhole, 0);
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, connect_nm, &dispatchmgr);
|
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_dispatch_createtcp(dispatchmgr, &tcp_connect_addr,
|
result = dns_dispatch_createtcp(dispatchmgr, &tcp_connect_addr,
|
||||||
@@ -489,8 +460,7 @@ dispatch_timeout_tcp_connect(void **state) {
|
|||||||
assert_int_equal(result, ISC_R_TIMEDOUT);
|
assert_int_equal(result, ISC_R_TIMEDOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatch_timeout_tcp_response) {
|
||||||
dispatch_timeout_tcp_response(void **state __attribute__((unused))) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_region_t region;
|
isc_region_t region;
|
||||||
unsigned char rbuf[12] = { 0 };
|
unsigned char rbuf[12] = { 0 };
|
||||||
@@ -503,7 +473,7 @@ dispatch_timeout_tcp_response(void **state __attribute__((unused))) {
|
|||||||
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
||||||
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
|
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, connect_nm, &dispatchmgr);
|
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_dispatch_createtcp(dispatchmgr, &tcp_connect_addr,
|
result = dns_dispatch_createtcp(dispatchmgr, &tcp_connect_addr,
|
||||||
@@ -546,8 +516,7 @@ dispatch_timeout_tcp_response(void **state __attribute__((unused))) {
|
|||||||
dns_dispatchmgr_detach(&dispatchmgr);
|
dns_dispatchmgr_detach(&dispatchmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatch_tcp_response) {
|
||||||
dispatch_tcp_response(void **state __attribute__((unused))) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_region_t region;
|
isc_region_t region;
|
||||||
unsigned char rbuf[12] = { 0 };
|
unsigned char rbuf[12] = { 0 };
|
||||||
@@ -560,7 +529,7 @@ dispatch_tcp_response(void **state __attribute__((unused))) {
|
|||||||
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
||||||
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
|
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, connect_nm, &dispatchmgr);
|
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_dispatch_createtcp(dispatchmgr, &tcp_connect_addr,
|
result = dns_dispatch_createtcp(dispatchmgr, &tcp_connect_addr,
|
||||||
@@ -606,8 +575,7 @@ dispatch_tcp_response(void **state __attribute__((unused))) {
|
|||||||
dns_dispatchmgr_detach(&dispatchmgr);
|
dns_dispatchmgr_detach(&dispatchmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatch_timeout_udp_response) {
|
||||||
dispatch_timeout_udp_response(void **state __attribute__((unused))) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_region_t region;
|
isc_region_t region;
|
||||||
unsigned char rbuf[12] = { 0 };
|
unsigned char rbuf[12] = { 0 };
|
||||||
@@ -620,7 +588,7 @@ dispatch_timeout_udp_response(void **state __attribute__((unused))) {
|
|||||||
udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
||||||
isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
|
isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, connect_nm, &dispatchmgr);
|
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_dispatch_createudp(dispatchmgr, &tcp_connect_addr,
|
result = dns_dispatch_createudp(dispatchmgr, &tcp_connect_addr,
|
||||||
@@ -663,8 +631,7 @@ dispatch_timeout_udp_response(void **state __attribute__((unused))) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* test dispatch getnext */
|
/* test dispatch getnext */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dispatch_getnext) {
|
||||||
dispatch_getnext(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_region_t region;
|
isc_region_t region;
|
||||||
isc_nmsocket_t *sock = NULL;
|
isc_nmsocket_t *sock = NULL;
|
||||||
@@ -674,7 +641,7 @@ dispatch_getnext(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, connect_nm, &dispatchmgr);
|
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_dispatch_createudp(dispatchmgr, &udp_connect_addr,
|
result = dns_dispatch_createudp(dispatchmgr, &udp_connect_addr,
|
||||||
@@ -718,36 +685,16 @@ dispatch_getnext(void **state) {
|
|||||||
dns_dispatchmgr_detach(&dispatchmgr);
|
dns_dispatchmgr_detach(&dispatchmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
|
||||||
const struct CMUnitTest tests[] = {
|
|
||||||
cmocka_unit_test_setup_teardown(dispatch_timeout_tcp_connect,
|
|
||||||
_setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dispatch_timeout_tcp_response,
|
|
||||||
_setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dispatch_tcp_response, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dispatch_timeout_udp_response,
|
|
||||||
_setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dispatchset_create, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dispatchset_get, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dispatch_getnext, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_ENTRY_CUSTOM(dispatch_timeout_tcp_connect, _setup, _teardown)
|
||||||
}
|
ISC_TEST_ENTRY_CUSTOM(dispatch_timeout_tcp_response, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dispatch_tcp_response, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dispatch_timeout_udp_response, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dispatchset_create, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dispatchset_get, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dispatch_getnext, _setup, _teardown)
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
ISC_TEST_LIST_END
|
||||||
|
|
||||||
#include <stdio.h>
|
ISC_TEST_MAIN
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -34,6 +32,8 @@
|
|||||||
#include <dns/rdatalist.h>
|
#include <dns/rdatalist.h>
|
||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
|
|
||||||
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
multiple_prefixes(void) {
|
multiple_prefixes(void) {
|
||||||
size_t i, count;
|
size_t i, count;
|
||||||
@@ -121,8 +121,7 @@ multiple_prefixes(void) {
|
|||||||
assert_true(have_p1 != have_p2);
|
assert_true(have_p1 != have_p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns64_findprefix) {
|
||||||
dns64_findprefix(void **state) {
|
|
||||||
unsigned int i, j, o;
|
unsigned int i, j, o;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
struct {
|
struct {
|
||||||
@@ -165,8 +164,6 @@ dns64_findprefix(void **state) {
|
|||||||
ISC_R_NOTFOUND },
|
ISC_R_NOTFOUND },
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tests); i++) {
|
for (i = 0; i < ARRAY_SIZE(tests); i++) {
|
||||||
size_t count = 2;
|
size_t count = 2;
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
@@ -231,22 +228,8 @@ dns64_findprefix(void **state) {
|
|||||||
multiple_prefixes();
|
multiple_prefixes();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(dns64_findprefix)
|
||||||
const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(
|
ISC_TEST_LIST_END
|
||||||
dns64_findprefix, NULL, NULL) };
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -24,6 +22,9 @@
|
|||||||
|
|
||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
|
#include <fstrm.h>
|
||||||
|
|
||||||
|
#include <protobuf-c/protobuf-c.h>
|
||||||
|
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/file.h>
|
#include <isc/file.h>
|
||||||
@@ -35,63 +36,48 @@
|
|||||||
#include <dns/dnstap.h>
|
#include <dns/dnstap.h>
|
||||||
#include <dns/view.h>
|
#include <dns/view.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
#ifdef HAVE_DNSTAP
|
#define TAPFILE TESTS_DIR "/testdata/dnstap/dnstap.file"
|
||||||
|
#define TAPSOCK TESTS_DIR "/testdata/dnstap/dnstap.sock"
|
||||||
|
|
||||||
#include <fstrm.h>
|
#define TAPSAVED TESTS_DIR "/testdata/dnstap/dnstap.saved"
|
||||||
|
#define TAPTEXT TESTS_DIR "/testdata/dnstap/dnstap.text"
|
||||||
#include <protobuf-c/protobuf-c.h>
|
|
||||||
|
|
||||||
#define TAPFILE "testdata/dnstap/dnstap.file"
|
|
||||||
#define TAPSOCK "testdata/dnstap/dnstap.sock"
|
|
||||||
|
|
||||||
#define TAPSAVED "testdata/dnstap/dnstap.saved"
|
|
||||||
#define TAPTEXT "testdata/dnstap/dnstap.text"
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
cleanup(void **state __attribute__((__unused__))) {
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
cleanup(void) {
|
|
||||||
(void)isc_file_remove(TAPFILE);
|
(void)isc_file_remove(TAPFILE);
|
||||||
(void)isc_file_remove(TAPSOCK);
|
(void)isc_file_remove(TAPSOCK);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
setup(void **state) {
|
||||||
|
/*
|
||||||
|
* Make sure files are cleaned up before the test runs.
|
||||||
|
*/
|
||||||
|
cleanup(state);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure text conversions match the time zone in which
|
||||||
|
* the testdata was originally generated.
|
||||||
|
*/
|
||||||
|
setenv("TZ", "PDT8", 1);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up dnstap environment */
|
/* set up dnstap environment */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_dt_create) {
|
||||||
create_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_dtenv_t *dtenv = NULL;
|
dns_dtenv_t *dtenv = NULL;
|
||||||
struct fstrm_iothr_options *fopt;
|
struct fstrm_iothr_options *fopt;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
cleanup();
|
|
||||||
|
|
||||||
fopt = fstrm_iothr_options_init();
|
fopt = fstrm_iothr_options_init();
|
||||||
assert_non_null(fopt);
|
assert_non_null(fopt);
|
||||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||||
|
|
||||||
result = dns_dt_create(dt_mctx, dns_dtmode_file, TAPFILE, &fopt, NULL,
|
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, NULL,
|
||||||
&dtenv);
|
&dtenv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
if (dtenv != NULL) {
|
if (dtenv != NULL) {
|
||||||
@@ -107,7 +93,7 @@ create_test(void **state) {
|
|||||||
assert_non_null(fopt);
|
assert_non_null(fopt);
|
||||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||||
|
|
||||||
result = dns_dt_create(dt_mctx, dns_dtmode_unix, TAPSOCK, &fopt, NULL,
|
result = dns_dt_create(mctx, dns_dtmode_unix, TAPSOCK, &fopt, NULL,
|
||||||
&dtenv);
|
&dtenv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
if (dtenv != NULL) {
|
if (dtenv != NULL) {
|
||||||
@@ -124,7 +110,7 @@ create_test(void **state) {
|
|||||||
assert_non_null(fopt);
|
assert_non_null(fopt);
|
||||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||||
|
|
||||||
result = dns_dt_create(dt_mctx, 33, TAPSOCK, &fopt, NULL, &dtenv);
|
result = dns_dt_create(mctx, 33, TAPSOCK, &fopt, NULL, &dtenv);
|
||||||
assert_int_equal(result, ISC_R_FAILURE);
|
assert_int_equal(result, ISC_R_FAILURE);
|
||||||
assert_null(dtenv);
|
assert_null(dtenv);
|
||||||
if (dtenv != NULL) {
|
if (dtenv != NULL) {
|
||||||
@@ -133,13 +119,10 @@ create_test(void **state) {
|
|||||||
if (fopt != NULL) {
|
if (fopt != NULL) {
|
||||||
fstrm_iothr_options_destroy(&fopt);
|
fstrm_iothr_options_destroy(&fopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send dnstap messages */
|
/* send dnstap messages */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_dt_send) {
|
||||||
send_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_dtenv_t *dtenv = NULL;
|
dns_dtenv_t *dtenv = NULL;
|
||||||
dns_dthandle_t *handle = NULL;
|
dns_dthandle_t *handle = NULL;
|
||||||
@@ -163,18 +146,14 @@ send_test(void **state) {
|
|||||||
isc_time_t p, f;
|
isc_time_t p, f;
|
||||||
struct fstrm_iothr_options *fopt;
|
struct fstrm_iothr_options *fopt;
|
||||||
|
|
||||||
UNUSED(state);
|
result = dns_test_makeview("test", false, &view);
|
||||||
|
|
||||||
cleanup();
|
|
||||||
|
|
||||||
result = dns_test_makeview("test", &view);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
fopt = fstrm_iothr_options_init();
|
fopt = fstrm_iothr_options_init();
|
||||||
assert_non_null(fopt);
|
assert_non_null(fopt);
|
||||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||||
|
|
||||||
result = dns_dt_create(dt_mctx, dns_dtmode_file, TAPFILE, &fopt, NULL,
|
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, NULL,
|
||||||
&dtenv);
|
&dtenv);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -192,7 +171,7 @@ send_test(void **state) {
|
|||||||
|
|
||||||
memset(&zr, 0, sizeof(zr));
|
memset(&zr, 0, sizeof(zr));
|
||||||
isc_buffer_init(&zb, zone, sizeof(zone));
|
isc_buffer_init(&zb, zone, sizeof(zone));
|
||||||
result = dns_compress_init(&cctx, -1, dt_mctx);
|
result = dns_compress_init(&cctx, -1, mctx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
||||||
result = dns_name_towire(zname, &cctx, &zb);
|
result = dns_name_towire(zname, &cctx, &zb);
|
||||||
@@ -266,7 +245,7 @@ send_test(void **state) {
|
|||||||
dns_dt_detach(&dtenv);
|
dns_dt_detach(&dtenv);
|
||||||
dns_view_detach(&view);
|
dns_view_detach(&view);
|
||||||
|
|
||||||
result = dns_dt_open(TAPFILE, dns_dtmode_file, dt_mctx, &handle);
|
result = dns_dt_open(TAPFILE, dns_dtmode_file, mctx, &handle);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
while (dns_dt_getframe(handle, &data, &dsize) == ISC_R_SUCCESS) {
|
while (dns_dt_getframe(handle, &data, &dsize) == ISC_R_SUCCESS) {
|
||||||
@@ -278,7 +257,7 @@ send_test(void **state) {
|
|||||||
r.base = data;
|
r.base = data;
|
||||||
r.length = dsize;
|
r.length = dsize;
|
||||||
|
|
||||||
result = dns_dt_parse(dt_mctx, &r, &dtdata);
|
result = dns_dt_parse(mctx, &r, &dtdata);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
n++;
|
n++;
|
||||||
@@ -299,12 +278,10 @@ send_test(void **state) {
|
|||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
dns_dt_close(&handle);
|
dns_dt_close(&handle);
|
||||||
}
|
}
|
||||||
cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dnstap message to text */
|
/* dnstap message to text */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_dt_totext) {
|
||||||
totext_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_dthandle_t *handle = NULL;
|
dns_dthandle_t *handle = NULL;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
@@ -313,7 +290,7 @@ totext_test(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_dt_open(TAPSAVED, dns_dtmode_file, dt_mctx, &handle);
|
result = dns_dt_open(TAPSAVED, dns_dtmode_file, mctx, &handle);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_stdio_open(TAPTEXT, "r", &fp);
|
result = isc_stdio_open(TAPTEXT, "r", &fp);
|
||||||
@@ -341,13 +318,13 @@ totext_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* parse dnstap frame */
|
/* parse dnstap frame */
|
||||||
result = dns_dt_parse(dt_mctx, &r, &dtdata);
|
result = dns_dt_parse(mctx, &r, &dtdata);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_buffer_allocate(dt_mctx, &b, 2048);
|
isc_buffer_allocate(mctx, &b, 2048);
|
||||||
assert_non_null(b);
|
assert_non_null(b);
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
break;
|
break;
|
||||||
@@ -366,37 +343,14 @@ totext_test(void **state) {
|
|||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
dns_dt_close(&handle);
|
dns_dt_close(&handle);
|
||||||
}
|
}
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
#endif /* HAVE_DNSTAP */
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
#if HAVE_DNSTAP
|
|
||||||
const struct CMUnitTest tests[] = {
|
|
||||||
cmocka_unit_test_setup_teardown(create_test, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(send_test, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(totext_test, _setup, _teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* make sure text conversion gets the right local time */
|
|
||||||
setenv("TZ", "PST8", 1);
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
|
||||||
#else /* if HAVE_DNSTAP */
|
|
||||||
print_message("1..0 # Skipped: dnstap not enabled\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
#endif /* HAVE_DNSTAP */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
ISC_TEST_LIST_START
|
||||||
|
|
||||||
#include <stdio.h>
|
ISC_TEST_ENTRY_CUSTOM(dns_dt_create, setup, cleanup)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_dt_send, setup, cleanup)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_dt_totext, setup, cleanup)
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_END
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAVE_CMOCKA */
|
ISC_TEST_MAIN
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -33,26 +31,24 @@
|
|||||||
|
|
||||||
#include <dst/dst.h>
|
#include <dst/dst.h>
|
||||||
|
|
||||||
#include "../dst_internal.h"
|
#include "dst_internal.h"
|
||||||
#include "dnstest.h"
|
|
||||||
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
setup_test(void **state) {
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
dst_lib_init(mctx, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
teardown_test(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
dns_test_end();
|
dst_lib_destroy();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -73,7 +69,7 @@ sig_fromfile(const char *path, isc_buffer_t *buf) {
|
|||||||
result = isc_file_getsizefd(fileno(fp), &size);
|
result = isc_file_getsizefd(fileno(fp), &size);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
data = isc_mem_get(dt_mctx, (size + 1));
|
data = isc_mem_get(mctx, (size + 1));
|
||||||
assert_non_null(data);
|
assert_non_null(data);
|
||||||
|
|
||||||
len = (size_t)size;
|
len = (size_t)size;
|
||||||
@@ -123,7 +119,7 @@ sig_fromfile(const char *path, isc_buffer_t *buf) {
|
|||||||
result = ISC_R_SUCCESS;
|
result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
isc_mem_put(dt_mctx, data, size + 1);
|
isc_mem_put(mctx, data, size + 1);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +150,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||||||
result = isc_file_getsizefd(fileno(fp), &size);
|
result = isc_file_getsizefd(fileno(fp), &size);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
data = isc_mem_get(dt_mctx, (size + 1));
|
data = isc_mem_get(mctx, (size + 1));
|
||||||
assert_non_null(data);
|
assert_non_null(data);
|
||||||
|
|
||||||
p = data;
|
p = data;
|
||||||
@@ -175,7 +171,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||||||
isc_buffer_add(&b, strlen(keyname));
|
isc_buffer_add(&b, strlen(keyname));
|
||||||
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
|
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
result = dst_key_fromfile(name, id, alg, type, "testdata/dst", dt_mctx,
|
result = dst_key_fromfile(name, id, alg, type, "testdata/dst", mctx,
|
||||||
&key);
|
&key);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -197,8 +193,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||||||
*/
|
*/
|
||||||
isc_buffer_remainingregion(&sigbuf, &sigreg);
|
isc_buffer_remainingregion(&sigbuf, &sigreg);
|
||||||
|
|
||||||
result = dst_context_create(key, dt_mctx, DNS_LOGCATEGORY_GENERAL,
|
result = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL, false,
|
||||||
false, 0, &ctx);
|
0, &ctx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dst_context_adddata(ctx, &datareg);
|
result = dst_context_adddata(ctx, &datareg);
|
||||||
@@ -215,8 +211,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||||||
isc_result_t result2;
|
isc_result_t result2;
|
||||||
|
|
||||||
dst_context_destroy(&ctx);
|
dst_context_destroy(&ctx);
|
||||||
result2 = dst_context_create(
|
result2 = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
key, dt_mctx, DNS_LOGCATEGORY_GENERAL, false, 0, &ctx);
|
false, 0, &ctx);
|
||||||
assert_int_equal(result2, ISC_R_SUCCESS);
|
assert_int_equal(result2, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result2 = dst_context_adddata(ctx, &datareg);
|
result2 = dst_context_adddata(ctx, &datareg);
|
||||||
@@ -241,7 +237,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||||||
fprintf(stderr, "# %s:\n# %s\n", sigpath, hexbuf);
|
fprintf(stderr, "# %s:\n# %s\n", sigpath, hexbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_put(dt_mctx, data, size + 1);
|
isc_mem_put(mctx, data, size + 1);
|
||||||
dst_context_destroy(&ctx);
|
dst_context_destroy(&ctx);
|
||||||
dst_key_free(&key);
|
dst_key_free(&key);
|
||||||
|
|
||||||
@@ -251,10 +247,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(sig_test) {
|
||||||
sig_test(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *datapath;
|
const char *datapath;
|
||||||
const char *sigpath;
|
const char *sigpath;
|
||||||
@@ -310,7 +303,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
|||||||
result = dns_name_fromtext(name1, &b1, dns_rootname, 0, NULL);
|
result = dns_name_fromtext(name1, &b1, dns_rootname, 0, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
result = dst_key_fromfile(name1, key1_id, alg, type, "comparekeys",
|
result = dst_key_fromfile(name1, key1_id, alg, type, "comparekeys",
|
||||||
dt_mctx, &key1);
|
mctx, &key1);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -322,7 +315,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
|||||||
result = dns_name_fromtext(name2, &b2, dns_rootname, 0, NULL);
|
result = dns_name_fromtext(name2, &b2, dns_rootname, 0, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
result = dst_key_fromfile(name2, key2_id, alg, type, "comparekeys",
|
result = dst_key_fromfile(name2, key2_id, alg, type, "comparekeys",
|
||||||
dt_mctx, &key2);
|
mctx, &key2);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -346,10 +339,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(cmp_test) {
|
||||||
cmp_test(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *key1_name;
|
const char *key1_name;
|
||||||
dns_keytag_t key1_id;
|
dns_keytag_t key1_id;
|
||||||
@@ -477,24 +467,9 @@ cmp_test(void **state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(sig_test, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY_CUSTOM(cmp_test, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(sig_test, _setup, _teardown),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(cmp_test, _setup, _teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -34,11 +32,9 @@
|
|||||||
|
|
||||||
#include <dns/geoip.h>
|
#include <dns/geoip.h>
|
||||||
|
|
||||||
#include "../geoip2.c"
|
#include "geoip2.c"
|
||||||
#include "dnstest.h"
|
|
||||||
|
|
||||||
/* Use GeoIP2 databases from the 'geoip2' system test */
|
#include <tests/dns.h>
|
||||||
#define TEST_GEOIP_DATA "../../../bin/tests/system/geoip2/data"
|
|
||||||
|
|
||||||
static dns_geoip_databases_t geoip;
|
static dns_geoip_databases_t geoip;
|
||||||
|
|
||||||
@@ -50,14 +46,9 @@ static void
|
|||||||
close_geoip(void);
|
close_geoip(void);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
setup_test(void **state) {
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/* Use databases from the geoip system test */
|
/* Use databases from the geoip system test */
|
||||||
load_geoip(TEST_GEOIP_DATA);
|
load_geoip(TEST_GEOIP_DATA);
|
||||||
|
|
||||||
@@ -65,13 +56,11 @@ _setup(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
teardown_test(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
close_geoip();
|
close_geoip();
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,8 +124,7 @@ entry_exists(dns_geoip_subtype_t subtype, const char *addr) {
|
|||||||
* present in all databases, 192.0.2.128 should only be present in the country
|
* present in all databases, 192.0.2.128 should only be present in the country
|
||||||
* database, ::1 should be absent from all databases).
|
* database, ::1 should be absent from all databases).
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(baseline) {
|
||||||
baseline(void **state) {
|
|
||||||
dns_geoip_subtype_t subtype;
|
dns_geoip_subtype_t subtype;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -214,8 +202,7 @@ do_lookup_string_v6(const char *addr, dns_geoip_subtype_t subtype,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP country matching */
|
/* GeoIP country matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(country) {
|
||||||
country(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -240,8 +227,7 @@ country(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP country (ipv6) matching */
|
/* GeoIP country (ipv6) matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(country_v6) {
|
||||||
country_v6(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -260,8 +246,7 @@ country_v6(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP city (ipv4) matching */
|
/* GeoIP city (ipv4) matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(city) {
|
||||||
city(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -298,8 +283,7 @@ city(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP city (ipv6) matching */
|
/* GeoIP city (ipv6) matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(city_v6) {
|
||||||
city_v6(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -339,8 +323,7 @@ city_v6(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP asnum matching */
|
/* GeoIP asnum matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(asnum) {
|
||||||
asnum(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -354,8 +337,7 @@ asnum(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP isp matching */
|
/* GeoIP isp matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(isp) {
|
||||||
isp(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -370,8 +352,7 @@ isp(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP org matching */
|
/* GeoIP org matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(org) {
|
||||||
org(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -386,8 +367,7 @@ org(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GeoIP domain matching */
|
/* GeoIP domain matching */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(domain) {
|
||||||
domain(void **state) {
|
|
||||||
bool match;
|
bool match;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -400,27 +380,16 @@ domain(void **state) {
|
|||||||
assert_true(match);
|
assert_true(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(baseline, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY_CUSTOM(country, setup_test, teardown_test)
|
||||||
cmocka_unit_test(baseline), cmocka_unit_test(country),
|
ISC_TEST_ENTRY_CUSTOM(country_v6, setup_test, teardown_test)
|
||||||
cmocka_unit_test(country_v6), cmocka_unit_test(city),
|
ISC_TEST_ENTRY_CUSTOM(city, setup_test, teardown_test)
|
||||||
cmocka_unit_test(city_v6), cmocka_unit_test(asnum),
|
ISC_TEST_ENTRY_CUSTOM(city_v6, setup_test, teardown_test)
|
||||||
cmocka_unit_test(isp), cmocka_unit_test(org),
|
ISC_TEST_ENTRY_CUSTOM(asnum, setup_test, teardown_test)
|
||||||
cmocka_unit_test(domain),
|
ISC_TEST_ENTRY_CUSTOM(isp, setup_test, teardown_test)
|
||||||
};
|
ISC_TEST_ENTRY_CUSTOM(org, setup_test, teardown_test)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(domain, setup_test, teardown_test)
|
||||||
|
ISC_TEST_LIST_END
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, _setup, _teardown));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -42,28 +40,7 @@
|
|||||||
|
|
||||||
#include <dst/dst.h>
|
#include <dst/dst.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, true);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
dns_keytable_t *keytable = NULL;
|
dns_keytable_t *keytable = NULL;
|
||||||
dns_ntatable_t *ntatable = NULL;
|
dns_ntatable_t *ntatable = NULL;
|
||||||
@@ -123,7 +100,7 @@ create_keystruct(uint16_t flags, uint8_t proto, uint8_t alg, const char *keystr,
|
|||||||
|
|
||||||
keystruct->common.rdclass = rdclass;
|
keystruct->common.rdclass = rdclass;
|
||||||
keystruct->common.rdtype = dns_rdatatype_dnskey;
|
keystruct->common.rdtype = dns_rdatatype_dnskey;
|
||||||
keystruct->mctx = dt_mctx;
|
keystruct->mctx = mctx;
|
||||||
ISC_LINK_INIT(&keystruct->common, link);
|
ISC_LINK_INIT(&keystruct->common, link);
|
||||||
keystruct->flags = flags;
|
keystruct->flags = flags;
|
||||||
keystruct->protocol = proto;
|
keystruct->protocol = proto;
|
||||||
@@ -134,7 +111,7 @@ create_keystruct(uint16_t flags, uint8_t proto, uint8_t alg, const char *keystr,
|
|||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
isc_buffer_usedregion(&keydatabuf, &r);
|
isc_buffer_usedregion(&keydatabuf, &r);
|
||||||
keystruct->datalen = r.length;
|
keystruct->datalen = r.length;
|
||||||
keystruct->data = isc_mem_allocate(dt_mctx, r.length);
|
keystruct->data = isc_mem_allocate(mctx, r.length);
|
||||||
memmove(keystruct->data, r.base, r.length);
|
memmove(keystruct->data, r.base, r.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,11 +159,10 @@ create_tables(void) {
|
|||||||
dns_name_t *keyname = dns_fixedname_name(&fn);
|
dns_name_t *keyname = dns_fixedname_name(&fn);
|
||||||
isc_stdtime_t now;
|
isc_stdtime_t now;
|
||||||
|
|
||||||
result = dns_test_makeview("view", &view);
|
result = dns_test_makeview("view", false, &view);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
assert_int_equal(dns_keytable_create(dt_mctx, &keytable),
|
assert_int_equal(dns_keytable_create(mctx, &keytable), ISC_R_SUCCESS);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
assert_int_equal(
|
assert_int_equal(
|
||||||
dns_ntatable_create(view, taskmgr, timermgr, &ntatable),
|
dns_ntatable_create(view, taskmgr, timermgr, &ntatable),
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
@@ -229,8 +205,7 @@ destroy_tables(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add keys to the keytable */
|
/* add keys to the keytable */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_add) {
|
||||||
add_test(void **state) {
|
|
||||||
dns_keynode_t *keynode = NULL;
|
dns_keynode_t *keynode = NULL;
|
||||||
dns_keynode_t *null_keynode = NULL;
|
dns_keynode_t *null_keynode = NULL;
|
||||||
unsigned char digest[ISC_MAX_MD_SIZE];
|
unsigned char digest[ISC_MAX_MD_SIZE];
|
||||||
@@ -380,10 +355,7 @@ add_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* delete keys from the keytable */
|
/* delete keys from the keytable */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_delete) {
|
||||||
delete_test(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
create_tables();
|
create_tables();
|
||||||
|
|
||||||
/* dns_keytable_delete requires exact match */
|
/* dns_keytable_delete requires exact match */
|
||||||
@@ -409,8 +381,7 @@ delete_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* delete key nodes from the keytable */
|
/* delete key nodes from the keytable */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_deletekey) {
|
||||||
deletekey_test(void **state) {
|
|
||||||
dns_rdata_dnskey_t dnskey;
|
dns_rdata_dnskey_t dnskey;
|
||||||
dns_fixedname_t fn;
|
dns_fixedname_t fn;
|
||||||
dns_name_t *keyname = dns_fixedname_name(&fn);
|
dns_name_t *keyname = dns_fixedname_name(&fn);
|
||||||
@@ -475,8 +446,7 @@ deletekey_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check find-variant operations */
|
/* check find-variant operations */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_find) {
|
||||||
find_test(void **state) {
|
|
||||||
dns_keynode_t *keynode = NULL;
|
dns_keynode_t *keynode = NULL;
|
||||||
dns_fixedname_t fname;
|
dns_fixedname_t fname;
|
||||||
dns_name_t *name;
|
dns_name_t *name;
|
||||||
@@ -530,8 +500,7 @@ find_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check issecuredomain() */
|
/* check issecuredomain() */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_issecuredomain) {
|
||||||
issecuredomain_test(void **state) {
|
|
||||||
bool issecure;
|
bool issecure;
|
||||||
const char **n;
|
const char **n;
|
||||||
const char *names[] = { "example.com", "sub.example.com",
|
const char *names[] = { "example.com", "sub.example.com",
|
||||||
@@ -568,8 +537,7 @@ issecuredomain_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check dns_keytable_dump() */
|
/* check dns_keytable_dump() */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_dump) {
|
||||||
dump_test(void **state) {
|
|
||||||
FILE *f = fopen("/dev/null", "w");
|
FILE *f = fopen("/dev/null", "w");
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -587,8 +555,7 @@ dump_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check negative trust anchors */
|
/* check negative trust anchors */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_keytable_nta) {
|
||||||
nta_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
bool issecure, covered;
|
bool issecure, covered;
|
||||||
dns_fixedname_t fn;
|
dns_fixedname_t fn;
|
||||||
@@ -600,13 +567,13 @@ nta_test(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_test_makeview("view", &myview);
|
result = dns_test_makeview("view", false, &myview);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, 0, &myview->task, 0);
|
result = isc_task_create(taskmgr, 0, &myview->task, 0);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_view_initsecroots(myview, dt_mctx);
|
result = dns_view_initsecroots(myview, mctx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
result = dns_view_getsecroots(myview, &keytable);
|
result = dns_view_getsecroots(myview, &keytable);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -692,29 +659,17 @@ nta_test(void **state) {
|
|||||||
dns_view_detach(&myview);
|
dns_view_detach(&myview);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
|
||||||
const struct CMUnitTest tests[] = {
|
|
||||||
cmocka_unit_test(add_test),
|
|
||||||
cmocka_unit_test(delete_test),
|
|
||||||
cmocka_unit_test(deletekey_test),
|
|
||||||
cmocka_unit_test(find_test),
|
|
||||||
cmocka_unit_test(issecuredomain_test),
|
|
||||||
cmocka_unit_test(dump_test),
|
|
||||||
cmocka_unit_test(nta_test),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, _setup, _teardown));
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_add, setup_managers, teardown_managers)
|
||||||
}
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_delete, setup_managers, teardown_managers)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_deletekey, setup_managers, teardown_managers)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_find, setup_managers, teardown_managers)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_issecuredomain, setup_managers,
|
||||||
|
teardown_managers)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_dump, setup_managers, teardown_managers)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_keytable_nta, setup_managers, teardown_managers)
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
ISC_TEST_LIST_END
|
||||||
|
|
||||||
#include <stdio.h>
|
ISC_TEST_MAIN
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -40,28 +38,7 @@
|
|||||||
#include <dns/rdatalist.h>
|
#include <dns/rdatalist.h>
|
||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) {
|
nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) {
|
||||||
@@ -174,7 +151,7 @@ test_master(const char *workdir, const char *testfile,
|
|||||||
|
|
||||||
result = dns_master_loadfile(testfile, &dns_origin, &dns_origin,
|
result = dns_master_loadfile(testfile, &dns_origin, &dns_origin,
|
||||||
dns_rdataclass_in, true, 0, &callbacks,
|
dns_rdataclass_in, true, 0, &callbacks,
|
||||||
NULL, NULL, dt_mctx, format, 0);
|
NULL, NULL, mctx, format, 0);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@@ -182,15 +159,14 @@ test_master(const char *workdir, const char *testfile,
|
|||||||
static void
|
static void
|
||||||
include_callback(const char *filename, void *arg) {
|
include_callback(const char *filename, void *arg) {
|
||||||
char **argp = (char **)arg;
|
char **argp = (char **)arg;
|
||||||
*argp = isc_mem_strdup(dt_mctx, filename);
|
*argp = isc_mem_strdup(mctx, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Successful load test:
|
* Successful load test:
|
||||||
* dns_master_loadfile() loads a valid master file and returns success
|
* dns_master_loadfile() loads a valid master file and returns success
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(load) {
|
||||||
load_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -204,8 +180,7 @@ load_test(void **state) {
|
|||||||
* Unexpected end of file test:
|
* Unexpected end of file test:
|
||||||
* dns_master_loadfile() returns DNS_R_UNEXPECTED when file ends too soon
|
* dns_master_loadfile() returns DNS_R_UNEXPECTED when file ends too soon
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(unexpected) {
|
||||||
unexpected_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -220,8 +195,7 @@ unexpected_test(void **state) {
|
|||||||
* dns_master_loadfile() accepts broken zones with no TTL for first record
|
* dns_master_loadfile() accepts broken zones with no TTL for first record
|
||||||
* if it is an SOA
|
* if it is an SOA
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(noowner) {
|
||||||
noowner_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -236,8 +210,7 @@ noowner_test(void **state) {
|
|||||||
* dns_master_loadfile() returns DNS_R_NOOWNER when no owner name is
|
* dns_master_loadfile() returns DNS_R_NOOWNER when no owner name is
|
||||||
* specified
|
* specified
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nottl) {
|
||||||
nottl_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -252,8 +225,7 @@ nottl_test(void **state) {
|
|||||||
* dns_master_loadfile() returns DNS_R_BADCLASS when record class doesn't
|
* dns_master_loadfile() returns DNS_R_BADCLASS when record class doesn't
|
||||||
* match zone class
|
* match zone class
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(badclass) {
|
||||||
badclass_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -267,8 +239,7 @@ badclass_test(void **state) {
|
|||||||
* Too big rdata test:
|
* Too big rdata test:
|
||||||
* dns_master_loadfile() returns ISC_R_NOSPACE when record is too big
|
* dns_master_loadfile() returns ISC_R_NOSPACE when record is too big
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(toobig) {
|
||||||
toobig_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -282,8 +253,7 @@ toobig_test(void **state) {
|
|||||||
* Maximum rdata test:
|
* Maximum rdata test:
|
||||||
* dns_master_loadfile() returns ISC_R_SUCCESS when record is maximum size
|
* dns_master_loadfile() returns ISC_R_SUCCESS when record is maximum size
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(maxrdata) {
|
||||||
maxrdata_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -297,8 +267,7 @@ maxrdata_test(void **state) {
|
|||||||
* DNSKEY test:
|
* DNSKEY test:
|
||||||
* dns_master_loadfile() understands DNSKEY with key material
|
* dns_master_loadfile() understands DNSKEY with key material
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dnskey) {
|
||||||
dnskey_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -315,8 +284,7 @@ dnskey_test(void **state) {
|
|||||||
* RFC 4034 removed the ability to signal NOKEY, so empty key material should
|
* RFC 4034 removed the ability to signal NOKEY, so empty key material should
|
||||||
* be rejected.
|
* be rejected.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dnsnokey) {
|
||||||
dnsnokey_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -330,8 +298,7 @@ dnsnokey_test(void **state) {
|
|||||||
* Include test:
|
* Include test:
|
||||||
* dns_master_loadfile() understands $INCLUDE
|
* dns_master_loadfile() understands $INCLUDE
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(include) {
|
||||||
include_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -345,8 +312,7 @@ include_test(void **state) {
|
|||||||
* Include file list test:
|
* Include file list test:
|
||||||
* dns_master_loadfile4() returns names of included file
|
* dns_master_loadfile4() returns names of included file
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(master_includelist) {
|
||||||
master_includelist_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
@@ -361,12 +327,12 @@ master_includelist_test(void **state) {
|
|||||||
result = dns_master_loadfile(
|
result = dns_master_loadfile(
|
||||||
"testdata/master/master8.data", &dns_origin, &dns_origin,
|
"testdata/master/master8.data", &dns_origin, &dns_origin,
|
||||||
dns_rdataclass_in, 0, true, &callbacks, include_callback,
|
dns_rdataclass_in, 0, true, &callbacks, include_callback,
|
||||||
&filename, dt_mctx, dns_masterformat_text, 0);
|
&filename, mctx, dns_masterformat_text, 0);
|
||||||
assert_int_equal(result, DNS_R_SEENINCLUDE);
|
assert_int_equal(result, DNS_R_SEENINCLUDE);
|
||||||
assert_non_null(filename);
|
assert_non_null(filename);
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
assert_string_equal(filename, "testdata/master/master6.data");
|
assert_string_equal(filename, "testdata/master/master6.data");
|
||||||
isc_mem_free(dt_mctx, filename);
|
isc_mem_free(mctx, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,8 +340,7 @@ master_includelist_test(void **state) {
|
|||||||
* Include failure test:
|
* Include failure test:
|
||||||
* dns_master_loadfile() understands $INCLUDE failures
|
* dns_master_loadfile() understands $INCLUDE failures
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(includefail) {
|
||||||
includefail_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -389,8 +354,7 @@ includefail_test(void **state) {
|
|||||||
* Non-empty blank lines test:
|
* Non-empty blank lines test:
|
||||||
* dns_master_loadfile() handles non-empty blank lines
|
* dns_master_loadfile() handles non-empty blank lines
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(blanklines) {
|
||||||
blanklines_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -405,8 +369,7 @@ blanklines_test(void **state) {
|
|||||||
* dns_master_loadfile() allows leading zeroes in SOA
|
* dns_master_loadfile() allows leading zeroes in SOA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(leadingzero) {
|
||||||
leadingzero_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -417,8 +380,7 @@ leadingzero_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* masterfile totext tests */
|
/* masterfile totext tests */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(totext) {
|
||||||
totext_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_rdataset_t rdataset;
|
dns_rdataset_t rdataset;
|
||||||
dns_rdatalist_t rdatalist;
|
dns_rdatalist_t rdatalist;
|
||||||
@@ -455,8 +417,7 @@ totext_test(void **state) {
|
|||||||
* Raw load test:
|
* Raw load test:
|
||||||
* dns_master_loadfile() loads a valid raw file and returns success
|
* dns_master_loadfile() loads a valid raw file and returns success
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(loadraw) {
|
||||||
loadraw_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -488,8 +449,7 @@ loadraw_test(void **state) {
|
|||||||
* Raw dump test:
|
* Raw dump test:
|
||||||
* dns_master_dump*() functions dump valid raw files
|
* dns_master_dump*() functions dump valid raw files
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dumpraw) {
|
||||||
dumpraw_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
dns_dbversion_t *version = NULL;
|
dns_dbversion_t *version = NULL;
|
||||||
@@ -512,7 +472,7 @@ dumpraw_test(void **state) {
|
|||||||
&target);
|
&target);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_db_create(dt_mctx, "rbt", &dnsorigin, dns_dbtype_zone,
|
result = dns_db_create(mctx, "rbt", &dnsorigin, dns_dbtype_zone,
|
||||||
dns_rdataclass_in, 0, NULL, &db);
|
dns_rdataclass_in, 0, NULL, &db);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -528,9 +488,8 @@ dumpraw_test(void **state) {
|
|||||||
|
|
||||||
dns_db_currentversion(db, &version);
|
dns_db_currentversion(db, &version);
|
||||||
|
|
||||||
result = dns_master_dump(dt_mctx, db, version,
|
result = dns_master_dump(mctx, db, version, &dns_master_style_default,
|
||||||
&dns_master_style_default, "test.dump",
|
"test.dump", dns_masterformat_raw, NULL);
|
||||||
dns_masterformat_raw, NULL);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = test_master(NULL, "test.dump", dns_masterformat_raw, nullmsg,
|
result = test_master(NULL, "test.dump", dns_masterformat_raw, nullmsg,
|
||||||
@@ -544,9 +503,8 @@ dumpraw_test(void **state) {
|
|||||||
header.flags |= DNS_MASTERRAW_SOURCESERIALSET;
|
header.flags |= DNS_MASTERRAW_SOURCESERIALSET;
|
||||||
|
|
||||||
unlink("test.dump");
|
unlink("test.dump");
|
||||||
result = dns_master_dump(dt_mctx, db, version,
|
result = dns_master_dump(mctx, db, version, &dns_master_style_default,
|
||||||
&dns_master_style_default, "test.dump",
|
"test.dump", dns_masterformat_raw, &header);
|
||||||
dns_masterformat_raw, &header);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = test_master(NULL, "test.dump", dns_masterformat_raw, nullmsg,
|
result = test_master(NULL, "test.dump", dns_masterformat_raw, nullmsg,
|
||||||
@@ -587,8 +545,7 @@ warn_expect(struct dns_rdatacallbacks *mycallbacks, const char *fmt, ...) {
|
|||||||
* Origin change test:
|
* Origin change test:
|
||||||
* dns_master_loadfile() rejects zones with inherited name following $ORIGIN
|
* dns_master_loadfile() rejects zones with inherited name following $ORIGIN
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(neworigin) {
|
||||||
neworigin_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -600,53 +557,25 @@ neworigin_test(void **state) {
|
|||||||
assert_true(warn_expect_result);
|
assert_true(warn_expect_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(load)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(unexpected)
|
||||||
cmocka_unit_test_setup_teardown(load_test, _setup, _teardown),
|
ISC_TEST_ENTRY(noowner)
|
||||||
cmocka_unit_test_setup_teardown(unexpected_test, _setup,
|
ISC_TEST_ENTRY(nottl)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(badclass)
|
||||||
cmocka_unit_test_setup_teardown(noowner_test, _setup,
|
ISC_TEST_ENTRY(dnskey)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(dnsnokey)
|
||||||
cmocka_unit_test_setup_teardown(nottl_test, _setup, _teardown),
|
ISC_TEST_ENTRY(include)
|
||||||
cmocka_unit_test_setup_teardown(badclass_test, _setup,
|
ISC_TEST_ENTRY(master_includelist)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(includefail)
|
||||||
cmocka_unit_test_setup_teardown(dnskey_test, _setup, _teardown),
|
ISC_TEST_ENTRY(blanklines)
|
||||||
cmocka_unit_test_setup_teardown(dnsnokey_test, _setup,
|
ISC_TEST_ENTRY(leadingzero)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(totext)
|
||||||
cmocka_unit_test_setup_teardown(include_test, _setup,
|
ISC_TEST_ENTRY(loadraw)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(dumpraw)
|
||||||
cmocka_unit_test_setup_teardown(master_includelist_test, _setup,
|
ISC_TEST_ENTRY(toobig)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(maxrdata)
|
||||||
cmocka_unit_test_setup_teardown(includefail_test, _setup,
|
ISC_TEST_ENTRY(neworigin)
|
||||||
_teardown),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(blanklines_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(leadingzero_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(totext_test, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(loadraw_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dumpraw_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(toobig_test, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(maxrdata_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(neworigin_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -38,35 +36,13 @@
|
|||||||
#include <dns/fixedname.h>
|
#include <dns/fixedname.h>
|
||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
/* Set to true (or use -v option) for verbose output */
|
/* Set to true (or use -v option) for verbose output */
|
||||||
static bool verbose = false;
|
static bool verbose = false;
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dns_name_fullcompare test */
|
/* dns_name_fullcompare test */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(fullcompare) {
|
||||||
fullcompare_test(void **state) {
|
|
||||||
dns_fixedname_t fixed1;
|
dns_fixedname_t fixed1;
|
||||||
dns_fixedname_t fixed2;
|
dns_fixedname_t fixed2;
|
||||||
dns_name_t *name1;
|
dns_name_t *name1;
|
||||||
@@ -182,8 +158,7 @@ compress_test(dns_name_t *name1, dns_name_t *name2, dns_name_t *name3,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* name compression test */
|
/* name compression test */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(compression) {
|
||||||
compression_test(void **state) {
|
|
||||||
unsigned int allowed;
|
unsigned int allowed;
|
||||||
dns_compress_t cctx;
|
dns_compress_t cctx;
|
||||||
dns_decompress_t dctx;
|
dns_decompress_t dctx;
|
||||||
@@ -216,7 +191,7 @@ compression_test(void **state) {
|
|||||||
|
|
||||||
/* Test 1: NONE */
|
/* Test 1: NONE */
|
||||||
allowed = DNS_COMPRESS_NONE;
|
allowed = DNS_COMPRESS_NONE;
|
||||||
assert_int_equal(dns_compress_init(&cctx, -1, dt_mctx), ISC_R_SUCCESS);
|
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, allowed);
|
dns_compress_setmethods(&cctx, allowed);
|
||||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||||
dns_decompress_setmethods(&dctx, allowed);
|
dns_decompress_setmethods(&dctx, allowed);
|
||||||
@@ -229,7 +204,7 @@ compression_test(void **state) {
|
|||||||
|
|
||||||
/* Test2: GLOBAL14 */
|
/* Test2: GLOBAL14 */
|
||||||
allowed = DNS_COMPRESS_GLOBAL14;
|
allowed = DNS_COMPRESS_GLOBAL14;
|
||||||
assert_int_equal(dns_compress_init(&cctx, -1, dt_mctx), ISC_R_SUCCESS);
|
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, allowed);
|
dns_compress_setmethods(&cctx, allowed);
|
||||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||||
dns_decompress_setmethods(&dctx, allowed);
|
dns_decompress_setmethods(&dctx, allowed);
|
||||||
@@ -242,7 +217,7 @@ compression_test(void **state) {
|
|||||||
|
|
||||||
/* Test3: ALL */
|
/* Test3: ALL */
|
||||||
allowed = DNS_COMPRESS_ALL;
|
allowed = DNS_COMPRESS_ALL;
|
||||||
assert_int_equal(dns_compress_init(&cctx, -1, dt_mctx), ISC_R_SUCCESS);
|
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, allowed);
|
dns_compress_setmethods(&cctx, allowed);
|
||||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||||
dns_decompress_setmethods(&dctx, allowed);
|
dns_decompress_setmethods(&dctx, allowed);
|
||||||
@@ -255,7 +230,7 @@ compression_test(void **state) {
|
|||||||
|
|
||||||
/* Test4: NONE disabled */
|
/* Test4: NONE disabled */
|
||||||
allowed = DNS_COMPRESS_NONE;
|
allowed = DNS_COMPRESS_NONE;
|
||||||
assert_int_equal(dns_compress_init(&cctx, -1, dt_mctx), ISC_R_SUCCESS);
|
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, allowed);
|
dns_compress_setmethods(&cctx, allowed);
|
||||||
dns_compress_disable(&cctx);
|
dns_compress_disable(&cctx);
|
||||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||||
@@ -269,7 +244,7 @@ compression_test(void **state) {
|
|||||||
|
|
||||||
/* Test5: GLOBAL14 disabled */
|
/* Test5: GLOBAL14 disabled */
|
||||||
allowed = DNS_COMPRESS_GLOBAL14;
|
allowed = DNS_COMPRESS_GLOBAL14;
|
||||||
assert_int_equal(dns_compress_init(&cctx, -1, dt_mctx), ISC_R_SUCCESS);
|
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, allowed);
|
dns_compress_setmethods(&cctx, allowed);
|
||||||
dns_compress_disable(&cctx);
|
dns_compress_disable(&cctx);
|
||||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||||
@@ -283,7 +258,7 @@ compression_test(void **state) {
|
|||||||
|
|
||||||
/* Test6: ALL disabled */
|
/* Test6: ALL disabled */
|
||||||
allowed = DNS_COMPRESS_ALL;
|
allowed = DNS_COMPRESS_ALL;
|
||||||
assert_int_equal(dns_compress_init(&cctx, -1, dt_mctx), ISC_R_SUCCESS);
|
assert_int_equal(dns_compress_init(&cctx, -1, mctx), ISC_R_SUCCESS);
|
||||||
dns_compress_setmethods(&cctx, allowed);
|
dns_compress_setmethods(&cctx, allowed);
|
||||||
dns_compress_disable(&cctx);
|
dns_compress_disable(&cctx);
|
||||||
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_STRICT);
|
||||||
@@ -297,8 +272,7 @@ compression_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* is trust-anchor-telemetry test */
|
/* is trust-anchor-telemetry test */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(istat) {
|
||||||
istat_test(void **state) {
|
|
||||||
dns_fixedname_t fixed;
|
dns_fixedname_t fixed;
|
||||||
dns_name_t *name;
|
dns_name_t *name;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@@ -341,8 +315,7 @@ istat_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_init */
|
/* dns_nane_init */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(init) {
|
||||||
init_test(void **state) {
|
|
||||||
dns_name_t name;
|
dns_name_t name;
|
||||||
unsigned char offsets[1];
|
unsigned char offsets[1];
|
||||||
|
|
||||||
@@ -359,8 +332,7 @@ init_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_invalidate */
|
/* dns_nane_invalidate */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(invalidate) {
|
||||||
invalidate_test(void **state) {
|
|
||||||
dns_name_t name;
|
dns_name_t name;
|
||||||
unsigned char offsets[1];
|
unsigned char offsets[1];
|
||||||
|
|
||||||
@@ -378,8 +350,7 @@ invalidate_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_setbuffer/hasbuffer */
|
/* dns_nane_setbuffer/hasbuffer */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(buffer) {
|
||||||
buffer_test(void **state) {
|
|
||||||
dns_name_t name;
|
dns_name_t name;
|
||||||
unsigned char buf[BUFSIZ];
|
unsigned char buf[BUFSIZ];
|
||||||
isc_buffer_t b;
|
isc_buffer_t b;
|
||||||
@@ -394,8 +365,7 @@ buffer_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_isabsolute */
|
/* dns_nane_isabsolute */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(isabsolute) {
|
||||||
isabsolute_test(void **state) {
|
|
||||||
struct {
|
struct {
|
||||||
const char *namestr;
|
const char *namestr;
|
||||||
bool expect;
|
bool expect;
|
||||||
@@ -429,8 +399,7 @@ isabsolute_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_hash */
|
/* dns_nane_hash */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(hash) {
|
||||||
hash_test(void **state) {
|
|
||||||
struct {
|
struct {
|
||||||
const char *name1;
|
const char *name1;
|
||||||
const char *name2;
|
const char *name2;
|
||||||
@@ -493,8 +462,7 @@ hash_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_issubdomain */
|
/* dns_nane_issubdomain */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(issubdomain) {
|
||||||
issubdomain_test(void **state) {
|
|
||||||
struct {
|
struct {
|
||||||
const char *name1;
|
const char *name1;
|
||||||
const char *name2;
|
const char *name2;
|
||||||
@@ -537,8 +505,7 @@ issubdomain_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_countlabels */
|
/* dns_nane_countlabels */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(countlabels) {
|
||||||
countlabels_test(void **state) {
|
|
||||||
struct {
|
struct {
|
||||||
const char *namestr;
|
const char *namestr;
|
||||||
unsigned int expect;
|
unsigned int expect;
|
||||||
@@ -573,8 +540,7 @@ countlabels_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_getlabel */
|
/* dns_nane_getlabel */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(getlabel) {
|
||||||
getlabel_test(void **state) {
|
|
||||||
struct {
|
struct {
|
||||||
const char *name1;
|
const char *name1;
|
||||||
unsigned int pos1;
|
unsigned int pos1;
|
||||||
@@ -617,8 +583,7 @@ getlabel_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_nane_getlabelsequence */
|
/* dns_nane_getlabelsequence */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(getlabelsequence) {
|
||||||
getlabelsequence_test(void **state) {
|
|
||||||
struct {
|
struct {
|
||||||
const char *name1;
|
const char *name1;
|
||||||
unsigned int pos1;
|
unsigned int pos1;
|
||||||
@@ -673,8 +638,7 @@ getlabelsequence_test(void **state) {
|
|||||||
|
|
||||||
/* Benchmark dns_name_fromwire() implementation */
|
/* Benchmark dns_name_fromwire() implementation */
|
||||||
|
|
||||||
static void *
|
ISC_RUN_TEST_IMPL(fromwire_thread(void *arg) {
|
||||||
fromwire_thread(void *arg) {
|
|
||||||
unsigned int maxval = 32000000;
|
unsigned int maxval = 32000000;
|
||||||
uint8_t data[] = { 3, 'w', 'w', 'w', 7, 'e', 'x',
|
uint8_t data[] = { 3, 'w', 'w', 'w', 7, 'e', 'x',
|
||||||
'a', 'm', 'p', 'l', 'e', 7, 'i',
|
'a', 'm', 'p', 'l', 'e', 7, 'i',
|
||||||
@@ -709,8 +673,7 @@ fromwire_thread(void *arg) {
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(benchmark) {
|
||||||
benchmark_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
isc_time_t ts1, ts2;
|
isc_time_t ts1, ts2;
|
||||||
@@ -747,50 +710,22 @@ benchmark_test(void **state) {
|
|||||||
|
|
||||||
#endif /* DNS_BENCHMARK_TESTS */
|
#endif /* DNS_BENCHMARK_TESTS */
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(int argc, char **argv) {
|
ISC_TEST_ENTRY(fullcompare)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(compression)
|
||||||
cmocka_unit_test(fullcompare_test),
|
ISC_TEST_ENTRY(istat)
|
||||||
cmocka_unit_test_setup_teardown(compression_test, _setup,
|
ISC_TEST_ENTRY(init)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(invalidate)
|
||||||
cmocka_unit_test(istat_test),
|
ISC_TEST_ENTRY(buffer)
|
||||||
cmocka_unit_test(init_test),
|
ISC_TEST_ENTRY(isabsolute)
|
||||||
cmocka_unit_test(invalidate_test),
|
ISC_TEST_ENTRY(hash)
|
||||||
cmocka_unit_test(buffer_test),
|
ISC_TEST_ENTRY(issubdomain)
|
||||||
cmocka_unit_test(isabsolute_test),
|
ISC_TEST_ENTRY(countlabels)
|
||||||
cmocka_unit_test(hash_test),
|
ISC_TEST_ENTRY(getlabel)
|
||||||
cmocka_unit_test(issubdomain_test),
|
ISC_TEST_ENTRY(getlabelsequence)
|
||||||
cmocka_unit_test(countlabels_test),
|
|
||||||
cmocka_unit_test(getlabel_test),
|
|
||||||
cmocka_unit_test(getlabelsequence_test),
|
|
||||||
#ifdef DNS_BENCHMARK_TESTS
|
#ifdef DNS_BENCHMARK_TESTS
|
||||||
cmocka_unit_test_setup_teardown(benchmark_test, _setup,
|
ISC_TEST_ENTRY(benchmark)
|
||||||
_teardown),
|
|
||||||
#endif /* DNS_BENCHMARK_TESTS */
|
#endif /* DNS_BENCHMARK_TESTS */
|
||||||
};
|
ISC_TEST_LIST_END
|
||||||
int c;
|
|
||||||
|
|
||||||
while ((c = isc_commandline_parse(argc, argv, "v")) != -1) {
|
ISC_TEST_MAIN
|
||||||
switch (c) {
|
|
||||||
case 'v':
|
|
||||||
verbose = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -30,28 +28,7 @@
|
|||||||
#include <dns/db.h>
|
#include <dns/db.h>
|
||||||
#include <dns/nsec3.h>
|
#include <dns/nsec3.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iteration_test(const char *file, unsigned int expected) {
|
iteration_test(const char *file, unsigned int expected) {
|
||||||
@@ -134,8 +111,7 @@ nsec3param_salttotext_test(const nsec3param_salttotext_test_params_t *params) {
|
|||||||
* check that appropriate max iterations is returned for different
|
* check that appropriate max iterations is returned for different
|
||||||
* key size mixes
|
* key size mixes
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(max_iterations) {
|
||||||
max_iterations(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
iteration_test("testdata/nsec3/1024.db", 150);
|
iteration_test("testdata/nsec3/1024.db", 150);
|
||||||
@@ -146,8 +122,7 @@ max_iterations(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check dns_nsec3param_salttotext() */
|
/* check dns_nsec3param_salttotext() */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nsec3param_salttotext) {
|
||||||
nsec3param_salttotext(void **state) {
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
const nsec3param_salttotext_test_params_t tests[] = {
|
const nsec3param_salttotext_test_params_t tests[] = {
|
||||||
@@ -171,26 +146,9 @@ nsec3param_salttotext(void **state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(max_iterations)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(nsec3param_salttotext)
|
||||||
cmocka_unit_test_setup_teardown(max_iterations, _setup,
|
ISC_TEST_LIST_END
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(nsec3param_salttotext, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -32,8 +30,9 @@
|
|||||||
#include <dns/db.h>
|
#include <dns/db.h>
|
||||||
#include <dns/nsec3.h>
|
#include <dns/nsec3.h>
|
||||||
|
|
||||||
#include "../zone_p.h"
|
#include "zone_p.h"
|
||||||
#include "dnstest.h"
|
|
||||||
|
#include <tests/dns.h>
|
||||||
|
|
||||||
#define HASH 1
|
#define HASH 1
|
||||||
#define FLAGS 0
|
#define FLAGS 0
|
||||||
@@ -41,27 +40,6 @@
|
|||||||
#define SALTLEN 4
|
#define SALTLEN 4
|
||||||
#define SALT "FEDCBA98"
|
#define SALT "FEDCBA98"
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Structures containing parameters for nsec3param_salttotext_test().
|
* Structures containing parameters for nsec3param_salttotext_test().
|
||||||
*/
|
*/
|
||||||
@@ -184,8 +162,7 @@ nsec3param_change_test(const nsec3param_change_test_params_t *test) {
|
|||||||
dns_zone_detach(&zone);
|
dns_zone_detach(&zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nsec3param_change) {
|
||||||
nsec3param_change(void **state) {
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -281,24 +258,8 @@ nsec3param_change(void **state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(nsec3param_change)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(nsec3param_change, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -28,46 +26,22 @@
|
|||||||
|
|
||||||
#include <dns/peer.h>
|
#include <dns/peer.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test DSCP set/get functions */
|
/* Test DSCP set/get functions */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dscp) {
|
||||||
dscp(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_netaddr_t netaddr;
|
isc_netaddr_t netaddr;
|
||||||
struct in_addr ina;
|
struct in_addr ina;
|
||||||
dns_peer_t *peer = NULL;
|
dns_peer_t *peer = NULL;
|
||||||
isc_dscp_t dscp;
|
isc_dscp_t dscp;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create peer structure for the loopback address.
|
* Create peer structure for the loopback address.
|
||||||
*/
|
*/
|
||||||
ina.s_addr = INADDR_LOOPBACK;
|
ina.s_addr = INADDR_LOOPBACK;
|
||||||
isc_netaddr_fromin(&netaddr, &ina);
|
isc_netaddr_fromin(&netaddr, &ina);
|
||||||
result = dns_peer_new(dt_mctx, &netaddr, &peer);
|
result = dns_peer_new(mctx, &netaddr, &peer);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -153,23 +127,10 @@ dscp(void **state) {
|
|||||||
dns_peer_detach(&peer);
|
dns_peer_detach(&peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
|
||||||
const struct CMUnitTest tests[] = {
|
|
||||||
cmocka_unit_test_setup_teardown(dscp, _setup, _teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_ENTRY(dscp)
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
ISC_TEST_LIST_END
|
||||||
|
|
||||||
#include <stdio.h>
|
ISC_TEST_MAIN
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -35,27 +33,30 @@
|
|||||||
|
|
||||||
#include <dst/dst.h>
|
#include <dst/dst.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static dns_rdatatype_t privatetype = 65534;
|
static dns_rdatatype_t privatetype = 65534;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
setup_test(void **state) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
result = dst_lib_init(mctx, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
teardown_test(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
dns_test_end();
|
dst_lib_destroy();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -147,8 +148,7 @@ make_nsec3(nsec3_testcase_t *testcase, dns_rdata_t *private,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert private signing records to text */
|
/* convert private signing records to text */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(private_signing_totext) {
|
||||||
private_signing_totext_test(void **state) {
|
|
||||||
dns_rdata_t private;
|
dns_rdata_t private;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -180,8 +180,7 @@ private_signing_totext_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert private chain records to text */
|
/* convert private chain records to text */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(private_nsec3_totext) {
|
||||||
private_nsec3_totext_test(void **state) {
|
|
||||||
dns_rdata_t private;
|
dns_rdata_t private;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -215,26 +214,9 @@ private_nsec3_totext_test(void **state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(private_signing_totext, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY_CUSTOM(private_nsec3_totext, setup_test, teardown_test)
|
||||||
cmocka_unit_test_setup_teardown(private_signing_totext_test,
|
ISC_TEST_LIST_END
|
||||||
_setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(private_nsec3_totext_test,
|
|
||||||
_setup, _teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@@ -29,7 +27,6 @@
|
|||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
|
|
||||||
#include <isc/app.h>
|
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/file.h>
|
#include <isc/file.h>
|
||||||
#include <isc/hash.h>
|
#include <isc/hash.h>
|
||||||
@@ -54,7 +51,7 @@
|
|||||||
|
|
||||||
#include <dst/dst.h>
|
#include <dst/dst.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
dns_rbt_t *rbt;
|
dns_rbt_t *rbt;
|
||||||
@@ -127,31 +124,11 @@ static const char *const ordered_names[] = {
|
|||||||
static const size_t ordered_names_count =
|
static const size_t ordered_names_count =
|
||||||
(sizeof(ordered_names) / sizeof(*ordered_names));
|
(sizeof(ordered_names) / sizeof(*ordered_names));
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
static void
|
static void
|
||||||
delete_data(void *data, void *arg) {
|
delete_data(void *data, void *arg) {
|
||||||
UNUSED(arg);
|
UNUSED(arg);
|
||||||
|
|
||||||
isc_mem_put(dt_mctx, data, sizeof(size_t));
|
isc_mem_put(mctx, data, sizeof(size_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static test_context_t *
|
static test_context_t *
|
||||||
@@ -160,16 +137,15 @@ test_context_setup(void) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
ctx = isc_mem_get(dt_mctx, sizeof(*ctx));
|
ctx = isc_mem_get(mctx, sizeof(*ctx));
|
||||||
assert_non_null(ctx);
|
assert_non_null(ctx);
|
||||||
|
|
||||||
ctx->rbt = NULL;
|
ctx->rbt = NULL;
|
||||||
result = dns_rbt_create(dt_mctx, delete_data, NULL, &ctx->rbt);
|
result = dns_rbt_create(mctx, delete_data, NULL, &ctx->rbt);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
ctx->rbt_distances = NULL;
|
ctx->rbt_distances = NULL;
|
||||||
result = dns_rbt_create(dt_mctx, delete_data, NULL,
|
result = dns_rbt_create(mctx, delete_data, NULL, &ctx->rbt_distances);
|
||||||
&ctx->rbt_distances);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
for (i = 0; i < domain_names_count; i++) {
|
for (i = 0; i < domain_names_count; i++) {
|
||||||
@@ -181,13 +157,13 @@ test_context_setup(void) {
|
|||||||
|
|
||||||
name = dns_fixedname_name(&fname);
|
name = dns_fixedname_name(&fname);
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = i + 1;
|
*n = i + 1;
|
||||||
result = dns_rbt_addname(ctx->rbt, name, n);
|
result = dns_rbt_addname(ctx->rbt, name, n);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = node_distances[i];
|
*n = node_distances[i];
|
||||||
result = dns_rbt_addname(ctx->rbt_distances, name, n);
|
result = dns_rbt_addname(ctx->rbt_distances, name, n);
|
||||||
@@ -202,7 +178,7 @@ test_context_teardown(test_context_t *ctx) {
|
|||||||
dns_rbt_destroy(&ctx->rbt);
|
dns_rbt_destroy(&ctx->rbt);
|
||||||
dns_rbt_destroy(&ctx->rbt_distances);
|
dns_rbt_destroy(&ctx->rbt_distances);
|
||||||
|
|
||||||
isc_mem_put(dt_mctx, ctx, sizeof(*ctx));
|
isc_mem_put(mctx, ctx, sizeof(*ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -233,13 +209,10 @@ check_test_data(dns_rbt_t *rbt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test the creation of an rbt */
|
/* Test the creation of an rbt */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_create) {
|
||||||
rbt_create(void **state) {
|
|
||||||
test_context_t *ctx;
|
test_context_t *ctx;
|
||||||
bool tree_ok;
|
bool tree_ok;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -253,12 +226,9 @@ rbt_create(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test dns_rbt_nodecount() on a tree */
|
/* Test dns_rbt_nodecount() on a tree */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_nodecount) {
|
||||||
rbt_nodecount(void **state) {
|
|
||||||
test_context_t *ctx;
|
test_context_t *ctx;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -269,8 +239,7 @@ rbt_nodecount(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test dns_rbtnode_get_distance() on a tree */
|
/* Test dns_rbtnode_get_distance() on a tree */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbtnode_get_distance) {
|
||||||
rbtnode_get_distance(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx;
|
test_context_t *ctx;
|
||||||
const char *name_str = "a";
|
const char *name_str = "a";
|
||||||
@@ -279,8 +248,6 @@ rbtnode_get_distance(void **state) {
|
|||||||
dns_rbtnode_t *node = NULL;
|
dns_rbtnode_t *node = NULL;
|
||||||
dns_rbtnodechain_t chain;
|
dns_rbtnodechain_t chain;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -322,19 +289,16 @@ rbtnode_get_distance(void **state) {
|
|||||||
* path from a sub-tree's root to a node is no more than
|
* path from a sub-tree's root to a node is no more than
|
||||||
* 2log(n). This check verifies that the tree is balanced.
|
* 2log(n). This check verifies that the tree is balanced.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_check_distance_random) {
|
||||||
rbt_check_distance_random(void **state) {
|
|
||||||
dns_rbt_t *mytree = NULL;
|
dns_rbt_t *mytree = NULL;
|
||||||
const unsigned int log_num_nodes = 16;
|
const unsigned int log_num_nodes = 16;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
bool tree_ok;
|
bool tree_ok;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
result = dns_rbt_create(dt_mctx, delete_data, NULL, &mytree);
|
result = dns_rbt_create(mctx, delete_data, NULL, &mytree);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* Names are inserted in random order. */
|
/* Names are inserted in random order. */
|
||||||
@@ -351,7 +315,7 @@ rbt_check_distance_random(void **state) {
|
|||||||
size_t *n;
|
size_t *n;
|
||||||
char namebuf[34];
|
char namebuf[34];
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = i + 1;
|
*n = i + 1;
|
||||||
|
|
||||||
@@ -400,19 +364,16 @@ rbt_check_distance_random(void **state) {
|
|||||||
* path from a sub-tree's root to a node is no more than
|
* path from a sub-tree's root to a node is no more than
|
||||||
* 2log(n). This check verifies that the tree is balanced.
|
* 2log(n). This check verifies that the tree is balanced.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_check_distance_ordered) {
|
||||||
rbt_check_distance_ordered(void **state) {
|
|
||||||
dns_rbt_t *mytree = NULL;
|
dns_rbt_t *mytree = NULL;
|
||||||
const unsigned int log_num_nodes = 16;
|
const unsigned int log_num_nodes = 16;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
bool tree_ok;
|
bool tree_ok;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
result = dns_rbt_create(dt_mctx, delete_data, NULL, &mytree);
|
result = dns_rbt_create(mctx, delete_data, NULL, &mytree);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* Names are inserted in sorted order. */
|
/* Names are inserted in sorted order. */
|
||||||
@@ -431,7 +392,7 @@ rbt_check_distance_ordered(void **state) {
|
|||||||
dns_fixedname_t fname;
|
dns_fixedname_t fname;
|
||||||
dns_name_t *name;
|
dns_name_t *name;
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = i + 1;
|
*n = i + 1;
|
||||||
|
|
||||||
@@ -479,25 +440,22 @@ compare_labelsequences(dns_rbtnode_t *node, const char *labelstr) {
|
|||||||
dns_name_init(&name, NULL);
|
dns_name_init(&name, NULL);
|
||||||
dns_rbt_namefromnode(node, &name);
|
dns_rbt_namefromnode(node, &name);
|
||||||
|
|
||||||
result = dns_name_tostring(&name, &nodestr, dt_mctx);
|
result = dns_name_tostring(&name, &nodestr, mctx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
is_equal = strcmp(labelstr, nodestr) == 0 ? true : false;
|
is_equal = strcmp(labelstr, nodestr) == 0 ? true : false;
|
||||||
|
|
||||||
isc_mem_free(dt_mctx, nodestr);
|
isc_mem_free(mctx, nodestr);
|
||||||
|
|
||||||
return (is_equal);
|
return (is_equal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test insertion into a tree */
|
/* Test insertion into a tree */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_insert) {
|
||||||
rbt_insert(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx;
|
test_context_t *ctx;
|
||||||
dns_rbtnode_t *node;
|
dns_rbtnode_t *node;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -653,13 +611,10 @@ rbt_insert(void **state) {
|
|||||||
* as a red-black tree. This test checks node deletion when upper nodes
|
* as a red-black tree. This test checks node deletion when upper nodes
|
||||||
* have data.
|
* have data.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_remove) {
|
||||||
rbt_remove(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -675,7 +630,7 @@ rbt_remove(void **state) {
|
|||||||
size_t start_node;
|
size_t start_node;
|
||||||
|
|
||||||
/* Create a tree. */
|
/* Create a tree. */
|
||||||
result = dns_rbt_create(dt_mctx, delete_data, NULL, &mytree);
|
result = dns_rbt_create(mctx, delete_data, NULL, &mytree);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* Insert test data into the tree. */
|
/* Insert test data into the tree. */
|
||||||
@@ -703,7 +658,7 @@ rbt_remove(void **state) {
|
|||||||
assert_non_null(node);
|
assert_non_null(node);
|
||||||
assert_null(node->data);
|
assert_null(node->data);
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = i;
|
*n = i;
|
||||||
|
|
||||||
@@ -843,7 +798,7 @@ insert_nodes(dns_rbt_t *mytree, char **names, size_t *names_count,
|
|||||||
size_t *n;
|
size_t *n;
|
||||||
char namebuf[34];
|
char namebuf[34];
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
|
|
||||||
*n = i; /* Unused value */
|
*n = i; /* Unused value */
|
||||||
@@ -868,7 +823,7 @@ insert_nodes(dns_rbt_t *mytree, char **names, size_t *names_count,
|
|||||||
result = dns_rbt_addnode(mytree, name, &node);
|
result = dns_rbt_addnode(mytree, name, &node);
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
node->data = n;
|
node->data = n;
|
||||||
names[*names_count] = isc_mem_strdup(dt_mctx,
|
names[*names_count] = isc_mem_strdup(mctx,
|
||||||
namebuf);
|
namebuf);
|
||||||
assert_non_null(names[*names_count]);
|
assert_non_null(names[*names_count]);
|
||||||
*names_count += 1;
|
*names_count += 1;
|
||||||
@@ -899,7 +854,7 @@ remove_nodes(dns_rbt_t *mytree, char **names, size_t *names_count,
|
|||||||
result = dns_rbt_deletename(mytree, name, false);
|
result = dns_rbt_deletename(mytree, name, false);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
isc_mem_free(dt_mctx, names[node]);
|
isc_mem_free(mctx, names[node]);
|
||||||
if (*names_count > 0) {
|
if (*names_count > 0) {
|
||||||
names[node] = names[*names_count - 1];
|
names[node] = names[*names_count - 1];
|
||||||
names[*names_count - 1] = NULL;
|
names[*names_count - 1] = NULL;
|
||||||
@@ -944,8 +899,7 @@ check_tree(dns_rbt_t *mytree, char **names, size_t names_count) {
|
|||||||
* forest. The number of nodes in the tree level doesn't grow
|
* forest. The number of nodes in the tree level doesn't grow
|
||||||
* over 1024.
|
* over 1024.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_insert_and_remove) {
|
||||||
rbt_insert_and_remove(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_rbt_t *mytree = NULL;
|
dns_rbt_t *mytree = NULL;
|
||||||
size_t *n;
|
size_t *n;
|
||||||
@@ -953,14 +907,12 @@ rbt_insert_and_remove(void **state) {
|
|||||||
size_t names_count;
|
size_t names_count;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
result = dns_rbt_create(dt_mctx, delete_data, NULL, &mytree);
|
result = dns_rbt_create(mctx, delete_data, NULL, &mytree);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
result = dns_rbt_addname(mytree, dns_rootname, n);
|
result = dns_rbt_addname(mytree, dns_rootname, n);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -999,7 +951,7 @@ rbt_insert_and_remove(void **state) {
|
|||||||
|
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
if (names[i] != NULL) {
|
if (names[i] != NULL) {
|
||||||
isc_mem_free(dt_mctx, names[i]);
|
isc_mem_free(mctx, names[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1011,16 +963,13 @@ rbt_insert_and_remove(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test findname return values */
|
/* Test findname return values */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_findname) {
|
||||||
rbt_findname(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx = NULL;
|
test_context_t *ctx = NULL;
|
||||||
dns_fixedname_t fname, found;
|
dns_fixedname_t fname, found;
|
||||||
dns_name_t *name = NULL, *foundname = NULL;
|
dns_name_t *name = NULL, *foundname = NULL;
|
||||||
size_t *n = NULL;
|
size_t *n = NULL;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -1059,21 +1008,18 @@ rbt_findname(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test addname return values */
|
/* Test addname return values */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_addname) {
|
||||||
rbt_addname(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx = NULL;
|
test_context_t *ctx = NULL;
|
||||||
dns_fixedname_t fname;
|
dns_fixedname_t fname;
|
||||||
dns_name_t *name = NULL;
|
dns_name_t *name = NULL;
|
||||||
size_t *n;
|
size_t *n;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
|
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = 1;
|
*n = 1;
|
||||||
|
|
||||||
@@ -1085,26 +1031,23 @@ rbt_addname(void **state) {
|
|||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* Now add again, should get ISC_R_EXISTS */
|
/* Now add again, should get ISC_R_EXISTS */
|
||||||
n = isc_mem_get(dt_mctx, sizeof(size_t));
|
n = isc_mem_get(mctx, sizeof(size_t));
|
||||||
assert_non_null(n);
|
assert_non_null(n);
|
||||||
*n = 2;
|
*n = 2;
|
||||||
result = dns_rbt_addname(ctx->rbt, name, n);
|
result = dns_rbt_addname(ctx->rbt, name, n);
|
||||||
assert_int_equal(result, ISC_R_EXISTS);
|
assert_int_equal(result, ISC_R_EXISTS);
|
||||||
isc_mem_put(dt_mctx, n, sizeof(size_t));
|
isc_mem_put(mctx, n, sizeof(size_t));
|
||||||
|
|
||||||
test_context_teardown(ctx);
|
test_context_teardown(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test deletename return values */
|
/* Test deletename return values */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_deletename) {
|
||||||
rbt_deletename(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx = NULL;
|
test_context_t *ctx = NULL;
|
||||||
dns_fixedname_t fname;
|
dns_fixedname_t fname;
|
||||||
dns_name_t *name = NULL;
|
dns_name_t *name = NULL;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -1125,8 +1068,7 @@ rbt_deletename(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test nodechain */
|
/* Test nodechain */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbt_nodechain) {
|
||||||
rbt_nodechain(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx;
|
test_context_t *ctx;
|
||||||
dns_fixedname_t fname, found, expect;
|
dns_fixedname_t fname, found, expect;
|
||||||
@@ -1134,8 +1076,6 @@ rbt_nodechain(void **state) {
|
|||||||
dns_rbtnode_t *node = NULL;
|
dns_rbtnode_t *node = NULL;
|
||||||
dns_rbtnodechain_t chain;
|
dns_rbtnodechain_t chain;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -1186,15 +1126,12 @@ rbt_nodechain(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test addname return values */
|
/* Test addname return values */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rbtnode_namelen) {
|
||||||
rbtnode_namelen(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
test_context_t *ctx = NULL;
|
test_context_t *ctx = NULL;
|
||||||
dns_rbtnode_t *node;
|
dns_rbtnode_t *node;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
|
|
||||||
ctx = test_context_setup();
|
ctx = test_context_setup();
|
||||||
@@ -1267,8 +1204,7 @@ find_thread(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Benchmark RBT implementation */
|
/* Benchmark RBT implementation */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(benchmark) {
|
||||||
benchmark(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
char namestr[sizeof("name18446744073709551616.example.org.")];
|
char namestr[sizeof("name18446744073709551616.example.org.")];
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
@@ -1281,8 +1217,6 @@ benchmark(void **state) {
|
|||||||
unsigned int nthreads;
|
unsigned int nthreads;
|
||||||
isc_thread_t threads[32];
|
isc_thread_t threads[32];
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
srandom(time(NULL));
|
srandom(time(NULL));
|
||||||
|
|
||||||
debug_mem_record = false;
|
debug_mem_record = false;
|
||||||
@@ -1301,7 +1235,7 @@ benchmark(void **state) {
|
|||||||
|
|
||||||
/* Create a tree. */
|
/* Create a tree. */
|
||||||
mytree = NULL;
|
mytree = NULL;
|
||||||
result = dns_rbt_create(dt_mctx, NULL, NULL, &mytree);
|
result = dns_rbt_create(mctx, NULL, NULL, &mytree);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* Insert test data into the tree. */
|
/* Insert test data into the tree. */
|
||||||
@@ -1343,47 +1277,24 @@ benchmark(void **state) {
|
|||||||
}
|
}
|
||||||
#endif /* defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__) */
|
#endif /* defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__) */
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(rbt_create)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(rbt_nodecount)
|
||||||
cmocka_unit_test_setup_teardown(rbt_create, _setup, _teardown),
|
ISC_TEST_ENTRY(rbtnode_get_distance)
|
||||||
cmocka_unit_test_setup_teardown(rbt_nodecount, _setup,
|
ISC_TEST_ENTRY(rbt_check_distance_random)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(rbt_check_distance_ordered)
|
||||||
cmocka_unit_test_setup_teardown(rbtnode_get_distance, _setup,
|
ISC_TEST_ENTRY(rbt_insert)
|
||||||
_teardown),
|
ISC_TEST_ENTRY(rbt_remove)
|
||||||
cmocka_unit_test_setup_teardown(rbt_check_distance_random,
|
ISC_TEST_ENTRY(rbt_insert_and_remove)
|
||||||
_setup, _teardown),
|
ISC_TEST_ENTRY(rbt_findname)
|
||||||
cmocka_unit_test_setup_teardown(rbt_check_distance_ordered,
|
ISC_TEST_ENTRY(rbt_addname)
|
||||||
_setup, _teardown),
|
ISC_TEST_ENTRY(rbt_deletename)
|
||||||
cmocka_unit_test_setup_teardown(rbt_insert, _setup, _teardown),
|
ISC_TEST_ENTRY(rbt_nodechain)
|
||||||
cmocka_unit_test_setup_teardown(rbt_remove, _setup, _teardown),
|
ISC_TEST_ENTRY(rbtnode_namelen)
|
||||||
cmocka_unit_test_setup_teardown(rbt_insert_and_remove, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(rbt_findname, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(rbt_addname, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(rbt_deletename, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(rbt_nodechain, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(rbtnode_namelen, _setup,
|
|
||||||
_teardown),
|
|
||||||
#if defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__)
|
#if defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__)
|
||||||
cmocka_unit_test_setup_teardown(benchmark, _setup, _teardown),
|
ISC_TEST_ENTRY(benchmark)
|
||||||
#endif /* defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__) */
|
#endif /* defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__) */
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_LIST_END
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
ISC_TEST_MAIN
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -29,33 +27,18 @@
|
|||||||
#include <dns/rbt.h>
|
#include <dns/rbt.h>
|
||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
#include <dns/rdatastruct.h>
|
#include <dns/rdatastruct.h>
|
||||||
|
#define KEEP_BEFORE
|
||||||
#include "dnstest.h"
|
|
||||||
|
|
||||||
/* Include the main file */
|
/* Include the main file */
|
||||||
|
|
||||||
#include "../rbtdb.c"
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wshadow"
|
||||||
|
#undef CHECK
|
||||||
|
#include "rbtdb.c"
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
static int
|
#undef CHECK
|
||||||
_setup(void **state) {
|
#include <tests/dns.h>
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ownercase_vectors[12][2] = {
|
const char *ownercase_vectors[12][2] = {
|
||||||
{
|
{
|
||||||
@@ -157,8 +140,7 @@ ownercase_test_one(const char *str1, const char *str2) {
|
|||||||
return (dns_name_caseequal(name1, name2));
|
return (dns_name_caseequal(name1, name2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(ownercase) {
|
||||||
ownercase_test(void **state) {
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
for (size_t n = 0; n < ARRAY_SIZE(ownercase_vectors); n++) {
|
for (size_t n = 0; n < ARRAY_SIZE(ownercase_vectors); n++) {
|
||||||
@@ -172,8 +154,7 @@ ownercase_test(void **state) {
|
|||||||
assert_false(ownercase_test_one("\\216", "\\246"));
|
assert_false(ownercase_test_one("\\216", "\\246"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(setownercase) {
|
||||||
setownercase_test(void **state) {
|
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
rbtdb_nodelock_t node_locks[1];
|
rbtdb_nodelock_t node_locks[1];
|
||||||
dns_rbtdb_t rbtdb = { .node_locks = node_locks };
|
dns_rbtdb_t rbtdb = { .node_locks = node_locks };
|
||||||
@@ -222,24 +203,9 @@ setownercase_test(void **state) {
|
|||||||
assert_true(dns_name_caseequal(name1, name2));
|
assert_true(dns_name_caseequal(name1, name2));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(ownercase)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(setownercase)
|
||||||
cmocka_unit_test(ownercase_test),
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test(setownercase_test),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, _setup, _teardown));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -35,7 +33,7 @@
|
|||||||
|
|
||||||
#include <dns/rdata.h>
|
#include <dns/rdata.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static bool debug = false;
|
static bool debug = false;
|
||||||
|
|
||||||
@@ -56,27 +54,6 @@ struct textvsunknown {
|
|||||||
};
|
};
|
||||||
typedef struct textvsunknown textvsunknown_t;
|
typedef struct textvsunknown textvsunknown_t;
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An array of these structures is passed to check_text_ok().
|
* An array of these structures is passed to check_text_ok().
|
||||||
*/
|
*/
|
||||||
@@ -199,7 +176,7 @@ rdata_towire(dns_rdata_t *rdata, unsigned char *dst, size_t dstlen,
|
|||||||
/*
|
/*
|
||||||
* Try converting input data into uncompressed wire form.
|
* Try converting input data into uncompressed wire form.
|
||||||
*/
|
*/
|
||||||
dns_compress_init(&cctx, -1, dt_mctx);
|
dns_compress_init(&cctx, -1, mctx);
|
||||||
result = dns_rdata_towire(rdata, &cctx, &target);
|
result = dns_rdata_towire(rdata, &cctx, &target);
|
||||||
dns_compress_invalidate(&cctx);
|
dns_compress_invalidate(&cctx);
|
||||||
|
|
||||||
@@ -285,7 +262,7 @@ check_struct_conversions(dns_rdata_t *rdata, size_t structsize,
|
|||||||
char buf[1024];
|
char buf[1024];
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
|
|
||||||
rdata_struct = isc_mem_allocate(dt_mctx, structsize);
|
rdata_struct = isc_mem_allocate(mctx, structsize);
|
||||||
assert_non_null(rdata_struct);
|
assert_non_null(rdata_struct);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -365,7 +342,7 @@ check_struct_conversions(dns_rdata_t *rdata, size_t structsize,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_free(dt_mctx, rdata_struct);
|
isc_mem_free(mctx, rdata_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -892,8 +869,7 @@ key_required(void **state, dns_rdatatype_t type, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* APL RDATA manipulations */
|
/* APL RDATA manipulations */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(apl) {
|
||||||
apl(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
/* empty list */
|
/* empty list */
|
||||||
TEXT_VALID(""),
|
TEXT_VALID(""),
|
||||||
@@ -934,8 +910,6 @@ apl(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, true, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, true, dns_rdataclass_in,
|
||||||
dns_rdatatype_apl, sizeof(dns_rdata_in_apl_t));
|
dns_rdatatype_apl, sizeof(dns_rdata_in_apl_t));
|
||||||
}
|
}
|
||||||
@@ -977,8 +951,7 @@ apl(void **state) {
|
|||||||
*
|
*
|
||||||
* ATMA RRs cause no additional section processing.
|
* ATMA RRs cause no additional section processing.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(atma) {
|
||||||
atma(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_VALID("00"),
|
text_ok_t text_ok[] = { TEXT_VALID("00"),
|
||||||
TEXT_VALID_CHANGED("0.0", "00"),
|
TEXT_VALID_CHANGED("0.0", "00"),
|
||||||
/*
|
/*
|
||||||
@@ -1041,15 +1014,12 @@ atma(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_atma, sizeof(dns_rdata_in_atma_t));
|
dns_rdatatype_atma, sizeof(dns_rdata_in_atma_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AMTRELAY RDATA manipulations */
|
/* AMTRELAY RDATA manipulations */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(amtrelay) {
|
||||||
amtrelay(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
TEXT_INVALID(""), TEXT_INVALID("0"), TEXT_INVALID("0 0"),
|
TEXT_INVALID(""), TEXT_INVALID("0"), TEXT_INVALID("0 0"),
|
||||||
/* gateway type 0 */
|
/* gateway type 0 */
|
||||||
@@ -1121,14 +1091,11 @@ amtrelay(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_amtrelay, sizeof(dns_rdata_amtrelay_t));
|
dns_rdatatype_amtrelay, sizeof(dns_rdata_amtrelay_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(cdnskey) {
|
||||||
cdnskey(void **state) {
|
|
||||||
key_required(state, dns_rdatatype_cdnskey, sizeof(dns_rdata_cdnskey_t));
|
key_required(state, dns_rdatatype_cdnskey, sizeof(dns_rdata_cdnskey_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1196,8 +1163,7 @@ cdnskey(void **state) {
|
|||||||
* must understand the semantics associated with a bit in the Type Bit
|
* must understand the semantics associated with a bit in the Type Bit
|
||||||
* Map field that has been set to 1.
|
* Map field that has been set to 1.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(csync) {
|
||||||
csync(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_INVALID(""),
|
text_ok_t text_ok[] = { TEXT_INVALID(""),
|
||||||
TEXT_INVALID("0"),
|
TEXT_INVALID("0"),
|
||||||
TEXT_VALID("0 0"),
|
TEXT_VALID("0 0"),
|
||||||
@@ -1252,14 +1218,11 @@ csync(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_csync, sizeof(dns_rdata_csync_t));
|
dns_rdatatype_csync, sizeof(dns_rdata_csync_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dnskey) {
|
||||||
dnskey(void **state) {
|
|
||||||
key_required(state, dns_rdatatype_dnskey, sizeof(dns_rdata_dnskey_t));
|
key_required(state, dns_rdatatype_dnskey, sizeof(dns_rdata_dnskey_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1323,8 +1286,7 @@ dnskey(void **state) {
|
|||||||
* character ("-", ASCII 45). White space is permitted within Base64
|
* character ("-", ASCII 45). White space is permitted within Base64
|
||||||
* data.
|
* data.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(doa) {
|
||||||
doa(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
/*
|
/*
|
||||||
* Valid, non-empty DOA-DATA.
|
* Valid, non-empty DOA-DATA.
|
||||||
@@ -1471,8 +1433,6 @@ doa(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_doa, sizeof(dns_rdata_doa_t));
|
dns_rdatatype_doa, sizeof(dns_rdata_doa_t));
|
||||||
}
|
}
|
||||||
@@ -1539,8 +1499,7 @@ doa(void **state) {
|
|||||||
* DNSKEY RR size. As of the time of this writing, the only defined
|
* DNSKEY RR size. As of the time of this writing, the only defined
|
||||||
* digest algorithm is SHA-1, which produces a 20 octet digest.
|
* digest algorithm is SHA-1, which produces a 20 octet digest.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(ds) {
|
||||||
ds(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
/*
|
/*
|
||||||
* Invalid, empty record.
|
* Invalid, empty record.
|
||||||
@@ -1742,8 +1701,6 @@ ds(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_ds, sizeof(dns_rdata_ds_t));
|
dns_rdatatype_ds, sizeof(dns_rdata_ds_t));
|
||||||
}
|
}
|
||||||
@@ -1808,8 +1765,7 @@ ds(void **state) {
|
|||||||
* All fields are in network byte order ("big-endian", per [RFC1700],
|
* All fields are in network byte order ("big-endian", per [RFC1700],
|
||||||
* Data Notation).
|
* Data Notation).
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(edns_client_subnet) {
|
||||||
edns_client_subnet(void **state) {
|
|
||||||
wire_ok_t wire_ok[] = {
|
wire_ok_t wire_ok[] = {
|
||||||
/*
|
/*
|
||||||
* Option code with no content.
|
* Option code with no content.
|
||||||
@@ -1883,8 +1839,6 @@ edns_client_subnet(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(NULL, wire_ok, NULL, true, dns_rdataclass_in,
|
check_rdata(NULL, wire_ok, NULL, true, dns_rdataclass_in,
|
||||||
dns_rdatatype_opt, sizeof(dns_rdata_opt_t));
|
dns_rdatatype_opt, sizeof(dns_rdata_opt_t));
|
||||||
}
|
}
|
||||||
@@ -1898,8 +1852,7 @@ edns_client_subnet(void **state) {
|
|||||||
* significant. For readability, whitespace may be included in the value
|
* significant. For readability, whitespace may be included in the value
|
||||||
* field and should be ignored when reading a master file.
|
* field and should be ignored when reading a master file.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(eid) {
|
||||||
eid(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_VALID("AABBCC"),
|
text_ok_t text_ok[] = { TEXT_VALID("AABBCC"),
|
||||||
TEXT_VALID_CHANGED("AA bb cc", "AABBCC"),
|
TEXT_VALID_CHANGED("AA bb cc", "AABBCC"),
|
||||||
TEXT_INVALID("aab"),
|
TEXT_INVALID("aab"),
|
||||||
@@ -1913,8 +1866,6 @@ eid(void **state) {
|
|||||||
*/
|
*/
|
||||||
WIRE_SENTINEL() };
|
WIRE_SENTINEL() };
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_eid, sizeof(dns_rdata_in_eid_t));
|
dns_rdatatype_eid, sizeof(dns_rdata_in_eid_t));
|
||||||
}
|
}
|
||||||
@@ -1922,8 +1873,7 @@ eid(void **state) {
|
|||||||
/*
|
/*
|
||||||
* test that an oversized HIP record will be rejected
|
* test that an oversized HIP record will be rejected
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(hip) {
|
||||||
hip(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
/* RFC 8005 examples. */
|
/* RFC 8005 examples. */
|
||||||
TEXT_VALID_LOOP(0, "2 200100107B1A74DF365639CC39F1D578 "
|
TEXT_VALID_LOOP(0, "2 200100107B1A74DF365639CC39F1D578 "
|
||||||
@@ -1959,8 +1909,6 @@ hip(void **state) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill the rest of input buffer with compression pointers.
|
* Fill the rest of input buffer with compression pointers.
|
||||||
*/
|
*/
|
||||||
@@ -2037,8 +1985,7 @@ hip(void **state) {
|
|||||||
* as one or two <character-string>s, i.e., count followed by
|
* as one or two <character-string>s, i.e., count followed by
|
||||||
* characters.
|
* characters.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(isdn) {
|
||||||
isdn(void **state) {
|
|
||||||
wire_ok_t wire_ok[] = { /*
|
wire_ok_t wire_ok[] = { /*
|
||||||
* "".
|
* "".
|
||||||
*/
|
*/
|
||||||
@@ -2061,8 +2008,6 @@ isdn(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(NULL, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(NULL, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_isdn, sizeof(dns_rdata_isdn_t));
|
dns_rdatatype_isdn, sizeof(dns_rdata_isdn_t));
|
||||||
}
|
}
|
||||||
@@ -2070,8 +2015,7 @@ isdn(void **state) {
|
|||||||
/*
|
/*
|
||||||
* KEY tests.
|
* KEY tests.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(key) {
|
||||||
key(void **state) {
|
|
||||||
wire_ok_t wire_ok[] = {
|
wire_ok_t wire_ok[] = {
|
||||||
/*
|
/*
|
||||||
* RDATA is comprised of:
|
* RDATA is comprised of:
|
||||||
@@ -2144,8 +2088,6 @@ key(void **state) {
|
|||||||
TEXT_SENTINEL()
|
TEXT_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_key, sizeof(dns_rdata_key_t));
|
dns_rdatatype_key, sizeof(dns_rdata_key_t));
|
||||||
}
|
}
|
||||||
@@ -2153,8 +2095,7 @@ key(void **state) {
|
|||||||
/*
|
/*
|
||||||
* LOC tests.
|
* LOC tests.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(loc) {
|
||||||
loc(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
TEXT_VALID_CHANGED("0 N 0 E 0", "0 0 0.000 N 0 0 0.000 E 0.00m "
|
TEXT_VALID_CHANGED("0 N 0 E 0", "0 0 0.000 N 0 0 0.000 E 0.00m "
|
||||||
"1m 10000m 10m"),
|
"1m 10000m 10m"),
|
||||||
@@ -2209,8 +2150,6 @@ loc(void **state) {
|
|||||||
TEXT_SENTINEL()
|
TEXT_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, 0, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, 0, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_loc, sizeof(dns_rdata_loc_t));
|
dns_rdatatype_loc, sizeof(dns_rdata_loc_t));
|
||||||
}
|
}
|
||||||
@@ -2224,8 +2163,7 @@ loc(void **state) {
|
|||||||
* significant. For readability, whitespace may be included in the value
|
* significant. For readability, whitespace may be included in the value
|
||||||
* field and should be ignored when reading a master file.
|
* field and should be ignored when reading a master file.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nimloc) {
|
||||||
nimloc(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_VALID("AABBCC"),
|
text_ok_t text_ok[] = { TEXT_VALID("AABBCC"),
|
||||||
TEXT_VALID_CHANGED("AA bb cc", "AABBCC"),
|
TEXT_VALID_CHANGED("AA bb cc", "AABBCC"),
|
||||||
TEXT_INVALID("aab"),
|
TEXT_INVALID("aab"),
|
||||||
@@ -2239,8 +2177,6 @@ nimloc(void **state) {
|
|||||||
*/
|
*/
|
||||||
WIRE_SENTINEL() };
|
WIRE_SENTINEL() };
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_nimloc, sizeof(dns_rdata_in_nimloc_t));
|
dns_rdatatype_nimloc, sizeof(dns_rdata_in_nimloc_t));
|
||||||
}
|
}
|
||||||
@@ -2311,8 +2247,7 @@ nimloc(void **state) {
|
|||||||
* Bits representing pseudo-types MUST be clear, as they do not appear
|
* Bits representing pseudo-types MUST be clear, as they do not appear
|
||||||
* in zone data. If encountered, they MUST be ignored upon being read.
|
* in zone data. If encountered, they MUST be ignored upon being read.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nsec) {
|
||||||
nsec(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_INVALID(""), TEXT_INVALID("."),
|
text_ok_t text_ok[] = { TEXT_INVALID(""), TEXT_INVALID("."),
|
||||||
TEXT_VALID(". RRSIG"), TEXT_SENTINEL() };
|
TEXT_VALID(". RRSIG"), TEXT_SENTINEL() };
|
||||||
wire_ok_t wire_ok[] = { WIRE_INVALID(0x00), WIRE_INVALID(0x00, 0x00),
|
wire_ok_t wire_ok[] = { WIRE_INVALID(0x00), WIRE_INVALID(0x00, 0x00),
|
||||||
@@ -2320,8 +2255,6 @@ nsec(void **state) {
|
|||||||
WIRE_VALID(0x00, 0x00, 0x01, 0x02),
|
WIRE_VALID(0x00, 0x00, 0x01, 0x02),
|
||||||
WIRE_SENTINEL() };
|
WIRE_SENTINEL() };
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_nsec, sizeof(dns_rdata_nsec_t));
|
dns_rdatatype_nsec, sizeof(dns_rdata_nsec_t));
|
||||||
}
|
}
|
||||||
@@ -2331,8 +2264,7 @@ nsec(void **state) {
|
|||||||
*
|
*
|
||||||
* RFC 5155.
|
* RFC 5155.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nsec3) {
|
||||||
nsec3(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_INVALID(""),
|
text_ok_t text_ok[] = { TEXT_INVALID(""),
|
||||||
TEXT_INVALID("."),
|
TEXT_INVALID("."),
|
||||||
TEXT_INVALID(". RRSIG"),
|
TEXT_INVALID(". RRSIG"),
|
||||||
@@ -2352,15 +2284,12 @@ nsec3(void **state) {
|
|||||||
"AJHVGTICN6K0VDA53GCHFMT219SRRQLM"),
|
"AJHVGTICN6K0VDA53GCHFMT219SRRQLM"),
|
||||||
TEXT_SENTINEL() };
|
TEXT_SENTINEL() };
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, NULL, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, NULL, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_nsec3, sizeof(dns_rdata_nsec3_t));
|
dns_rdatatype_nsec3, sizeof(dns_rdata_nsec3_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NXT RDATA manipulations */
|
/* NXT RDATA manipulations */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(nxt) {
|
||||||
nxt(void **state) {
|
|
||||||
compare_ok_t compare_ok[] = {
|
compare_ok_t compare_ok[] = {
|
||||||
COMPARE("a. A SIG", "a. A SIG", 0),
|
COMPARE("a. A SIG", "a. A SIG", 0),
|
||||||
/*
|
/*
|
||||||
@@ -2379,14 +2308,11 @@ nxt(void **state) {
|
|||||||
COMPARE("b. A SIG AAAA", "b. A AAAA SIG", 0), COMPARE_SENTINEL()
|
COMPARE("b. A SIG AAAA", "b. A AAAA SIG", 0), COMPARE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(NULL, NULL, compare_ok, false, dns_rdataclass_in,
|
check_rdata(NULL, NULL, compare_ok, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_nxt, sizeof(dns_rdata_nxt_t));
|
dns_rdatatype_nxt, sizeof(dns_rdata_nxt_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(rkey) {
|
||||||
rkey(void **state) {
|
|
||||||
text_ok_t text_ok[] = { /*
|
text_ok_t text_ok[] = { /*
|
||||||
* Valid, flags set to 0 and a key is present.
|
* Valid, flags set to 0 and a key is present.
|
||||||
*/
|
*/
|
||||||
@@ -2420,108 +2346,8 @@ rkey(void **state) {
|
|||||||
dns_rdatatype_rkey, sizeof(dns_rdata_rkey_t));
|
dns_rdatatype_rkey, sizeof(dns_rdata_rkey_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* rrsig (sig) tests.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
sig_rrsig(void **state) {
|
|
||||||
wire_ok_t wire_ok[] = {
|
|
||||||
/*
|
|
||||||
* RDATA is comprised of:
|
|
||||||
*
|
|
||||||
* type covered: 2
|
|
||||||
* algorithm: 1
|
|
||||||
* labels: 1
|
|
||||||
* original ttl: 4
|
|
||||||
* signature expiration: 4
|
|
||||||
* time signed: 4
|
|
||||||
* key footprint: 2
|
|
||||||
* signer: variable
|
|
||||||
* signature: variable
|
|
||||||
* - if algorithm is PRIVATEDNS the algorithm name is embedded
|
|
||||||
* at the start of the signature
|
|
||||||
* - if algorithm is PRIVATEOID the algorithm OID is embedded
|
|
||||||
* at the start of the signature
|
|
||||||
*/
|
|
||||||
/* PRIVATEDNS example. */
|
|
||||||
WIRE_INVALID(0x00, 0x01, 253, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x06, 's', 'i', 'g', 'n', 'e', 'r',
|
|
||||||
0x00, 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
|
|
||||||
0x00),
|
|
||||||
/* PRIVATEDNS example. + sigdata */
|
|
||||||
WIRE_VALID(0x00, 0x01, 253, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x06, 's', 'i', 'g', 'n', 'e', 'r', 0x00, 0x07, 'e',
|
|
||||||
'x', 'a', 'm', 'p', 'l', 'e', 0x00, 0x00),
|
|
||||||
/* PRIVATEDNS compression pointer. */
|
|
||||||
WIRE_INVALID(0x00, 0x00, 0x00, 253, 0xc0, 0x00, 0x00),
|
|
||||||
/* PRIVATEOID */
|
|
||||||
WIRE_INVALID(0x00, 0x01, 254, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x06, 's', 'i', 'g', 'n', 'e', 'r',
|
|
||||||
0x00, 0x00),
|
|
||||||
/* PRIVATEOID 1.3.6.1.4.1.2495 */
|
|
||||||
WIRE_INVALID(0x00, 0x01, 254, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x06, 's', 'i', 'g', 'n', 'e', 'r',
|
|
||||||
0x00, 0x06, 0x07, 0x2b, 0x06, 0x01, 0x04, 0x01,
|
|
||||||
0x93, 0x3f),
|
|
||||||
/* PRIVATEOID 1.3.6.1.4.1.2495 + sigdata */
|
|
||||||
WIRE_VALID(0x00, 0x01, 254, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x06, 's', 'i', 'g', 'n', 'e', 'r', 0x00, 0x06, 0x07,
|
|
||||||
0x2b, 0x06, 0x01, 0x04, 0x01, 0x93, 0x3f, 0x00),
|
|
||||||
/* PRIVATEOID malformed OID - high-bit set on last octet */
|
|
||||||
WIRE_INVALID(0x00, 0x01, 254, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x06, 's', 'i', 'g', 'n', 'e', 'r',
|
|
||||||
0x00, 0x06, 0x07, 0x2b, 0x06, 0x01, 0x04, 0x01,
|
|
||||||
0x93, 0xbf, 0x00),
|
|
||||||
WIRE_SENTINEL()
|
|
||||||
};
|
|
||||||
text_ok_t text_ok[] = {
|
|
||||||
/* PRIVATEDNS example. */
|
|
||||||
TEXT_INVALID("A 253 1 0 19700101000001 19700101000000 0 "
|
|
||||||
"signer. B2V4YW1wbGUA"),
|
|
||||||
/* PRIVATEDNS example. + sigdata */
|
|
||||||
TEXT_VALID("A 253 1 0 19700101000001 19700101000000 0 signer. "
|
|
||||||
"B2V4YW1wbGUAAA=="),
|
|
||||||
/* PRIVATEDNS compression pointer. */
|
|
||||||
TEXT_INVALID("A 253 1 0 19700101000001 19700101000000 0 "
|
|
||||||
"signer. wAAA"),
|
|
||||||
/* PRIVATEOID */
|
|
||||||
TEXT_INVALID("A 254 1 0 19700101000001 19700101000000 0 "
|
|
||||||
"signer. AA=="),
|
|
||||||
/* PRIVATEOID 1.3.6.1.4.1.2495 */
|
|
||||||
TEXT_INVALID("A 254 1 0 19700101000001 19700101000000 0 "
|
|
||||||
"signer. BgcrBgEEAZM/"),
|
|
||||||
/* PRIVATEOID 1.3.6.1.4.1.2495 + sigdata */
|
|
||||||
TEXT_VALID("A 254 1 0 19700101000001 19700101000000 0 signer. "
|
|
||||||
"BgcrBgEEAZM/AA=="),
|
|
||||||
/* PRIVATEOID malformed OID - high-bit set on last octet */
|
|
||||||
TEXT_INVALID("A 254 1 0 19700101000001 19700101000000 0 "
|
|
||||||
"signer. BgcrBgEEAZO/AA=="),
|
|
||||||
/* PRIVATEOID malformed OID - wrong tag */
|
|
||||||
TEXT_INVALID("A 254 1 0 19700101000001 19700101000000 0 "
|
|
||||||
"signer. BwcrBgEEAZM/AA=="),
|
|
||||||
/*
|
|
||||||
* Sentinel.
|
|
||||||
*/
|
|
||||||
TEXT_SENTINEL()
|
|
||||||
};
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
|
||||||
dns_rdatatype_sig, sizeof(dns_rdata_sig_t));
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
|
||||||
dns_rdatatype_rrsig, sizeof(dns_rdata_rrsig_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SSHFP RDATA manipulations */
|
/* SSHFP RDATA manipulations */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(sshfp) {
|
||||||
sshfp(void **state) {
|
|
||||||
text_ok_t text_ok[] = { TEXT_INVALID(""), /* too short */
|
text_ok_t text_ok[] = { TEXT_INVALID(""), /* too short */
|
||||||
TEXT_INVALID("0"), /* reserved, too short */
|
TEXT_INVALID("0"), /* reserved, too short */
|
||||||
TEXT_VALID("0 0"), /* no finger print */
|
TEXT_VALID("0 0"), /* no finger print */
|
||||||
@@ -2598,8 +2424,6 @@ sshfp(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_sshfp, sizeof(dns_rdata_sshfp_t));
|
dns_rdatatype_sshfp, sizeof(dns_rdata_sshfp_t));
|
||||||
}
|
}
|
||||||
@@ -2643,8 +2467,7 @@ sshfp(void **state) {
|
|||||||
* port 25; if zero, SMTP service is not supported on the specified
|
* port 25; if zero, SMTP service is not supported on the specified
|
||||||
* address.
|
* address.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(wks) {
|
||||||
wks(void **state) {
|
|
||||||
text_ok_t text_ok[] = { /*
|
text_ok_t text_ok[] = { /*
|
||||||
* Valid, IPv4 address in dotted-quad form.
|
* Valid, IPv4 address in dotted-quad form.
|
||||||
*/
|
*/
|
||||||
@@ -2681,14 +2504,11 @@ wks(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_wks, sizeof(dns_rdata_in_wks_t));
|
dns_rdatatype_wks, sizeof(dns_rdata_in_wks_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(https_svcb) {
|
||||||
https_svcb(void **state) {
|
|
||||||
/*
|
/*
|
||||||
* Known keys: mandatory, apln, no-default-alpn, port,
|
* Known keys: mandatory, apln, no-default-alpn, port,
|
||||||
* ipv4hint, port, ipv6hint.
|
* ipv4hint, port, ipv6hint.
|
||||||
@@ -2932,8 +2752,6 @@ https_svcb(void **state) {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_svcb, sizeof(dns_rdata_in_svcb_t));
|
dns_rdatatype_svcb, sizeof(dns_rdata_in_svcb_t));
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
@@ -3030,8 +2848,7 @@ https_svcb(void **state) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(zonemd) {
|
||||||
zonemd(void **state) {
|
|
||||||
text_ok_t text_ok[] = {
|
text_ok_t text_ok[] = {
|
||||||
TEXT_INVALID(""),
|
TEXT_INVALID(""),
|
||||||
/* No digest scheme or digest type*/
|
/* No digest scheme or digest type*/
|
||||||
@@ -3198,16 +3015,13 @@ zonemd(void **state) {
|
|||||||
WIRE_SENTINEL()
|
WIRE_SENTINEL()
|
||||||
};
|
};
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
|
||||||
dns_rdatatype_zonemd, sizeof(dns_rdata_zonemd_t));
|
dns_rdatatype_zonemd, sizeof(dns_rdata_zonemd_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(atcname) {
|
||||||
atcname(void **state) {
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
UNUSED(state);
|
|
||||||
#define UNR "# Unexpected result from dns_rdatatype_atcname for type %u\n"
|
#define UNR "# Unexpected result from dns_rdatatype_atcname for type %u\n"
|
||||||
for (i = 0; i < 0xffffU; i++) {
|
for (i = 0; i < 0xffffU; i++) {
|
||||||
bool tf = dns_rdatatype_atcname((dns_rdatatype_t)i);
|
bool tf = dns_rdatatype_atcname((dns_rdatatype_t)i);
|
||||||
@@ -3231,10 +3045,9 @@ atcname(void **state) {
|
|||||||
#undef UNR
|
#undef UNR
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(atparent) {
|
||||||
atparent(void **state) {
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
UNUSED(state);
|
|
||||||
#define UNR "# Unexpected result from dns_rdatatype_atparent for type %u\n"
|
#define UNR "# Unexpected result from dns_rdatatype_atparent for type %u\n"
|
||||||
for (i = 0; i < 0xffffU; i++) {
|
for (i = 0; i < 0xffffU; i++) {
|
||||||
bool tf = dns_rdatatype_atparent((dns_rdatatype_t)i);
|
bool tf = dns_rdatatype_atparent((dns_rdatatype_t)i);
|
||||||
@@ -3256,10 +3069,8 @@ atparent(void **state) {
|
|||||||
#undef UNR
|
#undef UNR
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
ISC_RUN_TEST_IMPL(iszonecutauth) {
|
||||||
iszonecutauth(void **state) {
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
UNUSED(state);
|
|
||||||
#define UNR "# Unexpected result from dns_rdatatype_iszonecutauth for type %u\n"
|
#define UNR "# Unexpected result from dns_rdatatype_iszonecutauth for type %u\n"
|
||||||
for (i = 0; i < 0xffffU; i++) {
|
for (i = 0; i < 0xffffU; i++) {
|
||||||
bool tf = dns_rdatatype_iszonecutauth((dns_rdatatype_t)i);
|
bool tf = dns_rdatatype_iszonecutauth((dns_rdatatype_t)i);
|
||||||
@@ -3285,88 +3096,37 @@ iszonecutauth(void **state) {
|
|||||||
#undef UNR
|
#undef UNR
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(int argc, char **argv) {
|
|
||||||
const struct CMUnitTest tests[] = {
|
|
||||||
/* types */
|
|
||||||
cmocka_unit_test_setup_teardown(amtrelay, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(apl, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(atma, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(cdnskey, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(csync, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(dnskey, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(doa, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(ds, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(eid, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(hip, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(https_svcb, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(isdn, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(key, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(loc, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(nimloc, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(nsec, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(nsec3, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(nxt, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(rkey, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(sig_rrsig, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(sshfp, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(wks, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(zonemd, _setup, _teardown),
|
|
||||||
/* other tests */
|
|
||||||
cmocka_unit_test_setup_teardown(edns_client_subnet, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(atcname, NULL, NULL),
|
|
||||||
cmocka_unit_test_setup_teardown(atparent, NULL, NULL),
|
|
||||||
cmocka_unit_test_setup_teardown(iszonecutauth, NULL, NULL),
|
|
||||||
};
|
|
||||||
struct CMUnitTest selected[sizeof(tests) / sizeof(tests[0])];
|
|
||||||
size_t i;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
memset(selected, 0, sizeof(selected));
|
/* types */
|
||||||
|
ISC_TEST_ENTRY(amtrelay)
|
||||||
|
ISC_TEST_ENTRY(apl)
|
||||||
|
ISC_TEST_ENTRY(atma)
|
||||||
|
ISC_TEST_ENTRY(cdnskey)
|
||||||
|
ISC_TEST_ENTRY(csync)
|
||||||
|
ISC_TEST_ENTRY(dnskey)
|
||||||
|
ISC_TEST_ENTRY(doa)
|
||||||
|
ISC_TEST_ENTRY(ds)
|
||||||
|
ISC_TEST_ENTRY(eid)
|
||||||
|
ISC_TEST_ENTRY(hip)
|
||||||
|
ISC_TEST_ENTRY(https_svcb)
|
||||||
|
ISC_TEST_ENTRY(isdn)
|
||||||
|
ISC_TEST_ENTRY(key)
|
||||||
|
ISC_TEST_ENTRY(loc)
|
||||||
|
ISC_TEST_ENTRY(nimloc)
|
||||||
|
ISC_TEST_ENTRY(nsec)
|
||||||
|
ISC_TEST_ENTRY(nsec3)
|
||||||
|
ISC_TEST_ENTRY(nxt)
|
||||||
|
ISC_TEST_ENTRY(rkey)
|
||||||
|
ISC_TEST_ENTRY(sshfp)
|
||||||
|
ISC_TEST_ENTRY(wks)
|
||||||
|
ISC_TEST_ENTRY(zonemd)
|
||||||
|
|
||||||
while ((c = isc_commandline_parse(argc, argv, "dlt:")) != -1) {
|
/* other tests */
|
||||||
switch (c) {
|
ISC_TEST_ENTRY(edns_client_subnet)
|
||||||
case 'd':
|
ISC_TEST_ENTRY(atcname)
|
||||||
debug = true;
|
ISC_TEST_ENTRY(atparent)
|
||||||
break;
|
ISC_TEST_ENTRY(iszonecutauth)
|
||||||
case 'l':
|
ISC_TEST_LIST_END
|
||||||
for (i = 0; i < (sizeof(tests) / sizeof(tests[0])); i++)
|
|
||||||
{
|
|
||||||
if (tests[i].name != NULL) {
|
|
||||||
fprintf(stdout, "%s\n", tests[i].name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
case 't':
|
|
||||||
if (!cmocka_add_test_byname(
|
|
||||||
tests, isc_commandline_argument, selected))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "unknown test '%s'\n",
|
|
||||||
isc_commandline_argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selected[0].name != NULL) {
|
ISC_TEST_MAIN
|
||||||
return (cmocka_run_group_tests(selected, NULL, NULL));
|
|
||||||
} else {
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -29,32 +27,10 @@
|
|||||||
#include <dns/rdataset.h>
|
#include <dns/rdataset.h>
|
||||||
#include <dns/rdatastruct.h>
|
#include <dns/rdatastruct.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* test trimming of rdataset TTLs */
|
/* test trimming of rdataset TTLs */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(trimttl) {
|
||||||
trimttl(void **state) {
|
|
||||||
dns_rdataset_t rdataset, sigrdataset;
|
dns_rdataset_t rdataset, sigrdataset;
|
||||||
dns_rdata_rrsig_t rrsig;
|
dns_rdata_rrsig_t rrsig;
|
||||||
isc_stdtime_t ttltimenow, ttltimeexpire;
|
isc_stdtime_t ttltimenow, ttltimeexpire;
|
||||||
@@ -124,23 +100,8 @@ trimttl(void **state) {
|
|||||||
assert_int_equal(sigrdataset.ttl, 0);
|
assert_int_equal(sigrdataset.ttl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(trimttl)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(trimttl, _setup, _teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@@ -31,28 +29,7 @@
|
|||||||
|
|
||||||
#include <dns/stats.h>
|
#include <dns/stats.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_typestats(dns_stats_t *stats, dns_rdatatype_t type) {
|
set_typestats(dns_stats_t *stats, dns_rdatatype_t type) {
|
||||||
@@ -220,7 +197,7 @@ rdatasetstats(void **state, bool servestale) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_rdatasetstats_create(dt_mctx, &stats);
|
result = dns_rdatasetstats_create(mctx, &stats);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* First 255 types. */
|
/* First 255 types. */
|
||||||
@@ -272,41 +249,17 @@ rdatasetstats(void **state, bool servestale) {
|
|||||||
* Test that rdatasetstats counters are properly set when moving from
|
* Test that rdatasetstats counters are properly set when moving from
|
||||||
* active -> stale -> ancient.
|
* active -> stale -> ancient.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(active_stale_ancient) { rdatasetstats(state, true); }
|
||||||
test_rdatasetstats_active_stale_ancient(void **state) {
|
|
||||||
rdatasetstats(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test that rdatasetstats counters are properly set when moving from
|
* Test that rdatasetstats counters are properly set when moving from
|
||||||
* active -> ancient.
|
* active -> ancient.
|
||||||
*/
|
*/
|
||||||
static void
|
ISC_RUN_TEST_IMPL(active_ancient) { rdatasetstats(state, false); }
|
||||||
test_rdatasetstats_active_ancient(void **state) {
|
|
||||||
rdatasetstats(state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY(active_stale_ancient)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_ENTRY(active_ancient)
|
||||||
cmocka_unit_test_setup_teardown(
|
ISC_TEST_LIST_END
|
||||||
test_rdatasetstats_active_stale_ancient, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(
|
|
||||||
test_rdatasetstats_active_ancient, _setup, _teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -36,7 +34,7 @@
|
|||||||
#include <dns/resolver.h>
|
#include <dns/resolver.h>
|
||||||
#include <dns/view.h>
|
#include <dns/view.h>
|
||||||
|
|
||||||
#include "dnstest.h"
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static dns_dispatchmgr_t *dispatchmgr = NULL;
|
static dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||||
static dns_dispatch_t *dispatch = NULL;
|
static dns_dispatch_t *dispatch = NULL;
|
||||||
@@ -47,15 +45,12 @@ _setup(void **state) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_sockaddr_t local;
|
isc_sockaddr_t local;
|
||||||
|
|
||||||
UNUSED(state);
|
setup_managers(state);
|
||||||
|
|
||||||
result = dns_test_begin(NULL, true);
|
result = dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = dns_dispatchmgr_create(dt_mctx, netmgr, &dispatchmgr);
|
result = dns_test_makeview("view", true, &view);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = dns_test_makeview("view", &view);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
isc_sockaddr_any(&local);
|
isc_sockaddr_any(&local);
|
||||||
@@ -67,12 +62,11 @@ _setup(void **state) {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
_teardown(void **state) {
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_dispatch_detach(&dispatch);
|
dns_dispatch_detach(&dispatch);
|
||||||
dns_view_detach(&view);
|
dns_view_detach(&view);
|
||||||
dns_dispatchmgr_detach(&dispatchmgr);
|
dns_dispatchmgr_detach(&dispatchmgr);
|
||||||
dns_test_end();
|
|
||||||
|
teardown_managers(state);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -93,8 +87,7 @@ destroy_resolver(dns_resolver_t **resolverp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_resolver_create */
|
/* dns_resolver_create */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_resolver_create) {
|
||||||
create_test(void **state) {
|
|
||||||
dns_resolver_t *resolver = NULL;
|
dns_resolver_t *resolver = NULL;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -104,8 +97,7 @@ create_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_resolver_gettimeout */
|
/* dns_resolver_gettimeout */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_resolver_gettimeout) {
|
||||||
gettimeout_test(void **state) {
|
|
||||||
dns_resolver_t *resolver = NULL;
|
dns_resolver_t *resolver = NULL;
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
|
|
||||||
@@ -120,8 +112,7 @@ gettimeout_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_resolver_settimeout */
|
/* dns_resolver_settimeout */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_resolver_settimeout) {
|
||||||
settimeout_test(void **state) {
|
|
||||||
dns_resolver_t *resolver = NULL;
|
dns_resolver_t *resolver = NULL;
|
||||||
unsigned int default_timeout, timeout;
|
unsigned int default_timeout, timeout;
|
||||||
|
|
||||||
@@ -138,8 +129,7 @@ settimeout_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_resolver_settimeout */
|
/* dns_resolver_settimeout */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_resolver_settimeout_default) {
|
||||||
settimeout_default_test(void **state) {
|
|
||||||
dns_resolver_t *resolver = NULL;
|
dns_resolver_t *resolver = NULL;
|
||||||
unsigned int default_timeout, timeout;
|
unsigned int default_timeout, timeout;
|
||||||
|
|
||||||
@@ -161,8 +151,7 @@ settimeout_default_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_resolver_settimeout below minimum */
|
/* dns_resolver_settimeout below minimum */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_resolver_settimeout_belowmin) {
|
||||||
settimeout_belowmin_test(void **state) {
|
|
||||||
dns_resolver_t *resolver = NULL;
|
dns_resolver_t *resolver = NULL;
|
||||||
unsigned int default_timeout, timeout;
|
unsigned int default_timeout, timeout;
|
||||||
|
|
||||||
@@ -180,8 +169,7 @@ settimeout_belowmin_test(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns_resolver_settimeout over maximum */
|
/* dns_resolver_settimeout over maximum */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(dns_resolver_settimeout_overmax) {
|
||||||
settimeout_overmax_test(void **state) {
|
|
||||||
dns_resolver_t *resolver = NULL;
|
dns_resolver_t *resolver = NULL;
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
|
|
||||||
@@ -195,33 +183,15 @@ settimeout_overmax_test(void **state) {
|
|||||||
destroy_resolver(&resolver);
|
destroy_resolver(&resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
|
||||||
const struct CMUnitTest tests[] = {
|
|
||||||
cmocka_unit_test_setup_teardown(create_test, _setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(gettimeout_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(settimeout_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(settimeout_default_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(settimeout_belowmin_test,
|
|
||||||
_setup, _teardown),
|
|
||||||
cmocka_unit_test_setup_teardown(settimeout_overmax_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_ENTRY_CUSTOM(dns_resolver_create, _setup, _teardown)
|
||||||
}
|
ISC_TEST_ENTRY_CUSTOM(dns_resolver_gettimeout, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_resolver_settimeout, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_resolver_settimeout_default, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_resolver_settimeout_belowmin, _setup, _teardown)
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(dns_resolver_settimeout_overmax, _setup, _teardown)
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
ISC_TEST_LIST_END
|
||||||
|
|
||||||
#include <stdio.h>
|
ISC_TEST_MAIN
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -28,26 +26,30 @@
|
|||||||
#include <isc/print.h>
|
#include <isc/print.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
#include "../dst_internal.h"
|
#include "dst_internal.h"
|
||||||
#include "dnstest.h"
|
|
||||||
|
#include <tests/dns.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_setup(void **state) {
|
setup_test(void **state) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
result = dst_lib_init(mctx, NULL);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
teardown_test(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
dns_test_end();
|
dst_lib_destroy();
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -131,8 +133,7 @@ static unsigned char sigsha512[512] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* RSA verify */
|
/* RSA verify */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(isc_rsa_verify) {
|
||||||
isc_rsa_verify_test(void **state) {
|
|
||||||
isc_result_t ret;
|
isc_result_t ret;
|
||||||
dns_fixedname_t fname;
|
dns_fixedname_t fname;
|
||||||
isc_buffer_t buf;
|
isc_buffer_t buf;
|
||||||
@@ -150,12 +151,12 @@ isc_rsa_verify_test(void **state) {
|
|||||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||||
|
|
||||||
ret = dst_key_fromfile(name, 29235, DST_ALG_RSASHA1, DST_TYPE_PUBLIC,
|
ret = dst_key_fromfile(name, 29235, DST_ALG_RSASHA1, DST_TYPE_PUBLIC,
|
||||||
"./", dt_mctx, &key);
|
"./", mctx, &key);
|
||||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||||
|
|
||||||
/* RSASHA1 */
|
/* RSASHA1 */
|
||||||
|
|
||||||
ret = dst_context_create(key, dt_mctx, DNS_LOGCATEGORY_DNSSEC, false, 0,
|
ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, false, 0,
|
||||||
&ctx);
|
&ctx);
|
||||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -175,7 +176,7 @@ isc_rsa_verify_test(void **state) {
|
|||||||
|
|
||||||
key->key_alg = DST_ALG_RSASHA256;
|
key->key_alg = DST_ALG_RSASHA256;
|
||||||
|
|
||||||
ret = dst_context_create(key, dt_mctx, DNS_LOGCATEGORY_DNSSEC, false, 0,
|
ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, false, 0,
|
||||||
&ctx);
|
&ctx);
|
||||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ isc_rsa_verify_test(void **state) {
|
|||||||
|
|
||||||
key->key_alg = DST_ALG_RSASHA512;
|
key->key_alg = DST_ALG_RSASHA512;
|
||||||
|
|
||||||
ret = dst_context_create(key, dt_mctx, DNS_LOGCATEGORY_DNSSEC, false, 0,
|
ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, false, 0,
|
||||||
&ctx);
|
&ctx);
|
||||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||||
|
|
||||||
@@ -214,24 +215,8 @@ isc_rsa_verify_test(void **state) {
|
|||||||
dst_key_free(&key);
|
dst_key_free(&key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(isc_rsa_verify, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(isc_rsa_verify_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAVE_CMOCKA */
|
|
@@ -11,8 +11,6 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CMOCKA
|
|
||||||
|
|
||||||
#include <sched.h> /* IWYU pragma: keep */
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -45,29 +43,9 @@
|
|||||||
|
|
||||||
#include <dst/dst.h>
|
#include <dst/dst.h>
|
||||||
|
|
||||||
#include "../zone_p.h"
|
#include "zone_p.h"
|
||||||
#include "dnstest.h"
|
|
||||||
|
|
||||||
static int
|
#include <tests/dns.h>
|
||||||
_setup(void **state) {
|
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
result = dns_test_begin(NULL, false);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_teardown(void **state) {
|
|
||||||
UNUSED(state);
|
|
||||||
|
|
||||||
dns_test_end();
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Structure characterizing a single diff tuple in the dns_diff_t structure
|
* Structure characterizing a single diff tuple in the dns_diff_t structure
|
||||||
@@ -95,6 +73,30 @@ typedef struct {
|
|||||||
* */
|
* */
|
||||||
} updatesigs_test_params_t;
|
} updatesigs_test_params_t;
|
||||||
|
|
||||||
|
static int
|
||||||
|
setup_test(void **state) {
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
UNUSED(state);
|
||||||
|
|
||||||
|
result = dst_lib_init(mctx, NULL);
|
||||||
|
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
teardown_test(void **state) {
|
||||||
|
UNUSED(state);
|
||||||
|
|
||||||
|
dst_lib_destroy();
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Check whether the 'found' tuple matches the 'expected' tuple. 'found' is
|
* Check whether the 'found' tuple matches the 'expected' tuple. 'found' is
|
||||||
* the 'index'th tuple output by dns__zone_updatesigs() in test 'test'.
|
* the 'index'th tuple output by dns__zone_updatesigs() in test 'test'.
|
||||||
@@ -126,8 +128,7 @@ compare_tuples(const zonediff_t *expected, dns_difftuple_t *found,
|
|||||||
* Check owner name.
|
* Check owner name.
|
||||||
*/
|
*/
|
||||||
expected_name = dns_fixedname_initname(&expected_fname);
|
expected_name = dns_fixedname_initname(&expected_fname);
|
||||||
result = dns_name_fromstring(expected_name, expected->owner, 0,
|
result = dns_name_fromstring(expected_name, expected->owner, 0, mctx);
|
||||||
dt_mctx);
|
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
dns_name_format(&found->name, found_name, sizeof(found_name));
|
dns_name_format(&found->name, found_name, sizeof(found_name));
|
||||||
assert_true(dns_name_equal(expected_name, &found->name));
|
assert_true(dns_name_equal(expected_name, &found->name));
|
||||||
@@ -235,7 +236,7 @@ updatesigs_test(const updatesigs_test_params_t *test, dns_zone_t *zone,
|
|||||||
/*
|
/*
|
||||||
* Initialize the structure dns__zone_updatesigs() will modify.
|
* Initialize the structure dns__zone_updatesigs() will modify.
|
||||||
*/
|
*/
|
||||||
dns_diff_init(dt_mctx, &zone_diff);
|
dns_diff_init(mctx, &zone_diff);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check whether dns__zone_updatesigs() behaves as expected.
|
* Check whether dns__zone_updatesigs() behaves as expected.
|
||||||
@@ -287,8 +288,7 @@ updatesigs_test(const updatesigs_test_params_t *test, dns_zone_t *zone,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dns__zone_updatesigs() tests */
|
/* dns__zone_updatesigs() tests */
|
||||||
static void
|
ISC_RUN_TEST_IMPL(updatesigs_next) {
|
||||||
updatesigs_next_test(void **state) {
|
|
||||||
dst_key_t *zone_keys[DNS_MAXZONEKEYS];
|
dst_key_t *zone_keys[DNS_MAXZONEKEYS];
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
@@ -314,8 +314,8 @@ updatesigs_next_test(void **state) {
|
|||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_stdtime_get(&now);
|
||||||
result = dns__zone_findkeys(zone, db, NULL, now, dt_mctx,
|
result = dns__zone_findkeys(zone, db, NULL, now, mctx, DNS_MAXZONEKEYS,
|
||||||
DNS_MAXZONEKEYS, zone_keys, &nkeys);
|
zone_keys, &nkeys);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
assert_int_equal(nkeys, 2);
|
assert_int_equal(nkeys, 2);
|
||||||
|
|
||||||
@@ -438,24 +438,8 @@ updatesigs_next_test(void **state) {
|
|||||||
dns_zone_detach(&zone);
|
dns_zone_detach(&zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
ISC_TEST_LIST_START
|
||||||
main(void) {
|
ISC_TEST_ENTRY_CUSTOM(updatesigs_next, setup_test, teardown_test)
|
||||||
const struct CMUnitTest tests[] = {
|
ISC_TEST_LIST_END
|
||||||
cmocka_unit_test_setup_teardown(updatesigs_next_test, _setup,
|
|
||||||
_teardown),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
ISC_TEST_MAIN
|
||||||
}
|
|
||||||
|
|
||||||
#else /* HAVE_CMOCKA */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
printf("1..0 # Skipped: cmocka not available\n");
|
|
||||||
return (SKIPPED_TEST_EXIT_CODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* if HAVE_CMOCKA */
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user