completed send helper tests
This commit is contained in:
parent
a88f767cca
commit
586993c081
@ -6,10 +6,7 @@
|
|||||||
#include "fsfw/tmtcservices/tmHelpers.h"
|
#include "fsfw/tmtcservices/tmHelpers.h"
|
||||||
|
|
||||||
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId)
|
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId)
|
||||||
: PusServiceBase(objectId, apid, serviceId),
|
: PusServiceBase(objectId, apid, serviceId), storeHelper(apid), packetSubCounter(0) {}
|
||||||
storeHelper(apid),
|
|
||||||
sendHelper(nullptr),
|
|
||||||
packetSubCounter(0) {}
|
|
||||||
|
|
||||||
Service17Test::~Service17Test() = default;
|
Service17Test::~Service17Test() = default;
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj
|
|||||||
apid(apid),
|
apid(apid),
|
||||||
serviceId(serviceId),
|
serviceId(serviceId),
|
||||||
targetDestination(targetDestination),
|
targetDestination(targetDestination),
|
||||||
sendHelper(nullptr),
|
|
||||||
storeHelper(apid) {
|
storeHelper(apid) {
|
||||||
tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap
|
|||||||
uint8_t serviceId, size_t maxNumberReportsPerCycle,
|
uint8_t serviceId, size_t maxNumberReportsPerCycle,
|
||||||
uint32_t messageQueueDepth)
|
uint32_t messageQueueDepth)
|
||||||
: PusServiceBase(objectId, apid, serviceId),
|
: PusServiceBase(objectId, apid, serviceId),
|
||||||
sendHelper(nullptr),
|
|
||||||
storeHelper(apid),
|
storeHelper(apid),
|
||||||
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
|
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
|
||||||
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||||
|
@ -194,8 +194,6 @@ void LocalPool::clearStore() {
|
|||||||
for (auto& size : sizeList) {
|
for (auto& size : sizeList) {
|
||||||
size = STORAGE_FREE;
|
size = STORAGE_FREE;
|
||||||
}
|
}
|
||||||
// std::memset(sizeList[index], 0xff,
|
|
||||||
// numberOfElements[index] * sizeof(size_type));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,3 +336,16 @@ void LocalPool::clearSubPool(max_subpools_t subpoolIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LocalPool::max_subpools_t LocalPool::getNumberOfSubPools() const { return NUMBER_OF_SUBPOOLS; }
|
LocalPool::max_subpools_t LocalPool::getNumberOfSubPools() const { return NUMBER_OF_SUBPOOLS; }
|
||||||
|
|
||||||
|
bool LocalPool::hasDataAtId(store_address_t storeId) const {
|
||||||
|
if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((storeId.packetIndex >= numberOfElements[storeId.poolIndex])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (sizeLists[storeId.poolIndex][storeId.packetIndex] != STORAGE_FREE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -132,6 +132,7 @@ class LocalPool : public SystemObject, public StorageManagerIF {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
max_subpools_t getNumberOfSubPools() const override;
|
max_subpools_t getNumberOfSubPools() const override;
|
||||||
|
bool hasDataAtId(store_address_t storeId) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -163,6 +163,8 @@ class StorageManagerIF : public HasReturnvaluesIF {
|
|||||||
virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data,
|
virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data,
|
||||||
bool ignoreFault = false) = 0;
|
bool ignoreFault = false) = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual bool hasDataAtId(store_address_t storeId) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the whole store.
|
* Clears the whole store.
|
||||||
* Use with care!
|
* Use with care!
|
||||||
|
@ -21,7 +21,6 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a
|
|||||||
service(service),
|
service(service),
|
||||||
timeoutSeconds(commandTimeoutSeconds),
|
timeoutSeconds(commandTimeoutSeconds),
|
||||||
tmStoreHelper(apid),
|
tmStoreHelper(apid),
|
||||||
tmSendHelper(nullptr),
|
|
||||||
commandMap(numberOfParallelCommands) {
|
commandMap(numberOfParallelCommands) {
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
||||||
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
||||||
|
@ -131,8 +131,8 @@ void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelp
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) {
|
void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) {
|
||||||
tmSendHelper.setMsgQueue(requestQueue);
|
tmSendHelper.setMsgQueue(*requestQueue);
|
||||||
tmSendHelper.setMsgDestination(requestQueue->getDefaultDestination());
|
tmSendHelper.setDefaultDestination(requestQueue->getDefaultDestination());
|
||||||
if (errReporter == nullptr) {
|
if (errReporter == nullptr) {
|
||||||
errReporter =
|
errReporter =
|
||||||
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||||
|
@ -2,38 +2,50 @@
|
|||||||
|
|
||||||
#include "fsfw/ipc/MessageQueueSenderIF.h"
|
#include "fsfw/ipc/MessageQueueSenderIF.h"
|
||||||
|
|
||||||
TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter,
|
TmSendHelper::TmSendHelper() = default;
|
||||||
|
|
||||||
|
TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &reporter,
|
||||||
MessageQueueId_t tmtcMsgDest)
|
MessageQueueId_t tmtcMsgDest)
|
||||||
: tmtcMsgDest(tmtcMsgDest), queue(queue), errReporter(reporter) {}
|
: defaultDest(tmtcMsgDest), queue(&queue), errReporter(&reporter) {}
|
||||||
|
|
||||||
TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter)
|
TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &reporter)
|
||||||
: queue(queue), errReporter(reporter) {}
|
: queue(&queue), errReporter(&reporter) {}
|
||||||
|
|
||||||
TmSendHelper::TmSendHelper(InternalErrorReporterIF *reporter) : errReporter(reporter) {}
|
TmSendHelper::TmSendHelper(InternalErrorReporterIF &reporter) : errReporter(&reporter) {}
|
||||||
|
|
||||||
ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) {
|
ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) {
|
||||||
if (queue == nullptr) {
|
if (queue == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
TmTcMessage message(storeId);
|
TmTcMessage message(storeId);
|
||||||
ReturnValue_t result = queue->sendMessage(tmtcMsgDest, &message, ignoreFault);
|
ReturnValue_t result = queue->sendMessage(defaultDest, &message, ignoreFault);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
if (errReporter != nullptr) {
|
if (errReporter != nullptr and not ignoreFault) {
|
||||||
errReporter->lostTm();
|
errReporter->lostTm();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TmSendHelper::setMsgDestination(MessageQueueId_t msgDest) { tmtcMsgDest = msgDest; }
|
void TmSendHelper::setDefaultDestination(MessageQueueId_t msgDest) { defaultDest = msgDest; }
|
||||||
|
|
||||||
void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) {
|
void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) {
|
||||||
errReporter = reporter;
|
errReporter = reporter;
|
||||||
}
|
}
|
||||||
void TmSendHelper::setMsgQueue(MessageQueueIF *queue_) { queue = queue_; }
|
void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; }
|
||||||
|
|
||||||
ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) {
|
ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) {
|
||||||
setMsgDestination(dest);
|
setDefaultDestination(dest);
|
||||||
return sendPacket(storeId);
|
return sendPacket(storeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageQueueId_t TmSendHelper::getDefaultDestination() const { return defaultDest; }
|
||||||
|
|
||||||
|
bool TmSendHelper::areFaultsIgnored() const { return ignoreFault; }
|
||||||
|
void TmSendHelper::ignoreFaults() { ignoreFault = true; }
|
||||||
|
void TmSendHelper::dontIgnoreFaults() { ignoreFault = false; }
|
||||||
|
|
||||||
|
InternalErrorReporterIF *TmSendHelper::getInternalErrorReporter() const { return errReporter; }
|
||||||
|
|
||||||
|
MessageQueueIF *TmSendHelper::getMsgQueue() const { return queue; }
|
||||||
|
@ -9,22 +9,30 @@
|
|||||||
|
|
||||||
class TmSendHelper {
|
class TmSendHelper {
|
||||||
public:
|
public:
|
||||||
TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter,
|
TmSendHelper();
|
||||||
|
TmSendHelper(MessageQueueIF& queue, InternalErrorReporterIF& reporter,
|
||||||
MessageQueueId_t tmtcMsgDest);
|
MessageQueueId_t tmtcMsgDest);
|
||||||
TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter);
|
TmSendHelper(MessageQueueIF& queue, InternalErrorReporterIF& reporter);
|
||||||
explicit TmSendHelper(InternalErrorReporterIF* reporter);
|
explicit TmSendHelper(InternalErrorReporterIF& reporter);
|
||||||
|
|
||||||
void setMsgQueue(MessageQueueIF* queue);
|
void setMsgQueue(MessageQueueIF& queue);
|
||||||
void setMsgDestination(MessageQueueId_t msgDest);
|
MessageQueueIF* getMsgQueue() const;
|
||||||
|
|
||||||
|
void setDefaultDestination(MessageQueueId_t msgDest);
|
||||||
|
[[nodiscard]] MessageQueueId_t getDefaultDestination() const;
|
||||||
|
[[nodiscard]] bool areFaultsIgnored() const;
|
||||||
|
void ignoreFaults();
|
||||||
|
void dontIgnoreFaults();
|
||||||
void setInternalErrorReporter(InternalErrorReporterIF* reporter);
|
void setInternalErrorReporter(InternalErrorReporterIF* reporter);
|
||||||
|
[[nodiscard]] InternalErrorReporterIF* getInternalErrorReporter() const;
|
||||||
ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId);
|
ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId);
|
||||||
ReturnValue_t sendPacket(const store_address_t& storeId);
|
ReturnValue_t sendPacket(const store_address_t& storeId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageQueueId_t tmtcMsgDest = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t defaultDest = MessageQueueIF::NO_QUEUE;
|
||||||
bool ignoreFault = false;
|
bool ignoreFault = false;
|
||||||
MessageQueueIF* queue = nullptr;
|
MessageQueueIF* queue = nullptr;
|
||||||
InternalErrorReporterIF* errReporter;
|
InternalErrorReporterIF* errReporter = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FSFW_TMTCPACKET_TMSENDHELPER_H
|
#endif // FSFW_TMTCPACKET_TMSENDHELPER_H
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
#include "mocks/LocalPoolOwnerBase.h"
|
|
||||||
#include "mocks/HkReceiverMock.h"
|
#include "mocks/HkReceiverMock.h"
|
||||||
|
#include "mocks/LocalPoolOwnerBase.h"
|
||||||
|
|
||||||
TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
||||||
const MessageQueueId_t defaultDestId = 1;
|
const MessageQueueId_t defaultDestId = 1;
|
||||||
@ -65,7 +65,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
|
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent() == true);
|
REQUIRE(poolOwnerMock.wasMessageSent() == true);
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() ==
|
CHECK(messageSent.getCommand() ==
|
||||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||||
@ -76,7 +76,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
poolOwner.dataset.setChanged(true);
|
poolOwner.dataset.setChanged(true);
|
||||||
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent() == true);
|
REQUIRE(poolOwnerMock.wasMessageSent() == true);
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 2);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 2);
|
||||||
// first message sent should be the update notification
|
// first message sent should be the update notification
|
||||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() ==
|
CHECK(messageSent.getCommand() ==
|
||||||
@ -110,7 +110,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
/* Trigger generation of snapshot */
|
/* Trigger generation of snapshot */
|
||||||
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
||||||
/* Check that snapshot was generated */
|
/* Check that snapshot was generated */
|
||||||
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_SET));
|
CHECK(messageSent.getCommand() == static_cast<int>(HousekeepingMessage::UPDATE_SNAPSHOT_SET));
|
||||||
@ -174,7 +174,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
|
|
||||||
/* Check update snapshot was sent. */
|
/* Check update snapshot was sent. */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
|
|
||||||
/* Should have been reset. */
|
/* Should have been reset. */
|
||||||
CHECK(poolVar->hasChanged() == false);
|
CHECK(poolVar->hasChanged() == false);
|
||||||
@ -222,7 +222,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
|
|
||||||
/* Check update notification was sent. */
|
/* Check update notification was sent. */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
/* Should have been reset. */
|
/* Should have been reset. */
|
||||||
CHECK(poolVar->hasChanged() == false);
|
CHECK(poolVar->hasChanged() == false);
|
||||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
||||||
@ -238,7 +238,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
/* Now two messages should be sent. */
|
/* Now two messages should be sent. */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 2);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 2);
|
||||||
poolOwnerMock.clearMessages(true);
|
poolOwnerMock.clearMessages(true);
|
||||||
|
|
||||||
poolOwner.dataset.setChanged(true);
|
poolOwner.dataset.setChanged(true);
|
||||||
@ -247,9 +247,9 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
/* Now three messages should be sent. */
|
/* Now three messages should be sent. */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 3);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 3);
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage(subscriberId) == 2);
|
CHECK(poolOwnerMock.numberOfSentMessagesToDest(subscriberId) == 2);
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage(hkDest) == 1);
|
CHECK(poolOwnerMock.numberOfSentMessagesToDest(hkDest) == 1);
|
||||||
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK);
|
||||||
CHECK(messageSent.getCommand() ==
|
CHECK(messageSent.getCommand() ==
|
||||||
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||||
@ -275,7 +275,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK);
|
||||||
/* Now HK packet should be sent as message immediately. */
|
/* Now HK packet should be sent as message immediately. */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid);
|
LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid);
|
||||||
@ -283,7 +283,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) ==
|
CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) ==
|
||||||
retval::CATCH_OK);
|
retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
CHECK(setHandle->getReportingEnabled() == true);
|
CHECK(setHandle->getReportingEnabled() == true);
|
||||||
@ -292,7 +292,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
CHECK(setHandle->getReportingEnabled() == false);
|
CHECK(setHandle->getReportingEnabled() == false);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
CHECK(poolOwnerMock.numberOfSentMessage() == 1);
|
CHECK(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false);
|
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false);
|
||||||
@ -314,7 +314,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
resulting collection interval should be 1.0 second */
|
resulting collection interval should be 1.0 second */
|
||||||
CHECK(poolOwner.dataset.getCollectionInterval() == 1.0);
|
CHECK(poolOwner.dataset.getCollectionInterval() == 1.0);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false);
|
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false);
|
||||||
@ -322,13 +322,13 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
/* Now HK packet should be sent as message. */
|
/* Now HK packet should be sent as message. */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false);
|
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid);
|
HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid);
|
||||||
@ -346,7 +346,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
||||||
/* We still expect a failure message being sent */
|
/* We still expect a failure message being sent */
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4,
|
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4,
|
||||||
@ -354,52 +354,52 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
|
|||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) ==
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) ==
|
||||||
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false);
|
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) ==
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) ==
|
||||||
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK);
|
||||||
|
|
||||||
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true);
|
HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4,
|
HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4,
|
||||||
true);
|
true);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true);
|
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true);
|
HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false);
|
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) ==
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) ==
|
||||||
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
static_cast<int>(LocalDataPoolManager::WRONG_HK_PACKET_TYPE));
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true);
|
HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true);
|
||||||
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwnerMock.wasMessageSent());
|
REQUIRE(poolOwnerMock.wasMessageSent());
|
||||||
REQUIRE(poolOwnerMock.numberOfSentMessage() == 1);
|
REQUIRE(poolOwnerMock.numberOfSentMessages() == 1);
|
||||||
poolOwnerMock.clearMessages();
|
poolOwnerMock.clearMessages();
|
||||||
|
|
||||||
HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid);
|
HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid);
|
||||||
|
@ -5,3 +5,9 @@ InternalErrorReporterMock::InternalErrorReporterMock() = default;
|
|||||||
void InternalErrorReporterMock::queueMessageNotSent() { queueMsgNotSentCallCnt++; }
|
void InternalErrorReporterMock::queueMessageNotSent() { queueMsgNotSentCallCnt++; }
|
||||||
void InternalErrorReporterMock::lostTm() { lostTmCallCnt++; }
|
void InternalErrorReporterMock::lostTm() { lostTmCallCnt++; }
|
||||||
void InternalErrorReporterMock::storeFull() { storeFullCallCnt++; }
|
void InternalErrorReporterMock::storeFull() { storeFullCallCnt++; }
|
||||||
|
|
||||||
|
void InternalErrorReporterMock::reset() {
|
||||||
|
queueMsgNotSentCallCnt = 0;
|
||||||
|
lostTmCallCnt = 0;
|
||||||
|
storeFullCallCnt = 0;
|
||||||
|
}
|
||||||
|
@ -9,10 +9,11 @@ class InternalErrorReporterMock : public InternalErrorReporterIF {
|
|||||||
unsigned int lostTmCallCnt = 0;
|
unsigned int lostTmCallCnt = 0;
|
||||||
unsigned int storeFullCallCnt = 0;
|
unsigned int storeFullCallCnt = 0;
|
||||||
InternalErrorReporterMock();
|
InternalErrorReporterMock();
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
void queueMessageNotSent() override;
|
void queueMessageNotSent() override;
|
||||||
void lostTm() override;
|
void lostTm() override;
|
||||||
void storeFull() override;
|
void storeFull() override;
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
};
|
||||||
#endif // FSFW_TESTS_INTERNALERRORREPORTERMOCK_H
|
#endif // FSFW_TESTS_INTERNALERRORREPORTERMOCK_H
|
||||||
|
@ -15,7 +15,7 @@ bool MessageQueueMock::wasMessageSent() const {
|
|||||||
[](const std::pair<MessageQueueId_t, SendInfo>& pair) { return pair.second.callCount > 0; });
|
[](const std::pair<MessageQueueId_t, SendInfo>& pair) { return pair.second.callCount > 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MessageQueueMock::numberOfSentMessage() const {
|
size_t MessageQueueMock::numberOfSentMessages() const {
|
||||||
size_t callCount = 0;
|
size_t callCount = 0;
|
||||||
for (auto& destInfo : sendMap) {
|
for (auto& destInfo : sendMap) {
|
||||||
callCount += destInfo.second.callCount;
|
callCount += destInfo.second.callCount;
|
||||||
@ -23,7 +23,7 @@ size_t MessageQueueMock::numberOfSentMessage() const {
|
|||||||
return callCount;
|
return callCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t MessageQueueMock::numberOfSentMessage(MessageQueueId_t id) const {
|
size_t MessageQueueMock::numberOfSentMessagesToDest(MessageQueueId_t id) const {
|
||||||
auto iter = sendMap.find(id);
|
auto iter = sendMap.find(id);
|
||||||
if (iter == sendMap.end()) {
|
if (iter == sendMap.end()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -31,6 +31,10 @@ size_t MessageQueueMock::numberOfSentMessage(MessageQueueId_t id) const {
|
|||||||
return iter->second.callCount;
|
return iter->second.callCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t MessageQueueMock::numberOfSentMessagesToDefault() const {
|
||||||
|
return numberOfSentMessagesToDest(MessageQueueBase::getDefaultDestination());
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t MessageQueueMock::clearLastReceivedMessage(bool clearCmdMsg) {
|
ReturnValue_t MessageQueueMock::clearLastReceivedMessage(bool clearCmdMsg) {
|
||||||
if (receivedMsgs.empty()) {
|
if (receivedMsgs.empty()) {
|
||||||
return MessageQueueIF::EMPTY;
|
return MessageQueueIF::EMPTY;
|
||||||
@ -61,6 +65,10 @@ ReturnValue_t MessageQueueMock::sendMessageFrom(MessageQueueId_t sendTo,
|
|||||||
if (message == nullptr) {
|
if (message == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
if (nextSendFailsPair.first) {
|
||||||
|
nextSendFailsPair.first = false;
|
||||||
|
return nextSendFailsPair.second;
|
||||||
|
}
|
||||||
auto iter = sendMap.find(sendTo);
|
auto iter = sendMap.find(sendTo);
|
||||||
MessageQueueMessage messageCopy;
|
MessageQueueMessage messageCopy;
|
||||||
if (iter == sendMap.end()) {
|
if (iter == sendMap.end()) {
|
||||||
@ -162,3 +170,7 @@ void MessageQueueMock::clearEmptyEntries() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void MessageQueueMock::makeNextSendFail(ReturnValue_t retval) {
|
||||||
|
nextSendFailsPair.first = true;
|
||||||
|
nextSendFailsPair.second = retval;
|
||||||
|
}
|
||||||
|
@ -32,8 +32,10 @@ class MessageQueueMock : public MessageQueueBase {
|
|||||||
//! Get message which was sent to a specific ID
|
//! Get message which was sent to a specific ID
|
||||||
ReturnValue_t getNextSentMessage(MessageQueueId_t id, MessageQueueMessageIF& message);
|
ReturnValue_t getNextSentMessage(MessageQueueId_t id, MessageQueueMessageIF& message);
|
||||||
[[nodiscard]] bool wasMessageSent() const;
|
[[nodiscard]] bool wasMessageSent() const;
|
||||||
[[nodiscard]] size_t numberOfSentMessage() const;
|
void makeNextSendFail(ReturnValue_t retval);
|
||||||
[[nodiscard]] size_t numberOfSentMessage(MessageQueueId_t id) const;
|
[[nodiscard]] size_t numberOfSentMessages() const;
|
||||||
|
[[nodiscard]] size_t numberOfSentMessagesToDefault() const;
|
||||||
|
[[nodiscard]] size_t numberOfSentMessagesToDest(MessageQueueId_t id) const;
|
||||||
/**
|
/**
|
||||||
* Pop a message, clearing it in the process.
|
* Pop a message, clearing it in the process.
|
||||||
* @return
|
* @return
|
||||||
@ -53,6 +55,7 @@ class MessageQueueMock : public MessageQueueBase {
|
|||||||
using SendMap = std::map<MessageQueueId_t, SendInfo>;
|
using SendMap = std::map<MessageQueueId_t, SendInfo>;
|
||||||
SendMap sendMap;
|
SendMap sendMap;
|
||||||
std::queue<MessageQueueMessage> receivedMsgs;
|
std::queue<MessageQueueMessage> receivedMsgs;
|
||||||
|
std::pair<bool, ReturnValue_t> nextSendFailsPair;
|
||||||
|
|
||||||
void clearEmptyEntries();
|
void clearEmptyEntries();
|
||||||
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override;
|
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
target_sources(${FSFW_TEST_TGT} PRIVATE
|
target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||||
TestNewAccessor.cpp
|
testAccessor.cpp
|
||||||
TestPool.cpp
|
testPool.cpp
|
||||||
)
|
)
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#include "CatchDefinitions.h"
|
#include "CatchDefinitions.h"
|
||||||
|
|
||||||
TEST_CASE("New Accessor", "[NewAccessor]") {
|
TEST_CASE("Pool Accessor", "[pool-accessor]") {
|
||||||
LocalPool::LocalPoolConfig poolCfg = {{1, 10}};
|
LocalPool::LocalPoolConfig poolCfg = {{1, 10}};
|
||||||
LocalPool SimplePool = LocalPool(0, poolCfg);
|
LocalPool SimplePool = LocalPool(0, poolCfg);
|
||||||
std::array<uint8_t, 20> testDataArray;
|
std::array<uint8_t, 20> testDataArray{};
|
||||||
std::array<uint8_t, 20> receptionArray;
|
std::array<uint8_t, 20> receptionArray{};
|
||||||
store_address_t testStoreId;
|
store_address_t testStoreId;
|
||||||
ReturnValue_t result = retval::CATCH_FAILED;
|
ReturnValue_t result = retval::CATCH_FAILED;
|
||||||
|
|
@ -10,10 +10,10 @@
|
|||||||
TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") {
|
TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") {
|
||||||
LocalPool::LocalPoolConfig config = {{1, 10}};
|
LocalPool::LocalPoolConfig config = {{1, 10}};
|
||||||
LocalPool simplePool(0, config);
|
LocalPool simplePool(0, config);
|
||||||
std::array<uint8_t, 20> testDataArray;
|
std::array<uint8_t, 20> testDataArray{};
|
||||||
std::array<uint8_t, 20> receptionArray;
|
std::array<uint8_t, 20> receptionArray{};
|
||||||
store_address_t testStoreId;
|
store_address_t testStoreId;
|
||||||
ReturnValue_t result = retval::CATCH_FAILED;
|
ReturnValue_t result;
|
||||||
uint8_t* pointer = nullptr;
|
uint8_t* pointer = nullptr;
|
||||||
const uint8_t* constPointer = nullptr;
|
const uint8_t* constPointer = nullptr;
|
||||||
|
|
||||||
@ -23,8 +23,10 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") {
|
|||||||
size_t size = 10;
|
size_t size = 10;
|
||||||
|
|
||||||
SECTION("Basic tests") {
|
SECTION("Basic tests") {
|
||||||
|
REQUIRE(not simplePool.hasDataAtId(testStoreId));
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
|
REQUIRE(simplePool.hasDataAtId(testStoreId));
|
||||||
result = simplePool.getData(testStoreId, &constPointer, &size);
|
result = simplePool.getData(testStoreId, &constPointer, &size);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
memcpy(receptionArray.data(), constPointer, size);
|
memcpy(receptionArray.data(), constPointer, size);
|
||||||
@ -40,6 +42,7 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") {
|
|||||||
}
|
}
|
||||||
result = simplePool.deleteData(testStoreId);
|
result = simplePool.deleteData(testStoreId);
|
||||||
REQUIRE(result == retval::CATCH_OK);
|
REQUIRE(result == retval::CATCH_OK);
|
||||||
|
REQUIRE(not simplePool.hasDataAtId(testStoreId));
|
||||||
result = simplePool.addData(&testStoreId, testDataArray.data(), 15);
|
result = simplePool.addData(&testStoreId, testDataArray.data(), 15);
|
||||||
CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE);
|
CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE);
|
||||||
}
|
}
|
@ -1,15 +1,103 @@
|
|||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "fsfw/storagemanager/LocalPool.h"
|
||||||
#include "fsfw/tmtcservices/TmSendHelper.h"
|
#include "fsfw/tmtcservices/TmSendHelper.h"
|
||||||
|
#include "fsfw/tmtcservices/TmStoreHelper.h"
|
||||||
|
#include "mocks/CdsShortTimestamperMock.h"
|
||||||
#include "mocks/InternalErrorReporterMock.h"
|
#include "mocks/InternalErrorReporterMock.h"
|
||||||
#include "mocks/MessageQueueMock.h"
|
#include "mocks/MessageQueueMock.h"
|
||||||
|
|
||||||
TEST_CASE("TM Send Helper", "[tm-send-helper]") {
|
TEST_CASE("TM Send Helper", "[tm-send-helper]") {
|
||||||
|
MessageQueueId_t destId = 1;
|
||||||
auto errReporter = InternalErrorReporterMock();
|
auto errReporter = InternalErrorReporterMock();
|
||||||
auto msgQueue = MessageQueueMock();
|
auto msgQueue = MessageQueueMock();
|
||||||
TmSendHelper sendHelper(&msgQueue, &errReporter);
|
msgQueue.setDefaultDestination(destId);
|
||||||
|
TmSendHelper sendHelper(msgQueue, errReporter, destId);
|
||||||
|
auto timeStamper = CdsShortTimestamperMock();
|
||||||
|
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
|
||||||
|
LocalPool pool(objects::NO_OBJECT, cfg);
|
||||||
|
auto storeHelper = TmStoreHelper(2, pool, timeStamper);
|
||||||
|
|
||||||
SECTION("State") {
|
SECTION("State and Setters") {
|
||||||
|
REQUIRE(sendHelper.getInternalErrorReporter() == &errReporter);
|
||||||
|
REQUIRE(sendHelper.getDefaultDestination() == destId);
|
||||||
|
REQUIRE(sendHelper.getMsgQueue() == &msgQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Setters") {
|
||||||
|
REQUIRE(not sendHelper.areFaultsIgnored());
|
||||||
|
sendHelper.ignoreFaults();
|
||||||
|
REQUIRE(sendHelper.areFaultsIgnored());
|
||||||
|
sendHelper.dontIgnoreFaults();
|
||||||
|
REQUIRE(not sendHelper.areFaultsIgnored());
|
||||||
|
REQUIRE(sendHelper.getDefaultDestination() == destId);
|
||||||
|
sendHelper.setDefaultDestination(destId + 1);
|
||||||
|
REQUIRE(sendHelper.getDefaultDestination() == destId + 1);
|
||||||
|
sendHelper.setInternalErrorReporter(nullptr);
|
||||||
|
REQUIRE(sendHelper.getInternalErrorReporter() == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Default CTOR") {
|
||||||
|
TmSendHelper emptyHelper;
|
||||||
|
REQUIRE(emptyHelper.getInternalErrorReporter() == nullptr);
|
||||||
|
REQUIRE(emptyHelper.getDefaultDestination() == MessageQueueIF::NO_QUEUE);
|
||||||
|
store_address_t dummy;
|
||||||
|
// basic robustness
|
||||||
|
REQUIRE(emptyHelper.sendPacket(dummy) == HasReturnvaluesIF::RETURN_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("One Arg CTOR") {
|
||||||
|
TmSendHelper helper(errReporter);
|
||||||
|
REQUIRE(helper.getInternalErrorReporter() == &errReporter);
|
||||||
|
REQUIRE(helper.getDefaultDestination() == MessageQueueIF::NO_QUEUE);
|
||||||
|
REQUIRE(helper.getMsgQueue() == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Two Arg CTOR") {
|
||||||
|
TmSendHelper helper(msgQueue, errReporter);
|
||||||
|
REQUIRE(helper.getInternalErrorReporter() == &errReporter);
|
||||||
|
REQUIRE(helper.getDefaultDestination() == MessageQueueIF::NO_QUEUE);
|
||||||
|
REQUIRE(helper.getMsgQueue() == &msgQueue);
|
||||||
|
}
|
||||||
|
SECTION("Send") {
|
||||||
|
storeHelper.preparePacket(17, 2, 0);
|
||||||
|
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
store_address_t storeId = storeHelper.getCurrentAddr();
|
||||||
|
REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(msgQueue.wasMessageSent());
|
||||||
|
REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1);
|
||||||
|
TmTcMessage msg;
|
||||||
|
REQUIRE(msgQueue.getNextSentMessage(msg) == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(msg.getStorageId() == storeId);
|
||||||
|
REQUIRE(pool.hasDataAtId(msg.getStorageId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Send to Non-Default") {
|
||||||
|
storeHelper.preparePacket(17, 2, 0);
|
||||||
|
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
store_address_t storeId = storeHelper.getCurrentAddr();
|
||||||
|
REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(msgQueue.wasMessageSent());
|
||||||
|
REQUIRE(msgQueue.numberOfSentMessagesToDest(destId + 1) == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Sending fails, errors not ignored") {
|
||||||
|
msgQueue.makeNextSendFail(HasReturnvaluesIF::RETURN_FAILED);
|
||||||
|
storeHelper.preparePacket(17, 2, 0);
|
||||||
|
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
store_address_t storeId = storeHelper.getCurrentAddr();
|
||||||
|
REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_FAILED);
|
||||||
|
REQUIRE(errReporter.lostTmCallCnt == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Sending fails, errors ignored") {
|
||||||
|
msgQueue.makeNextSendFail(HasReturnvaluesIF::RETURN_FAILED);
|
||||||
|
storeHelper.preparePacket(17, 2, 0);
|
||||||
|
sendHelper.ignoreFaults();
|
||||||
|
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
store_address_t storeId = storeHelper.getCurrentAddr();
|
||||||
|
REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_FAILED);
|
||||||
|
REQUIRE(errReporter.lostTmCallCnt == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user