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 fr_connection_state_t _conn_init (void **h_out, fr_connection_t *conn, UNUSED void *uctx)
 Allocate a basic socket pair. More...
 
static fr_connection_state_t _conn_init_no_signal (void **h_out, fr_connection_t *conn, 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 (fr_trunk_connection_t *tconn, fr_connection_t *conn, fr_event_list_t *el, fr_trunk_connection_event_t notify_on, UNUSED void *uctx)
 
static fr_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...
 
static void test_cancel_mux (UNUSED fr_event_list_t *el, fr_trunk_connection_t *tconn, fr_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 fr_trunk_connection_t *tconn, fr_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, fr_trunk_connection_t *tconn, fr_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 fr_connection_t *conn, void *preq, UNUSED fr_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 fr_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 fr_connection_ttest_setup_socket_pair_1s_reconnection_delay_alloc (fr_trunk_connection_t *tconn, fr_event_list_t *el, UNUSED fr_connection_conf_t const *conn_conf, char const *log_prefix, void *uctx)
 
static fr_connection_ttest_setup_socket_pair_1s_timeout_connection_alloc (fr_trunk_connection_t *tconn, fr_event_list_t *el, UNUSED fr_connection_conf_t const *conf, char const *log_prefix, void *uctx)
 
static fr_connection_ttest_setup_socket_pair_connection_alloc (fr_trunk_connection_t *tconn, fr_event_list_t *el, fr_connection_conf_t const *conn_conf, char const *log_prefix, UNUSED void *uctx)
 
static fr_trunk_ttest_setup_trunk (TALLOC_CTX *ctx, fr_event_list_t *el, fr_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.
fr_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 = fr_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)
fr_trunk_request_t * fr_trunk_request_alloc(fr_trunk_t *trunk, request_t *request)
(Pre-)Allocate a new trunk request
Definition: trunk.c:2369

Definition at line 1492 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_init()

static fr_connection_state_t _conn_init ( void **  h_out,
fr_connection_t conn,
UNUSED void *  uctx 
)
static

Allocate a basic socket pair.

Definition at line 313 of file trunk_tests.c.

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

◆ _conn_init_no_signal()

static fr_connection_state_t _conn_init_no_signal ( void **  h_out,
fr_connection_t conn,
UNUSED void *  uctx 
)
static

Definition at line 478 of file trunk_tests.c.

+ 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 ( fr_trunk_connection_t tconn,
fr_connection_t conn,
fr_event_list_t el,
fr_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 fr_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:

◆ test_cancel_mux()

static void test_cancel_mux ( UNUSED fr_event_list_t el,
fr_trunk_connection_t tconn,
fr_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 1660 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 1500 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 1430 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 1370 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 fr_trunk_connection_t tconn,
fr_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 1820 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 659 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 760 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,
fr_trunk_connection_t tconn,
fr_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 1007 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 349 of file trunk_tests.c.

+ Here is the caller graph for this function:

◆ test_request_cancel()

static void test_request_cancel ( UNUSED fr_connection_t conn,
void *  preq,
UNUSED fr_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 fr_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 1082 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_setup_socket_pair_1s_reconnection_delay_alloc()

static fr_connection_t* test_setup_socket_pair_1s_reconnection_delay_alloc ( fr_trunk_connection_t tconn,
fr_event_list_t el,
UNUSED fr_connection_conf_t const *  conn_conf,
char const *  log_prefix,
void *  uctx 
)
static

Definition at line 567 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 fr_connection_t* test_setup_socket_pair_1s_timeout_connection_alloc ( fr_trunk_connection_t tconn,
fr_event_list_t el,
UNUSED fr_connection_conf_t const *  conf,
char const *  log_prefix,
void *  uctx 
)
static

Definition at line 489 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 fr_connection_t* test_setup_socket_pair_connection_alloc ( fr_trunk_connection_t tconn,
fr_event_list_t el,
fr_connection_conf_t const *  conn_conf,
char const *  log_prefix,
UNUSED void *  uctx 
)
static

Definition at line 328 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 fr_trunk_t* test_setup_trunk ( TALLOC_CTX *  ctx,
fr_event_list_t el,
fr_trunk_conf_t conf,
bool  with_cancel_mux,
void *  uctx 
)
static

Definition at line 356 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 507 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 378 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 585 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 417 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:1820
static void test_socket_pair_alloc_then_connect_timeout(void)
Definition: trunk_tests.c:507
static void test_partial_to_complete_states(void)
Definition: trunk_tests.c:1007
static void test_socket_pair_alloc_then_free(void)
Definition: trunk_tests.c:378
static void test_connection_rebalance_requests(void)
Definition: trunk_tests.c:1430
static void test_connection_levels_max(void)
Definition: trunk_tests.c:1500
static void test_socket_pair_alloc_then_reconnect_check_delay(void)
Definition: trunk_tests.c:585
static void test_socket_pair_alloc_then_reconnect_then_free(void)
Definition: trunk_tests.c:417
static void test_enqueue_cancellation_points(void)
Definition: trunk_tests.c:760
static void test_requeue_on_reconnect(void)
Definition: trunk_tests.c:1082
static void test_connection_start_on_enqueue(void)
Definition: trunk_tests.c:1370
static void test_enqueue_basic(void)
Definition: trunk_tests.c:659
static void test_connection_levels_alternating_edges(void)
Definition: trunk_tests.c:1660

Definition at line 1933 of file trunk_tests.c.