psb unittests almost complete

This commit is contained in:
Robin Müller 2022-07-26 18:58:36 +02:00
parent 8bf0fb9885
commit 152c01b2ec
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
5 changed files with 45 additions and 3 deletions

View File

@ -5,6 +5,7 @@
#include "fsfw/tmtcservices/PusVerificationReport.h"
object_id_t VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
object_id_t VerificationReporter::DEFAULT_REPORTER = objects::TC_VERIFICATOR;
VerificationReporter::VerificationReporter(AcceptsVerifyMessageIF* receiver, object_id_t objectId)
: SystemObject(objectId) {

View File

@ -8,6 +8,10 @@
#include "fsfw/tmtcpacket/pus/tc/PusTcCreator.h"
#include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h"
namespace Factory {
void setStaticFrameworkObjectIds();
}
/**
* @brief This helper object is used to forward verification messages
* which are generated by the Flight Software Framework.
@ -20,9 +24,11 @@
*
*/
class VerificationReporter : public SystemObject, public VerificationReporterIF {
friend void Factory::setStaticFrameworkObjectIds();
public:
explicit VerificationReporter(AcceptsVerifyMessageIF* receiver,
object_id_t objectId = objects::TC_VERIFICATOR);
object_id_t objectId = DEFAULT_REPORTER);
~VerificationReporter() override;
void setReceiver(AcceptsVerifyMessageIF& receiver);
@ -33,6 +39,7 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF
ReturnValue_t sendFailureReport(VerifFailureParams params) override;
static object_id_t DEFAULT_REPORTER;
static object_id_t DEFAULT_RECEIVER;
ReturnValue_t initialize() override;

View File

@ -1,5 +1,13 @@
#include "PusVerificationReporterMock.h"
#include "fsfw/objectmanager/frameworkObjects.h"
PusVerificationReporterMock::PusVerificationReporterMock()
: SystemObject(objects::NO_OBJECT, false) {}
PusVerificationReporterMock::PusVerificationReporterMock(object_id_t registeredId)
: SystemObject(registeredId) {}
size_t PusVerificationReporterMock::successCallCount() const { return successParams.size(); }
size_t PusVerificationReporterMock::failCallCount() const { return failParams.size(); }

View File

@ -3,13 +3,15 @@
#include <queue>
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tmtcservices/VerificationReporterIF.h"
class PusVerificationReporterMock : public VerificationReporterIF {
class PusVerificationReporterMock : public SystemObject, public VerificationReporterIF {
public:
std::queue<VerifSuccessParams> successParams;
std::queue<VerifFailureParams> failParams;
PusVerificationReporterMock();
explicit PusVerificationReporterMock(object_id_t registeredId);
[[nodiscard]] size_t successCallCount() const;
VerifSuccessParams& getNextSuccessCallParams();
void popNextSuccessParams();

View File

@ -161,6 +161,15 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") {
REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination());
}
SECTION("TM Store And Send Helper Initializer") {
TmStoreHelper storeHelper(0);
TmSendHelper sendHelper;
psb.initializeTmHelpers(sendHelper, storeHelper);
REQUIRE(sendHelper.getMsgQueue() == &msgQueue);
REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination());
REQUIRE(storeHelper.getApid() == apid);
}
SECTION("TM Send Helper Initializer With Error Reporter") {
TmSendHelper sendHelper;
auto errReporter = InternalErrorReporterMock();
@ -195,4 +204,19 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") {
auto& p = psb2.getParams();
REQUIRE(p.tmReceiver == &packetDest);
}
SECTION("Auto Initialize Verification Reporter") {
psbParams.verifReporter = nullptr;
psbParams.objectId = 1;
object_id_t reporterId = objects::TC_VERIFICATOR;
PusVerificationReporterMock otherReporter(reporterId);
auto psb2 = PsbMock(psbParams);
REQUIRE(psb2.initialize() == retval::OK);
auto& p = psb2.getParams();
REQUIRE(p.verifReporter == &otherReporter);
}
SECTION("Auto Initialize TC Pool") {}
SECTION("Invalid Verification Reporter") {}
}