continue refactoring
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
// #include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <fsfw/datapoollocal/SharedLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/SharedLocalDataset.h>
|
||||
#include <fsfw/globalfunctions/bitutility.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
|
||||
@ -26,7 +24,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
|
||||
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.getSid() == lpool::testSid);
|
||||
CHECK(localSet.getSid() == lpool::testSid0);
|
||||
CHECK(localSet.getCreatorObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
size_t maxSize = localSet.getLocalPoolIdsSerializedSize(true);
|
||||
uint8_t localPoolIdBuff[maxSize];
|
||||
@ -139,7 +137,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") {
|
||||
|
||||
SECTION("SharedDataSet") {
|
||||
object_id_t sharedSetId = objects::SHARED_SET_ID;
|
||||
SharedLocalDataSet sharedSet(sharedSetId, poolOwner.sharedPool, lpool::testSetId, 5);
|
||||
SharedLocalDataset sharedSet(sharedSetId, poolOwner.sharedPool, lpool::testSetId0, 5);
|
||||
localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE);
|
||||
localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE);
|
||||
CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK);
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/StaticSharedDataset.h>
|
||||
#include <fsfw/globalfunctions/timevalOperations.h>
|
||||
#include <fsfw/housekeeping/HousekeepingSnapshot.h>
|
||||
#include <fsfw/ipc/CommandMessageCleaner.h>
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/timemanager/CCSDSTime.h>
|
||||
@ -22,21 +21,14 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
||||
const MessageQueueId_t subscriberId = 2;
|
||||
auto hkReceiver = HkReceiverMock(hkDest);
|
||||
auto queue = MessageQueueMock(3);
|
||||
LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
LocalPoolOwnerBase poolOwner(queue, hkDest, objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
|
||||
REQUIRE(poolOwner.initialize() == returnvalue::OK);
|
||||
|
||||
MessageQueueMock& poolOwnerMock = poolOwner.getMockQueueHandle();
|
||||
|
||||
// TODO: This is ugly. This should be an arbitrary ctor argument. Fix this in the pool
|
||||
// manager
|
||||
poolOwnerMock.setDefaultDestination(defaultDestId);
|
||||
poolOwner.setHkDestId(hkDest);
|
||||
|
||||
CommandMessage messageSent;
|
||||
|
||||
// TODO: Fix
|
||||
/*
|
||||
SECTION("Basic Test") {
|
||||
{
|
||||
// For code coverage, should not crash
|
||||
@ -46,231 +38,15 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
||||
REQUIRE(owner != nullptr);
|
||||
CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
|
||||
// Subscribe for message generation on update.
|
||||
REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == returnvalue::OK);
|
||||
/// Subscribe for an update message.
|
||||
poolOwner.dataset.setChanged(true);
|
||||
// Now the update message should be generated.
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
|
||||
// Should have been reset.
|
||||
CHECK(poolOwner.dataset.hasChanged() == false);
|
||||
poolOwnerMock.clearMessages(true);
|
||||
// Set changed again, result should be the same.
|
||||
poolOwner.dataset.setChanged(true);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
|
||||
REQUIRE(poolOwnerMock.wasMessageSent() == true);
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
|
||||
poolOwnerMock.clearMessages(true);
|
||||
// Now subscribe for set update HK as well.
|
||||
REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == returnvalue::OK);
|
||||
poolOwner.dataset.setChanged(true);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent() == true);
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 2);
|
||||
// first message sent should be the update notification
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
REQUIRE(poolOwnerMock.getNextSentMessageToDefaultDest(messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::HK_REPORT));
|
||||
// Clear message to avoid memory leak, our mock won't do it for us (yet)
|
||||
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
||||
}
|
||||
|
||||
SECTION("SetSnapshotUpdateTest") {
|
||||
// Set the variables in the set to certain values. These are checked later.
|
||||
{
|
||||
PoolReadGuard readHelper(&poolOwner.dataset);
|
||||
REQUIRE(readHelper.getReadResult() == returnvalue::OK);
|
||||
poolOwner.dataset.localPoolVarUint8.value = 5;
|
||||
poolOwner.dataset.localPoolVarFloat.value = -12.242;
|
||||
poolOwner.dataset.localPoolUint16Vec.value[0] = 2;
|
||||
poolOwner.dataset.localPoolUint16Vec.value[1] = 32;
|
||||
poolOwner.dataset.localPoolUint16Vec.value[2] = 42932;
|
||||
}
|
||||
|
||||
// Subscribe for snapshot generation on update.
|
||||
REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == returnvalue::OK);
|
||||
poolOwner.dataset.setChanged(true);
|
||||
|
||||
// Store current time, we are going to check the (approximate) time equality later
|
||||
timeval now{};
|
||||
Clock::getClock_timeval(&now);
|
||||
|
||||
// Trigger generation of snapshot
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
// Check that snapshot was generated
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_SET));
|
||||
// Now we deserialize the snapshot into a new dataset instance
|
||||
CCSDSTime::CDS_short cdsShort{};
|
||||
LocalPoolTestDataSet newSet;
|
||||
HousekeepingSnapshot snapshot(&cdsShort, &newSet);
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId);
|
||||
ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId);
|
||||
REQUIRE(accessorPair.first == returnvalue::OK);
|
||||
const uint8_t* readOnlyPtr = accessorPair.second.data();
|
||||
size_t sizeToDeserialize = accessorPair.second.size();
|
||||
CHECK(newSet.localPoolVarFloat.value == 0);
|
||||
CHECK(newSet.localPoolVarUint8 == 0);
|
||||
CHECK(newSet.localPoolUint16Vec.value[0] == 0);
|
||||
CHECK(newSet.localPoolUint16Vec.value[1] == 0);
|
||||
CHECK(newSet.localPoolUint16Vec.value[2] == 0);
|
||||
// Fill the dataset and timestamp
|
||||
REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize,
|
||||
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
|
||||
// Now we check that the snapshot is actually correct
|
||||
CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242));
|
||||
CHECK(newSet.localPoolVarUint8 == 5);
|
||||
CHECK(newSet.localPoolUint16Vec.value[0] == 2);
|
||||
CHECK(newSet.localPoolUint16Vec.value[1] == 32);
|
||||
CHECK(newSet.localPoolUint16Vec.value[2] == 42932);
|
||||
|
||||
// Now we check that both times are equal
|
||||
timeval timeFromHK{};
|
||||
auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort);
|
||||
CHECK(result == returnvalue::OK);
|
||||
timeval difference = timeFromHK - now;
|
||||
CHECK(timevalOperations::toDouble(difference) < 1.0);
|
||||
}
|
||||
|
||||
SECTION("VariableSnapshotTest") {
|
||||
// Acquire subscription interface
|
||||
PeriodicHkGenerationProviderIF* subscriptionIF = poolOwner.getSubscriptionInterface();
|
||||
REQUIRE(subscriptionIF != nullptr);
|
||||
|
||||
// Subscribe for variable snapshot
|
||||
REQUIRE(poolOwner.subscribeWrapperVariableSnapshot(subscriberId, lpool::uint8VarId) ==
|
||||
returnvalue::OK);
|
||||
auto poolVar =
|
||||
dynamic_cast<lp_var_t<uint8_t>*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId));
|
||||
REQUIRE(poolVar != nullptr);
|
||||
|
||||
{
|
||||
PoolReadGuard rg(poolVar);
|
||||
CHECK(rg.getReadResult() == returnvalue::OK);
|
||||
poolVar->value = 25;
|
||||
}
|
||||
|
||||
poolVar->setChanged(true);
|
||||
// Store current time, we are going to check the (approximate) time equality later
|
||||
CCSDSTime::CDS_short timeCdsNow{};
|
||||
timeval now{};
|
||||
Clock::getClock_timeval(&now);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
|
||||
// Check update snapshot was sent.
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
|
||||
// Should have been reset.
|
||||
CHECK(poolVar->hasChanged() == false);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE));
|
||||
// Now we deserialize the snapshot into a new dataset instance
|
||||
CCSDSTime::CDS_short cdsShort{};
|
||||
lp_var_t<uint8_t> varCopy = lp_var_t<uint8_t>(lpool::uint8VarGpid);
|
||||
HousekeepingSnapshot snapshot(&cdsShort, &varCopy);
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId);
|
||||
ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId);
|
||||
REQUIRE(accessorPair.first == returnvalue::OK);
|
||||
const uint8_t* readOnlyPtr = accessorPair.second.data();
|
||||
size_t sizeToDeserialize = accessorPair.second.size();
|
||||
CHECK(varCopy.value == 0);
|
||||
// Fill the dataset and timestamp
|
||||
REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize,
|
||||
SerializeIF::Endianness::MACHINE) == returnvalue::OK);
|
||||
CHECK(varCopy.value == 25);
|
||||
|
||||
// Now we check that both times are equal
|
||||
timeval timeFromHK{};
|
||||
auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort);
|
||||
CHECK(result == returnvalue::OK);
|
||||
timeval difference = timeFromHK - now;
|
||||
CHECK(timevalOperations::toDouble(difference) < 1.0);
|
||||
}
|
||||
|
||||
SECTION("VariableNotificationTest") {
|
||||
// Acquire subscription interface
|
||||
PeriodicHkGenerationProviderIF* subscriptionIF = poolOwner.getSubscriptionInterface();
|
||||
REQUIRE(subscriptionIF != nullptr);
|
||||
|
||||
// Subscribe for variable update
|
||||
REQUIRE(poolOwner.subscribeWrapperVariableUpdate(subscriberId, lpool::uint8VarId) ==
|
||||
returnvalue::OK);
|
||||
auto* poolVar =
|
||||
dynamic_cast<lp_var_t<uint8_t>*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId));
|
||||
REQUIRE(poolVar != nullptr);
|
||||
poolVar->setChanged(true);
|
||||
REQUIRE(poolVar->hasChanged() == true);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
|
||||
// Check update notification was sent.
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
// Should have been reset.
|
||||
CHECK(poolVar->hasChanged() == false);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||
// Now subscribe for the dataset update (HK and update) again with subscription interface
|
||||
REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT,
|
||||
subscriberId, false) == returnvalue::OK);
|
||||
REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == returnvalue::OK);
|
||||
|
||||
poolOwner.dataset.setChanged(true);
|
||||
poolOwnerMock.clearMessages();
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
// Now two messages should be sent.
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 2);
|
||||
poolOwnerMock.clearMessages(true);
|
||||
|
||||
poolOwner.dataset.setChanged(true);
|
||||
poolOwnerMock.clearMessages(true);
|
||||
poolVar->setChanged(true);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
// Now three messages should be sent.
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 3);
|
||||
CHECK(poolOwnerMock.numberOfSentMessagesToDest(subscriberId) == 2);
|
||||
CHECK(poolOwnerMock.numberOfSentMessagesToDest(hkDest) == 1);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||
REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() ==
|
||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessageToDefaultDest(messageSent) == returnvalue::OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::HK_REPORT));
|
||||
REQUIRE(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == MessageQueueIF::EMPTY);
|
||||
REQUIRE(poolOwnerMock.getNextSentMessageToDefaultDest(messageSent) == MessageQueueIF::EMPTY);
|
||||
}
|
||||
|
||||
SECTION("PeriodicHKAndMessaging") {
|
||||
//Now we subcribe for a HK periodic generation. Even when it's difficult to simulate
|
||||
//the temporal behaviour correctly the HK manager should generate a HK packet
|
||||
//immediately and the periodic helper depends on HK op function calls anyway instead of
|
||||
//using the clock, so we could also just call performHkOperation multiple times
|
||||
// Now we subcribe for a HK periodic generation. Even when it's difficult to simulate
|
||||
// the temporal behaviour correctly the HK manager should generate a HK packet
|
||||
// immediately and the periodic helper depends on HK op function calls anyway instead of
|
||||
// using the clock, so we could also just call performHkOperation multiple times
|
||||
REQUIRE(poolOwner.subscribePeriodicHk(true) == returnvalue::OK);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
// Now HK packet should be sent as message immediately.
|
||||
@ -278,43 +54,40 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
|
||||
LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid);
|
||||
REQUIRE(setHandle != nullptr);
|
||||
CHECK(poolOwner.hkHelper.generateHousekeepingPacket(lpool::testSid, setHandle, false) ==
|
||||
returnvalue::OK);
|
||||
CHECK(poolOwner.hkHelper.generateHousekeepingPacket(lpool::testSid0) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
|
||||
CHECK(setHandle->getReportingEnabled() == true);
|
||||
// CHECK(setHandle->getReportingEnabled() == true);
|
||||
CommandMessage hkCmd;
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false);
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid0, false);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(setHandle->getReportingEnabled() == false);
|
||||
// CHECK(setHandle->getReportingEnabled() == false);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true);
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid0, true);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(setHandle->getReportingEnabled() == true);
|
||||
// CHECK(setHandle->getReportingEnabled() == true);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false);
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid0, false);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(setHandle->getReportingEnabled() == false);
|
||||
// CHECK(setHandle->getReportingEnabled() == false);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
|
||||
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4);
|
||||
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid0, 0.4);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK_THAT(poolOwner.dataset.getCollectionInterval(), Catch::Matchers::WithinAbs(0.4, 0.01));
|
||||
// CHECK_THAT(poolOwner.dataset.getCollectionInterval(), Catch::Matchers::WithinAbs(0.4, 0.01));
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK);
|
||||
|
||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid);
|
||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid0);
|
||||
REQUIRE(poolOwner.hkHelper.performHkOperation() == returnvalue::OK);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
// Now HK packet should be sent as message.
|
||||
@ -322,73 +95,47 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid);
|
||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid0);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid);
|
||||
sid_t sidToCheck;
|
||||
store_address_t storeId;
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true);
|
||||
CHECK(sidToCheck == lpool::testSid);
|
||||
|
||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid);
|
||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid0);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4);
|
||||
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid0, 0.4);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true);
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid0, true);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false);
|
||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid0, false);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid);
|
||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid0);
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||
poolOwnerMock.clearMessages();
|
||||
|
||||
HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid);
|
||||
gp_id_t gpidToCheck;
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true);
|
||||
CHECK(gpidToCheck == lpool::uint8VarGpid);
|
||||
|
||||
HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid,
|
||||
store_address_t::invalid());
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true);
|
||||
CHECK(sidToCheck == lpool::testSid);
|
||||
|
||||
HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid,
|
||||
store_address_t::invalid());
|
||||
CHECK(poolOwner.hkHelper.handleHousekeepingMessage(&hkCmd) == returnvalue::OK);
|
||||
CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true);
|
||||
CHECK(gpidToCheck == lpool::uint8VarGpid);
|
||||
|
||||
poolOwner.hkHelper.printPoolEntry(lpool::uint8VarId);
|
||||
// poolOwner.hkHelper.printPoolEntry(lpool::uint8VarId);
|
||||
}
|
||||
|
||||
// we need to reset the subscription list because the pool owner
|
||||
//is a global object.
|
||||
// is a global object.
|
||||
CHECK(poolOwner.reset() == returnvalue::OK);
|
||||
poolOwnerMock.clearMessages(true);
|
||||
*/
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include <mocks/HkReceiverMock.h>
|
||||
#include <mocks/MessageQueueMock.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "DeviceHandlerCommander.h"
|
||||
@ -11,9 +14,13 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") {
|
||||
// Will be deleted with DHB destructor
|
||||
auto* cookieIFMock = new CookieIFMock;
|
||||
ComIFMock comIF(objects::COM_IF_MOCK);
|
||||
MessageQueueMock mqMock(1);
|
||||
HkReceiverMock hkReceiver(1);
|
||||
DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT);
|
||||
DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK,
|
||||
cookieIFMock, &deviceFdirMock);
|
||||
auto& hkHelper = deviceHandlerMock.getHkHelper();
|
||||
hkHelper.setHkDestinationId(1);
|
||||
ReturnValue_t result = deviceHandlerMock.initialize();
|
||||
REQUIRE(result == returnvalue::OK);
|
||||
DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER);
|
||||
|
@ -90,7 +90,7 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) {
|
||||
|
||||
void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; }
|
||||
|
||||
bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; }
|
||||
bool DeviceHandlerMock::getPeriodicReplyReceived() const { return periodicReplyReceived; }
|
||||
|
||||
ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) {
|
||||
return updatePeriodicReply(true, replyId);
|
||||
@ -109,7 +109,8 @@ ReturnValue_t DeviceHandlerMock::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t DeviceHandlerMock::serializeHkDataset(sid_t structureId, uint8_t *buf, size_t maxSize) {
|
||||
ReturnValue_t DeviceHandlerMock::serializeHkDataset(sid_t structureId, uint8_t *buf,
|
||||
size_t maxSize) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,19 @@
|
||||
|
||||
class DeviceHandlerMock : public DeviceHandlerBase {
|
||||
public:
|
||||
static const DeviceCommandId_t SIMPLE_COMMAND = 1;
|
||||
static const DeviceCommandId_t PERIODIC_REPLY = 2;
|
||||
static constexpr DeviceCommandId_t SIMPLE_COMMAND = 1;
|
||||
static constexpr DeviceCommandId_t PERIODIC_REPLY = 2;
|
||||
|
||||
static const uint8_t SIMPLE_COMMAND_DATA = 1;
|
||||
static const uint8_t PERIODIC_REPLY_DATA = 2;
|
||||
static constexpr uint8_t SIMPLE_COMMAND_DATA = 1;
|
||||
static constexpr uint8_t PERIODIC_REPLY_DATA = 2;
|
||||
|
||||
DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
||||
FailureIsolationBase *fdirInstance);
|
||||
virtual ~DeviceHandlerMock();
|
||||
~DeviceHandlerMock() override;
|
||||
void changePeriodicReplyCountdown(uint32_t timeout);
|
||||
void changeSimpleCommandReplyCountdown(uint32_t timeout);
|
||||
void resetPeriodicReplyState();
|
||||
bool getPeriodicReplyReceived();
|
||||
bool getPeriodicReplyReceived() const;
|
||||
ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId);
|
||||
ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId);
|
||||
|
||||
@ -46,7 +46,7 @@ class DeviceHandlerMock : public DeviceHandlerBase {
|
||||
Countdown simpleCommandReplyTimeout = Countdown(1000);
|
||||
Countdown periodicReplyCountdown = Countdown(1000);
|
||||
|
||||
uint8_t commandBuffer[1];
|
||||
uint8_t commandBuffer[1]{};
|
||||
|
||||
bool periodicReplyReceived = false;
|
||||
};
|
||||
|
@ -1,11 +1,15 @@
|
||||
#include "LocalPoolOwnerBase.h"
|
||||
|
||||
LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, object_id_t objectId)
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
|
||||
LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, MessageQueueId_t hkDestId,
|
||||
object_id_t objectId)
|
||||
: SystemObject(objectId),
|
||||
queue(queue),
|
||||
sharedPool(getObjectId()),
|
||||
hkHelper(this, &queue),
|
||||
dataset(sharedPool, lpool::testSetId) {}
|
||||
hkHelper(this, &queue, hkDestId),
|
||||
sharedPool(LocalPoolOwnerBase::getObjectId()),
|
||||
set1(sharedPool, lpool::testSetId1),
|
||||
set2(sharedPool, lpool::testSetId2),
|
||||
queue(queue) {}
|
||||
|
||||
LocalPoolOwnerBase::~LocalPoolOwnerBase() = default;
|
||||
|
||||
@ -68,15 +72,15 @@ ReturnValue_t LocalPoolOwnerBase::reset() {
|
||||
// resetSubscriptionList();
|
||||
ReturnValue_t status = returnvalue::OK;
|
||||
{
|
||||
PoolReadGuard readHelper(&dataset);
|
||||
PoolReadGuard readHelper(&set1);
|
||||
if (readHelper.getReadResult() != returnvalue::OK) {
|
||||
status = readHelper.getReadResult();
|
||||
}
|
||||
dataset.localPoolVarUint8.value = 0;
|
||||
dataset.localPoolVarFloat.value = 0.0;
|
||||
dataset.localPoolUint16Vec.value[0] = 0;
|
||||
dataset.localPoolUint16Vec.value[1] = 0;
|
||||
dataset.localPoolUint16Vec.value[2] = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -101,28 +105,4 @@ ReturnValue_t LocalPoolOwnerBase::reset() {
|
||||
return status;
|
||||
}
|
||||
|
||||
bool LocalPoolOwnerBase::changedDataSetCallbackWasCalled(sid_t &sid, store_address_t &storeId) {
|
||||
bool condition = false;
|
||||
if (not this->changedDatasetSid.notSet()) {
|
||||
condition = true;
|
||||
}
|
||||
sid = changedDatasetSid;
|
||||
storeId = storeIdForChangedSet;
|
||||
this->changedDatasetSid.raw = sid_t::INVALID_SID;
|
||||
this->storeIdForChangedSet = store_address_t::invalid();
|
||||
return condition;
|
||||
}
|
||||
|
||||
bool LocalPoolOwnerBase::changedVariableCallbackWasCalled(gp_id_t &gpid, store_address_t &storeId) {
|
||||
bool condition = false;
|
||||
if (not this->changedPoolVariableGpid.notSet()) {
|
||||
condition = true;
|
||||
}
|
||||
gpid = changedPoolVariableGpid;
|
||||
storeId = storeIdForChangedVariable;
|
||||
this->changedPoolVariableGpid.raw = gp_id_t::INVALID_GPID;
|
||||
this->storeIdForChangedVariable = store_address_t::invalid();
|
||||
return condition;
|
||||
}
|
||||
|
||||
void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { hkHelper.setHkDestinationId(id); }
|
||||
|
@ -1,12 +1,11 @@
|
||||
#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/datapoollocal/LocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
||||
#include <fsfw/datapoollocal/PeriodicHkGenerationHelper.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/StaticSharedDataset.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
@ -21,10 +20,14 @@ 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 testSetId = 0;
|
||||
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 sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId);
|
||||
static const auto testSid0 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId0);
|
||||
static const auto testSid1 = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, testSetId1);
|
||||
static const auto testSid2 = sid_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);
|
||||
@ -33,12 +36,12 @@ static const gp_id_t uint16Vec3Gpid = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BAS
|
||||
static const gp_id_t uint64Vec2Id = gp_id_t(objects::TEST_LOCAL_POOL_OWNER_BASE, int64Vec2Id);
|
||||
} // namespace lpool
|
||||
|
||||
class LocalPoolStaticTestDataSet : public StaticLocalDataSet<3> {
|
||||
class LocalPoolStaticTestDataSet : public StaticSharedDataset<3> {
|
||||
public:
|
||||
LocalPoolStaticTestDataSet() : StaticLocalDataSet(lpool::testSid) {}
|
||||
LocalPoolStaticTestDataSet() : StaticSharedDataset(lpool::testSid1) {}
|
||||
|
||||
LocalPoolStaticTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
|
||||
: StaticLocalDataSet(sharedPool, setId) {}
|
||||
: StaticSharedDataset(sharedPool, setId) {}
|
||||
|
||||
lp_var_t<uint8_t> localPoolVarUint8 = lp_var_t<uint8_t>(lpool::uint8VarGpid, this);
|
||||
lp_var_t<float> localPoolVarFloat = lp_var_t<float>(lpool::floatVarGpid, this);
|
||||
@ -47,12 +50,12 @@ class LocalPoolStaticTestDataSet : public StaticLocalDataSet<3> {
|
||||
private:
|
||||
};
|
||||
|
||||
class LocalPoolTestDataSet : public LocalDataSet {
|
||||
class LocalPoolTestDataSet : public SharedDataSet {
|
||||
public:
|
||||
LocalPoolTestDataSet() : LocalDataSet(lpool::testSid, lpool::dataSetMaxVariables) {}
|
||||
LocalPoolTestDataSet() : SharedDataSet(lpool::testSid2, lpool::dataSetMaxVariables) {}
|
||||
|
||||
LocalPoolTestDataSet(localpool::SharedPool& sharedPool, uint32_t setId)
|
||||
: LocalDataSet(sharedPool, setId, lpool::dataSetMaxVariables) {}
|
||||
: SharedDataSet(sharedPool, setId, lpool::dataSetMaxVariables) {}
|
||||
|
||||
lp_var_t<uint8_t> localPoolVarUint8 = lp_var_t<uint8_t>(lpool::uint8VarGpid, this);
|
||||
lp_var_t<float> localPoolVarFloat = lp_var_t<float>(lpool::floatVarGpid, this);
|
||||
@ -63,7 +66,7 @@ class LocalPoolTestDataSet : public LocalDataSet {
|
||||
|
||||
class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
|
||||
public:
|
||||
explicit LocalPoolOwnerBase(MessageQueueIF& queue,
|
||||
explicit LocalPoolOwnerBase(MessageQueueIF& queue, MessageQueueId_t hkDestId,
|
||||
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
|
||||
~LocalPoolOwnerBase() override;
|
||||
@ -79,8 +82,6 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
|
||||
|
||||
void setHkDestId(MessageQueueId_t id);
|
||||
|
||||
// ReturnValue_t initializeHkManagerAfterTaskCreation();
|
||||
|
||||
/** Command queue for housekeeping messages. */
|
||||
[[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); }
|
||||
|
||||
@ -91,25 +92,17 @@ class LocalPoolOwnerBase : public SystemObject, public PeriodicHkGenerationIF {
|
||||
}
|
||||
|
||||
ReturnValue_t subscribePeriodicHk(bool enableReporting) {
|
||||
return hkHelper.enablePeriodicPacket(lpool::testSid, 200);
|
||||
return hkHelper.enablePeriodicPacket(lpool::testSid0, 50);
|
||||
}
|
||||
|
||||
ReturnValue_t reset();
|
||||
|
||||
bool changedDataSetCallbackWasCalled(sid_t& sid, store_address_t& storeId);
|
||||
bool changedVariableCallbackWasCalled(gp_id_t& gpid, store_address_t& storeId);
|
||||
|
||||
PeriodicHkGenerationHelper hkHelper;
|
||||
localpool::SharedPool sharedPool;
|
||||
LocalPoolTestDataSet dataset;
|
||||
LocalPoolTestDataSet set1;
|
||||
LocalPoolStaticTestDataSet set2;
|
||||
|
||||
private:
|
||||
sid_t changedDatasetSid;
|
||||
store_address_t storeIdForChangedSet;
|
||||
|
||||
gp_id_t changedPoolVariableGpid;
|
||||
store_address_t storeIdForChangedVariable;
|
||||
|
||||
PoolEntry<uint8_t> u8PoolEntry = PoolEntry<uint8_t>({0});
|
||||
PoolEntry<float> floatPoolEntry = PoolEntry<float>({0});
|
||||
PoolEntry<uint32_t> u32PoolEntry = PoolEntry<uint32_t>({0});
|
||||
|
@ -1,3 +1,4 @@
|
||||
target_sources(
|
||||
${FSFW_TEST_TGT} PRIVATE testSerialBufferAdapter.cpp testSerializeAdapter.cpp
|
||||
testSerialLinkedPacket.cpp testSerializeIF.cpp)
|
||||
${FSFW_TEST_TGT}
|
||||
PRIVATE testSerialBufferAdapter.cpp testSerializeAdapter.cpp
|
||||
testSerialLinkedPacket.cpp testSerializeIF.cpp testList.cpp)
|
||||
|
94
unittests/serialize/testList.cpp
Normal file
94
unittests/serialize/testList.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw/serialize/SerializableList.h"
|
||||
#include "fsfw/serialize/SerializableListElement.h"
|
||||
|
||||
using namespace serialize;
|
||||
|
||||
class ExampleSet0 : public List {
|
||||
public:
|
||||
LE<uint8_t> val0{*this};
|
||||
LE<uint32_t> val1{*this};
|
||||
LAE<uint16_t, 3> val2{*this};
|
||||
};
|
||||
|
||||
using namespace returnvalue;
|
||||
|
||||
TEST_CASE("Serial List", "[serialize]") {
|
||||
ExampleSet0 set0;
|
||||
uint8_t buf[1024]{};
|
||||
size_t serSize = 0;
|
||||
size_t dummy = 0;
|
||||
SECTION("serialization default") {
|
||||
uint8_t* ptr = buf;
|
||||
CHECK(set0.getSerializedSize() == 11);
|
||||
const ReturnValue_t result =
|
||||
set0.serialize(&ptr, &serSize, sizeof(buf), SerializeIF::Endianness::NETWORK);
|
||||
CHECK(result == returnvalue::OK);
|
||||
CHECK(ptr == buf + 11);
|
||||
CHECK(buf[0] == 0);
|
||||
uint32_t u32Val = 0;
|
||||
CHECK(SerializeAdapter::deSerialize(&u32Val, buf + 1, &dummy,
|
||||
SerializeIF::Endianness::NETWORK) == OK);
|
||||
CHECK(u32Val == 0);
|
||||
uint16_t u16Val = 0;
|
||||
for (uint32_t i = 0; i < 3; i++) {
|
||||
CHECK(SerializeAdapter::deSerialize(&u16Val, buf + 5, &dummy,
|
||||
SerializeIF::Endianness::NETWORK) == OK);
|
||||
CHECK(u16Val == 0);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("serialization with values") {
|
||||
uint8_t* ptr = buf;
|
||||
set0.val0 = 240;
|
||||
set0.val1 = 0x1f1f1f1f;
|
||||
set0.val2[0] = 0x1f1f;
|
||||
set0.val2[1] = 0xf1f1;
|
||||
set0.val2[2] = 0x4242;
|
||||
const ReturnValue_t result =
|
||||
set0.serialize(&ptr, &serSize, sizeof(buf), SerializeIF::Endianness::NETWORK);
|
||||
CHECK(result == returnvalue::OK);
|
||||
dummy = set0.getSerializedSize();
|
||||
CHECK(ptr == buf + 11);
|
||||
CHECK(buf[0] == 240);
|
||||
const uint8_t* cPtr = buf + 1;
|
||||
uint32_t u32Val = 0;
|
||||
CHECK(SerializeAdapter::deSerialize(&u32Val, &cPtr, &dummy, SerializeIF::Endianness::NETWORK) ==
|
||||
OK);
|
||||
CHECK(u32Val == 0x1f1f1f1f);
|
||||
uint16_t u16Val = 0;
|
||||
CHECK(SerializeAdapter::deSerialize(&u16Val, &cPtr, &dummy, SerializeIF::Endianness::NETWORK) ==
|
||||
OK);
|
||||
CHECK(u16Val == 0x1f1f);
|
||||
CHECK(SerializeAdapter::deSerialize(&u16Val, &cPtr, &dummy, SerializeIF::Endianness::NETWORK) ==
|
||||
OK);
|
||||
CHECK(u16Val == 0xf1f1);
|
||||
CHECK(SerializeAdapter::deSerialize(&u16Val, &cPtr, &dummy, SerializeIF::Endianness::NETWORK) ==
|
||||
OK);
|
||||
CHECK(u16Val == 0x4242);
|
||||
}
|
||||
|
||||
SECTION("deserialization with values") {
|
||||
uint8_t* ptr = buf;
|
||||
set0.val0 = 240;
|
||||
set0.val1 = 0x1f1f1f1f;
|
||||
set0.val2[0] = 0x1f1f;
|
||||
set0.val2[1] = 0xf1f1;
|
||||
set0.val2[2] = 0x4242;
|
||||
const ReturnValue_t result =
|
||||
set0.serialize(&ptr, &serSize, sizeof(buf), SerializeIF::Endianness::NETWORK);
|
||||
CHECK(result == returnvalue::OK);
|
||||
const uint8_t* cPtr = buf;
|
||||
dummy = set0.getSerializedSize();
|
||||
ExampleSet0 deserSet;
|
||||
CHECK(deserSet.deSerialize(&cPtr, &dummy, SerializeIF::Endianness::NETWORK) == returnvalue::OK);
|
||||
|
||||
CHECK(deserSet.val0.get() == 240);
|
||||
CHECK(deserSet.val1.get() == 0x1f1f1f1f);
|
||||
CHECK(deserSet.val2[0] == 0x1f1f);
|
||||
CHECK(deserSet.val2[1] == 0xf1f1);
|
||||
CHECK(deserSet.val2[2] == 0x4242);
|
||||
CHECK(dummy == 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user