mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
Merge branch 'michal/bind-to-random-port-numbers-in-unit-tests' into 'master'
Bind to random port numbers in unit tests See merge request isc-projects/bind9!2831
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <isc/list.h>
|
#include <isc/list.h>
|
||||||
#include <isc/print.h>
|
#include <isc/print.h>
|
||||||
|
#include <isc/random.h>
|
||||||
|
|
||||||
#include <dns/acl.h>
|
#include <dns/acl.h>
|
||||||
|
|
||||||
@@ -60,13 +61,14 @@ _teardown(void **state) {
|
|||||||
static void
|
static void
|
||||||
ns_listenlist_default_test(void **state) {
|
ns_listenlist_default_test(void **state) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
in_port_t port = 5300 + isc_random8();
|
||||||
ns_listenlist_t *list = NULL;
|
ns_listenlist_t *list = NULL;
|
||||||
ns_listenelt_t *elt;
|
ns_listenelt_t *elt;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
result = ns_listenlist_default(mctx, 5300, -1, false, &list);
|
result = ns_listenlist_default(mctx, port, -1, false, &list);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
assert_non_null(list);
|
assert_non_null(list);
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ ns_listenlist_default_test(void **state) {
|
|||||||
|
|
||||||
ns_listenlist_detach(&list);
|
ns_listenlist_detach(&list);
|
||||||
|
|
||||||
result = ns_listenlist_default(mctx, 5300, -1, true, &list);
|
result = ns_listenlist_default(mctx, port, -1, true, &list);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
assert_false(ISC_LIST_EMPTY(list->elts));
|
assert_false(ISC_LIST_EMPTY(list->elts));
|
||||||
|
@@ -215,6 +215,7 @@ scan_interfaces(isc_task_t *task, isc_event_t *event) {
|
|||||||
static isc_result_t
|
static isc_result_t
|
||||||
create_managers(void) {
|
create_managers(void) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
in_port_t port = 5300 + isc_random8();
|
||||||
ns_listenlist_t *listenon = NULL;
|
ns_listenlist_t *listenon = NULL;
|
||||||
isc_event_t *event = NULL;
|
isc_event_t *event = NULL;
|
||||||
ncpus = isc_os_ncpus();
|
ncpus = isc_os_ncpus();
|
||||||
@@ -238,7 +239,7 @@ create_managers(void) {
|
|||||||
socketmgr, nm, dispatchmgr, maintask,
|
socketmgr, nm, dispatchmgr, maintask,
|
||||||
ncpus, NULL, &interfacemgr));
|
ncpus, NULL, &interfacemgr));
|
||||||
|
|
||||||
CHECK(ns_listenlist_default(mctx, 5300, -1, true, &listenon));
|
CHECK(ns_listenlist_default(mctx, port, -1, true, &listenon));
|
||||||
ns_interfacemgr_setlistenon4(interfacemgr, listenon);
|
ns_interfacemgr_setlistenon4(interfacemgr, listenon);
|
||||||
ns_listenlist_detach(&listenon);
|
ns_listenlist_detach(&listenon);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user