Unit tests implementation for the stdio_stream adapter.
More...
#include "stdio_stream/cr/stdio_stream_cr_api.h"#include "stream/borrowers/stream.h"#include "stream/lifecycle/stream_lifecycle.h"#include "osal/stdio/test/osal_stdio_fake_provider.h"#include "osal/mem/osal_mem.h"#include "osal/mem/test/osal_mem_fake_provider.h"#include "internal/stdio_stream_handle.h"#include "internal/stream_handle.h"#include "internal/stdio_stream_ctor_ud.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_stdio_stream_default_cfg (void **state) |
Test stdio_stream_default_cfg(). | |
| static void | test_stdio_stream_default_env (void **state) |
Test stdio_stream_default_env(). | |
| int | main (void) |
This file implements the unit-level validation of the stdio_stream adapter contracts.
Covered surfaces:
stdio_stream_default_cfg(), stdio_stream_default_env()stdio_stream_create_stream()stdio_stream_create_desc()stdio_stream_ctor()Test strategy:
stream port wrappers.fake_stdio is used to observe standard-stream behavior and state transitions.fake_memory is used to inject allocation failures and to verify memory invariants at teardown.See also:
Definition in file unit_test_stdio_stream.c.
static stream_status_t stdio_stream_close( void *backend );
This private callback is exercised through the public stream_destroy() API on streams created by stdio_stream_create_stream().
Invalid arguments:
backend == NULLSuccess:
STREAM_STATUS_OK.stdio_stream backend container through its injected memory operations.Failure:
STREAM_STATUS_INVALID for invalid arguments.Doubles:
Fake behavior:
stdio_stream backend wraps a borrowed standard streamIsolation:
stream port wrapperSee also:
The scenarios below define the test oracle for stdio_stream_close().
Definition at line 2842 of file unit_test_stdio_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 stdio_stream_create_desc().
| Enumerator | |
|---|---|
| STDIO_STREAM_CREATE_DESC_SCENARIO_OK | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_OUT_NULL | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_KEY_NULL | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_KEY_EMPTY | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_CFG_NULL | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_ENV_NULL | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_MEM_NULL | WHEN
|
| STDIO_STREAM_CREATE_DESC_SCENARIO_OOM | WHEN allocation required by
Notes:
|
Definition at line 571 of file unit_test_stdio_stream.c.
stream_status_t stdio_stream_create_stream( stream_t **out, const stdio_stream_args_t *args, const stdio_stream_cfg_t *cfg, const stdio_stream_env_t *env);
Contract:
Doubles:
See also:
The scenarios below define the test oracle for stdio_stream_create_stream().
| Enumerator | |
|---|---|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_OK | WHEN
|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_OUT_NULL | WHEN
|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_ARGS_NULL | WHEN
|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_CFG_NULL | WHEN
|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_ENV_NULL | WHEN
|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_UNSUPPORTED_KIND | WHEN
|
| STDIO_STREAM_CREATE_STREAM_SCENARIO_OOM | WHEN allocation required by
Notes:
|
Definition at line 158 of file unit_test_stdio_stream.c.
stream_status_t stdio_stream_ctor( const void *ud, const void *args, stream_t **out);
Contract:
Doubles:
See also:
The scenarios below define the test oracle for stdio_stream_ctor().
| Enumerator | |
|---|---|
| STDIO_STREAM_CTOR_SCENARIO_OK | WHEN
|
| STDIO_STREAM_CTOR_SCENARIO_OUT_NULL | WHEN
|
| STDIO_STREAM_CTOR_SCENARIO_ARGS_NULL | WHEN
|
| STDIO_STREAM_CTOR_SCENARIO_UD_NULL | WHEN
|
| STDIO_STREAM_CTOR_SCENARIO_UNSUPPORTED_KIND | WHEN
|
| STDIO_STREAM_CTOR_SCENARIO_OOM | WHEN allocation required by
Notes:
|
Definition at line 958 of file unit_test_stdio_stream.c.
static stream_status_t stdio_stream_flush( void *backend );
This private callback is exercised through the public stream_flush() API on streams created by stdio_stream_create_stream().
Invalid arguments:
backend == NULLSuccess:
STREAM_STATUS_OK.Failure:
STREAM_STATUS_INVALID for invalid arguments.STREAM_STATUS_IO_ERROR when the bound standard stream does not support flushing.Doubles:
Fake behavior:
buffered_backing) and a flushed output (sink_backing)Isolation:
stream port wrapperSee also:
The scenarios below define the test oracle for stdio_stream_flush().
Definition at line 2438 of file unit_test_stdio_stream.c.
static size_t stdio_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 stdio_stream_create_stream().
Invalid arguments:
backend == NULLbuf == NULL && n > 0Success:
buf when that stream supports reading.*st to STREAM_STATUS_OK when st != NULL.Failure:
0 and sets *st to STREAM_STATUS_INVALID for invalid arguments when st != NULL.0 and sets *st to STREAM_STATUS_IO_ERROR when the bound standard stream does not support reading.Doubles:
Fake behavior:
buffered_backing)read_posIsolation:
stream port wrapperSee also:
The scenarios below define the test oracle for stdio_stream_read().
Definition at line 1855 of file unit_test_stdio_stream.c.
static size_t stdio_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 stdio_stream_create_stream().
Invalid arguments:
backend == NULLbuf == NULL && n > 0Success:
*st to STREAM_STATUS_OK when st != NULL.Failure:
0 and sets *st to STREAM_STATUS_INVALID for invalid arguments when st != NULL.0 and sets *st to STREAM_STATUS_IO_ERROR when the bound standard stream does not support writing.Doubles:
Fake behavior:
buffered_backing) and a flushed output (sink_backing)Isolation:
stream port wrapperSee also:
The scenarios below define the test oracle for stdio_stream_write().
Definition at line 1343 of file unit_test_stdio_stream.c.
| int main | ( | void | ) |
Definition at line 3081 of file unit_test_stdio_stream.c.
|
static |
stdio_stream_cfg_t stdio_stream_default_cfg(void);
Success:
stdio_stream_cfg_t.ret.reserved == 0.Failure:
See also:
Definition at line 79 of file unit_test_stdio_stream.c.
|
static |
stdio_stream_env_t stdio_stream_default_env( const osal_stdio_ops_t *stdio_ops, const osal_mem_ops_t *mem, const stream_env_t *port_env);
Success:
ret.stdio_ops == stdio_ops.ret.mem == mem.ret.port_env == *port_env.Failure:
Doubles:
osal_stdio_ops_t *osal_mem_ops_t *stream_env_tSee also:
Definition at line 113 of file unit_test_stdio_stream.c.