Skip to content

Add reals for configuration_reader, the COM wrappers and sf_service_config consumers - #392

Open
Parth Aggarwal (parth21999) wants to merge 1 commit into
masterfrom
paaggarwal/config-reader-reals
Open

Parth Aggarwal (parth21999) wants to merge 1 commit into
masterfrom
paaggarwal/config-reader-reals

Conversation

@parth21999

Copy link
Copy Markdown
Member

Problem

A unit test that mocks c_pal (gballoc_hl, interlocked) cannot build a real configuration through fc_activation_context, its COM wrapper, DEFINE_SF_SERVICE_CONFIG and configuration_reader. Several links in that chain have no reals, so plain sf_c_util code runs inside the test and its gballoc, interlocked and rc_string calls land in the test's mocks:

  • With interlocked mocked but not hooked, interlocked_decrement returns 0. The first Release of a configuration package frees it while the activation context still holds it, and the next read access violates in GetConfigurationPackage.
  • With everything hooked, nothing crashes, but about 90 internal calls show up in umock's actual calls and break strict expectations.

Changes

Test code only; no changes under src or inc.

  • real_configuration_reader (.c, .h, _renames.h).
  • Reals for the COM wrappers of fc_activation_context, fc_package and fabric_string_list_result. Renaming the wrapped handle type renames every symbol com_wrapper.h generates.
  • Missing dependency renames in the existing reals: real_fc_activation_context, real_fc_package, real_hresult_to_string, and string_utils in the argc/argv reals.
  • real_sf_service_config.h. DEFINE_SF_SERVICE_CONFIG expands in the consumer, so sf_c_util cannot ship its real. The header documents how a consumer builds it and provides DECLARE_REAL_SF_SERVICE_CONFIG and REGISTER_SF_SERVICE_CONFIG_GLOBAL_MOCK_HOOK. real_sf_service_config_dependencies_renames.h renames everything the generated code calls.
  • New real_sf_service_config_ut. It builds a configuration from argv entirely with reals, reads all 8 supported types, refreshes and releases it. It also asserts that the actual calls are exactly the top-level calls the test expects.

Consumer recipe:

// real_<consumer>_renames.h
#define my_service real_my_service
#define real_my_service_CONFIGURATION_TAG my_service_CONFIGURATION_TAG

// real_<consumer>.c
#include "real_sf_service_config_dependencies_renames.h"
#include "real_<consumer>_renames.h"
#include "../../src/<consumer>.c"

Testing

  • Clean Debug x64 build with warnings as errors, configured with run_unittests, run_int_tests, run_reals_check, run_repo_validation and use_vld ON.
  • 13 unit test executables (274 tests) and 11 integration test executables (172 tests) pass, with no VLD leaks.
  • Reals check, traceability and repo validation pass.
  • Removing any of the new renames makes real_sf_service_config_ut fail.

…onfig consumers

A unit test that mocks c_pal could not build a real configuration through
fc_activation_context, its COM wrapper, DEFINE_SF_SERVICE_CONFIG and
configuration_reader. Parts of that chain had no reals, so plain sf_c_util code
ran inside the test and its gballoc, interlocked and rc_string calls landed in
the test's mocks. With interlocked mocked, the first Release of a configuration
package freed it while the activation context still held it, and the next read
access violated.

- Add reals for configuration_reader and for the fc_activation_context,
  fc_package and fabric_string_list_result COM wrappers.
- Add the missing dependency renames to the existing reals.
- Add real_sf_service_config.h. DEFINE_SF_SERVICE_CONFIG expands in the
  consumer, so the header documents how a consumer builds the real of its
  configuration and provides DECLARE_REAL_SF_SERVICE_CONFIG and
  REGISTER_SF_SERVICE_CONFIG_GLOBAL_MOCK_HOOK.
- Add real_sf_service_config_ut, which builds a configuration from argv entirely
  with reals and checks that no internal call reaches the mocks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4c84832a-b5c4-4db4-b114-8aeb0a7dc11a
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@parth21999

Copy link
Copy Markdown
Member Author

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant