The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
trunk_tests.c File Reference
#include <freeradius-devel/util/test/acutest.h>
#include <freeradius-devel/util/test/acutest_helpers.h>
#include <freeradius-devel/util/syserror.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_conn_t
 
struct  test_proto_request_t
 
struct  test_proto_stats_t
 
struct  test_sent_t
 A request the muxer has written, waiting for the demuxer. More...
 

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 connection_state_t _conn_init (void **h_out, connection_t *conn, UNUSED void *uctx)
 Allocate a basic socket pair.
 
static connection_state_t _conn_init_no_signal (void **h_out, 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.
 
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.
 
static void test_cancel_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static int test_conn_write (test_conn_t *tc, test_proto_request_t *preq)
 Write a request to the connection.
 
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 fr_cmp_ret_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_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 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 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 trunk_t * test_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)
 
static void test_trunk_state_full (void)
 
static void test_trunk_state_pending_active_failed (void)
 

Variables

 TEST_LIST
 

Data Structure Documentation

◆ test_conn_t

struct test_conn_t

Definition at line 40 of file trunk_tests.c.

+ Collaboration diagram for test_conn_t:
Data Fields
int fd[2] Socket pair. fd[1] loops data back to fd[0].
fr_dlist_head_t sent Requests written, in the order they were written.

◆ test_proto_request_t

struct test_proto_request_t

Definition at line 9 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 20 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.

◆ test_sent_t

struct test_sent_t

A request the muxer has written, waiting for the demuxer.

The muxer keeps written requests in memory, and writes one byte to the socket pair for each. The demuxer takes one request off the list for each byte that comes back. Writing the request pointers themselves through the socket would make every pointer the demuxer reads back untrusted data.

Definition at line 35 of file trunk_tests.c.

+ Collaboration diagram for test_sent_t:
Data Fields
fr_dlist_t entry Entry in test_conn_t sent.
test_proto_request_t * preq Request that was written.

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:2542

Definition at line 1523 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 45 of file trunk_tests.c.

◆ TRUNK_TESTS

#define TRUNK_TESTS   1

Definition at line 6 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 309 of file trunk_tests.c.

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

◆ _conn_init()

static connection_state_t _conn_init ( void **  h_out,
connection_t *  conn,
UNUSED void *  uctx 
)
static

Allocate a basic socket pair.

Definition at line 340 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 connection_state_t _conn_init_no_signal ( void **  h_out,
connection_t *  conn,
UNUSED void *  uctx 
)
static

Definition at line 508 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 176 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 278 of file trunk_tests.c.

+ 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 185 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 191 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 197 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 324 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,
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_conn_write()

static int test_conn_write ( test_conn_t *  tc,
test_proto_request_t *  preq 
)
static

Write a request to the connection.

Returns
  • 1 if the request was written.
  • 0 if the socket would block.
  • -1 on error.

Definition at line 54 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 1691 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 1531 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 1461 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 1401 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 136 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 1994 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 690 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 791 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 70 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 1038 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_preq_cmp()

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

Definition at line 377 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 226 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 239 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 251 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 263 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 1113 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 598 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 520 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 356 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 385 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 538 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 407 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 616 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 446 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_trunk_state_full()

static void test_trunk_state_full ( void  )
static

Definition at line 1925 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_trunk_state_pending_active_failed()

static void test_trunk_state_pending_active_failed ( void  )
static

Definition at line 1853 of file trunk_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ TEST_LIST

TEST_LIST

Definition at line 2107 of file trunk_tests.c.