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

Integration tests implementation for the stream factory. More...

#include "stream/cr/stream_factory_cr_api.h"
#include "osal/mem/osal_mem.h"
#include "policy/lexleo_cstd_types.h"
#include "policy/lexleo_cstd_lib.h"
#include "policy/lexleo_cstd_jmp.h"
#include "lexleo_cmocka.h"
Include dependency graph for integration_test_stream_factory.c:

Go to the source code of this file.

Enumerations

enum  stream_fact_lifecycle_scenario_t {
  STREAM_FACT_LIFECYCLE_SCENARIO_OK = 0 , STREAM_FACT_LIFECYCLE_SCENARIO_OUT_NULL , STREAM_FACT_LIFECYCLE_SCENARIO_CFG_NULL , STREAM_FACT_LIFECYCLE_SCENARIO_ENV_NULL ,
  STREAM_FACT_LIFECYCLE_SCENARIO_ENV_MEM_NULL , STREAM_FACT_LIFECYCLE_SCENARIO_ENV_MEM_CALLOC_NULL , STREAM_FACT_LIFECYCLE_SCENARIO_ENV_MEM_FREE_NULL , STREAM_FACT_LIFECYCLE_SCENARIO_DESTROY_IDEMPOTENT
}
 Scenarios for stream_create_factory() / stream_destroy_factory(). More...
 
enum  stream_fact_add_adapter_scenario_t {
  STREAM_FACT_ADD_ADAPTER_SCENARIO_OK = 0 , STREAM_FACT_ADD_ADAPTER_SCENARIO_FACT_NULL , STREAM_FACT_ADD_ADAPTER_SCENARIO_DESC_NULL , STREAM_FACT_ADD_ADAPTER_SCENARIO_KEY_NULL ,
  STREAM_FACT_ADD_ADAPTER_SCENARIO_KEY_EMPTY , STREAM_FACT_ADD_ADAPTER_SCENARIO_CTOR_NULL , STREAM_FACT_ADD_ADAPTER_SCENARIO_DUPLICATE_KEY , STREAM_FACT_ADD_ADAPTER_SCENARIO_CAP_REACHED
}
 Scenarios for stream_factory_add_adapter(). More...
 

Detailed Description

This file implements integration-level validation of the stream factory lifecycle and adapter-registration contracts.

Covered surfaces:

Test strategy:

  • parametric scenario-based testing
  • explicit validation of argument checking and lifecycle behavior
  • explicit validation of adapter registration outcomes
  • indirect observation through stream_factory_create_stream() when registration effects must be verified

Local test doubles:

  • test_stream_ctor_1()
  • test_stream_ctor_2()
  • make_test_desc()

See also:

Definition in file integration_test_stream_factory.c.

Enumeration Type Documentation

◆ stream_fact_add_adapter_scenario_t

stream_status_t stream_factory_add_adapter( stream_factory_t *fact, const stream_adapter_desc_t *desc );

Precondition:

Invalid arguments:

  • fact and desc must not be NULL.
  • desc->key and desc->ctor must not be NULL.
  • desc->key must not be empty.

Success:

Failure:

  • Returns:
    • STREAM_STATUS_INVALID for invalid arguments
    • STREAM_STATUS_ALREADY_EXISTS if the key is already registered
    • STREAM_STATUS_FULL if the factory capacity is exhausted

Doubles:

  • none

See also:

The scenarios below define the test oracle for stream_factory_add_adapter().

Enumerator
STREAM_FACT_ADD_ADAPTER_SCENARIO_OK 

WHEN stream_factory_add_adapter(fact, desc) is called with a valid factory, a valid descriptor whose key is not yet registered, and a factory that has not reached its registration capacity EXPECT:

  • returns STREAM_STATUS_OK
  • a later call to stream_factory_create_stream() with that key returns STREAM_STATUS_OK
  • the produced stream corresponds to the registered descriptor
STREAM_FACT_ADD_ADAPTER_SCENARIO_FACT_NULL 

