![]() |
The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
|
Tests for slab allocator. More...
#include "acutest_common_init.h"#include "acutest_helpers.h"#include <freeradius-devel/util/timer.h>#include <freeradius-devel/util/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_count_t |
| How many times each callback has run. More... | |
| struct | test_element_t |
| struct | test_uctx_t |
Functions | |
| static void | test_alloc (void) |
| Test basic allocation and reservation of elements. | |
| static void | test_alloc_fail (void) |
| Test allocation beyond max fails correctly. | |
| static void | test_alloc_reserve_count (void) |
| Count the callbacks across a reserve, release, reserve cycle. | |
| static void | test_bulk_teardown (void) |
| Test that talloc free of the slab list with in-use elements does not assert. | |
| static void | test_child_alloc (void) |
| static void | test_clearup_1 (void) |
| Test of clearing unused slabs. | |
| static void | test_clearup_2 (void) |
| Test that slab clearing does not go beyond the minimum. | |
| static void | test_clearup_3 (void) |
| Test that repeated clearing frees more slabs. | |
| static int | test_element_alloc (test_element_t *elem, void *uctx) |
| static int | test_element_count_alloc (test_element_t *elem, void *uctx) |
| static int | test_element_count_reserve (UNUSED 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 freeing an element results in the destructor being called, and that all accounting is correctly updated. | |
| static void | test_free_and_reserve (void) |
| Test that reserving after talloc_free of an element still works. | |
| static void | test_free_mixed (void) |
| Test mixed release and talloc_free of elements from the same slab. | |
| static void | test_free_multiple (void) |
| Test that talloc freeing multiple in-use elements correctly updates accounting. | |
| static void | test_init (void) |
| Test that a callback correctly initialises slab elements on first use. | |
| static void | test_init_reserve (void) |
| Test that reserve callback runs after init callback. | |
| static void | test_realloc (void) |
| Test that reserving after clearup results in new slab allocation. | |
| static void | test_reserve (void) |
| Test that a reserve callback correctly initialises slab elements. | |
| static void | test_reserve_mru (void) |
| Test that setting reserve_mru to true works. | |
| static void | test_reuse_noreset (void) |
| Test that freeing an element makes it available for reuse with the element not reset between uses. | |
| static void | test_reuse_reset (void) |
| Test that freeing an element makes it available for reuse with the element reset between uses. | |
| 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) |
Tests for slab allocator.
Definition in file slab_tests.c.
| struct test_conf_t |
Definition at line 21 of file slab_tests.c.
| Data Fields | ||
|---|---|---|
| int | initial | |
| struct test_count_t |
How many times each callback has run.
Definition at line 434 of file slab_tests.c.
| Data Fields | ||
|---|---|---|
| int | alloc | Calls to the alloc callback. |
| int | reserve | Calls to the reserve callback. |
| struct test_element_t |
Definition at line 12 of file slab_tests.c.
| Data Fields | ||
|---|---|---|
| char * | name | |
| int | num | |
| struct test_uctx_t |
Definition at line 17 of file slab_tests.c.
| Data Fields | ||
|---|---|---|
| int | count | |
|
static |
Test basic allocation and reservation of elements.
Definition at line 54 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test allocation beyond max fails correctly.
Definition at line 124 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Count the callbacks across a reserve, release, reserve cycle.
Releasing an element hands it back to the slab, and reserving again hands back the same element with whatever the alloc callback set up still in place. Callers rely on that. rlm_ftp, rlm_imap, rlm_rest and rlm_smtp create a CURL handle in their alloc callback, and rlm_krb5 creates a Kerberos context. None of those should be built again for every request.
So the alloc callback runs once per element, and the reserve callback runs once per reserve. Nothing else in this file measures the difference: a change which turned the slab into a plain memory recycler, freeing each element on release and building a new one on the next reserve, would still pass every other test here. The counts below are what notices.
Definition at line 512 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that talloc free of the slab list with in-use elements does not assert.
This exercises the being_freed flag path: the slab destructor sets being_freed = true before children are freed, so element destructors will see the flag and skip the direct-free assertion.
Definition at line 892 of file slab_tests.c.
Here is the call graph for this function:
|
static |
|
static |
Test of clearing unused slabs.
Definition at line 572 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that slab clearing does not go beyond the minimum.
Definition at line 625 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that repeated clearing frees more slabs.
Definition at line 689 of file slab_tests.c.
Here is the call graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Test that freeing an element results in the destructor being called, and that all accounting is correctly updated.
Definition at line 316 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that reserving after talloc_free of an element still works.
Definition at line 980 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test mixed release and talloc_free of elements from the same slab.
Definition at line 931 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that talloc freeing multiple in-use elements correctly updates accounting.
Definition at line 845 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that a callback correctly initialises slab elements on first use.
Definition at line 354 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that reserve callback runs after init callback.
Definition at line 464 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that reserving after clearup results in new slab allocation.
Definition at line 782 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that a reserve callback correctly initialises slab elements.
Definition at line 391 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that setting reserve_mru to true works.
After releasing an element, a subsequent reserve should return the same element
Definition at line 272 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that freeing an element makes it available for reuse with the element not reset between uses.
Definition at line 220 of file slab_tests.c.
Here is the call graph for this function:
|
static |
Test that freeing an element makes it available for reuse with the element reset between uses.
Definition at line 161 of file slab_tests.c.
Here is the call graph for this function:
|
static |
|
static |
Definition at line 25 of file slab_tests.c.
| TEST_LIST |
Definition at line 1056 of file slab_tests.c.
|
static |
Definition at line 42 of file slab_tests.c.
1.9.8