Skip to content

Commit cb6cd5d

Browse files
prepare for update to newer QP release
1 parent 2f1615e commit cb6cd5d

5 files changed

Lines changed: 29 additions & 14 deletions

File tree

cpputest-for-qpcpp-lib/include/qp_port.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
// QF_LOG2 not defined -- use the internal LOG2() implementation
3535

36+
#include <array> //needed by qp.hpp below, starting at 8.1.2
3637
#include "qequeue.hpp" // QP event queue (for deferring events)
3738
#include "qmpool.hpp" // QP memory pool (for event pools)
3839
#include "qp.hpp" // QP platform-independent public interface

cpputest-for-qpcpp-lib/src/cms_cpputest_qf_ctrl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <cassert>
3030
#include <vector>
3131
#include "CppUTest/TestHarness.h"
32+
33+
#define QP_IMPL //need internal access from QP 8.1.0
3234
#include "qp_pkg.hpp"
3335

3436
namespace cms {
@@ -111,8 +113,8 @@ void Teardown()
111113

112114
const size_t poolNumOfEvents =
113115
l_pubSubEventMemPoolConfigs->at(i).config.numberOfEvents;
114-
115-
if (poolNumOfEvents != QP::QF::priv_.ePool_[i].getNFree())
116+
const auto freeEvents = QP::QF::priv_.ePool_[i].getNFree();
117+
if (poolNumOfEvents != freeEvents)
116118
{
117119
leakDetected = true;
118120
fprintf(stderr, "Memory leak in pool: %zu\n", i);

cpputest-for-qpcpp-lib/src/cpputest_qf_port.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ QPSet cpputest_readySet_; // ready set of active objects
2727
void QF::init()
2828
{
2929
priv_.maxPool_ = static_cast<uint_fast8_t>(0);
30-
QP::QF::bzero_(&QP::QTimeEvt::timeEvtHead_[0], sizeof(QP::QTimeEvt::timeEvtHead_));
30+
#if QP_VERSION < 810
31+
QP::QF::bzero_(&QP::QTimeEvt::timeEvtHead_[0],sizeof(QP::QTimeEvt::timeEvtHead_));
3132
QP::QF::bzero_(&QP::QActive::registry_[0], sizeof(QP::QActive::registry_));
33+
#else
34+
QP::QTimeEvt_head_.fill({});
35+
QP::QActive_registry_.fill(nullptr);
36+
#endif
3237
}
3338

3439
#if PURPOSEFULLY_NOT_IMPLEMENTED_
@@ -62,13 +67,13 @@ void RunUntilNoReadyActiveObjects()
6267
{
6368
while (cpputest_readySet_.notEmpty()) {
6469
std::uint_fast8_t p = cpputest_readySet_.findMax();
65-
#if QP_VERSION > 800
66-
QActive* a = QP::QActive::fromRegistry(p);
67-
#elif QP_VERSION > 700
68-
QActive* a = QP::QActive::registry_[p];
69-
#else
70-
#error "unsupported QP version"
71-
#endif
70+
#if QP_VERSION > 800
71+
QActive* a = QP::QActive::fromRegistry(p);
72+
#elif QP_VERSION > 700
73+
QActive* a = QP::QActive::registry_[p];
74+
#else
75+
#error "unsupported QP version"
76+
#endif
7277

7378
// the active object 'a' must still be registered in QF
7479
// (e.g., it must not be stopped)

cpputest-for-qpcpp-lib/tests/backedQueueTests.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828

2929
using namespace cms;
3030

31-
TEST_GROUP(BackedQueueTests) {
32-
void setup() final {}
33-
void teardown() final {}
34-
};
31+
TEST_GROUP(BackedQueueTests) {void setup() final {} void teardown() final {}};
3532

3633
TEST(BackedQueueTests, can_create_vector_backed_qequeue)
3734
{
@@ -89,7 +86,11 @@ TEST(BackedQueueTests, can_push_up_to_max_events)
8986

9087
// confirm full
9188
CHECK_FALSE(underTest->isEmpty());
89+
#if QP_VERSION < 810
9290
CHECK_EQUAL(0, underTest->getNFree());
91+
#else
92+
CHECK_EQUAL(0, underTest->getFree());
93+
#endif
9394

9495
// empty the queue
9596
for (size_t i = 0; i < underTest->capacity(); ++i) {
@@ -98,5 +99,9 @@ TEST(BackedQueueTests, can_push_up_to_max_events)
9899

99100
// confirm empty
100101
CHECK_TRUE(underTest->isEmpty());
102+
#if QP_VERSION < 810
101103
CHECK_EQUAL(MaxStorageForEvents + 1, underTest->getNFree());
104+
#else
105+
CHECK_EQUAL(MaxStorageForEvents + 1, underTest->getFree());
106+
#endif
102107
}

cpputest-for-qpcpp-lib/tests/cms_cpputest_qf_ctrlTests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "cms_cpputest_qf_ctrl.hpp"
2626
#include "qpcpp.hpp"
2727
#include "CppUTest/TestHarness.h"
28+
29+
#define QP_IMPL //need internal access from QP 8.1.0
2830
#include "qp_pkg.hpp"
2931

3032
using namespace cms::test;

0 commit comments

Comments
 (0)