25# define TEST_INIT test_init()
27#include <freeradius-devel/util/test/acutest.h>
28#include <freeradius-devel/util/test/acutest_helpers.h>
29#include <freeradius-devel/server/cf_file.h>
30#include <freeradius-devel/server/cf_util.h>
31#include <freeradius-devel/server/cf_priv.h>
945 output,
sizeof(output),
946 "hello world", -1, NULL);
949 TEST_CHECK(strcmp(result,
"hello world") == 0);
950 TEST_MSG(
"Expected 'hello world', got '%s'", result);
968 output,
sizeof(output),
969 "${name}", -1, NULL);
973 TEST_MSG(
"Expected 'testval', got '%s'", result);
994 output,
sizeof(output),
995 "${server.name}", -1, NULL);
999 TEST_MSG(
"Expected 'myserver', got '%s'", result);
1010 bool soft_fail =
false;
1016 output,
sizeof(output),
1017 "${nonexistent}", -1, &soft_fail);
1020 TEST_MSG(
"Expected soft_fail to be set for missing reference");
1046 TEST_MSG(
"cf_pair_values_concat returned %zd", slen);
1048 fr_sbuff_terminate(&sbuff);
static int const char char buffer[256]
#define TEST_ASSERT(cond)
#define L(_str)
Helper for initialising arrays of string literals.
char const * cf_expand_variables(char const *cf, int lineno, CONF_SECTION *outer_cs, char *output, size_t outsize, char const *input, ssize_t inlen, bool *soft_fail)
CONF_ITEM * cf_reference_item(CONF_SECTION const *parent_cs, CONF_SECTION const *outer_cs, char const *ptr)
Internal data that is associated with a configuration section.
Common header for all CONF_* types.
Configuration AVP similar to a fr_pair_t.
A section grouping multiple CONF_PAIR.
static void test_section_alloc_parent(void)
static size_t test_table_len
static void test_item_remove_pair(void)
static void test_data_remove(void)
static void test_pair_values_concat_missing(void)
static void test_pair_values_concat(void)
static void test_section_find_name1_name2(void)
static TALLOC_CTX * autofree
static void test_cf_root(void)
static void test_section_name_cmp(void)
static void test_filename_lineno(void)
static void test_pair_in_table_invalid(void)
static void test_pair_find_next(void)
static void test_item_mark_parsed(void)
static void test_section_alloc_name1_name2(void)
static void test_pair_count_descendents(void)
static void test_section_to_item_roundtrip(void)
static void test_reference_item_pair(void)
static void test_reference_item_section(void)
static void test_expand_nested_ref(void)
static void test_pair_first_next(void)
static void test_section_first_next(void)
static void test_expand_section_ref(void)
static void test_section_value_find(void)
static void test_pair_count(void)
static void test_data_find_missing(void)
static void test_reference_item_missing(void)
static void test_expand_no_variables(void)
static void test_pair_find_basic(void)
static void test_pair_in_table_found(void)
static void test_pair_replace(void)
static void test_section_dup_basic(void)
static void test_pair_alloc_no_value(void)
static void test_lineno_set(void)
static void test_section_alloc_name1_only(void)
static void test_pair_to_item_roundtrip(void)
static void test_expand_missing_ref(void)
static void test_pair_alloc_quoted(void)
static void test_item_remove_section(void)
static void test_section_find_missing(void)
static void test_section_dup_rename(void)
static void test_pair_find_missing(void)
static void test_item_free_children(void)
static void test_pair_dup(void)
static void test_section_find_next(void)
static void test_item_next_mixed(void)
static void test_section_find_child(void)
static void test_init(void)
Global initialisation.
static void test_data_add_find(void)
static void test_pair_alloc_operators(void)
static void test_pair_alloc_basic(void)
static void test_section_prev(void)
static fr_table_num_sorted_t const test_table[]
static void test_pair_prev(void)
static void test_filename_set(void)
bool cf_item_is_pair(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_PAIR.
fr_token_t cf_pair_attr_quote(CONF_PAIR const *pair)
Return the value (lhs) quoting of a pair.
void * _cf_data_remove(CONF_ITEM *parent, CONF_DATA const *cd)
Remove data from a configuration section.
unsigned int cf_pair_count_descendents(CONF_SECTION const *cs)
Count the number of conf pairs beneath a section.
CONF_PAIR * cf_pair_find_next(CONF_SECTION const *cs, CONF_PAIR const *prev, char const *attr)
Find a pair with a name matching attr, after specified pair.
CONF_DATA const * _cf_data_find(CONF_ITEM const *ci, char const *type, char const *name)
Find user data in a config section.
unsigned int cf_pair_count(CONF_SECTION const *cs, char const *attr)
Count the number of times an attribute occurs in a parent section.
int cf_pair_in_table(int32_t *out, fr_table_num_sorted_t const *table, size_t table_len, CONF_PAIR *cp)
Check to see if the CONF_PAIR value is present in the specified table.
CONF_PAIR * cf_pair_dup(CONF_SECTION *parent, CONF_PAIR *cp, bool copy_meta)
Duplicate a CONF_PAIR.
fr_slen_t cf_pair_values_concat(fr_sbuff_t *out, CONF_SECTION const *cs, char const *attr, char const *sep)
Concatenate the values of any pairs with name attr.
char const * cf_section_name2(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
int8_t cf_section_name_cmp(CONF_SECTION const *cs, char const *name1, char const *name2)
Check if a given section matches the specified name1/name2 identifiers.
void * cf_data_value(CONF_DATA const *cd)
Return the user assigned value of CONF_DATA.
CONF_ITEM * cf_section_to_item(CONF_SECTION const *cs)
Cast a CONF_SECTION to a CONF_ITEM.
CONF_PAIR * cf_pair_alloc(CONF_SECTION *parent, char const *attr, char const *value, fr_token_t op, fr_token_t lhs_quote, fr_token_t rhs_quote)
Allocate a CONF_PAIR.
CONF_SECTION * cf_section_next(CONF_SECTION const *cs, CONF_SECTION const *curr)
Return the next child that's a CONF_SECTION.
char const * cf_section_name1(CONF_SECTION const *cs)
Return the second identifier of a CONF_SECTION.
CONF_SECTION * cf_section_find(CONF_SECTION const *cs, char const *name1, char const *name2)
Find a CONF_SECTION with name1 and optionally name2.
CONF_SECTION * cf_item_to_section(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_SECTION.
CONF_PAIR * cf_pair_find(CONF_SECTION const *cs, char const *attr)
Search for a CONF_PAIR with a specific name.
char const * cf_section_value_find(CONF_SECTION const *cs, char const *attr)
Find a pair in a CONF_SECTION.
char const * cf_section_name(CONF_SECTION const *cs)
Return name2 if set, else name1.
bool cf_item_is_data(CONF_ITEM const *ci)
Determine if CONF_ITEM is CONF_DATA.
fr_token_t cf_pair_operator(CONF_PAIR const *pair)
Return the operator of a pair.
fr_token_t cf_pair_value_quote(CONF_PAIR const *pair)
Return the value (rhs) quoting of a pair.
CONF_PAIR * cf_pair_first(CONF_SECTION const *cs)
Return the first child that's a CONF_PAIR.
CONF_PAIR * cf_pair_next(CONF_SECTION const *cs, CONF_PAIR const *curr)
Return the next child that's a CONF_PAIR.
bool cf_item_is_section(CONF_ITEM const *ci)
Determine if CONF_ITEM is a CONF_SECTION.
CONF_SECTION * cf_section_dup(TALLOC_CTX *ctx, CONF_SECTION *parent, CONF_SECTION const *cs, char const *name1, char const *name2, bool copy_meta)
Duplicate a configuration section.
CONF_PAIR * cf_pair_prev(CONF_SECTION const *cs, CONF_PAIR const *curr)
Return the previous child that's a CONF_PAIR.
CONF_SECTION * cf_section_first(CONF_SECTION const *cs)
Return the first child in a CONF_SECTION.
CONF_PAIR * cf_item_to_pair(CONF_ITEM const *ci)
Cast a CONF_ITEM to a CONF_PAIR.
CONF_SECTION * cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *prev, char const *name1, char const *name2)
Return the next matching section.
char const * cf_pair_value(CONF_PAIR const *pair)
Return the value of a CONF_PAIR.
int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, char const *value)
Replace pair value in a given section with the given value.
CONF_ITEM * cf_pair_to_item(CONF_PAIR const *cp)
Cast a CONF_PAIR to a CONF_ITEM.
CONF_SECTION * cf_section_prev(CONF_SECTION const *cs, CONF_SECTION const *curr)
Return the previous child that's a CONF_SECTION.
char const * cf_pair_attr(CONF_PAIR const *pair)
Return the attr of a CONF_PAIR.
#define cf_data_add(_cf, _data, _name, _free)
#define cf_item_is_parsed(_cf)
#define cf_lineno_set(_ci, _lineno)
#define cf_section_free_children(_x)
#define cf_item_remove(_parent, _child)
#define cf_item_next(_parent, _curr)
#define cf_section_alloc(_ctx, _parent, _name1, _name2)
#define cf_filename_set(_ci, _filename)
#define cf_item_mark_parsed(_cf)
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
#define FR_SBUFF_OUT(_start, _len_or_end)
An element in a lexicographically sorted array of name to num mappings.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
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
static size_t char ** out