30#define USE_CONSTRUCTOR
39# define TEST_INIT test_init()
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>
112 TEST_CASE(
"Expected (count == 3) after undoing the edits");
135 TEST_CASE(
"Add 3 pairs and delete the first one");
150 TEST_CASE(
"Expected (count == 2) after deleting the head");
154 TEST_CASE(
"head is now what was the second pair");
168 TEST_CASE(
"Add 3 pairs and delete the first one");
181 TEST_CASE(
"Expected (count == 2) after deleting the head");
200 TEST_CASE(
"Add 3 pairs and delete the middle one");
218 TEST_CASE(
"Expected (count == 2) after deleting the middle");
238 TEST_CASE(
"Add 3 pairs and delete the middle one, then abort");
254 TEST_CASE(
"Expected (count == 2) after deleting the middle");
279 TEST_CASE(
"Add 3 pairs and delete the last 2");
302 TEST_CASE(
"Expected (count == 1) after deleting the last 2");
322 TEST_CASE(
"Add 3 pairs and delete the last two, then abort");
345 TEST_CASE(
"Expected (count == 1) after deleting the last 2");
370 TEST_CASE(
"Add 3 pairs and change the value of the first one");
404 TEST_CASE(
"Add 3 pairs and change the value of the first one, then abort");
442 TEST_CASE(
"Add 3 pairs and insert a new one at the head");
457 TEST_CASE(
"Expected (count == 4) after inserting a new one");
461 TEST_CASE(
"head is now what was the second pair");
475 TEST_CASE(
"Add 3 pairs and insert a new one at the head, then abort");
488 TEST_CASE(
"Expected (count == 4) after inserting a new one");
507 TEST_CASE(
"Add 3 pairs and insert a new one at the head");
526 TEST_CASE(
"Expected (count == 4) after inserting a new one");
540 TEST_CASE(
"Add 3 pairs and insert a new one at the head, then abort");
557 TEST_CASE(
"Expected (count == 4) after inserting a new one");
575 TEST_CASE(
"Add 3 pairs, change the value of the first one, and delete it");
602 TEST_CASE(
"Expected (count == 2) after deleting the edited pair");
613 TEST_CASE(
"Add 3 pairs, change the value of the first one, and delete it, then abort");
654 TEST_CASE(
"Add 3 pairs and insert a new one at the head, and delete it");
667 TEST_CASE(
"Expected (count == 4) after inserting a new one");
674 TEST_CASE(
"Expected (count == 3) after deleting the just inserted on");
690 TEST_CASE(
"Add 3 pairs and insert a new one at the head and delete it, then abort");
703 TEST_CASE(
"Expected (count == 4) after inserting a new one");
722 TEST_CASE(
"Add 3 pairs and change the value of the first one in a child transaction");
771 TEST_CASE(
"Add 3 pairs and change the value of the first one, then abort");
821 TEST_CASE(
"Add 3 pairs and delete the tail");
838 TEST_CASE(
"Expected (count == 2) after deleting the tail");
855 TEST_CASE(
"Add 3 pairs and delete the tail, then abort");
885 TEST_CASE(
"Add pairs and delete all with a matching da");
907 TEST_CASE(
"Expected (count == 2) after deleting all uint32 pairs");
927 TEST_CASE(
"Add pairs and delete all with a matching da, then abort");
951 TEST_CASE(
"Expected (count == 4) after aborting the delete");
973 TEST_CASE(
"Add 3 pairs and replace the value of the first one");
1009 TEST_CASE(
"Add 3 pairs and replace the value of the first one, then abort");
1045 TEST_CASE(
"Add 3 pairs and replace the head with a new pair");
1057 new_vp->vp_uint32 = 99;
1065 TEST_CASE(
"Expected (count == 3) after replacing a pair");
1082 TEST_CASE(
"Add 3 pairs and replace the head, then abort");
1094 new_vp->vp_uint32 = 99;
1119 TEST_CASE(
"Add 3 pairs and insert a new one at the tail");
1134 TEST_CASE(
"Expected (count == 4) after inserting at the tail");
1151 TEST_CASE(
"Add 3 pairs and insert a new one at the tail, then abort");
1179 TEST_CASE(
"Add children to a TLV pair and free them");
1215 TEST_CASE(
"Add children to a TLV pair, free them, then abort");
1252 TEST_CASE(
"Add 3 pairs and insert a list of 2 at the tail");
1275 TEST_CASE(
"Expected (count == 5) after inserting a list of 2");
1292 TEST_CASE(
"Add 3 pairs and insert a list of 2 at the tail, then abort");
1327 TEST_CASE(
"Child commits value change, parent aborts - everything reverted");
static TALLOC_CTX * autofree
#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_string
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.
fr_dict_attr_t const * fr_dict_attr_test_uint16
static void test_pair_delete_multiple(void)
static void test_pair_insert_list_tail(void)
static void test_pair_delete_head(void)
static void test_pair_delete_head_abort(void)
static void test_pair_delete_tail(void)
static void test_pair_replace_value_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_replace_pair(void)
static void test_pair_edit_child_commit_parent_abort(void)
static void test_pair_delete_by_da(void)
static void test_pair_edit_value(void)
static void test_pair_free_children(void)
static void test_pair_insert_after_tail_abort(void)
static void test_pair_delete_by_da_abort(void)
static void test_pair_replace_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_tail(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_free_children_abort(void)
static void test_pair_insert_list_tail_abort(void)
static void test_pair_edit_value_delete(void)
static void test_pair_delete_tail_abort(void)
static void test_init(void)
Global initialisation.
static void test_pair_replace_pair_abort(void)
static void test_pair_edit_value_abort(void)
static void test_pair_insert_after_middle_abort(void)
@ FR_TYPE_UINT32
32 Bit unsigned integer.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
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.
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
Helper functions for pair tests.
static int fr_pair_test_list_alloc(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_test_attr_t const *test_defs)
#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.
int fr_edit_list_replace_pair_value(fr_edit_list_t *el, fr_pair_t *vp, fr_value_box_t *box)
Write a new value to the fr_value_box_t.
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.
int fr_edit_list_replace_pair(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp)
Replace a pair with another one.
int fr_edit_list_free_pair_children(fr_edit_list_t *el, fr_pair_t *vp)
Free children of a structural pair.
int fr_edit_list_pair_delete_by_da(fr_edit_list_t *el, fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete VPs with a matching da.
fr_edit_list_t * fr_edit_list_alloc(TALLOC_CTX *ctx, int hint, fr_edit_list_t *parent)
Allocate an edit list.
#define fr_edit_list_insert_pair_tail(_el, _list, _vp)
#define fr_edit_list_insert_list_tail(_el, _list, _to_insert)
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
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.
fr_pair_t * fr_pair_list_tail(fr_pair_list_t const *list)
Get the tail of a valuepair list.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of 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
#define fr_value_box_init(_vb, _type, _enumv, _tainted)
Initialise a fr_value_box_t.