diff --git a/cpputest-for-qpc-lib/include/cms_cpputest_qf_ctrl.hpp b/cpputest-for-qpc-lib/include/cms_cpputest_qf_ctrl.hpp index 2818db3..3865b09 100644 --- a/cpputest-for-qpc-lib/include/cms_cpputest_qf_ctrl.hpp +++ b/cpputest-for-qpc-lib/include/cms_cpputest_qf_ctrl.hpp @@ -62,6 +62,8 @@ void Setup(enum_t maxPubSubSignalValue, uint32_t ticksPerSecond, const MemPoolConfigs& pubSubEventMemPoolConfigs = {}, MemPoolTeardownOption memPoolOpt = MemPoolTeardownOption::CHECK_FOR_LEAKS); +void ChangeMemPoolTeardownOption(MemPoolTeardownOption memPoolOpt); + /// Teardown the QP/QF subsystem after completing a unit test. void Teardown(); diff --git a/cpputest-for-qpc-lib/src/cms_cpputest_qf_ctrl.cpp b/cpputest-for-qpc-lib/src/cms_cpputest_qf_ctrl.cpp index ea50809..71c5e67 100644 --- a/cpputest-for-qpc-lib/src/cms_cpputest_qf_ctrl.cpp +++ b/cpputest-for-qpc-lib/src/cms_cpputest_qf_ctrl.cpp @@ -113,6 +113,11 @@ void Teardown() } } +void ChangeMemPoolTeardownOption(MemPoolTeardownOption memPoolOpt) +{ + l_memPoolOption = memPoolOpt; +} + void ProcessEvents() { QF_runUntilNoReadyActiveObjects(); diff --git a/cpputest-for-qpc-lib/tests/cms_cpputest_qf_ctrlTests.cpp b/cpputest-for-qpc-lib/tests/cms_cpputest_qf_ctrlTests.cpp index dab4d64..8434434 100644 --- a/cpputest-for-qpc-lib/tests/cms_cpputest_qf_ctrlTests.cpp +++ b/cpputest-for-qpc-lib/tests/cms_cpputest_qf_ctrlTests.cpp @@ -105,6 +105,24 @@ TEST(qf_ctrlTests, setup_provides_option_to_skip_memory_pool_leak_detection) // teardown. } +TEST(qf_ctrlTests, provides_modify_memory_pool_leak_detection) +{ + //Do a setup with leak detection. + qf_ctrl::Setup(10, 1000, qf_ctrl::MemPoolConfigs {}, + qf_ctrl::MemPoolTeardownOption::CHECK_FOR_LEAKS); + + //but, this test only wants to disable leak detection, likely because of ASSERT + //testing which may interrupt normal event processing, resulting in false leaks. + qf_ctrl::ChangeMemPoolTeardownOption(qf_ctrl::MemPoolTeardownOption::IGNORE); + + // purposeful leak of an allocated QEvt + QEvt* volatile e = Q_NEW(QEvt, 5); + (void)e; + + // test should pass, as we disabled the memory pool leak detection during + // teardown. +} + TEST(qf_ctrlTests, qf_ctrl_provides_for_ability_to_move_time_forward_firing_active_object_timers_as_expected) {