Skip to content

Commit

Permalink
Update to QP/C++ v7.3.4, which is not backwards compatible to v7.2.*.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheweshleman committed Jun 4, 2024
1 parent 4d51823 commit 484e4de
Show file tree
Hide file tree
Showing 17 changed files with 155 additions and 266 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions cpputest-for-qpcpp-lib/include/cmsDummyActiveObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions cpputest-for-qpcpp-lib/include/cmsOrthogonalComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions cpputest-for-qpcpp-lib/include/cmsOrthogonalContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions cpputest-for-qpcpp-lib/include/qassertMockSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 0 additions & 50 deletions cpputest-for-qpcpp-lib/include/qep_port.hpp

This file was deleted.

151 changes: 0 additions & 151 deletions cpputest-for-qpcpp-lib/include/qf_port.hpp

This file was deleted.

84 changes: 84 additions & 0 deletions cpputest-for-qpcpp-lib/include/qp_port.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
//
//

#ifndef CPPUTEST_FOR_QPCPP_LIB_QP_PORT_HPP
#define CPPUTEST_FOR_QPCPP_LIB_QP_PORT_HPP

#include <cstdint> // 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<void>(0))
#define QF_SCHED_UNLOCK_() (static_cast<void>(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<QEvt *>((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
13 changes: 7 additions & 6 deletions cpputest-for-qpcpp-lib/src/cms_cpputest_q_onAssert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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;
}
Loading

0 comments on commit 484e4de

Please sign in to comment.