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>
108 TEST_CASE(
"Expected (count == 3) after undoing the edits");
131 TEST_CASE(
"Add 3 pairs and delete the first one");
146 TEST_CASE(
"Expected (count == 2) after deleting the head");
150 TEST_CASE(
"head is now what was the second pair");
164 TEST_CASE(
"Add 3 pairs and delete the first one");
177 TEST_CASE(
"Expected (count == 2) after deleting the head");
196 TEST_CASE(
"Add 3 pairs and delete the middle one");
214 TEST_CASE(
"Expected (count == 2) after deleting the middle");
234 TEST_CASE(
"Add 3 pairs and delete the middle one, then abort");
250 TEST_CASE(
"Expected (count == 2) after deleting the middle");
275 TEST_CASE(
"Add 3 pairs and delete the last 2");
298 TEST_CASE(
"Expected (count == 1) after deleting the last 2");
318 TEST_CASE(
"Add 3 pairs and delete the last two, then abort");
341 TEST_CASE(
"Expected (count == 1) after deleting the last 2");
366 TEST_CASE(
"Add 3 pairs and change the value of the first one");
400 TEST_CASE(
"Add 3 pairs and change the value of the first one, then abort");
438 TEST_CASE(
"Add 3 pairs and insert a new one at the head");
453 TEST_CASE(
"Expected (count == 4) after inserting a new one");
457 TEST_CASE(
"head is now what was the second pair");
471 TEST_CASE(
"Add 3 pairs and insert a new one at the head, then abort");
484 TEST_CASE(
"Expected (count == 4) after inserting a new one");
503 TEST_CASE(
"Add 3 pairs and insert a new one at the head");
522 TEST_CASE(
"Expected (count == 4) after inserting a new one");
536 TEST_CASE(
"Add 3 pairs and insert a new one at the head, then abort");
553 TEST_CASE(
"Expected (count == 4) after inserting a new one");
571 TEST_CASE(
"Add 3 pairs, change the value of the first one, and delete it");
598 TEST_CASE(
"Expected (count == 2) after deleting the edited pair");
609 TEST_CASE(
"Add 3 pairs, change the value of the first one, and delete it, then abort");
650 TEST_CASE(
"Add 3 pairs and insert a new one at the head, and delete it");
663 TEST_CASE(
"Expected (count == 4) after inserting a new one");
670 TEST_CASE(
"Expected (count == 3) after deleting the just inserted on");
686 TEST_CASE(
"Add 3 pairs and insert a new one at the head and delete it, then abort");
699 TEST_CASE(
"Expected (count == 4) after inserting a new one");
718 TEST_CASE(
"Add 3 pairs and change the value of the first one in a child transaction");
767 TEST_CASE(
"Add 3 pairs and change the value of the first one, then abort");
817 TEST_CASE(
"Add 3 pairs and delete the tail");
834 TEST_CASE(
"Expected (count == 2) after deleting the tail");
851 TEST_CASE(
"Add 3 pairs and delete the tail, then abort");
881 TEST_CASE(
"Add pairs and delete all with a matching da");
903 TEST_CASE(
"Expected (count == 2) after deleting all uint32 pairs");
923 TEST_CASE(
"Add pairs and delete all with a matching da, then abort");
947 TEST_CASE(
"Expected (count == 4) after aborting the delete");
969 TEST_CASE(
"Add 3 pairs and replace the value of the first one");
1005 TEST_CASE(
"Add 3 pairs and replace the value of the first one, then abort");
1041 TEST_CASE(
"Add 3 pairs and replace the head with a new pair");
1053 new_vp->vp_uint32 = 99;
1061 TEST_CASE(
"Expected (count == 3) after replacing a pair");
1078 TEST_CASE(
"Add 3 pairs and replace the head, then abort");
1090 new_vp->vp_uint32 = 99;
1115 TEST_CASE(
"Add 3 pairs and insert a new one at the tail");
1130 TEST_CASE(
"Expected (count == 4) after inserting at the tail");
1147 TEST_CASE(
"Add 3 pairs and insert a new one at the tail, then abort");
1175 TEST_CASE(
"Add children to a TLV pair and free them");
1211 TEST_CASE(
"Add children to a TLV pair, free them, then abort");
1248 TEST_CASE(
"Add 3 pairs and insert a list of 2 at the tail");
1271 TEST_CASE(
"Expected (count == 5) after inserting a list of 2");
1288 TEST_CASE(
"Add 3 pairs and insert a list of 2 at the tail, then abort");
1323 TEST_CASE(
"Child commits value change, parent aborts - everything reverted");
#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.