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 void test_complete_from_mux (void)
 
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_order_after_demux (void)
 
static void test_connection_order_lru (void)
 
static void test_connection_order_lru_after_write (void)
 
static void test_connection_order_mrs (void)
 
static void test_connection_order_rto (void)
 
static void test_connection_order_sort (void)
 
static void test_connection_order_window (void)
 
static void test_connection_order_zero_window (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)
 
static void test_two_active (trunk_t *trunk, trunk_connection_t **a, trunk_connection_t **b)
 Get the two active connections of a trunk which has two connections.
 

Variables

 TEST_LIST
 

Data Structure Documentation

◆ test_conn_t

struct test_conn_t

Definition at line 42 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 complete_on_write Muxer signals complete after the write, instead of sent.

The request needs no reply, as with replicated packets.

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.

◆ 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 37 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:2615

Definition at line 2276 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 47 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 321 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 352 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 520 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 188 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 290 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 197 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 203 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 209 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 336 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 112 of file trunk_tests.c.

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

◆ test_complete_from_mux()

static void test_complete_from_mux ( void  )
static

Definition at line 1125 of file trunk_tests.c.

+ Here is the call 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 56 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 2444 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 2284 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_after_demux()

static void test_connection_order_after_demux ( void  )
static

Definition at line 2203 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_lru()

static void test_connection_order_lru ( void  )
static

Definition at line 1818 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_lru_after_write()

static void test_connection_order_lru_after_write ( void  )
static

Definition at line 2134 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_mrs()

static void test_connection_order_mrs ( void  )
static

Definition at line 1921 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_rto()

static void test_connection_order_rto ( void  )
static

Definition at line 2016 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_sort()

static void test_connection_order_sort ( void  )
static

Definition at line 1761 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_window()

static void test_connection_order_window ( void  )
static

Definition at line 1707 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_connection_order_zero_window()

static void test_connection_order_zero_window ( void  )
static

Definition at line 1651 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 1578 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 1518 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 148 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 2747 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 702 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 803 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 73 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 1050 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 389 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 238 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 251 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 263 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 275 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 1230 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 610 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 532 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 368 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 397 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 550 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 419 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 628 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 458 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 2678 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 2606 of file trunk_tests.c.

+ Here is the call graph for this function:

◆ test_two_active()

static void test_two_active ( trunk_t *  trunk,
trunk_connection_t **  a,
trunk_connection_t **  b 
)
static

Get the two active connections of a trunk which has two connections.

Definition at line 1643 of file trunk_tests.c.

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

Variable Documentation

◆ TEST_LIST

TEST_LIST

Definition at line 2860 of file trunk_tests.c.