Unit tests implementation for the dynamic_buffer_stream adapter.
More...
#include "dynamic_buffer_stream/cr/dynamic_buffer_stream_cr_api.h"#include "stream/borrowers/stream.h"#include "stream/lifecycle/stream_lifecycle.h"#include "osal/mem/osal_mem.h"#include "osal/mem/test/osal_mem_fake_provider.h"#include "internal/dynamic_buffer_stream_handle.h"#include "internal/stream_handle.h"#include "policy/lexleo_cstd_types.h"#include "policy/lexleo_cstd_lib.h"#include "policy/lexleo_cstd_jmp.h"#include "lexleo_cmocka.h"
Go to the source code of this file.
Functions | |
| static void | test_dynamic_buffer_stream_default_cfg (void **state) |
Test dynamic_buffer_stream_default_cfg(). | |
| static void | test_dynamic_buffer_stream_default_env (void **state) |
Test dynamic_buffer_stream_default_env(). | |
| static void | test_dynamic_buffer_stream_flush (void **state) |
Test dynamic_buffer_stream_flush(). | |
| static void | test_dynamic_buffer_stream_close (void **state) |
Test dynamic_buffer_stream_close(). | |
This file implements unit-level validation of the dynamic_buffer_stream adapter contracts.
Covered surfaces:
stream_adapter_desc_t::ctorstream API and lifecycle entry points:
Test strategy:
fake_memorystream API checks on successfully created streamsSee also:
Definition in file unit_test_dynamic_buffer_stream.c.
Invalid arguments:
out, key, cfg, env, mem must not be NULL.key must not be an empty string.Success:
STREAM_STATUS_OK.*out.out->ud_dtor().Failure:
STREAM_STATUS_INVALID for invalid argumentsSTREAM_STATUS_OOM on allocation failureout is not NULL, resets *out to an empty descriptor.Doubles:
See also:
The scenarios below define the test oracle for dynamic_buffer_stream_create_desc().
| Enumerator | |
|---|---|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_OK | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_OUT_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_KEY_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_KEY_EMPTY | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_CFG_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_ENV_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_MEM_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_DESC_SCENARIO_OOM | WHEN allocation required by
Notes:
|
Definition at line 495 of file unit_test_dynamic_buffer_stream.c.
stream_status_t dynamic_buffer_stream_create_stream( stream_t **out, const dynamic_buffer_stream_cfg_t *cfg, const dynamic_buffer_stream_env_t *env);
Doubles:
Isolation:
stream port wrapper is not doubledSee also:
The scenarios below define the test oracle for dynamic_buffer_stream_create_stream().
| Enumerator | |
|---|---|
| DYNAMIC_BUFFER_STREAM_CREATE_STREAM_SCENARIO_OK | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_STREAM_SCENARIO_OUT_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_STREAM_SCENARIO_CFG_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_STREAM_SCENARIO_ENV_NULL | WHEN
|
| DYNAMIC_BUFFER_STREAM_CREATE_STREAM_SCENARIO_OOM | WHEN allocation required by
Notes:
|
Definition at line 149 of file unit_test_dynamic_buffer_stream.c.
static size_t dynamic_buffer_stream_read( void *backend, void *buf, size_t n, stream_status_t *st );
This private callback is exercised through the public stream_read() API on streams created by dynamic_buffer_stream_create_stream().
Invalid arguments:
buf == NULL && n > 0Success:
buf.read_pos by the number of bytes returned.len unchanged.*st to STREAM_STATUS_OK when st != NULL.Failure:
STREAM_STATUS_INVALID for invalid argumentsSTREAM_STATUS_EOF when no unread byte remainsDoubles:
Isolation:
stream port wrapperSee also:
The scenarios below define the test oracle for dynamic_buffer_stream_read().
Definition at line 1417 of file unit_test_dynamic_buffer_stream.c.
static size_t dynamic_buffer_stream_write( void *backend, const void *buf, size_t n, stream_status_t *st );
This private callback is exercised through the public stream_write() API on streams created by dynamic_buffer_stream_create_stream().
Invalid arguments:
backend == NULLbuf == NULL && n > 0Success:
read_pos unchanged.*st to STREAM_STATUS_OK when st != NULL.Failure:
STREAM_STATUS_INVALID for invalid argumentsSTREAM_STATUS_OOM on growth / reserve failureDoubles:
Isolation:
stream port wrapperSee also:
The scenarios below define the test oracle for dynamic_buffer_stream_write().
| Enumerator | |
|---|---|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_OK_NO_GROW | WHEN
|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_ZERO_LEN | WHEN
|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_BUF_NULL_ZERO_LEN | WHEN
|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_OK_GROW | WHEN
|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_BUF_NULL_NONZERO | WHEN
|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_RESERVE_OOM | WHEN
Notes:
|
| DYNAMIC_BUFFER_STREAM_WRITE_SCENARIO_SIZE_OVERFLOW | WHEN
Notes:
|
Definition at line 899 of file unit_test_dynamic_buffer_stream.c.
|
static |
static void dynamic_buffer_stream_close(void *backend);
Success:
stream_destroy()NULLFailure:
Doubles:
See also:
Definition at line 1946 of file unit_test_dynamic_buffer_stream.c.
|
static |
dynamic_buffer_stream_cfg_t dynamic_buffer_stream_default_cfg(void);
Success:
dynamic_buffer_stream_cfg_t.ret.default_cap > 0.Failure:
See also:
Definition at line 80 of file unit_test_dynamic_buffer_stream.c.
|
static |
dynamic_buffer_stream_env_t dynamic_buffer_stream_default_env( const osal_mem_ops_t *mem, const stream_env_t *port_env );
Success:
ret.mem == mem.ret.port_env == *port_env.Failure:
Doubles:
osal_mem_ops_t *stream_env_tSee also:
Definition at line 111 of file unit_test_dynamic_buffer_stream.c.
|
static |
static stream_status_t dynamic_buffer_stream_flush(void *backend);
Success:
STREAM_STATUS_OKFailure:
Doubles:
See also:
Definition at line 1868 of file unit_test_dynamic_buffer_stream.c.