The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions | Variables
slab_tests.c File Reference

Tests for slab allocator. More...

#include <freeradius-devel/util/acutest.h>
#include <freeradius-devel/util/acutest_helpers.h>
#include "slab.h"
+ Include dependency graph for slab_tests.c:

Go to the source code of this file.

Data Structures

struct  test_conf_t
 
struct  test_element_t
 
struct  test_uctx_t
 

Functions

static void test_alloc (void)
 Test basic allocation and reservation of elements. More...
 
static void test_alloc_fail (void)
 Test allocation beyond max fails correctly. More...
 
static void test_child_alloc (void)
 
static void test_clearup_1 (void)
 Test of clearing unused slabs. More...
 
static void test_clearup_2 (void)
 Test that slab clearing does not go beyond the minimum. More...
 
static void test_clearup_3 (void)
 Test that repeated clearing frees more slabs. More...
 
static int test_element_alloc (test_element_t *elem, void *uctx)
 
static int test_element_free (test_element_t *elem, void *uctx)
 
static int test_element_reserve (test_element_t *elem, void *uctx)
 
static void test_free (void)
 Test that talloc freeing an element results in destructor being called. More...
 
static void test_init (void)
 Test that a callback correctly initialises slab elements on first use. More...
 
static void test_init_reserve (void)
 Test that reserve callback runs after init callback. More...
 
static void test_realloc (void)
 Test that reserving after clearup results in new slab allocation. More...
 
static void test_reserve (void)
 Test that a reserve callback correctly initialises slab elements. More...
 
static void test_reserve_mru (void)
 Test that setting reserve_mru to true works. More...
 
static void test_reuse_noreset (void)
 Test that freeing an element makes it available for reuse with the element not reset between uses. More...
 
static void test_reuse_reset (void)
 Test that freeing an element makes it available for reuse with the element reset between uses. More...
 
static fr_time_t test_time (void)
 

Variables

static fr_slab_config_t def_slab_config
 
 TEST_LIST
 
static fr_time_t test_time_base = fr_time_wrap(1)
 

Detailed Description

Tests for slab allocator.

Definition in file slab_tests.c.


Data Structure Documentation

◆ test_conf_t

struct test_conf_t

Definition at line 21 of file slab_tests.c.

Data Fields
int initial

◆ test_element_t

struct test_element_t

Definition at line 12 of file slab_tests.c.

Data Fields
char * name
int num

◆ test_uctx_t

struct test_uctx_t

Definition at line 17 of file slab_tests.c.

Data Fields
int count

Function Documentation

◆ test_alloc()

static void test_alloc ( void  )
static

Test basic allocation and reservation of elements.

Definition at line 55 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_alloc_fail()

static void test_alloc_fail ( void  )
static

Test allocation beyond max fails correctly.

Definition at line 126 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_child_alloc()

static void test_child_alloc ( void  )
static

Definition at line 753 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_clearup_1()

static void test_clearup_1 ( void  )
static

Test of clearing unused slabs.

Definition at line 478 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_clearup_2()

static void test_clearup_2 ( void  )
static

Test that slab clearing does not go beyond the minimum.

Definition at line 532 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_clearup_3()

static void test_clearup_3 ( void  )
static

Test that repeated clearing frees more slabs.

Definition at line 597 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_element_alloc()

static int test_element_alloc ( test_element_t elem,
void *  uctx 
)
static

Definition at line 347 of file slab_tests.c.

+ Here is the caller graph for this function:

◆ test_element_free()

static int test_element_free ( test_element_t elem,
void *  uctx 
)
static

Definition at line 35 of file slab_tests.c.

+ Here is the caller graph for this function:

◆ test_element_reserve()

static int test_element_reserve ( test_element_t elem,
void *  uctx 
)
static

Definition at line 430 of file slab_tests.c.

+ Here is the caller graph for this function:

◆ test_free()

static void test_free ( void  )
static

Test that talloc freeing an element results in destructor being called.

Definition at line 323 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_init()

static void test_init ( void  )
static

