test auto-initializers
This commit is contained in:
parent
1954ce0ea4
commit
8bf0fb9885
@ -36,7 +36,7 @@ void Factory::produceFsfwObjects(void) {
|
||||
|
||||
void Factory::setStaticFrameworkObjectIds() {
|
||||
PusServiceBase::packetSource = objects::NO_OBJECT;
|
||||
PusServiceBase::packetDestination = objects::NO_OBJECT;
|
||||
PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT;
|
||||
|
||||
CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
|
||||
CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
|
||||
|
@ -104,9 +104,12 @@ ReturnValue_t CommandingServiceBase::initialize() {
|
||||
errReporter =
|
||||
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (errReporter != nullptr) {
|
||||
tmSendHelper.setInternalErrorReporter(errReporter);
|
||||
tmSendHelper.setInternalErrorReporter(*errReporter);
|
||||
}
|
||||
} else {
|
||||
tmSendHelper.setInternalErrorReporter(*errReporter);
|
||||
}
|
||||
|
||||
if (verificationReporter == nullptr) {
|
||||
verificationReporter =
|
||||
ObjectManager::instance()->get<VerificationReporterIF>(objects::TC_VERIFICATOR);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
namespace Factory {
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class is the basis for all PUS Services, which have to
|
||||
@ -38,7 +38,7 @@ class CommandingServiceBase : public SystemObject,
|
||||
public AcceptsTelecommandsIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasReturnvaluesIF {
|
||||
friend void(Factory::setStaticFrameworkObjectIds)();
|
||||
friend void Factory::setStaticFrameworkObjectIds();
|
||||
|
||||
public:
|
||||
// We could make this configurable via preprocessor and the FSFWConfig file.
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "fsfw/tmtcservices/TmTcMessage.h"
|
||||
#include "fsfw/tmtcservices/tcHelpers.h"
|
||||
|
||||
object_id_t PusServiceBase::packetDestination = 0;
|
||||
object_id_t PusServiceBase::pusDistributor = 0;
|
||||
object_id_t PusServiceBase::PACKET_DESTINATION = 0;
|
||||
object_id_t PusServiceBase::PUS_DISTRIBUTOR = 0;
|
||||
|
||||
PusServiceBase::PusServiceBase(PsbParams params)
|
||||
: SystemObject(params.objectId), psbParams(params) {}
|
||||
@ -83,7 +83,12 @@ void PusServiceBase::handleRequestQueue() {
|
||||
|
||||
uint16_t PusServiceBase::getIdentifier() { return psbParams.serviceId; }
|
||||
|
||||
MessageQueueId_t PusServiceBase::getRequestQueue() { return psbParams.reqQueue->getId(); }
|
||||
MessageQueueId_t PusServiceBase::getRequestQueue() {
|
||||
if (psbParams.reqQueue == nullptr) {
|
||||
return MessageQueueIF::NO_QUEUE;
|
||||
}
|
||||
return psbParams.reqQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::initialize() {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
@ -96,15 +101,16 @@ ReturnValue_t PusServiceBase::initialize() {
|
||||
} else {
|
||||
ownedQueue = false;
|
||||
}
|
||||
|
||||
if (psbParams.tmReceiver == nullptr) {
|
||||
psbParams.tmReceiver = ObjectManager::instance()->get<AcceptsTelemetryIF>(packetDestination);
|
||||
psbParams.tmReceiver = ObjectManager::instance()->get<AcceptsTelemetryIF>(PACKET_DESTINATION);
|
||||
if (psbParams.tmReceiver != nullptr) {
|
||||
psbParams.reqQueue->setDefaultDestination(psbParams.tmReceiver->getReportReceptionQueue());
|
||||
}
|
||||
}
|
||||
|
||||
if (psbParams.pusDistributor != nullptr) {
|
||||
psbParams.pusDistributor = ObjectManager::instance()->get<PUSDistributorIF>(pusDistributor);
|
||||
if (psbParams.pusDistributor == nullptr) {
|
||||
psbParams.pusDistributor = ObjectManager::instance()->get<PUSDistributorIF>(PUS_DISTRIBUTOR);
|
||||
if (psbParams.pusDistributor != nullptr) {
|
||||
registerService(*psbParams.pusDistributor);
|
||||
}
|
||||
@ -127,17 +133,10 @@ ReturnValue_t PusServiceBase::initialize() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::initializeAfterTaskCreation() {
|
||||
// If task parameters, for example task frequency are required, this
|
||||
// function should be overriden and the system object task IF can
|
||||
// be used to get those parameters.
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
void PusServiceBase::setTcPool(StorageManagerIF& tcPool) { psbParams.tcPool = &tcPool; }
|
||||
|
||||
void PusServiceBase::setCustomTcStore(StorageManagerIF* tcPool) { psbParams.tcPool = tcPool; }
|
||||
|
||||
void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) {
|
||||
psbParams.errReporter = errReporter_;
|
||||
void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) {
|
||||
psbParams.errReporter = &errReporter_;
|
||||
}
|
||||
|
||||
void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) {
|
||||
@ -155,8 +154,10 @@ void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) {
|
||||
psbParams.errReporter =
|
||||
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (psbParams.errReporter != nullptr) {
|
||||
tmSendHelper.setInternalErrorReporter(psbParams.errReporter);
|
||||
tmSendHelper.setInternalErrorReporter(*psbParams.errReporter);
|
||||
}
|
||||
} else {
|
||||
tmSendHelper.setInternalErrorReporter(*psbParams.errReporter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,16 +165,16 @@ void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const
|
||||
tmStoreHelper.setApid(psbParams.apid);
|
||||
}
|
||||
|
||||
void PusServiceBase::setVerificationReporter(VerificationReporterIF* reporter) {
|
||||
psbParams.verifReporter = reporter;
|
||||
void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) {
|
||||
psbParams.verifReporter = &reporter;
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::registerService(PUSDistributorIF& distributor) {
|
||||
return distributor.registerService(this);
|
||||
}
|
||||
|
||||
void PusServiceBase::setTmReceiver(AcceptsTelemetryIF* tmReceiver_) {
|
||||
psbParams.tmReceiver = tmReceiver_;
|
||||
void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) {
|
||||
psbParams.tmReceiver = &tmReceiver_;
|
||||
}
|
||||
|
||||
void PusServiceBase::setRequestQueue(MessageQueueIF* reqQueue) { psbParams.reqQueue = reqQueue; }
|
||||
void PusServiceBase::setRequestQueue(MessageQueueIF& reqQueue) { psbParams.reqQueue = &reqQueue; }
|
||||
|
@ -14,10 +14,6 @@
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/tcdistribution/PUSDistributorIF.h"
|
||||
|
||||
namespace Factory {
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
class StorageManagerIF;
|
||||
|
||||
/**
|
||||
@ -71,6 +67,10 @@ struct PsbParams {
|
||||
PUSDistributorIF* pusDistributor = nullptr;
|
||||
};
|
||||
|
||||
namespace Factory {
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* @defgroup pus_services PUS Service Framework
|
||||
* These group contains all implementations of PUS Services in the OBSW.
|
||||
@ -93,7 +93,7 @@ class PusServiceBase : public ExecutableObjectIF,
|
||||
public AcceptsTelecommandsIF,
|
||||
public SystemObject,
|
||||
public HasReturnvaluesIF {
|
||||
friend void(Factory::setStaticFrameworkObjectIds)();
|
||||
friend void Factory::setStaticFrameworkObjectIds();
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -121,11 +121,11 @@ class PusServiceBase : public ExecutableObjectIF,
|
||||
* function will create one
|
||||
* @param reqQueue
|
||||
*/
|
||||
void setRequestQueue(MessageQueueIF* reqQueue);
|
||||
void setTmReceiver(AcceptsTelemetryIF* tmReceiver);
|
||||
void setCustomTcStore(StorageManagerIF* tcStore);
|
||||
void setVerificationReporter(VerificationReporterIF* reporter);
|
||||
void setCustomErrorReporter(InternalErrorReporterIF* errReporter);
|
||||
void setRequestQueue(MessageQueueIF& reqQueue);
|
||||
void setTmReceiver(AcceptsTelemetryIF& tmReceiver);
|
||||
void setTcPool(StorageManagerIF& tcStore);
|
||||
void setVerificationReporter(VerificationReporterIF& reporter);
|
||||
void setErrorReporter(InternalErrorReporterIF& errReporter);
|
||||
|
||||
/**
|
||||
* Helper methods if the implementing class wants to send telemetry
|
||||
@ -190,7 +190,6 @@ class PusServiceBase : public ExecutableObjectIF,
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
void setTaskIF(PeriodicTaskIF* taskHandle) override;
|
||||
ReturnValue_t initializeAfterTaskCreation() override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -215,9 +214,8 @@ class PusServiceBase : public ExecutableObjectIF,
|
||||
PusTcReader currentPacket;
|
||||
bool ownedQueue = true;
|
||||
|
||||
static object_id_t packetDestination;
|
||||
static object_id_t pusDistributor;
|
||||
VerifSuccessParams successParams;
|
||||
static object_id_t PACKET_DESTINATION;
|
||||
static object_id_t PUS_DISTRIBUTOR;
|
||||
|
||||
private:
|
||||
void handleRequestQueue();
|
||||
|
@ -30,8 +30,8 @@ ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) {
|
||||
|
||||
void TmSendHelper::setDefaultDestination(MessageQueueId_t msgDest) { defaultDest = msgDest; }
|
||||
|
||||
void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) {
|
||||
errReporter = reporter;
|
||||
void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF &reporter) {
|
||||
errReporter = &reporter;
|
||||
}
|
||||
void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; }
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TmSendHelper {
|
||||
[[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(const store_address_t& storeId);
|
||||
|
@ -54,7 +54,7 @@ void Factory::produceFrameworkObjects(void* args) {
|
||||
// like this. Instead, this should be more like a general struct containing all important
|
||||
// object IDs which are then explicitely passed in the object constructor
|
||||
void Factory::setStaticFrameworkObjectIds() {
|
||||
PusServiceBase::packetDestination = objects::NO_OBJECT;
|
||||
PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT;
|
||||
|
||||
CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
|
||||
CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
|
||||
@ -62,9 +62,7 @@ void Factory::setStaticFrameworkObjectIds() {
|
||||
DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
||||
DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
|
||||
|
||||
// TODO: Incredibly ugly, get rid of it
|
||||
LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT;
|
||||
|
||||
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include "AcceptsTmMock.h"
|
||||
|
||||
AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) : returnedQueue(queueToReturn) {}
|
||||
AcceptsTmMock::AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn)
|
||||
: SystemObject(registeredId), returnedQueue(queueToReturn) {}
|
||||
|
||||
AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn)
|
||||
: SystemObject(objects::NO_OBJECT, false), returnedQueue(queueToReturn) {}
|
||||
|
||||
MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) {
|
||||
return returnedQueue;
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef FSFW_TESTS_ACCEPTSTMMOCK_H
|
||||
#define FSFW_TESTS_ACCEPTSTMMOCK_H
|
||||
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
|
||||
class AcceptsTmMock : public AcceptsTelemetryIF {
|
||||
class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF {
|
||||
public:
|
||||
AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn);
|
||||
explicit AcceptsTmMock(MessageQueueId_t queueToReturn);
|
||||
|
||||
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override;
|
||||
|
@ -10,4 +10,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE
|
||||
PusVerificationReporterMock.cpp
|
||||
PusServiceBaseMock.cpp
|
||||
AcceptsTmMock.cpp
|
||||
PusDistributorMock.cpp
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCom
|
||||
mode = MODE_ON;
|
||||
}
|
||||
|
||||
DeviceHandlerMock::~DeviceHandlerMock() {}
|
||||
DeviceHandlerMock::~DeviceHandlerMock() = default;
|
||||
|
||||
void DeviceHandlerMock::doStartUp() { setMode(_MODE_TO_ON); }
|
||||
|
||||
|
12
unittests/mocks/PusDistributorMock.cpp
Normal file
12
unittests/mocks/PusDistributorMock.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "PusDistributorMock.h"
|
||||
|
||||
PusDistributorMock::PusDistributorMock() : SystemObject(objects::NO_OBJECT, false) {}
|
||||
|
||||
PusDistributorMock::PusDistributorMock(object_id_t registeredId)
|
||||
: SystemObject(registeredId, true) {}
|
||||
|
||||
ReturnValue_t PusDistributorMock::registerService(AcceptsTelecommandsIF *service) {
|
||||
registerCallCount++;
|
||||
lastServiceArg = service;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
16
unittests/mocks/PusDistributorMock.h
Normal file
16
unittests/mocks/PusDistributorMock.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef FSFW_TESTS_PUSDISTRIBUTORMOCK_H
|
||||
#define FSFW_TESTS_PUSDISTRIBUTORMOCK_H
|
||||
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/tcdistribution/PUSDistributorIF.h"
|
||||
|
||||
class PusDistributorMock : public SystemObject, public PUSDistributorIF {
|
||||
public:
|
||||
PusDistributorMock();
|
||||
explicit PusDistributorMock(object_id_t registeredId);
|
||||
unsigned int registerCallCount = 0;
|
||||
AcceptsTelecommandsIF* lastServiceArg = nullptr;
|
||||
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
|
||||
};
|
||||
|
||||
#endif // FSFW_TESTS_PUSDISTRIBUTORMOCK_H
|
@ -39,3 +39,15 @@ bool PsbMock::getAndPopNextSubservice(uint8_t& subservice) {
|
||||
subserviceQueue.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
PsbParams& PsbMock::getParams() { return psbParams; }
|
||||
|
||||
void PsbMock::setStaticPusDistributor(object_id_t pusDistributor) {
|
||||
PUS_DISTRIBUTOR = pusDistributor;
|
||||
}
|
||||
|
||||
object_id_t PsbMock::getStaticPusDistributor() { return PUS_DISTRIBUTOR; }
|
||||
|
||||
void PsbMock::setStaticTmDest(object_id_t tmDest) { PACKET_DESTINATION = tmDest; }
|
||||
|
||||
object_id_t PsbMock::getStaticTmDest() { return PACKET_DESTINATION; }
|
||||
|
@ -12,6 +12,13 @@ class PsbMock : public PusServiceBase {
|
||||
std::queue<uint8_t> subserviceQueue;
|
||||
unsigned int performServiceCallCnt = 0;
|
||||
|
||||
static void setStaticPusDistributor(object_id_t pusDistributor);
|
||||
static object_id_t getStaticPusDistributor();
|
||||
static void setStaticTmDest(object_id_t tmDest);
|
||||
static object_id_t getStaticTmDest();
|
||||
|
||||
PsbParams& getParams();
|
||||
|
||||
std::pair<bool, ReturnValue_t> handleReqFailPair;
|
||||
std::pair<bool, ReturnValue_t> performServiceFailPair;
|
||||
ReturnValue_t handleRequest(uint8_t subservice) override;
|
||||
|
@ -4,15 +4,18 @@
|
||||
#include "fsfw/storagemanager/LocalPool.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"
|
||||
|
||||
TEST_CASE("Pus Service Base", "[pus-service-base]") {
|
||||
uint16_t apid = 2;
|
||||
auto verificationReporter = PusVerificationReporterMock();
|
||||
auto msgQueue = MessageQueueMock(1);
|
||||
auto tmReceiver = AcceptsTmMock(2);
|
||||
auto psbParams = PsbParams(0, 0x02, 17);
|
||||
auto psbParams = PsbParams(0, apid, 17);
|
||||
|
||||
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
|
||||
LocalPool pool(objects::NO_OBJECT, cfg);
|
||||
@ -38,6 +41,9 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") {
|
||||
SECTION("State") {
|
||||
REQUIRE(psb.getIdentifier() == 17);
|
||||
REQUIRE(psb.getObjectId() == 0);
|
||||
REQUIRE(psb.getRequestQueue() == msgQueue.getId());
|
||||
auto psbParamsLocal = psb.getParams();
|
||||
REQUIRE(psbParamsLocal.errReporter == nullptr);
|
||||
}
|
||||
|
||||
SECTION("Perform Service") {
|
||||
@ -87,4 +93,106 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") {
|
||||
REQUIRE(verifParams.tcPacketId == creator.getPacketIdRaw());
|
||||
REQUIRE(verifParams.tcPsc == creator.getPacketSeqCtrlRaw());
|
||||
}
|
||||
|
||||
SECTION("Invalid Packet Sent") {
|
||||
tmtcMsg.setStorageId(store_address_t::invalid());
|
||||
msgQueue.addReceivedMessage(tmtcMsg);
|
||||
REQUIRE(psb.performOperation(0) == retval::OK);
|
||||
REQUIRE(verificationReporter.failCallCount() == 1);
|
||||
auto verifParams = verificationReporter.getNextFailCallParams();
|
||||
REQUIRE(verifParams.tcPacketId == 0);
|
||||
REQUIRE(verifParams.tcPsc == 0);
|
||||
}
|
||||
|
||||
SECTION("Set Verif Reporter") {
|
||||
auto verificationReporter2 = PusVerificationReporterMock();
|
||||
psb.setVerificationReporter(verificationReporter2);
|
||||
auto& p = psb.getParams();
|
||||
REQUIRE(p.verifReporter == &verificationReporter2);
|
||||
}
|
||||
|
||||
SECTION("Set Request Queue") {
|
||||
auto msgQueueMock = MessageQueueMock(2);
|
||||
psb.setRequestQueue(msgQueueMock);
|
||||
auto& p = psb.getParams();
|
||||
REQUIRE(p.reqQueue == &msgQueueMock);
|
||||
}
|
||||
|
||||
SECTION("Set TM Receiver") {
|
||||
auto tmReceiver2 = AcceptsTmMock(3);
|
||||
psb.setTmReceiver(tmReceiver2);
|
||||
auto& p = psb.getParams();
|
||||
REQUIRE(p.tmReceiver == &tmReceiver2);
|
||||
}
|
||||
|
||||
SECTION("Set TC Store") {
|
||||
LocalPool tcStore2(5, cfg);
|
||||
psb.setTcPool(tcStore2);
|
||||
auto& p = psb.getParams();
|
||||
REQUIRE(p.tcPool == &tcStore2);
|
||||
}
|
||||
|
||||
SECTION("Set error reporter") {
|
||||
auto errReporter = InternalErrorReporterMock();
|
||||
psb.setErrorReporter(errReporter);
|
||||
auto& p = psb.getParams();
|
||||
REQUIRE(p.errReporter == &errReporter);
|
||||
}
|
||||
SECTION("Owner Queue") {
|
||||
// This will cause the initialize function to create a new owner queue
|
||||
psbParams.reqQueue = nullptr;
|
||||
psbParams.objectId = 1;
|
||||
auto mockWithOwnerQueue = PsbMock(psbParams);
|
||||
REQUIRE(mockWithOwnerQueue.getRequestQueue() == MessageQueueIF::NO_QUEUE);
|
||||
REQUIRE(mockWithOwnerQueue.initialize() == retval::OK);
|
||||
REQUIRE(mockWithOwnerQueue.getRequestQueue() != MessageQueueIF::NO_QUEUE);
|
||||
}
|
||||
|
||||
SECTION("TM Store Helper Initializer") {
|
||||
TmStoreHelper storeHelper(0);
|
||||
psb.initializeTmStoreHelper(storeHelper);
|
||||
REQUIRE(storeHelper.getApid() == apid);
|
||||
}
|
||||
|
||||
SECTION("TM Send Helper Initializer") {
|
||||
TmSendHelper sendHelper;
|
||||
psb.initializeTmSendHelper(sendHelper);
|
||||
REQUIRE(sendHelper.getMsgQueue() == &msgQueue);
|
||||
REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination());
|
||||
}
|
||||
|
||||
SECTION("TM Send Helper Initializer With Error Reporter") {
|
||||
TmSendHelper sendHelper;
|
||||
auto errReporter = InternalErrorReporterMock();
|
||||
psb.setErrorReporter(errReporter);
|
||||
psb.initializeTmSendHelper(sendHelper);
|
||||
REQUIRE(sendHelper.getMsgQueue() == &msgQueue);
|
||||
REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination());
|
||||
REQUIRE(sendHelper.getInternalErrorReporter() == &errReporter);
|
||||
}
|
||||
|
||||
SECTION("Auto Initialize PUS Distributor") {
|
||||
psbParams.objectId = 1;
|
||||
object_id_t distributorId = 3;
|
||||
auto psb2 = PsbMock(psbParams);
|
||||
auto pusDistrib = PusDistributorMock(distributorId);
|
||||
PsbMock::setStaticPusDistributor(distributorId);
|
||||
REQUIRE(PsbMock::getStaticPusDistributor() == distributorId);
|
||||
REQUIRE(psb2.initialize() == retval::OK);
|
||||
REQUIRE(pusDistrib.registerCallCount == 1);
|
||||
REQUIRE(pusDistrib.lastServiceArg == &psb2);
|
||||
}
|
||||
|
||||
SECTION("Auto Initialize Packet Destination") {
|
||||
psbParams.tmReceiver = nullptr;
|
||||
psbParams.objectId = 1;
|
||||
object_id_t destId = 3;
|
||||
auto psb2 = PsbMock(psbParams);
|
||||
auto packetDest = AcceptsTmMock(destId, 2);
|
||||
PsbMock::setStaticTmDest(destId);
|
||||
REQUIRE(PsbMock::getStaticTmDest() == destId);
|
||||
REQUIRE(psb2.initialize() == retval::OK);
|
||||
auto& p = psb2.getParams();
|
||||
REQUIRE(p.tmReceiver == &packetDest);
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,9 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") {
|
||||
REQUIRE(sendHelper.getDefaultDestination() == destId);
|
||||
sendHelper.setDefaultDestination(destId + 1);
|
||||
REQUIRE(sendHelper.getDefaultDestination() == destId + 1);
|
||||
sendHelper.setInternalErrorReporter(nullptr);
|
||||
REQUIRE(sendHelper.getInternalErrorReporter() == nullptr);
|
||||
auto errReporter2 = InternalErrorReporterMock();
|
||||
sendHelper.setInternalErrorReporter(errReporter2);
|
||||
REQUIRE(sendHelper.getInternalErrorReporter() == &errReporter2);
|
||||
}
|
||||
|
||||
SECTION("Default CTOR") {
|
||||
|
Loading…
Reference in New Issue
Block a user