Fake stream provider used by stream tests.
More...
#include "stream/borrowers/stream_types.h"#include "osal/mem/osal_mem_ops.h"#include "policy/lexleo_cstd_types.h"

Go to the source code of this file.
Data Structures | |
| struct | stream_fake_counters_t |
| Call counters recorded by the fake stream. More... | |
Typedefs | |
| typedef struct stream_fake_t | stream_fake_t |
| Opaque fake stream state. | |
| typedef struct stream_fake_counters_t | stream_fake_counters_t |
| Call counters recorded by the fake stream. | |
Functions | |
| stream_status_t | stream_fake_create (stream_fake_t **out_fake, stream_t **out_stream, const osal_mem_ops_t *mem) |
Create a fake stream backend and its associated public stream_t. | |
| void | stream_fake_destroy (stream_fake_t **fake, stream_t **stream) |
| Destroy a fake stream backend and its associated public stream. | |
| void | stream_fake_reset (stream_fake_t *fake) |
| Reset the fake stream runtime state and counters. | |
| void | stream_fake_set_write_result (stream_fake_t *fake, size_t n, stream_status_t status) |
| Configure the result returned by the next write operations. | |
| void | stream_fake_set_flush_result (stream_fake_t *fake, stream_status_t status) |
| Configure the result returned by flush operations. | |
| void | stream_fake_fail_write_since (stream_fake_t *fake, size_t call_idx, stream_status_t status) |
| Make fake writes fail starting from a given call index. | |
| const stream_fake_counters_t * | stream_fake_counters (const stream_fake_t *fake) |
| Return the current call counters recorded by the fake stream. | |
| size_t | stream_fake_written_len (const stream_fake_t *fake) |
| Return the number of bytes captured by the fake stream. | |
| const uint8_t * | stream_fake_written_data (const stream_fake_t *fake) |
| Return the captured bytes written through the fake stream. | |
This header exposes a lightweight fake backend used to exercise the public stream port in tests.
It provides:
stream_t,Definition in file stream_fake_provider.h.
| typedef struct stream_fake_counters_t stream_fake_counters_t |
| typedef struct stream_fake_t stream_fake_t |
Definition at line 37 of file stream_fake_provider.h.
| const stream_fake_counters_t * stream_fake_counters | ( | const stream_fake_t * | fake | ) |
| [in] | fake | Fake stream to inspect. |
Definition at line 140 of file stream_fake_provider.c.
| stream_status_t stream_fake_create | ( | stream_fake_t ** | out_fake, |
| stream_t ** | out_stream, | ||
| const osal_mem_ops_t * | mem | ||
| ) |
| [out] | out_fake | Receives the created fake backend. |
| [out] | out_stream | Receives the created public stream handle backed by the fake. |
| [in] | mem | Borrowed memory operations used for allocation. |
| STREAM_STATUS_OK | Fake backend and public stream successfully created. |
| STREAM_STATUS_INVALID | One or more arguments are invalid. |
| STREAM_STATUS_OOM | Allocation failed. |
Definition at line 35 of file stream_fake_provider.c.
| void stream_fake_destroy | ( | stream_fake_t ** | fake, |
| stream_t ** | stream | ||
| ) |
| [in,out] | fake | Fake backend handle to destroy. |
| [in,out] | stream | Public stream handle to destroy. |
Definition at line 78 of file stream_fake_provider.c.
| void stream_fake_fail_write_since | ( | stream_fake_t * | fake, |
| size_t | call_idx, | ||
| stream_status_t | status | ||
| ) |
| [in,out] | fake | Fake stream to configure. |
| [in] | call_idx | First write-call index that must fail. |
| [in] | status | Stream status reported for failing writes. |
Definition at line 128 of file stream_fake_provider.c.
| void stream_fake_reset | ( | stream_fake_t * | fake | ) |
| [in,out] | fake | Fake stream to reset. |
Definition at line 96 of file stream_fake_provider.c.
| void stream_fake_set_flush_result | ( | stream_fake_t * | fake, |
| stream_status_t | status | ||
| ) |
| [in,out] | fake | Fake stream to configure. |
| [in] | status | Stream status reported by the fake flush. |
Definition at line 117 of file stream_fake_provider.c.
| void stream_fake_set_write_result | ( | stream_fake_t * | fake, |
| size_t | n, | ||
| stream_status_t | status | ||
| ) |
| [in,out] | fake | Fake stream to configure. |
| [in] | n | Number of bytes the fake write should report as written. |
| [in] | status | Stream status reported by the fake write. |
Definition at line 105 of file stream_fake_provider.c.
| const uint8_t * stream_fake_written_data | ( | const stream_fake_t * | fake | ) |
| [in] | fake | Fake stream to inspect. |
Definition at line 158 of file stream_fake_provider.c.
| size_t stream_fake_written_len | ( | const stream_fake_t * | fake | ) |
| [in] | fake | Fake stream to inspect. |
Definition at line 149 of file stream_fake_provider.c.