bool debug_mem_record = true;
static bool dst_active = false;
+static bool test_running = false;
/*
* Logging categories: this needs to match the list in bin/named/log.c.
static void
cleanup_managers(void) {
- if (app_running)
- isc_app_finish();
- if (socketmgr != NULL)
- isc_socketmgr_destroy(&socketmgr);
- if (maintask != NULL)
+ if (maintask != NULL) {
+ isc_task_shutdown(maintask);
isc_task_destroy(&maintask);
- if (taskmgr != NULL)
+ }
+ if (socketmgr != NULL) {
+ isc_socketmgr_destroy(&socketmgr);
+ }
+ if (taskmgr != NULL) {
isc_taskmgr_destroy(&taskmgr);
- if (timermgr != NULL)
+ }
+ if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
+ }
+ if (app_running) {
+ isc_app_finish();
+ }
}
static isc_result_t
dns_test_begin(FILE *logfile, bool start_managers) {
isc_result_t result;
- if (start_managers)
+ INSIST(!test_running);
+ test_running = true;
+
+ if (start_managers) {
CHECK(isc_app_start());
- if (debug_mem_record)
+ }
+ if (debug_mem_record) {
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
+ }
+
+ INSIST(mctx == NULL);
CHECK(isc_mem_create(0, 0, &mctx));
- if (!dst_active) {
- CHECK(dst_lib_init(mctx, NULL));
- dst_active = true;
- }
+ INSIST(!dst_active);
+ CHECK(dst_lib_init(mctx, NULL));
+ dst_active = true;
if (logfile != NULL) {
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
+ INSIST(lctx == NULL);
CHECK(isc_log_create(mctx, &lctx, &logconfig));
+
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_result_register();
- if (start_managers)
+ if (start_managers) {
CHECK(create_managers());
+ }
/*
* The caller might run from another directory, so tests
dns_test_end(void) {
cleanup_managers();
- if (dst_active) {
- dst_lib_destroy();
- dst_active = false;
- }
+ dst_lib_destroy();
+ dst_active = false;
- if (lctx != NULL)
+ if (lctx != NULL) {
isc_log_destroy(&lctx);
+ }
- if (mctx != NULL)
+ if (mctx != NULL) {
isc_mem_destroy(&mctx);
+ }
+ test_running = false;
}
/*
#include <stdlib.h>
#include <time.h>
-#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/hash.h>
#include <isc/mem.h>
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 void
cleanup_managers(void) {
- if (maintask != NULL)
+ if (maintask != NULL) {
+ isc_task_shutdown(maintask);
isc_task_destroy(&maintask);
- if (socketmgr != NULL)
+ }
+ if (socketmgr != NULL) {
isc_socketmgr_destroy(&socketmgr);
- if (taskmgr != NULL)
+ }
+ if (taskmgr != NULL) {
isc_taskmgr_destroy(&taskmgr);
- if (timermgr != NULL)
+ }
+ if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
+ }
}
static isc_result_t
{
isc_result_t result;
+ INSIST(!test_running);
+ test_running = true;
+
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
+
+ INSIST(mctx == NULL);
CHECK(isc_mem_create(0, 0, &mctx));
if (logfile != NULL) {
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
+ INSIST(lctx == NULL);
CHECK(isc_log_create(mctx, &lctx, &logconfig));
+
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
void
isc_test_end(void) {
- if (maintask != NULL)
+ if (maintask != NULL) {
isc_task_detach(&maintask);
- if (taskmgr != NULL)
+ }
+ if (taskmgr != NULL) {
isc_taskmgr_destroy(&taskmgr);
+ }
cleanup_managers();
- if (lctx != NULL)
+ if (lctx != NULL) {
isc_log_destroy(&lctx);
- if (mctx != NULL)
+ }
+ if (mctx != NULL) {
isc_mem_destroy(&mctx);
+ }
+
+ test_running = false;
}
/*
bool run_managers = false;
static bool dst_active = false;
+static bool test_running = false;
static dns_zone_t *served_zone = NULL;
static void
cleanup_managers(void) {
- if (app_running)
- isc_app_finish();
-
shutdown_done = false;
if (maintask != NULL) {
ns_test_nap(500000);
}
- if (sctx != NULL)
+ if (sctx != NULL) {
ns_server_detach(&sctx);
- if (socketmgr != NULL)
+ }
+ if (socketmgr != NULL) {
isc_socketmgr_destroy(&socketmgr);
- if (taskmgr != NULL)
+ }
+ if (taskmgr != NULL) {
isc_taskmgr_destroy(&taskmgr);
- if (timermgr != NULL)
+ }
+ if (timermgr != NULL) {
isc_timermgr_destroy(&timermgr);
+ }
+ if (app_running) {
+ isc_app_finish();
+ }
}
static void
scan_interfaces, NULL,
sizeof (isc_event_t));
isc_task_send(maintask, &event);
+
/*
* There's no straightforward way to determine
* whether the interfaces have been scanned,
ns_test_begin(FILE *logfile, bool start_managers) {
isc_result_t result;
- if (start_managers)
+ INSIST(!test_running);
+ test_running = true;
+
+ if (start_managers) {
CHECK(isc_app_start());
- if (debug_mem_record)
+ }
+ if (debug_mem_record) {
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
+ }
+
+ INSIST(mctx == NULL);
CHECK(isc_mem_create(0, 0, &mctx));
- CHECK(dst_lib_init(mctx, NULL));
- dst_active = true;
+ if (!dst_active) {
+ CHECK(dst_lib_init(mctx, NULL));
+ dst_active = true;
+ }
if (logfile != NULL) {
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
+ INSIST(lctx == NULL);
CHECK(isc_log_create(mctx, &lctx, &logconfig));
+
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_result_register();
- if (start_managers)
+ if (start_managers) {
CHECK(create_managers());
+ }
/*
* atf-run changes us to a /tmp directory, so tests
* that access test data files must first chdir to the proper
* location.
*/
- if (chdir(TESTS) == -1)
+ if (chdir(TESTS) == -1) {
CHECK(ISC_R_FAILURE);
+ }
ns__hook_table = NULL;
ns_test_end(void) {
cleanup_managers();
- if (dst_active) {
- dst_lib_destroy();
- dst_active = false;
- }
+ dst_lib_destroy();
+ dst_active = false;
- if (lctx != NULL)
+ if (lctx != NULL) {
isc_log_destroy(&lctx);
+ }
- if (mctx != NULL)
+ if (mctx != NULL) {
isc_mem_destroy(&mctx);
+ }
+
+ test_running = false;
}
isc_result_t