mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 18:19:42 +00:00
WIP: QUIC dispatcher experiments
This commit is contained in:
parent
9cb53c7e68
commit
02ff0ae2cc
@ -69,6 +69,7 @@ endif
|
|||||||
if config.has('HAVE_LIBNGTCP2')
|
if config.has('HAVE_LIBNGTCP2')
|
||||||
isc_test += [
|
isc_test += [
|
||||||
'ngtcp2_integration',
|
'ngtcp2_integration',
|
||||||
|
'quic_dispatcher',
|
||||||
'quic_session',
|
'quic_session',
|
||||||
'quic_tls',
|
'quic_tls',
|
||||||
]
|
]
|
||||||
|
135
tests/isc/quic_dispatcher_test.c
Normal file
135
tests/isc/quic_dispatcher_test.c
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sched.h> /* IWYU pragma: keep */
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define UNIT_TESTING
|
||||||
|
#include <cmocka.h>
|
||||||
|
|
||||||
|
#include <isc/buffer.h>
|
||||||
|
#include <isc/lib.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
#include <isc/ngtcp2_utils.h>
|
||||||
|
#include <isc/quic.h>
|
||||||
|
#include <isc/random.h>
|
||||||
|
#include <isc/time.h>
|
||||||
|
#include <isc/tls.h>
|
||||||
|
#include <isc/urcu.h>
|
||||||
|
|
||||||
|
#include <tests/isc.h>
|
||||||
|
|
||||||
|
static struct call_rcu_data *thread_call_rcu_data = NULL;
|
||||||
|
|
||||||
|
static isc_mem_t *mctx = NULL;
|
||||||
|
|
||||||
|
static isc_tlsctx_t *default_server_tlsctx = NULL;
|
||||||
|
static isc_tlsctx_t *default_client_tlsctx = NULL;
|
||||||
|
|
||||||
|
ISC_RUN_TEST_IMPL(quic_dispatcher_noop_test) {
|
||||||
|
isc_quic_cid_map_t *map = NULL;
|
||||||
|
isc_quic_cid_map_create(mctx, &map);
|
||||||
|
|
||||||
|
isc_quic_cid_map_detach(&map);
|
||||||
|
}
|
||||||
|
|
||||||
|
static isc_tlsctx_t *
|
||||||
|
create_quic_tls_context(const bool is_server,
|
||||||
|
const isc_tls_quic_interface_t *iface) {
|
||||||
|
isc_tlsctx_t *tlsctx = NULL;
|
||||||
|
isc_result_t result;
|
||||||
|
|
||||||
|
if (is_server) {
|
||||||
|
result = isc_tlsctx_createserver(NULL, NULL, &tlsctx);
|
||||||
|
} else {
|
||||||
|
result = isc_tlsctx_createclient(&tlsctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_tlsctx_set_random_session_id_context(tlsctx);
|
||||||
|
isc_tlsctx_quic_configure(tlsctx, iface);
|
||||||
|
|
||||||
|
return tlsctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
quic_dispatcher_test_setup(void **state) {
|
||||||
|
UNUSED(state);
|
||||||
|
|
||||||
|
default_server_tlsctx = create_quic_tls_context(
|
||||||
|
true, isc_tls_get_default_quic_interface());
|
||||||
|
|
||||||
|
if (default_server_tlsctx == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
default_client_tlsctx = create_quic_tls_context(
|
||||||
|
false, isc_tls_get_default_quic_interface());
|
||||||
|
|
||||||
|
if (default_client_tlsctx == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
quic_dispatcher_test_teardown(void **state) {
|
||||||
|
UNUSED(state);
|
||||||
|
|
||||||
|
isc_tlsctx_free(&default_client_tlsctx);
|
||||||
|
isc_tlsctx_free(&default_server_tlsctx);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
quic_dispatcher_testset_setup(void **state) {
|
||||||
|
UNUSED(state);
|
||||||
|
|
||||||
|
set_thread_call_rcu_data(thread_call_rcu_data);
|
||||||
|
|
||||||
|
isc_tls_quic_crypto_initialize();
|
||||||
|
|
||||||
|
isc_mem_create("testctx", &mctx);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
quic_dispatcher_testset_teardown(void **state) {
|
||||||
|
UNUSED(state);
|
||||||
|
|
||||||
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
|
isc_tls_quic_crypto_shutdown();
|
||||||
|
|
||||||
|
set_thread_call_rcu_data(NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISC_TEST_LIST_START
|
||||||
|
ISC_TEST_ENTRY_CUSTOM(quic_dispatcher_noop_test, quic_dispatcher_test_setup,
|
||||||
|
quic_dispatcher_test_teardown)
|
||||||
|
ISC_TEST_LIST_END
|
||||||
|
|
||||||
|
ISC_TEST_MAIN_CUSTOM(quic_dispatcher_testset_setup,
|
||||||
|
quic_dispatcher_testset_teardown);
|
Loading…
x
Reference in New Issue
Block a user