The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
atomic_ring_test.c File Reference
#include <freeradius-devel/io/atomic_queue.h>
#include <freeradius-devel/util/debug.h>
#include <inttypes.h>
#include <pthread.h>
#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for atomic_ring_test.c:

Go to the source code of this file.

Data Structures

struct  stress_arg_t
 

Macros

#define CHECK(cond, fmt, ...)
 
#define FAIL(fmt, ...)
 
#define OK()   do { printf("ok\n"); } while (0)
 
#define STRESS_N   200000
 
#define TEST(_name)   do { printf(" %-48s ", _name); fflush(stdout); } while (0)
 

Typedefs

typedef struct request_s request_t
 

Functions

int main (int argc, UNUSED char *argv[])
 
void request_verify (UNUSED char const *file, UNUSED int line, UNUSED request_t *request)
 
static void * stress_consumer (void *arg)
 
static void * stress_producer (void *arg)
 
static void test_alloc_free (TALLOC_CTX *ctx)
 
static void test_free_nonempty (TALLOC_CTX *ctx)
 
static void test_grow_across_segments (TALLOC_CTX *ctx)
 
static void test_interleaved (TALLOC_CTX *ctx)
 
static void test_push_pop_single_segment (TALLOC_CTX *ctx)
 
static void test_stress_two_thread (TALLOC_CTX *ctx)
 

Data Structure Documentation

◆ stress_arg_t

struct stress_arg_t

Definition at line 185 of file atomic_ring_test.c.

+ Collaboration diagram for stress_arg_t:
Data Fields
size_t n
fr_atomic_ring_t * ring

Macro Definition Documentation

◆ CHECK

#define CHECK (   cond,
  fmt,
  ... 
)
Value:
do { \
if (!(cond)) FAIL(fmt, ##__VA_ARGS__); \
} while (0)
static int const char * fmt
Definition acutest.h:573
#define FAIL(fmt,...)

Definition at line 47 of file atomic_ring_test.c.

◆ FAIL

#define FAIL (   fmt,
  ... 
)
Value:
do { \
printf("FAIL\n " fmt "\n", ##__VA_ARGS__); \
fr_exit_now(EXIT_FAILURE); \
} while (0)

Definition at line 42 of file atomic_ring_test.c.

◆ OK

#define OK ( )    do { printf("ok\n"); } while (0)

Definition at line 41 of file atomic_ring_test.c.

◆ STRESS_N

#define STRESS_N   200000

Definition at line 183 of file atomic_ring_test.c.

◆ TEST

#define TEST (   _name)    do { printf(" %-48s ", _name); fflush(stdout); } while (0)

Definition at line 40 of file atomic_ring_test.c.

Typedef Documentation

◆ request_t

typedef struct request_s request_t

Definition at line 35 of file atomic_ring_test.c.

Function Documentation

◆ main()

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

Definition at line 273 of file atomic_ring_test.c.

+ Here is the call graph for this function:

◆ request_verify()

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

Definition at line 37 of file atomic_ring_test.c.

◆ stress_consumer()

static void * stress_consumer ( void *  arg)
static

Definition at line 207 of file atomic_ring_test.c.

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

◆ stress_producer()

static void * stress_producer ( void *  arg)
static

Definition at line 190 of file atomic_ring_test.c.

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

◆ test_alloc_free()

static void test_alloc_free ( TALLOC_CTX *  ctx)
static
  1. alloc/free round-trip with nothing ever pushed

Definition at line 52 of file atomic_ring_test.c.

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

◆ test_free_nonempty()

static void test_free_nonempty ( TALLOC_CTX *  ctx)
static
  1. free the ring with items still queued; must not leak/crash

Definition at line 160 of file atomic_ring_test.c.

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

◆ test_grow_across_segments()

static void test_grow_across_segments ( TALLOC_CTX *  ctx)
static
  1. push past segment capacity triggers new-segment allocation

Definition at line 91 of file atomic_ring_test.c.

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

◆ test_interleaved()

static void test_interleaved ( TALLOC_CTX *  ctx)
static
  1. interleaved push/pop keeps FIFO and frees drained segments

Definition at line 118 of file atomic_ring_test.c.

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

◆ test_push_pop_single_segment()

static void test_push_pop_single_segment ( TALLOC_CTX *  ctx)
static
  1. push/pop within a single segment preserves FIFO

Definition at line 67 of file atomic_ring_test.c.

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

◆ test_stress_two_thread()

static void test_stress_two_thread ( TALLOC_CTX *  ctx)
static

Definition at line 232 of file atomic_ring_test.c.

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