From 484e4de5734f1e94b38e64d6b60582619ac084df Mon Sep 17 00:00:00 2001 From: Matthew Eshleman Date: Tue, 4 Jun 2024 12:14:13 -0500 Subject: [PATCH] Update to QP/C++ v7.3.4, which is not backwards compatible to v7.2.*. --- CMakeLists.txt | 2 +- .../include/cmsDummyActiveObject.hpp | 2 + .../include/cmsOrthogonalComponent.hpp | 1 + .../include/cmsOrthogonalContainer.hpp | 2 + .../include/qassertMockSupport.hpp | 14 +- cpputest-for-qpcpp-lib/include/qep_port.hpp | 50 ------ cpputest-for-qpcpp-lib/include/qf_port.hpp | 151 ------------------ cpputest-for-qpcpp-lib/include/qp_port.hpp | 84 ++++++++++ .../src/cms_cpputest_q_onAssert.cpp | 13 +- .../src/cms_cpputest_qf_ctrl.cpp | 37 +++-- .../src/cpputest_qf_port.cpp | 22 +-- .../tests/backedQueueTests.cpp | 2 +- .../cms_cpputest_qf_ctrlPublishTests.cpp | 5 +- .../tests/cms_cpputest_qf_ctrlTests.cpp | 22 +-- .../tests/orthogonalComponentTests.cpp | 8 +- .../tests/orthogonalContainerTests.cpp | 5 +- cpputest-for-qpcpp-lib/tests/qassertTests.cpp | 1 + 17 files changed, 155 insertions(+), 266 deletions(-) delete mode 100644 cpputest-for-qpcpp-lib/include/qep_port.hpp delete mode 100644 cpputest-for-qpcpp-lib/include/qf_port.hpp create mode 100644 cpputest-for-qpcpp-lib/include/qp_port.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cca402..c4d0819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ if(NOT DEFINED CMS_QPCPP_TOP_DIR) set(CMS_QPCPP_TOP_DIR ${CMS_EXTERNALS_TOP_DIR}/qpcpp) FetchContent_Declare(qpcpp GIT_REPOSITORY https://github.com/QuantumLeaps/qpcpp.git - GIT_TAG 6b7d766521a5c9681f61922a64027690721c2478 #7.2.1 + GIT_TAG 10441f7a03fa956b9e4772a073a05a96487983e2 #7.3.4 SOURCE_DIR ${CMS_QPCPP_TOP_DIR} ) message("Fetching QP/C++ git repository") diff --git a/cpputest-for-qpcpp-lib/include/cmsDummyActiveObject.hpp b/cpputest-for-qpcpp-lib/include/cmsDummyActiveObject.hpp index d7939da..4f959e8 100644 --- a/cpputest-for-qpcpp-lib/include/cmsDummyActiveObject.hpp +++ b/cpputest-for-qpcpp-lib/include/cmsDummyActiveObject.hpp @@ -48,6 +48,8 @@ class DummyActiveObject : public QP::QActive { m_incomingEvents.fill(nullptr); } + virtual ~DummyActiveObject() = default; + DummyActiveObject(const DummyActiveObject&) = delete; DummyActiveObject& operator=(const DummyActiveObject&) = delete; DummyActiveObject(DummyActiveObject&&) = delete; diff --git a/cpputest-for-qpcpp-lib/include/cmsOrthogonalComponent.hpp b/cpputest-for-qpcpp-lib/include/cmsOrthogonalComponent.hpp index 5d74009..343cce6 100644 --- a/cpputest-for-qpcpp-lib/include/cmsOrthogonalComponent.hpp +++ b/cpputest-for-qpcpp-lib/include/cmsOrthogonalComponent.hpp @@ -44,6 +44,7 @@ class OrthogonalComponent : public QP::QHsm { m_container(container), m_qs_id(qs_id) { } + virtual ~OrthogonalComponent() = default; OrthogonalComponent(const OrthogonalComponent&) = delete; OrthogonalComponent& operator=(const OrthogonalComponent&) = delete; diff --git a/cpputest-for-qpcpp-lib/include/cmsOrthogonalContainer.hpp b/cpputest-for-qpcpp-lib/include/cmsOrthogonalContainer.hpp index 6045cae..1288fc9 100644 --- a/cpputest-for-qpcpp-lib/include/cmsOrthogonalContainer.hpp +++ b/cpputest-for-qpcpp-lib/include/cmsOrthogonalContainer.hpp @@ -55,6 +55,8 @@ class OrthogonalContainer : public QP::QActive { { } + virtual ~OrthogonalContainer() = default; + protected: // The 'ForEachInTuple' support inspired by: // https://stackoverflow.com/questions/26902633/how-to-iterate-over-a-stdtuple-in-c-11 diff --git a/cpputest-for-qpcpp-lib/include/qassertMockSupport.hpp b/cpputest-for-qpcpp-lib/include/qassertMockSupport.hpp index 4df873f..ba47e52 100644 --- a/cpputest-for-qpcpp-lib/include/qassertMockSupport.hpp +++ b/cpputest-for-qpcpp-lib/include/qassertMockSupport.hpp @@ -25,27 +25,27 @@ #define CPPUTEST_FOR_QPCPP_QASSERTMOCKSUPPORT_HPP #include "CppUTestExt/MockSupport.h" -#include "qassert.h" +#include "qsafe.h" namespace cms { namespace test { static constexpr const char* QASSERT_MOCK_NAME = "QASSERT"; -static constexpr const char* ONASSERT_FUNC_NAME = "Q_onAssert"; +static constexpr const char* ONERROR_FUNC_NAME = "Q_onError"; inline void MockExpectQAssert() { mock(QASSERT_MOCK_NAME) - .expectOneCall(ONASSERT_FUNC_NAME) + .expectOneCall(ONERROR_FUNC_NAME) .ignoreOtherParameters(); } -inline void MockExpectQAssert(const char* file, int loc) +inline void MockExpectQAssert(const char* module, int id) { mock(QASSERT_MOCK_NAME) - .expectOneCall(ONASSERT_FUNC_NAME) - .withParameter("file", file) - .withParameter("loc", loc); + .expectOneCall(ONERROR_FUNC_NAME) + .withParameter("module", module) + .withParameter("id", id); } } // namespace test diff --git a/cpputest-for-qpcpp-lib/include/qep_port.hpp b/cpputest-for-qpcpp-lib/include/qep_port.hpp deleted file mode 100644 index b183e93..0000000 --- a/cpputest-for-qpcpp-lib/include/qep_port.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/// @file -/// @brief QEP/C++ port, generic C++11 compiler -/// @cond -///*************************************************************************** -/// Last updated for version 6.8.0 -/// Last updated on 2020-01-23 -/// -/// Q u a n t u m L e a P s -/// ------------------------ -/// Modern Embedded Software -/// -/// Copyright (C) 2005-2020 Quantum Leaps. All rights reserved. -/// -/// This program is open source software: you can redistribute it and/or -/// modify it under the terms of the GNU General Public License as published -/// by the Free Software Foundation, either version 3 of the License, or -/// (at your option) any later version. -/// -/// Alternatively, this program may be distributed and modified under the -/// terms of Quantum Leaps commercial licenses, which expressly supersede -/// the GNU General Public License and are specifically designed for -/// licensees interested in retaining the proprietary status of their code. -/// -/// This program is distributed in the hope that it will be useful, -/// but WITHOUT ANY WARRANTY; without even the implied warranty of -/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/// GNU General Public License for more details. -/// -/// You should have received a copy of the GNU General Public License -/// along with this program. If not, see . -/// -/// Contact information: -/// -/// -///*************************************************************************** -/// @endcond - -#ifndef QEP_PORT_HPP -#define QEP_PORT_HPP - -#ifdef __GNUC__ - //! no-return function specifier (GCC-ARM compiler) - #define Q_NORETURN __attribute__ ((noreturn)) void -#endif - -#include // Exact-width types. C++11 Standard - -#include "qep.hpp" // QEP platform-independent public interface - -#endif // QEP_PORT_HPP diff --git a/cpputest-for-qpcpp-lib/include/qf_port.hpp b/cpputest-for-qpcpp-lib/include/qf_port.hpp deleted file mode 100644 index c9c6f2e..0000000 --- a/cpputest-for-qpcpp-lib/include/qf_port.hpp +++ /dev/null @@ -1,151 +0,0 @@ -/// @file -/// @brief QF/C++ port to cpputest host based testing environment -/// @cond -///*************************************************************************** -/// Last updated for version 6.9.1 -/// Last updated on 2020-09-21 -/// -/// Q u a n t u m L e a P s -/// ------------------------ -/// Modern Embedded Software -/// -/// Copyright (C) 2005-2020 Quantum Leaps. All rights reserved. -/// -/// This program is open source software: you can redistribute it and/or -/// modify it under the terms of the GNU General Public License as published -/// by the Free Software Foundation, either version 3 of the License, or -/// (at your option) any later version. -/// -/// Alternatively, this program may be distributed and modified under the -/// terms of Quantum Leaps commercial licenses, which expressly supersede -/// the GNU General Public License and are specifically designed for -/// licensees interested in retaining the proprietary status of their code. -/// -/// This program is distributed in the hope that it will be useful, -/// but WITHOUT ANY WARRANTY; without even the implied warranty of -/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/// GNU General Public License for more details. -/// -/// You should have received a copy of the GNU General Public License -/// along with this program. If not, see . -/// -/// Contact information: -/// -/// -///*************************************************************************** -/// @endcond - -#ifndef QF_PORT_HPP -#define QF_PORT_HPP - -// provide QP::QHsm virtual destructor -#define Q_HSM_XTOR 1 - -// event queue and thread types -#define QF_EQUEUE_TYPE QEQueue -// QF_OS_OBJECT_TYPE not used -// QF_THREAD_TYPE not used - -#define QF_EPOOL_TYPE_ QMPool - -// The maximum number of active objects in the application -#define QF_MAX_ACTIVE 64U - -// The number of system clock tick rates -#define QF_MAX_TICK_RATE 2U - -// Activate the QF QActive::stop() API -#define QF_ACTIVE_STOP 1 - -// various QF object sizes configuration for this port -#define QF_EVENT_SIZ_SIZE 4U -#define QF_EQUEUE_CTR_SIZE 4U -#define QF_MPOOL_SIZ_SIZE 4U -#define QF_MPOOL_CTR_SIZE 4U -#define QF_TIMEEVT_CTR_SIZE 4U - -// QF critical section entry/exit for POSIX, see NOTE1 -// QF_CRIT_STAT_TYPE not defined -#define QF_CRIT_ENTRY(dummy) -#define QF_CRIT_EXIT(dummy) - -// QF_LOG2 not defined -- use the internal LOG2() implementation - -#include "qep_port.hpp" // QEP port -#include "qequeue.hpp" // POSIX-QV needs event-queue -#include "qmpool.hpp" // POSIX-QV needs memory-pool -#include "qf.hpp" // QF platform-independent public interface - -namespace QP { - -void QF_runUntilNoReadyActiveObjects(); - -} // namespace QP - -//**************************************************************************** -// interface used only inside QF implementation, but not in applications -// -#ifdef QP_IMPL - - // scheduler locking (not needed in single-thread port) - #define QF_SCHED_STAT_ - #define QF_SCHED_LOCK_(dummy) ((void)0) - #define QF_SCHED_UNLOCK_() ((void)0) - - // event queue operations... - #define QACTIVE_EQUEUE_WAIT_(me_) \ - Q_ASSERT((me_)->m_eQueue.m_frontEvt != nullptr) - - #define QACTIVE_EQUEUE_SIGNAL_(me_) do { \ - cpputest_readySet_.insert((me_)->m_prio); \ - } while (false) - - // event pool operations... - #define QF_EPOOL_TYPE_ QMPool - #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ - (p_).init((poolSto_), (poolSize_), (evtSize_)) - #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) - #define QF_EPOOL_GET_(p_, e_, m_, qs_id_) \ - ((e_) = static_cast((p_).get((m_), (qs_id_)))) - #define QF_EPOOL_PUT_(p_, e_, qs_id_) ((p_).put((e_), (qs_id_))) - - - namespace QP { - extern QPSet cpputest_readySet_; // ready set of active objects - } // namespace QP - -#endif // QP_IMPL - -// NOTES: ==================================================================== -// -// NOTE1: -// QF, like all real-time frameworks, needs to execute certain sections of -// code exclusively, meaning that only one thread can execute the code at -// the time. Such sections of code are called "critical sections" -// -// This port uses a pair of functions QF_enterCriticalSection_() / -// QF_leaveCriticalSection_() to enter/leave the cirtical section, -// respectively. -// -// These functions are implemented in the qf_port.c module, where they -// manipulate the file-scope POSIX mutex object l_pThreadMutex_ -// to protect all critical sections. Using the single mutex for all crtical -// section guarantees that only one thread at a time can execute inside a -// critical section. This prevents race conditions and data corruption. -// -// Please note, however, that the POSIX mutex implementation behaves -// differently than interrupt disabling. A common POSIX mutex ensures -// that only one thread at a time can execute a critical section, but it -// does not guarantee that a context switch cannot occur within the -// critical section. In fact, such context switches probably will happen, -// but they should not cause concurrency hazards because the critical -// section eliminates all race conditionis. -// -// Unlinke simply disabling and enabling interrupts, the mutex approach is -// also subject to priority inversions. However, the p-thread mutex -// implementation, such as POSIX threads, should support the priority- -// inheritance protocol. -// - -#endif // QF_PORT_HPP - diff --git a/cpputest-for-qpcpp-lib/include/qp_port.hpp b/cpputest-for-qpcpp-lib/include/qp_port.hpp new file mode 100644 index 0000000..01b44c4 --- /dev/null +++ b/cpputest-for-qpcpp-lib/include/qp_port.hpp @@ -0,0 +1,84 @@ +// +// +// + +#ifndef CPPUTEST_FOR_QPCPP_LIB_QP_PORT_HPP +#define CPPUTEST_FOR_QPCPP_LIB_QP_PORT_HPP + +#include // Exact-width types. C++11 Standard + +#ifdef QP_CONFIG + #include "qp_config.hpp" // external QP configuration +#endif + +// no-return function specifier (C++11 Standard) +// removed due to certain cpputest test functions +#define Q_NORETURN void + +#define QACTIVE_EQUEUE_TYPE QEQueue +#define QF_EPOOL_TYPE_ QMPool + +// QF critical section for POSIX-QV, see NOTE1 +#define QF_CRIT_STAT +#define QF_CRIT_ENTRY() +#define QF_CRIT_EXIT() + + +// Activate the QF QActive::stop() API +#define QACTIVE_CAN_STOP 1 + +// QF_LOG2 not defined -- use the internal LOG2() implementation + +#include "qequeue.hpp" // QP event queue (for deferring events) +#include "qmpool.hpp" // QP memory pool (for event pools) +#include "qp.hpp" // QP platform-independent public interface + + +namespace QP { + +void RunUntilNoReadyActiveObjects(); + +} // namespace QP + +//============================================================================ +// interface used only inside QF implementation, but not in applications + +#ifdef QP_IMPL + + // QF scheduler locking for POSIX-QV (not needed in single-thread port) + #define QF_SCHED_STAT_ + #define QF_SCHED_LOCK_(dummy) (static_cast(0)) + #define QF_SCHED_UNLOCK_() (static_cast(0)) + + #define QACTIVE_EQUEUE_WAIT_(me_) \ +Q_ASSERT_INCRIT(302, (me_)->m_eQueue.m_frontEvt != nullptr) + + + +#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \ + cpputest_readySet_.insert((me_)->m_prio); \ +} while (false) + + // native QF event pool operations + #define QF_EPOOL_TYPE_ QMPool + #define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \ +(p_).init((poolSto_), (poolSize_), (evtSize_)) + #define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize()) + #define QF_EPOOL_GET_(p_, e_, m_, qsId_) \ +((e_) = static_cast((p_).get((m_), (qsId_)))) + #define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_))) + + +namespace QP { +extern QPSet cpputest_readySet_; // ready set of active objects +} // namespace QP + +namespace QP { +namespace QF { + +} // namespace QF +} // namespace QP + +#endif // QP_IMPL + +#endif // CPPUTEST_FOR_QPCPP_LIB_QP_PORT_HPP diff --git a/cpputest-for-qpcpp-lib/src/cms_cpputest_q_onAssert.cpp b/cpputest-for-qpcpp-lib/src/cms_cpputest_q_onAssert.cpp index ece5b44..c9a399d 100644 --- a/cpputest-for-qpcpp-lib/src/cms_cpputest_q_onAssert.cpp +++ b/cpputest-for-qpcpp-lib/src/cms_cpputest_q_onAssert.cpp @@ -27,12 +27,13 @@ /// @endcond #include "CppUTest/TestHarness.h" -#include "qassert.h" +#include "qp_port.hpp" +#include "qsafe.h" #include "qassertMockSupport.hpp" -Q_NORETURN Q_onAssert(char const* const file, int_t const loc) +void Q_onError(char const* const module, int_t const id) { - // fprintf(stderr, "%s(%s , %d)\n", __FUNCTION__ , file, loc); + //fprintf(stderr, "%s(%s , %d)\n", __FUNCTION__ , module, id); // The TEST_EXIT macro used below is throwing an exception. // However, many of QP/QF methods are marked as 'noexcept' @@ -46,9 +47,9 @@ Q_NORETURN Q_onAssert(char const* const file, int_t const loc) // the function std::terminate ... is called ..." // mock(cms::test::QASSERT_MOCK_NAME) - .actualCall(cms::test::ONASSERT_FUNC_NAME) - .withParameter("file", file) - .withParameter("loc", loc); + .actualCall(cms::test::ONERROR_FUNC_NAME) + .withParameter("module", module) + .withParameter("id", id); TEST_EXIT; } diff --git a/cpputest-for-qpcpp-lib/src/cms_cpputest_qf_ctrl.cpp b/cpputest-for-qpcpp-lib/src/cms_cpputest_qf_ctrl.cpp index b01613c..619e09f 100644 --- a/cpputest-for-qpcpp-lib/src/cms_cpputest_qf_ctrl.cpp +++ b/cpputest-for-qpcpp-lib/src/cms_cpputest_qf_ctrl.cpp @@ -27,10 +27,9 @@ #include "qpcpp.hpp" #include #include -#include #include #include "CppUTest/TestHarness.h" -#include "qf_pkg.hpp" +#include "qp_pkg.hpp" namespace cms { namespace test { @@ -71,7 +70,7 @@ void Setup(enum_t const maxPubSubSignalValue, uint32_t ticksPerSecond, l_ticksPerSecond = ticksPerSecond; l_subscriberStorage = new SubscriberList(); l_subscriberStorage->resize(maxPubSubSignalValue); - QSubscrList nullValue = {0}; + QSubscrList nullValue = QSubscrList(); std::fill(l_subscriberStorage->begin(), l_subscriberStorage->end(), nullValue); @@ -102,13 +101,10 @@ void Teardown() QF::stop(); + bool leakDetected = false; + // No test should complete with allocated events sitting - // in a memory pool. However, the QP Pool class - // is rather private. Ideally that - // QP class is modified to include size/usage accessors. - // Instead, we modified the QF port stop() method, which - // internally will perform the memory check, as it has - // friend access. + // in a memory pool. if (l_pubSubEventMemPoolConfigs != nullptr) { if (l_memPoolOption == MemPoolTeardownOption::CHECK_FOR_LEAKS) { for (size_t i = 0; i < l_pubSubEventMemPoolConfigs->size(); ++i) { @@ -116,20 +112,24 @@ void Teardown() const size_t poolNumOfEvents = l_pubSubEventMemPoolConfigs->at(i).config.numberOfEvents; - CHECK_TRUE_TEXT( - poolNumOfEvents == QP::QF::ePool_[i].getNFree(), - "A leak was detected in an internal QF event pool!"); + if (poolNumOfEvents != QP::QF::priv_.ePool_[i].getNFree()) + { + leakDetected = true; + fprintf(stderr, "Memory leak in pool: %zu\n", i); + } } } delete l_pubSubEventMemPoolConfigs; l_pubSubEventMemPoolConfigs = nullptr; + + CHECK_TRUE_TEXT(!leakDetected, "A leak was detected in an internal QF event pool!"); } } void ProcessEvents() { - QP::QF_runUntilNoReadyActiveObjects(); + QP::RunUntilNoReadyActiveObjects(); } void MoveTimeForward(const std::chrono::milliseconds& duration) @@ -148,7 +148,7 @@ void MoveTimeForward(const std::chrono::milliseconds& duration) ONCE, static_cast(duration.count() / millisecondsPerTick)); for (LoopCounter_t i = 0; i < ticks; ++i) { - QP::QTimeEvt::tick_(0, nullptr); + QP::QTimeEvt::tick(0, nullptr); ProcessEvents(); } } @@ -187,13 +187,16 @@ void PublishAndProcess(QP::QEvt const* const e, void CreateDefaultPools() { + //see QP/C++ 7.3.0 release notes, where memory pool behavior/sizing + //was changed: https://www.state-machine.com/qpcpp/history.html#qpcpp_7_3_0 + l_pubSubEventMemPoolConfigs = new std::vector(); l_pubSubEventMemPoolConfigs->push_back( - InternalPoolConfig(MemPoolConfig {sizeof(uint64_t), 25})); + InternalPoolConfig(MemPoolConfig {sizeof(uint64_t) * 2, 25})); l_pubSubEventMemPoolConfigs->push_back( - InternalPoolConfig(MemPoolConfig {sizeof(uint64_t) * 5, 10})); + InternalPoolConfig(MemPoolConfig {sizeof(uint64_t) * 10, 10})); l_pubSubEventMemPoolConfigs->push_back( - InternalPoolConfig(MemPoolConfig {sizeof(uint64_t) * 15, 5})); + InternalPoolConfig(MemPoolConfig {sizeof(uint64_t) * 20, 5})); } void CreatePoolConfigsFromArg(const MemPoolConfigs& pubSubEventMemPoolConfigs) diff --git a/cpputest-for-qpcpp-lib/src/cpputest_qf_port.cpp b/cpputest-for-qpcpp-lib/src/cpputest_qf_port.cpp index 902a8bf..b761eef 100644 --- a/cpputest-for-qpcpp-lib/src/cpputest_qf_port.cpp +++ b/cpputest-for-qpcpp-lib/src/cpputest_qf_port.cpp @@ -7,9 +7,9 @@ /// #define QP_IMPL // this is QP implementation -#include "qf_port.hpp" // QF port -#include "qf_pkg.hpp" // QF package-scope interface -#include "qassert.h" // QP embedded systems-friendly assertions +#include "qp_port.hpp" // QF port +#include "qp_pkg.hpp" // QF package-scope interface +#include "qsafe.h" // QP embedded systems-friendly assertions #ifdef Q_SPY // QS software tracing enabled? #error "Q_SPY not supported in the cpputest port" #else @@ -26,9 +26,9 @@ QPSet cpputest_readySet_; // ready set of active objects //**************************************************************************** void QF::init() { - QF::maxPool_ = static_cast(0); - bzero(&QP::QTimeEvt::timeEvtHead_[0], sizeof(QP::QTimeEvt::timeEvtHead_)); - bzero(&QP::QActive::registry_[0], sizeof(QP::QActive::registry_)); + priv_.maxPool_ = static_cast(0); + QP::QF::bzero_(&QP::QTimeEvt::timeEvtHead_[0], sizeof(QP::QTimeEvt::timeEvtHead_)); + QP::QF::bzero_(&QP::QActive::registry_[0], sizeof(QP::QActive::registry_)); } #if PURPOSEFULLY_NOT_IMPLEMENTED_ @@ -39,7 +39,7 @@ int_t QF::run() } #endif -void QF_runUntilNoReadyActiveObjects() +void RunUntilNoReadyActiveObjects() { while (cpputest_readySet_.notEmpty()) { std::uint_fast8_t p = cpputest_readySet_.findMax(); @@ -49,13 +49,13 @@ void QF_runUntilNoReadyActiveObjects() // (e.g., it must not be stopped) Q_ASSERT_ID(320, a != nullptr); - while (!a->m_eQueue.isEmpty()) { - const auto e = a->m_eQueue.get(0); + while (!a->getEQueue().isEmpty()) { + const auto e = a->get_(); a->dispatch(e, 0); QF::gc(e); } - if (a->m_eQueue.isEmpty()) { /* empty queue? */ + if (a->getEQueue().isEmpty()) { /* empty queue? */ cpputest_readySet_.remove(p); } } @@ -88,7 +88,7 @@ void QActive::start( QPrioSpec const prioSpec, } //............................................................................ -#ifdef QF_ACTIVE_STOP +#ifdef QACTIVE_CAN_STOP void QActive::stop() { unsubscribeAll(); diff --git a/cpputest-for-qpcpp-lib/tests/backedQueueTests.cpp b/cpputest-for-qpcpp-lib/tests/backedQueueTests.cpp index 87e70b5..9799b35 100644 --- a/cpputest-for-qpcpp-lib/tests/backedQueueTests.cpp +++ b/cpputest-for-qpcpp-lib/tests/backedQueueTests.cpp @@ -82,7 +82,7 @@ TEST(BackedQueueTests, can_push_up_to_max_events) auto underTest = std::unique_ptr(new ArrayTestType()); // fill up the queue - static QP::QEvt testEvent {5, 0, 0}; + static const QP::QEvt testEvent = QP::QEvt(5); for (size_t i = 0; i < underTest->capacity(); ++i) { underTest->post(&testEvent, QP::QF::NO_MARGIN, 0); } diff --git a/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlPublishTests.cpp b/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlPublishTests.cpp index 57bce12..da33e56 100644 --- a/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlPublishTests.cpp +++ b/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlPublishTests.cpp @@ -83,8 +83,7 @@ TEST(qf_ctrlPublishTests, qf_ctrl_provides_a_qevt_publish_from_test_helper_func) qf_ctrl::PublishEvent(e); qf_ctrl::ProcessEvents(); CHECK_TRUE(mRecorder->isSignalRecorded(TEST1_PUBLISH_SIG)); - QP::QF::gc(e); -} + } TEST(qf_ctrlPublishTests, qf_ctrl_provides_a_qevt_publish_and_process_from_test_helper_func) @@ -92,7 +91,6 @@ TEST(qf_ctrlPublishTests, auto e = Q_NEW(QP::QEvt, TEST1_PUBLISH_SIG); qf_ctrl::PublishAndProcess(e); CHECK_TRUE(mRecorder->isSignalRecorded(TEST1_PUBLISH_SIG)); - QP::QF::gc(e); } TEST(qf_ctrlPublishTests, @@ -101,5 +99,4 @@ TEST(qf_ctrlPublishTests, auto e = Q_NEW(QP::QEvt, TEST1_PUBLISH_SIG); qf_ctrl::PublishAndProcess(e, mRecorder); CHECK_FALSE(mRecorder->isSignalRecorded(TEST1_PUBLISH_SIG)); - QP::QF::gc(e); } diff --git a/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlTests.cpp b/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlTests.cpp index 766cd00..2069012 100644 --- a/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlTests.cpp +++ b/cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlTests.cpp @@ -25,7 +25,7 @@ #include "cms_cpputest_qf_ctrl.hpp" #include "qpcpp.hpp" #include "CppUTest/TestHarness.h" -#include "qf_pkg.hpp" +#include "qp_pkg.hpp" using namespace cms::test; @@ -42,14 +42,14 @@ TEST_GROUP(qf_ctrlTests) void ConfirmNumberOfPools(uint32_t poolCount) { - CHECK_EQUAL(poolCount, QP::QF::maxPool_); + CHECK_EQUAL(poolCount, QP::QF::priv_.maxPool_); } void ConfirmPoolEventSize(uint32_t poolIndex, uint32_t blockSize) { CHECK_TRUE(poolIndex < QF_MAX_EPOOL); - CHECK_TRUE(poolIndex < QP::QF::maxPool_); - CHECK_EQUAL(blockSize, QP::QF::ePool_[poolIndex].getBlockSize()); + CHECK_TRUE(poolIndex < QP::QF::priv_.maxPool_); + CHECK_EQUAL(blockSize, QP::QF::priv_.ePool_[poolIndex].getBlockSize()); } }; @@ -58,21 +58,21 @@ TEST(qf_ctrlTests, by_default_setup_creates_three_pubsub_pools) { qf_ctrl::Setup(10, 1000); ConfirmNumberOfPools(3); - ConfirmPoolEventSize(0, 8); - ConfirmPoolEventSize(1, 40); - ConfirmPoolEventSize(2, 120); + ConfirmPoolEventSize(0, 16); + ConfirmPoolEventSize(1, 80); + ConfirmPoolEventSize(2, 160); } TEST(qf_ctrlTests, setup_will_create_two_pools_when_requested) { qf_ctrl::MemPoolConfigs configs; - configs.push_back(qf_ctrl::MemPoolConfig {sizeof(uint64_t), 10}); - configs.push_back(qf_ctrl::MemPoolConfig {sizeof(uint64_t) * 2, 5}); + configs.push_back(qf_ctrl::MemPoolConfig {sizeof(uint64_t) * 4, 10}); + configs.push_back(qf_ctrl::MemPoolConfig {sizeof(uint64_t) * 8, 5}); qf_ctrl::Setup(10, 1000, configs); ConfirmNumberOfPools(2); - ConfirmPoolEventSize(0, sizeof(uint64_t)); - ConfirmPoolEventSize(1, sizeof(uint64_t) * 2); + ConfirmPoolEventSize(0, sizeof(uint64_t) * 4); + ConfirmPoolEventSize(1, sizeof(uint64_t) * 8); } TEST(qf_ctrlTests, setup_will_create_one_pool_when_requested) diff --git a/cpputest-for-qpcpp-lib/tests/orthogonalComponentTests.cpp b/cpputest-for-qpcpp-lib/tests/orthogonalComponentTests.cpp index 6b3b5d1..14b110e 100644 --- a/cpputest-for-qpcpp-lib/tests/orthogonalComponentTests.cpp +++ b/cpputest-for-qpcpp-lib/tests/orthogonalComponentTests.cpp @@ -174,7 +174,7 @@ TEST( TEST(OrthogonalComponentTests, component_will_process_desired_published_signal) { - static const QP::QEvt event = {TEST1_PUBLISH_SIG, 0, 0}; + static const QP::QEvt event = QP::QEvt(TEST1_PUBLISH_SIG); createUnitUnderTest(); startUnitUnderTest(); @@ -187,7 +187,7 @@ TEST(OrthogonalComponentTests, component_will_process_desired_published_signal) TEST(OrthogonalComponentTests, component_will_not_process_undesired_published_signal) { - static const QP::QEvt event = {TEST2_PUBLISH_SIG, 0, 0}; + static const QP::QEvt event = QP::QEvt(TEST2_PUBLISH_SIG); createUnitUnderTest(); startUnitUnderTest(); @@ -200,7 +200,7 @@ TEST(OrthogonalComponentTests, TEST(OrthogonalComponentTests, component_will_process_desired_direct_post_signal) { - static const QP::QEvt event = {TEST3_POST_SIG, 0, 0}; + static const QP::QEvt event = QP::QEvt(TEST3_POST_SIG); createUnitUnderTest(); startUnitUnderTest(); @@ -212,7 +212,7 @@ TEST(OrthogonalComponentTests, TEST(OrthogonalComponentTests, component_will_not_process_undesired_misc_signal) { - static const QP::QEvt event = {TEST4_MISC_SIG, 0, 0}; + static const QP::QEvt event = QP::QEvt(TEST4_MISC_SIG); createUnitUnderTest(); startUnitUnderTest(); diff --git a/cpputest-for-qpcpp-lib/tests/orthogonalContainerTests.cpp b/cpputest-for-qpcpp-lib/tests/orthogonalContainerTests.cpp index ab033b5..126a8f4 100644 --- a/cpputest-for-qpcpp-lib/tests/orthogonalContainerTests.cpp +++ b/cpputest-for-qpcpp-lib/tests/orthogonalContainerTests.cpp @@ -300,9 +300,8 @@ TEST( OrthogonalContainerTests, container_with_two_components_allows_for_posts_for_components_and_expected_components_process_expected_signals) { - - static const QP::QEvt Test3Event = {TEST1_POST_SIG, 0, 0}; - static const QP::QEvt Test4Event = {TEST2_POST_SIG, 0, 0}; + static const QP::QEvt Test3Event = QP::QEvt(TEST1_POST_SIG); + static const QP::QEvt Test4Event = QP::QEvt(TEST2_POST_SIG); auto underTest = CreateAndStartWithTwoTestComponents(); diff --git a/cpputest-for-qpcpp-lib/tests/qassertTests.cpp b/cpputest-for-qpcpp-lib/tests/qassertTests.cpp index 30a3931..19d1f2a 100644 --- a/cpputest-for-qpcpp-lib/tests/qassertTests.cpp +++ b/cpputest-for-qpcpp-lib/tests/qassertTests.cpp @@ -22,6 +22,7 @@ /// @endcond #include "CppUTest/TestHarness.h" +#include "qp_port.hpp" #include "qassertMockSupport.hpp" Q_DEFINE_THIS_MODULE("QAssertTests");