CFDP SOURCE handler #157
@ -33,7 +33,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
|||||||
AcceptsTmMock tmReceiver(destQueueId);
|
AcceptsTmMock tmReceiver(destQueueId);
|
||||||
MessageQueueMock mqMock(destQueueId);
|
MessageQueueMock mqMock(destQueueId);
|
||||||
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
|
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
|
||||||
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(3));
|
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(5));
|
||||||
FaultHandlerMock fhMock;
|
FaultHandlerMock fhMock;
|
||||||
LocalEntityCfg localEntityCfg(localId, IndicationCfg(), fhMock);
|
LocalEntityCfg localEntityCfg(localId, IndicationCfg(), fhMock);
|
||||||
FilesystemMock fsMock;
|
FilesystemMock fsMock;
|
||||||
@ -52,8 +52,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
|||||||
|
|
||||||
RemoteEntityCfg cfg;
|
RemoteEntityCfg cfg;
|
||||||
cfg.maxFileSegmentLen = MAX_FILE_SEGMENT_SIZE;
|
cfg.maxFileSegmentLen = MAX_FILE_SEGMENT_SIZE;
|
||||||
EntityId id(cfdp::WidthInBytes::TWO_BYTES, 5);
|
cfg.remoteId = remoteId;
|
||||||
cfg.remoteId = id;
|
|
||||||
std::string srcFileName = "/tmp/cfdp-test.txt";
|
std::string srcFileName = "/tmp/cfdp-test.txt";
|
||||||
std::string destFileName = "/tmp/cfdp-test2.txt";
|
std::string destFileName = "/tmp/cfdp-test2.txt";
|
||||||
FilesystemParams srcFileNameFs(srcFileName.c_str());
|
FilesystemParams srcFileNameFs(srcFileName.c_str());
|
||||||
@ -61,7 +60,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
|||||||
cfdp::StringLv srcNameLv(srcFileNameFs.path, std::strlen(srcFileNameFs.path));
|
cfdp::StringLv srcNameLv(srcFileNameFs.path, std::strlen(srcFileNameFs.path));
|
||||||
FilesystemParams destFileNameFs(destFileName.c_str());
|
FilesystemParams destFileNameFs(destFileName.c_str());
|
||||||
cfdp::StringLv destNameLv(destFileNameFs.path, std::strlen(destFileNameFs.path));
|
cfdp::StringLv destNameLv(destFileNameFs.path, std::strlen(destFileNameFs.path));
|
||||||
PutRequest putRequest(id, srcNameLv, destNameLv);
|
PutRequest putRequest(remoteId, srcNameLv, destNameLv);
|
||||||
CHECK(sourceHandler.initialize() == OK);
|
CHECK(sourceHandler.initialize() == OK);
|
||||||
|
|
||||||
auto onePduSentCheck = [&](SourceHandler::FsmResult& fsmResult, TmTcMessage& tmtcMessage,
|
auto onePduSentCheck = [&](SourceHandler::FsmResult& fsmResult, TmTcMessage& tmtcMessage,
|
||||||
@ -90,6 +89,14 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
|||||||
TransactionSeqNum seqNum;
|
TransactionSeqNum seqNum;
|
||||||
metadataReader.getTransactionSeqNum(seqNum);
|
metadataReader.getTransactionSeqNum(seqNum);
|
||||||
CHECK(seqNum.getValue() == expectedSeqNum);
|
CHECK(seqNum.getValue() == expectedSeqNum);
|
||||||
|
CHECK(userMock.transactionIndicRecvd.size() == 1);
|
||||||
|
CHECK(userMock.transactionIndicRecvd.back() == TransactionId(localId, seqNum));
|
||||||
|
EntityId srcId;
|
||||||
|
metadataReader.getSourceId(srcId);
|
||||||
|
EntityId destId;
|
||||||
|
metadataReader.getDestId(destId);
|
||||||
|
CHECK(srcId.getValue() == localId.getValue());
|
||||||
|
CHECK(destId.getValue() == remoteId.getValue());
|
||||||
std::string destNameRead = metadataReader.getDestFileName().getString();
|
std::string destNameRead = metadataReader.getDestFileName().getString();
|
||||||
CHECK(destNameRead == destFileName);
|
CHECK(destNameRead == destFileName);
|
||||||
if (expectedFileSize == 0) {
|
if (expectedFileSize == 0) {
|
||||||
|
@ -4,7 +4,8 @@ namespace cfdp {
|
|||||||
|
|
||||||
cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {}
|
cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {}
|
||||||
|
|
||||||
void UserMock::transactionIndication(const TransactionId& id) {}
|
void UserMock::transactionIndication(const TransactionId& id) { transactionIndicRecvd.emplace(id); }
|
||||||
|
|
||||||
void UserMock::eofSentIndication(const TransactionId& id) {}
|
void UserMock::eofSentIndication(const TransactionId& id) {}
|
||||||
void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code,
|
void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code,
|
||||||
uint64_t progress) {}
|
uint64_t progress) {}
|
||||||
@ -12,11 +13,11 @@ void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode
|
|||||||
void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); }
|
void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); }
|
||||||
|
|
||||||
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {
|
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {
|
||||||
finishedRecvd.push({finishedParams.id, finishedParams});
|
finishedRecvd.emplace(finishedParams.id, finishedParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
|
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
|
||||||
metadataRecvd.push({params.id, params});
|
metadataRecvd.emplace(params.id, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {}
|
void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {}
|
||||||
|
@ -23,6 +23,7 @@ class UserMock : public UserBase {
|
|||||||
void resumedIndication(const TransactionId& id, size_t progress) override;
|
void resumedIndication(const TransactionId& id, size_t progress) override;
|
||||||
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
|
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
|
||||||
|
|
||||||
|
std::queue<TransactionId> transactionIndicRecvd;
|
||||||
std::queue<std::pair<TransactionId, MetadataRecvdParams>> metadataRecvd;
|
std::queue<std::pair<TransactionId, MetadataRecvdParams>> metadataRecvd;
|
||||||
std::queue<TransactionId> eofsRevd;
|
std::queue<TransactionId> eofsRevd;
|
||||||
std::queue<std::pair<TransactionId, TransactionFinishedParams>> finishedRecvd;
|
std::queue<std::pair<TransactionId, TransactionFinishedParams>> finishedRecvd;
|
||||||
|
Loading…
Reference in New Issue
Block a user