continue source handler

This commit is contained in:
Robin Müller 2023-08-03 13:03:58 +02:00
parent a856f91c67
commit 3167988951
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
10 changed files with 29 additions and 12 deletions

View File

@ -40,6 +40,7 @@ cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwParams fsfwPa
cfdp::SourceHandler::FsmResult& cfdp::SourceHandler::fsmNacked() {
ReturnValue_t result;
if (step == TransactionStep::IDLE) {
fsmResult.packetsSent = 0;
step = TransactionStep::TRANSACTION_START;
}
if (step == TransactionStep::TRANSACTION_START) {
@ -203,6 +204,7 @@ ReturnValue_t cfdp::SourceHandler::prepareAndSendMetadataPdu() {
if (result != OK) {
return result;
}
fsmResult.packetsSent += 1;
// Advance FSM if everything works
step = TransactionStep::SENDING_FILE_DATA;
return OK;

View File

@ -57,7 +57,7 @@ TEST_CASE("Action Helper", "[action]") {
step += 1;
CHECK(testMqMock.wasMessageSent());
CommandMessage testMessage;
REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK);
REQUIRE(testMqMock.getNextSentMessageToDefaultDest(testMessage) == returnvalue::OK);
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
REQUIRE(testMessage.getParameter() == static_cast<uint32_t>(testActionId));
uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status;
@ -71,7 +71,7 @@ TEST_CASE("Action Helper", "[action]") {
actionHelper.finish(false, testMqMock.getId(), testActionId, status);
CHECK(testMqMock.wasMessageSent());
CommandMessage testMessage;
REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK);
REQUIRE(testMqMock.getNextSentMessageToDefaultDest(testMessage) == returnvalue::OK);
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::COMPLETION_FAILED));
REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(status));
@ -87,7 +87,7 @@ TEST_CASE("Action Helper", "[action]") {
REQUIRE(ipcStore->getData(toLongParamAddress).first ==
static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
CommandMessage testMessage;
REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK);
REQUIRE(testMqMock.getNextSentMessageToDefaultDest(testMessage) == returnvalue::OK);
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE);
REQUIRE(ActionMessage::getStep(&testMessage) == 0);

View File

@ -2,11 +2,13 @@
#include <filesystem>
#include "fsfw/cfdp.h"
#include "fsfw/cfdp/CfdpMessage.h"
#include "fsfw/cfdp/handler/PutRequest.h"
#include "fsfw/cfdp/handler/SourceHandler.h"
#include "fsfw/cfdp/pdu/EofPduCreator.h"
#include "fsfw/cfdp/pdu/FileDataCreator.h"
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/util/SeqCountProvider.h"
#include "mocks/AcceptsTmMock.h"
#include "mocks/EventReportingProxyMock.h"
@ -38,7 +40,10 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
StorageManagerMock tcStore(2, storeCfg);
StorageManagerMock tmStore(3, storeCfg);
FsfwParams fp(tmReceiver, &mqMock, &eventReporterMock);
fp.tcStore = &tcStore;
fp.tmStore = &tmStore;
auto sourceHandler = SourceHandler(dp, fp);
CHECK(sourceHandler.initialize() == OK);
SECTION("Test Basic") {
CHECK(sourceHandler.getState() == CfdpState::IDLE);
@ -46,6 +51,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
}
SECTION("Transfer empty file") {
// using StorageManagerIF::getData;
RemoteEntityCfg cfg;
EntityId id(cfdp::WidthInBytes::ONE_BYTE, 5);
cfg.remoteId = id;
@ -56,5 +62,13 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
cfdp::StringLv destNameLv(destFileName.path, std::strlen(destFileName.path));
PutRequest putRequest(id, srcNameLv, destNameLv);
CHECK(sourceHandler.transactionStart(putRequest, cfg) == OK);
SourceHandler::FsmResult& fsmResult = sourceHandler.stateMachine();
CHECK(fsmResult.packetsSent == 1);
CHECK(mqMock.numberOfSentMessages() == 1);
CommandMessage msg;
CHECK(mqMock.getNextSentMessage(destQueueId, msg) == OK);
store_address_t storeId = CfdpMessage::getStoreId(&msg);
auto accessor = tmStore.getData(storeId);
// CHECK(fsmResult.)
}
}

View File

@ -82,7 +82,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK);
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == returnvalue::OK);
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);
@ -259,11 +259,11 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") {
CHECK(messageSent.getCommand() ==
static_cast<int>(HousekeepingMessage::UPDATE_NOTIFICATION_SET));
REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == returnvalue::OK);
REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == 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.getNextSentMessage(messageSent) == MessageQueueIF::EMPTY);
REQUIRE(poolOwnerMock.getNextSentMessageToDefaultDest(messageSent) == MessageQueueIF::EMPTY);
}
SECTION("PeriodicHKAndMessaging") {

View File

@ -9,8 +9,8 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF {
AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn);
explicit AcceptsTmMock(MessageQueueId_t queueToReturn);
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override;
const char* getName() const override;
[[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override;
[[nodiscard]] const char* getName() const override;
MessageQueueId_t returnedQueue;
};

View File

@ -124,7 +124,7 @@ ReturnValue_t MessageQueueMock::getNextSentMessage(MessageQueueId_t id,
return returnvalue::OK;
}
ReturnValue_t MessageQueueMock::getNextSentMessage(MessageQueueMessageIF& message) {
ReturnValue_t MessageQueueMock::getNextSentMessageToDefaultDest(MessageQueueMessageIF& message) {
return getNextSentMessage(MessageQueueBase::getDefaultDestination(), message);
}

View File

@ -26,7 +26,7 @@ class MessageQueueMock : public MessageQueueBase {
explicit MessageQueueMock(MessageQueueId_t queueId);
//! Get next message which was sent to the default destination
ReturnValue_t getNextSentMessage(MessageQueueMessageIF& message);
ReturnValue_t getNextSentMessageToDefaultDest(MessageQueueMessageIF& message);
//! Get message which was sent to a specific ID
ReturnValue_t getNextSentMessage(MessageQueueId_t id, MessageQueueMessageIF& message);
[[nodiscard]] bool wasMessageSent() const;

View File

@ -32,6 +32,7 @@ class StorageManagerMock : public LocalPool {
std::pair<bool, ReturnValue_t> nextFreeElementCallFails;
using LocalPool::getFreeElement;
using StorageManagerIF::getData;
void reset();
};

View File

@ -71,7 +71,7 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") {
REQUIRE(msgQueue.wasMessageSent());
REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1);
TmTcMessage msg;
REQUIRE(msgQueue.getNextSentMessage(msg) == returnvalue::OK);
REQUIRE(msgQueue.getNextSentMessageToDefaultDest(msg) == returnvalue::OK);
REQUIRE(msg.getStorageId() == storeId);
REQUIRE(pool.hasDataAtId(msg.getStorageId()));
}

View File

@ -52,7 +52,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") {
REQUIRE(msgQueue.wasMessageSent());
REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1);
TmTcMessage msg;
REQUIRE(msgQueue.getNextSentMessage(msg) == returnvalue::OK);
REQUIRE(msgQueue.getNextSentMessageToDefaultDest(msg) == returnvalue::OK);
REQUIRE(msg.getStorageId() == storeId);
REQUIRE(pool.hasDataAtId(msg.getStorageId()));
storeHelper.deletePacket();