empty file transfer unittest almost done
This commit is contained in:
parent
806ae9b41a
commit
428da017ba
@ -224,6 +224,9 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) {
|
|||||||
}
|
}
|
||||||
tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt);
|
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.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
|
||||||
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
|
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
|
||||||
fsmRes.step = TransactionStep::TRANSFER_COMPLETION;
|
fsmRes.step = TransactionStep::TRANSFER_COMPLETION;
|
||||||
|
@ -66,7 +66,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
StringLv destName(destNameString);
|
StringLv destName(destNameString);
|
||||||
FileSize cfdpFileSize(0);
|
FileSize cfdpFileSize(0);
|
||||||
MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName);
|
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);
|
PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum);
|
||||||
MetadataPduCreator metadataCreator(conf, info);
|
MetadataPduCreator metadataCreator(conf, info);
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
@ -82,6 +82,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
REQUIRE(res.callStatus == CallStatus::CALL_AGAIN);
|
REQUIRE(res.callStatus == CallStatus::CALL_AGAIN);
|
||||||
// Assert that the packet was deleted after handling
|
// Assert that the packet was deleted after handling
|
||||||
REQUIRE(not tcStore.hasDataAtId(storeId));
|
REQUIRE(not tcStore.hasDataAtId(storeId));
|
||||||
|
REQUIRE(packetInfoList.empty());
|
||||||
destHandler.performStateMachine();
|
destHandler.performStateMachine();
|
||||||
REQUIRE(userMock.metadataRecvd.size() == 1);
|
REQUIRE(userMock.metadataRecvd.size() == 1);
|
||||||
MetadataRecvdParams& params = userMock.metadataRecvd.back();
|
MetadataRecvdParams& params = userMock.metadataRecvd.back();
|
||||||
@ -90,6 +91,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
REQUIRE(params.fileSize == 0);
|
REQUIRE(params.fileSize == 0);
|
||||||
REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0);
|
REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0);
|
||||||
REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0);
|
REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0);
|
||||||
|
userMock.metadataRecvd.pop();
|
||||||
REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end());
|
REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end());
|
||||||
REQUIRE(res.result == OK);
|
REQUIRE(res.result == OK);
|
||||||
REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY);
|
REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY);
|
||||||
@ -99,6 +101,20 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
EofPduCreator eofCreator(conf, eofInfo);
|
EofPduCreator eofCreator(conf, eofInfo);
|
||||||
REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &ptr) == OK);
|
REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &ptr) == OK);
|
||||||
REQUIRE(eofCreator.serialize(ptr, serLen, eofCreator.getSerializedSize()) == 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") {}
|
SECTION("Small File Transfer") {}
|
||||||
|
@ -8,7 +8,9 @@ void UserMock::transactionIndication(const TransactionId& 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) {}
|
||||||
void UserMock::eofRecvIndication(const TransactionId& id) {}
|
|
||||||
|
void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); }
|
||||||
|
|
||||||
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {}
|
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {}
|
||||||
|
|
||||||
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
|
void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {
|
||||||
@ -24,8 +26,8 @@ void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UserMock::reset() {
|
void UserMock::reset() {
|
||||||
auto empty = std::queue<cfdp::MetadataRecvdParams>();
|
std::queue<TransactionId>().swap(eofsRevd);
|
||||||
metadataRecvd.swap(empty);
|
std::queue<cfdp::MetadataRecvdParams>().swap(metadataRecvd);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
|
@ -24,6 +24,7 @@ class UserMock : public UserBase {
|
|||||||
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
|
void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override;
|
||||||
|
|
||||||
std::queue<MetadataRecvdParams> metadataRecvd;
|
std::queue<MetadataRecvdParams> metadataRecvd;
|
||||||
|
std::queue<TransactionId> eofsRevd;
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user