From a88f767ccacdb8e1c30c61075493972e71bbc3d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 19:49:19 +0200 Subject: [PATCH] all tests running again --- unittests/datapoollocal/CMakeLists.txt | 1 - unittests/datapoollocal/testDataSet.cpp | 5 +++-- unittests/datapoollocal/testLocalPoolManager.cpp | 6 +++--- unittests/datapoollocal/testLocalPoolVariable.cpp | 13 +++++-------- unittests/datapoollocal/testLocalPoolVector.cpp | 10 ++++------ unittests/mocks/CMakeLists.txt | 1 + unittests/mocks/LocalPoolOwnerBase.h | 4 ++-- unittests/tmtcservices/testSendHelper.cpp | 6 ++++-- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/unittests/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index 6b8946a2..016645fd 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -3,5 +3,4 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testLocalPoolVector.cpp testDataSet.cpp testLocalPoolManager.cpp - LocalPoolOwnerBase.cpp ) diff --git a/unittests/datapoollocal/testDataSet.cpp b/unittests/datapoollocal/testDataSet.cpp index 62bf59bb..0ef5a77f 100644 --- a/unittests/datapoollocal/testDataSet.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -9,11 +9,12 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" +#include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { - auto queue = MessageQueueMockBase(); + auto queue = MessageQueueMock(); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index 9c979df2..228ab08c 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -12,7 +12,7 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" #include "mocks/HkReceiverMock.h" TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { @@ -20,12 +20,12 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { const MessageQueueId_t hkDest = defaultDestId; const MessageQueueId_t subscriberId = 2; auto hkReceiver = HkReceiverMock(hkDest); - auto queue = MessageQueueMockBase(); + auto queue = MessageQueueMock(); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); - MessageQueueMockBase& poolOwnerMock = poolOwner.getMockQueueHandle(); + MessageQueueMock& poolOwnerMock = poolOwner.getMockQueueHandle(); // TODO: This is ugly. This should be an arbitrary ctor argument. Fix this in the pool // manager diff --git a/unittests/datapoollocal/testLocalPoolVariable.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp index 3479cdbe..dda5aca6 100644 --- a/unittests/datapoollocal/testLocalPoolVariable.cpp +++ b/unittests/datapoollocal/testLocalPoolVariable.cpp @@ -4,15 +4,14 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { - auto* poolOwner = - ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + auto queue = MessageQueueMock(); + LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); SECTION("Basic Tests") { /* very basic test. */ @@ -106,6 +105,4 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { lp_var_t invalidObjectVar2 = lp_var_t(globPoolId); lp_var_t invalidObjectVar3 = lp_var_t(nullptr, lpool::uint8VarId); } - - CHECK(poolOwner->reset() == retval::CATCH_OK); } diff --git a/unittests/datapoollocal/testLocalPoolVector.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp index 331d4e09..dc91fa7e 100644 --- a/unittests/datapoollocal/testLocalPoolVector.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -8,11 +8,10 @@ #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { - auto* poolOwner = - ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + auto queue = MessageQueueMock(); + LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); SECTION("BasicTest") { // very basic test. @@ -106,5 +105,4 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id, nullptr, pool_rwm_t::VAR_READ); REQUIRE(readOnlyVec.commit() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); } - poolOwner->reset(); } diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 9ecb013a..7bc8fd30 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -6,4 +6,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE ComIFMock.cpp MessageQueueMock.cpp InternalErrorReporterMock.cpp + LocalPoolOwnerBase.cpp ) diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 132885ac..329aa0b3 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -98,8 +98,8 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override; - [[nodiscard]] MessageQueueMockBase& getMockQueueHandle() const { - return dynamic_cast(queue); + [[nodiscard]] MessageQueueMock& getMockQueueHandle() const { + return dynamic_cast(queue); } ReturnValue_t subscribePeriodicHk(bool enableReporting) { diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 09d34a50..fc5b86bd 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -1,4 +1,5 @@ #include +#include #include "fsfw/tmtcservices/TmSendHelper.h" #include "mocks/InternalErrorReporterMock.h" @@ -6,8 +7,9 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { auto errReporter = InternalErrorReporterMock(); - auto msgQueue = MessageQueueMockBase(); + auto msgQueue = MessageQueueMock(); TmSendHelper sendHelper(&msgQueue, &errReporter); - SECTION("State") {} + SECTION("State") { + } } \ No newline at end of file