clean up CFDP stack a bit
This commit is contained in:
@ -12,9 +12,24 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
|
||||
auto queue = MessageQueueMock(1);
|
||||
CfdpDistribCfg distribCfg(1, pool, &queue);
|
||||
auto distributor = CfdpDistributor(distribCfg);
|
||||
auto entityId = cfdp::EntityId(UnsignedByteField<uint16_t>(2));
|
||||
auto obswEntityId = cfdp::EntityId(UnsignedByteField<uint16_t>(2));
|
||||
auto groundEntityId = cfdp::EntityId(UnsignedByteField<uint16_t>(1));
|
||||
MessageQueueId_t acceptorQueueId = 3;
|
||||
auto tcAcceptor = AcceptsTcMock("TC Acceptor", 0, acceptorQueueId);
|
||||
cfdp::FileSize fileSize(12);
|
||||
const cfdp::EntityId& sourceId(groundEntityId);
|
||||
const cfdp::EntityId& destId(obswEntityId);
|
||||
cfdp::TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(12));
|
||||
auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum);
|
||||
std::string sourceFileString = "hello.txt";
|
||||
cfdp::Lv sourceFileName(sourceFileString.c_str(), sourceFileString.size());
|
||||
std::string destFileString = "hello2.txt";
|
||||
cfdp::Lv destFileName(destFileString.c_str(), sourceFileString.size());
|
||||
MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName,
|
||||
destFileName);
|
||||
MetadataPduCreator creator(pduConf, metadataInfo);
|
||||
uint8_t* dataPtr = nullptr;
|
||||
|
||||
SECTION("State") {
|
||||
CHECK(distributor.initialize() == result::OK);
|
||||
CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0);
|
||||
@ -24,7 +39,14 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
|
||||
|
||||
SECTION("Register Listener") {
|
||||
CHECK(distributor.initialize() == result::OK);
|
||||
CHECK(distributor.registerTcDestination(entityId, tcAcceptor));
|
||||
// queue.addReceivedMessage()
|
||||
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK);
|
||||
size_t serLen = 0;
|
||||
store_address_t storeId;
|
||||
CHECK(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK);
|
||||
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
|
||||
result::OK);
|
||||
TmTcMessage msg(storeId);
|
||||
queue.addReceivedMessage(msg);
|
||||
CHECK(distributor.performOperation(0) == result::OK);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
|
||||
std::string firstFileName = "hello.txt";
|
||||
cfdp::Lv sourceFileName(reinterpret_cast<const uint8_t*>(firstFileName.data()),
|
||||
firstFileName.size());
|
||||
cfdp::Lv destFileName(nullptr, 0);
|
||||
cfdp::Lv destFileName;
|
||||
FileSize fileSize(35);
|
||||
MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName);
|
||||
|
||||
@ -72,7 +72,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
|
||||
otherFileName.size());
|
||||
info.setSourceFileName(otherFileNameLv);
|
||||
size_t sizeOfOptions = options.size();
|
||||
info.setOptionsArray(*options.data(), &sizeOfOptions, &sizeOfOptions);
|
||||
info.setOptionsArray(options.data(), &sizeOfOptions, &sizeOfOptions);
|
||||
REQUIRE(info.getMaxOptionsLen() == 2);
|
||||
info.setMaxOptionsLen(3);
|
||||
REQUIRE(info.getMaxOptionsLen() == 3);
|
||||
@ -130,7 +130,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
|
||||
}
|
||||
size_t sizeOfOptions = options.size();
|
||||
size_t maxSize = 4;
|
||||
info.setOptionsArray(reinterpret_cast<Tlv*>(options.data()), &sizeOfOptions, &maxSize);
|
||||
info.setOptionsArray(options.data(), &sizeOfOptions, &maxSize);
|
||||
REQUIRE(info.getOptionsLen() == 2);
|
||||
info.setChecksumType(cfdp::ChecksumType::CRC_32C);
|
||||
info.setClosureRequested(true);
|
||||
@ -169,7 +169,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
|
||||
mdBuffer[2] = 36 & 0xff;
|
||||
info.setOptionsArray(nullptr, nullptr, nullptr);
|
||||
REQUIRE(deserializer2.parseData() == cfdp::METADATA_CANT_PARSE_OPTIONS);
|
||||
info.setOptionsArray(reinterpret_cast<Tlv*>(options.data()), &sizeOfOptions, nullptr);
|
||||
info.setOptionsArray(options.data(), &sizeOfOptions, nullptr);
|
||||
for (size_t maxSz = 0; maxSz < 46; maxSz++) {
|
||||
MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info);
|
||||
result = invalidSzDeser.parseData();
|
||||
|
@ -158,7 +158,7 @@ TEST_CASE("CFDP TLV LV", "[cfdp]") {
|
||||
SerializeIF::Endianness::BIG);
|
||||
REQUIRE(sourceIdRaw == 0x0ff0);
|
||||
|
||||
auto lvEmpty = Lv(nullptr, 0);
|
||||
auto lvEmpty = Lv();
|
||||
REQUIRE(lvEmpty.getSerializedSize() == 1);
|
||||
serPtr = rawBuf.data();
|
||||
deserSize = 0;
|
||||
@ -191,7 +191,7 @@ TEST_CASE("CFDP TLV LV", "[cfdp]") {
|
||||
SerializeIF::Endianness::BIG);
|
||||
REQUIRE(sourceIdRaw == 0x0ff0);
|
||||
|
||||
auto lvEmpty = Lv(nullptr, 0);
|
||||
auto lvEmpty = Lv();
|
||||
REQUIRE(lvEmpty.getSerializedSize() == 1);
|
||||
serPtr = rawBuf.data();
|
||||
deserSize = 0;
|
||||
|
Reference in New Issue
Block a user