default PUS receiver set automatically now
This commit is contained in:
@ -31,3 +31,11 @@ void PsbMock::makeNextHandleReqCallFail(ReturnValue_t retval) {
|
||||
handleReqFailPair.first = true;
|
||||
handleReqFailPair.second = retval;
|
||||
}
|
||||
bool PsbMock::getAndPopNextSubservice(uint8_t& subservice) {
|
||||
if (subserviceQueue.empty()) {
|
||||
return false;
|
||||
}
|
||||
subservice = subserviceQueue.front();
|
||||
subserviceQueue.pop();
|
||||
return true;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ class PsbMock : public PusServiceBase {
|
||||
ReturnValue_t performService() override;
|
||||
|
||||
void makeNextHandleReqCallFail(ReturnValue_t retval);
|
||||
bool getAndPopNextSubservice(uint8_t& subservice);
|
||||
void reset();
|
||||
};
|
||||
|
||||
|
@ -16,8 +16,19 @@ void PusVerificationReporterMock::popNextFailParams() {
|
||||
VerifFailureParams& PusVerificationReporterMock::getNextFailCallParams() {
|
||||
return failParams.front();
|
||||
}
|
||||
|
||||
void PusVerificationReporterMock::popNextSuccessParams() {
|
||||
if (not successParams.empty()) {
|
||||
successParams.pop();
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PusVerificationReporterMock::sendSuccessReport(VerifSuccessParams params) {
|
||||
successParams.push(params);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PusVerificationReporterMock::sendFailureReport(VerifFailureParams params) {
|
||||
failParams.push(params);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class PusVerificationReporterMock : public VerificationReporterIF {
|
||||
VerifFailureParams& getNextFailCallParams();
|
||||
void popNextFailParams();
|
||||
|
||||
ReturnValue_t sendSuccessReport(VerifSuccessParams params) override { return 0; }
|
||||
ReturnValue_t sendFailureReport(VerifFailureParams params) override { return 0; }
|
||||
ReturnValue_t sendSuccessReport(VerifSuccessParams params) override;
|
||||
ReturnValue_t sendFailureReport(VerifFailureParams params) override;
|
||||
};
|
||||
#endif // FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/storagemanager/LocalPool.h"
|
||||
#include "mocks/AcceptsTmMock.h"
|
||||
#include "mocks/CdsShortTimestamperMock.h"
|
||||
#include "mocks/MessageQueueMock.h"
|
||||
#include "mocks/PusServiceBaseMock.h"
|
||||
#include "mocks/PusVerificationReporterMock.h"
|
||||
@ -11,13 +13,26 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") {
|
||||
auto msgQueue = MessageQueueMock(1);
|
||||
auto tmReceiver = AcceptsTmMock(2);
|
||||
auto psbParams = PsbParams(0, 0x02, 17);
|
||||
|
||||
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
|
||||
LocalPool pool(objects::NO_OBJECT, cfg);
|
||||
|
||||
psbParams.verifReporter = &verificationReporter;
|
||||
psbParams.reqQueue = &msgQueue;
|
||||
psbParams.tmReceiver = &tmReceiver;
|
||||
psbParams.tcPool = &pool;
|
||||
auto psb = PsbMock(psbParams);
|
||||
store_address_t dummyId(1);
|
||||
auto reqQueue = psb.getRequestQueue();
|
||||
TmTcMessage tmtcMsg(dummyId);
|
||||
|
||||
store_address_t storeId;
|
||||
TmTcMessage tmtcMsg;
|
||||
|
||||
// Components to create valid PUS packets
|
||||
auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02);
|
||||
auto spParams =
|
||||
SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 0x34), 0x00);
|
||||
auto pusParams = PusTcParams(17, 1);
|
||||
PusTcCreator creator(spParams, pusParams);
|
||||
|
||||
REQUIRE(psb.initialize() == HasReturnvaluesIF::RETURN_OK);
|
||||
|
||||
SECTION("State") {
|
||||
@ -25,8 +40,51 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") {
|
||||
REQUIRE(psb.getObjectId() == 0);
|
||||
}
|
||||
|
||||
SECTION("Send Request") {
|
||||
SECTION("Perform Service") {
|
||||
REQUIRE(psb.performServiceCallCnt == 0);
|
||||
REQUIRE(psb.performOperation(0) == retval::OK);
|
||||
REQUIRE(psb.performServiceCallCnt == 1);
|
||||
}
|
||||
|
||||
SECTION("Send Request with Successful Handling") {
|
||||
REQUIRE(psb.performServiceCallCnt == 0);
|
||||
uint8_t* dataPtr;
|
||||
REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK);
|
||||
REQUIRE(creator.serializeBe(dataPtr, creator.getSerializedSize()) == retval::OK);
|
||||
tmtcMsg.setStorageId(storeId);
|
||||
msgQueue.addReceivedMessage(tmtcMsg);
|
||||
REQUIRE(psb.performOperation(0) == retval::OK);
|
||||
uint8_t subservice = 0;
|
||||
REQUIRE(psb.getAndPopNextSubservice(subservice));
|
||||
REQUIRE(subservice == 1);
|
||||
REQUIRE(psb.performServiceCallCnt == 1);
|
||||
// PSB should take care of freeing the pool slot
|
||||
REQUIRE(not pool.hasDataAtId(storeId));
|
||||
REQUIRE(verificationReporter.successCallCount() == 1);
|
||||
REQUIRE(verificationReporter.failCallCount() == 0);
|
||||
auto verifParams = verificationReporter.getNextSuccessCallParams();
|
||||
REQUIRE(verifParams.tcPacketId == creator.getPacketIdRaw());
|
||||
REQUIRE(verifParams.tcPsc == creator.getPacketSeqCtrlRaw());
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Send Request with Failed Handling") {
|
||||
uint8_t* dataPtr;
|
||||
REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK);
|
||||
REQUIRE(creator.serializeBe(dataPtr, creator.getSerializedSize()) == retval::OK);
|
||||
tmtcMsg.setStorageId(storeId);
|
||||
msgQueue.addReceivedMessage(tmtcMsg);
|
||||
psb.makeNextHandleReqCallFail(3);
|
||||
REQUIRE(psb.performOperation(0) == retval::OK);
|
||||
uint8_t subservice = 0;
|
||||
REQUIRE(psb.getAndPopNextSubservice(subservice));
|
||||
REQUIRE(subservice == 1);
|
||||
REQUIRE(psb.performServiceCallCnt == 1);
|
||||
// PSB should take care of freeing the pool slot
|
||||
REQUIRE(not pool.hasDataAtId(storeId));
|
||||
REQUIRE(verificationReporter.successCallCount() == 0);
|
||||
REQUIRE(verificationReporter.failCallCount() == 1);
|
||||
auto verifParams = verificationReporter.getNextFailCallParams();
|
||||
REQUIRE(verifParams.tcPacketId == creator.getPacketIdRaw());
|
||||
REQUIRE(verifParams.tcPsc == creator.getPacketSeqCtrlRaw());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user