Test that a callback correctly initialises slab elements on first use.

Definition at line 357 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_init_reserve()

static void test_init_reserve ( void  )
static

Test that reserve callback runs after init callback.

Definition at line 440 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_realloc()

static void test_realloc ( void  )
static

Test that reserving after clearup results in new slab allocation.

Definition at line 691 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_reserve()

static void test_reserve ( void  )
static

Test that a reserve callback correctly initialises slab elements.

Definition at line 395 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_reserve_mru()

static void test_reserve_mru ( void  )
static

Test that setting reserve_mru to true works.

After releasing an element, a subsequent reserve should return the same element

Definition at line 277 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_reuse_noreset()

static void test_reuse_noreset ( void  )
static

Test that freeing an element makes it available for reuse with the element not reset between uses.

Definition at line 224 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_reuse_reset()

static void test_reuse_reset ( void  )
static

Test that freeing an element makes it available for reuse with the element reset between uses.

Definition at line 164 of file slab_tests.c.

+ Here is the call graph for this function:

◆ test_time()

static fr_time_t test_time ( void  )
static

Definition at line 43 of file slab_tests.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ def_slab_config

fr_slab_config_t def_slab_config
static
Initial value:
.elements_per_slab = 2,
.min_elements = 1,
.max_elements = 4,
.at_max_fail = false,
.num_children = 0,
.child_pool_size = 0,
.interval.value = 1 * NSEC
}
Tuneable parameters for slabs.
Definition: slab.h:42
#define NSEC
Definition: time.h:377

Definition at line 25 of file slab_tests.c.

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "test_alloc", test_alloc },
{ "test_alloc_fail", test_alloc_fail },
{ "test_reuse_reset", test_reuse_reset },
{ "test_reuse_noreset", test_reuse_noreset },
{ "test_reserve_mru", test_reserve_mru },
{ "test_free", test_free },
{ "test_init", test_init },
{ "test_reserve", test_reserve },
{ "test_init_reserve", test_init_reserve },
{ "test_clearup_1", test_clearup_1 },
{ "test_clearup_2", test_clearup_2 },
{ "test_clearup_3", test_clearup_3 },
{ "test_realloc", test_realloc },
{ "test_child_alloc", test_child_alloc },
{ NULL }
}
static void test_clearup_3(void)
Test that repeated clearing frees more slabs.
Definition: slab_tests.c:597
static void test_reserve(void)
Test that a reserve callback correctly initialises slab elements.
Definition: slab_tests.c:395
static void test_init_reserve(void)
Test that reserve callback runs after init callback.
Definition: slab_tests.c:440
static void test_reserve_mru(void)
Test that setting reserve_mru to true works.
Definition: slab_tests.c:277
static void test_clearup_2(void)
Test that slab clearing does not go beyond the minimum.
Definition: slab_tests.c:532
static void test_reuse_noreset(void)
Test that freeing an element makes it available for reuse with the element not reset between uses.
Definition: slab_tests.c:224
static void test_child_alloc(void)
Definition: slab_tests.c:753
static void test_clearup_1(void)
Test of clearing unused slabs.
Definition: slab_tests.c:478
static void test_free(void)
Test that talloc freeing an element results in destructor being called.
Definition: slab_tests.c:323
static void test_alloc(void)
Test basic allocation and reservation of elements.
Definition: slab_tests.c:55
static void test_reuse_reset(void)
Test that freeing an element makes it available for reuse with the element reset between uses.
Definition: slab_tests.c:164
static void test_init(void)
Test that a callback correctly initialises slab elements on first use.
Definition: slab_tests.c:357
static void test_alloc_fail(void)
Test allocation beyond max fails correctly.
Definition: slab_tests.c:126
static void test_realloc(void)
Test that reserving after clearup results in new slab allocation.
Definition: slab_tests.c:691

Definition at line 791 of file slab_tests.c.

◆ test_time_base

fr_time_t test_time_base = fr_time_wrap(1)
static

Definition at line 42 of file slab_tests.c.