26 # define TEST_INIT test_init()
27 # define TEST_FINI test_free()
29 #include <freeradius-devel/util/acutest.h>
30 #include <freeradius-devel/util/acutest_helpers.h>
31 #include <freeradius-devel/util/pair_test_helpers.h>
33 #include <freeradius-devel/util/conf.h>
34 #include <freeradius-devel/util/dict.h>
35 #include <freeradius-devel/util/dict_test.h>
36 #include <freeradius-devel/util/pair.h>
37 #include <freeradius-devel/util/talloc.h>
39 #include <freeradius-devel/server/pair.h>
40 #include <freeradius-devel/server/request.h>
42 #ifdef HAVE_GPERFTOOLS_PROFILER_H
43 # include <gperftools/profiler.h>
109 TEST_CASE(
"Add 'Test-Integer' in 'request_pairs' using pair_append_request()");
117 vp->vp_uint32 = 12345;
130 TEST_CASE(
"Add 'Test-Integer' in 'reply_pairs' using pair_append_reply()");
138 vp->vp_uint32 = 12345;
152 TEST_CASE(
"Add 'Test-Integer' in 'control_pairs' using pair_append_control()");
160 vp->vp_uint32 = 12345;
174 TEST_CASE(
"Add 'Test-Integer' in 'control_pairs' using pair_append_session_state()");
182 vp->vp_uint32 = 12345;
195 TEST_CASE(
"Update 'Test-Integer' in 'request_pairs' using pair_update_request()");
202 vp->vp_uint32 = 112233;
204 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 112233)");
210 TEST_MSG(
"Checking if vp == 12345");
224 TEST_CASE(
"Update 'Test-Integer' in 'reply_pairs' using pair_update_request()");
231 vp->vp_uint32 = 3333;
233 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 3333)");
249 TEST_CASE(
"Update 'Test-Integer' in 'control_pairs' using pair_update_control()");
256 vp->vp_uint32 = 44444;
258 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 44444)");
274 TEST_CASE(
"Update 'Test-Integer' in 'state' using pair_update_session_state()");
281 vp->vp_uint32 = 7890;
283 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 7890)");
298 TEST_CASE(
"Copy 'test_pairs' into 'request->request_pairs'");
301 TEST_CASE(
"Delete 'Test-Integer' in 'request->request_pairs' using pair_delete_request()");
304 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->request_pairs'");
314 TEST_CASE(
"Copy 'test_pairs' into 'request->reply_pairs'");
317 TEST_CASE(
"Delete 'Test-Integer' in 'request->reply_pairs' using pair_delete_reply()");
320 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->reply_pairs'");
330 TEST_CASE(
"Copy 'test_pairs' into 'request->control_pairs'");
333 TEST_CASE(
"Delete 'Test-Integer' in 'request->control_pairs' using pair_delete_control()");
336 TEST_CASE(
"The 'Test-Integer' shouldn't exist in 'request->control_pairs'");
346 TEST_CASE(
"Copy 'test_pairs' into 'request->state'");
349 TEST_CASE(
"Delete 'Test-Integer' in 'request->state' using pair_delete_session_state()");
352 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 void test_free(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)
void request_global_free(void)
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