30 #define USE_CONSTRUCTOR
35 #ifdef USE_CONSTRUCTOR
39 # define TEST_INIT test_init()
42 #include <freeradius-devel/util/acutest.h>
43 #include <freeradius-devel/util/acutest_helpers.h>
44 #include <freeradius-devel/util/pair_test_helpers.h>
46 #include <freeradius-devel/util/conf.h>
47 #include <freeradius-devel/util/dict.h>
48 #include <freeradius-devel/util/edit.h>
50 #ifdef HAVE_GPERFTOOLS_PROFILER_H
51 # include <gperftools/profiler.h>
115 TEST_CASE(
"Expected (count == 3) after undoing the edits");
138 TEST_CASE(
"Add 3 pairs and delete the first one");
153 TEST_CASE(
"Expected (count == 2) after deleting the head");
157 TEST_CASE(
"head is now what was the second pair");
171 TEST_CASE(
"Add 3 pairs and delete the first one");
184 TEST_CASE(
"Expected (count == 2) after deleting the head");
203 TEST_CASE(
"Add 3 pairs and delete the middle one");
221 TEST_CASE(
"Expected (count == 2) after deleting the middle");
241 TEST_CASE(
"Add 3 pairs and delete the middle one, then abort");
257 TEST_CASE(
"Expected (count == 2) after deleting the middle");
282 TEST_CASE(
"Add 3 pairs and delete the last 2");
305 TEST_CASE(
"Expected (count == 1) after deleting the last 2");
325 TEST_CASE(
"Add 3 pairs and delete the last two, then abort");
348 TEST_CASE(
"Expected (count == 1) after deleting the last 2");
373 TEST_CASE(
"Add 3 pairs and change the value of the first one");
407 TEST_CASE(
"Add 3 pairs and change the value of the first one, then abort");
445 TEST_CASE(
"Add 3 pairs and insert a new one at the head");
460 TEST_CASE(
"Expected (count == 4) after inserting a new one");
464 TEST_CASE(
"head is now what was the second pair");
478 TEST_CASE(
"Add 3 pairs and insert a new one at the head, then abort");
491 TEST_CASE(
"Expected (count == 4) after inserting a new one");
510 TEST_CASE(
"Add 3 pairs and insert a new one at the head");
529 TEST_CASE(
"Expected (count == 4) after inserting a new one");
543 TEST_CASE(
"Add 3 pairs and insert a new one at the head, then abort");
560 TEST_CASE(
"Expected (count == 4) after inserting a new one");
578 TEST_CASE(
"Add 3 pairs, change the value of the first one, and delete it");
605 TEST_CASE(
"Expected (count == 2) after deleting the edited pair");
616 TEST_CASE(
"Add 3 pairs, change the value of the first one, and delete it, then abort");
657 TEST_CASE(
"Add 3 pairs and insert a new one at the head, and delete it");
670 TEST_CASE(
"Expected (count == 4) after inserting a new one");
677 TEST_CASE(
"Expected (count == 3) after deleting the just inserted on");
693 TEST_CASE(
"Add 3 pairs and insert a new one at the head and delete it, then abort");
706 TEST_CASE(
"Expected (count == 4) after inserting a new one");
725 TEST_CASE(
"Add 3 pairs and change the value of the first one in a child transaction");
774 TEST_CASE(
"Add 3 pairs and change the value of the first one, then abort");
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
fr_dict_attr_t const * fr_dict_attr_test_tlv
fr_dict_attr_t const * fr_dict_attr_test_uint32
fr_dict_attr_t const * fr_dict_attr_test_octets
fr_dict_attr_t const * fr_dict_attr_test_string
int fr_dict_test_init(TALLOC_CTX *ctx, fr_dict_t **dict_p, fr_dict_test_attr_t const *test_defs)
Initialise a test dictionary and add our test_defs to it.
static void test_pair_delete_multiple(void)
static void test_pair_delete_head(void)
static void test_pair_delete_head_abort(void)
static void test_pair_delete_multiple_abort(void)
static void test_pair_edit_value_delete_abort(void)
static void test_pair_insert_after_head_delete_abort(void)
static void test_pair_delete_middle_abort(void)
static void expect3(fr_pair_list_t *local_pairs)
static void test_pair_edit_value(void)
static void test_pair_insert_after_middle(void)
static void test_pair_edit_child_value(void)
static void add_pairs(fr_pair_list_t *local_pairs)
static void test_pair_insert_after_head_abort(void)
static void test_pair_insert_after_head(void)
static void test_pair_insert_after_head_delete(void)
static void test_pair_edit_child_value_abort(void)
static void test_pair_delete_middle(void)
static void test_pair_edit_value_delete(void)
static void test_init(void)
Global initialisation.
static void test_pair_edit_value_abort(void)
static void test_pair_insert_after_middle_abort(void)
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
static fr_pair_list_t test_pairs
static fr_dict_t * test_dict
static int fr_pair_test_list_alloc(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_test_attr_t const *test_defs)
static TALLOC_CTX * autofree
#define local_pairs
Convenience macro for accessing the state list.
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
static fr_event_list_t * el
int fr_edit_list_pair_delete(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *vp)
Delete a VP.
void fr_edit_list_commit(fr_edit_list_t *el)
Commit an edit list.
int fr_edit_list_insert_pair_after(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *vp)
Insert a new VP after an existing one.
int fr_edit_list_save_pair_value(fr_edit_list_t *el, fr_pair_t *vp)
Record the value of a leaf fr_value_box_t.
void fr_edit_list_abort(fr_edit_list_t *el)
Abort the entries in an edit list.
fr_edit_list_t * fr_edit_list_alloc(TALLOC_CTX *ctx, int hint, fr_edit_list_t *parent)
Allocate an edit list.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
fr_pair_t * fr_pair_list_tail(fr_pair_list_t const *list)
Get the tail of a valuepair list.
fr_pair_t * fr_pair_list_next(fr_pair_list_t const *list, fr_pair_t const *item))
Get the next item in a valuepair list after a specific entry.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
size_t fr_pair_list_num_elements(fr_pair_list_t const *list)
Get the length of a list of fr_pair_t.
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
#define RADIUSD_MAGIC_NUMBER