From cd8d64830c6c5bb08e2da45ee87bec72d2059f9b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Aug 2023 13:33:47 +0200 Subject: [PATCH] more checks --- unittests/cfdp/handler/testSourceHandler.cpp | 15 +++++++++++---- unittests/mocks/cfdp/UserMock.cpp | 7 ++++--- unittests/mocks/cfdp/UserMock.h | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/unittests/cfdp/handler/testSourceHandler.cpp b/unittests/cfdp/handler/testSourceHandler.cpp index c9ffcdf8..08def58f 100644 --- a/unittests/cfdp/handler/testSourceHandler.cpp +++ b/unittests/cfdp/handler/testSourceHandler.cpp @@ -33,7 +33,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") { AcceptsTmMock tmReceiver(destQueueId); MessageQueueMock mqMock(destQueueId); EntityId localId = EntityId(UnsignedByteField(2)); - EntityId remoteId = EntityId(UnsignedByteField(3)); + EntityId remoteId = EntityId(UnsignedByteField(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) { diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index ca15a5e6..6614d38d 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -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) {} diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index e2a4a483..36e56d73 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -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 transactionIndicRecvd; std::queue> metadataRecvd; std::queue eofsRevd; std::queue> finishedRecvd;