additional checks

This commit is contained in:
Robin Müller 2023-08-14 13:24:22 +02:00
parent 0fc2c7b5e9
commit b7056a7467
Signed by: muellerr
GPG Key ID: 407F9B00F858F270

View File

@ -75,7 +75,8 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
*pduPtr = accessor.second.data();
return std::move(accessor);
};
auto genericMetadataCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize) {
auto genericMetadataCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize,
uint16_t expectedSeqNum) {
CHECK(fsmResult.errors == 0);
TmTcMessage tmtcMessage;
const uint8_t* pduPtr;
@ -86,6 +87,9 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
REQUIRE(metadataReader.parseData() == OK);
std::string srcNameRead = metadataReader.getSourceFileName().getString();
CHECK(srcNameRead == srcFileName);
TransactionSeqNum seqNum;
metadataReader.getTransactionSeqNum(seqNum);
CHECK(seqNum.getValue() == expectedSeqNum);
std::string destNameRead = metadataReader.getDestFileName().getString();
CHECK(destNameRead == destFileName);
if (expectedFileSize == 0) {
@ -124,7 +128,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
size_t expectedFileSize = 0;
SourceHandler::FsmResult& fsmResult = sourceHandler.stateMachine();
// Verify metadata PDU was sent.
genericMetadataCheck(fsmResult, expectedFileSize);
genericMetadataCheck(fsmResult, expectedFileSize, 0);
fsmResult = sourceHandler.stateMachine();
// Verify EOF PDU was sent. No file data PDU is sent for an empty file and the checksum is 0.
@ -144,7 +148,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
SourceHandler::FsmResult& fsmResult = sourceHandler.stateMachine();
// Verify metadata PDU was sent.
genericMetadataCheck(fsmResult, expectedFileSize);
genericMetadataCheck(fsmResult, expectedFileSize, 0);
// Verify that a small file data PDU was sent.
fsmResult = sourceHandler.stateMachine();
@ -193,7 +197,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
CHECK(sourceHandler.transactionStart(putRequest, cfg) == OK);
SourceHandler::FsmResult& fsmResult = sourceHandler.stateMachine();
// Verify metadata PDU was sent.
genericMetadataCheck(fsmResult, expectedFileSize);
genericMetadataCheck(fsmResult, expectedFileSize, 0);
// Check first file data PDU. It should have the maximum file segment size.
fsmResult = sourceHandler.stateMachine();