WHEN fact == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
STREAM_FACT_ADD_ADAPTER_SCENARIO_DESC_NULL 

WHEN desc == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
STREAM_FACT_ADD_ADAPTER_SCENARIO_KEY_NULL 

WHEN desc != NULL but desc->key == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
STREAM_FACT_ADD_ADAPTER_SCENARIO_KEY_EMPTY 

WHEN desc != NULL but desc->key is an empty string EXPECT:

  • returns STREAM_STATUS_INVALID
STREAM_FACT_ADD_ADAPTER_SCENARIO_CTOR_NULL 

WHEN desc != NULL but desc->ctor == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
STREAM_FACT_ADD_ADAPTER_SCENARIO_DUPLICATE_KEY 

WHEN a descriptor is added with a key that is already registered EXPECT:

  • returns STREAM_STATUS_ALREADY_EXISTS
  • a later call to stream_factory_create_stream() with that key returns STREAM_STATUS_OK
  • the produced stream corresponds to the previously registered descriptor
STREAM_FACT_ADD_ADAPTER_SCENARIO_CAP_REACHED 

WHEN the factory has reached its registration capacity and a new descriptor is added EXPECT:

  • returns STREAM_STATUS_FULL
  • a later call to stream_factory_create_stream() with the new key returns STREAM_STATUS_NOT_FOUND
  • no stream handle is produced

Definition at line 560 of file integration_test_stream_factory.c.

◆ stream_fact_lifecycle_scenario_t

stream_status_t stream_create_factory( stream_factory_t **out, const stream_factory_cfg_t *cfg, const stream_env_t *env );

void stream_destroy_factory(stream_factory_t **fact);

Invalid arguments:

  • out, cfg, and env must not be NULL.
  • env->mem must not be NULL.
  • env->mem->calloc and env->mem->free must not be NULL.

Success:

  • Returns STREAM_STATUS_OK.
  • Stores a valid factory handle in *out.
  • The produced factory must be destroyed via stream_destroy_factory().

Failure:

  • Returns:
    • STREAM_STATUS_INVALID for invalid arguments
  • Leaves *out unchanged if out is not NULL.

Lifecycle:

  • stream_destroy_factory() does nothing if fact is NULL or *fact is NULL.
  • Otherwise, it releases the factory object and sets *fact to NULL.

Doubles:

  • none

See also:

The scenarios below define the test oracle for stream_create_factory() and stream_destroy_factory().

Enumerator
STREAM_FACT_LIFECYCLE_SCENARIO_OK 

WHEN stream_create_factory(out, cfg, env) is called with valid arguments EXPECT:

  • returns STREAM_STATUS_OK
  • stores a non-NULL factory handle in *out
  • the produced handle is eligible for destruction by stream_destroy_factory()
STREAM_FACT_LIFECYCLE_SCENARIO_OUT_NULL 

WHEN out == NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • no factory handle is produced
STREAM_FACT_LIFECYCLE_SCENARIO_CFG_NULL 

WHEN cfg == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_LIFECYCLE_SCENARIO_ENV_NULL 

WHEN env == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_LIFECYCLE_SCENARIO_ENV_MEM_NULL 

WHEN env != NULL but env->mem == NULL and out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_LIFECYCLE_SCENARIO_ENV_MEM_CALLOC_NULL 

WHEN env->mem != NULL but env->mem->calloc == NULL AND out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_LIFECYCLE_SCENARIO_ENV_MEM_FREE_NULL 

WHEN env->mem != NULL but env->mem->free == NULL AND out != NULL EXPECT:

  • returns STREAM_STATUS_INVALID
  • leaves *out unchanged
STREAM_FACT_LIFECYCLE_SCENARIO_DESTROY_IDEMPOTENT 

WHEN stream_create_factory() succeeds and stream_destroy_factory() is called twice EXPECT:

  • first stream_destroy_factory(&fact) releases the handle and sets fact to NULL
  • second stream_destroy_factory(&fact) is a no-op and keeps fact as NULL

Notes:

Definition at line 170 of file integration_test_stream_factory.c.