mirror of
https://github.com/isc-projects/bind9.git
synced 2026-02-23 01:40:23 -05:00
Move the libtest code into a 'libtest' subdirectory and make it
one of the SUBDIRS in the tests Makefile. having it at the top level
required having "." as one of the subdirs, and that caused the
unit tests to be executed twice.
(cherry picked from commit 568f65cc56)
87 lines
1.7 KiB
C
87 lines
1.7 KiB
C
/*
|
|
* 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 <inttypes.h>
|
|
#include <signal.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>
|
|
|
|
#include "netmgr_p.h"
|
|
#include "task_p.h"
|
|
#include "timer_p.h"
|
|
|
|
#include <tests/isc.h>
|
|
|
|
isc_mem_t *mctx = NULL;
|
|
isc_taskmgr_t *taskmgr = NULL;
|
|
isc_timermgr_t *timermgr = NULL;
|
|
isc_nm_t *netmgr = NULL;
|
|
unsigned int workers = 0;
|
|
isc_task_t *maintask = NULL;
|
|
|
|
int
|
|
setup_managers(void **state) {
|
|
isc_result_t result;
|
|
|
|
UNUSED(state);
|
|
|
|
REQUIRE(mctx != NULL);
|
|
|
|
if (workers == 0) {
|
|
char *env_workers = getenv("ISC_TASK_WORKERS");
|
|
if (env_workers != NULL) {
|
|
workers = atoi(env_workers);
|
|
} else {
|
|
workers = isc_os_ncpus();
|
|
}
|
|
INSIST(workers > 0);
|
|
}
|
|
|
|
result = isc_managers_create(mctx, workers, 0, &netmgr, &taskmgr,
|
|
&timermgr);
|
|
if (result != ISC_R_SUCCESS) {
|
|
return (-1);
|
|
}
|
|
|
|
result = isc_task_create_bound(taskmgr, 0, &maintask, 0);
|
|
if (result != ISC_R_SUCCESS) {
|
|
return (-1);
|
|
}
|
|
|
|
isc_taskmgr_setexcltask(taskmgr, maintask);
|
|
|
|
return (0);
|
|
}
|
|
|
|
int
|
|
teardown_managers(void **state) {
|
|
UNUSED(state);
|
|
|
|
isc_task_detach(&maintask);
|
|
isc_managers_destroy(&netmgr, &taskmgr, &timermgr);
|
|
|
|
return (0);
|
|
}
|