diff --git a/misc/archive/HasLocalDpIFManagerAttorney.h b/misc/archive/HasLocalDpIFManagerAttorney.h index 4651d5e1..ae19b8c1 100644 --- a/misc/archive/HasLocalDpIFManagerAttorney.h +++ b/misc/archive/HasLocalDpIFManagerAttorney.h @@ -9,7 +9,7 @@ class LocalPoolObjectBase; class HasLocalDpIFManagerAttorney { static LocalPoolObjectBase* getPoolObjectHandle(PeriodicHkGenerationIF* clientIF, - dp::lp_id_t localPoolId); + dp::id_t localPoolId); static object_id_t getObjectId(PeriodicHkGenerationIF* clientIF); diff --git a/src/fsfw/datapool/LocalPoolObjectBase.cpp b/src/fsfw/datapool/LocalPoolObjectBase.cpp index 7cc09e13..aced7c23 100644 --- a/src/fsfw/datapool/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapool/LocalPoolObjectBase.cpp @@ -4,7 +4,7 @@ #include "fsfw/objectmanager/ObjectManager.h" using namespace dp; -PoolObjectBase::PoolObjectBase(SharedPool& sharedPool, dp::lp_id_t poolId, DataSetIF* dataSet, +PoolObjectBase::PoolObjectBase(SharedPool& sharedPool, dp::id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode), sharedPool(&sharedPool) { if (poolId == PoolVariableIF::NO_PARAMETER) { @@ -19,7 +19,7 @@ PoolObjectBase::PoolObjectBase(SharedPool& sharedPool, dp::lp_id_t poolId, DataS } } -PoolObjectBase::PoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet, +PoolObjectBase::PoolObjectBase(object_id_t poolOwner, id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : localPoolId(poolId), readWriteMode(setReadWriteMode) { if (poolId == PoolVariableIF::NO_PARAMETER) { @@ -56,16 +56,16 @@ PoolObjectBase::PoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* pool_rwm_t PoolObjectBase ::getReadWriteMode() const { return readWriteMode; } -lp_id_t PoolObjectBase ::getDataPoolId() const { return localPoolId; } +id_t PoolObjectBase ::getDataPoolId() const { return localPoolId; } -void PoolObjectBase::setDataPoolId(lp_id_t poolId) { this->localPoolId = poolId; } +void PoolObjectBase::setDataPoolId(id_t poolId) { this->localPoolId = poolId; } void PoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) { this->readWriteMode = newReadWriteMode; } void PoolObjectBase::reportReadCommitError(const char* variableType, ReturnValue_t error, bool read, - object_id_t objectId, lp_id_t lpId) { + object_id_t objectId, id_t lpId) { #if FSFW_DISABLE_PRINTOUT == 0 const char* variablePrintout = variableType; if (variablePrintout == nullptr) { diff --git a/src/fsfw/datapool/LocalPoolObjectBase.h b/src/fsfw/datapool/LocalPoolObjectBase.h index 2ce76579..e50a429f 100644 --- a/src/fsfw/datapool/LocalPoolObjectBase.h +++ b/src/fsfw/datapool/LocalPoolObjectBase.h @@ -15,17 +15,17 @@ namespace datapool { */ class PoolObjectBase : public PoolVariableIF { public: - PoolObjectBase(dp::SharedPool& sharedPool, dp::lp_id_t poolId, DataSetIF* dataSet, + PoolObjectBase(dp::SharedPool& sharedPool, dp::id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode); - PoolObjectBase(object_id_t poolOwner, dp::lp_id_t poolId, DataSetIF* dataSet = nullptr, + PoolObjectBase(object_id_t poolOwner, dp::id_t poolId, DataSetIF* dataSet = nullptr, pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); void setReadWriteMode(pool_rwm_t newReadWriteMode) override; [[nodiscard]] pool_rwm_t getReadWriteMode() const override; - [[nodiscard]] lp_id_t getDataPoolId() const override; - void setDataPoolId(dp::lp_id_t poolId); + [[nodiscard]] dp::id_t getDataPoolId() const override; + void setDataPoolId(dp::id_t poolId); protected: /** @@ -44,7 +44,7 @@ class PoolObjectBase : public PoolVariableIF { dp::SharedPool* sharedPool = nullptr; void reportReadCommitError(const char* variableType, ReturnValue_t error, bool read, - object_id_t objectId, dp::lp_id_t lpId); + object_id_t objectId, dp::id_t lpId); }; } // namespace datapool \ No newline at end of file diff --git a/src/fsfw/datapool/LocalPoolVector.h b/src/fsfw/datapool/LocalPoolVector.h index 4fbf114f..c2d84a13 100644 --- a/src/fsfw/datapool/LocalPoolVector.h +++ b/src/fsfw/datapool/LocalPoolVector.h @@ -48,7 +48,7 @@ class PoolVector : public PoolObjectBase { * @param dataSet The data set in which the variable shall register itself. * If nullptr, the variable is not registered. */ - PoolVector(SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr, + PoolVector(SharedPool& sharedPool, id_t poolId, DataSetIF* dataSet = nullptr, pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE) : PoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {} @@ -59,15 +59,15 @@ class PoolVector : public PoolObjectBase { * It does not fetch the current value from the data pool. This is performed * by the read() operation (which is not thread-safe). * Datasets can be used to access local pool entires in a thread-safe way. + * @param poolOwner Owner of the shared pool. * @param poolId ID of the local pool entry. - * @param hkOwner Pointer of the owner. This will generally be the calling - * class itself which passes "this". * @param setReadWriteMode Specify the read-write mode of the pool variable. * @param dataSet The data set in which the variable shall register itself. * If nullptr, the variable is not registered. */ - PoolVector(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr, - pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); + PoolVector(object_id_t poolOwner, id_t poolId, DataSetIF* dataSet = nullptr, + pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE) + : PoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {} /** * Variation which takes the unique global identifier of a local pool * vector. diff --git a/src/fsfw/datapool/PoolVariable.h b/src/fsfw/datapool/PoolVariable.h index d2685aab..e5c555e7 100644 --- a/src/fsfw/datapool/PoolVariable.h +++ b/src/fsfw/datapool/PoolVariable.h @@ -43,7 +43,7 @@ class PoolVariable : public PoolObjectBase { * If nullptr, the variable is not registered. * @param setReadWriteMode Specify the read-write mode of the pool variable. */ - PoolVariable(SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet = nullptr, + PoolVariable(SharedPool& sharedPool, dp::id_t poolId, DataSetIF* dataSet = nullptr, pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); /** @@ -63,7 +63,7 @@ class PoolVariable : public PoolObjectBase { * @param setReadWriteMode Specify the read-write mode of the pool variable. * */ - PoolVariable(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr, + PoolVariable(object_id_t poolOwner, dp::id_t poolId, DataSetIF* dataSet = nullptr, pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); /** * Variation which takes the global unique identifier of a pool variable. @@ -164,12 +164,12 @@ class PoolVariable : public PoolObjectBase { }; template -PoolVariable::PoolVariable(SharedPool& sharedPool, lp_id_t poolId, DataSetIF* dataSet, +PoolVariable::PoolVariable(SharedPool& sharedPool, dp::id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : PoolObjectBase(sharedPool, poolId, dataSet, setReadWriteMode) {} template -PoolVariable::PoolVariable(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet, +PoolVariable::PoolVariable(object_id_t poolOwner, dp::id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode) : PoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {} diff --git a/src/fsfw/datapool/SharedPool.cpp b/src/fsfw/datapool/SharedPool.cpp index e0ad6338..59fea2bc 100644 --- a/src/fsfw/datapool/SharedPool.cpp +++ b/src/fsfw/datapool/SharedPool.cpp @@ -20,13 +20,13 @@ SharedPool::~SharedPool() { MutexFactory::instance()->deleteMutex(mutex); } object_id_t SharedPool::getOwnerId() const { return ownerId; } -void SharedPool::addPoolEntry(lp_id_t poolId, PoolEntryIF* entry) { +void SharedPool::addPoolEntry(id_t poolId, PoolEntryIF* entry) { localPoolMap.emplace(poolId, entry); } MutexIF* SharedPool::getPoolMutex() { return mutex; } -ReturnValue_t SharedPool::printPoolEntry(lp_id_t localPoolId) { +ReturnValue_t SharedPool::printPoolEntry(id_t localPoolId) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { return POOL_ENTRY_NOT_FOUND; diff --git a/src/fsfw/datapool/SharedPool.h b/src/fsfw/datapool/SharedPool.h index eda785ca..277dc76a 100644 --- a/src/fsfw/datapool/SharedPool.h +++ b/src/fsfw/datapool/SharedPool.h @@ -25,9 +25,9 @@ class SharedPool { * @return */ template - ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry** poolEntry); - ReturnValue_t printPoolEntry(lp_id_t localPoolId); - void addPoolEntry(lp_id_t poolId, PoolEntryIF* entry); + ReturnValue_t fetchPoolEntry(id_t localPoolId, PoolEntry** poolEntry); + ReturnValue_t printPoolEntry(id_t localPoolId); + void addPoolEntry(id_t poolId, PoolEntryIF* entry); MutexIF* getPoolMutex(); private: @@ -41,7 +41,7 @@ class SharedPool { }; template -inline ReturnValue_t datapool::SharedPool::fetchPoolEntry(lp_id_t localPoolId, +inline ReturnValue_t datapool::SharedPool::fetchPoolEntry(id_t localPoolId, PoolEntry** poolEntry) { if (poolEntry == nullptr) { return returnvalue::FAILED; diff --git a/src/fsfw/datapool/SharedSetBase.cpp b/src/fsfw/datapool/SharedSetBase.cpp index 59a40197..0dad8b89 100644 --- a/src/fsfw/datapool/SharedSetBase.cpp +++ b/src/fsfw/datapool/SharedSetBase.cpp @@ -76,7 +76,7 @@ ReturnValue_t SharedSetBase::serializeLocalPoolIds(uint8_t **buffer, size_t *siz SerializeAdapter::serialize(&fillCount, buffer, size, maxSize, streamEndianness); } for (uint16_t count = 0; count < fillCount; count++) { - lp_id_t currentPoolId = base.registeredVariables[count]->getDataPoolId(); + id_t currentPoolId = base.registeredVariables[count]->getDataPoolId(); auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { @@ -96,9 +96,9 @@ ReturnValue_t SharedSetBase::serializeLocalPoolIds(uint8_t **buffer, size_t *siz size_t SharedSetBase::getLocalPoolIdsSerializedSize(bool serializeFillCount) const { if (serializeFillCount) { - return base.getFillCount() * sizeof(lp_id_t) + sizeof(u8_t); + return base.getFillCount() * sizeof(id_t) + sizeof(u8_t); } else { - return base.getFillCount() * sizeof(lp_id_t); + return base.getFillCount() * sizeof(id_t); } } diff --git a/src/fsfw/datapool/definitions.h b/src/fsfw/datapool/definitions.h index 5ade7dd0..9d3ce082 100644 --- a/src/fsfw/datapool/definitions.h +++ b/src/fsfw/datapool/definitions.h @@ -12,7 +12,7 @@ namespace datapool { /** * @brief Type definition for local pool entries. */ -using lp_id_t = uint32_t; +using id_t = uint32_t; static constexpr uint32_t INVALID_LPID = -1; @@ -23,7 +23,7 @@ static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x01) /** This is the core data structure of the local data pools. Users should insert all desired pool variables, using the std::map interface. */ -using DataPool = std::map; +using DataPool = std::map; /** * Used as a unique identifier for data sets. Consists of 4 byte object ID and 4 byte set ID. @@ -70,12 +70,11 @@ union g_id_t { g_id_t() : raw(INVALID_GPID) {} - g_id_t(object_id_t objectId, lp_id_t localPoolId) - : objectId(objectId), localPoolId(localPoolId) {} + g_id_t(object_id_t objectId, id_t localPoolId) : objectId(objectId), localPoolId(localPoolId) {} struct { object_id_t objectId; - lp_id_t localPoolId; + id_t localPoolId; }; uint64_t raw; diff --git a/src/fsfw/datapool/internal/SharedPoolAttorney.h b/src/fsfw/datapool/internal/SharedPoolAttorney.h index f696219a..1d9198ed 100644 --- a/src/fsfw/datapool/internal/SharedPoolAttorney.h +++ b/src/fsfw/datapool/internal/SharedPoolAttorney.h @@ -16,7 +16,7 @@ namespace datapool { class SharedPoolAttorney { private: template - static ReturnValue_t fetchPoolEntry(SharedPool& manager, lp_id_t localPoolId, + static ReturnValue_t fetchPoolEntry(SharedPool& manager, dp::id_t localPoolId, PoolEntry** poolEntry) { return manager.fetchPoolEntry(localPoolId, poolEntry); } diff --git a/src/fsfw/devicehandlers/DeviceHandlerIF.h b/src/fsfw/devicehandlers/DeviceHandlerIF.h index 8b939ed6..29320200 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerIF.h +++ b/src/fsfw/devicehandlers/DeviceHandlerIF.h @@ -122,8 +122,8 @@ class DeviceHandlerIF { static constexpr uint32_t DEFAULT_THERMAL_SET_ID = dp::sid_t::INVALID_SET_ID - 1; - static constexpr dp::lp_id_t DEFAULT_THERMAL_STATE_POOL_ID = dp::INVALID_LPID - 2; - static constexpr dp::lp_id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = dp::INVALID_LPID - 1; + static constexpr dp::id_t DEFAULT_THERMAL_STATE_POOL_ID = dp::INVALID_LPID - 2; + static constexpr dp::id_t DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID = dp::INVALID_LPID - 1; /** * Default Destructor @@ -138,8 +138,8 @@ class DeviceHandlerIF { }; struct ThermalStateCfg { - dp::lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID; - dp::lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID; + dp::id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID; + dp::id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID; uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID; }; diff --git a/src/fsfw/devicehandlers/DeviceHandlerThermalSet.h b/src/fsfw/devicehandlers/DeviceHandlerThermalSet.h index 3a12e89a..cf384694 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerThermalSet.h +++ b/src/fsfw/devicehandlers/DeviceHandlerThermalSet.h @@ -17,8 +17,8 @@ class DeviceHandlerThermalSet : public dp::StaticSharedSet<2> { thermalStatePoolId(cfg.thermalStatePoolId), heaterRequestPoolId(cfg.thermalRequestPoolId) {} - const dp::lp_id_t thermalStatePoolId; - const dp::lp_id_t heaterRequestPoolId; + const dp::id_t thermalStatePoolId; + const dp::id_t heaterRequestPoolId; dp::var_t thermalState = dp::var_t(sid.objectId, thermalStatePoolId, this); diff --git a/src/fsfw/housekeeping/GeneratesPeriodicHkIF.h b/src/fsfw/housekeeping/GeneratesPeriodicHkIF.h index 57ccc992..ab8fe41b 100644 --- a/src/fsfw/housekeeping/GeneratesPeriodicHkIF.h +++ b/src/fsfw/housekeeping/GeneratesPeriodicHkIF.h @@ -34,6 +34,8 @@ namespace hk { * } */ class GeneratesPeriodicHkIF { + friend class PeriodicHelper; + public: [[nodiscard]] virtual object_id_t getObjectId() const = 0; diff --git a/src/fsfw/housekeeping/PeriodicHkHelper.cpp b/src/fsfw/housekeeping/PeriodicHkHelper.cpp index abb1a502..65a1c9ad 100644 --- a/src/fsfw/housekeeping/PeriodicHkHelper.cpp +++ b/src/fsfw/housekeeping/PeriodicHkHelper.cpp @@ -130,7 +130,7 @@ ReturnValue_t PeriodicHelper::handleHousekeepingMessage(CommandMessage* message) return result; } -PeriodicHkGenerationIF* PeriodicHelper::getOwner() const { return owner; } +GeneratesPeriodicHkIF* PeriodicHelper::getOwner() const { return owner; } ReturnValue_t PeriodicHelper::generateHousekeepingPacket(const dp::sid_t sid, MessageQueueId_t destination) { @@ -189,7 +189,7 @@ void PeriodicHelper::performPeriodicHkGeneration(SetSpecification& setSpec, time // timeval now{}; Clock::getClockMonotonic(&now); - sid_t sid = setSpec.dataId.sid; + dp::sid_t sid = setSpec.dataId.sid; timeval diff = now - setSpec.lastGenerated; dur_millis_t diffMillis = diff.tv_sec * 1000 + diff.tv_usec / 1000; @@ -222,7 +222,7 @@ ReturnValue_t PeriodicHelper::togglePeriodicGeneration(dp::sid_t sid, bool enabl } std::optional> PeriodicHelper::getSetSpecification( - sid_t structureId) { + dp::sid_t structureId) { for (auto& receiver : setList) { if (receiver.dataId.sid == structureId) { return receiver; @@ -231,7 +231,7 @@ std::optional> PeriodicHelper::getSetSp return std::nullopt; } -ReturnValue_t PeriodicHelper::setCollectionInterval(sid_t sid, +ReturnValue_t PeriodicHelper::setCollectionInterval(dp::sid_t sid, dur_millis_t newCollectionIntervalMs) { bool wasUpdated = false; for (auto& receiver : setList) { @@ -247,7 +247,7 @@ ReturnValue_t PeriodicHelper::setCollectionInterval(sid_t sid, return returnvalue::OK; } -ReturnValue_t PeriodicHelper::generateSetStructurePacket(sid_t sid) { +ReturnValue_t PeriodicHelper::generateSetStructurePacket(dp::structure_id_t sid) { // Get and check dataset first. auto optSetSpec = getSetSpecification(sid); if (!optSetSpec.has_value()) { @@ -297,7 +297,7 @@ ReturnValue_t PeriodicHelper::generateSetStructurePacket(sid_t sid) { return result; } -ReturnValue_t PeriodicHelper::enablePeriodicPacket(const sid_t structureId, +ReturnValue_t PeriodicHelper::enablePeriodicPacket(const dp::structure_id_t structureId, const std::optional frequencyMs) { // Get and check dataset first. const auto optSetSpec = getSetSpecification(structureId); @@ -314,7 +314,7 @@ ReturnValue_t PeriodicHelper::enablePeriodicPacket(const sid_t structureId, return returnvalue::OK; } -ReturnValue_t PeriodicHelper::disablePeriodicPacket(const sid_t structureId) { +ReturnValue_t PeriodicHelper::disablePeriodicPacket(const dp::structure_id_t structureId) { // Get and check dataset first. const auto optSetSpec = getSetSpecification(structureId); if (!optSetSpec.has_value()) { diff --git a/src/fsfw/housekeeping/PeriodicHkHelper.h b/src/fsfw/housekeeping/PeriodicHkHelper.h index 26a6b7a9..ed297071 100644 --- a/src/fsfw/housekeeping/PeriodicHkHelper.h +++ b/src/fsfw/housekeeping/PeriodicHkHelper.h @@ -113,10 +113,10 @@ class PeriodicHelper : public PeriodicHelperIF { ReturnValue_t generateHousekeepingPacket(dp::sid_t sid, MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); - [[nodiscard]] PeriodicHkGenerationIF* getOwner() const; + [[nodiscard]] GeneratesPeriodicHkIF* getOwner() const; void addSetSpecification(const SetSpecification& setSpec); - ReturnValue_t printPoolEntry(dp::lp_id_t localPoolId); + ReturnValue_t printPoolEntry(dp::id_t localPoolId); /* Copying forbidden */ PeriodicHelper(const PeriodicHkGenerationHelper&) = delete; @@ -139,7 +139,6 @@ class PeriodicHelper : public PeriodicHelperIF { */ MutexIF* getMutexHandle(); - // PeriodicHkGenerationHelper* getPoolManagerHandle() override; /** * Set the periodic generation frequency without enabling the periodic generation of packets. */ diff --git a/src/fsfw/housekeeping/definitions.h b/src/fsfw/housekeeping/definitions.h index a4de3ba7..85d7ce99 100644 --- a/src/fsfw/housekeeping/definitions.h +++ b/src/fsfw/housekeeping/definitions.h @@ -36,7 +36,7 @@ union DataId { return d; } dp::sid_t sid; - dp::lp_id_t localPoolId; + dp::id_t localPoolId; }; /** Different data types are possible in the HK receiver map. For example, updates can be @@ -44,8 +44,9 @@ requested for full datasets or for single pool variables. Periodic reporting is for data sets. */ enum class DataType : uint8_t { LOCAL_POOL_VARIABLE, DATA_SET }; -/** The data pool manager will keep an internal map of HK receivers. */ struct SetSpecification { + friend class PeriodicHelper; + public: SetSpecification(dp::sid_t structureId, size_t size, dur_millis_t collectionFrequency, MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE) diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index ab02a630..27919e62 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -28,7 +28,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { public: SerializeElement monitorId; SerializeElement parameterObjectId; - SerializeElement localPoolId; + SerializeElement localPoolId; SerializeElement parameterValue; SerializeElement limitValue; SerializeElement oldState; diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 950b96b8..7dcd010c 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -4,8 +4,7 @@ target_sources(${FSFW_TEST_TGT} PRIVATE CatchDefinitions.cpp CatchFactory.cpp target_sources(${FSFW_TEST_TGT} PRIVATE CatchRunner.cpp CatchSetup.cpp) add_subdirectory(testcfg) -add_subdirectory(mocks) - +add_subdirectory(mock) add_subdirectory(tcdistributor) add_subdirectory(action) add_subdirectory(power) diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index ffa7af53..b3d2ae1f 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -10,7 +10,7 @@ #include #include -#include "mocks/HkReceiverMock.h" +#include "mock/HkReceiverMock.h" #include "tests/TestsConfig.h" #if FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS == 1 diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 3b22dcee..39b16d6f 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -6,7 +6,7 @@ #include #include -#include "mocks/MessageQueueMock.h" +#include "mock/MessageQueueMock.h" TEST_CASE("Action Helper", "[action]") { ActionHelperOwnerMockBase testDhMock; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index c7ae5225..b6d7ec68 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -10,14 +10,14 @@ #include "fsfw/cfdp/pdu/EofPduCreator.h" #include "fsfw/cfdp/pdu/FileDataCreator.h" #include "fsfw/cfdp/pdu/MetadataPduCreator.h" -#include "mocks/AcceptsTmMock.h" -#include "mocks/EventReportingProxyMock.h" -#include "mocks/FilesystemMock.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/StorageManagerMock.h" -#include "mocks/cfdp/FaultHandlerMock.h" -#include "mocks/cfdp/RemoteConfigTableMock.h" -#include "mocks/cfdp/UserMock.h" +#include "mock/AcceptsTmMock.h" +#include "mock/EventReportingProxyMock.h" +#include "mock/FilesystemMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/StorageManagerMock.h" +#include "mock/cfdp/FaultHandlerMock.h" +#include "mock/cfdp/RemoteConfigTableMock.h" +#include "mock/cfdp/UserMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; diff --git a/unittests/cfdp/handler/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp index f6685c89..dd8d996d 100644 --- a/unittests/cfdp/handler/testDistributor.cpp +++ b/unittests/cfdp/handler/testDistributor.cpp @@ -5,9 +5,9 @@ #include "fsfw/cfdp/tlv/StringLv.h" #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tcdistribution/definitions.h" -#include "mocks/AcceptsTcMock.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/StorageManagerMock.h" +#include "mock/AcceptsTcMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/StorageManagerMock.h" TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp index 5da9a70d..9770f71c 100644 --- a/unittests/cfdp/handler/testFaultHandler.cpp +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -1,6 +1,6 @@ #include -#include "mocks/cfdp/FaultHandlerMock.h" +#include "mock/cfdp/FaultHandlerMock.h" TEST_CASE("CFDP Fault Handler", "[cfdp]") { using namespace cfdp; diff --git a/unittests/cfdp/handler/testReservedMsgParser.cpp b/unittests/cfdp/handler/testReservedMsgParser.cpp index 85aad8a2..3e70acba 100644 --- a/unittests/cfdp/handler/testReservedMsgParser.cpp +++ b/unittests/cfdp/handler/testReservedMsgParser.cpp @@ -10,8 +10,8 @@ #include "fsfw/cfdp/tlv/StringLv.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serialize.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/StorageManagerMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/StorageManagerMock.h" TEST_CASE("Reserved Message Parser", "[cfdp]") { using namespace cfdp; diff --git a/unittests/cfdp/handler/testSourceHandler.cpp b/unittests/cfdp/handler/testSourceHandler.cpp index 671a7508..17dc3849 100644 --- a/unittests/cfdp/handler/testSourceHandler.cpp +++ b/unittests/cfdp/handler/testSourceHandler.cpp @@ -15,14 +15,14 @@ #include "fsfw/cfdp/pdu/MetadataPduReader.h" #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/util/SeqCountProvider.h" -#include "mocks/AcceptsTmMock.h" -#include "mocks/EventReportingProxyMock.h" -#include "mocks/FilesystemMock.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/StorageManagerMock.h" -#include "mocks/cfdp/FaultHandlerMock.h" -#include "mocks/cfdp/RemoteConfigTableMock.h" -#include "mocks/cfdp/UserMock.h" +#include "mock/AcceptsTmMock.h" +#include "mock/EventReportingProxyMock.h" +#include "mock/FilesystemMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/StorageManagerMock.h" +#include "mock/cfdp/FaultHandlerMock.h" +#include "mock/cfdp/RemoteConfigTableMock.h" +#include "mock/cfdp/UserMock.h" TEST_CASE("CFDP Source Handler", "[cfdp]") { using namespace cfdp; diff --git a/unittests/datapoollocal/testDataSet.cpp b/unittests/datapoollocal/testDataSet.cpp index 93fc2e1d..34a10637 100644 --- a/unittests/datapoollocal/testDataSet.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -7,29 +7,30 @@ #include #include "CatchDefinitions.h" -#include "mocks/LocalPoolOwnerBase.h" -#include "mocks/MessageQueueMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/TestPoolOwner.h" #include "tests/TestsConfig.h" using namespace returnvalue; +using namespace lpool; TEST_CASE("DataSetTest", "[DataSetTest]") { auto queue = MessageQueueMock(1); - LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + TestPoolOwner poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); poolOwner.initialize(); - LocalPoolStaticTestDataSet localSet; + StaticTestDataSet localSet; SECTION("BasicTest") { /* Test some basic functions */ CHECK(localSet.getReportingEnabled() == false); - CHECK(localSet.getLocalPoolIdsSerializedSize(false) == 3 * sizeof(lp_id_t)); - CHECK(localSet.getLocalPoolIdsSerializedSize(true) == 3 * sizeof(lp_id_t) + sizeof(uint8_t)); + CHECK(localSet.getLocalPoolIdsSerializedSize(false) == 3 * sizeof(dp::id_t)); + CHECK(localSet.getLocalPoolIdsSerializedSize(true) == 3 * sizeof(dp::id_t) + sizeof(uint8_t)); CHECK(localSet.getSid() == lpool::testSid0); CHECK(localSet.getCreatorObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); size_t maxSize = localSet.getLocalPoolIdsSerializedSize(true); uint8_t localPoolIdBuff[maxSize]; // Skip size field - auto* lpIds = reinterpret_cast(localPoolIdBuff + 1); + auto* lpIds = reinterpret_cast(localPoolIdBuff + 1); size_t serSize = 0; auto* localPoolIdBuffPtr = reinterpret_cast(localPoolIdBuff); @@ -42,7 +43,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { CHECK(lpIds[1] == localSet.localPoolVarFloat.getDataPoolId()); CHECK(lpIds[2] == localSet.localPoolUint16Vec.getDataPoolId()); // Now serialize without fill count - lpIds = reinterpret_cast(localPoolIdBuff); + lpIds = reinterpret_cast(localPoolIdBuff); localPoolIdBuffPtr = localPoolIdBuff; serSize = 0; CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, @@ -125,26 +126,15 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { CHECK(localSet.localPoolUint16Vec.value[1] == 0); CHECK(localSet.localPoolUint16Vec.value[2] == 0); } - - /* Common fault test cases */ - LocalPoolObjectBase* variableHandle = poolOwner.getPoolObjectHandle(lpool::uint32VarId); - CHECK(variableHandle != nullptr); - CHECK(localSet.registerVariable(variableHandle) == static_cast(DataSetIF::DATA_SET_FULL)); - variableHandle = nullptr; - REQUIRE(localSet.registerVariable(variableHandle) == - static_cast(DataSetIF::POOL_VAR_NULL)); } SECTION("SharedDataSet") { object_id_t sharedSetId = objects::SHARED_SET_ID; - SharedLocalDataset sharedSet(sharedSetId, poolOwner.sharedPool, lpool::testSetId0, 5); + SharedSet sharedSet(poolOwner.sharedPool, sharedSetId, 5); localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE); localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE); CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == returnvalue::OK); - CHECK(sharedSet.initialize() == returnvalue::OK); - CHECK(sharedSet.lockDataset() == returnvalue::OK); - CHECK(sharedSet.unlockDataset() == returnvalue::OK); { PoolReadGuard rg(&sharedSet); diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index 06fc3744..e465bb17 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #include #include @@ -12,8 +10,10 @@ #include #include "CatchDefinitions.h" -#include "mocks/HkReceiverMock.h" -#include "mocks/LocalPoolOwnerBase.h" +#include "mock/HkReceiverMock.h" +#include "mock/TestPoolOwner.h" + +using namespace lpool; TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { const MessageQueueId_t defaultDestId = 1; @@ -21,7 +21,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { const MessageQueueId_t subscriberId = 2; auto hkReceiver = HkReceiverMock(hkDest); auto queue = MessageQueueMock(3); - LocalPoolOwnerBase poolOwner(queue, hkDest, objects::TEST_LOCAL_POOL_OWNER_BASE); + TestPoolOwner poolOwner(queue, hkDest, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initialize() == returnvalue::OK); @@ -32,7 +32,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { SECTION("Basic Test") { { // For code coverage, should not crash - PeriodicHkGenerationHelper manager(nullptr, nullptr); + hk::PeriodicHelper manager(nullptr, nullptr); } auto owner = poolOwner.hkHelper.getOwner(); REQUIRE(owner != nullptr); diff --git a/unittests/datapoollocal/testLocalPoolVariable.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp index 8b344141..cc805ecf 100644 --- a/unittests/datapoollocal/testLocalPoolVariable.cpp +++ b/unittests/datapoollocal/testLocalPoolVariable.cpp @@ -1,23 +1,24 @@ -#include +#include #include #include #include "CatchDefinitions.h" -#include "mocks/LocalPoolOwnerBase.h" +#include "mock/TestPoolOwner.h" #include "tests/TestsConfig.h" using namespace returnvalue; +using namespace lpool; +using namespace dp; TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { auto queue = MessageQueueMock(1); - LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + lpool::TestPoolOwner poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initialize() == OK); SECTION("Basic Tests") { /* very basic test. */ - lp_var_t testVariable = - lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + u8_t testVariable{objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId}; REQUIRE(testVariable.read() == returnvalue::OK); CHECK(testVariable.value == 0); testVariable.value = 5; @@ -34,8 +35,8 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { CHECK(testVariable.getDataPoolId() == 22); testVariable.setDataPoolId(lpool::uint8VarId); - gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - lp_var_t testVariable2 = lp_var_t(globPoolId); + g_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + u8_t testVariable2{globPoolId}; REQUIRE(testVariable2.read() == returnvalue::OK); CHECK(testVariable2 == 5); CHECK(testVariable == testVariable2); @@ -70,32 +71,30 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { SECTION("ErrorHandling") { /* now try to use a local pool variable which does not exist */ - lp_var_t invalidVariable = - lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); - REQUIRE(invalidVariable.read() == static_cast(localpool::POOL_ENTRY_NOT_FOUND)); + dp::u8_t invalidVariable{objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff}; + REQUIRE(invalidVariable.read() == static_cast(POOL_ENTRY_NOT_FOUND)); - REQUIRE(invalidVariable.commit() == static_cast(localpool::POOL_ENTRY_NOT_FOUND)); + REQUIRE(invalidVariable.commit() == static_cast(POOL_ENTRY_NOT_FOUND)); /* now try to access with wrong type */ - lp_var_t invalidVariable2 = - lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(invalidVariable2.read() == static_cast(localpool::POOL_ENTRY_TYPE_CONFLICT)); + dp::i8_t invalidVariable2 = dp::i8_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + REQUIRE(invalidVariable2.read() == static_cast(POOL_ENTRY_TYPE_CONFLICT)); - lp_var_t readOnlyVar = lp_var_t( + dp::var_t readOnlyVar = dp::var_t( objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId, nullptr, pool_rwm_t::VAR_READ); REQUIRE(readOnlyVar.commit() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); - lp_var_t writeOnlyVar = lp_var_t( + dp::var_t writeOnlyVar = dp::var_t( objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId, nullptr, pool_rwm_t::VAR_WRITE); REQUIRE(writeOnlyVar.read() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); - lp_var_t uint32tVar = - lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId); + dp::var_t uint32tVar = + dp::var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "LocalPoolVariable printout: " << uint32tVar << std::endl; #endif /* for code coverage. If program does not crash -> OK */ - lp_var_t invalidObjectVar = lp_var_t(0xffffffff, lpool::uint8VarId); - gp_id_t globPoolId(0xffffffff, lpool::uint8VarId); - lp_var_t invalidObjectVar2 = lp_var_t(globPoolId); + dp::var_t invalidObjectVar = dp::var_t(0xffffffff, lpool::uint8VarId); + dp::g_id_t globPoolId(0xffffffff, lpool::uint8VarId); + dp::var_t invalidObjectVar2 = dp::var_t(globPoolId); } } diff --git a/unittests/datapoollocal/testLocalPoolVector.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp index a3ce3f55..30bb51d5 100644 --- a/unittests/datapoollocal/testLocalPoolVector.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -1,30 +1,30 @@ -#include #include #include #include "CatchDefinitions.h" -#include "mocks/LocalPoolOwnerBase.h" +#include "mock/TestPoolOwner.h" #include "tests/TestsConfig.h" using namespace returnvalue; +using namespace dp; +using namespace lpool; TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { auto queue = MessageQueueMock(1); - LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + lpool::TestPoolOwner poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initialize() == OK); SECTION("BasicTest") { // very basic test. - lp_vec_t testVector = - lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); + vec_t testVector = + vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); REQUIRE(testVector.read() == returnvalue::OK); testVector.value[0] = 5; testVector.value[1] = 232; testVector.value[2] = 32023; - REQUIRE(testVector.commit(true) == returnvalue::OK); - // CHECK(testVector.isValid()); + REQUIRE(testVector.commit() == returnvalue::OK); testVector.value[0] = 0; testVector.value[1] = 0; @@ -44,7 +44,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { CHECK(testVector.commit() == returnvalue::OK); /* Use read-only reference. */ - const lp_vec_t& roTestVec = testVector; + const dp::vec_t& roTestVec = testVector; uint16_t valueOne = roTestVec[0]; CHECK(valueOne == 5); @@ -55,7 +55,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { CHECK(maxSize == 6); uint16_t serializedVector[3]; - uint8_t* vecPtr = reinterpret_cast(serializedVector); + auto* vecPtr = reinterpret_cast(serializedVector); size_t serSize = 0; REQUIRE(testVector.serialize(&vecPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == returnvalue::OK); @@ -73,7 +73,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { serializedVector[1] = 7832; serializedVector[2] = 39232; - const uint8_t* constVecPtr = reinterpret_cast(serializedVector); + const auto* constVecPtr = reinterpret_cast(serializedVector); REQUIRE(testVector.deSerialize(&constVecPtr, &serSize, SerializeIF::Endianness::MACHINE) == returnvalue::OK); CHECK(testVector[0] == 16); @@ -87,23 +87,21 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { SECTION("ErrorHandling") { /* Now try to use a local pool variable which does not exist */ - lp_vec_t invalidVector = - lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); - REQUIRE(invalidVector.read() == static_cast(localpool::POOL_ENTRY_NOT_FOUND)); - REQUIRE(invalidVector.commit() == static_cast(localpool::POOL_ENTRY_NOT_FOUND)); + dp::vec_t invalidVector{objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff}; + REQUIRE(invalidVector.read() == static_cast(POOL_ENTRY_NOT_FOUND)); + REQUIRE(invalidVector.commit() == static_cast(POOL_ENTRY_NOT_FOUND)); /* Now try to access with wrong type */ - lp_vec_t invalidVector2 = - lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); - REQUIRE(invalidVector2.read() == static_cast(localpool::POOL_ENTRY_TYPE_CONFLICT)); - REQUIRE(invalidVector2.commit() == static_cast(localpool::POOL_ENTRY_TYPE_CONFLICT)); + dp::vec_t invalidVector2{objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id}; + REQUIRE(invalidVector2.read() == static_cast(POOL_ENTRY_TYPE_CONFLICT)); + REQUIRE(invalidVector2.commit() == static_cast(POOL_ENTRY_TYPE_CONFLICT)); - lp_vec_t writeOnlyVec = lp_vec_t( - objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id, nullptr, pool_rwm_t::VAR_WRITE); + dp::vec_t writeOnlyVec{objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id, + nullptr, pool_rwm_t::VAR_WRITE}; REQUIRE(writeOnlyVec.read() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); - lp_vec_t readOnlyVec = lp_vec_t( - objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id, nullptr, pool_rwm_t::VAR_READ); + dp::vec_t readOnlyVec = {objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id, + nullptr, pool_rwm_t::VAR_READ}; REQUIRE(readOnlyVec.commit() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); } } diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index 3fdaf74b..c3f4df84 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -1,13 +1,13 @@ -#include -#include +#include +#include #include #include "DeviceHandlerCommander.h" -#include "mocks/ComIFMock.h" -#include "mocks/CookieIFMock.h" -#include "mocks/DeviceFdirMock.h" -#include "mocks/DeviceHandlerMock.h" +#include "mock/ComIFMock.h" +#include "mock/CookieIFMock.h" +#include "mock/DeviceFdirMock.h" +#include "mock/DeviceHandlerMock.h" #include "objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { diff --git a/unittests/hal/testFsMock.cpp b/unittests/hal/testFsMock.cpp index ac69441a..2f1caeb5 100644 --- a/unittests/hal/testFsMock.cpp +++ b/unittests/hal/testFsMock.cpp @@ -1,7 +1,7 @@ #include #include "fsfw/serialize/SerializeIF.h" -#include "mocks/FilesystemMock.h" +#include "mock/FilesystemMock.h" using namespace std; diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index c1aa666a..45e8867b 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -13,7 +13,7 @@ #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/objectmanager/frameworkObjects.h" -#include "mocks/PeriodicTaskIFMock.h" +#include "mock/PeriodicTaskIFMock.h" TEST_CASE("Internal Error Reporter", "[TestInternalError]") { PeriodicTaskMock task(10, nullptr); diff --git a/unittests/mocks/AcceptsTcMock.cpp b/unittests/mock/AcceptsTcMock.cpp similarity index 100% rename from unittests/mocks/AcceptsTcMock.cpp rename to unittests/mock/AcceptsTcMock.cpp diff --git a/unittests/mocks/AcceptsTcMock.h b/unittests/mock/AcceptsTcMock.h similarity index 100% rename from unittests/mocks/AcceptsTcMock.h rename to unittests/mock/AcceptsTcMock.h diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mock/AcceptsTmMock.cpp similarity index 100% rename from unittests/mocks/AcceptsTmMock.cpp rename to unittests/mock/AcceptsTmMock.cpp diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mock/AcceptsTmMock.h similarity index 100% rename from unittests/mocks/AcceptsTmMock.h rename to unittests/mock/AcceptsTmMock.h diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mock/CMakeLists.txt similarity index 94% rename from unittests/mocks/CMakeLists.txt rename to unittests/mock/CMakeLists.txt index bd093da8..89023b0d 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mock/CMakeLists.txt @@ -7,7 +7,6 @@ target_sources( ComIFMock.cpp MessageQueueMock.cpp InternalErrorReporterMock.cpp - LocalPoolOwnerBase.cpp PusVerificationReporterMock.cpp PusServiceBaseMock.cpp AcceptsTmMock.cpp @@ -16,6 +15,7 @@ target_sources( AcceptsTcMock.cpp StorageManagerMock.cpp FilesystemMock.cpp + TestPoolOwner.cpp EventReportingProxyMock.cpp) add_subdirectory(cfdp) diff --git a/unittests/mocks/CcsdsCheckerMock.cpp b/unittests/mock/CcsdsCheckerMock.cpp similarity index 100% rename from unittests/mocks/CcsdsCheckerMock.cpp rename to unittests/mock/CcsdsCheckerMock.cpp diff --git a/unittests/mocks/CcsdsCheckerMock.h b/unittests/mock/CcsdsCheckerMock.h similarity index 100% rename from unittests/mocks/CcsdsCheckerMock.h rename to unittests/mock/CcsdsCheckerMock.h diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mock/CdsShortTimestamperMock.h similarity index 100% rename from unittests/mocks/CdsShortTimestamperMock.h rename to unittests/mock/CdsShortTimestamperMock.h diff --git a/unittests/mocks/ComIFMock.cpp b/unittests/mock/ComIFMock.cpp similarity index 100% rename from unittests/mocks/ComIFMock.cpp rename to unittests/mock/ComIFMock.cpp diff --git a/unittests/mocks/ComIFMock.h b/unittests/mock/ComIFMock.h similarity index 100% rename from unittests/mocks/ComIFMock.h rename to unittests/mock/ComIFMock.h diff --git a/unittests/mocks/CookieIFMock.cpp b/unittests/mock/CookieIFMock.cpp similarity index 100% rename from unittests/mocks/CookieIFMock.cpp rename to unittests/mock/CookieIFMock.cpp diff --git a/unittests/mocks/CookieIFMock.h b/unittests/mock/CookieIFMock.h similarity index 100% rename from unittests/mocks/CookieIFMock.h rename to unittests/mock/CookieIFMock.h diff --git a/unittests/mocks/DeviceFdirMock.cpp b/unittests/mock/DeviceFdirMock.cpp similarity index 100% rename from unittests/mocks/DeviceFdirMock.cpp rename to unittests/mock/DeviceFdirMock.cpp diff --git a/unittests/mocks/DeviceFdirMock.h b/unittests/mock/DeviceFdirMock.h similarity index 100% rename from unittests/mocks/DeviceFdirMock.h rename to unittests/mock/DeviceFdirMock.h diff --git a/unittests/mocks/DeviceHandlerMock.cpp b/unittests/mock/DeviceHandlerMock.cpp similarity index 92% rename from unittests/mocks/DeviceHandlerMock.cpp rename to unittests/mock/DeviceHandlerMock.cpp index 90c1169a..bb8b748c 100644 --- a/unittests/mocks/DeviceHandlerMock.cpp +++ b/unittests/mock/DeviceHandlerMock.cpp @@ -109,14 +109,13 @@ ReturnValue_t DeviceHandlerMock::initialize() { return result; } -ReturnValue_t DeviceHandlerMock::serializeHkDataset(structure_id_t structureId, uint8_t *buf, +ReturnValue_t DeviceHandlerMock::serializeHkDataset(dp::structure_id_t structureId, uint8_t *buf, size_t maxSize) { return returnvalue::OK; } -ReturnValue_t DeviceHandlerMock::specifyHkDatasets( - std::vector &setList) { +ReturnValue_t DeviceHandlerMock::specifyHkDatasets(std::vector &setList) { return returnvalue::OK; } -localpool::SharedPool *DeviceHandlerMock::getOptionalSharedPool() { return nullptr; } +dp::SharedPool *DeviceHandlerMock::getOptionalSharedPool() { return nullptr; } diff --git a/unittests/mocks/DeviceHandlerMock.h b/unittests/mock/DeviceHandlerMock.h similarity index 87% rename from unittests/mocks/DeviceHandlerMock.h rename to unittests/mock/DeviceHandlerMock.h index 936a1fd4..23690687 100644 --- a/unittests/mocks/DeviceHandlerMock.h +++ b/unittests/mock/DeviceHandlerMock.h @@ -23,11 +23,12 @@ class DeviceHandlerMock : public DeviceHandlerBase { ReturnValue_t initialize() override; - ReturnValue_t serializeHkDataset(sid_t structureId, uint8_t *buf, size_t maxSize) override; + ReturnValue_t serializeHkDataset(dp::structure_id_t structureId, uint8_t *buf, + size_t maxSize) override; - ReturnValue_t specifyHkDatasets(std::vector &setList) override; + ReturnValue_t specifyHkDatasets(std::vector &setList) override; - localpool::SharedPool *getOptionalSharedPool() override; + dp::SharedPool *getOptionalSharedPool() override; protected: void doStartUp() override; diff --git a/unittests/mocks/EventReportingProxyMock.cpp b/unittests/mock/EventReportingProxyMock.cpp similarity index 100% rename from unittests/mocks/EventReportingProxyMock.cpp rename to unittests/mock/EventReportingProxyMock.cpp diff --git a/unittests/mocks/EventReportingProxyMock.h b/unittests/mock/EventReportingProxyMock.h similarity index 100% rename from unittests/mocks/EventReportingProxyMock.h rename to unittests/mock/EventReportingProxyMock.h diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mock/FilesystemMock.cpp similarity index 100% rename from unittests/mocks/FilesystemMock.cpp rename to unittests/mock/FilesystemMock.cpp diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mock/FilesystemMock.h similarity index 100% rename from unittests/mocks/FilesystemMock.h rename to unittests/mock/FilesystemMock.h diff --git a/unittests/mocks/HkReceiverMock.h b/unittests/mock/HkReceiverMock.h similarity index 100% rename from unittests/mocks/HkReceiverMock.h rename to unittests/mock/HkReceiverMock.h diff --git a/unittests/mocks/InternalErrorReporterMock.cpp b/unittests/mock/InternalErrorReporterMock.cpp similarity index 100% rename from unittests/mocks/InternalErrorReporterMock.cpp rename to unittests/mock/InternalErrorReporterMock.cpp diff --git a/unittests/mocks/InternalErrorReporterMock.h b/unittests/mock/InternalErrorReporterMock.h similarity index 100% rename from unittests/mocks/InternalErrorReporterMock.h rename to unittests/mock/InternalErrorReporterMock.h diff --git a/unittests/mocks/MessageQueueMock.cpp b/unittests/mock/MessageQueueMock.cpp similarity index 100% rename from unittests/mocks/MessageQueueMock.cpp rename to unittests/mock/MessageQueueMock.cpp diff --git a/unittests/mocks/MessageQueueMock.h b/unittests/mock/MessageQueueMock.h similarity index 100% rename from unittests/mocks/MessageQueueMock.h rename to unittests/mock/MessageQueueMock.h diff --git a/unittests/mocks/PeriodicTaskIFMock.h b/unittests/mock/PeriodicTaskIFMock.h similarity index 100% rename from unittests/mocks/PeriodicTaskIFMock.h rename to unittests/mock/PeriodicTaskIFMock.h diff --git a/unittests/mocks/PowerSwitcherMock.cpp b/unittests/mock/PowerSwitcherMock.cpp similarity index 100% rename from unittests/mocks/PowerSwitcherMock.cpp rename to unittests/mock/PowerSwitcherMock.cpp diff --git a/unittests/mocks/PowerSwitcherMock.h b/unittests/mock/PowerSwitcherMock.h similarity index 100% rename from unittests/mocks/PowerSwitcherMock.h rename to unittests/mock/PowerSwitcherMock.h diff --git a/unittests/mocks/PusDistributorMock.cpp b/unittests/mock/PusDistributorMock.cpp similarity index 100% rename from unittests/mocks/PusDistributorMock.cpp rename to unittests/mock/PusDistributorMock.cpp diff --git a/unittests/mocks/PusDistributorMock.h b/unittests/mock/PusDistributorMock.h similarity index 100% rename from unittests/mocks/PusDistributorMock.h rename to unittests/mock/PusDistributorMock.h diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mock/PusServiceBaseMock.cpp similarity index 100% rename from unittests/mocks/PusServiceBaseMock.cpp rename to unittests/mock/PusServiceBaseMock.cpp diff --git a/unittests/mocks/PusServiceBaseMock.h b/unittests/mock/PusServiceBaseMock.h similarity index 100% rename from unittests/mocks/PusServiceBaseMock.h rename to unittests/mock/PusServiceBaseMock.h diff --git a/unittests/mocks/PusVerificationReporterMock.cpp b/unittests/mock/PusVerificationReporterMock.cpp similarity index 100% rename from unittests/mocks/PusVerificationReporterMock.cpp rename to unittests/mock/PusVerificationReporterMock.cpp diff --git a/unittests/mocks/PusVerificationReporterMock.h b/unittests/mock/PusVerificationReporterMock.h similarity index 100% rename from unittests/mocks/PusVerificationReporterMock.h rename to unittests/mock/PusVerificationReporterMock.h diff --git a/unittests/mocks/SimpleSerializable.h b/unittests/mock/SimpleSerializable.h similarity index 100% rename from unittests/mocks/SimpleSerializable.h rename to unittests/mock/SimpleSerializable.h diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mock/StorageManagerMock.cpp similarity index 100% rename from unittests/mocks/StorageManagerMock.cpp rename to unittests/mock/StorageManagerMock.cpp diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mock/StorageManagerMock.h similarity index 100% rename from unittests/mocks/StorageManagerMock.h rename to unittests/mock/StorageManagerMock.h diff --git a/unittests/mock/TestPoolOwner.cpp b/unittests/mock/TestPoolOwner.cpp new file mode 100644 index 00000000..cd10568e --- /dev/null +++ b/unittests/mock/TestPoolOwner.cpp @@ -0,0 +1,75 @@ +#include "TestPoolOwner.h" + +#include + +using namespace lpool; + +TestPoolOwner::TestPoolOwner(MessageQueueIF &queue, MessageQueueId_t hkDestId, object_id_t objectId) + : SystemObject(objectId), + hkHelper(this, &queue, hkDestId), + sharedPool(TestPoolOwner::getObjectId()), + set1(sharedPool, lpool::testSetId1), + set2(sharedPool, lpool::testSetId2), + queue(queue) {} + +TestPoolOwner::~TestPoolOwner() = default; + +ReturnValue_t TestPoolOwner::initialize() { + sharedPool.addPoolEntry(lpool::uint8VarId, &u8PoolEntry); + sharedPool.addPoolEntry(lpool::floatVarId, &floatPoolEntry); + sharedPool.addPoolEntry(lpool::uint32VarId, &u32PoolEntry); + sharedPool.addPoolEntry(lpool::uint16Vec3Id, &u16VecPoolEntry); + sharedPool.addPoolEntry(lpool::int64Vec2Id, &i64VecPoolEntry); + ReturnValue_t result = hkHelper.initialize(&queue); + if (result != returnvalue::OK) { + return result; + } + return SystemObject::initialize(); +} + +SharedPool *TestPoolOwner::getOptionalSharedPool() { return &sharedPool; } + +ReturnValue_t TestPoolOwner::serializeHkDataset(structure_id_t structureId, uint8_t *buf, + size_t maxSize) { + return returnvalue::OK; +} + +ReturnValue_t TestPoolOwner::specifyHkDatasets(std::vector &setList) { + return returnvalue::OK; +} + +ReturnValue_t TestPoolOwner::reset() { + ReturnValue_t status = returnvalue::OK; + { + PoolReadGuard readHelper(&set1); + if (readHelper.getReadResult() != returnvalue::OK) { + status = readHelper.getReadResult(); + } + set1.localPoolVarUint8.value = 0; + set1.localPoolVarFloat.value = 0.0; + set1.localPoolUint16Vec.value[0] = 0; + set1.localPoolUint16Vec.value[1] = 0; + set1.localPoolUint16Vec.value[2] = 0; + // dataset.setValidity(false, true); + } + + { + PoolReadGuard readHelper(&testUint32); + if (readHelper.getReadResult() != returnvalue::OK) { + status = readHelper.getReadResult(); + } + testUint32.value = 0; + } + + { + PoolReadGuard readHelper(&testInt64Vec); + if (readHelper.getReadResult() != returnvalue::OK) { + status = readHelper.getReadResult(); + } + testInt64Vec.value[0] = 0; + testInt64Vec.value[1] = 0; + } + return status; +} + +void TestPoolOwner::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); } diff --git a/unittests/mock/TestPoolOwner.h b/unittests/mock/TestPoolOwner.h new file mode 100644 index 00000000..b1a2b9f7 --- /dev/null +++ b/unittests/mock/TestPoolOwner.h @@ -0,0 +1,64 @@ +#pragma once +#include +#include + +#include "poolDefinitions.h" + +namespace lpool { + +class TestPoolOwner : public SystemObject, public hk::GeneratesPeriodicHkIF { + public: + explicit TestPoolOwner(MessageQueueIF& queue, MessageQueueId_t hkDestId, + object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE); + + ~TestPoolOwner() override; + + [[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); } + + ReturnValue_t serializeHkDataset(structure_id_t structureId, uint8_t* buf, + size_t maxSize) override; + + ReturnValue_t specifyHkDatasets(std::vector& setList) override; + + SharedPool* getOptionalSharedPool() override; + ReturnValue_t initialize() override; + + void setHkDestId(MessageQueueId_t id); + + /** Command queue for housekeeping messages. */ + [[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); } + + [[nodiscard]] MessageQueueMock& getMockQueueHandle() const { + return dynamic_cast(queue); + } + + ReturnValue_t subscribePeriodicHk(bool enableReporting) { + return hkHelper.enablePeriodicPacket(lpool::testSid0, 50); + } + + ReturnValue_t reset(); + + hk::PeriodicHelper hkHelper; + SharedPool sharedPool; + LocalPoolTestDataSet set1; + StaticTestDataSet set2; + + private: + PoolEntry u8PoolEntry = PoolEntry({0}); + PoolEntry floatPoolEntry = PoolEntry({0}); + PoolEntry u32PoolEntry = PoolEntry({0}); + PoolEntry u16VecPoolEntry = PoolEntry({0, 0, 0}); + PoolEntry i64VecPoolEntry = PoolEntry({0, 0}); + + dp::u8_t testUint8{sharedPool, lpool::uint8VarId}; + dp::f32_t testFloat{sharedPool, lpool::floatVarId}; + dp::u32_t testUint32{sharedPool, lpool::uint32VarId}; + vec_t testUint16Vec{sharedPool, lpool::uint16Vec3Id}; + vec_t testInt64Vec{sharedPool, lpool::int64Vec2Id}; + + MessageQueueIF& queue; + + bool initialized = false; + bool initializedAfterTaskCreation = false; +}; +} // namespace lpool \ No newline at end of file diff --git a/unittests/mocks/cfdp/CMakeLists.txt b/unittests/mock/cfdp/CMakeLists.txt similarity index 100% rename from unittests/mocks/cfdp/CMakeLists.txt rename to unittests/mock/cfdp/CMakeLists.txt diff --git a/unittests/mocks/cfdp/FaultHandlerMock.cpp b/unittests/mock/cfdp/FaultHandlerMock.cpp similarity index 100% rename from unittests/mocks/cfdp/FaultHandlerMock.cpp rename to unittests/mock/cfdp/FaultHandlerMock.cpp diff --git a/unittests/mocks/cfdp/FaultHandlerMock.h b/unittests/mock/cfdp/FaultHandlerMock.h similarity index 100% rename from unittests/mocks/cfdp/FaultHandlerMock.h rename to unittests/mock/cfdp/FaultHandlerMock.h diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.cpp b/unittests/mock/cfdp/RemoteConfigTableMock.cpp similarity index 100% rename from unittests/mocks/cfdp/RemoteConfigTableMock.cpp rename to unittests/mock/cfdp/RemoteConfigTableMock.cpp diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.h b/unittests/mock/cfdp/RemoteConfigTableMock.h similarity index 100% rename from unittests/mocks/cfdp/RemoteConfigTableMock.h rename to unittests/mock/cfdp/RemoteConfigTableMock.h diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mock/cfdp/UserMock.cpp similarity index 100% rename from unittests/mocks/cfdp/UserMock.cpp rename to unittests/mock/cfdp/UserMock.cpp diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mock/cfdp/UserMock.h similarity index 100% rename from unittests/mocks/cfdp/UserMock.h rename to unittests/mock/cfdp/UserMock.h diff --git a/unittests/mock/poolDefinitions.h b/unittests/mock/poolDefinitions.h new file mode 100644 index 00000000..6d750235 --- /dev/null +++ b/unittests/mock/poolDefinitions.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include +#include + +#include "fsfw/datapool/PoolEntry.h" +#include "mock/MessageQueueMock.h" +#include "tests/TestsConfig.h" + +namespace lpool { + +using namespace dp; + +static constexpr id_t uint8VarId = 0; +static constexpr id_t floatVarId = 1; +static constexpr id_t uint32VarId = 2; +static constexpr id_t uint16Vec3Id = 3; +static constexpr id_t int64Vec2Id = 4; + +static constexpr uint32_t testSetId0 = 0; +static constexpr uint32_t testSetId1 = 1; +static constexpr uint32_t testSetId2 = 2; +static constexpr uint8_t dataSetMaxVariables = 10; + +static const auto testSid0 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId0); +static const auto testSid1 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId1); +static const auto testSid2 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId2); + +static const g_id_t uint8VarGpid = g_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint8VarId); +static const g_id_t floatVarGpid = g_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, floatVarId); +static const g_id_t uint32Gpid = g_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint32VarId); +static const g_id_t uint16Vec3Gpid = g_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint16Vec3Id); +static const g_id_t uint64Vec2Id = g_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, int64Vec2Id); + +class StaticTestDataSet : public StaticSharedSet<3> { + public: + StaticTestDataSet() : StaticSharedSet(lpool::testSid1) {} + + StaticTestDataSet(SharedPool& sharedPool, uint32_t setId) : StaticSharedSet(sharedPool, setId) {} + + u8_t localPoolVarUint8{lpool::uint8VarGpid, this}; + f32_t localPoolVarFloat{lpool::floatVarGpid, this}; + vec_t localPoolUint16Vec{lpool::uint16Vec3Gpid, this}; + + private: +}; + +class LocalPoolTestDataSet : public SharedSet { + public: + LocalPoolTestDataSet() : SharedSet(lpool::testSid2, lpool::dataSetMaxVariables) {} + + LocalPoolTestDataSet(SharedPool& sharedPool, uint32_t setId) + : SharedSet(sharedPool, setId, lpool::dataSetMaxVariables) {} + + u8_t localPoolVarUint8{lpool::uint8VarGpid, this}; + f32_t localPoolVarFloat{lpool::floatVarGpid, this}; + vec_t localPoolUint16Vec{lpool::uint16Vec3Gpid, this}; + + private: +}; + +} // namespace lpool \ No newline at end of file diff --git a/unittests/mocks/LocalPoolOwnerBase.cpp b/unittests/mocks/LocalPoolOwnerBase.cpp deleted file mode 100644 index 6f29f472..00000000 --- a/unittests/mocks/LocalPoolOwnerBase.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "LocalPoolOwnerBase.h" - -#include - -LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, MessageQueueId_t hkDestId, - object_id_t objectId) - : SystemObject(objectId), - hkHelper(this, &queue, hkDestId), - sharedPool(LocalPoolOwnerBase::getObjectId()), - set1(sharedPool, lpool::testSetId1), - set2(sharedPool, lpool::testSetId2), - queue(queue) {} - -LocalPoolOwnerBase::~LocalPoolOwnerBase() = default; - -ReturnValue_t LocalPoolOwnerBase::initialize() { - sharedPool.addPoolEntry(lpool::uint8VarId, &u8PoolEntry); - sharedPool.addPoolEntry(lpool::floatVarId, &floatPoolEntry); - sharedPool.addPoolEntry(lpool::uint32VarId, &u32PoolEntry); - sharedPool.addPoolEntry(lpool::uint16Vec3Id, &u16VecPoolEntry); - sharedPool.addPoolEntry(lpool::int64Vec2Id, &i64VecPoolEntry); - ReturnValue_t result = hkHelper.initialize(&queue); - if (result != returnvalue::OK) { - return result; - } - return SystemObject::initialize(); -} - -localpool::SharedPool *LocalPoolOwnerBase::getOptionalSharedPool() { return &sharedPool; } - -ReturnValue_t LocalPoolOwnerBase::serializeHkDataset(structure_id_t structureId, uint8_t *buf, - size_t maxSize) { - return returnvalue::OK; -} - -ReturnValue_t LocalPoolOwnerBase::specifyHkDatasets( - std::vector &setList) { - return returnvalue::OK; -} - -/* -ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - PeriodicHkGenerationHelper &poolManager) { - // Default initialization empty for now. - localDataPoolMap.emplace(lpool::uint8VarId, &u8PoolEntry); - localDataPoolMap.emplace(lpool::floatVarId, &floatPoolEntry); - localDataPoolMap.emplace(lpool::uint32VarId, &u32PoolEntry); - - localDataPoolMap.emplace(lpool::uint16Vec3Id, &u16VecPoolEntry); - localDataPoolMap.emplace(lpool::int64Vec2Id, &i64VecPoolEntry); - return returnvalue::OK; -} - */ - -LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId) { - if (localPoolId == lpool::uint8VarId) { - return &testUint8; - } else if (localPoolId == lpool::uint16Vec3Id) { - return &testUint16Vec; - } else if (localPoolId == lpool::floatVarId) { - return &testFloat; - } else if (localPoolId == lpool::int64Vec2Id) { - return &testInt64Vec; - } else if (localPoolId == lpool::uint32VarId) { - return &testUint32; - } else { - return &testUint8; - } -} - -ReturnValue_t LocalPoolOwnerBase::reset() { - // resetSubscriptionList(); - ReturnValue_t status = returnvalue::OK; - { - PoolReadGuard readHelper(&set1); - if (readHelper.getReadResult() != returnvalue::OK) { - status = readHelper.getReadResult(); - } - set1.localPoolVarUint8.value = 0; - set1.localPoolVarFloat.value = 0.0; - set1.localPoolUint16Vec.value[0] = 0; - set1.localPoolUint16Vec.value[1] = 0; - set1.localPoolUint16Vec.value[2] = 0; - // dataset.setValidity(false, true); - } - - { - PoolReadGuard readHelper(&testUint32); - if (readHelper.getReadResult() != returnvalue::OK) { - status = readHelper.getReadResult(); - } - testUint32.value = 0; - // testUint32.setValid(false); - } - - { - PoolReadGuard readHelper(&testInt64Vec); - if (readHelper.getReadResult() != returnvalue::OK) { - status = readHelper.getReadResult(); - } - testInt64Vec.value[0] = 0; - testInt64Vec.value[1] = 0; - // testInt64Vec.setValid(false); - } - return status; -} - -void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); } diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h deleted file mode 100644 index fbfb76ff..00000000 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ -#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include "fsfw/datapool/PoolEntry.h" -#include "mocks/MessageQueueMock.h" -#include "tests/TestsConfig.h" - -namespace lpool { -static constexpr lp_id_t uint8VarId = 0; -static constexpr lp_id_t floatVarId = 1; -static constexpr lp_id_t uint32VarId = 2; -static constexpr lp_id_t uint16Vec3Id = 3; -static constexpr lp_id_t int64Vec2Id = 4; - -static constexpr uint32_t testSetId0 = 0; -static constexpr uint32_t testSetId1 = 1; -static constexpr uint32_t testSetId2 = 2; -static constexpr uint8_t dataSetMaxVariables = 10; - -static const auto testSid0 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId0); -static const auto testSid1 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId1); -static const auto testSid2 = structure_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId2); - -static const gp_id_t uint8VarGpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint8VarId); -static const gp_id_t floatVarGpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, floatVarId); -static const gp_id_t uint32Gpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint32VarId); -static const gp_id_t uint16Vec3Gpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, uint16Vec3Id); -static const gp_id_t uint64Vec2Id = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, int64Vec2Id); -} // namespace lpool - -class LocalPoolStaticTestDataSet : public StaticSharedDataset<3> { - public: - LocalPoolStaticTestDataSet() : StaticSharedDataset(lpool::testSid1) {} - - LocalPoolStaticTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId) - : StaticSharedDataset(sharedPool, setId) {} - - lp_var_t localPoolVarUint8 = lp_var_t(lpool::uint8VarGpid, this); - lp_var_t localPoolVarFloat = lp_var_t(lpool::floatVarGpid, this); - lp_vec_t localPoolUint16Vec = lp_vec_t(lpool::uint16Vec3Gpid, this); - - private: -}; - -class LocalPoolTestDataSet : public SharedDataSet { - public: - LocalPoolTestDataSet() : SharedDataSet(lpool::testSid2, lpool::dataSetMaxVariables) {} - - LocalPoolTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId) - : SharedDataSet(sharedPool, setId, lpool::dataSetMaxVariables) {} - - lp_var_t localPoolVarUint8 = lp_var_t(lpool::uint8VarGpid, this); - lp_var_t localPoolVarFloat = lp_var_t(lpool::floatVarGpid, this); - lp_vec_t localPoolUint16Vec = lp_vec_t(lpool::uint16Vec3Gpid, this); - - private: -}; - -class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF { - public: - explicit LocalPoolOwnerBase(MessageQueueIF& queue, MessageQueueId_t hkDestId, - object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE); - - ~LocalPoolOwnerBase() override; - - [[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); } - - ReturnValue_t serializeHkDataset(structure_id_t structureId, uint8_t* buf, - size_t maxSize) override; - - ReturnValue_t specifyHkDatasets(std::vector& setList) override; - - localpool::SharedPool* getOptionalSharedPool() override; - ReturnValue_t initialize() override; - - void setHkDestId(MessageQueueId_t id); - - /** Command queue for housekeeping messages. */ - [[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); } - - LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override; - - [[nodiscard]] MessageQueueMock& getMockQueueHandle() const { - return dynamic_cast(queue); - } - - ReturnValue_t subscribePeriodicHk(bool enableReporting) { - return hkHelper.enablePeriodicPacket(lpool::testSid0, 50); - } - - ReturnValue_t reset(); - - PeriodicHkGenerationHelper hkHelper; - localpool::SharedPool sharedPool; - LocalPoolTestDataSet set1; - LocalPoolStaticTestDataSet set2; - - private: - PoolEntry u8PoolEntry = PoolEntry({0}); - PoolEntry floatPoolEntry = PoolEntry({0}); - PoolEntry u32PoolEntry = PoolEntry({0}); - PoolEntry u16VecPoolEntry = PoolEntry({0, 0, 0}); - PoolEntry i64VecPoolEntry = PoolEntry({0, 0}); - - lp_var_t testUint8 = lp_var_t(sharedPool, lpool::uint8VarId); - lp_var_t testFloat = lp_var_t(sharedPool, lpool::floatVarId); - lp_var_t testUint32 = lp_var_t(sharedPool, lpool::uint32VarId); - lp_vec_t testUint16Vec = lp_vec_t(sharedPool, lpool::uint16Vec3Id); - lp_vec_t testInt64Vec = lp_vec_t(sharedPool, lpool::int64Vec2Id); - - MessageQueueIF& queue; - - bool initialized = false; - bool initializedAfterTaskCreation = false; -}; - -#endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */ diff --git a/unittests/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp index 222dccf6..11ef6b9d 100644 --- a/unittests/power/testPowerSwitcher.cpp +++ b/unittests/power/testPowerSwitcher.cpp @@ -3,7 +3,7 @@ #include -#include "mocks/PowerSwitcherMock.h" +#include "mock/PowerSwitcherMock.h" #include "objects/systemObjectList.h" TEST_CASE("Power Switcher", "[power-switcher]") { diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 30ad58e5..baa686bf 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -2,7 +2,7 @@ #include #include -#include "mocks/SimpleSerializable.h" +#include "mock/SimpleSerializable.h" using namespace std; diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp index c8aa81f7..c61c6bc4 100644 --- a/unittests/tcdistributor/testCcsdsDistributor.cpp +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -4,9 +4,9 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tcdistribution/CcsdsDistributor.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" -#include "mocks/AcceptsTcMock.h" -#include "mocks/CcsdsCheckerMock.h" -#include "mocks/MessageQueueMock.h" +#include "mock/AcceptsTcMock.h" +#include "mock/CcsdsCheckerMock.h" +#include "mock/MessageQueueMock.h" TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index 58f8cbf9..fd041811 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -3,7 +3,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/tmtcpacket/pus/tc.h" -#include "mocks/SimpleSerializable.h" +#include "mock/SimpleSerializable.h" TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index fc86dcbe..7bc9955f 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -3,8 +3,8 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/tmtcpacket/pus/tm.h" -#include "mocks/CdsShortTimestamperMock.h" -#include "mocks/SimpleSerializable.h" +#include "mock/CdsShortTimestamperMock.h" +#include "mock/SimpleSerializable.h" TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 1180fd23..3e96f935 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -2,7 +2,7 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" #include "fsfw/tmtcpacket/pus/tm/PusTmReader.h" -#include "mocks/CdsShortTimestamperMock.h" +#include "mock/CdsShortTimestamperMock.h" TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); diff --git a/unittests/tmtcpacket/testZcTmWriter.cpp b/unittests/tmtcpacket/testZcTmWriter.cpp index 12e88ea1..b34c8ae1 100644 --- a/unittests/tmtcpacket/testZcTmWriter.cpp +++ b/unittests/tmtcpacket/testZcTmWriter.cpp @@ -3,7 +3,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" -#include "mocks/CdsShortTimestamperMock.h" +#include "mock/CdsShortTimestamperMock.h" TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 93d8aec5..b07cf7b4 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -3,13 +3,13 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/storagemanager/PoolManager.h" -#include "mocks/AcceptsTmMock.h" -#include "mocks/CdsShortTimestamperMock.h" -#include "mocks/InternalErrorReporterMock.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/PusDistributorMock.h" -#include "mocks/PusServiceBaseMock.h" -#include "mocks/PusVerificationReporterMock.h" +#include "mock/AcceptsTmMock.h" +#include "mock/CdsShortTimestamperMock.h" +#include "mock/InternalErrorReporterMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/PusDistributorMock.h" +#include "mock/PusServiceBaseMock.h" +#include "mock/PusVerificationReporterMock.h" TEST_CASE("Pus Service Base", "[pus-service-base]") { uint16_t apid = 2; diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 07315e44..1af33603 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -3,9 +3,9 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmSendHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h" -#include "mocks/CdsShortTimestamperMock.h" -#include "mocks/InternalErrorReporterMock.h" -#include "mocks/MessageQueueMock.h" +#include "mock/CdsShortTimestamperMock.h" +#include "mock/InternalErrorReporterMock.h" +#include "mock/MessageQueueMock.h" TEST_CASE("TM Send Helper", "[tm-send-helper]") { MessageQueueId_t destId = 2; diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 6fe9f8e2..2c23c172 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -4,10 +4,10 @@ #include "fsfw/tmtcservices/TmSendHelper.h" #include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h" -#include "mocks/CdsShortTimestamperMock.h" -#include "mocks/InternalErrorReporterMock.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/SimpleSerializable.h" +#include "mock/CdsShortTimestamperMock.h" +#include "mock/InternalErrorReporterMock.h" +#include "mock/MessageQueueMock.h" +#include "mock/SimpleSerializable.h" TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { auto timeStamper = CdsShortTimestamperMock(); diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index dd73305d..bee92024 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -3,8 +3,8 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmStoreHelper.h" #include "fsfw/tmtcservices/tmHelpers.h" -#include "mocks/CdsShortTimestamperMock.h" -#include "mocks/SimpleSerializable.h" +#include "mock/CdsShortTimestamperMock.h" +#include "mock/SimpleSerializable.h" TEST_CASE("TM Store Helper", "[tm-store-helper]") { auto timeStamper = CdsShortTimestamperMock();