The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
timer_tests.c File Reference

Tests for timer lists. More...

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

Go to the source code of this file.

Data Structures

struct  deferred_uctx_t
 
struct  disarm_ctx_t
 A callback which disarms the list which the callback runs in. More...
 
struct  free_ctx_t
 A callback which frees the list which the callback runs in, or the talloc parent of the list. More...
 

Macros

#define TIME_SOURCE(_name)
 Defines an artificial time source for a test.
 

Functions

static void basic_timer_list_tests (fr_timer_list_t *tl)
 
static void deferred_timer_list_tests (fr_timer_list_t *tl)
 
static void disarm_test (fr_timer_list_t *tl_outer, fr_timer_list_t *tl_inner)
 A callback which disarms the list stops the rest of the run.
 
static int free_ctx_probe_destructor (UNUSED void *probe)
 
static void free_in_callback_test (bool ordered, bool free_parent)
 A callback may free the list which the callback runs in, or the talloc parent of the list.
 
static void lst_basic_test (void)
 
static void lst_deferred_test (void)
 
static void lst_disarm_in_callback (void)
 
static void lst_free_list_in_callback (void)
 
static void lst_free_parent_in_callback (void)
 
static void lst_nested (void)
 
static void nested_test (fr_timer_list_t *tl_outer, fr_timer_list_t *tl_inner)
 
static void ordered_bad_inserts_test (void)
 
static void ordered_basic_test (void)
 
static void ordered_deferred_test (void)
 
static void ordered_disarm_in_callback (void)
 
static void ordered_free_list_in_callback (void)
 
static void ordered_free_parent_in_callback (void)
 
static void ordered_nested (void)
 
static void timer_cb (fr_timer_list_t *tl, fr_time_t now, void *uctx)
 Verifies time passed in is not 0, that tl is not NULL, and writes true to uctx (must be a bool)
 
static void timer_cb_deferred (fr_timer_list_t *tl, fr_time_t now, void *uctx)
 
