2011-09-02 21:15:39 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2011-09-02 21:15:39 +00:00
|
|
|
*
|
2016-06-27 14:56:38 +10: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 http://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2011-09-02 21:15:39 +00:00
|
|
|
*/
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
#if HAVE_CMOCKA
|
|
|
|
|
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 */
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <setjmp.h>
|
|
|
|
#include <stdarg.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <stddef.h>
|
2018-10-25 20:30:46 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-09-02 21:15:39 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
#define UNIT_TESTING
|
|
|
|
#include <cmocka.h>
|
|
|
|
|
2011-09-02 21:15:39 +00:00
|
|
|
#include <isc/app.h>
|
2019-07-04 11:04:52 +02:00
|
|
|
#include <isc/atomic.h>
|
2011-09-02 21:15:39 +00:00
|
|
|
#include <isc/buffer.h>
|
2018-08-28 15:59:20 -07:00
|
|
|
#include <isc/print.h>
|
2011-09-02 21:15:39 +00:00
|
|
|
#include <isc/task.h>
|
|
|
|
#include <isc/timer.h>
|
2018-10-25 20:30:46 -07:00
|
|
|
#include <isc/util.h>
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
#include <dns/db.h>
|
|
|
|
#include <dns/name.h>
|
|
|
|
#include <dns/view.h>
|
|
|
|
#include <dns/zone.h>
|
|
|
|
#include <dns/zt.h>
|
|
|
|
|
|
|
|
#include "dnstest.h"
|
|
|
|
|
2012-06-14 15:13:44 +10:00
|
|
|
struct args {
|
|
|
|
void *arg1;
|
|
|
|
void *arg2;
|
2020-02-12 13:59:18 +01:00
|
|
|
bool arg3;
|
2012-06-14 15:13:44 +10:00
|
|
|
};
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
static int
|
2020-02-12 13:59:18 +01:00
|
|
|
_setup(void **state)
|
|
|
|
{
|
2018-10-25 20:30:46 -07:00
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
UNUSED(state);
|
|
|
|
|
|
|
|
result = dns_test_begin(NULL, true);
|
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2020-02-12 13:59:18 +01:00
|
|
|
_teardown(void **state)
|
|
|
|
{
|
2018-10-25 20:30:46 -07:00
|
|
|
UNUSED(state);
|
|
|
|
|
|
|
|
dns_test_end();
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2011-09-02 21:15:39 +00:00
|
|
|
static isc_result_t
|
2020-02-12 13:59:18 +01:00
|
|
|
count_zone(dns_zone_t *zone, void *uap)
|
|
|
|
{
|
2011-09-02 21:15:39 +00:00
|
|
|
int *nzones = (int *)uap;
|
|
|
|
|
|
|
|
UNUSED(zone);
|
|
|
|
|
|
|
|
*nzones += 1;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-12 13:59:18 +01:00
|
|
|
load_done(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task)
|
|
|
|
{
|
2011-09-02 21:15:39 +00:00
|
|
|
/* We treat zt as a pointer to a boolean for testing purposes */
|
2020-02-12 13:59:18 +01:00
|
|
|
atomic_bool *done = (atomic_bool *)zt;
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
UNUSED(zone);
|
2011-09-03 06:13:30 +00:00
|
|
|
UNUSED(task);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2019-07-04 11:04:52 +02:00
|
|
|
atomic_store(done, true);
|
2011-09-02 21:15:39 +00:00
|
|
|
isc_app_shutdown();
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2020-02-12 13:59:18 +01:00
|
|
|
all_done(void *arg)
|
|
|
|
{
|
|
|
|
atomic_bool *done = (atomic_bool *)arg;
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2019-07-04 11:04:52 +02:00
|
|
|
atomic_store(done, true);
|
2011-09-02 21:15:39 +00:00
|
|
|
isc_app_shutdown();
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:44 +10:00
|
|
|
static void
|
2020-02-12 13:59:18 +01:00
|
|
|
start_zt_asyncload(isc_task_t *task, isc_event_t *event)
|
|
|
|
{
|
2012-06-14 15:13:44 +10:00
|
|
|
struct args *args = (struct args *)(event->ev_arg);
|
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
|
2018-07-10 18:43:55 +02:00
|
|
|
dns_zt_asyncload(args->arg1, false, all_done, args->arg2);
|
2012-06-14 15:13:44 +10:00
|
|
|
|
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-12 13:59:18 +01:00
|
|
|
start_zone_asyncload(isc_task_t *task, isc_event_t *event)
|
|
|
|
{
|
2012-06-14 15:13:44 +10:00
|
|
|
struct args *args = (struct args *)(event->ev_arg);
|
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
|
2018-07-10 18:43:55 +02:00
|
|
|
dns_zone_asyncload(args->arg1, args->arg3, load_done, args->arg2);
|
2012-06-14 15:13:44 +10:00
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
/* apply a function to a zone table */
|
|
|
|
static void
|
2020-02-12 13:59:18 +01:00
|
|
|
apply(void **state)
|
|
|
|
{
|
2011-09-02 21:15:39 +00:00
|
|
|
isc_result_t result;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_t * zone = NULL;
|
|
|
|
dns_view_t * view = NULL;
|
|
|
|
int nzones = 0;
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
UNUSED(state);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_test_makezone("foo", &zone, NULL, true);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 23:46:33 +00:00
|
|
|
|
2011-09-02 21:15:39 +00:00
|
|
|
view = dns_zone_getview(zone);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_non_null(view->zonetable);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(nzones, 0);
|
2020-02-12 13:59:18 +01:00
|
|
|
result =
|
|
|
|
dns_zt_apply(view->zonetable, false, NULL, count_zone, &nzones);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_int_equal(nzones, 1);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
/* These steps are necessary so the zone can be detached properly */
|
|
|
|
result = dns_test_setupzonemgr();
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
result = dns_test_managezone(zone);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
dns_test_releasezone(zone);
|
|
|
|
dns_test_closezonemgr();
|
|
|
|
|
|
|
|
/* The view was left attached in dns_test_makezone() */
|
|
|
|
dns_view_detach(&view);
|
|
|
|
dns_zone_detach(&zone);
|
|
|
|
}
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
/* asynchronous zone load */
|
|
|
|
static void
|
2020-02-12 13:59:18 +01:00
|
|
|
asyncload_zone(void **state)
|
|
|
|
{
|
2011-09-02 21:15:39 +00:00
|
|
|
isc_result_t result;
|
2020-02-12 13:59:18 +01:00
|
|
|
int n;
|
|
|
|
dns_zone_t * zone = NULL;
|
|
|
|
dns_view_t * view = NULL;
|
|
|
|
dns_db_t * db = NULL;
|
|
|
|
FILE * zonefile, *origfile;
|
|
|
|
char buf[4096];
|
|
|
|
atomic_bool done;
|
|
|
|
int i = 0;
|
|
|
|
struct args args;
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
UNUSED(state);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2020-01-13 11:38:43 +01:00
|
|
|
atomic_init(&done, false);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_test_makezone("foo", &zone, NULL, true);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
result = dns_test_setupzonemgr();
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
result = dns_test_managezone(zone);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
view = dns_zone_getview(zone);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_non_null(view->zonetable);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_false(dns__zone_loadpending(zone));
|
2019-07-04 11:04:52 +02:00
|
|
|
assert_false(atomic_load(&done));
|
2018-07-10 18:43:55 +02:00
|
|
|
zonefile = fopen("./zone.data", "wb");
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_non_null(zonefile);
|
2018-07-10 18:43:55 +02:00
|
|
|
origfile = fopen("./testdata/zt/zone1.db", "r+b");
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_non_null(origfile);
|
2018-07-10 18:43:55 +02:00
|
|
|
n = fread(buf, 1, 4096, origfile);
|
2018-08-31 12:13:19 +10:00
|
|
|
fclose(origfile);
|
2018-07-10 18:43:55 +02:00
|
|
|
fwrite(buf, 1, n, zonefile);
|
|
|
|
fflush(zonefile);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setfile(zone, "./zone.data", dns_masterformat_text,
|
|
|
|
&dns_master_style_default);
|
2012-06-14 15:13:44 +10:00
|
|
|
|
|
|
|
args.arg1 = zone;
|
|
|
|
args.arg2 = &done;
|
2018-07-10 18:43:55 +02:00
|
|
|
args.arg3 = false;
|
2019-06-18 15:01:43 +02:00
|
|
|
isc_app_onrun(dt_mctx, maintask, start_zone_asyncload, &args);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
isc_app_run();
|
2020-02-13 21:48:23 +01:00
|
|
|
while (dns__zone_loadpending(zone) && i++ < 5000) {
|
2011-09-02 21:15:39 +00:00
|
|
|
dns_test_nap(1000);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2019-07-04 11:04:52 +02:00
|
|
|
assert_true(atomic_load(&done));
|
2018-07-10 18:43:55 +02:00
|
|
|
/* The zone should now be loaded; test it */
|
|
|
|
result = dns_zone_getdb(zone, &db);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2018-07-10 18:43:55 +02:00
|
|
|
dns_db_detach(&db);
|
|
|
|
/*
|
|
|
|
* Add something to zone file, reload zone with newonly - it should
|
|
|
|
* not be reloaded.
|
|
|
|
*/
|
|
|
|
fprintf(zonefile, "\nb in b 1.2.3.4\n");
|
|
|
|
fflush(zonefile);
|
2018-08-31 12:13:19 +10:00
|
|
|
fclose(zonefile);
|
2018-07-10 18:43:55 +02:00
|
|
|
|
|
|
|
args.arg1 = zone;
|
|
|
|
args.arg2 = &done;
|
|
|
|
args.arg3 = true;
|
2019-06-18 15:01:43 +02:00
|
|
|
isc_app_onrun(dt_mctx, maintask, start_zone_asyncload, &args);
|
2018-07-10 18:43:55 +02:00
|
|
|
|
|
|
|
isc_app_run();
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
while (dns__zone_loadpending(zone) && i++ < 5000) {
|
2018-07-10 18:43:55 +02:00
|
|
|
dns_test_nap(1000);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2019-07-04 11:04:52 +02:00
|
|
|
assert_true(atomic_load(&done));
|
2011-09-02 21:15:39 +00:00
|
|
|
/* The zone should now be loaded; test it */
|
|
|
|
result = dns_zone_getdb(zone, &db);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2018-07-10 18:43:55 +02:00
|
|
|
dns_db_detach(&db);
|
|
|
|
|
|
|
|
/* Now reload it without newonly - it should be reloaded */
|
|
|
|
args.arg1 = zone;
|
|
|
|
args.arg2 = &done;
|
|
|
|
args.arg3 = false;
|
2019-06-18 15:01:43 +02:00
|
|
|
isc_app_onrun(dt_mctx, maintask, start_zone_asyncload, &args);
|
2018-07-10 18:43:55 +02:00
|
|
|
|
|
|
|
isc_app_run();
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
while (dns__zone_loadpending(zone) && i++ < 5000) {
|
2018-07-10 18:43:55 +02:00
|
|
|
dns_test_nap(1000);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2019-07-04 11:04:52 +02:00
|
|
|
assert_true(atomic_load(&done));
|
2018-07-10 18:43:55 +02:00
|
|
|
/* The zone should now be loaded; test it */
|
|
|
|
result = dns_zone_getdb(zone, &db);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2018-07-10 18:43:55 +02:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_non_null(db);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (db != NULL) {
|
2011-09-02 21:15:39 +00:00
|
|
|
dns_db_detach(&db);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
dns_test_releasezone(zone);
|
|
|
|
dns_test_closezonemgr();
|
|
|
|
|
|
|
|
dns_zone_detach(&zone);
|
|
|
|
dns_view_detach(&view);
|
|
|
|
}
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
/* asynchronous zone table load */
|
|
|
|
static void
|
2020-02-12 13:59:18 +01:00
|
|
|
asyncload_zt(void **state)
|
|
|
|
{
|
2011-09-02 21:15:39 +00:00
|
|
|
isc_result_t result;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_t * zone1 = NULL, *zone2 = NULL, *zone3 = NULL;
|
|
|
|
dns_view_t * view;
|
|
|
|
dns_zt_t * zt = NULL;
|
|
|
|
dns_db_t * db = NULL;
|
|
|
|
atomic_bool done;
|
|
|
|
int i = 0;
|
|
|
|
struct args args;
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
UNUSED(state);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2020-01-13 11:38:43 +01:00
|
|
|
atomic_init(&done, false);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_test_makezone("foo", &zone1, NULL, true);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setfile(zone1, "testdata/zt/zone1.db", dns_masterformat_text,
|
|
|
|
&dns_master_style_default);
|
2011-09-02 21:15:39 +00:00
|
|
|
view = dns_zone_getview(zone1);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_test_makezone("bar", &zone2, view, false);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setfile(zone2, "testdata/zt/zone1.db", dns_masterformat_text,
|
|
|
|
&dns_master_style_default);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
/* This one will fail to load */
|
2018-04-17 08:29:14 -07:00
|
|
|
result = dns_test_makezone("fake", &zone3, view, false);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2018-04-03 16:34:41 +02:00
|
|
|
dns_zone_setfile(zone3, "testdata/zt/nonexistent.db",
|
|
|
|
dns_masterformat_text, &dns_master_style_default);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
zt = view->zonetable;
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_non_null(zt);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
result = dns_test_setupzonemgr();
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
result = dns_test_managezone(zone1);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
result = dns_test_managezone(zone2);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
result = dns_test_managezone(zone3);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_false(dns__zone_loadpending(zone1));
|
|
|
|
assert_false(dns__zone_loadpending(zone2));
|
2019-07-04 11:04:52 +02:00
|
|
|
assert_false(atomic_load(&done));
|
2012-06-14 15:13:44 +10:00
|
|
|
|
|
|
|
args.arg1 = zt;
|
|
|
|
args.arg2 = &done;
|
2019-06-18 15:01:43 +02:00
|
|
|
isc_app_onrun(dt_mctx, maintask, start_zt_asyncload, &args);
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
isc_app_run();
|
2019-07-04 11:04:52 +02:00
|
|
|
while (!atomic_load(&done) && i++ < 5000) {
|
2011-09-02 21:15:39 +00:00
|
|
|
dns_test_nap(1000);
|
2019-07-04 11:04:52 +02:00
|
|
|
}
|
|
|
|
assert_true(atomic_load(&done));
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
/* Both zones should now be loaded; test them */
|
|
|
|
result = dns_zone_getdb(zone1, &db);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_non_null(db);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (db != NULL) {
|
2011-09-02 21:15:39 +00:00
|
|
|
dns_db_detach(&db);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
result = dns_zone_getdb(zone2, &db);
|
2018-10-25 20:30:46 -07:00
|
|
|
assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
|
assert_non_null(db);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (db != NULL) {
|
2011-09-02 21:15:39 +00:00
|
|
|
dns_db_detach(&db);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-09-02 21:15:39 +00:00
|
|
|
|
|
|
|
dns_test_releasezone(zone3);
|
|
|
|
dns_test_releasezone(zone2);
|
|
|
|
dns_test_releasezone(zone1);
|
|
|
|
dns_test_closezonemgr();
|
|
|
|
|
|
|
|
dns_zone_detach(&zone1);
|
|
|
|
dns_zone_detach(&zone2);
|
|
|
|
dns_zone_detach(&zone3);
|
|
|
|
dns_view_detach(&view);
|
2018-10-25 20:30:46 -07:00
|
|
|
}
|
2011-09-02 21:15:39 +00:00
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
int
|
2020-02-12 13:59:18 +01:00
|
|
|
main(void)
|
|
|
|
{
|
2018-10-25 20:30:46 -07:00
|
|
|
const struct CMUnitTest tests[] = {
|
|
|
|
cmocka_unit_test_setup_teardown(apply, _setup, _teardown),
|
2020-02-12 13:59:18 +01:00
|
|
|
cmocka_unit_test_setup_teardown(asyncload_zone, _setup,
|
|
|
|
_teardown),
|
|
|
|
cmocka_unit_test_setup_teardown(asyncload_zt, _setup,
|
|
|
|
_teardown),
|
2018-10-25 20:30:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
return (cmocka_run_group_tests(tests, NULL, NULL));
|
2011-09-02 21:15:39 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 20:30:46 -07:00
|
|
|
#else /* HAVE_CMOCKA */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int
|
2020-02-12 13:59:18 +01:00
|
|
|
main(void)
|
|
|
|
{
|
2018-10-25 20:30:46 -07:00
|
|
|
printf("1..0 # Skipped: cmocka not available\n");
|
|
|
|
return (0);
|
2011-09-02 21:15:39 +00:00
|
|
|
}
|
2018-10-25 20:30:46 -07:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
#endif /* if HAVE_CMOCKA */
|