empty file transfer unittest almost done

This commit is contained in:
Robin Müller 2022-09-06 13:45:43 +02:00
parent 806ae9b41a
commit 428da017ba
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 26 additions and 4 deletions

View File

@ -224,6 +224,9 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) {
}
tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt);
}
if (dp.cfg.indicCfg.eofRecvIndicRequired) {
dp.user.eofRecvIndication(getTransactionId());
}
if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
fsmRes.step = TransactionStep::TRANSFER_COMPLETION;

View File

@ -66,7 +66,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
StringLv destName(destNameString);
FileSize cfdpFileSize(0);
MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName);
auto seqNum = TransactionSeqNum(UnsignedByteField<uint16_t>(1));
TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(1));
PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum);
MetadataPduCreator metadataCreator(conf, info);
store_address_t storeId;
@ -82,6 +82,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
REQUIRE(res.callStatus == CallStatus::CALL_AGAIN);
// Assert that the packet was deleted after handling
REQUIRE(not tcStore.hasDataAtId(storeId));
REQUIRE(packetInfoList.empty());
destHandler.performStateMachine();
REQUIRE(userMock.metadataRecvd.size() == 1);
MetadataRecvdParams& params = userMock.metadataRecvd.back();
@ -90,6 +91,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
REQUIRE(params.fileSize == 0);
REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0);
REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0);
userMock.metadataRecvd.pop();
REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end());
REQUIRE(res.result == OK);
REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY);
@ -99,6 +101,20 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
EofPduCreator eofCreator(conf, eofInfo);
REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &ptr) == OK);
REQUIRE(eofCreator.serialize(ptr, serLen, eofCreator.getSerializedSize()) == OK);
packetInfo = PacketInfo(eofCreator.getPduType(), eofCreator.getDirectiveCode(), storeId);
packetInfoList.push_back(packetInfo);
auto transactionId = destHandler.getTransactionId();
// After EOF, operation is done because no closure was requested
destHandler.performStateMachine();
REQUIRE(res.result == OK);
REQUIRE(res.state == CfdpStates::IDLE);
REQUIRE(res.step == DestHandler::TransactionStep::IDLE);
// Assert that the packet was deleted after handling
REQUIRE(not tcStore.hasDataAtId(storeId));
REQUIRE(packetInfoList.empty());
REQUIRE(userMock.eofsRevd.size() == 1);
auto& eofId = userMock.eofsRevd.back();
CHECK(eofId == transactionId);
}
SECTION("Small File Transfer") {}

View File

@ -8,7 +8,9 @@ void UserMock::transactionIndication(const TransactionId& id) {}
void UserMock::eofSentIndication(const TransactionId& id) {}
void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code,
uint64_t progress) {}
void UserMock::eofRecvIndication(const TransactionId& id) {}
void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); }
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {}
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
@ -24,8 +26,8 @@ void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code
}
void UserMock::reset() {
auto empty = std::queue<cfdp::MetadataRecvdParams>();
metadataRecvd.swap(empty);
std::queue<TransactionId>().swap(eofsRevd);
std::queue<cfdp::MetadataRecvdParams>().swap(metadataRecvd);
}
} // namespace cfdp

View File

@ -24,6 +24,7 @@ class UserMock : public UserBase {
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
std::queue<MetadataRecvdParams> metadataRecvd;
std::queue<TransactionId> eofsRevd;
void reset();
};