23#include <freeradius-devel/util/test/acutest_common_init.h>
24#include <freeradius-devel/util/test/acutest_helpers.h>
27#include <freeradius-devel/bio/bio_priv.h>
28#include <freeradius-devel/bio/mem.h>
29#include <freeradius-devel/bio/pipe.h>
67 TEST_CASE(
"a read returns what was written");
70 if (slen == 5)
TEST_CHECK(memcmp(buf,
"hello", 5) == 0);
72 TEST_CASE(
"an empty pipe reads nothing, and says so");
95 TEST_CASE(
"the write is clamped to the room available");
98 TEST_CASE(
"a full pipe accepts nothing more");
122 if (!sink)
goto done;
134 TEST_CASE(
"the buffered data is still delivered");
137 TEST_CASE(
"EOF is signalled once the buffer empties");
161 if (!sink)
goto done;
165 TEST_CASE(
"an empty pipe lets the walk reach the head");
186 if (!sink)
goto done;
192 TEST_CASE(
"a write after EOF is an error, not a zero");
#define TEST_CHECK_RET(_got, _exp)
static ssize_t fr_bio_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
Write raw data to a bio.
static ssize_t fr_bio_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Read raw data from a bio.
fr_bio_io_t read_resume
"unblocked" is too similar to "blocked"
static void test_write_read(void)
static void cb_eof(fr_bio_t *bio)
static fr_bio_cb_funcs_t test_cb
static int cb_read_blocked(fr_bio_t *bio)
static void test_eof_walk_continues(void)
An empty pipe must not stop the EOF walk.
static fr_bio_t * test_pipe_alloc(TALLOC_CTX *ctx, size_t size)
static void test_eof_on_empty_read(void)
EOF is signalled even when the read which notices it returns no data.
static int read_blocked_count
static void test_write_after_eof(void)
A write after EOF reports an error rather than "try again later".
static void test_write_clamped(void)
A write larger than the buffer is clamped rather than refused.
static int cb_noop(fr_bio_t *bio)
static void fr_bio_chain(fr_bio_t *first, fr_bio_t *second)
Chain one bio after another.
fr_bio_t * fr_bio_eof(fr_bio_t *bio)
Internal BIO function to run EOF callbacks.
fr_bio_t * fr_bio_mem_sink_alloc(TALLOC_CTX *ctx, size_t read_size)
Allocate a memory buffer which sinks data from a bio system into the callers application.
fr_bio_t * fr_bio_pipe_alloc(TALLOC_CTX *ctx, fr_bio_cb_funcs_t *cb, size_t buffer_size)
Allocate a thread-safe pipe which can be used for both reads and writes.
static TALLOC_CTX * talloc_init_const(char const *name)
Allocate a top level chunk with a constant name.