The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
trunk_tests.c File Reference
#include <freeradius-devel/util/acutest.h>
#include <freeradius-devel/util/acutest_helpers.h>
#include <freeradius-devel/util/syserror.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "trunk.c"
+ Include dependency graph for trunk_tests.c:

Go to the source code of this file.

Data Structures

struct  test_proto_request_t
 
struct  test_proto_stats_t
 

Macros

#define ALLOC_REQ(_id)
 
#define DEBUG_LVL_SET   if (acutest_verbose_level_ >= 3) fr_debug_lvl = L_DBG_LVL_4 + 1
 
#define TRUNK_TESTS   1
 

Functions

static void _conn_close (UNUSED fr_event_list_t *el, void *h, UNUSED void *uctx)
 
static void _conn_io_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, UNUSED int fd_errno, void *uctx)
 
static void _conn_io_loopback (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 Whenever the second socket in a socket pair is readable, read all pending data, and write it back. More...
 
static void _conn_io_read (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 
static void _conn_io_write (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 
static void _conn_notify (trunk_connection_t *tconn, connection_t *conn, fr_event_list_t *el, trunk_connection_event_t notify_on, UNUSED void *uctx)
 
static connection_state_t _conn_open (fr_event_list_t *el, void *h, UNUSED void *uctx)
 Insert I/O handlers that loop any data back round. More...
 
 CC_NO_UBSAN (function)
 Allocate a basic socket pair. More...
 
static void test_cancel_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static void test_connection_levels_alternating_edges (void)
 
static void test_connection_levels_max (void)
 
static void test_connection_rebalance_requests (void)
 
static void test_connection_start_on_enqueue (void)
 
static void test_demux (UNUSED fr_event_list_t *el, UNUSED trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static void test_enqueue_and_io_speed (void)
 
static void test_enqueue_basic (void)
 
static void test_enqueue_cancellation_points (void)
 
static void test_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static void test_partial_to_complete_states (void)
 
static int8_t test_preq_cmp (void const *a, void const *b)
 
static void test_request_cancel (UNUSED connection_t *conn, void *preq, UNUSED trunk_cancel_reason_t reason, void *uctx)
 
static void test_request_complete (UNUSED request_t *request, void *preq, UNUSED void *rctx, void *uctx)
 
static void test_request_fail (UNUSED request_t *request, void *preq, UNUSED void *rctx, UNUSED trunk_request_state_t state, void *uctx)
 
static void test_request_free (UNUSED request_t *request, void *preq, void *uctx)
 
static void test_requeue_on_reconnect (void)
 
static connection_ttest_setup_socket_pair_1s_reconnection_delay_alloc (trunk_connection_t *tconn, fr_event_list_t *el, UNUSED connection_conf_t const *conn_conf, char const *log_prefix, void *uctx)
 
static connection_ttest_setup_socket_pair_1s_timeout_connection_alloc (trunk_connection_t *tconn, fr_event_list_t *el, UNUSED connection_conf_t const *conf, char const *log_prefix, void *uctx)
 
static connection_ttest_setup_socket_pair_connection_alloc (trunk_connection_t *tconn, fr_event_list_t *el, connection_conf_t const *conn_conf, char const *log_prefix, UNUSED void *uctx)
 
static trunk_ttest_setup_trunk (TALLOC_CTX *ctx, fr_event_list_t *el, trunk_conf_t *conf, bool with_cancel_mux, void *uctx)
 
static void test_socket_pair_alloc_then_connect_timeout (void)
 
static void test_socket_pair_alloc_then_free (void)
 
static void test_socket_pair_alloc_then_reconnect_check_delay (void)
 
static void test_socket_pair_alloc_then_reconnect_then_free (void)
 

Variables

 TEST_LIST
 

Data Structure Documentation

◆ test_proto_request_t

struct test_proto_request_t

Definition at line 11 of file trunk_tests.c.

+ Collaboration diagram for test_proto_request_t:
Data Fields
bool cancelled Seen by the cancelled callback.
bool completed Seen by the complete callback.
bool failed Seen by the failed callback.
bool freed Seen by the free callback.
int priority Priority of request.
bool signal_cancel_partial Muxer should signal that this request is partially cancelled.
bool signal_partial Muxer should signal that this request is partially written.
trunk_request_t * treq Trunk request.

◆ test_proto_stats_t

struct test_proto_stats_t

Definition at line 22 of file trunk_tests.c.

Data Fields
uint64_t cancelled Count of tests in this run that were cancelled.
uint64_t completed Count of tests in this run that completed.
uint64_t failed Count of tests in this run that failed.
uint64_t freed Count of tests in this run that were freed.

Macro Definition Documentation

◆ ALLOC_REQ

#define ALLOC_REQ (   _id)
Value:
do { \
treq_##_id = trunk_request_alloc(trunk, NULL); \
preq_##_id = talloc_zero(ctx, test_proto_request_t); \
preq_##_id->treq = treq_##_id; \
preq_##_id->priority = next_prio++; \
} while (0)
trunk_request_t * trunk_request_alloc(trunk_t *trunk, request_t *request)
(Pre-)Allocate a new trunk request
Definition: trunk.c:2462

Definition at line 1494 of file trunk_tests.c.

◆ DEBUG_LVL_SET

#define DEBUG_LVL_SET   if (acutest_verbose_level_ >= 3) fr_debug_lvl = L_DBG_LVL_4 + 1

Definition at line 29 of file trunk_tests.c.

◆ TRUNK_TESTS

#define TRUNK_TESTS   1

Definition at line 7 of file trunk_tests.c.

Function Documentation

◆ _conn_close()

static void _conn_close ( UNUSED fr_event_list_t el,
void *  h,
UNUSED void *  uctx 
)
static

Definition at line 283 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _conn_io_error()

static void _conn_io_error ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
UNUSED int  fd_errno,
void *  uctx 
)
static

Definition at line 151 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _conn_io_loopback()

static void _conn_io_loopback ( UNUSED fr_event_list_t el,
int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Whenever the second socket in a socket pair is readable, read all pending data, and write it back.

Definition at line 252 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _conn_io_read()

static void _conn_io_read ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Definition at line 160 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _conn_io_write()

static void _conn_io_write ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Definition at line 166 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _conn_notify()

static void _conn_notify ( trunk_connection_t tconn,
connection_t conn,
fr_event_list_t el,
trunk_connection_event_t  notify_on,
UNUSED void *  uctx 
)
static

Definition at line 172 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _conn_open()

static connection_state_t _conn_open ( fr_event_list_t el,
void *  h,
UNUSED void *  uctx 
)
static

Insert I/O handlers that loop any data back round.

Definition at line 298 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CC_NO_UBSAN()

CC_NO_UBSAN ( function  )

Allocate a basic socket pair.

Definition at line 313 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_cancel_mux()

static void test_cancel_mux ( UNUSED fr_event_list_t el,
trunk_connection_t tconn,
connection_t conn,
UNUSED void *  uctx 
)
static

Definition at line 63 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_connection_levels_alternating_edges()

static void test_connection_levels_alternating_edges ( void  )
static

Definition at line 1662 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_levels_max()

static void test_connection_levels_max ( void  )
static

Definition at line 1502 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_rebalance_requests()

static void test_connection_rebalance_requests ( void  )
static

Definition at line 1432 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_start_on_enqueue()

static void test_connection_start_on_enqueue ( void  )
static

Definition at line 1372 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_demux()

static void test_demux ( UNUSED fr_event_list_t el,
UNUSED trunk_connection_t tconn,
connection_t conn,
UNUSED void *  uctx 
)
static

Definition at line 100 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_enqueue_and_io_speed()

static void test_enqueue_and_io_speed ( void  )
static

Definition at line 1822 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_enqueue_basic()

static void test_enqueue_basic ( void  )
static

Definition at line 661 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_enqueue_cancellation_points()

static void test_enqueue_cancellation_points ( void  )
static

Definition at line 762 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_mux()

static void test_mux ( UNUSED fr_event_list_t el,
trunk_connection_t tconn,
connection_t conn,
UNUSED void *  uctx 
)
static

Definition at line 31 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_partial_to_complete_states()

static void test_partial_to_complete_states ( void  )
static

Definition at line 1009 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_preq_cmp()

static int8_t test_preq_cmp ( void const *  a,
void const *  b 
)
static

Definition at line 350 of file trunk_tests.c.

+ Here is the caller graph for this function:

◆ test_request_cancel()

static void test_request_cancel ( UNUSED connection_t conn,
void *  preq,
UNUSED trunk_cancel_reason_t  reason,
void *  uctx 
)
static

Definition at line 200 of file trunk_tests.c.

+ Here is the caller graph for this function:

◆ test_request_complete()

static void test_request_complete ( UNUSED request_t request,
void *  preq,
UNUSED void *  rctx,
void *  uctx 
)
static

Definition at line 213 of file trunk_tests.c.

+ Here is the caller graph for this function:

◆ test_request_fail()

static void test_request_fail ( UNUSED request_t request,
void *  preq,
UNUSED void *  rctx,
UNUSED trunk_request_state_t  state,
void *  uctx 
)
static

Definition at line 225 of file trunk_tests.c.

+ Here is the caller graph for this function:

◆ test_request_free()

static void test_request_free ( UNUSED request_t request,
void *  preq,
void *  uctx 
)
static

Definition at line 237 of file trunk_tests.c.

+ Here is the caller graph for this function:

◆ test_requeue_on_reconnect()

static void test_requeue_on_reconnect ( void  )
static

Definition at line 1084 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_setup_socket_pair_1s_reconnection_delay_alloc()

static connection_t* test_setup_socket_pair_1s_reconnection_delay_alloc ( trunk_connection_t tconn,
fr_event_list_t el,
UNUSED connection_conf_t const *  conn_conf,
char const *  log_prefix,
void *  uctx 
)
static

Definition at line 569 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_setup_socket_pair_1s_timeout_connection_alloc()

static connection_t* test_setup_socket_pair_1s_timeout_connection_alloc ( trunk_connection_t tconn,
fr_event_list_t el,
UNUSED connection_conf_t const *  conf,
char const *  log_prefix,
void *  uctx 
)
static

Definition at line 491 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_setup_socket_pair_connection_alloc()

static connection_t* test_setup_socket_pair_connection_alloc ( trunk_connection_t tconn,
fr_event_list_t el,
connection_conf_t const *  conn_conf,
char const *  log_prefix,
UNUSED void *  uctx 
)
static

Definition at line 329 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_setup_trunk()

static trunk_t* test_setup_trunk ( TALLOC_CTX *  ctx,
fr_event_list_t el,
trunk_conf_t conf,
bool  with_cancel_mux,
void *  uctx 
)
static

Definition at line 357 of file trunk_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_socket_pair_alloc_then_connect_timeout()

static void test_socket_pair_alloc_then_connect_timeout ( void  )
static

Definition at line 509 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_socket_pair_alloc_then_free()

static void test_socket_pair_alloc_then_free ( void  )
static

Definition at line 379 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_socket_pair_alloc_then_reconnect_check_delay()

static void test_socket_pair_alloc_then_reconnect_check_delay ( void  )
static

Definition at line 587 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_socket_pair_alloc_then_reconnect_then_free()

static void test_socket_pair_alloc_then_reconnect_then_free ( void  )
static

Definition at line 418 of file trunk_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "Basic - Alloc then free", test_socket_pair_alloc_then_free },
{ "Basic - Alloc then reconnect then free", test_socket_pair_alloc_then_reconnect_then_free },
{ "Timeouts - Connection", test_socket_pair_alloc_then_connect_timeout },
{ "Timeouts - Reconnect delay", test_socket_pair_alloc_then_reconnect_check_delay },
{ "Enqueue - Basic", test_enqueue_basic },
{ "Enqueue - Cancellation points", test_enqueue_cancellation_points },
{ "Enqueue - Partial state transitions", test_partial_to_complete_states },
{ "Requeue - On reconnect", test_requeue_on_reconnect },
{ "Rebalance - Connection rebalance", test_connection_rebalance_requests },
{ "Spawn - Test connection start on enqueue", test_connection_start_on_enqueue },
{ "Spawn - Connection levels max", test_connection_levels_max },
{ "Spawn - Connection levels alternating edges",test_connection_levels_alternating_edges },
{ "Speed Test - Enqueue, and I/O", test_enqueue_and_io_speed },
{ NULL }
}
static void test_enqueue_and_io_speed(void)
Definition: trunk_tests.c:1822
static void test_socket_pair_alloc_then_connect_timeout(void)
Definition: trunk_tests.c:509
static void test_partial_to_complete_states(void)
Definition: trunk_tests.c:1009
static void test_socket_pair_alloc_then_free(void)
Definition: trunk_tests.c:379
static void test_connection_rebalance_requests(void)
Definition: trunk_tests.c:1432
static void test_connection_levels_max(void)
Definition: trunk_tests.c:1502
static void test_socket_pair_alloc_then_reconnect_check_delay(void)
Definition: trunk_tests.c:587
static void test_socket_pair_alloc_then_reconnect_then_free(void)
Definition: trunk_tests.c:418
static void test_enqueue_cancellation_points(void)
Definition: trunk_tests.c:762
static void test_requeue_on_reconnect(void)
Definition: trunk_tests.c:1084
static void test_connection_start_on_enqueue(void)
Definition: trunk_tests.c:1372
static void test_enqueue_basic(void)
Definition: trunk_tests.c:661
static void test_connection_levels_alternating_edges(void)
Definition: trunk_tests.c:1662

Definition at line 1935 of file trunk_tests.c.