23 RCSID(
"$Id: bab1e00e37c9a30de4b8f73cc7b1e2d91b9e4755 $")
25 #include <freeradius-devel/io/ring_buffer.h>
26 #include <freeradius-devel/util/request.h>
27 #include <freeradius-devel/util/debug.h>
28 #include <freeradius-devel/util/hash.h>
29 #include <freeradius-devel/util/syserror.h>
30 #include <freeradius-devel/util/talloc.h>
37 #define ALLOC_SIZE (8)
38 #define ARRAY_SIZE (4 * ALLOC_SIZE)
128 fprintf(stderr,
"usage: ring_buffer_test [OPTS]\n");
129 fprintf(stderr,
" -x Debugging mode.\n");
130 fprintf(stderr,
" -s <string> Set random seed to <string>.\n");
131 fprintf(stderr,
" -l <length> Set the iteration number to <length>.\n");
136 int main(
int argc,
char *argv[])
140 int i, start, end, length = 1000;
146 while ((c = getopt(argc, argv,
"hl:s:x")) != -1)
switch (c) {
148 length = strtol(optarg, NULL, 10);
164 argc -= (optind - 1);
165 argv += (optind - 1);
170 fprintf(stderr,
"Failed creating ring buffer\n");
186 for (i = 0; i < length; i++) {
#define NEVER_RETURNS
Should be placed before the function return type.
static fr_ring_buffer_t * rb
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
uint32_t fr_hash_update(void const *data, size_t size, uint32_t hash)
static TALLOC_CTX * autofree
rlm_rcode_t rcode
Last rcode returned by a module.
Optional arguments for initialising requests.
fr_ring_buffer_t * fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size)
Create a ring buffer.
uint8_t * fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size)
Reserve room in the ring buffer.
int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size_to_free)
Mark data as free,.
size_t fr_ring_buffer_used(fr_ring_buffer_t *rb)
Get the amount of data used in a ring buffer.
uint8_t * fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size)
Mark data as allocated.
int main(int argc, char *argv[])
static uint8_t * data[ARRAY_SIZE]
static void free_blocks(fr_ring_buffer_t *rb, UNUSED uint32_t *seed, int *start, int *end)
request_t * request_alloc(UNUSED TALLOC_CTX *ctx, UNUSED request_init_args_t const *args)
static size_t array[ARRAY_SIZE]
static size_t seed_string_len
static char const * seed_string
static NEVER_RETURNS void usage(void)
static void alloc_blocks(fr_ring_buffer_t *rb, uint32_t *seed, UNUSED int *start, int *end)
void request_verify(UNUSED char const *file, UNUSED int line, UNUSED request_t *request)
static unsigned int hash(char const *username, unsigned int tablesize)
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.