The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
tmpl_dcursor_tests.c File Reference
#include <freeradius-devel/util/acutest.h>
#include <freeradius-devel/util/acutest_helpers.h>
#include <freeradius-devel/util/dict_test.h>
#include <freeradius-devel/server/tmpl_dcursor.h>
#include <freeradius-devel/server/pair.h>
+ Include dependency graph for tmpl_dcursor_tests.c:

Go to the source code of this file.

Data Structures

struct  tmpl_dcursor_vars_t
 

Macros

#define build_test_end
 
#define common_vars
 
#define pair_defs(_x)
 
#define pair_defs_thin(_x)
 
#define pair_populate(_x)
 
#define pair_populate_thin(_x)
 
#define test_cursor()   &vars.cursor
 
#define test_end
 
#define TEST_FINI   test_free()
 
#define TEST_INIT   test_init()
 
#define test_vp()   vars.vp
 
#define test_vp_p()   &vars.vp
 
#define test_vp_set(_vp)   vars.vp = _vp
 
#define tmpl_setup_and_cursor_build_init(_vp_out, _ref)    if (_tmpl_setup_and_cursor_build_init(_vp_out, &vars, request, _ref)) return
 
#define tmpl_setup_and_cursor_init(_vp_out, _ref)    if (_tmpl_setup_and_cursor_init(_vp_out, &vars, request, _ref)) return
 

Functions

static int _tmpl_setup_and_cursor_build_init (fr_pair_t **vp_out, tmpl_dcursor_vars_t *vars, request_t *request, char const *ref)
 Initialise a tmpl using the _attr_str string, and return the first pair. More...
 
static int _tmpl_setup_and_cursor_init (fr_pair_t **vp_out, tmpl_dcursor_vars_t *vars, request_t *request, char const *ref)
 Initialise a tmpl using the _attr_str string, and return the first pair. More...
 
static void debug_attr_list (fr_pair_list_t *list, int indent)
 
static request_trequest_fake_alloc (void)
 
static void test_free (void)
 
static void test_init (void)
 Global initialisation. More...
 
static void test_level_1_build (void)
 
static void test_level_1_one (void)
 
static void test_level_1_one_all (void)
 
static void test_level_1_one_last (void)
 
static void test_level_1_one_missing (void)
 
static void test_level_1_one_second (void)
 
static void test_level_1_two (void)
 
static void test_level_1_two_all (void)
 
static void test_level_1_two_count (void)
 
static void test_level_1_two_last (void)
 
static void test_level_1_two_second (void)
 
static void test_level_1_two_third (void)
 
static void test_level_2_build_intermediate (void)
 
static void test_level_2_build_leaf (void)
 
static void test_level_2_build_multi (void)
 
static void test_level_2_one (void)
 
static void test_level_2_one_all (void)
 
static void test_level_2_one_missing (void)
 
static void test_level_2_one_second (void)
 
static void test_level_2_two (void)
 
static void test_level_2_two_all (void)
 
static void test_level_2_two_last (void)
 
static void test_level_2_two_missing (void)
 
static void test_level_2_two_second (void)
 
static void test_level_3_build_entire (void)
 
static void test_level_3_build_invalid1 (void)
 
static void test_level_3_build_invalid2 (void)
 
static void test_level_3_build_leaf (void)
 
static void test_level_3_build_partial (void)
 
static void test_level_3_one (void)
 
static void test_level_3_one_all (void)
 
static void test_level_3_one_second (void)
 
static void test_level_3_two (void)
 
static void test_level_3_two_all (void)
 
static void test_level_3_two_last (void)
 

Variables

static TALLOC_CTX * autofree
 
static fr_dict_ttest_dict
 
 TEST_LIST
 

Data Structure Documentation

◆ tmpl_dcursor_vars_t

struct tmpl_dcursor_vars_t

Definition at line 110 of file tmpl_dcursor_tests.c.

+ Collaboration diagram for tmpl_dcursor_vars_t:
Data Fields
tmpl_dcursor_ctx_t cc
fr_dcursor_t cursor
int err
fr_pair_t * vp
tmpl_t * vpt

Macro Definition Documentation

◆ build_test_end

