The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Macros | Enumerations | Functions | Variables
machine_tests.c File Reference

Tests for the observable state machine. More...

#include "acutest_common_init.h"
#include "acutest_helpers.h"
#include <freeradius-devel/util/machine.h>
+ Include dependency graph for machine_tests.c:

Go to the source code of this file.

Macros

#define CONN_ROW(_from, ...)   FR_MACHINE_ROW(conn_state_t, _from, __VA_ARGS__)
 
#define LOG_MATCHES(...)    log_matches((char const * const []){ __VA_ARGS__ }, VA_NARG(__VA_ARGS__))
 
#define LOG_MAX   32
 

Enumerations

enum  conn_state_t : unsigned int {
  CONN_INIT = 0 ,
  CONN_CONNECTING ,
  CONN_CONNECTED ,
  CONN_FAILED ,
  CONN_CLOSED ,
  CONN_MAX
}
 

Functions

static int conn_enter_connected (UNUSED fr_machine_t *m, UNUSED void *uctx)
 
static int conn_enter_connecting (UNUSED fr_machine_t *m, UNUSED void *uctx)
 
static void conn_exit_connecting (UNUSED fr_machine_t *m, UNUSED void *uctx)
 
 FR_MACHINE_VALID (conn, CONN_MAX, CONN_ROW(CONN_INIT, CONN_CONNECTING, CONN_CLOSED), CONN_ROW(CONN_CONNECTING, CONN_CONNECTED, CONN_FAILED, CONN_CLOSED), CONN_ROW(CONN_CONNECTED, CONN_FAILED, CONN_CLOSED),)
 
static void log_add (char const *event)
 
static bool log_matches (char const *const expected[], size_t expected_num)
 
static void log_reset (void)
 
static void test_enter_failed (void)
 
static void test_init (void)
 
static void test_pause_resume (void)
 
static void test_queue_revalidated (void)
 
static void test_table (void)
 
static void test_transition_from_watcher (void)
 
static void test_transition_invalid (void)
 
static void test_transition_order (void)
 
static void test_watch_ctx_free (void)
 
static void test_watch_edges (void)
 
static void test_watch_free_during_walk (void)
 
static void test_watch_oneshot_and_disable (void)
 
static void watch_free_entry (UNUSED conn_machine_t *m, UNUSED conn_state_t prev, UNUSED conn_state_t state, void *uctx)
 
static void watch_log (UNUSED conn_machine_t *m, UNUSED conn_state_t prev, UNUSED conn_state_t state, void *uctx)
 
static void watch_transition (conn_machine_t *m, UNUSED conn_state_t prev, UNUSED conn_state_t state, void *uctx)
 

Variables

static fr_machine_def_t const conn_def
 
static fr_table_num_indexed_t const conn_state_names []
 
static fr_machine_state_t const conn_states [CONN_MAX]
 
static int enter_ret
 
static char const * event_log [LOG_MAX]
 
static size_t event_num
 
 TEST_LIST
 

Detailed Description

Tests for the observable state machine.

Definition in file machine_tests.c.

Macro Definition Documentation

◆ CONN_ROW

#define CONN_ROW (   _from,
  ... 
)    FR_MACHINE_ROW(conn_state_t, _from, __VA_ARGS__)

Definition at line 48 of file machine_tests.c.

◆ LOG_MATCHES

#define LOG_MATCHES (   ...)     log_matches((char const * const []){ __VA_ARGS__ }, VA_NARG(__VA_ARGS__))

Definition at line 149 of file machine_tests.c.

◆ LOG_MAX

#define LOG_MAX   32

Definition at line 65 of file machine_tests.c.

Enumeration Type Documentation

◆ conn_state_t

enum conn_state_t : unsigned int
Enumerator
CONN_INIT 
CONN_CONNECTING 
CONN_CONNECTED 
CONN_FAILED 
CONN_CLOSED 
CONN_MAX 

Definition at line 31 of file machine_tests.c.

Function Documentation

◆ conn_enter_connected()

static int conn_enter_connected ( UNUSED fr_machine_t *  m,
UNUSED void *  uctx 
)
static

Definition at line 82 of file machine_tests.c.

+ Here is the call graph for this function:

◆ conn_enter_connecting()

static int conn_enter_connecting ( UNUSED fr_machine_t *  m,
UNUSED void *  uctx 
)
static

Definition at line 93 of file machine_tests.c.

+ Here is the call graph for this function:

◆ conn_exit_connecting()

static void conn_exit_connecting ( UNUSED fr_machine_t *  m,
UNUSED void *  uctx 
)
static

Definition at line 88 of file machine_tests.c.

+ Here is the call graph for this function:

◆ FR_MACHINE_VALID()

◆ log_add()

static void log_add ( char const *  event)
static

Definition at line 76 of file machine_tests.c.

+ Here is the caller graph for this function:

◆ log_matches()

static bool log_matches ( char const *const  expected[],
size_t  expected_num 
)
static

Definition at line 131 of file machine_tests.c.

