Merge branch 'each-style-tweak' into 'master'
adjust clang-format options to get closer to ISC style See merge request isc-projects/bind9!3061 (cherry picked from commitd3b49b6675)0255a974revise .clang-format and add a C formatting script in utile851ed0bapply the modified style
This commit is contained in:
@@ -36,8 +36,7 @@
|
||||
#include "nstest.h"
|
||||
|
||||
static int
|
||||
_setup(void **state)
|
||||
{
|
||||
_setup(void **state) {
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(state);
|
||||
@@ -49,8 +48,7 @@ _setup(void **state)
|
||||
}
|
||||
|
||||
static int
|
||||
_teardown(void **state)
|
||||
{
|
||||
_teardown(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
ns_test_end();
|
||||
@@ -60,13 +58,12 @@ _teardown(void **state)
|
||||
|
||||
/* test that ns_listenlist_default() works */
|
||||
static void
|
||||
ns_listenlist_default_test(void **state)
|
||||
{
|
||||
isc_result_t result;
|
||||
in_port_t port = 5300 + isc_random8();
|
||||
ns_listenlist_default_test(void **state) {
|
||||
isc_result_t result;
|
||||
in_port_t port = 5300 + isc_random8();
|
||||
ns_listenlist_t *list = NULL;
|
||||
ns_listenelt_t * elt;
|
||||
int count;
|
||||
ns_listenelt_t *elt;
|
||||
int count;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
@@ -80,7 +77,7 @@ ns_listenlist_default_test(void **state)
|
||||
elt = ISC_LIST_HEAD(list->elts);
|
||||
while (elt != NULL) {
|
||||
ns_listenelt_t *next = ISC_LIST_NEXT(elt, link);
|
||||
dns_acl_t * acl = NULL;
|
||||
dns_acl_t *acl = NULL;
|
||||
|
||||
dns_acl_attach(elt->acl, &acl);
|
||||
ISC_LIST_UNLINK(list->elts, elt, link);
|
||||
@@ -118,8 +115,7 @@ ns_listenlist_default_test(void **state)
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(ns_listenlist_default_test,
|
||||
_setup, _teardown),
|
||||
@@ -133,8 +129,7 @@ main(void)
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
#if __SANITIZE_ADDRESS__
|
||||
/*
|
||||
* We disable this test when the address sanitizer is in
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
|
||||
#if defined(USE_LIBTOOL) || LD_WRAP
|
||||
static int
|
||||
_setup(void **state)
|
||||
{
|
||||
_setup(void **state) {
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(state);
|
||||
@@ -53,8 +52,7 @@ _setup(void **state)
|
||||
}
|
||||
|
||||
static int
|
||||
_teardown(void **state)
|
||||
{
|
||||
_teardown(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
ns_test_end();
|
||||
@@ -63,12 +61,11 @@ _teardown(void **state)
|
||||
}
|
||||
|
||||
static void
|
||||
check_response(isc_buffer_t *buf)
|
||||
{
|
||||
isc_result_t result;
|
||||
check_response(isc_buffer_t *buf) {
|
||||
isc_result_t result;
|
||||
dns_message_t *message = NULL;
|
||||
char rcodebuf[20];
|
||||
isc_buffer_t b;
|
||||
char rcodebuf[20];
|
||||
isc_buffer_t b;
|
||||
|
||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
@@ -87,14 +84,13 @@ check_response(isc_buffer_t *buf)
|
||||
|
||||
/* test ns_notify_start() */
|
||||
static void
|
||||
notify_start(void **state)
|
||||
{
|
||||
isc_result_t result;
|
||||
ns_client_t * client = NULL;
|
||||
notify_start(void **state) {
|
||||
isc_result_t result;
|
||||
ns_client_t *client = NULL;
|
||||
dns_message_t *nmsg = NULL;
|
||||
unsigned char ndata[4096];
|
||||
isc_buffer_t nbuf;
|
||||
size_t nsize;
|
||||
unsigned char ndata[4096];
|
||||
isc_buffer_t nbuf;
|
||||
size_t nsize;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
@@ -146,8 +142,7 @@ notify_start(void **state)
|
||||
#endif /* if defined(USE_LIBTOOL) || LD_WRAP */
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
#if defined(USE_LIBTOOL) || LD_WRAP
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(notify_start, _setup,
|
||||
@@ -164,8 +159,7 @@ main(void)
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
#if __SANITIZE_ADDRESS__
|
||||
/*
|
||||
* We disable this test when the address sanitizer is in
|
||||
|
||||
@@ -50,21 +50,21 @@
|
||||
#include <ns/interfacemgr.h>
|
||||
#include <ns/server.h>
|
||||
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_log_t * lctx = NULL;
|
||||
isc_taskmgr_t * taskmgr = NULL;
|
||||
isc_task_t * maintask = NULL;
|
||||
isc_timermgr_t * timermgr = NULL;
|
||||
isc_socketmgr_t * socketmgr = NULL;
|
||||
isc_nm_t * nm = NULL;
|
||||
dns_zonemgr_t * zonemgr = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_taskmgr_t *taskmgr = NULL;
|
||||
isc_task_t *maintask = NULL;
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_socketmgr_t *socketmgr = NULL;
|
||||
isc_nm_t *nm = NULL;
|
||||
dns_zonemgr_t *zonemgr = NULL;
|
||||
dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
ns_clientmgr_t * clientmgr = NULL;
|
||||
ns_clientmgr_t *clientmgr = NULL;
|
||||
ns_interfacemgr_t *interfacemgr = NULL;
|
||||
ns_server_t * sctx = NULL;
|
||||
bool app_running = false;
|
||||
int ncpus;
|
||||
bool debug_mem_record = true;
|
||||
ns_server_t *sctx = NULL;
|
||||
bool app_running = false;
|
||||
int ncpus;
|
||||
bool debug_mem_record = true;
|
||||
static atomic_bool run_managers = ATOMIC_VAR_INIT(false);
|
||||
|
||||
static bool dst_active = false;
|
||||
@@ -76,16 +76,14 @@ static dns_zone_t *served_zone = NULL;
|
||||
* We don't want to use netmgr-based client accounting, we need to emulate it.
|
||||
*/
|
||||
atomic_uint_fast32_t client_refs[32];
|
||||
atomic_uintptr_t client_addrs[32];
|
||||
atomic_uintptr_t client_addrs[32];
|
||||
|
||||
void __wrap_isc_nmhandle_unref(isc_nmhandle_t *handle);
|
||||
|
||||
void
|
||||
__wrap_isc_nmhandle_unref(isc_nmhandle_t *handle);
|
||||
|
||||
void
|
||||
__wrap_isc_nmhandle_unref(isc_nmhandle_t *handle)
|
||||
{
|
||||
__wrap_isc_nmhandle_unref(isc_nmhandle_t *handle) {
|
||||
ns_client_t *client = (ns_client_t *)handle;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (atomic_load(&client_addrs[i]) == (uintptr_t)client) {
|
||||
@@ -120,8 +118,7 @@ static isc_logcategory_t categories[] = { { "", 0 },
|
||||
static isc_result_t
|
||||
matchview(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr,
|
||||
dns_message_t *message, dns_aclenv_t *env, isc_result_t *sigresultp,
|
||||
dns_view_t **viewp)
|
||||
{
|
||||
dns_view_t **viewp) {
|
||||
UNUSED(srcaddr);
|
||||
UNUSED(destaddr);
|
||||
UNUSED(message);
|
||||
@@ -137,8 +134,7 @@ matchview(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr,
|
||||
*/
|
||||
static atomic_bool shutdown_done = ATOMIC_VAR_INIT(false);
|
||||
static void
|
||||
shutdown_managers(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
shutdown_managers(isc_task_t *task, isc_event_t *event) {
|
||||
UNUSED(task);
|
||||
|
||||
if (interfacemgr != NULL) {
|
||||
@@ -157,8 +153,7 @@ shutdown_managers(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_managers(void)
|
||||
{
|
||||
cleanup_managers(void) {
|
||||
atomic_store(&shutdown_done, false);
|
||||
|
||||
if (maintask != NULL) {
|
||||
@@ -206,8 +201,7 @@ cleanup_managers(void)
|
||||
}
|
||||
|
||||
static void
|
||||
scan_interfaces(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
scan_interfaces(isc_task_t *task, isc_event_t *event) {
|
||||
UNUSED(task);
|
||||
|
||||
ns_interfacemgr_scan(interfacemgr, true);
|
||||
@@ -215,12 +209,11 @@ scan_interfaces(isc_task_t *task, isc_event_t *event)
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
create_managers(void)
|
||||
{
|
||||
isc_result_t result;
|
||||
in_port_t port = 5300 + isc_random8();
|
||||
create_managers(void) {
|
||||
isc_result_t result;
|
||||
in_port_t port = 5300 + isc_random8();
|
||||
ns_listenlist_t *listenon = NULL;
|
||||
isc_event_t * event = NULL;
|
||||
isc_event_t *event = NULL;
|
||||
ncpus = isc_os_ncpus();
|
||||
|
||||
CHECK(isc_taskmgr_create(mctx, ncpus, 0, NULL, &taskmgr));
|
||||
@@ -269,8 +262,7 @@ cleanup:
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_test_begin(FILE *logfile, bool start_managers)
|
||||
{
|
||||
ns_test_begin(FILE *logfile, bool start_managers) {
|
||||
isc_result_t result;
|
||||
|
||||
INSIST(!test_running);
|
||||
@@ -293,7 +285,7 @@ ns_test_begin(FILE *logfile, bool start_managers)
|
||||
|
||||
if (logfile != NULL) {
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t * logconfig = NULL;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
|
||||
INSIST(lctx == NULL);
|
||||
CHECK(isc_log_create(mctx, &lctx, &logconfig));
|
||||
@@ -336,8 +328,7 @@ cleanup:
|
||||
}
|
||||
|
||||
void
|
||||
ns_test_end(void)
|
||||
{
|
||||
ns_test_end(void) {
|
||||
cleanup_managers();
|
||||
|
||||
dst_lib_destroy();
|
||||
@@ -355,10 +346,9 @@ ns_test_end(void)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_test_makeview(const char *name, bool with_cache, dns_view_t **viewp)
|
||||
{
|
||||
ns_test_makeview(const char *name, bool with_cache, dns_view_t **viewp) {
|
||||
dns_cache_t *cache = NULL;
|
||||
dns_view_t * view = NULL;
|
||||
dns_view_t *view = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
CHECK(dns_view_create(mctx, dns_rdataclass_in, name, &view));
|
||||
@@ -399,13 +389,12 @@ cleanup:
|
||||
*/
|
||||
isc_result_t
|
||||
ns_test_makezone(const char *name, dns_zone_t **zonep, dns_view_t *view,
|
||||
bool keepview)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_zone_t * zone = NULL;
|
||||
isc_buffer_t buffer;
|
||||
bool keepview) {
|
||||
isc_result_t result;
|
||||
dns_zone_t *zone = NULL;
|
||||
isc_buffer_t buffer;
|
||||
dns_fixedname_t fixorigin;
|
||||
dns_name_t * origin;
|
||||
dns_name_t *origin;
|
||||
|
||||
if (view == NULL) {
|
||||
CHECK(dns_view_create(mctx, dns_rdataclass_in, "view", &view));
|
||||
@@ -447,8 +436,7 @@ cleanup:
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_test_setupzonemgr(void)
|
||||
{
|
||||
ns_test_setupzonemgr(void) {
|
||||
isc_result_t result;
|
||||
REQUIRE(zonemgr == NULL);
|
||||
|
||||
@@ -458,8 +446,7 @@ ns_test_setupzonemgr(void)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_test_managezone(dns_zone_t *zone)
|
||||
{
|
||||
ns_test_managezone(dns_zone_t *zone) {
|
||||
isc_result_t result;
|
||||
REQUIRE(zonemgr != NULL);
|
||||
|
||||
@@ -473,15 +460,13 @@ ns_test_managezone(dns_zone_t *zone)
|
||||
}
|
||||
|
||||
void
|
||||
ns_test_releasezone(dns_zone_t *zone)
|
||||
{
|
||||
ns_test_releasezone(dns_zone_t *zone) {
|
||||
REQUIRE(zonemgr != NULL);
|
||||
dns_zonemgr_releasezone(zonemgr, zone);
|
||||
}
|
||||
|
||||
void
|
||||
ns_test_closezonemgr(void)
|
||||
{
|
||||
ns_test_closezonemgr(void) {
|
||||
REQUIRE(zonemgr != NULL);
|
||||
|
||||
dns_zonemgr_shutdown(zonemgr);
|
||||
@@ -489,10 +474,10 @@ ns_test_closezonemgr(void)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_test_serve_zone(const char *zonename, const char *filename, dns_view_t *view)
|
||||
{
|
||||
ns_test_serve_zone(const char *zonename, const char *filename,
|
||||
dns_view_t *view) {
|
||||
isc_result_t result;
|
||||
dns_db_t * db = NULL;
|
||||
dns_db_t *db = NULL;
|
||||
|
||||
/*
|
||||
* Prepare zone structure for further processing.
|
||||
@@ -554,8 +539,7 @@ free_zone:
|
||||
}
|
||||
|
||||
void
|
||||
ns_test_cleanup_zone(void)
|
||||
{
|
||||
ns_test_cleanup_zone(void) {
|
||||
ns_test_releasezone(served_zone);
|
||||
ns_test_closezonemgr();
|
||||
|
||||
@@ -563,11 +547,10 @@ ns_test_cleanup_zone(void)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp)
|
||||
{
|
||||
ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp) {
|
||||
isc_result_t result;
|
||||
ns_client_t *client = isc_mem_get(mctx, sizeof(ns_client_t));
|
||||
int i;
|
||||
int i;
|
||||
|
||||
UNUSED(ifp0);
|
||||
UNUSED(tcp);
|
||||
@@ -576,7 +559,8 @@ ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp)
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (atomic_load(&client_addrs[i]) == (uintptr_t)NULL ||
|
||||
atomic_load(&client_addrs[i]) == (uintptr_t)client) {
|
||||
atomic_load(&client_addrs[i]) == (uintptr_t)client)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -596,15 +580,14 @@ ns_test_getclient(ns_interface_t *ifp0, bool tcp, ns_client_t **clientp)
|
||||
*/
|
||||
static isc_result_t
|
||||
attach_query_msg_to_client(ns_client_t *client, const char *qnamestr,
|
||||
dns_rdatatype_t qtype, unsigned int qflags)
|
||||
{
|
||||
dns_rdatatype_t qtype, unsigned int qflags) {
|
||||
dns_rdataset_t *qrdataset = NULL;
|
||||
dns_message_t * message = NULL;
|
||||
unsigned char query[65536];
|
||||
dns_name_t * qname = NULL;
|
||||
isc_buffer_t querybuf;
|
||||
dns_compress_t cctx;
|
||||
isc_result_t result;
|
||||
dns_message_t *message = NULL;
|
||||
unsigned char query[65536];
|
||||
dns_name_t *qname = NULL;
|
||||
isc_buffer_t querybuf;
|
||||
dns_compress_t cctx;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(client != NULL);
|
||||
REQUIRE(qnamestr != NULL);
|
||||
@@ -699,10 +682,9 @@ destroy_message:
|
||||
* point.
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
extract_qctx(void *arg, void *data, isc_result_t *resultp)
|
||||
{
|
||||
extract_qctx(void *arg, void *data, isc_result_t *resultp) {
|
||||
query_ctx_t **qctxp;
|
||||
query_ctx_t * qctx;
|
||||
query_ctx_t *qctx;
|
||||
|
||||
REQUIRE(arg != NULL);
|
||||
REQUIRE(data != NULL);
|
||||
@@ -737,8 +719,7 @@ extract_qctx(void *arg, void *data, isc_result_t *resultp)
|
||||
* \li "client->message" to hold a parsed DNS query.
|
||||
*/
|
||||
static isc_result_t
|
||||
create_qctx_for_client(ns_client_t *client, query_ctx_t **qctxp)
|
||||
{
|
||||
create_qctx_for_client(ns_client_t *client, query_ctx_t **qctxp) {
|
||||
ns_hooktable_t *saved_hook_table = NULL, *query_hooks = NULL;
|
||||
const ns_hook_t hook = {
|
||||
.action = extract_qctx,
|
||||
@@ -777,8 +758,7 @@ create_qctx_for_client(ns_client_t *client, query_ctx_t **qctxp)
|
||||
|
||||
isc_result_t
|
||||
ns_test_qctx_create(const ns_test_qctx_create_params_t *params,
|
||||
query_ctx_t ** qctxp)
|
||||
{
|
||||
query_ctx_t **qctxp) {
|
||||
ns_client_t *client = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
@@ -847,8 +827,7 @@ detach_client:
|
||||
}
|
||||
|
||||
void
|
||||
ns_test_qctx_destroy(query_ctx_t **qctxp)
|
||||
{
|
||||
ns_test_qctx_destroy(query_ctx_t **qctxp) {
|
||||
query_ctx_t *qctx;
|
||||
|
||||
REQUIRE(qctxp != NULL);
|
||||
@@ -871,8 +850,7 @@ ns_test_qctx_destroy(query_ctx_t **qctxp)
|
||||
}
|
||||
|
||||
ns_hookresult_t
|
||||
ns_test_hook_catch_call(void *arg, void *data, isc_result_t *resultp)
|
||||
{
|
||||
ns_test_hook_catch_call(void *arg, void *data, isc_result_t *resultp) {
|
||||
UNUSED(arg);
|
||||
UNUSED(data);
|
||||
|
||||
@@ -885,8 +863,7 @@ ns_test_hook_catch_call(void *arg, void *data, isc_result_t *resultp)
|
||||
* Sleep for 'usec' microseconds.
|
||||
*/
|
||||
void
|
||||
ns_test_nap(uint32_t usec)
|
||||
{
|
||||
ns_test_nap(uint32_t usec) {
|
||||
#ifdef HAVE_NANOSLEEP
|
||||
struct timespec ts;
|
||||
|
||||
@@ -906,11 +883,10 @@ ns_test_nap(uint32_t usec)
|
||||
|
||||
isc_result_t
|
||||
ns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin,
|
||||
const char *testfile)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *testfile) {
|
||||
isc_result_t result;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t * name;
|
||||
dns_name_t *name;
|
||||
|
||||
name = dns_fixedname_initname(&fixed);
|
||||
|
||||
@@ -930,8 +906,7 @@ ns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin,
|
||||
}
|
||||
|
||||
static int
|
||||
fromhex(char c)
|
||||
{
|
||||
fromhex(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return (c - '0');
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
@@ -947,15 +922,14 @@ fromhex(char c)
|
||||
|
||||
isc_result_t
|
||||
ns_test_getdata(const char *file, unsigned char *buf, size_t bufsiz,
|
||||
size_t *sizep)
|
||||
{
|
||||
isc_result_t result;
|
||||
size_t *sizep) {
|
||||
isc_result_t result;
|
||||
unsigned char *bp;
|
||||
char * rp, *wp;
|
||||
char s[BUFSIZ];
|
||||
size_t len, i;
|
||||
FILE * f = NULL;
|
||||
int n;
|
||||
char *rp, *wp;
|
||||
char s[BUFSIZ];
|
||||
size_t len, i;
|
||||
FILE *f = NULL;
|
||||
int n;
|
||||
|
||||
result = isc_stdio_open(file, "r", &f);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
||||
@@ -29,16 +29,15 @@
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
_fail(const char *const file, const int line) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_PLATFORM_NORETURN_PRE void _fail(const char *const file,
|
||||
const int line) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
#include <ns/hooks.h>
|
||||
|
||||
#include "nstest.h"
|
||||
|
||||
static int
|
||||
_setup(void **state)
|
||||
{
|
||||
_setup(void **state) {
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(state);
|
||||
@@ -50,8 +49,7 @@ _setup(void **state)
|
||||
}
|
||||
|
||||
static int
|
||||
_teardown(void **state)
|
||||
{
|
||||
_teardown(void **state) {
|
||||
if (*state != NULL) {
|
||||
isc_mem_free(mctx, *state);
|
||||
}
|
||||
@@ -65,22 +63,22 @@ _teardown(void **state)
|
||||
* Structure containing parameters for run_full_path_test().
|
||||
*/
|
||||
typedef struct {
|
||||
const ns_test_id_t id; /* libns test identifier */
|
||||
const char * input; /* source string - plugin name or path
|
||||
* */
|
||||
size_t output_size; /* size of target char array to
|
||||
* allocate */
|
||||
isc_result_t result; /* expected return value */
|
||||
const char * output; /* expected output string */
|
||||
const ns_test_id_t id; /* libns test identifier */
|
||||
const char *input; /* source string - plugin name or path
|
||||
* */
|
||||
size_t output_size; /* size of target char array to
|
||||
* allocate */
|
||||
isc_result_t result; /* expected return value */
|
||||
const char *output; /* expected output string */
|
||||
} ns_plugin_expandpath_test_params_t;
|
||||
|
||||
/*%
|
||||
* Perform a single ns_plugin_expandpath() check using given parameters.
|
||||
*/
|
||||
static void
|
||||
run_full_path_test(const ns_plugin_expandpath_test_params_t *test, void **state)
|
||||
{
|
||||
char ** target = (char **)state;
|
||||
run_full_path_test(const ns_plugin_expandpath_test_params_t *test,
|
||||
void **state) {
|
||||
char **target = (char **)state;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(test != NULL);
|
||||
@@ -125,8 +123,7 @@ run_full_path_test(const ns_plugin_expandpath_test_params_t *test, void **state)
|
||||
|
||||
/* test ns_plugin_expandpath() */
|
||||
static void
|
||||
ns_plugin_expandpath_test(void **state)
|
||||
{
|
||||
ns_plugin_expandpath_test(void **state) {
|
||||
size_t i;
|
||||
|
||||
const ns_plugin_expandpath_test_params_t tests[] = {
|
||||
@@ -189,8 +186,7 @@ ns_plugin_expandpath_test(void **state)
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(ns_plugin_expandpath_test,
|
||||
_setup, _teardown),
|
||||
@@ -203,8 +199,7 @@ main(void)
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
printf("1..0 # Skipped: cmocka not available\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
|
||||
#if defined(USE_LIBTOOL) || LD_WRAP
|
||||
static int
|
||||
_setup(void **state)
|
||||
{
|
||||
_setup(void **state) {
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(state);
|
||||
@@ -49,8 +48,7 @@ _setup(void **state)
|
||||
}
|
||||
|
||||
static int
|
||||
_teardown(void **state)
|
||||
{
|
||||
_teardown(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
ns_test_end();
|
||||
@@ -66,32 +64,31 @@ _teardown(void **state)
|
||||
* Structure containing parameters for ns__query_sfcache_test().
|
||||
*/
|
||||
typedef struct {
|
||||
const ns_test_id_t id; /* libns test identifier */
|
||||
unsigned int qflags; /* query flags */
|
||||
bool cache_entry_present; /* whether a SERVFAIL
|
||||
* cache entry
|
||||
* matching the query
|
||||
* should be
|
||||
* present */
|
||||
uint32_t cache_entry_flags; /* NS_FAILCACHE_* flags to
|
||||
* set for
|
||||
* the SERVFAIL cache entry
|
||||
* */
|
||||
bool servfail_expected; /* whether a cached
|
||||
* SERVFAIL is
|
||||
* expected to be returned
|
||||
* */
|
||||
const ns_test_id_t id; /* libns test identifier */
|
||||
unsigned int qflags; /* query flags */
|
||||
bool cache_entry_present; /* whether a SERVFAIL
|
||||
* cache entry
|
||||
* matching the query
|
||||
* should be
|
||||
* present */
|
||||
uint32_t cache_entry_flags; /* NS_FAILCACHE_* flags to
|
||||
* set for
|
||||
* the SERVFAIL cache entry
|
||||
* */
|
||||
bool servfail_expected; /* whether a cached
|
||||
* SERVFAIL is
|
||||
* expected to be returned
|
||||
* */
|
||||
} ns__query_sfcache_test_params_t;
|
||||
|
||||
/*%
|
||||
* Perform a single ns__query_sfcache() check using given parameters.
|
||||
*/
|
||||
static void
|
||||
run_sfcache_test(const ns__query_sfcache_test_params_t *test)
|
||||
{
|
||||
run_sfcache_test(const ns__query_sfcache_test_params_t *test) {
|
||||
ns_hooktable_t *query_hooks = NULL;
|
||||
query_ctx_t * qctx = NULL;
|
||||
isc_result_t result;
|
||||
query_ctx_t *qctx = NULL;
|
||||
isc_result_t result;
|
||||
const ns_hook_t hook = {
|
||||
.action = ns_test_hook_catch_call,
|
||||
};
|
||||
@@ -130,7 +127,7 @@ run_sfcache_test(const ns__query_sfcache_test_params_t *test)
|
||||
*/
|
||||
if (test->cache_entry_present) {
|
||||
isc_interval_t hour;
|
||||
isc_time_t expire;
|
||||
isc_time_t expire;
|
||||
|
||||
isc_interval_set(&hour, 3600, 0);
|
||||
result = isc_time_nowplusinterval(&expire, &hour);
|
||||
@@ -171,8 +168,7 @@ run_sfcache_test(const ns__query_sfcache_test_params_t *test)
|
||||
|
||||
/* test ns__query_sfcache() */
|
||||
static void
|
||||
ns__query_sfcache_test(void **state)
|
||||
{
|
||||
ns__query_sfcache_test(void **state) {
|
||||
size_t i;
|
||||
|
||||
const ns__query_sfcache_test_params_t tests[] = {
|
||||
@@ -260,29 +256,29 @@ ns__query_sfcache_test(void **state)
|
||||
* Structure containing parameters for ns__query_start_test().
|
||||
*/
|
||||
typedef struct {
|
||||
const ns_test_id_t id; /* libns test identifier */
|
||||
const char * qname; /* QNAME */
|
||||
dns_rdatatype_t qtype; /* QTYPE */
|
||||
unsigned int qflags; /* query flags */
|
||||
bool disable_name_checks; /* if set to true, owner
|
||||
* name
|
||||
* checks will
|
||||
* be disabled for the
|
||||
* view created
|
||||
* */
|
||||
bool recursive_service; /* if set to true, the view
|
||||
* created will
|
||||
* have a cache
|
||||
* database
|
||||
* attached */
|
||||
const char *auth_zone_origin; /* origin name of the zone
|
||||
* the
|
||||
* created view will be
|
||||
* authoritative for */
|
||||
const char *auth_zone_path; /* path to load the
|
||||
* authoritative
|
||||
* zone from */
|
||||
enum { /* expected result: */
|
||||
const ns_test_id_t id; /* libns test identifier */
|
||||
const char *qname; /* QNAME */
|
||||
dns_rdatatype_t qtype; /* QTYPE */
|
||||
unsigned int qflags; /* query flags */
|
||||
bool disable_name_checks; /* if set to true, owner
|
||||
* name
|
||||
* checks will
|
||||
* be disabled for the
|
||||
* view created
|
||||
* */
|
||||
bool recursive_service; /* if set to true, the view
|
||||
* created will
|
||||
* have a cache
|
||||
* database
|
||||
* attached */
|
||||
const char *auth_zone_origin; /* origin name of the zone
|
||||
* the
|
||||
* created view will be
|
||||
* authoritative for */
|
||||
const char *auth_zone_path; /* path to load the
|
||||
* authoritative
|
||||
* zone from */
|
||||
enum { /* expected result: */
|
||||
NS__QUERY_START_R_INVALID,
|
||||
NS__QUERY_START_R_REFUSE, /* query should be REFUSED */
|
||||
NS__QUERY_START_R_CACHE, /* query should be answered from
|
||||
@@ -296,11 +292,10 @@ typedef struct {
|
||||
* Perform a single ns__query_start() check using given parameters.
|
||||
*/
|
||||
static void
|
||||
run_start_test(const ns__query_start_test_params_t *test)
|
||||
{
|
||||
run_start_test(const ns__query_start_test_params_t *test) {
|
||||
ns_hooktable_t *query_hooks = NULL;
|
||||
query_ctx_t * qctx = NULL;
|
||||
isc_result_t result;
|
||||
query_ctx_t *qctx = NULL;
|
||||
isc_result_t result;
|
||||
const ns_hook_t hook = {
|
||||
.action = ns_test_hook_catch_call,
|
||||
};
|
||||
@@ -389,8 +384,8 @@ run_start_test(const ns__query_start_test_params_t *test)
|
||||
"query context, but some was",
|
||||
test->id.description, test->id.lineno);
|
||||
}
|
||||
if (qctx->db == NULL ||
|
||||
qctx->db != qctx->client->view->cachedb) {
|
||||
if (qctx->db == NULL || qctx->db != qctx->client->view->cachedb)
|
||||
{
|
||||
fail_msg("# test \"%s\" on line %d: "
|
||||
"cache database was expected to be "
|
||||
"attached to query context, but it was not",
|
||||
@@ -438,8 +433,7 @@ run_start_test(const ns__query_start_test_params_t *test)
|
||||
|
||||
/* test ns__query_start() */
|
||||
static void
|
||||
ns__query_start_test(void **state)
|
||||
{
|
||||
ns__query_start_test(void **state) {
|
||||
size_t i;
|
||||
|
||||
const ns__query_start_test_params_t tests[] = {
|
||||
@@ -609,8 +603,7 @@ ns__query_start_test(void **state)
|
||||
#endif /* if defined(USE_LIBTOOL) || LD_WRAP */
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
#if defined(USE_LIBTOOL) || LD_WRAP
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(ns__query_sfcache_test, _setup,
|
||||
@@ -630,8 +623,7 @@ main(void)
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
main(void) {
|
||||
#if __SANITIZE_ADDRESS__
|
||||
/*
|
||||
* We disable this test when the address sanitizer is in
|
||||
|
||||
@@ -31,11 +31,9 @@
|
||||
* can't be used.
|
||||
*/
|
||||
|
||||
extern void
|
||||
__wrap_isc_nmhandle_unref(isc_nmhandle_t *handle);
|
||||
extern void __wrap_isc_nmhandle_unref(isc_nmhandle_t *handle);
|
||||
|
||||
void
|
||||
isc_nmhandle_unref(isc_nmhandle_t *handle)
|
||||
{
|
||||
isc_nmhandle_unref(isc_nmhandle_t *handle) {
|
||||
__wrap_isc_nmhandle_unref(handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user