HomeClusterLabs Projects

Test: unit tests: overhaul how mocked functions are used

Description

Test: unit tests: overhaul how mocked functions are used

This overhauls mocked function usage so that a single mocked function
definition be used with any number of unit test files.

  • The list of wrapped functions is moved to mk/tap.mk so all unit test Makefiles can add the --wrap flags automatically.
  • All wrapper definitions are moved to lib/common/mock.c (the "weak" versions are gone).
  • All wrapper definitions now follow a common pattern. A global bool pcmk__mock_X determines whether the wrapper will used the mocked behavior or call the real X.
  • mock_private.h declares the new bools as extern, for use by unit tests.
  • Every unit test Makefile.am declares the same AM_CPPFLAGS, LDADD, and AM_LDFLAGS, making the wrappers available. Overrides are no longer needed for specific unit tests that use mocked functions.

Details

Provenance
kgaillotAuthored on Jun 9 2022, 12:09 PM
Parents
rPc94d72b3ef87: Low: libcrmcommon: use proper size for snprintf()
Branches
Unknown
Tags
Unknown