added some user checks
This commit is contained in:
parent
cd8d64830c
commit
5ff464252f
@ -108,8 +108,8 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
||||
// 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();
|
||||
REQUIRE(userMock.eofRecvdRecvd.size() == 1);
|
||||
auto& eofId = userMock.eofRecvdRecvd.back();
|
||||
CHECK(eofId == id);
|
||||
REQUIRE(userMock.finishedRecvd.size() == 1);
|
||||
auto& idParamPair = userMock.finishedRecvd.back();
|
||||
|
@ -109,7 +109,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
mqMock.clearMessages();
|
||||
};
|
||||
auto genericEofCheck = [&](SourceHandler::FsmResult& fsmResult, size_t expectedFileSize,
|
||||
uint32_t expectedChecksum) {
|
||||
uint32_t expectedChecksum, uint16_t expectedSeqNum) {
|
||||
CHECK(fsmResult.errors == 0);
|
||||
TmTcMessage tmtcMessage;
|
||||
const uint8_t* pduPtr;
|
||||
@ -120,6 +120,11 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
EofInfo eofInfo;
|
||||
EofPduReader eofReader(pduPtr, accessor.second.size(), eofInfo);
|
||||
REQUIRE(eofReader.parseData() == OK);
|
||||
TransactionSeqNum seqNum;
|
||||
eofReader.getTransactionSeqNum(seqNum);
|
||||
CHECK(seqNum.getValue() == expectedSeqNum);
|
||||
CHECK(userMock.eofSentRecvd.size() == 1);
|
||||
CHECK(userMock.eofSentRecvd.back() == TransactionId(localId, seqNum));
|
||||
CHECK(eofInfo.getChecksum() == expectedChecksum);
|
||||
CHECK(eofInfo.getConditionCode() == ConditionCode::NO_ERROR);
|
||||
CHECK(eofInfo.getFileSize().value() == expectedFileSize);
|
||||
@ -139,13 +144,14 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
|
||||
fsmResult = sourceHandler.stateMachine();
|
||||
// Verify EOF PDU was sent. No file data PDU is sent for an empty file and the checksum is 0.
|
||||
genericEofCheck(fsmResult, expectedFileSize, 0);
|
||||
genericEofCheck(fsmResult, expectedFileSize, 0, 0);
|
||||
|
||||
CHECK(sourceHandler.getStep() == SourceHandler::TransactionStep::IDLE);
|
||||
CHECK(sourceHandler.getState() == CfdpState::IDLE);
|
||||
}
|
||||
|
||||
SECTION("Transfer small file") {
|
||||
uint16_t expectedSeqNum = 0;
|
||||
fsMock.createFile(srcFileNameFs);
|
||||
std::string fileContent = "hello world\n";
|
||||
size_t expectedFileSize = fileContent.size();
|
||||
@ -155,7 +161,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
SourceHandler::FsmResult& fsmResult = sourceHandler.stateMachine();
|
||||
|
||||
// Verify metadata PDU was sent.
|
||||
genericMetadataCheck(fsmResult, expectedFileSize, 0);
|
||||
genericMetadataCheck(fsmResult, expectedFileSize, expectedSeqNum);
|
||||
|
||||
// Verify that a small file data PDU was sent.
|
||||
fsmResult = sourceHandler.stateMachine();
|
||||
@ -181,13 +187,14 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
etl::crc32 crcCalc;
|
||||
crcCalc.add(fileContent.data(), fileContent.data() + fileContent.size());
|
||||
// Verify EOF PDU was sent.
|
||||
genericEofCheck(fsmResult, expectedFileSize, crcCalc.value());
|
||||
genericEofCheck(fsmResult, expectedFileSize, crcCalc.value(), expectedSeqNum);
|
||||
|
||||
CHECK(sourceHandler.getStep() == SourceHandler::TransactionStep::IDLE);
|
||||
CHECK(sourceHandler.getState() == CfdpState::IDLE);
|
||||
}
|
||||
|
||||
SECTION("Transfer two segment file") {
|
||||
uint16_t expectedSeqNum = 0;
|
||||
// Create 400 bytes of random data. This should result in two file segments, with one
|
||||
// having the maximum size.
|
||||
std::random_device dev;
|
||||
@ -204,7 +211,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, 0);
|
||||
genericMetadataCheck(fsmResult, expectedFileSize, expectedSeqNum);
|
||||
|
||||
// Check first file data PDU. It should have the maximum file segment size.
|
||||
fsmResult = sourceHandler.stateMachine();
|
||||
@ -251,7 +258,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
etl::crc32 crcCalc;
|
||||
crcCalc.add(largerFileData.data(), largerFileData.data() + largerFileData.size());
|
||||
// Verify EOF PDU was sent.
|
||||
genericEofCheck(fsmResult, expectedFileSize, crcCalc.value());
|
||||
genericEofCheck(fsmResult, expectedFileSize, crcCalc.value(), expectedSeqNum);
|
||||
|
||||
CHECK(sourceHandler.getStep() == SourceHandler::TransactionStep::IDLE);
|
||||
CHECK(sourceHandler.getState() == CfdpState::IDLE);
|
||||
|
@ -6,11 +6,11 @@ cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {}
|
||||
|
||||
void UserMock::transactionIndication(const TransactionId& id) { transactionIndicRecvd.emplace(id); }
|
||||
|
||||
void UserMock::eofSentIndication(const TransactionId& id) {}
|
||||
void UserMock::eofSentIndication(const TransactionId& id) { eofSentRecvd.emplace(id); }
|
||||
void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code,
|
||||
uint64_t progress) {}
|
||||
|
||||
void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); }
|
||||
void UserMock::eofRecvIndication(const TransactionId& id) { eofRecvdRecvd.push(id); }
|
||||
|
||||
void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {
|
||||
finishedRecvd.emplace(finishedParams.id, finishedParams);
|
||||
@ -28,7 +28,7 @@ void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code
|
||||
}
|
||||
|
||||
void UserMock::reset() {
|
||||
std::queue<TransactionId>().swap(eofsRevd);
|
||||
std::queue<TransactionId>().swap(eofRecvdRecvd);
|
||||
std::queue<std::pair<TransactionId, cfdp::MetadataRecvdParams>>().swap(metadataRecvd);
|
||||
std::queue<std::pair<TransactionId, cfdp::TransactionFinishedParams>>().swap(finishedRecvd);
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ class UserMock : public UserBase {
|
||||
|
||||
std::queue<TransactionId> transactionIndicRecvd;
|
||||
std::queue<std::pair<TransactionId, MetadataRecvdParams>> metadataRecvd;
|
||||
std::queue<TransactionId> eofsRevd;
|
||||
std::queue<TransactionId> eofRecvdRecvd;
|
||||
std::queue<TransactionId> eofSentRecvd;
|
||||
std::queue<std::pair<TransactionId, TransactionFinishedParams>> finishedRecvd;
|
||||
void reset();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user