23RCSID(
"$Id: b1413f1d4c717dec20fe854e8ce9089785184800 $")
25#include <freeradius-devel/io/message.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>
38#define MPRINT1 if (debug_lvl) printf
39#define MPRINT2 if (debug_lvl > 1) printf
42#define ARRAY_SIZE (4 * ALLOC_SIZE)
43#define MY_ARRAY_SIZE (16 * ARRAY_SIZE)
160 fprintf(stderr,
"usage: message_set_test [OPTS]\n");
161 fprintf(stderr,
" -s <string> Set random seed to <string>.\n");
162 fprintf(stderr,
" -t Touch 'packet' memory.\n");
163 fprintf(stderr,
" -x Debugging mode.\n");
168int main(
int argc,
char *argv[])
171 int i, start, end, ret;
180 while ((c = getopt(argc, argv,
"hs:tx")) != -1)
switch (c) {
199 argc -= (optind - 1);
200 argv += (optind - 1);
205 fprintf(stderr,
"Failed creating message set\n");
222 for (i = 0; i < 4; i++) {
244 for (i = 0; i < 1000; i++) {
265 for (i = 0; i < 1000; i++) {
287 for (i = 0; i < 1000; i++) {
309 for (i = 0; i < 10000; i++) {
329 for (i = 0; i < 10000; i++) {
360 for (i = 0; i < 10000; i++) {
368 printf(
"\nELAPSED %"PRIu64
".%06d seconds, %d allocation / free cycles\n\n",
393 fprintf(stderr,
"Failed creating message set\n");
static TALLOC_CTX * autofree
#define NEVER_RETURNS
Should be placed before the function return type.
#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)
fr_message_set_t * fr_message_set_create(TALLOC_CTX *ctx, int num_messages, size_t message_size, size_t ring_buffer_size, bool unlimited_size)
Create a message set.
int fr_message_done(fr_message_t *m)
Mark a message as done.
fr_message_t * fr_message_alloc(fr_message_set_t *ms, fr_message_t *m, size_t actual_packet_size)
Allocate packet data for a message.
int fr_message_set_messages_used(fr_message_set_t *ms)
Count the number of used messages.
void fr_message_set_gc(fr_message_set_t *ms)
Garbage collect the message set.
void fr_message_set_debug(FILE *fp, fr_message_set_t *ms)
Print debug information about the message set.
fr_message_t * fr_message_reserve(fr_message_set_t *ms, size_t reserve_size)
Reserve a message.
A Message set, composed of message headers and ring buffer data.
uint8_t * data
pointer to the data in the ring buffer
size_t data_size
size of the data in the ring buffer
fr_message_status_t status
free, used, done, etc.
static fr_test_t * messages[MY_ARRAY_SIZE]
int main(int argc, char *argv[])
static size_t reserve_size
static size_t allocation_mask
static size_t array[MY_ARRAY_SIZE]
static size_t seed_string_len
static char const * seed_string
static void free_blocks(UNUSED fr_message_set_t *ms, UNUSED uint32_t *seed, int *start, int *end)
static NEVER_RETURNS void usage(void)
static void alloc_blocks(fr_message_set_t *ms, uint32_t *seed, UNUSED int *start, int *end)
static unsigned int hash(char const *username, unsigned int tablesize)
#define fr_time()
Allow us to arbitrarily manipulate time.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
static int64_t fr_time_delta_to_sec(fr_time_delta_t delta)
static int64_t fr_time_delta_to_usec(fr_time_delta_t delta)
#define fr_time_sub(_a, _b)
Subtract one time from another.