The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions | Variables
atomic_queue_test.c File Reference
#include <freeradius-devel/io/atomic_queue.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/table.h>
#include <string.h>
#include <sys/time.h>
+ Include dependency graph for atomic_queue_test.c:

Go to the source code of this file.

Macros

#define OFFSET   (1024)
 

Typedefs

typedef void(* queue_test_t) (TALLOC_CTX *ctx, int size)
 
typedef struct request_s request_t
 

Enumerations

enum  queue_type_t {
  QUEUE_TYPE_TALLOC = 0 ,
  QUEUE_TYPE_MALLOC ,
  QUEUE_TYPE_MAX
}
 Which allocator the queue under test comes from. More...
 

Functions

int main (int argc, char *argv[])
 
static void queue_exercise (fr_atomic_queue_t *aq, int size)
 Fill the queue to capacity, check it refuses one more, then drain it.
 
void request_verify (UNUSED char const *file, UNUSED int line, UNUSED request_t *request)
 
static void test_malloc (TALLOC_CTX *ctx, int size)
 Queue allocated outside talloc, but owned by a talloc context.
 
static void test_talloc (TALLOC_CTX *ctx, int size)
 Queue allocated inside the talloc hierarchy.
 
static NEVER_RETURNS void usage (void)
 

Variables

static int debug_lvl = 0
 
static queue_test_t const queue_tests [QUEUE_TYPE_MAX]
 
static fr_table_num_sorted_t const queue_type_table []
 
static size_t queue_type_table_len = NUM_ELEMENTS(queue_type_table)
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET   (1024)

Definition at line 35 of file atomic_queue_test.c.

Typedef Documentation

◆ queue_test_t

typedef void(* queue_test_t) (TALLOC_CTX *ctx, int size)

Definition at line 216 of file atomic_queue_test.c.

◆ request_t

typedef struct request_s request_t

Definition at line 55 of file atomic_queue_test.c.

Enumeration Type Documentation

◆ queue_type_t

Which allocator the queue under test comes from.

Enumerator
QUEUE_TYPE_TALLOC 

fr_atomic_queue_talloc, queue lives in the talloc hierarchy.

QUEUE_TYPE_MALLOC 

fr_atomic_queue_malloc, raw queue owned by a talloc handle.

QUEUE_TYPE_MAX 

Definition at line 41 of file atomic_queue_test.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 223 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ queue_exercise()

static void queue_exercise ( fr_atomic_queue_t *  aq,
int  size 
)
static

Fill the queue to capacity, check it refuses one more, then drain it.

Exits the process on the first wrong answer.

Definition at line 78 of file atomic_queue_test.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ request_verify()

void request_verify ( UNUSED char const *  file,
UNUSED int  line,
UNUSED request_t *  request 
)

Definition at line 58 of file atomic_queue_test.c.

+ Here is the caller graph for this function:

◆ test_malloc()

static void test_malloc ( TALLOC_CTX *  ctx,
int  size 
)
static

Queue allocated outside talloc, but owned by a talloc context.

The only talloc'd block is the owner handle, so the context holds exactly one child, and freeing the context releases the raw queue through the handle.

Definition at line 194 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ test_talloc()

static void test_talloc ( TALLOC_CTX *  ctx,
int  size 
)
static

Queue allocated inside the talloc hierarchy.

Definition at line 174 of file atomic_queue_test.c.

+ Here is the call graph for this function:

◆ usage()

static NEVER_RETURNS void usage ( void  )
static

Definition at line 64 of file atomic_queue_test.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ debug_lvl

int debug_lvl = 0
static

Definition at line 37 of file atomic_queue_test.c.

◆ queue_tests

queue_test_t const queue_tests[QUEUE_TYPE_MAX]
static
Initial value:
= {
}
static void test_malloc(TALLOC_CTX *ctx, int size)
Queue allocated outside talloc, but owned by a talloc context.
@ QUEUE_TYPE_MALLOC
fr_atomic_queue_malloc, raw queue owned by a talloc handle.
@ QUEUE_TYPE_TALLOC
fr_atomic_queue_talloc, queue lives in the talloc hierarchy.
static void test_talloc(TALLOC_CTX *ctx, int size)
Queue allocated inside the talloc hierarchy.

Definition at line 218 of file atomic_queue_test.c.

◆ queue_type_table

fr_table_num_sorted_t const queue_type_table[]
static
Initial value:
= {
{ L("malloc"), QUEUE_TYPE_MALLOC },
{ L("talloc"), QUEUE_TYPE_TALLOC }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:228

Definition at line 47 of file atomic_queue_test.c.

◆ queue_type_table_len

size_t queue_type_table_len = NUM_ELEMENTS(queue_type_table)
static

Definition at line 51 of file atomic_queue_test.c.