◆ log_reset()

static void log_reset ( void  )
static

Definition at line 70 of file machine_tests.c.

+ Here is the caller graph for this function:

◆ test_enter_failed()

static void test_enter_failed ( void  )
static

Definition at line 239 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_init()

static void test_init ( void  )
static

Definition at line 152 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_pause_resume()

static void test_pause_resume ( void  )
static

Definition at line 415 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_queue_revalidated()

static void test_queue_revalidated ( void  )
static

Definition at line 445 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_table()

static void test_table ( void  )
static

Definition at line 172 of file machine_tests.c.

◆ test_transition_from_watcher()

static void test_transition_from_watcher ( void  )
static

Definition at line 381 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_transition_invalid()

static void test_transition_invalid ( void  )
static

Definition at line 220 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_transition_order()

static void test_transition_order ( void  )
static

Definition at line 195 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_watch_ctx_free()

static void test_watch_ctx_free ( void  )
static

Definition at line 465 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_watch_edges()

static void test_watch_edges ( void  )
static

Definition at line 259 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_watch_free_during_walk()

static void test_watch_free_during_walk ( void  )
static

Definition at line 349 of file machine_tests.c.

+ Here is the call graph for this function:

◆ test_watch_oneshot_and_disable()

static void test_watch_oneshot_and_disable ( void  )
static

Definition at line 286 of file machine_tests.c.

+ Here is the call graph for this function:

◆ watch_free_entry()

static void watch_free_entry ( UNUSED conn_machine_t *  m,
UNUSED conn_state_t  prev,
UNUSED conn_state_t  state,
void *  uctx 
)
static

Definition at line 340 of file machine_tests.c.

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

◆ watch_log()

static void watch_log ( UNUSED conn_machine_t *  m,
UNUSED conn_state_t  prev,
UNUSED conn_state_t  state,
void *  uctx 
)
static

Definition at line 115 of file machine_tests.c.

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

◆ watch_transition()

static void watch_transition ( conn_machine_t *  m,
UNUSED conn_state_t  prev,
UNUSED conn_state_t  state,
void *  uctx 
)
static

Definition at line 123 of file machine_tests.c.

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

Variable Documentation

◆ conn_def

fr_machine_def_t const conn_def
static
Initial value:
= {
.name = "conn",
.state_names = conn_state_names,
.state_names_len = NUM_ELEMENTS(conn_state_names),
.valid = &conn_valid,
.states = conn_states
}
#define NUM_ELEMENTS(_t)
Definition build.h:437
static fr_machine_state_t const conn_states[CONN_MAX]
static fr_table_num_indexed_t const conn_state_names[]

Definition at line 104 of file machine_tests.c.

◆ conn_state_names

fr_table_num_indexed_t const conn_state_names[]
static
Initial value:
= {
}
@ CONN_INIT
@ CONN_CONNECTING
@ CONN_CLOSED
@ CONN_FAILED
@ CONN_CONNECTED
#define FR_TABLE_INDEXED_ENTRY(_v)
Build a single fr_table_num_indexed_t entry from an enum identifier.
Definition table.h:110

Definition at line 40 of file machine_tests.c.

◆ conn_states

fr_machine_state_t const conn_states[CONN_MAX]
static
Initial value:
= {
}
static int conn_enter_connected(UNUSED fr_machine_t *m, UNUSED void *uctx)
static void conn_exit_connecting(UNUSED fr_machine_t *m, UNUSED void *uctx)
static int conn_enter_connecting(UNUSED fr_machine_t *m, UNUSED void *uctx)

Definition at line 99 of file machine_tests.c.

◆ enter_ret

int enter_ret
static

Definition at line 68 of file machine_tests.c.

◆ event_log

char const* event_log[LOG_MAX]
static

Definition at line 66 of file machine_tests.c.

◆ event_num

size_t event_num
static

Definition at line 67 of file machine_tests.c.

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "init", test_init },
{ "table", test_table },
{ "transition_order", test_transition_order },
{ "transition_invalid", test_transition_invalid },
{ "enter_failed", test_enter_failed },
{ "watch_edges", test_watch_edges },
{ "watch_oneshot_and_disable", test_watch_oneshot_and_disable },
{ "watch_free_during_walk", test_watch_free_during_walk },
{ "transition_from_watcher", test_transition_from_watcher },
{ "pause_resume", test_pause_resume },
{ "queue_revalidated", test_queue_revalidated },
{ "watch_ctx_free", test_watch_ctx_free },
}
#define TEST_TERMINATOR
Definition acutest.h:77
static void test_table(void)
static void test_enter_failed(void)
static void test_transition_from_watcher(void)
static void test_pause_resume(void)
static void test_watch_oneshot_and_disable(void)
static void test_watch_free_during_walk(void)
static void test_transition_invalid(void)
static void test_init(void)
static void test_watch_ctx_free(void)
static void test_queue_revalidated(void)
static void test_watch_edges(void)
static void test_transition_order(void)

Definition at line 488 of file machine_tests.c.