LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
integration_test_stream_factory_fs_stream.c File Reference

Integration tests implementation for stream_factory_create_stream() with the fs_stream adapter. More...

Include dependency graph for integration_test_stream_factory_fs_stream.c:

Go to the source code of this file.

Enumerations

enum  stream_fact_create_fs_scenario_t {
  STREAM_FACT_CREATE_FS_SCENARIO_OK = 0 , STREAM_FACT_CREATE_FS_SCENARIO_ARGS_NULL , STREAM_FACT_CREATE_FS_SCENARIO_OUT_NULL , STREAM_FACT_CREATE_FS_SCENARIO_PATH_NULL ,
  STREAM_FACT_CREATE_FS_SCENARIO_PATH_EMPTY , STREAM_FACT_CREATE_FS_SCENARIO_FLAGS_ZERO , STREAM_FACT_CREATE_FS_SCENARIO_OPEN_FAIL , STREAM_FACT_CREATE_FS_SCENARIO_FACTORY_NULL ,
  STREAM_FACT_CREATE_FS_SCENARIO_KEY_NULL , STREAM_FACT_CREATE_FS_SCENARIO_KEY_EMPTY , STREAM_FACT_CREATE_FS_SCENARIO_KEY_UNKNOWN
}
 Scenarios for stream_factory_create_stream() / fs_stream integration. More...
 

Detailed Description

This file implements integration-level validation of the interaction between the stream factory and the fs_stream adapter registered through the Composition Root API.

Covered surfaces:

  • factory-based stream creation: stream_factory_create_stream()
  • integration of factory lookup with fs_stream descriptor registration
  • propagation of backend file-open failures through the created stream path

Test strategy:

  • parametric scenario-based testing
  • explicit validation of argument checking and output-handle preservation
  • integration-focused exercising of the public factory API with a real adapter descriptor produced by fs_stream_create_desc()
  • backend fault injection through fake_file
  • validation that successfully created streams are usable through the public borrower API

Local test doubles:

  • fake_file

See also:

Definition in file integration_test_stream_factory_fs_stream.c.

Enumeration Type Documentation

◆ stream_fact_create_fs_scenario_t

stream_status_t stream_factory_create_stream( const stream_factory_t *f, stream_key_t key, const void *args, stream_t **out );

Precondition:

  • Unless stated otherwise by the scenario, f designates a valid factory instance previously created by stream_create_factory().
  • Unless stated otherwise by the scenario, the factory contains a valid fs_stream adapter descriptor registered under the key "fs".
  • Unless stated otherwise by the scenario, args designates a valid fs_stream_args_t object prepared by the fixture.

Invalid arguments:

  • f, key, args, and out must not be NULL.
  • key must not be NULL and must not be an empty string.
  • args->path must not be NULL and must not be an empty string.
  • args->flags must not be zero.

Success:

  • Returns STREAM_STATUS_OK.
  • Stores a valid stream in *out.
  • The produced stream is ready for normal runtime use.
  • The produced stream must be destroyed via stream_destroy().

Failure:

  • Returns:
    • STREAM_STATUS_INVALID for invalid arguments
    • STREAM_STATUS_NOT_FOUND if key is not registered
    • STREAM_STATUS_IO_ERROR when OSAL file operations fail
  • Leaves *out unchanged if out is not NULL.

Doubles:

  • fake_file

See also:

The scenarios below define the test oracle for stream_factory_create_stream() with the fs_stream adapter.

Enumerator
STREAM_FACT_CREATE_FS_SCENARIO_OK 

WHEN stream_factory_create_stream(f, key, args, out) is called with a valid factory, a registered fs_stream key, valid fs_stream arguments, and backend file open succeeds EXPECT:

  • returns STREAM_STATUS_OK
  • stores a non-NULL stream handle in *out
  • the produced stream is ready for normal runtime use
STREAM_FACT_CREATE_FS_SCENARIO_ARGS_NULL 

WHEN args == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_OUT_NULL 

WHEN out == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • no stream handle is produced
STREAM_FACT_CREATE_FS_SCENARIO_PATH_NULL 

WHEN args != NULL but args->path == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_PATH_EMPTY 

WHEN args != NULL but args->path is an empty string EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_FLAGS_ZERO 

WHEN args != NULL but args->flags == 0 EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_OPEN_FAIL 

WHEN stream_factory_create_stream(f, key, args, out) is called with a valid factory, a registered fs_stream key, valid fs_stream arguments, and backend file open fails EXPECT:

  • returns STREAM_STATUS_IO_ERROR
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_FACTORY_NULL 

WHEN f == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_KEY_NULL 

WHEN key == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_KEY_EMPTY 

WHEN key is an empty string EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_CREATE_FS_SCENARIO_KEY_UNKNOWN 

WHEN f designates a valid factory instance but key is not registered in that factory EXPECT:

  • returns STREAM_STATUS_NOT_FOUND
  • leaves *out unchanged

Definition at line 100 of file integration_test_stream_factory_fs_stream.c.