#define build_test_end
Value:
debug_attr_list(&request->request_pairs, 0); \
test_vp_set(fr_dcursor_next(test_cursor())); \
TEST_CHECK_PAIR(test_vp(), NULL); \
tmpl_dcursor_clear(&vars.cc)
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
Definition: dcursor.h:287
static void debug_attr_list(fr_pair_list_t *list, int indent)
#define test_cursor()
#define test_vp()

Definition at line 204 of file tmpl_dcursor_tests.c.

◆ common_vars

#define common_vars
Value:
request_t *request = request_fake_alloc()
static request_t * request_fake_alloc(void)

Definition at line 126 of file tmpl_dcursor_tests.c.

◆ pair_defs

#define pair_defs (   _x)
Value:
fr_pair_t *int32_vp ## _x; \
fr_pair_t *string_vp ## _x; \
fr_pair_t *group_vp ## _x; \
fr_pair_t *child_vp ## _x; \
fr_pair_t *top_vp ## _x; \
fr_pair_t *mid_vp ## _x; \
fr_pair_t *leaf_string_vp ## _x; \
fr_pair_t *leaf_int32_vp ## _x
Stores an attribute, a value and various bits of other data.
Definition: pair.h:68

Definition at line 62 of file tmpl_dcursor_tests.c.

◆ pair_defs_thin

#define pair_defs_thin (   _x)
Value:
fr_pair_t *int32_vp ## _x; \
fr_pair_t *group_vp ## _x; \
fr_pair_t *top_vp ## _x; \
fr_pair_t *mid_vp ## _x; \
fr_pair_t *leaf_int32_vp ## _x

Definition at line 72 of file tmpl_dcursor_tests.c.

◆ pair_populate

