2012-04-27 16:07:24 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
2012-04-27 16:07:24 -07:00
|
|
|
* 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/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
2012-04-27 16:07:24 -07:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
|
|
|
*/
|
|
|
|
|
2018-03-28 14:19:37 +02:00
|
|
|
#include <inttypes.h>
|
Include <sched.h> where necessary for musl libc
All unit tests define the UNIT_TESTING macro, which causes <cmocka.h> to
replace malloc(), calloc(), realloc(), and free() with its own functions
tracking memory allocations. In order for this not to break
compilation, the system header declaring the prototypes for these
standard functions must be included before <cmocka.h>.
Normally, these prototypes are only present in <stdlib.h>, so we make
sure it is included before <cmocka.h>. However, musl libc also defines
the prototypes for calloc() and free() in <sched.h>, which is included
by <pthread.h>, which is included e.g. by <isc/mutex.h>. Thus, unit
tests including "dnstest.h" (which includes <isc/mem.h>, which includes
<isc/mutex.h>) after <cmocka.h> will not compile with musl libc as for
these programs, <sched.h> will be included after <cmocka.h>.
Always including <cmocka.h> after all other header files is not a
feasible solution as that causes the mock assertion macros defined in
<isc/util.h> to mangle the contents of <cmocka.h>, thus breaking
compilation. We cannot really use the __noreturn__ or analyzer_noreturn
attributes with cmocka assertion functions because they do return if the
tested condition is true. The problem is that what BIND unit tests do
is incompatible with Clang Static Analyzer's assumptions: since we use
cmocka, our custom assertion handlers are present in a shared library
(i.e. it is the cmocka library that checks the assertion condition, not
a macro in unit test code). Redefining cmocka's assertion macros in
<isc/util.h> is an ugly hack to overcome that problem - unfortunately,
this is the only way we can think of to make Clang Static Analyzer
properly process unit test code. Giving up on Clang Static Analyzer
being able to properly process unit test code is not a satisfactory
solution.
Undefining _GNU_SOURCE for unit test code could work around the problem
(musl libc's <sched.h> only defines the prototypes for calloc() and
free() when _GNU_SOURCE is defined), but doing that could introduce
discrepancies for unit tests including entire *.c files, so it is also
not a good solution.
All in all, including <sched.h> before <cmocka.h> for all affected unit
tests seems to be the most benign way of working around this musl libc
quirk. While quite an ugly solution, it achieves our goals here, which
are to keep the benefit of proper static analysis of unit test code and
to fix compilation against musl libc.
2019-07-30 21:08:40 +02:00
|
|
|
#include <sched.h> /* IWYU pragma: keep */
|
2018-10-26 08:46:28 -07:00
|
|
|
#include <setjmp.h>
|
|
|
|
#include <stdarg.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2018-10-26 08:46:28 -07:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2012-04-27 16:07:24 -07:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-10-26 08:46:28 -07:00
|
|
|
#define UNIT_TESTING
|
|
|
|
#include <cmocka.h>
|
2018-03-28 14:19:37 +02:00
|
|
|
|
2012-04-27 16:07:24 -07:00
|
|
|
#include <isc/buffer.h>
|
2025-02-04 13:17:31 +01:00
|
|
|
#include <isc/lib.h>
|
2021-01-14 13:02:57 -08:00
|
|
|
#include <isc/managers.h>
|
2019-07-01 15:19:29 +02:00
|
|
|
#include <isc/refcount.h>
|
2022-09-19 12:33:32 +00:00
|
|
|
#include <isc/tls.h>
|
2018-10-26 08:46:28 -07:00
|
|
|
#include <isc/util.h>
|
2022-04-27 17:41:47 +02:00
|
|
|
#include <isc/uv.h>
|
2012-04-27 16:07:24 -07:00
|
|
|
|
|
|
|
#include <dns/dispatch.h>
|
2025-02-04 13:17:31 +01:00
|
|
|
#include <dns/lib.h>
|
2012-04-27 16:07:24 -07:00
|
|
|
#include <dns/name.h>
|
|
|
|
#include <dns/view.h>
|
|
|
|
|
2022-05-03 11:37:31 +02:00
|
|
|
#include <tests/dns.h>
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2021-01-14 13:02:57 -08:00
|
|
|
/* Timeouts in miliseconds */
|
2024-03-28 16:22:11 +02:00
|
|
|
#define T_SERVER_INIT (120 * 1000)
|
|
|
|
#define T_SERVER_IDLE (120 * 1000)
|
|
|
|
#define T_SERVER_KEEPALIVE (120 * 1000)
|
|
|
|
#define T_SERVER_ADVERTISED (120 * 1000)
|
2025-02-18 14:44:29 +00:00
|
|
|
#define T_SERVER_PRIMARIES (120 * 1000)
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2024-10-29 16:25:36 +00:00
|
|
|
#define T_CLIENT_INIT (60 * 1000)
|
|
|
|
#define T_CLIENT_IDLE (60 * 1000)
|
|
|
|
#define T_CLIENT_KEEPALIVE (60 * 1000)
|
|
|
|
#define T_CLIENT_ADVERTISED (60 * 1000)
|
2025-02-18 14:44:29 +00:00
|
|
|
#define T_CLIENT_PRIMARIES (60 * 1000)
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2024-03-28 16:22:11 +02:00
|
|
|
#define T_CLIENT_CONNECT (30 * 1000)
|
|
|
|
|
|
|
|
/* For checks which are expected to timeout */
|
2024-10-30 09:23:33 +00:00
|
|
|
#define T_CLIENT_SHORT (10 * 1000)
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* dns_dispatchset_t *dset = NULL; */
|
2021-08-04 13:14:11 -07:00
|
|
|
static isc_sockaddr_t udp_server_addr;
|
|
|
|
static isc_sockaddr_t udp_connect_addr;
|
|
|
|
static isc_sockaddr_t tcp_server_addr;
|
|
|
|
static isc_sockaddr_t tcp_connect_addr;
|
2022-09-19 12:33:32 +00:00
|
|
|
static isc_sockaddr_t tls_server_addr;
|
|
|
|
static isc_sockaddr_t tls_connect_addr;
|
|
|
|
|
|
|
|
static isc_tlsctx_cache_t *tls_tlsctx_client_cache = NULL;
|
|
|
|
static isc_tlsctx_t *tls_listen_tlsctx = NULL;
|
|
|
|
static const char *tls_name_str = "ephemeral";
|
|
|
|
static dns_transport_t *tls_transport = NULL;
|
|
|
|
static dns_transport_list_t *transport_list = NULL;
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
static isc_nmsocket_t *sock = NULL;
|
|
|
|
|
|
|
|
static isc_nm_t *connect_nm = NULL;
|
|
|
|
|
2021-08-04 13:14:11 -07:00
|
|
|
const struct in6_addr in6addr_blackhole = { { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 1 } } };
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
struct {
|
|
|
|
uint8_t rbuf[12];
|
|
|
|
isc_region_t region;
|
|
|
|
uint8_t message[12];
|
|
|
|
} testdata;
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
typedef struct {
|
|
|
|
dns_dispatchmgr_t *dispatchmgr;
|
|
|
|
dns_dispatch_t *dispatch;
|
|
|
|
dns_dispentry_t *dispentry;
|
|
|
|
uint16_t id;
|
|
|
|
} test_dispatch_t;
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dispatch_done(test_dispatch_t *test) {
|
|
|
|
dns_dispatch_done(&test->dispentry);
|
|
|
|
dns_dispatch_detach(&test->dispatch);
|
|
|
|
dns_dispatchmgr_detach(&test->dispatchmgr);
|
|
|
|
isc_mem_put(mctx, test, sizeof(*test));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_dispatch_shutdown(test_dispatch_t *test) {
|
|
|
|
test_dispatch_done(test);
|
|
|
|
isc_loopmgr_shutdown(loopmgr);
|
|
|
|
}
|
|
|
|
|
2021-01-14 13:02:57 -08:00
|
|
|
static int
|
|
|
|
setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
|
|
|
|
socklen_t addrlen = sizeof(*addr);
|
2022-07-26 13:03:45 +02:00
|
|
|
uv_os_sock_t fd;
|
2021-01-14 13:02:57 -08:00
|
|
|
int r;
|
|
|
|
|
|
|
|
isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
|
|
|
|
|
|
|
|
fd = socket(AF_INET6, family, 0);
|
|
|
|
if (fd < 0) {
|
|
|
|
perror("setup_ephemeral_port: socket()");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = bind(fd, (const struct sockaddr *)&addr->type.sa,
|
|
|
|
sizeof(addr->type.sin6));
|
|
|
|
if (r != 0) {
|
|
|
|
perror("setup_ephemeral_port: bind()");
|
|
|
|
close(fd);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = getsockname(fd, (struct sockaddr *)&addr->type.sa, &addrlen);
|
|
|
|
if (r != 0) {
|
|
|
|
perror("setup_ephemeral_port: getsockname()");
|
|
|
|
close(fd);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if IPV6_RECVERR
|
|
|
|
#define setsockopt_on(socket, level, name) \
|
|
|
|
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
|
|
|
|
|
|
|
|
r = setsockopt_on(fd, IPPROTO_IPV6, IPV6_RECVERR);
|
|
|
|
if (r != 0) {
|
|
|
|
perror("setup_ephemeral_port");
|
|
|
|
close(fd);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return fd;
|
|
|
|
}
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2018-10-26 08:46:28 -07:00
|
|
|
static int
|
2022-07-26 13:03:45 +02:00
|
|
|
setup_test(void **state) {
|
2025-02-21 13:36:57 -08:00
|
|
|
isc_buffer_t namesrc;
|
|
|
|
dns_fixedname_t ft;
|
|
|
|
dns_name_t *tls_name = dns_fixedname_initname(&ft);
|
2022-09-19 12:33:32 +00:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
uv_os_sock_t socket = -1;
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
/* Create just 1 loop for this test */
|
|
|
|
isc_loopmgr_create(mctx, 1, &loopmgr);
|
|
|
|
mainloop = isc_loop_main(loopmgr);
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
setup_netmgr(state);
|
|
|
|
|
|
|
|
isc_netmgr_create(mctx, loopmgr, &connect_nm);
|
2018-10-26 08:46:28 -07:00
|
|
|
|
2021-08-04 13:14:11 -07:00
|
|
|
udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
|
|
|
isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
|
|
|
|
|
|
|
|
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
|
|
|
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_loopback, 0);
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2022-09-19 12:33:32 +00:00
|
|
|
tls_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
|
|
|
isc_sockaddr_fromin6(&tls_connect_addr, &in6addr_loopback, 0);
|
|
|
|
|
2021-08-04 13:14:11 -07:00
|
|
|
udp_server_addr = (isc_sockaddr_t){ .length = 0 };
|
2022-07-26 13:03:45 +02:00
|
|
|
socket = setup_ephemeral_port(&udp_server_addr, SOCK_DGRAM);
|
|
|
|
if (socket < 0) {
|
2021-08-04 13:14:11 -07:00
|
|
|
return -1;
|
|
|
|
}
|
2022-07-26 13:03:45 +02:00
|
|
|
close(socket);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
|
|
|
tcp_server_addr = (isc_sockaddr_t){ .length = 0 };
|
2022-07-26 13:03:45 +02:00
|
|
|
socket = setup_ephemeral_port(&tcp_server_addr, SOCK_STREAM);
|
|
|
|
if (socket < 0) {
|
2021-01-14 13:02:57 -08:00
|
|
|
return -1;
|
|
|
|
}
|
2022-07-26 13:03:45 +02:00
|
|
|
close(socket);
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2022-09-19 12:33:32 +00:00
|
|
|
tls_server_addr = (isc_sockaddr_t){ .length = 0 };
|
|
|
|
socket = setup_ephemeral_port(&tls_server_addr, SOCK_STREAM);
|
|
|
|
if (socket < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
close(socket);
|
|
|
|
|
2025-03-11 12:10:51 +00:00
|
|
|
isc_nm_setinitialtimeout(netmgr, T_SERVER_INIT);
|
|
|
|
isc_nm_setprimariestimeout(netmgr, T_SERVER_PRIMARIES);
|
|
|
|
isc_nm_setidletimeout(netmgr, T_SERVER_IDLE);
|
|
|
|
isc_nm_setkeepalivetimeout(netmgr, T_SERVER_KEEPALIVE);
|
|
|
|
isc_nm_setadvertisedtimeout(netmgr, T_SERVER_ADVERTISED);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Use shorter client-side timeouts, to ensure that clients
|
|
|
|
* time out before the server.
|
|
|
|
*/
|
2025-03-11 12:10:51 +00:00
|
|
|
isc_nm_setinitialtimeout(connect_nm, T_CLIENT_INIT);
|
|
|
|
isc_nm_setprimariestimeout(connect_nm, T_CLIENT_PRIMARIES);
|
|
|
|
isc_nm_setidletimeout(connect_nm, T_CLIENT_IDLE);
|
|
|
|
isc_nm_setkeepalivetimeout(connect_nm, T_CLIENT_KEEPALIVE);
|
|
|
|
isc_nm_setadvertisedtimeout(connect_nm, T_CLIENT_ADVERTISED);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
memset(testdata.rbuf, 0, sizeof(testdata.rbuf));
|
|
|
|
testdata.region.base = testdata.rbuf;
|
|
|
|
testdata.region.length = sizeof(testdata.rbuf);
|
|
|
|
memset(testdata.message, 0, sizeof(testdata.message));
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2022-12-22 19:54:16 +02:00
|
|
|
isc_tlsctx_cache_create(mctx, &tls_tlsctx_client_cache);
|
2022-09-19 12:33:32 +00:00
|
|
|
|
|
|
|
if (isc_tlsctx_createserver(NULL, NULL, &tls_listen_tlsctx) !=
|
2022-11-02 19:33:14 +01:00
|
|
|
ISC_R_SUCCESS)
|
|
|
|
{
|
2022-09-19 12:33:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_buffer_constinit(&namesrc, tls_name_str, strlen(tls_name_str));
|
|
|
|
isc_buffer_add(&namesrc, strlen(tls_name_str));
|
2025-02-21 13:36:57 -08:00
|
|
|
if (dns_name_fromtext(tls_name, &namesrc, dns_rootname,
|
2025-02-22 00:11:38 -08:00
|
|
|
DNS_NAME_DOWNCASE) != ISC_R_SUCCESS)
|
2022-09-19 12:33:32 +00:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
transport_list = dns_transport_list_new(mctx);
|
2025-02-21 13:36:57 -08:00
|
|
|
tls_transport = dns_transport_new(tls_name, DNS_TRANSPORT_TLS,
|
2022-09-19 12:33:32 +00:00
|
|
|
transport_list);
|
|
|
|
dns_transport_set_tlsname(tls_transport, tls_name_str);
|
|
|
|
|
2018-10-26 08:46:28 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2022-07-26 13:03:45 +02:00
|
|
|
teardown_test(void **state) {
|
2022-09-19 12:33:32 +00:00
|
|
|
dns_transport_list_detach(&transport_list);
|
|
|
|
isc_tlsctx_cache_detach(&tls_tlsctx_client_cache);
|
|
|
|
isc_tlsctx_free(&tls_listen_tlsctx);
|
|
|
|
|
2025-07-09 11:01:15 +02:00
|
|
|
isc_nm_detach(&connect_nm);
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
teardown_netmgr(state);
|
|
|
|
teardown_loopmgr(state);
|
2018-10-26 08:46:28 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-27 16:07:24 -07:00
|
|
|
static isc_result_t
|
2023-10-23 12:26:50 +02:00
|
|
|
make_dispatchset(dns_dispatchmgr_t *dispatchmgr, unsigned int ndisps,
|
|
|
|
dns_dispatchset_t **dsetp) {
|
2012-04-27 16:07:24 -07:00
|
|
|
isc_result_t result;
|
|
|
|
isc_sockaddr_t any;
|
|
|
|
dns_dispatch_t *disp = NULL;
|
|
|
|
|
|
|
|
isc_sockaddr_any(&any);
|
2021-08-04 13:14:11 -07:00
|
|
|
result = dns_dispatch_createudp(dispatchmgr, &any, &disp);
|
2012-04-27 16:07:24 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
return result;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
result = dns_dispatchset_create(mctx, disp, dsetp, ndisps);
|
2012-04-27 16:07:24 -07:00
|
|
|
dns_dispatch_detach(&disp);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-10-26 08:46:28 -07:00
|
|
|
/* create dispatch set */
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatchset_create) {
|
|
|
|
dns_dispatchset_t *dset = NULL;
|
2012-04-27 16:07:24 -07:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatchmgr_t *dispatchmgr = NULL;
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
UNUSED(arg);
|
|
|
|
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
|
|
|
&dispatchmgr);
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = make_dispatchset(dispatchmgr, 1, &dset);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2022-07-26 13:03:45 +02:00
|
|
|
dns_dispatchset_destroy(&dset);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = make_dispatchset(dispatchmgr, 10, &dset);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2022-07-26 13:03:45 +02:00
|
|
|
dns_dispatchset_destroy(&dset);
|
|
|
|
|
|
|
|
dns_dispatchmgr_detach(&dispatchmgr);
|
|
|
|
|
|
|
|
isc_loopmgr_shutdown(loopmgr);
|
2012-04-27 16:07:24 -07:00
|
|
|
}
|
|
|
|
|
2023-09-15 11:36:28 +02:00
|
|
|
/* test dispatch set per-loop dispatch */
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatchset_get) {
|
2012-04-27 16:07:24 -07:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatchmgr_t *dispatchmgr = NULL;
|
2022-07-26 13:03:45 +02:00
|
|
|
dns_dispatchset_t *dset = NULL;
|
2012-04-27 16:07:24 -07:00
|
|
|
dns_dispatch_t *d1, *d2, *d3, *d4, *d5;
|
2025-06-04 17:54:20 +02:00
|
|
|
isc_tid_t tid_saved;
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
UNUSED(arg);
|
|
|
|
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
|
|
|
&dispatchmgr);
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = make_dispatchset(dispatchmgr, 1, &dset);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
|
|
|
d1 = dns_dispatchset_get(dset);
|
|
|
|
d2 = dns_dispatchset_get(dset);
|
|
|
|
d3 = dns_dispatchset_get(dset);
|
|
|
|
d4 = dns_dispatchset_get(dset);
|
|
|
|
d5 = dns_dispatchset_get(dset);
|
|
|
|
|
2020-11-26 13:10:40 +01:00
|
|
|
assert_ptr_equal(d1, d2);
|
|
|
|
assert_ptr_equal(d2, d3);
|
|
|
|
assert_ptr_equal(d3, d4);
|
|
|
|
assert_ptr_equal(d4, d5);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
dns_dispatchset_destroy(&dset);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = make_dispatchset(dispatchmgr, 4, &dset);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2023-09-15 11:36:28 +02:00
|
|
|
/*
|
|
|
|
* Temporarily modify and then restore the current thread's
|
|
|
|
* ID value, in order to confirm that different threads get
|
|
|
|
* different dispatch sets but the same thread gets the same
|
|
|
|
* one.
|
|
|
|
*/
|
|
|
|
tid_saved = isc__tid_local;
|
2012-04-27 16:07:24 -07:00
|
|
|
d1 = dns_dispatchset_get(dset);
|
2023-09-15 11:36:28 +02:00
|
|
|
isc__tid_local++;
|
2012-04-27 16:07:24 -07:00
|
|
|
d2 = dns_dispatchset_get(dset);
|
2023-09-15 11:36:28 +02:00
|
|
|
isc__tid_local++;
|
2012-04-27 16:07:24 -07:00
|
|
|
d3 = dns_dispatchset_get(dset);
|
2023-09-15 11:36:28 +02:00
|
|
|
isc__tid_local++;
|
2012-04-27 16:07:24 -07:00
|
|
|
d4 = dns_dispatchset_get(dset);
|
2023-09-15 11:36:28 +02:00
|
|
|
isc__tid_local = tid_saved;
|
2012-04-27 16:07:24 -07:00
|
|
|
d5 = dns_dispatchset_get(dset);
|
|
|
|
|
2020-11-26 13:10:40 +01:00
|
|
|
assert_ptr_equal(d1, d5);
|
|
|
|
assert_ptr_not_equal(d1, d2);
|
|
|
|
assert_ptr_not_equal(d2, d3);
|
|
|
|
assert_ptr_not_equal(d3, d4);
|
|
|
|
assert_ptr_not_equal(d4, d5);
|
2012-04-27 16:07:24 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
dns_dispatchset_destroy(&dset);
|
|
|
|
dns_dispatchmgr_detach(&dispatchmgr);
|
|
|
|
isc_loopmgr_shutdown(loopmgr);
|
2012-04-27 16:07:24 -07:00
|
|
|
}
|
|
|
|
|
2022-03-08 23:55:10 +01:00
|
|
|
static atomic_bool first = true;
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2021-01-14 13:02:57 -08:00
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
server_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
|
2021-01-14 13:02:57 -08:00
|
|
|
UNUSED(handle);
|
|
|
|
UNUSED(eresult);
|
2023-10-23 12:26:50 +02:00
|
|
|
UNUSED(arg);
|
2021-01-14 13:02:57 -08:00
|
|
|
|
|
|
|
return;
|
2016-07-11 13:36:16 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-01-14 13:02:57 -08:00
|
|
|
nameserver(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
|
2023-10-23 12:26:50 +02:00
|
|
|
void *arg ISC_ATTR_UNUSED) {
|
2022-07-26 13:03:45 +02:00
|
|
|
isc_region_t response1, response2;
|
2016-07-11 13:36:16 +10:00
|
|
|
static unsigned char buf1[16];
|
|
|
|
static unsigned char buf2[16];
|
|
|
|
|
Fix the streaming read callback shutdown logic
When shutting down TCP sockets, the read callback calling logic was
flawed, it would call either one less callback or one extra. Fix the
logic in the way:
1. When isc_nm_read() has been called but isc_nm_read_stop() hasn't on
the handle, the read callback will be called with ISC_R_CANCELED to
cancel active reading from the socket/handle.
2. When isc_nm_read() has been called and isc_nm_read_stop() has been
called on the on the handle, the read callback will be called with
ISC_R_SHUTTINGDOWN to signal that the dormant (not-reading) socket
is being shut down.
3. The .reading and .recv_read flags are little bit tricky. The
.reading flag indicates if the outer layer is reading the data (that
would be uv_tcp_t for TCP and isc_nmsocket_t (TCP) for TLSStream),
the .recv_read flag indicates whether somebody is interested in the
data read from the socket.
Usually, you would expect that the .reading should be false when
.recv_read is false, but it gets even more tricky with TLSStream as
the TLS protocol might need to read from the socket even when sending
data.
Fix the usage of the .recv_read and .reading flags in the TLSStream
to their true meaning - which mostly consist of using .recv_read
everywhere and then wrapping isc_nm_read() and isc_nm_read_stop()
with the .reading flag.
4. The TLS failed read helper has been modified to resemble the TCP code
as much as possible, clearing and re-setting the .recv_read flag in
the TCP timeout code has been fixed and .recv_read is now cleared
when isc_nm_read_stop() has been called on the streaming socket.
5. The use of Network Manager in the named_controlconf, isccc_ccmsg, and
isc_httpd units have been greatly simplified due to the improved design.
6. More unit tests for TCP and TLS testing the shutdown conditions have
been added.
Co-authored-by: Ondřej Surý <ondrej@isc.org>
Co-authored-by: Artem Boldariev <artem@isc.org>
2023-04-13 17:27:50 +02:00
|
|
|
if (eresult != ISC_R_SUCCESS) {
|
|
|
|
return;
|
|
|
|
}
|
2021-01-14 13:02:57 -08:00
|
|
|
|
|
|
|
memmove(buf1, region->base, 12);
|
2016-07-11 13:36:16 +10:00
|
|
|
memset(buf1 + 12, 0, 4);
|
|
|
|
buf1[2] |= 0x80; /* qr=1 */
|
|
|
|
|
2021-01-14 13:02:57 -08:00
|
|
|
memmove(buf2, region->base, 12);
|
2016-07-11 13:36:16 +10:00
|
|
|
memset(buf2 + 12, 1, 4);
|
|
|
|
buf2[2] |= 0x80; /* qr=1 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send message to be discarded.
|
|
|
|
*/
|
2022-07-26 13:03:45 +02:00
|
|
|
response1.base = buf1;
|
|
|
|
response1.length = sizeof(buf1);
|
|
|
|
isc_nm_send(handle, &response1, server_senddone, NULL);
|
2016-07-11 13:36:16 +10:00
|
|
|
|
|
|
|
/*
|
|
|
|
* send nextitem message.
|
|
|
|
*/
|
2022-07-26 13:03:45 +02:00
|
|
|
response2.base = buf2;
|
|
|
|
response2.length = sizeof(buf2);
|
|
|
|
isc_nm_send(handle, &response2, server_senddone, NULL);
|
2016-07-11 13:36:16 +10:00
|
|
|
}
|
|
|
|
|
2021-08-04 13:14:11 -07:00
|
|
|
static isc_result_t
|
2023-10-23 12:26:50 +02:00
|
|
|
accept_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
|
2021-08-04 13:14:11 -07:00
|
|
|
UNUSED(handle);
|
2023-10-23 12:26:50 +02:00
|
|
|
UNUSED(arg);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
|
|
|
return eresult;
|
|
|
|
}
|
|
|
|
|
2016-07-11 13:36:16 +10:00
|
|
|
static void
|
2021-08-04 13:14:11 -07:00
|
|
|
noop_nameserver(isc_nmhandle_t *handle, isc_result_t eresult,
|
2023-10-23 12:26:50 +02:00
|
|
|
isc_region_t *region, void *arg) {
|
2021-08-04 13:14:11 -07:00
|
|
|
UNUSED(handle);
|
|
|
|
UNUSED(eresult);
|
|
|
|
UNUSED(region);
|
2023-10-23 12:26:50 +02:00
|
|
|
UNUSED(arg);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2021-08-04 13:14:11 -07:00
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
response_getnext(isc_result_t result, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2021-08-04 13:14:11 -07:00
|
|
|
if (atomic_compare_exchange_strong(&first, &(bool){ true }, false)) {
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatch_getnext(test->dispentry);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-07-11 13:36:16 +10:00
|
|
|
} else {
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_shutdown(test);
|
2016-07-11 13:36:16 +10:00
|
|
|
}
|
2016-08-08 09:35:17 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
response_noop(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
|
|
|
|
|
|
|
if (eresult == ISC_R_SUCCESS) {
|
|
|
|
test_dispatch_done(test);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
response_shutdown(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(eresult, ISC_R_SUCCESS);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_shutdown(test);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
response_timeout(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(eresult, ISC_R_TIMEDOUT);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_shutdown(test);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
client_senddone(isc_result_t eresult, isc_region_t *region, void *arg) {
|
2021-01-14 13:02:57 -08:00
|
|
|
UNUSED(eresult);
|
2021-08-04 13:14:11 -07:00
|
|
|
UNUSED(region);
|
2023-10-23 12:26:50 +02:00
|
|
|
UNUSED(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connected(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
|
|
|
|
2024-08-14 10:01:33 +02:00
|
|
|
switch (eresult) {
|
|
|
|
case ISC_R_CONNECTIONRESET:
|
|
|
|
/* Don't send any data if the connection failed */
|
|
|
|
test_dispatch_shutdown(test);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
assert_int_equal(eresult, ISC_R_SUCCESS);
|
|
|
|
}
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_send(test->dispentry, &testdata.region);
|
2021-01-14 13:02:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
connected_shutdown(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
|
|
|
|
2024-08-14 10:01:33 +02:00
|
|
|
switch (eresult) {
|
|
|
|
case ISC_R_CONNECTIONRESET:
|
|
|
|
/* Skip */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert_int_equal(eresult, ISC_R_SUCCESS);
|
|
|
|
}
|
2023-10-23 12:26:50 +02:00
|
|
|
|
|
|
|
test_dispatch_shutdown(test);
|
2021-01-14 13:02:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-10-23 12:26:50 +02:00
|
|
|
connected_gettcp(isc_result_t eresult ISC_ATTR_UNUSED,
|
|
|
|
isc_region_t *region ISC_ATTR_UNUSED, void *arg) {
|
|
|
|
test_dispatch_t *test1 = arg;
|
|
|
|
|
|
|
|
/* Client 2 */
|
|
|
|
isc_result_t result;
|
|
|
|
test_dispatch_t *test2 = isc_mem_get(mctx, sizeof(*test2));
|
|
|
|
*test2 = (test_dispatch_t){
|
|
|
|
.dispatchmgr = dns_dispatchmgr_ref(test1->dispatchmgr),
|
|
|
|
};
|
|
|
|
|
|
|
|
result = dns_dispatch_gettcp(test2->dispatchmgr, &tcp_server_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tcp_connect_addr, NULL, &test2->dispatch);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
assert_ptr_equal(test1->dispatch, test2->dispatch);
|
|
|
|
|
2024-10-30 09:23:33 +00:00
|
|
|
result = dns_dispatch_add(
|
|
|
|
test2->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
|
|
|
|
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_shutdown,
|
|
|
|
client_senddone, response_noop, test2, &test2->id,
|
|
|
|
&test2->dispentry);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
dns_dispatch_connect(test2->dispentry);
|
|
|
|
|
|
|
|
test_dispatch_done(test1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connected_newtcp(isc_result_t eresult ISC_ATTR_UNUSED,
|
|
|
|
isc_region_t *region ISC_ATTR_UNUSED, void *arg) {
|
|
|
|
test_dispatch_t *test3 = arg;
|
|
|
|
|
|
|
|
/* Client - unshared */
|
|
|
|
isc_result_t result;
|
|
|
|
test_dispatch_t *test4 = isc_mem_get(mctx, sizeof(*test4));
|
|
|
|
*test4 = (test_dispatch_t){
|
|
|
|
.dispatchmgr = dns_dispatchmgr_ref(test3->dispatchmgr),
|
|
|
|
};
|
|
|
|
result = dns_dispatch_gettcp(test4->dispatchmgr, &tcp_server_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tcp_connect_addr, NULL, &test4->dispatch);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_NOTFOUND);
|
|
|
|
|
|
|
|
result = dns_dispatch_createtcp(
|
2024-10-15 16:09:48 +11:00
|
|
|
test4->dispatchmgr, &tcp_connect_addr, &tcp_server_addr, NULL,
|
2023-10-23 12:26:50 +02:00
|
|
|
DNS_DISPATCHOPT_UNSHARED, &test4->dispatch);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
assert_ptr_not_equal(test3->dispatch, test4->dispatch);
|
|
|
|
|
2024-10-30 09:23:33 +00:00
|
|
|
result = dns_dispatch_add(
|
|
|
|
test4->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
|
|
|
|
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_shutdown,
|
|
|
|
client_senddone, response_noop, test4, &test4->id,
|
|
|
|
&test4->dispentry);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
dns_dispatch_connect(test4->dispentry);
|
|
|
|
|
|
|
|
test_dispatch_done(test3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
timeout_connected(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|
|
|
void *arg) {
|
|
|
|
test_dispatch_t *test = arg;
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2024-08-14 10:01:33 +02:00
|
|
|
switch (eresult) {
|
|
|
|
case ISC_R_ADDRNOTAVAIL:
|
|
|
|
case ISC_R_CONNREFUSED:
|
|
|
|
/* Skip */
|
|
|
|
break;
|
|
|
|
default:
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(eresult, ISC_R_TIMEDOUT);
|
|
|
|
}
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_shutdown(test);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_connect) {
|
2021-08-04 13:14:11 -07:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Client */
|
2021-08-04 13:14:11 -07:00
|
|
|
tcp_connect_addr = (isc_sockaddr_t){ .length = 0 };
|
|
|
|
isc_sockaddr_fromin6(&tcp_connect_addr, &in6addr_blackhole, 0);
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
testdata.region.base = testdata.message;
|
|
|
|
testdata.region.length = sizeof(testdata.message);
|
|
|
|
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
2023-10-23 12:26:50 +02:00
|
|
|
&test->dispatchmgr);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tcp_server_addr, NULL, 0,
|
|
|
|
&test->dispatch);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2024-10-30 09:23:33 +00:00
|
|
|
result = dns_dispatch_add(
|
|
|
|
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_SHORT,
|
|
|
|
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, timeout_connected,
|
|
|
|
client_senddone, response_timeout, test, &test->id,
|
|
|
|
&test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
testdata.message[0] = (test->id >> 8) & 0xff;
|
|
|
|
testdata.message[1] = test->id & 0xff;
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_connect(test->dispentry);
|
2022-07-26 13:03:45 +02:00
|
|
|
}
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
static void
|
|
|
|
stop_listening(void *arg) {
|
|
|
|
UNUSED(arg);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
isc_nm_stoplistening(sock);
|
|
|
|
isc_nmsocket_close(&sock);
|
|
|
|
assert_null(sock);
|
2016-07-11 13:36:16 +10:00
|
|
|
}
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_response) {
|
2016-07-11 13:36:16 +10:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Server */
|
2023-05-09 15:13:05 +03:00
|
|
|
result = isc_nm_listenstreamdns(
|
|
|
|
netmgr, ISC_NM_LISTEN_ONE, &tcp_server_addr, noop_nameserver,
|
2023-05-19 14:28:52 +03:00
|
|
|
NULL, accept_cb, NULL, 0, NULL, NULL, ISC_NM_PROXY_NONE, &sock);
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* ensure we stop listening after the test is done */
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Client */
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
2023-10-23 12:26:50 +02:00
|
|
|
&test->dispatchmgr);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tcp_server_addr, NULL, 0,
|
|
|
|
&test->dispatch);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2024-03-28 16:22:11 +02:00
|
|
|
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
|
2024-10-30 09:23:33 +00:00
|
|
|
T_CLIENT_CONNECT, T_CLIENT_SHORT,
|
|
|
|
&tcp_server_addr, NULL, NULL, connected,
|
|
|
|
client_senddone, response_timeout, test,
|
|
|
|
&test->id, &test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_connect(test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_tcp_response) {
|
2021-08-04 13:14:11 -07:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Server */
|
2023-05-09 15:13:05 +03:00
|
|
|
result = isc_nm_listenstreamdns(
|
|
|
|
netmgr, ISC_NM_LISTEN_ONE, &tcp_server_addr, nameserver, NULL,
|
2023-05-19 14:28:52 +03:00
|
|
|
accept_cb, NULL, 0, NULL, NULL, ISC_NM_PROXY_NONE, &sock);
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Client */
|
|
|
|
testdata.region.base = testdata.message;
|
|
|
|
testdata.region.length = sizeof(testdata.message);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
2023-10-23 12:26:50 +02:00
|
|
|
&test->dispatchmgr);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tcp_server_addr, NULL, 0,
|
|
|
|
&test->dispatch);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2024-10-30 09:23:33 +00:00
|
|
|
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
|
|
|
|
T_CLIENT_CONNECT, T_CLIENT_INIT,
|
|
|
|
&tcp_server_addr, NULL, NULL, connected,
|
|
|
|
client_senddone, response_shutdown, test,
|
|
|
|
&test->id, &test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
testdata.message[0] = (test->id >> 8) & 0xff;
|
|
|
|
testdata.message[1] = test->id & 0xff;
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_connect(test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
|
|
|
|
2022-09-19 12:33:32 +00:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_tls_response) {
|
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
2022-09-19 12:33:32 +00:00
|
|
|
|
|
|
|
/* Server */
|
2022-10-07 22:23:06 +03:00
|
|
|
result = isc_nm_listenstreamdns(
|
2022-09-19 12:33:32 +00:00
|
|
|
netmgr, ISC_NM_LISTEN_ONE, &tls_server_addr, nameserver, NULL,
|
2023-05-19 14:28:52 +03:00
|
|
|
accept_cb, NULL, 0, NULL, tls_listen_tlsctx, ISC_NM_PROXY_NONE,
|
|
|
|
&sock);
|
2022-09-19 12:33:32 +00:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
|
|
|
|
|
|
|
/* Client */
|
|
|
|
testdata.region.base = testdata.message;
|
|
|
|
testdata.region.length = sizeof(testdata.message);
|
|
|
|
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
2023-10-23 12:26:50 +02:00
|
|
|
&test->dispatchmgr);
|
2022-09-19 12:33:32 +00:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatch_createtcp(test->dispatchmgr, &tls_connect_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tls_server_addr, tls_transport, 0,
|
|
|
|
&test->dispatch);
|
2022-09-19 12:33:32 +00:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2024-10-30 09:23:33 +00:00
|
|
|
result = dns_dispatch_add(
|
|
|
|
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
|
|
|
|
T_CLIENT_INIT, &tls_server_addr, tls_transport,
|
|
|
|
tls_tlsctx_client_cache, connected, client_senddone,
|
|
|
|
response_shutdown, test, &test->id, &test->dispentry);
|
2022-09-19 12:33:32 +00:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
testdata.message[0] = (test->id >> 8) & 0xff;
|
|
|
|
testdata.message[1] = test->id & 0xff;
|
2022-09-19 12:33:32 +00:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_connect(test->dispentry);
|
2022-09-19 12:33:32 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_timeout_udp_response) {
|
2021-08-04 13:14:11 -07:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Server */
|
2022-03-25 16:44:21 +01:00
|
|
|
result = isc_nm_listenudp(netmgr, ISC_NM_LISTEN_ONE, &udp_server_addr,
|
|
|
|
noop_nameserver, NULL, &sock);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* ensure we stop listening after the test is done */
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
|
|
|
|
|
|
|
/* Client */
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
|
|
|
&test->dispatchmgr);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
result = dns_dispatch_createudp(test->dispatchmgr, &udp_connect_addr,
|
|
|
|
&test->dispatch);
|
2022-07-26 13:03:45 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2024-03-28 16:22:11 +02:00
|
|
|
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
|
2024-10-30 09:23:33 +00:00
|
|
|
T_CLIENT_CONNECT, T_CLIENT_SHORT,
|
|
|
|
&udp_server_addr, NULL, NULL, connected,
|
|
|
|
client_senddone, response_timeout, test,
|
|
|
|
&test->id, &test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_connect(test->dispentry);
|
2021-08-04 13:14:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* test dispatch getnext */
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_getnext) {
|
2021-08-04 13:14:11 -07:00
|
|
|
isc_result_t result;
|
2023-10-23 12:26:50 +02:00
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
/* Server */
|
|
|
|
result = isc_nm_listenudp(netmgr, ISC_NM_LISTEN_ONE, &udp_server_addr,
|
|
|
|
nameserver, NULL, &sock);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
|
|
|
|
|
|
|
/* Client */
|
|
|
|
testdata.region.base = testdata.message;
|
|
|
|
testdata.region.length = sizeof(testdata.message);
|
2021-08-04 13:14:11 -07:00
|
|
|
|
2023-09-15 14:38:02 +02:00
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
2023-10-23 12:26:50 +02:00
|
|
|
&test->dispatchmgr);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
result = dns_dispatch_createudp(test->dispatchmgr, &udp_connect_addr,
|
|
|
|
&test->dispatch);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2024-10-30 09:23:33 +00:00
|
|
|
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
|
|
|
|
T_CLIENT_CONNECT, T_CLIENT_INIT,
|
|
|
|
&udp_server_addr, NULL, NULL, connected,
|
|
|
|
client_senddone, response_getnext, test,
|
|
|
|
&test->id, &test->dispentry);
|
2018-10-26 08:46:28 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2016-07-11 13:36:16 +10:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
testdata.message[0] = (test->id >> 8) & 0xff;
|
|
|
|
testdata.message[1] = test->id & 0xff;
|
|
|
|
|
|
|
|
dns_dispatch_connect(test->dispentry);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_gettcp) {
|
|
|
|
isc_result_t result;
|
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
|
|
|
|
|
|
|
/* Server */
|
2023-05-09 15:13:05 +03:00
|
|
|
result = isc_nm_listenstreamdns(
|
|
|
|
netmgr, ISC_NM_LISTEN_ONE, &tcp_server_addr, nameserver, NULL,
|
2023-05-19 14:28:52 +03:00
|
|
|
accept_cb, NULL, 0, NULL, NULL, ISC_NM_PROXY_NONE, &sock);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
/* ensure we stop listening after the test is done */
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
|
|
|
|
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
|
|
|
&test->dispatchmgr);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
/* Client */
|
|
|
|
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
2024-10-15 16:09:48 +11:00
|
|
|
&tcp_server_addr, NULL, 0,
|
|
|
|
&test->dispatch);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
result = dns_dispatch_add(
|
|
|
|
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
|
2024-10-30 09:23:33 +00:00
|
|
|
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_gettcp,
|
|
|
|
client_senddone, response_noop, test, &test->id,
|
|
|
|
&test->dispentry);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
dns_dispatch_connect(test->dispentry);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISC_LOOP_TEST_IMPL(dispatch_newtcp) {
|
|
|
|
isc_result_t result;
|
|
|
|
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
|
|
|
*test = (test_dispatch_t){ 0 };
|
|
|
|
|
|
|
|
/* Server */
|
2023-05-09 15:13:05 +03:00
|
|
|
result = isc_nm_listenstreamdns(
|
|
|
|
netmgr, ISC_NM_LISTEN_ONE, &tcp_server_addr, nameserver, NULL,
|
2023-05-19 14:28:52 +03:00
|
|
|
accept_cb, NULL, 0, NULL, NULL, ISC_NM_PROXY_NONE, &sock);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
/* ensure we stop listening after the test is done */
|
|
|
|
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
|
|
|
|
|
|
|
|
/* Client - unshared */
|
|
|
|
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
|
|
|
|
&test->dispatchmgr);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
result = dns_dispatch_createtcp(
|
2024-10-15 16:09:48 +11:00
|
|
|
test->dispatchmgr, &tcp_connect_addr, &tcp_server_addr, NULL,
|
2023-10-23 12:26:50 +02:00
|
|
|
DNS_DISPATCHOPT_UNSHARED, &test->dispatch);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
result = dns_dispatch_add(
|
|
|
|
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
|
2024-10-30 09:23:33 +00:00
|
|
|
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_newtcp,
|
|
|
|
client_senddone, response_noop, test, &test->id,
|
|
|
|
&test->dispentry);
|
2023-10-23 12:26:50 +02:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2021-01-14 13:02:57 -08:00
|
|
|
|
2023-10-23 12:26:50 +02:00
|
|
|
dns_dispatch_connect(test->dispentry);
|
2018-10-26 08:46:28 -07:00
|
|
|
}
|
2016-07-11 13:36:16 +10:00
|
|
|
|
Give the unit tests a big overhaul
The unit tests contain a lot of duplicated code and here's an attempt
to reduce code duplication.
This commit does several things:
1. Remove #ifdef HAVE_CMOCKA - we already solve this with automake
conditionals.
2. Create a set of ISC_TEST_* and ISC_*_TEST_ macros to wrap the test
implementations, test lists, and the main test routine, so we don't
have to repeat this all over again. The macros were modeled after
libuv test suite but adapted to cmocka as the test driver.
A simple example of a unit test would be:
ISC_RUN_TEST_IMPL(test1) { assert_true(true); }
ISC_TEST_LIST_START
ISC_TEST_ENTRY(test1)
ISC_TEST_LIST_END
ISC_TEST_MAIN (Discussion: Should this be ISC_TEST_RUN ?)
For more complicated examples including group setup and teardown
functions, and per-test setup and teardown functions.
3. The macros prefix the test functions and cmocka entries, so the name
of the test can now match the tested function name, and we don't have
to append `_test` because `run_test_` is automatically prepended to
the main test function, and `setup_test_` and `teardown_test_` is
prepended to setup and teardown function.
4. Update all the unit tests to use the new syntax and fix a few bits
here and there.
5. In the future, we can separate the test declarations and test
implementations which are going to greatly help with uncluttering the
bigger unit tests like doh_test and netmgr_test, because the test
implementations are not declared static (see `ISC_RUN_TEST_DECLARE`
and `ISC_RUN_TEST_IMPL` for more details.
NOTE: This heavily relies on preprocessor macros, but the result greatly
outweighs all the negatives of using the macros. There's less
duplicated code, the tests are more uniform and the implementation can
be more flexible.
2022-05-02 10:56:42 +02:00
|
|
|
ISC_TEST_LIST_START
|
2023-10-23 12:26:50 +02:00
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_gettcp, setup_test, teardown_test)
|
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_newtcp, setup_test, teardown_test)
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_timeout_udp_response, setup_test, teardown_test)
|
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatchset_create, setup_test, teardown_test)
|
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatchset_get, setup_test, teardown_test)
|
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_timeout_tcp_response, setup_test, teardown_test)
|
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_timeout_tcp_connect, setup_test, teardown_test)
|
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_tcp_response, setup_test, teardown_test)
|
2022-09-19 12:33:32 +00:00
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_tls_response, setup_test, teardown_test)
|
2022-07-26 13:03:45 +02:00
|
|
|
ISC_TEST_ENTRY_CUSTOM(dispatch_getnext, setup_test, teardown_test)
|
Give the unit tests a big overhaul
The unit tests contain a lot of duplicated code and here's an attempt
to reduce code duplication.
This commit does several things:
1. Remove #ifdef HAVE_CMOCKA - we already solve this with automake
conditionals.
2. Create a set of ISC_TEST_* and ISC_*_TEST_ macros to wrap the test
implementations, test lists, and the main test routine, so we don't
have to repeat this all over again. The macros were modeled after
libuv test suite but adapted to cmocka as the test driver.
A simple example of a unit test would be:
ISC_RUN_TEST_IMPL(test1) { assert_true(true); }
ISC_TEST_LIST_START
ISC_TEST_ENTRY(test1)
ISC_TEST_LIST_END
ISC_TEST_MAIN (Discussion: Should this be ISC_TEST_RUN ?)
For more complicated examples including group setup and teardown
functions, and per-test setup and teardown functions.
3. The macros prefix the test functions and cmocka entries, so the name
of the test can now match the tested function name, and we don't have
to append `_test` because `run_test_` is automatically prepended to
the main test function, and `setup_test_` and `teardown_test_` is
prepended to setup and teardown function.
4. Update all the unit tests to use the new syntax and fix a few bits
here and there.
5. In the future, we can separate the test declarations and test
implementations which are going to greatly help with uncluttering the
bigger unit tests like doh_test and netmgr_test, because the test
implementations are not declared static (see `ISC_RUN_TEST_DECLARE`
and `ISC_RUN_TEST_IMPL` for more details.
NOTE: This heavily relies on preprocessor macros, but the result greatly
outweighs all the negatives of using the macros. There's less
duplicated code, the tests are more uniform and the implementation can
be more flexible.
2022-05-02 10:56:42 +02:00
|
|
|
ISC_TEST_LIST_END
|
2018-10-26 08:46:28 -07:00
|
|
|
|
Give the unit tests a big overhaul
The unit tests contain a lot of duplicated code and here's an attempt
to reduce code duplication.
This commit does several things:
1. Remove #ifdef HAVE_CMOCKA - we already solve this with automake
conditionals.
2. Create a set of ISC_TEST_* and ISC_*_TEST_ macros to wrap the test
implementations, test lists, and the main test routine, so we don't
have to repeat this all over again. The macros were modeled after
libuv test suite but adapted to cmocka as the test driver.
A simple example of a unit test would be:
ISC_RUN_TEST_IMPL(test1) { assert_true(true); }
ISC_TEST_LIST_START
ISC_TEST_ENTRY(test1)
ISC_TEST_LIST_END
ISC_TEST_MAIN (Discussion: Should this be ISC_TEST_RUN ?)
For more complicated examples including group setup and teardown
functions, and per-test setup and teardown functions.
3. The macros prefix the test functions and cmocka entries, so the name
of the test can now match the tested function name, and we don't have
to append `_test` because `run_test_` is automatically prepended to
the main test function, and `setup_test_` and `teardown_test_` is
prepended to setup and teardown function.
4. Update all the unit tests to use the new syntax and fix a few bits
here and there.
5. In the future, we can separate the test declarations and test
implementations which are going to greatly help with uncluttering the
bigger unit tests like doh_test and netmgr_test, because the test
implementations are not declared static (see `ISC_RUN_TEST_DECLARE`
and `ISC_RUN_TEST_IMPL` for more details.
NOTE: This heavily relies on preprocessor macros, but the result greatly
outweighs all the negatives of using the macros. There's less
duplicated code, the tests are more uniform and the implementation can
be more flexible.
2022-05-02 10:56:42 +02:00
|
|
|
ISC_TEST_MAIN
|