25 # define TEST_INIT test_init()
27 #include <freeradius-devel/util/acutest.h>
28 #include <freeradius-devel/util/acutest_helpers.h>
29 #include <freeradius-devel/util/pair_test_helpers.h>
31 #include <freeradius-devel/util/conf.h>
32 #include <freeradius-devel/util/dict.h>
33 #include <freeradius-devel/util/dict_test.h>
34 #include <freeradius-devel/util/pair.h>
35 #include <freeradius-devel/util/talloc.h>
37 #include <freeradius-devel/server/pair.h>
38 #include <freeradius-devel/server/request.h>
40 #ifdef HAVE_GPERFTOOLS_PROFILER_H
41 # include <gperftools/profiler.h>
102 TEST_CASE(
"Add 'Test-Integer' in 'request_pairs' using pair_append_request()");
110 vp->vp_uint32 = 12345;
123 TEST_CASE(
"Add 'Test-Integer' in 'reply_pairs' using pair_append_reply()");
131 vp->vp_uint32 = 12345;
145 TEST_CASE(
"Add 'Test-Integer' in 'control_pairs' using pair_append_control()");
153 vp->vp_uint32 = 12345;
167 TEST_CASE(
"Add 'Test-Integer' in 'control_pairs' using pair_append_session_state()");
175 vp->vp_uint32 = 12345;
188 TEST_CASE(
"Update 'Test-Integer' in 'request_pairs' using pair_update_request()");
195 vp->vp_uint32 = 112233;
197 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 112233)");
203 TEST_MSG(
"Checking if vp == 12345");
217 TEST_CASE(
"Update 'Test-Integer' in 'reply_pairs' using pair_update_request()");
224 vp->vp_uint32 = 3333;
226 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 3333)");
242 TEST_CASE(
"Update 'Test-Integer' in 'control_pairs' using pair_update_control()");
249 vp->vp_uint32 = 44444;
251 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 44444)");
267 TEST_CASE(
"Update 'Test-Integer' in 'state' using pair_update_session_state()");
274 vp->vp_uint32 = 7890;
276 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 7890)");
291 TEST_CASE(
"Copy 'test_pairs' into 'request->request_pairs'");
294 TEST_CASE(
"Delete 'Test-Integer' in 'request->request_pairs' using pair_delete_request()");
297 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->request_pairs'");
307 TEST_CASE(
"Copy 'test_pairs' into 'request->reply_pairs'");
310 TEST_CASE(
"Delete 'Test-Integer' in 'request->reply_pairs' using pair_delete_reply()");
313 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->reply_pairs'");
323 TEST_CASE(
"Copy 'test_pairs' into 'request->control_pairs'");
326 TEST_CASE(
"Delete 'Test-Integer' in 'request->control_pairs' using pair_delete_control()");
329 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->control_pairs'");
339 TEST_CASE(
"Copy 'test_pairs' into 'request->state'");
342 TEST_CASE(
"Delete 'Test-Integer' in 'request->state' using pair_delete_session_state()");
345 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->state'");
#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_uint32
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.
TEST_CHECK_RET((int) count,(int) 3)
fr_packet_t * fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
Allocate a new fr_packet_t.
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.
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
static void test_pair_update_control(void)
static void test_pair_append_request(void)
static void test_pair_append_session_state(void)
static void test_pair_delete_request(void)
static TALLOC_CTX * autofree
static void test_pair_append_control(void)
static void test_pair_delete_session_state(void)
static void test_pair_update_request(void)
static void test_pair_delete_control(void)
static fr_pair_list_t test_pairs
static void test_pair_append_reply(void)
static void test_pair_update_session_state(void)
static void test_pair_delete_reply(void)
static fr_dict_t * test_dict
static void test_init(void)
Global initialisation.
static void test_pair_update_reply(void)
static request_t * request_fake_alloc(void)
static int fr_pair_test_list_alloc(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_test_attr_t const *test_defs)
#define pair_update_request(_attr, _da)
int request_global_init(void)
#define request_local_alloc_external(_ctx, _args)
Allocate a new external request outside of the request pool.
#define pair_append_control(_attr, _da)
Allocate and append a fr_pair_t to the control list.
#define pair_update_reply(_attr, _da)
Return or allocate a fr_pair_t in the reply list.
#define pair_append_session_state(_attr, _da)
Allocate and append a fr_pair_t to session-state list.
#define pair_delete_session_state(_pair_or_da)
Delete a fr_pair_t in the session_state list.
#define pair_append_request(_attr, _da)
Allocate and append a fr_pair_t to the request list.
#define pair_delete_request(_pair_or_da)
Delete a fr_pair_t in the request list.
#define pair_update_session_state(_attr, _da)
Return or allocate a fr_pair_t in the session_state list.
#define pair_delete_reply(_pair_or_da)
Delete a fr_pair_t in the reply list.
#define pair_append_reply(_attr, _da)
Allocate and append a fr_pair_t to reply list.
#define pair_delete_control(_pair_or_da)
Delete a fr_pair_t in the control list.
#define pair_update_control(_attr, _da)
Return or allocate a fr_pair_t in the control list.
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.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of 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