The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
pair_list_perf_test.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/** Performance tests for lists of fr_pair_t
18 *
19 * @file src/lib/util/test//pair_list_perf_test.c
20 * @author Nick Porter <nick.porter@networkradius.com>
21 *
22 * @copyright 2021 Network RADIUS SAS (legal@networkradius.com)
23 */
24
25/**
26 * The 'TEST_INIT' macro provided by 'acutest.h' allows registering a function to be called
27 * before call the unit tests. Therefore, It calls the function ALL THE TIME causing an overhead.
28 * That is why we are initializing pair_list_perf_init() by "__attribute__((constructor));" reducing the
29 * test execution by 50% of the time.
30 */
31#define USE_CONSTRUCTOR
32
33/*
34 * It should be declared before including "acutest.h"
35 */
36#ifdef USE_CONSTRUCTOR
37static void pair_list_perf_init(void) __attribute__((constructor));
38#else
39static void pair_list_perf_init(void);
40#define TEST_INIT pair_list_perf_init()
41#endif
42
43#include "acutest_common_init.h"
44
45#ifdef WITH_VERIFY_PTR
46#undef WITH_VERIFY_PTR
47#endif
48
49#include <freeradius-devel/util/dict_test.h>
50#include <freeradius-devel/server/base.h>
51
52
53#define TEST_MSG_STATS \
54 do { \
55 TEST_MSG_ALWAYS("\n"); \
56 TEST_MSG_ALWAYS("repetitions = %u", reps); \
57 TEST_MSG_ALWAYS("%% repeated = %u", perc); \
58 TEST_MSG_ALWAYS("list_length = %u", len); \
59 TEST_MSG_ALWAYS("elapsed (ns) = %" PRId64, fr_time_delta_unwrap(used)); \
60 TEST_MSG_ALWAYS("calls/s = %0.0lf", (reps * len)/(fr_time_delta_unwrap(used) / (double)NSEC)); \
61 TEST_MSG_ALWAYS("(ns) / call = %0.0lf", (double) fr_time_delta_unwrap(used) / (double) reps); \
62 } while (0)
63
64/*
65 * Global variables
66 */
67static fr_dict_t *test_dict;
68static TALLOC_CTX *autofree;
69
70static char const *test_attrs_0 = \
71 "Test-String-# = \"hello\"," /* 1 */
72 "Test-Octets-# = 0x0102030405060708," /* 2 */
73 "Test-IPv4-Addr-# = 192.168.1.1," /* 3 */
74 "Test-IPv4-Prefix-# = 192.168/16," /* 4 */
75 "Test-IPv6-Addr-# = fd12:3456:789a:1::1," /* 5 */
76 "Test-IPv6-Prefix-# = fd12:3456:789a:1::/64," /* 6 */
77 "Test-Ethernet-# = 11:22:33:44:55:66," /* 7 */
78 "Test-Uint8-# = 255," /* 8 */
79 "Test-Uint16-# = 65535," /* 9 */
80 "Test-Uint32-# = 4294967295," /* 10 */
81 "Test-Uint64-# = 18446744073709551615," /* 11 */
82 "Test-Int8-# = -120," /* 12 */
83 "Test-Int16-# = -4573," /* 13 */
84 "Test-Int32-# = 45645," /* 14 */
85 "Test-Int64-# = 85645," /* 15 */
86 "Test-Float32-# = 1.134," /* 16 */
87 "Test-Float64-# = 1.1345," /* 17 */
88 "Test-Date-# += \"Jan 1 2020 00:00:00 UTC\"," /* 18 */
89 "Test-TLV-#.String = \"nested\"," /* 19 */
90 "Test-Struct-#.uint32 = 1234"; /* 20 */
91
92static char const *test_attrs_25 = \
93 "Test-String-# += \"hello\"," /* 1 */
94 "Test-String-# += \"goodbye\"," /* 2 */
95 "Test-String-# += \"hola\"," /* 3 */
96 "Test-String-# += \"hasta pronto\"," /* 4 */
97 "Test-String-# += \"bonjour\"," /* 5 */
98 "Test-Octets-# += 0x0102030405060708," /* 6 */
99 "Test-IPv4-Addr-# = 192.168.1.1," /* 7 */
100 "Test-IPv4-Prefix-# = 192.168/16," /* 8 */
101 "Test-IPv6-Addr-# = fd12:3456:789a:1::1," /* 9 */
102 "Test-IPv6-Prefix-# = fd12:3456:789a:1::/64," /* 10 */
103 "Test-Ethernet-# = 11:22:33:44:55:66," /* 11 */
104 "Test-Uint8-# = 255," /* 12 */
105 "Test-Uint16-# = 65535," /* 13 */
106 "Test-Uint32-# = 4294967295," /* 14 */
107 "Test-Uint64-# = 18446744073709551615," /* 15 */
108 "Test-Int64-# = 85645," /* 16 */
109 "Test-Float32-# = 1.134," /* 17 */
110 "Test-Date-# += \"Jan 1 2020 00:00:00 UTC\"," /* 18 */
111 "Test-TLV-#.String = \"nested\"," /* 19 */
112 "Test-Struct-#.uint32 = 1234"; /* 20 */
113
114static char const *test_attrs_50 = \
115 "Test-String-# += \"hello\"," /* 1 */
116 "Test-String-# += \"goodbye\"," /* 2 */
117 "Test-String-# += \"hola\"," /* 3 */
118 "Test-String-# += \"hasta pronto\"," /* 4 */
119 "Test-String-# += \"bonjour\"," /* 5 */
120 "Test-String-# += \"au revoir\"," /* 6 */
121 "Test-String-# += \"halo\"," /* 7 */
122 "Test-String-# += \"kwaheri\"," /* 8 */
123 "Test-String-# += \"ciao\"," /* 9 */
124 "Test-String-# += \"arrivederci\"," /* 10 */
125 "Test-IPv4-Addr-# = 192.168.1.1," /* 11 */
126 "Test-IPv4-Prefix-# = 192.168/16," /* 12 */
127 "Test-IPv6-Addr-# = fd12:3456:789a:1::1," /* 13 */
128 "Test-IPv6-Prefix-# = fd12:3456:789a:1::/64," /* 14 */
129 "Test-Ethernet-# = 11:22:33:44:55:66," /* 15 */
130 "Test-Uint8-# = 255," /* 16 */
131 "Test-Int64-# = 85645," /* 17 */
132 "Test-Date-# += \"Jan 1 2020 00:00:00 UTC\"," /* 18 */
133 "Test-TLV-#.String = \"nested\"," /* 19 */
134 "Test-Struct-#.uint32 = 1234"; /* 20 */
135
136static char const *test_attrs_75 = \
137 "Test-String-# += \"hello\"," /* 1 */
138 "Test-String-# += \"goodbye\"," /* 2 */
139 "Test-String-# += \"hola\"," /* 3 */
140 "Test-String-# += \"hasta pronto\"," /* 4 */
141 "Test-String-# += \"bonjour\"," /* 5 */
142 "Test-String-# += \"au revoir\"," /* 6 */
143 "Test-String-# += \"halo\"," /* 7 */
144 "Test-String-# += \"kwaheri\"," /* 8 */
145 "Test-String-# += \"ciao\"," /* 9 */
146 "Test-String-# += \"arrivederci\"," /* 10 */
147 "Test-String-# += \"halo\"," /* 11 */
148 "Test-String-# += \"selamat tinggal\"," /* 12 */
149 "Test-String-# += \"你好\"," /* 13 */
150 "Test-String-# += \"再见\"," /* 14 */
151 "Test-String-# += \"Я люблю сир\"," /* 15 */
152 "Test-Uint8-# = 255," /* 16 */
153 "Test-Int64-# = 85645," /* 17 */
154 "Test-Date-# += \"Jan 1 2020 00:00:00 UTC\"," /* 18 */
155 "Test-TLV-#.String = \"nested\"," /* 19 */
156 "Test-Struct-#.uint32 = 1234"; /* 20 */
157
158static char const *test_attrs_100 = \
159 "Test-String-# += \"hello\"," /* 1 */
160 "Test-String-# += \"goodbye\"," /* 2 */
161 "Test-String-# += \"hola\"," /* 3 */
162 "Test-String-# += \"hasta pronto\"," /* 4 */
163 "Test-String-# += \"bonjour\"," /* 5 */
164 "Test-String-# += \"au revoir\"," /* 6 */
165 "Test-String-# += \"halo\"," /* 7 */
166 "Test-String-# += \"kwaheri\"," /* 8 */
167 "Test-String-# += \"ciao\"," /* 9 */
168 "Test-String-# += \"arrivederci\"," /* 10 */
169 "Test-String-# += \"halo\"," /* 11 */
170 "Test-String-# += \"selamat tinggal\"," /* 12 */
171 "Test-String-# += \"你好\"," /* 13 */
172 "Test-String-# += \"再见\"," /* 14 */
173 "Test-String-# += \"Я люблю сир\"," /* 15 I love cheese */
174 "Test-String-# += \"Найкращий сир - бринза\"," /* 16 The best cheese is brynza */
175 "Test-String-# += \"Сулугуні чудовий на грилі\"," /* 17 Suluguni is wonderful grilled */
176 "Test-String-# += \"Сирники з домашнього сиру\"," /* 18 Syrnyky from homemade cheese */
177 "Test-String-# += \"Карпатська бринза пахне гірськими травами\","/* 19 (Carpathian brynza smells of mountain herbs */
178 "Test-String-# += \"Вареники з сиром найсмачніші\""; /* 20 Varenyky with cheese are the tastiest */
179
180static fr_pair_t **source_vps_0; //!< List with zero duplicate attributes.
181static fr_pair_t **source_vps_25; //!< List with 25% duplicate attributes.
182static fr_pair_t **source_vps_50; //!< List with 50% duplicate attributes.
183static fr_pair_t **source_vps_75; //!< List with 75% duplicate attributes.
184static fr_pair_t **source_vps_100; //!< List with 100% duplicate attributes, i.e. all the same.
185
186/** Duplicate a list of pairs starting at a particular item
187 *
188 * Copy all pairs from 'from' regardless of tag, attribute or vendor, starting at 'item'.
189 *
190 * @param[in] ctx for new #fr_pair_t (s) to be allocated in.
191 * @param[in] to where to copy attributes to.
192 * @param[in] from whence to copy #fr_pair_t (s).
193 * @param[in] start first pair to start copying from.
194 * @return
195 * - >0 the number of attributes copied.
196 * - 0 if no attributes copied.
197 * - -1 on error.
198 */
199static int fr_pair_sublist_copy(TALLOC_CTX *ctx, fr_pair_list_t *to,
200 fr_pair_list_t const *from, fr_pair_t const *start)
201{
202 fr_pair_t const *vp;
203 fr_pair_t *new_vp;
204 unsigned int cnt = 0;
205 fr_pair_list_t list;
206
207 fr_pair_list_init(&list);
208
209 if (!start) start = fr_pair_list_head(from);
210
211 for (vp = start;
212 vp != NULL;
213 vp = fr_pair_list_next(from, vp), cnt++) {
215
216 new_vp = fr_pair_copy(ctx, vp);
217 if (unlikely(!new_vp)) {
218 fr_pair_list_free(&list);
219 return -1;
220 }
221
222 fr_pair_append(&list, new_vp);
223 }
224
225 fr_pair_list_append(to, &list);
226
227 return cnt;
228}
229
230static void pair_list_init(TALLOC_CTX *ctx, fr_pair_t ***out, fr_dict_t const *dict, char const *pairs,
231 int const perc, int const reps)
232{
233 fr_pair_list_t list, full_list, dups;
234 char *prep_pairs, *p;
235 fr_pair_t *vp, *next;
236 int i;
237 size_t j;
238 fr_slen_t slen;
239 fr_pair_t **vp_array;
240 size_t input_count;
241
242 fr_pair_list_init(&list);
243 fr_pair_list_init(&full_list);
244 fr_pair_list_init(&dups);
245
246 prep_pairs = talloc_array(NULL, char, strlen(pairs) + 1);
247
248 /*
249 * Build a list of pairs, repeating the source list 'reps' times
250 * replacing the '#' in the source string with the number of this
251 * repetition.
252 */
253 for (i = 0; i < reps; i++) {
254 fr_pair_parse_t root, relative;
255
256 root = (fr_pair_parse_t) {
257 .ctx = ctx,
258 .da = fr_dict_root(dict),
259 .list = &list,
260 .dict = dict,
261 .internal = fr_dict_internal(),
262 };
263 relative = (fr_pair_parse_t) { };
264
265 strcpy(prep_pairs, pairs);
266 p = prep_pairs;
267 while ((p = strchr(p, '#'))) {
268 *p = (char)(i + 48);
269 }
270 slen = fr_pair_list_afrom_substr(&root, &relative, &FR_SBUFF_IN_STR(prep_pairs));
271 if (slen <= 0) fr_perror("pair_list_perf_tests");
272 TEST_ASSERT(slen > 0);
273
274 input_count = fr_pair_list_num_elements(&list);
275
276 if ((i == 0) && (perc > 0) && (reps > 0)) {
277 fr_pair_t *new_vp;
278 /*
279 * Copy the required number of attributes from the first iteration
280 * to use for duplicating attributes to required percentage.
281 * Duplicates are at the beginning of the source list
282 */
283 /* coverity[dereference] */
284 vp = fr_pair_list_head(&list);
285 for (j = 0; j < (size_t)(input_count * perc / 100); j++) {
286 /* coverity[dereference] */
287 new_vp = fr_pair_copy(ctx, vp);
288 fr_pair_append(&dups, new_vp);
289 /* coverity[dereference] */
290 vp = fr_pair_list_next(&list, vp);
291 }
292 }
293
294 if (i == 0) {
295 /*
296 * On the first iteration, just move the test pairs to the final list
297 */
298 fr_pair_list_append(&full_list, &list);
299 } else {
300 /*
301 * With subsequent iterations, replicate the duplicates from the first
302 * iteration to maintain the percentage of attribute repeats
303 */
304 vp = fr_pair_list_head(&dups);
305 fr_pair_sublist_copy(ctx, &full_list, &dups, vp);
306
307 /*
308 * Walk past equivalent pairs in new source list
309 */
310 vp = fr_pair_list_head(&list);
311 for (j = 0; j < fr_pair_list_num_elements(&dups); j++) vp = fr_pair_list_next(&list, vp);
312
313 /*
314 * Append copy remaining pairs from source list to destination
315 */
316 fr_pair_sublist_copy(ctx, &full_list, &list, vp);
317
318 /*
319 * We copied pairs rather than moving, free the source
320 */
321 fr_pair_list_free(&list);
322 }
323 }
324
325 talloc_free(prep_pairs);
326
327 /*
328 * Move vps to array so we can pick them randomly to populate the test list.
329 */
330 vp_array = talloc_array(ctx, fr_pair_t *, fr_pair_list_num_elements(&full_list));
331 for (vp = fr_pair_list_head(&full_list), i = 0; vp; vp = next, i++) {
332 next = fr_pair_list_next(&full_list, vp);
333 fr_pair_remove(&full_list, vp);
334 vp_array[i] = vp;
335 }
336
337 *out = vp_array;
338}
339
340void pair_list_perf_init(void)
341{
343 if (!autofree) {
344 error:
345 fr_perror("pair_list_perf_tests");
346 fr_exit_now(EXIT_FAILURE);
347 }
348
349 /*
350 * Mismatch between the binary and the libraries it depends on
351 */
352 if (fr_check_lib_magic(RADIUSD_MAGIC_NUMBER) < 0) goto error;
353
354 if (fr_dict_test_init(autofree, &test_dict, NULL) < 0) goto error;
355
356 if (fr_dict_test_attrs_init(test_dict, fr_dict_test_attrs, 100, 1) < 0) goto error;
357 if (fr_dict_test_attrs_init(test_dict, fr_dict_test_attrs, 200, 2) < 0) goto error;
358 if (fr_dict_test_attrs_init(test_dict, fr_dict_test_attrs, 300, 3) < 0) goto error;
359 if (fr_dict_test_attrs_init(test_dict, fr_dict_test_attrs, 400, 4) < 0) goto error;
360
361 pair_list_init(autofree, &source_vps_0, test_dict, test_attrs_0, 0, 5);
362 pair_list_init(autofree, &source_vps_25, test_dict, test_attrs_25, 25, 5);
363 pair_list_init(autofree, &source_vps_50, test_dict, test_attrs_50, 50, 5);
364 pair_list_init(autofree, &source_vps_75, test_dict, test_attrs_75, 75, 5);
365 pair_list_init(autofree, &source_vps_100, test_dict, test_attrs_100, 100, 5);
366
368}
369
370static void do_test_fr_pair_append(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
371{
372 fr_pair_list_t test_vps;
373 unsigned int i, j;
374 fr_pair_t *new_vp;
375 fr_time_t start, end;
377 size_t input_count = talloc_array_length(source_vps);
378 fr_fast_rand_t rand_ctx;
379
380 fr_pair_list_init(&test_vps);
381 rand_ctx.a = fr_rand();
382 rand_ctx.b = fr_rand();
383
384 /*
385 * Only use up to the number of pairs needed from the source to maintain ratio
386 * of attribute repeats.
387 */
388 if (input_count > len) input_count = len;
389
390 /*
391 * Insert pairs into the test list, choosing randomly from the source list
392 */
393 for (i = 0; i < reps; i++) {
394 for (j = 0; j < len; j++) {
395 int idx = fr_fast_rand(&rand_ctx) % input_count;
396 new_vp = fr_pair_copy(autofree, source_vps[idx]);
397 start = fr_time();
398 fr_pair_append(&test_vps, new_vp);
399 end = fr_time();
400 used = fr_time_delta_add(used, fr_time_sub(end, start));
401 }
402 TEST_CHECK(fr_pair_list_num_elements(&test_vps) == len);
403 fr_pair_list_free(&test_vps);
404 }
406}
407
408static void do_test_fr_pair_find_by_da(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
409{
410 fr_pair_list_t test_vps;
411 unsigned int i, j;
412 fr_pair_t *new_vp;
413 fr_time_t start, end;
415 fr_dict_attr_t const *da;
416 size_t input_count = talloc_array_length(source_vps);
417 fr_fast_rand_t rand_ctx;
418
419 fr_pair_list_init(&test_vps);
420 if (input_count > len) input_count = len;
421 rand_ctx.a = fr_rand();
422 rand_ctx.b = fr_rand();
423
424 /*
425 * Initialise the test list
426 */
427 for (i = 0; i < len; i++) {
428 int idx = fr_fast_rand(&rand_ctx) % input_count;
429 new_vp = fr_pair_copy(autofree, source_vps[idx]);
430 fr_pair_append(&test_vps, new_vp);
431 }
432
433 /*
434 * Find first instance of specific DA
435 */
436 for (i = 0; i < reps; i++) {
437 for (j = 0; j < len; j++) {
438 int idx = fr_fast_rand(&rand_ctx) % input_count;
439 da = source_vps[idx]->da;
440 start = fr_time();
441 (void) fr_pair_find_by_da(&test_vps, NULL, da);
442 end = fr_time();
443 used = fr_time_delta_add(used, fr_time_sub(end, start));
444 }
445 }
446 fr_pair_list_free(&test_vps);
448}
449
450static void do_test_find_nth(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
451{
452 fr_pair_list_t test_vps;
453 unsigned int i, j, nth_item;
454 fr_pair_t *new_vp;
455 fr_time_t start, end;
457 fr_dict_attr_t const *da;
458 size_t input_count = talloc_array_length(source_vps);
459 fr_fast_rand_t rand_ctx;
460
461 fr_pair_list_init(&test_vps);
462 if (input_count > len) input_count = len;
463 rand_ctx.a = fr_rand();
464 rand_ctx.b = fr_rand();
465
466 /*
467 * Initialise the test list
468 */
469 for (i = 0; i < len; i++) {
470 int idx = fr_fast_rand(&rand_ctx) % input_count;
471 new_vp = fr_pair_copy(autofree, source_vps[idx]);
472 fr_pair_append(&test_vps, new_vp);
473 }
474
475 /*
476 * Find nth instance of specific DA. nth is based on the percentage
477 * of attributes which are repeats.
478 */
479 nth_item = perc == 0 ? 1 : (unsigned int)(len * perc / 100);
480 for (i = 0; i < reps; i++) {
481 for (j = 0; j < len; j++) {
482 int idx = fr_fast_rand(&rand_ctx) % input_count;
483
484 da = source_vps[idx]->da;
485 start = fr_time();
486 (void) fr_pair_find_by_da_idx(&test_vps, da, nth_item);
487 end = fr_time();
488 used = fr_time_delta_add(used, fr_time_sub(end, start));
489 }
490 }
491 fr_pair_list_free(&test_vps);
493}
494
495static void do_test_fr_pair_list_free(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
496{
497 fr_pair_list_t test_vps;
498 unsigned int i, j;
499 fr_pair_t *new_vp;
500 fr_time_t start, end;
502 size_t input_count = talloc_array_length(source_vps);
503 fr_fast_rand_t rand_ctx;
504
505 fr_pair_list_init(&test_vps);
506 if (input_count > len) input_count = len;
507 rand_ctx.a = fr_rand();
508 rand_ctx.b = fr_rand();
509
510 for (i = 0; i < reps; i++) {
511 for (j = 0; j < len; j++) {
512 int idx = fr_fast_rand(&rand_ctx) % input_count;
513 new_vp = fr_pair_copy(autofree, source_vps[idx]);
514 fr_pair_append(&test_vps, new_vp);
515 }
516 start = fr_time();
517 fr_pair_list_free(&test_vps);
518 end = fr_time();
519 used = fr_time_delta_add(used, fr_time_sub(end, start));
520 }
521 fr_pair_list_free(&test_vps);
523}
524
525#define test_func(_func, _count, _perc, _source_vps) \
526static void test_ ## _func ## _ ## _count ## _ ## _perc(void)\
527{\
528 do_test_ ## _func(_count, _perc, 10000, _source_vps);\
529}
530
531#define test_funcs(_func, _perc) \
532 test_func(_func, 20, _perc, source_vps_ ## _perc) \
533 test_func(_func, 40, _perc, source_vps_ ## _perc) \
534 test_func(_func, 60, _perc, source_vps_ ## _perc) \
535 test_func(_func, 80, _perc, source_vps_ ## _perc) \
536 test_func(_func, 100, _perc, source_vps_ ## _perc)
537
538#define all_test_funcs(_func) \
539 test_funcs(_func, 0) \
540 test_funcs(_func, 25) \
541 test_funcs(_func, 50) \
542 test_funcs(_func, 75) \
543 test_funcs(_func, 100)
544
547all_test_funcs(find_nth)
549
550#define repetition_tests(_func, _perc) \
551 { #_func "_20_" #_perc, test_ ## _func ## _20_ ## _perc},\
552 { #_func "_40_" #_perc, test_ ## _func ## _40_ ## _perc},\
553 { #_func "_60_" #_perc, test_ ## _func ## _60_ ## _perc},\
554 { #_func "_80_" #_perc, test_ ## _func ## _80_ ## _perc},\
555 { #_func "_100_" #_perc, test_ ## _func ## _100_ ## _perc},\
556
557#define all_repetition_tests(_func) \
558 repetition_tests(_func, 0) \
559 repetition_tests(_func, 25) \
560 repetition_tests(_func, 50) \
561 repetition_tests(_func, 75) \
562 repetition_tests(_func, 100)
563
564TEST_LIST = {
567 all_repetition_tests(find_nth)
569
571};
#define TEST_CHECK(cond)
Definition acutest.h:87
#define TEST_LIST
Definition acutest.h:62
strcpy(log_entry->msg, buffer)
#define TEST_ASSERT(cond)
Definition acutest.h:110
#define TEST_TERMINATOR
Definition acutest.h:64
Common initialisation for acutest binaries.
#define unlikely(_x)
Definition build.h:455
TALLOC_CTX * autofree
Definition common.c:29
fr_dict_t * dict
Definition common.c:31
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
Definition debug.h:272
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2720
fr_dict_t const * fr_dict_internal(void)
Definition dict_util.c:5036
fr_dict_test_attr_t const fr_dict_test_attrs[]
Definition dict_test.c:86
int fr_dict_test_attrs_init(fr_dict_t *dict, fr_dict_test_attr_t const *test_defs, unsigned int base, int inst)
Add our test attributes to our test dictionary.
Definition dict_test.c:176
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.
Definition dict_test.c:248
#define __attribute__(x)
Definition filenames.h:38
talloc_free(hp)
#define fr_time()
Definition event.c:60
ssize_t fr_slen_t
unsigned long int size_t
static size_t used
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.
Definition pair.c:708
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
Definition pair.c:1298
fr_pair_t * fr_pair_find_by_da_idx(fr_pair_list_t const *list, fr_dict_attr_t const *da, unsigned int idx)
Find a pair with a matching da at a given index.
Definition pair.c:755
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
Definition pair.c:47
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
Definition pair.c:504
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.
TALLOC_CTX * ctx
Definition pair_legacy.h:43
#define all_repetition_tests(_func)
#define TEST_MSG_STATS
static void do_test_fr_pair_append(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
static void pair_list_perf_init(void)
static void do_test_find_nth(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
#define all_test_funcs(_func)
static void do_test_fr_pair_list_free(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
static void pair_list_init(TALLOC_CTX *ctx, fr_pair_t ***out, fr_dict_t const *dict, char const *pairs, int const perc, int const reps)
static void do_test_fr_pair_find_by_da(unsigned int len, unsigned int perc, unsigned int reps, fr_pair_t *source_vps[])
static fr_dict_t * test_dict
uint32_t fr_fast_rand(fr_fast_rand_t *ctx)
Definition rand.c:279
uint32_t fr_rand(void)
Return a 32-bit random number.
Definition rand.c:104
uint32_t b
Definition rand.h:55
uint32_t a
Definition rand.h:55
Smaller fast random number generator.
Definition rand.h:54
#define FR_SBUFF_IN_STR(_start)
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
Definition talloc.h:55
int fr_time_start(void)
Initialize the local time.
Definition time.c:157
static fr_time_delta_t fr_time_delta_add(fr_time_delta_t a, fr_time_delta_t b)
Definition time.h:255
#define fr_time_delta_wrap(_time)
Definition time.h:152
#define fr_time_sub(_a, _b)
Subtract one time from another.
Definition time.h:229
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
"server local" time.
Definition time.h:69
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.
Definition pair_inline.c:69
fr_pair_t * fr_pair_remove(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list without freeing.
Definition pair_inline.c:93
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define PAIR_VERIFY_WITH_LIST(_l, _x)
Definition pair.h:206
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
Definition pair_inline.c:42
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.
Definition strerror.c:737
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
Definition version.c:40
#define RADIUSD_MAGIC_NUMBER
Definition version.h:81
static size_t char ** out
Definition value.h:1062