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_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_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 103 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:288
static void debug_attr_list(fr_pair_list_t *list, int indent)
#define test_cursor()
#define test_vp()

Definition at line 197 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 119 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 55 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 65 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 72 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 83 of file tmpl_dcursor_tests.c.

◆ test_cursor

#define test_cursor ( )    &vars.cursor

Definition at line 111 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 184 of file tmpl_dcursor_tests.c.

◆ TEST_INIT

#define TEST_INIT   test_init()

Definition at line 2 of file tmpl_dcursor_tests.c.

◆ test_vp

#define test_vp ( )    vars.vp

Definition at line 112 of file tmpl_dcursor_tests.c.

◆ test_vp_p

#define test_vp_p ( )    &vars.vp

Definition at line 113 of file tmpl_dcursor_tests.c.

◆ test_vp_set

#define test_vp_set (   _vp)    vars.vp = _vp

Definition at line 114 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 178 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 149 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 160 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 131 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 203 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 37 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 18 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 641 of file tmpl_dcursor_tests.c.

◆ test_level_1_one()

static void test_level_1_one ( void  )
static

Definition at line 222 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_all()

static void test_level_1_one_all ( void  )
static

Definition at line 252 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_last()

static void test_level_1_one_last ( void  )
static

Definition at line 282 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_missing()

static void test_level_1_one_missing ( void  )
static

Definition at line 267 of file tmpl_dcursor_tests.c.

◆ test_level_1_one_second()

static void test_level_1_one_second ( void  )
static

Definition at line 237 of file tmpl_dcursor_tests.c.

◆ test_level_1_two()

static void test_level_1_two ( void  )
static

Definition at line 297 of file tmpl_dcursor_tests.c.

◆ test_level_1_two_all()

static void test_level_1_two_all ( void  )
static

Definition at line 348 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 386 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 369 of file tmpl_dcursor_tests.c.

◆ test_level_1_two_second()

static void test_level_1_two_second ( void  )
static

Definition at line 314 of file tmpl_dcursor_tests.c.

◆ test_level_1_two_third()

static void test_level_1_two_third ( void  )
static

Definition at line 331 of file tmpl_dcursor_tests.c.

◆ test_level_2_build_intermediate()

static void test_level_2_build_intermediate ( void  )
static

Definition at line 675 of file tmpl_dcursor_tests.c.

◆ test_level_2_build_leaf()

static void test_level_2_build_leaf ( void  )
static

Definition at line 658 of file tmpl_dcursor_tests.c.

◆ test_level_2_build_multi()

static void test_level_2_build_multi ( void  )
static

Definition at line 690 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 406 of file tmpl_dcursor_tests.c.

◆ test_level_2_one_all()

static void test_level_2_one_all ( void  )
static

Definition at line 436 of file tmpl_dcursor_tests.c.

◆ test_level_2_one_missing()

static void test_level_2_one_missing ( void  )
static

Definition at line 451 of file tmpl_dcursor_tests.c.

◆ test_level_2_one_second()

static void test_level_2_one_second ( void  )
static

Definition at line 421 of file tmpl_dcursor_tests.c.

◆ test_level_2_two()

static void test_level_2_two ( void  )
static

Definition at line 466 of file tmpl_dcursor_tests.c.

◆ test_level_2_two_all()

static void test_level_2_two_all ( void  )
static

Definition at line 500 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 520 of file tmpl_dcursor_tests.c.

◆ test_level_2_two_missing()

static void test_level_2_two_missing ( void  )
static

Definition at line 537 of file tmpl_dcursor_tests.c.

◆ test_level_2_two_second()

static void test_level_2_two_second ( void  )
static

Definition at line 483 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_entire()

static void test_level_3_build_entire ( void  )
static

Definition at line 732 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_invalid1()

static void test_level_3_build_invalid1 ( void  )
static

Definition at line 767 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_invalid2()

static void test_level_3_build_invalid2 ( void  )
static

Definition at line 782 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_leaf()

static void test_level_3_build_leaf ( void  )
static

Definition at line 715 of file tmpl_dcursor_tests.c.

◆ test_level_3_build_partial()

static void test_level_3_build_partial ( void  )
static

Definition at line 747 of file tmpl_dcursor_tests.c.

◆ test_level_3_one()

static void test_level_3_one ( void  )
static

Definition at line 554 of file tmpl_dcursor_tests.c.

◆ test_level_3_one_all()

static void test_level_3_one_all ( void  )
static

Definition at line 584 of file tmpl_dcursor_tests.c.

◆ test_level_3_one_second()

static void test_level_3_one_second ( void  )
static

Definition at line 569 of file tmpl_dcursor_tests.c.

◆ test_level_3_two()

static void test_level_3_two ( void  )
static

Definition at line 596 of file tmpl_dcursor_tests.c.

◆ test_level_3_two_all()

static void test_level_3_two_all ( void  )
static

Definition at line 610 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 627 of file tmpl_dcursor_tests.c.

Variable Documentation

◆ autofree

TALLOC_CTX* autofree
static

Definition at line 11 of file tmpl_dcursor_tests.c.

◆ test_dict

fr_dict_t* test_dict
static

Definition at line 12 of file tmpl_dcursor_tests.c.

◆ TEST_LIST

TEST_LIST

Definition at line 797 of file tmpl_dcursor_tests.c.