2022-08-08 12:41:05 +02:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
|
|
|
2022-08-09 15:46:42 +02:00
|
|
|
#include "fsfw/cfdp.h"
|
2022-09-05 14:20:01 +02:00
|
|
|
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
|
2022-09-05 11:19:23 +02:00
|
|
|
#include "mocks/AcceptsTmMock.h"
|
2022-09-05 11:37:41 +02:00
|
|
|
#include "mocks/EventReportingProxyMock.h"
|
2022-08-17 17:09:39 +02:00
|
|
|
#include "mocks/FilesystemMock.h"
|
2022-09-05 11:19:23 +02:00
|
|
|
#include "mocks/MessageQueueMock.h"
|
2022-09-05 11:37:41 +02:00
|
|
|
#include "mocks/StorageManagerMock.h"
|
2022-08-09 19:00:47 +02:00
|
|
|
#include "mocks/cfdp/FaultHandlerMock.h"
|
2022-08-17 17:09:39 +02:00
|
|
|
#include "mocks/cfdp/RemoteConfigTableMock.h"
|
2022-08-10 11:09:07 +02:00
|
|
|
#include "mocks/cfdp/UserMock.h"
|
2022-08-10 15:03:53 +02:00
|
|
|
|
2022-08-09 15:46:42 +02:00
|
|
|
TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|
|
|
using namespace cfdp;
|
2022-09-05 11:37:41 +02:00
|
|
|
using namespace returnvalue;
|
2022-09-05 11:19:23 +02:00
|
|
|
MessageQueueId_t destQueueId = 2;
|
|
|
|
AcceptsTmMock tmReceiver(destQueueId);
|
|
|
|
MessageQueueMock mqMock(destQueueId);
|
2022-08-09 16:36:35 +02:00
|
|
|
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
|
2022-09-05 14:20:01 +02:00
|
|
|
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(3));
|
2022-08-09 19:00:47 +02:00
|
|
|
auto fhMock = FaultHandlerMock();
|
2022-08-09 16:36:35 +02:00
|
|
|
auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock);
|
2022-08-17 17:09:39 +02:00
|
|
|
auto fsMock = FilesystemMock();
|
|
|
|
auto userMock = UserMock(fsMock);
|
|
|
|
auto remoteCfgTableMock = RemoteConfigTableMock();
|
2022-09-05 11:19:23 +02:00
|
|
|
PacketInfoList<64> packetInfoList;
|
|
|
|
LostSegmentsList<128> lostSegmentsList;
|
|
|
|
DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList,
|
|
|
|
lostSegmentsList);
|
2022-09-05 11:37:41 +02:00
|
|
|
EventReportingProxyMock eventReporterMock;
|
|
|
|
LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}};
|
|
|
|
StorageManagerMock tcStore(2, storeCfg);
|
|
|
|
StorageManagerMock tmStore(3, storeCfg);
|
|
|
|
FsfwParams fp(tmReceiver, mqMock, eventReporterMock);
|
|
|
|
fp.tcStore = &tcStore;
|
|
|
|
fp.tmStore = &tmStore;
|
|
|
|
auto destHandler = DestHandler(dp, fp);
|
|
|
|
CHECK(destHandler.initialize() == OK);
|
2022-08-09 15:46:42 +02:00
|
|
|
|
2022-09-05 11:37:41 +02:00
|
|
|
SECTION("State") {
|
|
|
|
CHECK(destHandler.getCfdpState() == CfdpStates::IDLE);
|
|
|
|
CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE);
|
|
|
|
}
|
2022-09-05 11:40:22 +02:00
|
|
|
|
2022-09-05 14:20:01 +02:00
|
|
|
SECTION("Idle State Machine Iteration") {
|
|
|
|
CHECK(destHandler.performStateMachine() == OK);
|
|
|
|
CHECK(destHandler.getCfdpState() == CfdpStates::IDLE);
|
|
|
|
CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE);
|
2022-09-05 11:40:22 +02:00
|
|
|
}
|
|
|
|
|
2022-09-05 14:20:01 +02:00
|
|
|
SECTION("Empty File Transfer") {
|
|
|
|
CHECK(destHandler.performStateMachine() == OK);
|
|
|
|
FileSize size(0);
|
|
|
|
std::string srcNameString = "hello.txt";
|
|
|
|
std::string destNameString = "hello-cpy.txt";
|
|
|
|
StringLv srcName(srcNameString);
|
|
|
|
StringLv destName(destNameString);
|
|
|
|
MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName);
|
|
|
|
auto seqNum = TransactionSeqNum(UnsignedByteField<uint16_t>(1));
|
|
|
|
PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum);
|
|
|
|
MetadataPduCreator metadataPdu(conf, info);
|
|
|
|
store_address_t storeId;
|
|
|
|
uint8_t* ptr;
|
|
|
|
CHECK(tcStore.getFreeElement(&storeId, metadataPdu.getSerializedSize(), &ptr) == OK);
|
|
|
|
size_t serLen = 0;
|
|
|
|
CHECK(metadataPdu.serialize(ptr, serLen, metadataPdu.getSerializedSize()) == OK);
|
|
|
|
PacketInfo packetInfo(metadataPdu.getPduType(), metadataPdu.getDirectiveCode(), storeId);
|
|
|
|
packetInfoList.push_back(packetInfo);
|
|
|
|
CHECK(destHandler.performStateMachine() == OK);
|
2022-09-05 11:40:22 +02:00
|
|
|
}
|
|
|
|
|
2022-09-05 14:20:01 +02:00
|
|
|
SECTION("Small File Transfer") {}
|
|
|
|
|
|
|
|
SECTION("Segmented File Transfer") {}
|
2022-08-09 15:46:42 +02:00
|
|
|
}
|