more checks

This commit is contained in:
Robin Müller 2023-08-14 13:33:47 +02:00
parent b7056a7467
commit cd8d64830c
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
3 changed files with 16 additions and 7 deletions

View File

@ -33,7 +33,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
AcceptsTmMock tmReceiver(destQueueId);
MessageQueueMock mqMock(destQueueId);
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(3));
EntityId remoteId = EntityId(UnsignedByteField<uint16_t>(5));
FaultHandlerMock fhMock;
LocalEntityCfg localEntityCfg(localId, IndicationCfg(), fhMock);
FilesystemMock fsMock;
@ -52,8 +52,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
RemoteEntityCfg cfg;
cfg.maxFileSegmentLen = MAX_FILE_SEGMENT_SIZE;
EntityId id(cfdp::WidthInBytes::TWO_BYTES, 5);
cfg.remoteId = id;
cfg.remoteId = remoteId;
std::string srcFileName = "/tmp/cfdp-test.txt";
std::string destFileName = "/tmp/cfdp-test2.txt";
FilesystemParams srcFileNameFs(srcFileName.c_str());
@ -61,7 +60,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
cfdp::StringLv srcNameLv(srcFileNameFs.path, std::strlen(srcFileNameFs.path));
FilesystemParams destFileNameFs(destFileName.c_str());
cfdp::StringLv destNameLv(destFileNameFs.path, std::strlen(destFileNameFs.path));
PutRequest putRequest(id, srcNameLv, destNameLv);
PutRequest putRequest(remoteId, srcNameLv, destNameLv);
CHECK(sourceHandler.initialize() == OK);
auto onePduSentCheck = [&](SourceHandler::FsmResult& fsmResult, TmTcMessage& tmtcMessage,
@ -90,6 +89,14 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
TransactionSeqNum seqNum;
metadataReader.getTransactionSeqNum(seqNum);
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();
CHECK(destNameRead == destFileName);
if (expectedFileSize == 0) {

View File

@ -4,7 +4,8 @@ namespace cfdp {
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::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code,
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::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {
finishedRecvd.push({finishedParams.id, finishedParams});
finishedRecvd.emplace(finishedParams.id, finishedParams);
}
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
metadataRecvd.push({params.id, params});
metadataRecvd.emplace(params.id, params);
}
void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {}

View File

@ -23,6 +23,7 @@ class UserMock : public UserBase {
void resumedIndication(const TransactionId& id, 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<TransactionId> eofsRevd;
std::queue<std::pair<TransactionId, TransactionFinishedParams>> finishedRecvd;