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/pair_legacy.h>
50 #ifdef HAVE_GPERFTOOLS_PROFILER_H
51 # include <gperftools/profiler.h>
88 char const *
buffer =
"Test-Uint32-0 = 123, Test-String-0 = \"Testing123\"";
101 TEST_CASE(
"Create 'vp' using fr_pair_list_afrom_substr()");
110 TEST_CASE(
"Checking if (Test-Uint32-0 == 123)");
119 TEST_CASE(
"Checking if (Test-String-0 == 'Testing123')");
130 TEST_CHECK((fp = fmemopen(our_buffer, buffer_len,
"r")) != NULL);
141 char const *
buffer =
"Test-Uint32-0 = 123\nTest-String-0 = \"Testing123\"\n";
147 TEST_CASE(
"Create 'vp' using fr_pair_list_afrom_file()");
156 TEST_CASE(
"Checking if (Test-Uint32-0 == 123)");
165 TEST_CASE(
"Checking if (Test-String-0 == 'Testing123')");
178 char const *fake_file =
"Test-Uint32-0 = 123\nTest-String-0 = \"Testing123\"\n";
184 TEST_CASE(
"Create 'vp' using fr_pair_list_afrom_file()");
188 TEST_CASE(
"Move pair from 'old_list' to 'new_list' using fr_pair_list_move_op()");
199 TEST_CASE(
"Checking if (Test-Uint32-0 == 123)");
210 TEST_CASE(
"Checking if (Test-String-0 == 'Testing123')");
static int const char char buffer[256]
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_dict_attr_t const * fr_dict_attr_test_uint32
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_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
fr_slen_t fr_pair_list_afrom_substr(fr_pair_parse_t const *root, fr_pair_parse_t *relative, fr_sbuff_t *in)
Parse a fr_pair_list_t from a substring.
int fr_pair_list_afrom_file(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *out, FILE *fp, bool *pfiledone)
Read valuepairs from the fp up to End-Of-File.
void fr_pair_list_move_op(fr_pair_list_t *to, fr_pair_list_t *from, fr_token_t op)
Move pairs from source list to destination list respecting operator.
struct fr_pair_parse_s fr_pair_parse_t
static void test_fr_pair_list_afrom_file(void)
static void test_fr_pair_list_move_op(void)
static void test_fr_pair_list_afrom_substr(void)
static void test_init(void)
Global initialisation.
static FILE * open_buffer_as_file(uint8_t const *buffer, size_t buffer_len)
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 FR_SBUFF_IN(_start, _len_or_end)
Stores an attribute, a value and various bits of other data.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
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