![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
Tests for radius_pairmove()
More...
#include <freeradius-devel/util/test/acutest_common_init.h>#include <freeradius-devel/util/test/acutest_helpers.h>#include <freeradius-devel/util/dict_test.h>#include <freeradius-devel/server/pairmove.h>#include <freeradius-devel/server/request.h>#include <freeradius-devel/util/conf.h>#include <freeradius-devel/util/pair.h>
Include dependency graph for pairmove_tests.c:Go to the source code of this file.
Data Structures | |
| struct | pairmove_case_t |
Macros | |
| #define | TEST_GLOBAL_INIT test_init() |
Enumerations | |
| enum | list_target_t { LIST_REQUEST = 0 , LIST_REPLY , LIST_CONTROL , LIST_NUM } |
Functions | |
| static void | list_alloc (TALLOC_CTX *ctx, fr_pair_list_t *list, char const *spec) |
Build a list of pairs from the text in spec | |
| static char const * | list_str (fr_pair_list_t const *list) |
Render a list in the text form that list_alloc() accepts. | |
| static fr_pair_list_t * | list_target (TALLOC_CTX **ctx, request_t *request, list_target_t target) |
| Get the pair list and the talloc context for a target. | |
| static void | pairmove_run (pairmove_case_t const *tc, list_target_t target) |
| static void | pairmove_run_cases (pairmove_case_t const *cases, size_t num) |
| static request_t * | request_make (void) |
| Make a request with empty pair lists. | |
| static void | test_empty_to (void) |
| static void | test_init (void) |
| Global initialisation. | |
| static void | test_long_lists (void) |
| Merge lists of up to 100 pairs. | |
| static void | test_mixed (void) |
| static void | test_op_add (void) |
| static void | test_op_cmp_eq (void) |
| static void | test_op_cmp_false (void) |
| static void | test_op_eq (void) |
| static void | test_op_eq_after_edit (void) |
| static void | test_op_le_ge (void) |
| static void | test_op_le_ge_prefix (void) |
| static void | test_op_prepend (void) |
| static void | test_op_set (void) |
| static void | test_op_sub (void) |
| static void | test_original_list_only (void) |
| static void | test_stale_next (void) |
Variables | ||
| struct { | ||
| fr_dict_attr_t const * | da | |
| char const * | name | |
| } | attr_names [] | |
| static TALLOC_CTX * | autofree | |
| static char const * | list_target_names [LIST_NUM] = { "request", "reply", "control" } | |
| struct { | ||
| fr_token_t | op | |
| char const * | str | |
| } | op_names [] | |
| static fr_dict_test_attr_t const | test_attrs [] | |
| static fr_dict_t * | test_dict | |
| TEST_LIST | ||
Tests for radius_pairmove()
radius_pairmove() merges the pairs of the from list into the to list, and applies the operator of each pair in the from list. These tests record the behaviour of radius_pairmove(). A developer who rewrites the function runs the tests to check that the behaviour is unchanged.
Each test writes a list as short text, for example s0=a i0+=5. Each entry has a name, an operator, and a value:
s0, s1, s2 `Test-String-0`, `Test-String-1`, `Test-String-2` i0, i1 `Test-Uint32-0`, `Test-Uint32-1` p4, p6 `Test-IPv4-Prefix`, `Test-IPv6-Prefix` un, up `Test-User-Name`, `Test-User-Password`
Each test renders the merged to list in the same text form, and compares the result with the expected text. Each case runs against the request list, the reply list, and the control list of a request. After the merge, the test frees the to list and checks that the number of talloc blocks under the request equals the number before the merge. The check catches a leak of pairs, or of the temporary arrays that radius_pairmove() allocates.
Definition in file pairmove_tests.c.
| struct pairmove_case_t |
Definition at line 278 of file pairmove_tests.c.
Definition at line 44 of file pairmove_tests.c.
| enum list_target_t |
| Enumerator | |
|---|---|
| LIST_REQUEST | |
| LIST_REPLY | |
| LIST_CONTROL | |
| LIST_NUM | |
Definition at line 229 of file pairmove_tests.c.
|
static |
Build a list of pairs from the text in spec
list_alloc() allocates the pairs in ctx. Because the '!*' operator does not take a value, list_alloc() gives the pair an empty string, or zero for an integer.
Definition at line 132 of file pairmove_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Render a list in the text form that list_alloc() accepts.
Because list_str() omits the '=' operator, a result pair that still has an operator from the from list shows the operator in the output.
Definition at line 197 of file pairmove_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get the pair list and the talloc context for a target.
list_target() sets *ctx to the talloc context in which the server allocates the pairs of the list.
Definition at line 261 of file pairmove_tests.c.
Here is the caller graph for this function:
|
static |
Definition at line 285 of file pairmove_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 323 of file pairmove_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Make a request with empty pair lists.
Definition at line 240 of file pairmove_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Global initialisation.
Definition at line 87 of file pairmove_tests.c.
Here is the call graph for this function:
|
static |
Merge lists of up to 100 pairs.
This test checks the sizes of the temporary arrays that radius_pairmove() allocates. The lengths of the to list and the from list are 1 and 100, 100 and 1, 100 and 100, 0 and 100, and 100 and 0.
Definition at line 688 of file pairmove_tests.c.
Here is the call graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| struct { ... } attr_names[] |
|
static |
Definition at line 55 of file pairmove_tests.c.
|
static |
Definition at line 236 of file pairmove_tests.c.
| struct { ... } op_names[] |
|
static |
Definition at line 72 of file pairmove_tests.c.
|
static |
Definition at line 56 of file pairmove_tests.c.
| TEST_LIST |
Definition at line 818 of file pairmove_tests.c.
1.9.8