add more checks
This commit is contained in:
parent
22df8f6147
commit
cb1aaea6cd
@ -77,6 +77,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
auto genericMetadataCheck = [&](const SourceHandler::FsmResult& fsmResult,
|
||||
size_t expectedFileSize, uint16_t expectedSeqNum) {
|
||||
CHECK(fsmResult.errors == 0);
|
||||
CHECK(fsmResult.callStatus == CallStatus::CALL_AGAIN);
|
||||
TmTcMessage tmtcMessage;
|
||||
const uint8_t* pduPtr;
|
||||
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
|
||||
@ -111,6 +112,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
auto genericEofCheck = [&](const SourceHandler::FsmResult& fsmResult, size_t expectedFileSize,
|
||||
uint32_t expectedChecksum, uint16_t expectedSeqNum) {
|
||||
CHECK(fsmResult.errors == 0);
|
||||
CHECK(fsmResult.callStatus == CallStatus::CALL_AGAIN);
|
||||
TmTcMessage tmtcMessage;
|
||||
const uint8_t* pduPtr;
|
||||
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
|
||||
@ -132,6 +134,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
};
|
||||
auto genericNoticeOfCompletionCheck = [&](const SourceHandler::FsmResult& fsmResult,
|
||||
uint16_t expectedSeqNum) {
|
||||
CHECK(fsmResult.callStatus == CallStatus::DONE);
|
||||
CHECK(userMock.finishedRecvd.size() == 1);
|
||||
CHECK(userMock.finishedRecvd.back().first ==
|
||||
TransactionId(localId, TransactionSeqNum(cfdp::WidthInBytes::TWO_BYTES, expectedSeqNum)));
|
||||
@ -231,6 +234,7 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
const uint8_t* pduPtr;
|
||||
FileDataInfo fdInfo;
|
||||
{
|
||||
CHECK(fsmResult.callStatus == CallStatus::CALL_AGAIN);
|
||||
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
|
||||
FileDataReader fdReader(pduPtr, accessor.second.size(), fdInfo);
|
||||
// 10 byte PDU header, 4 byte offset, 255 byte file data
|
||||
@ -249,18 +253,21 @@ TEST_CASE("CFDP Source Handler", "[cfdp]") {
|
||||
|
||||
// Check second file data PDU.
|
||||
sourceHandler.stateMachine();
|
||||
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
|
||||
FileDataReader fdReader(pduPtr, accessor.second.size(), fdInfo);
|
||||
// 10 byte PDU header, 4 byte offset, remaining file data (400 - 255 == 145).
|
||||
CHECK(accessor.second.size() == 10 + 4 + largerFileData.size() - MAX_FILE_SEGMENT_SIZE);
|
||||
CHECK(fdReader.parseData() == OK);
|
||||
CHECK(fdInfo.getOffset().value() == MAX_FILE_SEGMENT_SIZE);
|
||||
size_t fileDataSize = 0;
|
||||
const uint8_t* fileData = fdInfo.getFileData(&fileDataSize);
|
||||
// Maximum file segment size.
|
||||
REQUIRE(fileDataSize == largerFileData.size() - MAX_FILE_SEGMENT_SIZE);
|
||||
for (unsigned i = 0; i < fileDataSize; i++) {
|
||||
CHECK(fileData[i] == largerFileData[MAX_FILE_SEGMENT_SIZE + i]);
|
||||
{
|
||||
CHECK(fsmResult.callStatus == CallStatus::CALL_AGAIN);
|
||||
auto accessor = onePduSentCheck(fsmResult, tmtcMessage, &pduPtr);
|
||||
FileDataReader fdReader(pduPtr, accessor.second.size(), fdInfo);
|
||||
// 10 byte PDU header, 4 byte offset, remaining file data (400 - 255 == 145).
|
||||
CHECK(accessor.second.size() == 10 + 4 + largerFileData.size() - MAX_FILE_SEGMENT_SIZE);
|
||||
CHECK(fdReader.parseData() == OK);
|
||||
CHECK(fdInfo.getOffset().value() == MAX_FILE_SEGMENT_SIZE);
|
||||
size_t fileDataSize = 0;
|
||||
const uint8_t* fileData = fdInfo.getFileData(&fileDataSize);
|
||||
// Maximum file segment size.
|
||||
REQUIRE(fileDataSize == largerFileData.size() - MAX_FILE_SEGMENT_SIZE);
|
||||
for (unsigned i = 0; i < fileDataSize; i++) {
|
||||
CHECK(fileData[i] == largerFileData[MAX_FILE_SEGMENT_SIZE + i]);
|
||||
}
|
||||
}
|
||||
mqMock.clearMessages();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user