#define pair_populate (   _x)
Value:
do { \
pair_append_request(&int32_vp ## _x, fr_dict_attr_test_int32); \
pair_append_request(&string_vp ## _x, fr_dict_attr_test_string); \
pair_append_request(&group_vp ## _x, fr_dict_attr_test_group); \
fr_pair_append_by_da(group_vp ## _x, &child_vp ## _x, &group_vp ## _x->children, fr_dict_attr_test_int16); \
pair_append_request(&top_vp ## _x, fr_dict_attr_test_nested_top_tlv); \
fr_pair_append_by_da(top_vp ## _x, &mid_vp ## _x, &top_vp ## _x->children, fr_dict_attr_test_nested_child_tlv); \
fr_pair_append_by_da(mid_vp ## _x, &leaf_string_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_string); \
fr_pair_append_by_da(mid_vp ## _x, &leaf_int32_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_int32); \
} while (0)
fr_dict_attr_t const * fr_dict_attr_test_nested_leaf_string
Definition: dict_test.c:78
fr_dict_attr_t const * fr_dict_attr_test_int32
Definition: dict_test.c:52
fr_dict_attr_t const * fr_dict_attr_test_int16
Definition: dict_test.c:51
fr_dict_attr_t const * fr_dict_attr_test_nested_top_tlv
Definition: dict_test.c:76
fr_dict_attr_t const * fr_dict_attr_test_string
Definition: dict_test.c:30
fr_dict_attr_t const * fr_dict_attr_test_nested_child_tlv
Definition: dict_test.c:77
fr_dict_attr_t const * fr_dict_attr_test_group
Definition: dict_test.c:74
fr_dict_attr_t const * fr_dict_attr_test_nested_leaf_int32
Definition: dict_test.c:79

Definition at line 79 of file tmpl_dcursor_tests.c.

◆ pair_populate_thin

#define pair_populate_thin (   _x)
Value:
do { \
pair_append_request(&int32_vp ## _x, fr_dict_attr_test_int32); \
pair_append_request(&group_vp ## _x, fr_dict_attr_test_group); \
pair_append_request(&top_vp ## _x, fr_dict_attr_test_nested_top_tlv); \
fr_pair_append_by_da(top_vp ## _x, &mid_vp ## _x, &top_vp ## _x->children, fr_dict_attr_test_nested_child_tlv); \
fr_pair_append_by_da(mid_vp ## _x, &leaf_int32_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_int32); \
} while (0)

Definition at line 90 of file tmpl_dcursor_tests.c.

◆ test_cursor

#define test_cursor ( )    &vars.cursor

Definition at line 118 of file tmpl_dcursor_tests.c.

◆ test_end

#define test_end
Value:
debug_attr_list(&request->request_pairs, 0); \
vars.vp = fr_dcursor_next(test_cursor()); \
TEST_CHECK_PAIR(vars.vp, NULL); \
TEST_MSG("Cursor should've been empty (i.e. returned NULL) at end of test"); \
tmpl_dcursor_clear(&vars.cc); \
TEST_CHECK_RET(talloc_free(vars.vpt), 0); \
TEST_CHECK_RET(talloc_free(request), 0)
talloc_free(reap)

Definition at line 191 of file tmpl_dcursor_tests.c.

◆ TEST_FINI

#define TEST_FINI   test_free()

Definition at line 4 of file tmpl_dcursor_tests.c.

◆ TEST_INIT

#define TEST_INIT   test_init()

Definition at line 3 of file tmpl_dcursor_tests.c.

◆ test_vp

#define test_vp ( )    vars.vp

Definition at line 119 of file tmpl_dcursor_tests.c.

◆ test_vp_p

#define test_vp_p ( )    &vars.vp

Definition at line 120 of file tmpl_dcursor_tests.c.

◆ test_vp_set

#define test_vp_set (   _vp)    vars.vp = _vp

Definition at line 121 of file tmpl_dcursor_tests.c.

◆ tmpl_setup_and_cursor_build_init

#define tmpl_setup_and_cursor_build_init (   _vp_out,
  _ref 
)     if (_tmpl_setup_and_cursor_build_init(_vp_out, &vars, request, _ref)) return

Definition at line 185 of file tmpl_dcursor_tests.c.

◆ tmpl_setup_and_cursor_init

#define tmpl_setup_and_cursor_init (   _vp_out,
  _ref 
)     if (_tmpl_setup_and_cursor_init(_vp_out, &vars, request, _ref)) return

Definition at line 156 of file tmpl_dcursor_tests.c.

Function Documentation

◆ _tmpl_setup_and_cursor_build_init()

static int _tmpl_setup_and_cursor_build_init ( fr_pair_t **  vp_out,
tmpl_dcursor_vars_t vars,
request_t request,
char const *  ref 
)
inlinestatic

Initialise a tmpl using the _attr_str string, and return the first pair.

Parameters
[out]vp_outwhere to write the returned pair.
[in,out]varstest variables
[in]requestthe current request.
[in]refAttribute reference string.

Definition at line 167 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ _tmpl_setup_and_cursor_init()

static int _tmpl_setup_and_cursor_init ( fr_pair_t **  vp_out,
tmpl_dcursor_vars_t vars,
request_t request,
char const *  ref 
)
inlinestatic

Initialise a tmpl using the _attr_str string, and return the first pair.

Parameters
[out]vp_outwhere to write the returned pair
[in,out]varstest variables
[in]requestthe current request.
[in]refAttribute reference string.

Definition at line 138 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ debug_attr_list()

static void debug_attr_list ( fr_pair_list_t list,
int  indent 
)
static

Definition at line 210 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ request_fake_alloc()

static request_t* request_fake_alloc ( void  )
static

Definition at line 44 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_free()

static void test_free ( void  )
static

Definition at line 39 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_init()

static void test_init ( void  )
static

Global initialisation.

Definition at line 20 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_level_1_build()

static void test_level_1_build ( void  )
static

Definition at line 648 of file tmpl_dcursor_tests.c.

◆ test_level_1_one()

static void test_level_1_one ( void  )
static

Definition at line 229 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_all()

static void test_level_1_one_all ( void  )
static

Definition at line 259 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_last()

static void test_level_1_one_last ( void  )
static

Definition at line 289 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_missing()

static void test_level_1_one_missing ( void  )
static

Definition at line 274 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_second()

static void test_level_1_one_second ( void  )
static

Definition at line 244 of file tmpl_dcursor_tests.c.

◆ test_level_1_two()

static void test_level_1_two ( void  )
static

Definition at line 304 of file tmpl_dcursor_tests.c.

◆ test_level_1_two_all()

static void test_level_1_two_all ( void  )
static

Definition at line 355 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_level_1_two_count()

static void test_level_1_two_count ( void  )
static

Definition at line 393 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_level_1_two_last()

static void test_level_1_two_last ( void  )
static

Definition at line 376 of file tmpl_dcursor_tests.c.

◆ test_level_1_two_second()

static void test_level_1_two_second ( void  )
static

Definition at line 321 of file tmpl_dcursor_tests.c.

◆ test_level_1_two_third()

static void test_level_1_two_third ( void  )
static

Definition at line 338 of file tmpl_dcursor_tests.c.

◆ test_level_2_build_intermediate()

static void test_level_2_build_intermediate ( void  )
static

Definition at line 682 of file tmpl_dcursor_tests.c.

◆ test_level_2_build_leaf()

static void test_level_2_build_leaf ( void  )
static

Definition at line 665 of file tmpl_dcursor_tests.c.

◆ test_level_2_build_multi()

static void test_level_2_build_multi ( void  )
static

Definition at line 697 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_level_2_one()

static void test_level_2_one ( void  )
static

Definition at line 413 of file tmpl_dcursor_tests.c.

◆ test_level_2_one_all()

static void test_level_2_one_all ( void  )
static

Definition at line 443 of file tmpl_dcursor_tests.c.

◆ test_level_2_one_missing()

static void test_level_2_one_missing ( void  )
static

Definition at line 458 of file tmpl_dcursor_tests.c.

◆ test_level_2_one_second()

static void test_level_2_one_second ( void  )
static

Definition at line 428 of file tmpl_dcursor_tests.c.

◆ test_level_2_two()

static void test_level_2_two ( void  )
static

Definition at line 473 of file tmpl_dcursor_tests.c.

◆ test_level_2_two_all()

static void test_level_2_two_all ( void  )
static

Definition at line 507 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_level_2_two_last()

static void test_level_2_two_last ( void  )
static

Definition at line 527 of file tmpl_dcursor_tests.c.

◆ test_level_2_two_missing()

static void test_level_2_two_missing ( void  )
static

Definition at line 544 of file tmpl_dcursor_tests.c.

◆ test_level_2_two_second()

static void test_level_2_two_second ( void  )
static

Definition at line 490 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_entire()

static void test_level_3_build_entire ( void  )
static

Definition at line 739 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_invalid1()

static void test_level_3_build_invalid1 ( void  )
static

Definition at line 774 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_invalid2()

static void test_level_3_build_invalid2 ( void  )
static

Definition at line 789 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_leaf()

static void test_level_3_build_leaf ( void  )
static

Definition at line 722 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_partial()

static void test_level_3_build_partial ( void  )
static

Definition at line 754 of file tmpl_dcursor_tests.c.

◆ test_level_3_one()

static void test_level_3_one ( void  )
static

Definition at line 561 of file tmpl_dcursor_tests.c.

◆ test_level_3_one_all()

static void test_level_3_one_all ( void  )
static

Definition at line 591 of file tmpl_dcursor_tests.c.

◆ test_level_3_one_second()

static void test_level_3_one_second ( void  )
static

Definition at line 576 of file tmpl_dcursor_tests.c.

◆ test_level_3_two()

static void test_level_3_two ( void  )
static

Definition at line 603 of file tmpl_dcursor_tests.c.

◆ test_level_3_two_all()

static void test_level_3_two_all ( void  )
static

Definition at line 617 of file tmpl_dcursor_tests.c.

+ Here is the call graph for this function:

◆ test_level_3_two_last()

static void test_level_3_two_last ( void  )
static

Definition at line 634 of file tmpl_dcursor_tests.c.

Variable Documentation

◆ autofree

TALLOC_CTX* autofree
static

Definition at line 13 of file tmpl_dcursor_tests.c.

◆ test_dict

fr_dict_t* test_dict
static

Definition at line 14 of file tmpl_dcursor_tests.c.

◆ TEST_LIST

TEST_LIST

Definition at line 804 of file tmpl_dcursor_tests.c.