26#include <freeradius-devel/util/fifo.h>
28#define FIFO_TEST_SIZE 128
74 TEST_MSG(
"push %d failed, returned %d", i, ret);
85 TEST_MSG(
"expected %d, got %d", i, *p);
90 TEST_CASE(
"Pop from empty fifo returns NULL");
106 TEST_CASE(
"Peek on empty fifo returns NULL");
110 TEST_CASE(
"Peek returns head without removing it");
163 TEST_CASE(
"Fill, drain, and refill to test circular buffer wraparound");
164 for (
int cycle = 0; cycle < 3; cycle++) {
168 values[i] = base + i;
171 TEST_MSG(
"cycle %d, push %d failed", cycle, i);
181 TEST_MSG(
"cycle %d, expected %d, got %d", cycle, base + i, *p);
200 TEST_CASE(
"Push half, pop half, push half again");
220 TEST_CASE(
"Verify remaining elements are in correct order");
226 TEST_MSG(
"expected %d, got %d", i, *p);
252 TEST_CASE(
"Free callback is called for remaining elements on destroy");
253 for (i = 0; i < 8; i++) {
266 TEST_CASE(
"NULL fifo operations don't crash");
#define TEST_ASSERT(cond)
void * fr_fifo_peek(fr_fifo_t *fi)
Examine the next element that would be popped.
unsigned int fr_fifo_num_elements(fr_fifo_t *fi)
Return the number of elements in the fifo queue.
int fr_fifo_push(fr_fifo_t *fi, void *data)
Push data onto the fifo.
void * fr_fifo_pop(fr_fifo_t *fi)
Pop data off of the fifo.
#define fr_fifo_create(_ctx, _max_entries, _node_free)
Creates a fifo.
static void test_fifo_full(void)
static void test_free_callback(void *data)
static void test_fifo_create_invalid(void)
static void test_fifo_peek(void)
static unsigned int free_count
static void test_fifo_free_callback(void)
static void test_fifo_partial_drain(void)
static void test_fifo_null_args(void)
static void test_fifo_push_pop(void)
static void test_fifo_create(void)
static void test_fifo_wraparound(void)