23 RCSID(
"$Id: ad2272f781d674ebb18581b236d1048e7b4fd85d $")
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
41 #define ALLOC_SIZE (8)
42 #define ARRAY_SIZE (4 * ALLOC_SIZE)
43 #define MY_ARRAY_SIZE (16 * ARRAY_SIZE)
180 fprintf(stderr,
"usage: message_set_test [OPTS]\n");
181 fprintf(stderr,
" -s <string> Set random seed to <string>.\n");
182 fprintf(stderr,
" -t Touch 'packet' memory.\n");
183 fprintf(stderr,
" -x Debugging mode.\n");
188 int main(
int argc,
char *argv[])
191 int i, start, end, ret;
200 while ((c = getopt(argc, argv,
"hs:tx")) != -1)
switch (c) {
219 argc -= (optind - 1);
220 argv += (optind - 1);
225 fprintf(stderr,
"Failed creating message set\n");
242 for (i = 0; i < 4; i++) {
264 for (i = 0; i < 1000; i++) {
285 for (i = 0; i < 1000; i++) {
307 for (i = 0; i < 1000; i++) {
329 for (i = 0; i < 10000; i++) {
349 for (i = 0; i < 10000; i++) {
380 for (i = 0; i < 10000; i++) {
388 printf(
"\nELAPSED %d.%06d seconds, %d allocation / free cycles\n\n",
389 (
int) (end_t - start_t) /
NSEC, (
int) ((end_t - start_t) %
NSEC),
#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)
Create a message set.
int fr_message_done(fr_message_t *m)
Mark a message as done.
fr_message_t * fr_message_reserve(fr_message_set_t *ms, size_t reserve_size)
Reserve a message.
int fr_message_set_messages_used(fr_message_set_t *ms)
Count the number of used messages.
void fr_message_set_debug(fr_message_set_t *ms, FILE *fp)
Print debug information about the message set.
void fr_message_set_gc(fr_message_set_t *ms)
Garbage collect the message set.
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.
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]
request_t * request_alloc(UNUSED TALLOC_CTX *ctx, UNUSED request_init_args_t const *args)
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)
void request_verify(UNUSED char const *file, UNUSED int line, UNUSED request_t *request)
static TALLOC_CTX * autofree
Optional arguments for initialising requests.
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.