static void timer_cb_disarm (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
 
static void timer_cb_free (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
 

Variables

static bool free_probe_destroyed
 
 TEST_LIST
 

Detailed Description

Tests for timer lists.

Definition in file timer_tests.c.


Data Structure Documentation

◆ deferred_uctx_t

struct deferred_uctx_t

Definition at line 173 of file timer_tests.c.

+ Collaboration diagram for deferred_uctx_t:
Data Fields
fr_timer_t * event
bool * fired

◆ disarm_ctx_t

struct disarm_ctx_t

A callback which disarms the list which the callback runs in.

Definition at line 392 of file timer_tests.c.

+ Collaboration diagram for disarm_ctx_t:
Data Fields
bool fired
fr_timer_list_t * tl list to disarm

◆ free_ctx_t

struct free_ctx_t

A callback which frees the list which the callback runs in, or the talloc parent of the list.

Freeing the talloc parent is the shape of a module which allocates a child list with a connection handle as the talloc parent, and then closes the connection, and so frees the handle, from a timer callback.

Definition at line 475 of file timer_tests.c.

+ Collaboration diagram for free_ctx_t:
Data Fields
fr_timer_t * deferred event which the callback inserts.
bool fired
fr_timer_t * pending event in the list, due after the callback.
int ret Result of talloc_free().
fr_timer_list_t * tl list which runs the callback.
void * to_free what the callback frees.

Macro Definition Documentation

◆ TIME_SOURCE

#define TIME_SOURCE (   _name)
Value:
static fr_time_t _name##_timer = fr_time_wrap(0); \
static fr_time_t _name##_time(void) \
{ \
return _name##_timer; \
} \
static void _name##_set(fr_time_t t) \
{ \
_name##_timer = t; \
}
#define fr_time_wrap(_time)
Definition time.h:145
"server local" time.
Definition time.h:69

Defines an artificial time source for a test.

Defines _name + _time() and _name + _set() functions.

Definition at line 32 of file timer_tests.c.

Function Documentation

◆ basic_timer_list_tests()

static void basic_timer_list_tests ( fr_timer_list_t *  tl)
static

Definition at line 58 of file timer_tests.c.

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

◆ deferred_timer_list_tests()

static void deferred_timer_list_tests ( fr_timer_list_t *  tl)
static

Definition at line 188 of file timer_tests.c.

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

◆ disarm_test()

static void disarm_test ( fr_timer_list_t *  tl_outer,
fr_timer_list_t *  tl_inner 
)
static

A callback which disarms the list stops the rest of the run.

Arming the list runs the rest.

Definition at line 407 of file timer_tests.c.

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

◆ free_ctx_probe_destructor()

static int free_ctx_probe_destructor ( UNUSED void *  probe)
static

Definition at line 486 of file timer_tests.c.

+ Here is the caller graph for this function:

◆ free_in_callback_test()

static void free_in_callback_test ( bool  ordered,
bool  free_parent 
)
static

A callback may free the list which the callback runs in, or the talloc parent of the list.

The code which runs the callbacks must not read the list after the callback returns. The test checks that the list is freed, that the list frees the events which are pending and deferred, and that the run returns. An address sanitiser reports a read of the list after the callback.

Definition at line 512 of file timer_tests.c.

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

◆ lst_basic_test()

static void lst_basic_test ( void  )
static

Definition at line 159 of file timer_tests.c.

+ Here is the call graph for this function:

◆ lst_deferred_test()

static void lst_deferred_test ( void  )
static

Definition at line 226 of file timer_tests.c.

+ Here is the call graph for this function:

◆ lst_disarm_in_callback()

static void lst_disarm_in_callback ( void  )
static

Definition at line 434 of file timer_tests.c.

+ Here is the call graph for this function:

◆ lst_free_list_in_callback()

static void lst_free_list_in_callback ( void  )
static

Definition at line 575 of file timer_tests.c.

+ Here is the call graph for this function:

◆ lst_free_parent_in_callback()

static void lst_free_parent_in_callback ( void  )
static

Definition at line 585 of file timer_tests.c.

+ Here is the call graph for this function:

◆ lst_nested()

static void lst_nested ( void  )
static

Definition at line 328 of file timer_tests.c.

+ Here is the call graph for this function:

◆ nested_test()

static void nested_test ( fr_timer_list_t *  tl_outer,
fr_timer_list_t *  tl_inner 
)
static

Definition at line 274 of file timer_tests.c.

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

◆ ordered_bad_inserts_test()

static void ordered_bad_inserts_test ( void  )
static

Definition at line 250 of file timer_tests.c.

+ Here is the call graph for this function:

◆ ordered_basic_test()

static void ordered_basic_test ( void  )
static

Definition at line 212 of file timer_tests.c.

+ Here is the call graph for this function:

◆ ordered_deferred_test()

static void ordered_deferred_test ( void  )
static

Definition at line 238 of file timer_tests.c.

+ Here is the call graph for this function:

◆ ordered_disarm_in_callback()

static void ordered_disarm_in_callback ( void  )
static

Definition at line 452 of file timer_tests.c.

+ Here is the call graph for this function:

◆ ordered_free_list_in_callback()

static void ordered_free_list_in_callback ( void  )
static

Definition at line 580 of file timer_tests.c.

+ Here is the call graph for this function:

◆ ordered_free_parent_in_callback()

static void ordered_free_parent_in_callback ( void  )
static

Definition at line 590 of file timer_tests.c.

+ Here is the call graph for this function:

◆ ordered_nested()

static void ordered_nested ( void  )
static

Definition at line 359 of file timer_tests.c.

+ Here is the call graph for this function:

◆ timer_cb()

static void timer_cb ( fr_timer_list_t *  tl,
fr_time_t  now,
void *  uctx 
)
static

Verifies time passed in is not 0, that tl is not NULL, and writes true to uctx (must be a bool)

Definition at line 48 of file timer_tests.c.

+ Here is the caller graph for this function:

◆ timer_cb_deferred()

static void timer_cb_deferred ( fr_timer_list_t *  tl,
fr_time_t  now,
void *  uctx 
)
static

Definition at line 178 of file timer_tests.c.

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

◆ timer_cb_disarm()

static void timer_cb_disarm ( UNUSED fr_timer_list_t *  tl,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Definition at line 397 of file timer_tests.c.

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

◆ timer_cb_free()

static void timer_cb_free ( UNUSED fr_timer_list_t *  tl,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Definition at line 492 of file timer_tests.c.

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

Variable Documentation

◆ free_probe_destroyed

bool free_probe_destroyed
static

Definition at line 484 of file timer_tests.c.

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "lst_basic", lst_basic_test },
{ "ordered_basic", ordered_basic_test },
{ "lst_deferred", lst_deferred_test },
{ "ordered_deferred", ordered_deferred_test },
{ "ordered_bad_inserts", ordered_bad_inserts_test },
{ "lst_nested", lst_nested },
{ "ordered_nested", ordered_nested },
{ "lst_disarm_in_callback", lst_disarm_in_callback },
{ "ordered_disarm_in_callback", ordered_disarm_in_callback },
{ "lst_free_list_in_callback", lst_free_list_in_callback },
{ "ordered_free_list_in_callback", ordered_free_list_in_callback },
{ "lst_free_parent_in_callback", lst_free_parent_in_callback },
{ "ordered_free_parent_in_callback", ordered_free_parent_in_callback },
}
#define TEST_TERMINATOR
Definition acutest.h:77
static void ordered_nested(void)
static void lst_disarm_in_callback(void)
static void lst_nested(void)
static void lst_free_parent_in_callback(void)
static void ordered_basic_test(void)
static void ordered_disarm_in_callback(void)
static void lst_basic_test(void)
static void ordered_free_parent_in_callback(void)
static void ordered_deferred_test(void)
static void lst_deferred_test(void)
static void ordered_free_list_in_callback(void)
static void ordered_bad_inserts_test(void)
static void lst_free_list_in_callback(void)

Definition at line 595 of file timer_tests.c.