![]() |
The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
|
Tests for the memory bio. More...
#include <freeradius-devel/util/test/acutest_common_init.h>#include <freeradius-devel/util/test/acutest_helpers.h>#include <freeradius-devel/bio/bio_priv.h>#include <freeradius-devel/bio/mem.h>#include <freeradius-devel/bio/null.h>#include <freeradius-devel/bio/pipe.h>
Include dependency graph for bio_mem_tests.c:Go to the source code of this file.
Data Structures | |
| struct | stub_t |
| A stub transport which fails recoverably or fatally, as each test chooses. More... | |
| struct | test_verify_ctx_t |
| Framing for the tests: the first byte of a packet is its total length. More... | |
Macros | |
| #define | _BIO_PRIVATE 1 |
Functions | |
| static int | cb_noop (fr_bio_t *bio) |
| static void | cb_noop_void (fr_bio_t *bio) |
| static int | cb_shutdown (fr_bio_t *bio) |
| static fr_bio_t * | stub_alloc (TALLOC_CTX *ctx) |
| static ssize_t | stub_read (fr_bio_t *bio, UNUSED void *packet_ctx, void *buffer, size_t size) |
| Return "abcde" once, and fail every read after that. | |
| static ssize_t | stub_write_all (UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, size_t size) |
| Accept every write in full. | |
| static ssize_t | stub_write_fail (fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, UNUSED size_t size) |
| static ssize_t | stub_write_one (UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, UNUSED size_t size) |
| Accept one byte of each write, so the memory bio buffers the rest. | |
| static void | test_buffered_read_drains (void) |
| Without a verify function the bio is a plain buffer, and hands back what it has. | |
| static void | test_fatal_read_drains (void) |
| After a fatal read error in the next bio, the application still gets the buffered data. | |
| static fr_bio_t * | test_mem_alloc (TALLOC_CTX *ctx, fr_bio_t **source_p, test_verify_ctx_t *tctx) |
| A memory bio in front of a pipe, which stands in for the network. | |
| static void | test_recoverable_flush_passes_up (void) |
| The memory bio passes a recoverable flush error up to the application, and keeps the buffered data. | |
| static void | test_recoverable_read_datagram (void) |
| With the datagram verify reader, the memory bio passes a recoverable read error up to the application. | |
| static void | test_recoverable_write_passes_up (void) |
| The memory bio passes a recoverable write error up to the application, and keeps working. | |
| static ssize_t | test_source_write (fr_bio_t *source, char const *data, size_t size) |
| Put bytes where the memory bio's reads will find them. | |
| static fr_bio_verify_action_t | test_verify (UNUSED fr_bio_t *bio, void *verify_ctx, UNUSED void *packet_ctx, const void *buffer, size_t *size) |
| static void | test_verify_buffer_too_small (void) |
| A caller buffer smaller than the packet is an error, and loses nothing. | |
| static void | test_verify_error_close (void) |
| A verify function which says "close" shuts the chain down. | |
| static void | test_verify_one_packet (void) |
| A complete packet is returned, and only one packet at a time. | |
| static void | test_verify_partial_packet (void) |
| A packet split across two reads is reassembled. | |
| static void | test_verify_pipelined (void) |
| Pipelined packets: a buffer holding more than one packet must still return the first. | |
Variables | |
| static int | shutdown_count |
| static fr_bio_cb_funcs_t | stub_cb |
| static fr_bio_cb_funcs_t | test_cb |
| TEST_LIST | |
Tests for the memory bio.
Definition in file bio_mem_tests.c.
| struct stub_t |
A stub transport which fails recoverably or fatally, as each test chooses.
On a recoverable failure, the stub returns an error and changes nothing else. On a fatal failure, the stub first shuts the chain down, as the fd bio does. Only the failing bio decides whether a failure is recoverable or fatal.
Definition at line 288 of file bio_mem_tests.c.
| Data Fields | ||
|---|---|---|
| bool | data_sent | the first read has returned "abcde" |
| bool | fatal | shut the chain down before failing |
| FR_BIO_COMMON | ||
| struct test_verify_ctx_t |
Framing for the tests: the first byte of a packet is its total length.
Definition at line 45 of file bio_mem_tests.c.
| Data Fields | ||
|---|---|---|
| bool | fail | return ERROR_CLOSE for the next packet |
| #define _BIO_PRIVATE 1 |
Definition at line 26 of file bio_mem_tests.c.
|
static |
Definition at line 32 of file bio_mem_tests.c.
|
static |
Definition at line 33 of file bio_mem_tests.c.
|
static |
Definition at line 296 of file bio_mem_tests.c.
|
static |
Definition at line 349 of file bio_mem_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Return "abcde" once, and fail every read after that.
Definition at line 309 of file bio_mem_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Accept every write in full.
Definition at line 344 of file bio_mem_tests.c.
Here is the caller graph for this function:
|
static |
Definition at line 325 of file bio_mem_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Accept one byte of each write, so the memory bio buffers the rest.
Definition at line 337 of file bio_mem_tests.c.
Here is the caller graph for this function:
|
static |
Without a verify function the bio is a plain buffer, and hands back what it has.
mem.md finding 9. A zero from the next bio means no more is coming, and the bytes already buffered still belong to the application.
Definition at line 251 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
After a fatal read error in the next bio, the application still gets the buffered data.
The stub decides that the error is fatal, and calls fr_bio_shutdown(). The memory bio passes the error up, and fr_bio_mem_eof() keeps the buffered data for the application.
Definition at line 436 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
A memory bio in front of a pipe, which stands in for the network.
Writing to the pipe puts bytes where the memory bio's reads will find them.
Definition at line 85 of file bio_mem_tests.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
The memory bio passes a recoverable flush error up to the application, and keeps the buffered data.
Definition at line 397 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
With the datagram verify reader, the memory bio passes a recoverable read error up to the application.
Definition at line 483 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
The memory bio passes a recoverable write error up to the application, and keeps working.
Definition at line 366 of file bio_mem_tests.c.
Here is the call graph for this function:Put bytes where the memory bio's reads will find them.
fr_bio_write() requires the head of a chain, and the source is the tail, so this calls the source's own write routine.
Definition at line 76 of file bio_mem_tests.c.
Here is the caller graph for this function:
|
static |
|
static |
A caller buffer smaller than the packet is an error, and loses nothing.
Definition at line 194 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
A verify function which says "close" shuts the chain down.
Definition at line 222 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
A complete packet is returned, and only one packet at a time.
Definition at line 103 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
A packet split across two reads is reassembled.
Definition at line 131 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
Pipelined packets: a buffer holding more than one packet must still return the first.
mem.md finding 1. The second path used to compare the whole buffer against the caller's size, and return BUFFER_TOO_SMALL although a complete packet was sitting at the front.
Definition at line 162 of file bio_mem_tests.c.
Here is the call graph for this function:
|
static |
Definition at line 294 of file bio_mem_tests.c.
|
static |
Definition at line 298 of file bio_mem_tests.c.
|
static |
Definition at line 35 of file bio_mem_tests.c.
| TEST_LIST |
Definition at line 513 of file bio_mem_tests.c.
1.9.8