23 RCSID(
"$Id: d76389cb2cb1dc1555b0d31a5b08f441b769c8ab $")
25 #include <freeradius-devel/io/ring_buffer.h>
26 #include <freeradius-devel/util/debug.h>
27 #include <freeradius-devel/util/hash.h>
28 #include <freeradius-devel/util/syserror.h>
29 #include <freeradius-devel/util/talloc.h>
36 #define ALLOC_SIZE (8)
37 #define ARRAY_SIZE (4 * ALLOC_SIZE)
127 fprintf(stderr,
"usage: ring_buffer_test [OPTS]\n");
128 fprintf(stderr,
" -x Debugging mode.\n");
129 fprintf(stderr,
" -s <string> Set random seed to <string>.\n");
130 fprintf(stderr,
" -l <length> Set the iteration number to <length>.\n");
135 int main(
int argc,
char *argv[])
139 int i, start, end, length = 1000;
145 while ((c = getopt(argc, argv,
"hl:s:x")) != -1)
switch (c) {
147 length = strtol(optarg, NULL, 10);
163 argc -= (optind - 1);
164 argv += (optind - 1);
169 fprintf(stderr,
"Failed creating ring buffer\n");
185 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.