added string LV tests
This commit is contained in:
parent
507c6ddff1
commit
96dfe46e25
@ -4,5 +4,8 @@
|
|||||||
#include "cfdp/definitions.h"
|
#include "cfdp/definitions.h"
|
||||||
#include "cfdp/handler/DestHandler.h"
|
#include "cfdp/handler/DestHandler.h"
|
||||||
#include "cfdp/handler/FaultHandlerBase.h"
|
#include "cfdp/handler/FaultHandlerBase.h"
|
||||||
|
#include "cfdp/tlv/Lv.h"
|
||||||
|
#include "cfdp/tlv/StringLv.h"
|
||||||
|
#include "cfdp/tlv/Tlv.h"
|
||||||
|
|
||||||
#endif // FSFW_CFDP_H
|
#endif // FSFW_CFDP_H
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
#include "UserBase.h"
|
#include "UserBase.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <iostream>
|
||||||
|
void cfdp::testFunc() {
|
||||||
|
std::vector<void*> testVec;
|
||||||
|
testVec.reserve(10);
|
||||||
|
std::array<uint8_t, 4> customMsg = {1, 2, 3, 4};
|
||||||
|
MessageToUserTlv tlv0(customMsg.data(), customMsg.size());
|
||||||
|
std::cout << testVec.size() << std::endl;
|
||||||
|
testVec[0] = &tlv0;
|
||||||
|
FilestoreResponseTlv tlv1();
|
||||||
|
}
|
||||||
|
|
||||||
cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {}
|
cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "StatusReportIF.h"
|
#include "StatusReportIF.h"
|
||||||
#include "fsfw/cfdp/VarLenFields.h"
|
#include "fsfw/cfdp/VarLenFields.h"
|
||||||
@ -12,6 +13,8 @@
|
|||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
|
|
||||||
|
void testFunc();
|
||||||
|
|
||||||
struct TransactionFinishedParams {
|
struct TransactionFinishedParams {
|
||||||
TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status,
|
TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status,
|
||||||
FileDeliveryCode delivCode)
|
FileDeliveryCode delivCode)
|
||||||
@ -31,7 +34,8 @@ struct MetadataRecvParams {
|
|||||||
size_t fileSize;
|
size_t fileSize;
|
||||||
const char* sourceFileName;
|
const char* sourceFileName;
|
||||||
const char* destFileName;
|
const char* destFileName;
|
||||||
std::pair<uint8_t, MessageToUserTlv**> msgsToUser;
|
std::vector<MessageToUserTlv*> msgsToUser;
|
||||||
|
// std::pair<uint8_t, MessageToUserTlv**> msgsToUser;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FileSegmentRecvdParams {
|
struct FileSegmentRecvdParams {
|
||||||
|
@ -5,6 +5,7 @@ target_sources(
|
|||||||
FilestoreResponseTlv.cpp
|
FilestoreResponseTlv.cpp
|
||||||
Lv.cpp
|
Lv.cpp
|
||||||
Tlv.cpp
|
Tlv.cpp
|
||||||
|
StringLv.cpp
|
||||||
FlowLabelTlv.cpp
|
FlowLabelTlv.cpp
|
||||||
MessageToUserTlv.cpp
|
MessageToUserTlv.cpp
|
||||||
FaultHandlerOverrideTlv.cpp)
|
FaultHandlerOverrideTlv.cpp)
|
||||||
|
@ -6,9 +6,8 @@ cfdp::Lv::Lv(const uint8_t* value, size_t size) : value(value, size, true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfdp::Lv::Lv(const char* value, size_t size)
|
cfdp::Lv::Lv(const std::vector<uint8_t>& data) : value(data.data(), data.size(), true) {
|
||||||
: value(reinterpret_cast<const uint8_t*>(value), size, true) {
|
if (!data.empty()) {
|
||||||
if (size > 0) {
|
|
||||||
zeroLen = false;
|
zeroLen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,11 +23,11 @@ cfdp::Lv::Lv(const Lv& other)
|
|||||||
|
|
||||||
cfdp::Lv& cfdp::Lv::operator=(const Lv& other) {
|
cfdp::Lv& cfdp::Lv::operator=(const Lv& other) {
|
||||||
size_t otherSize = 0;
|
size_t otherSize = 0;
|
||||||
uint8_t* value = const_cast<uint8_t*>(other.getValue(&otherSize));
|
auto* otherVal = const_cast<uint8_t*>(other.getValue(&otherSize));
|
||||||
if (value == nullptr or otherSize == 0) {
|
if (otherVal == nullptr or otherSize == 0) {
|
||||||
this->zeroLen = true;
|
this->zeroLen = true;
|
||||||
}
|
}
|
||||||
this->value.setBuffer(value, otherSize);
|
this->value.setBuffer(otherVal, otherSize);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#ifndef FSFW_SRC_FSFW_CFDP_LV_H_
|
#ifndef FSFW_CFDP_LV_H_
|
||||||
#define FSFW_SRC_FSFW_CFDP_LV_H_
|
#define FSFW_CFDP_LV_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "fsfw/serialize/SerialBufferAdapter.h"
|
#include "fsfw/serialize/SerialBufferAdapter.h"
|
||||||
|
|
||||||
@ -12,12 +14,10 @@ namespace cfdp {
|
|||||||
*/
|
*/
|
||||||
class Lv : public SerializeIF {
|
class Lv : public SerializeIF {
|
||||||
public:
|
public:
|
||||||
|
explicit Lv(const std::vector<uint8_t>& data);
|
||||||
Lv(const uint8_t* value, size_t size);
|
Lv(const uint8_t* value, size_t size);
|
||||||
Lv(const char* value, size_t size);
|
|
||||||
Lv();
|
Lv();
|
||||||
|
|
||||||
// Delete copy ctor and assingment ctor for now because this class contains a reference to
|
|
||||||
// data
|
|
||||||
Lv(const Lv&);
|
Lv(const Lv&);
|
||||||
Lv& operator=(const Lv&);
|
Lv& operator=(const Lv&);
|
||||||
|
|
||||||
@ -51,4 +51,4 @@ class Lv : public SerializeIF {
|
|||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
|
|
||||||
#endif /* FSFW_SRC_FSFW_CFDP_LV_H_ */
|
#endif /* FSFW_CFDP_LV_H_ */
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include "MessageToUserTlv.h"
|
#include "MessageToUserTlv.h"
|
||||||
|
|
||||||
MessageToUserTlv::MessageToUserTlv(uint8_t *value, size_t size)
|
MessageToUserTlv::MessageToUserTlv(uint8_t* value, size_t size)
|
||||||
: Tlv(cfdp::TlvTypes::MSG_TO_USER, value, size) {}
|
: Tlv(cfdp::TlvTypes::MSG_TO_USER, value, size) {}
|
||||||
|
|
||||||
MessageToUserTlv::MessageToUserTlv() : Tlv() {}
|
MessageToUserTlv::MessageToUserTlv() : Tlv() {}
|
||||||
|
|
||||||
|
MessageToUserTlv::MessageToUserTlv(const std::vector<uint8_t>& data)
|
||||||
|
: Tlv(cfdp::TlvTypes::MSG_TO_USER, data.data(), data.size()) {}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#ifndef FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_
|
#ifndef FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_
|
||||||
#define FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_
|
#define FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Tlv.h"
|
#include "Tlv.h"
|
||||||
|
|
||||||
class MessageToUserTlv : public cfdp::Tlv {
|
class MessageToUserTlv : public cfdp::Tlv {
|
||||||
public:
|
public:
|
||||||
MessageToUserTlv();
|
MessageToUserTlv();
|
||||||
MessageToUserTlv(uint8_t* value, size_t size);
|
MessageToUserTlv(uint8_t* value, size_t size);
|
||||||
|
explicit MessageToUserTlv(const std::vector<uint8_t>& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
7
src/fsfw/cfdp/tlv/StringLv.cpp
Normal file
7
src/fsfw/cfdp/tlv/StringLv.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "StringLv.h"
|
||||||
|
|
||||||
|
cfdp::StringLv::StringLv(const std::string& fileName)
|
||||||
|
: Lv(reinterpret_cast<const uint8_t*>(fileName.data()), fileName.size()) {}
|
||||||
|
|
||||||
|
cfdp::StringLv::StringLv(const char* filename, size_t len)
|
||||||
|
: Lv(reinterpret_cast<const uint8_t*>(filename), len) {}
|
18
src/fsfw/cfdp/tlv/StringLv.h
Normal file
18
src/fsfw/cfdp/tlv/StringLv.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef FSFW_CFDP_STRINGLV_H
|
||||||
|
#define FSFW_CFDP_STRINGLV_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Lv.h"
|
||||||
|
|
||||||
|
namespace cfdp {
|
||||||
|
|
||||||
|
class StringLv : public Lv {
|
||||||
|
public:
|
||||||
|
explicit StringLv(const std::string& fileName);
|
||||||
|
explicit StringLv(const char* filename, size_t len);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cfdp
|
||||||
|
|
||||||
|
#endif // FSFW_CFDP_STRINGLV_H
|
@ -21,15 +21,15 @@ SerialBufferAdapter<count_t>::SerialBufferAdapter(uint8_t* buffer, count_t buffe
|
|||||||
bufferLength(bufferLength) {}
|
bufferLength(bufferLength) {}
|
||||||
|
|
||||||
template <typename count_t>
|
template <typename count_t>
|
||||||
SerialBufferAdapter<count_t>::~SerialBufferAdapter() {}
|
SerialBufferAdapter<count_t>::~SerialBufferAdapter() = default;
|
||||||
|
|
||||||
template <typename count_t>
|
template <typename count_t>
|
||||||
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer_, size_t* size,
|
||||||
size_t maxSize,
|
size_t maxSize,
|
||||||
Endianness streamEndianness) const {
|
Endianness streamEndianness) const {
|
||||||
if (serializeLength) {
|
if (serializeLength) {
|
||||||
ReturnValue_t result =
|
ReturnValue_t result =
|
||||||
SerializeAdapter::serialize(&bufferLength, buffer, size, maxSize, streamEndianness);
|
SerializeAdapter::serialize(&bufferLength, buffer_, size, maxSize, streamEndianness);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -40,16 +40,16 @@ ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer, size_t*
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->constBuffer != nullptr) {
|
if (this->constBuffer != nullptr) {
|
||||||
std::memcpy(*buffer, this->constBuffer, bufferLength);
|
std::memcpy(*buffer_, this->constBuffer, bufferLength);
|
||||||
} else if (this->buffer != nullptr) {
|
} else if (this->buffer != nullptr) {
|
||||||
// This will propably be never reached, constBuffer should always be
|
// This will propably be never reached, constBuffer should always be
|
||||||
// set if non-const buffer is set.
|
// set if non-const buffer is set.
|
||||||
std::memcpy(*buffer, this->buffer, bufferLength);
|
std::memcpy(*buffer_, this->buffer, bufferLength);
|
||||||
} else {
|
} else {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
*size += bufferLength;
|
*size += bufferLength;
|
||||||
(*buffer) += bufferLength;
|
(*buffer_) += bufferLength;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ size_t SerialBufferAdapter<count_t>::getSerializedSize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename count_t>
|
template <typename count_t>
|
||||||
ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer_, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
if (this->buffer == nullptr) {
|
if (this->buffer == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
@ -72,7 +72,7 @@ ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer,
|
|||||||
if (serializeLength) {
|
if (serializeLength) {
|
||||||
count_t lengthField = 0;
|
count_t lengthField = 0;
|
||||||
ReturnValue_t result =
|
ReturnValue_t result =
|
||||||
SerializeAdapter::deSerialize(&lengthField, buffer, size, streamEndianness);
|
SerializeAdapter::deSerialize(&lengthField, buffer_, size, streamEndianness);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -84,8 +84,8 @@ ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer,
|
|||||||
|
|
||||||
if (bufferLength <= *size) {
|
if (bufferLength <= *size) {
|
||||||
*size -= bufferLength;
|
*size -= bufferLength;
|
||||||
std::memcpy(this->buffer, *buffer, bufferLength);
|
std::memcpy(this->buffer, *buffer_, bufferLength);
|
||||||
(*buffer) += bufferLength;
|
(*buffer_) += bufferLength;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
} else {
|
} else {
|
||||||
return STREAM_TOO_SHORT;
|
return STREAM_TOO_SHORT;
|
||||||
@ -119,10 +119,9 @@ const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename count_t>
|
template <typename count_t>
|
||||||
void SerialBufferAdapter<count_t>::setBuffer(uint8_t* buffer, count_t bufferLength) {
|
void SerialBufferAdapter<count_t>::setBuffer(const uint8_t* data, count_t len) {
|
||||||
this->buffer = buffer;
|
this->constBuffer = data;
|
||||||
this->constBuffer = buffer;
|
this->bufferLength = len;
|
||||||
this->bufferLength = bufferLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward Template declaration for linker
|
// forward Template declaration for linker
|
||||||
|
@ -40,12 +40,12 @@ class SerialBufferAdapter : public SerializeIF {
|
|||||||
*/
|
*/
|
||||||
SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false);
|
SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false);
|
||||||
|
|
||||||
virtual ~SerialBufferAdapter();
|
~SerialBufferAdapter() override;
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer_, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const override;
|
[[nodiscard]] size_t getSerializedSize() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function deserializes a buffer into the member buffer.
|
* @brief This function deserializes a buffer into the member buffer.
|
||||||
@ -53,18 +53,18 @@ class SerialBufferAdapter : public SerializeIF {
|
|||||||
* If a length field is present, it is ignored, as the size should have
|
* If a length field is present, it is ignored, as the size should have
|
||||||
* been set in the constructor. If the size is not known beforehand,
|
* been set in the constructor. If the size is not known beforehand,
|
||||||
* consider using SerialFixedArrayListAdapter instead.
|
* consider using SerialFixedArrayListAdapter instead.
|
||||||
* @param buffer [out] Resulting buffer
|
* @param buffer_ [out] Resulting buffer
|
||||||
* @param size remaining size to deserialize, should be larger than buffer
|
* @param size remaining size to deserialize, should be larger than buffer
|
||||||
* + size field size
|
* + size field size
|
||||||
* @param bigEndian
|
* @param bigEndian
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer_, size_t* size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
uint8_t* getBuffer();
|
uint8_t* getBuffer();
|
||||||
const uint8_t* getConstBuffer() const;
|
[[nodiscard]] const uint8_t* getConstBuffer() const;
|
||||||
void setBuffer(uint8_t* buffer, count_t bufferLength);
|
void setBuffer(const uint8_t* buffer, count_t bufferLength);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool serializeLength = false;
|
bool serializeLength = false;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp)
|
target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testOtherTlvs.cpp
|
||||||
|
testTlv.cpp testLvs.cpp)
|
||||||
|
|
||||||
add_subdirectory(handler)
|
add_subdirectory(handler)
|
||||||
add_subdirectory(pdu)
|
add_subdirectory(pdu)
|
||||||
|
@ -9,6 +9,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
|||||||
auto fhMock = FaultHandlerMock();
|
auto fhMock = FaultHandlerMock();
|
||||||
auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock);
|
auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock);
|
||||||
// auto destHandler = DestHandler();
|
// auto destHandler = DestHandler();
|
||||||
|
cfdp::testFunc();
|
||||||
|
|
||||||
SECTION("State") {}
|
SECTION("State") {}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "fsfw/cfdp/CfdpDistributor.h"
|
#include "fsfw/cfdp/CfdpDistributor.h"
|
||||||
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
|
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
|
||||||
|
#include "fsfw/cfdp/tlv/StringLv.h"
|
||||||
#include "fsfw/storagemanager/LocalPool.h"
|
#include "fsfw/storagemanager/LocalPool.h"
|
||||||
#include "fsfw/tcdistribution/definitions.h"
|
#include "fsfw/tcdistribution/definitions.h"
|
||||||
#include "mocks/AcceptsTcMock.h"
|
#include "mocks/AcceptsTcMock.h"
|
||||||
@ -26,9 +27,9 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
|
|||||||
cfdp::TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(12));
|
cfdp::TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(12));
|
||||||
auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum);
|
auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum);
|
||||||
std::string sourceFileString = "hello.txt";
|
std::string sourceFileString = "hello.txt";
|
||||||
cfdp::Lv sourceFileName(sourceFileString.c_str(), sourceFileString.size());
|
cfdp::StringLv sourceFileName(sourceFileString);
|
||||||
std::string destFileString = "hello2.txt";
|
std::string destFileString = "hello2.txt";
|
||||||
cfdp::Lv destFileName(destFileString.c_str(), sourceFileString.size());
|
cfdp::StringLv destFileName(destFileString);
|
||||||
MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName,
|
MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName,
|
||||||
destFileName);
|
destFileName);
|
||||||
MetadataPduCreator creator(pduConf, metadataInfo);
|
MetadataPduCreator creator(pduConf, metadataInfo);
|
||||||
|
105
unittests/cfdp/testLvs.cpp
Normal file
105
unittests/cfdp/testLvs.cpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
#include <array>
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "fsfw/cfdp.h"
|
||||||
|
|
||||||
|
TEST_CASE("CFDP TLV", "[cfdp][lv]") {
|
||||||
|
using namespace cfdp;
|
||||||
|
ReturnValue_t result;
|
||||||
|
std::array<uint8_t, 255> rawBuf{};
|
||||||
|
uint8_t* serPtr = rawBuf.data();
|
||||||
|
const uint8_t* deserPtr = rawBuf.data();
|
||||||
|
size_t deserSize = 0;
|
||||||
|
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0);
|
||||||
|
|
||||||
|
SECTION("LV Serialization") {
|
||||||
|
std::array<uint8_t, 8> lvRawBuf{};
|
||||||
|
serPtr = lvRawBuf.data();
|
||||||
|
REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) == result::OK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(deserSize == 2);
|
||||||
|
|
||||||
|
auto lv = cfdp::Lv(lvRawBuf.data(), 2);
|
||||||
|
REQUIRE(lv.getSerializedSize() == 3);
|
||||||
|
|
||||||
|
SECTION("Copy") {
|
||||||
|
auto lvCopy = cfdp::Lv(lv);
|
||||||
|
REQUIRE(lvCopy.getSerializedSize() == 3);
|
||||||
|
REQUIRE(lv.getValue(nullptr) == lvCopy.getValue(nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
|
||||||
|
result::OK);
|
||||||
|
REQUIRE(deserSize == 3);
|
||||||
|
REQUIRE(rawBuf[0] == 2);
|
||||||
|
uint16_t sourceIdRaw = 0;
|
||||||
|
REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize,
|
||||||
|
SerializeIF::Endianness::BIG) == result::OK);
|
||||||
|
REQUIRE(sourceIdRaw == 0x0ff0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Empty Serialization") {
|
||||||
|
auto lvEmpty = Lv();
|
||||||
|
REQUIRE(lvEmpty.getSerializedSize() == 1);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
result =
|
||||||
|
lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(deserSize == 1);
|
||||||
|
deserPtr = rawBuf.data();
|
||||||
|
result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(lvEmpty.getSerializedSize() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Uninit LV") {
|
||||||
|
std::array<uint8_t, 8> lvRawBuf{};
|
||||||
|
serPtr = lvRawBuf.data();
|
||||||
|
REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) == result::OK);
|
||||||
|
auto lv = cfdp::Lv(lvRawBuf.data(), 2);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
Lv uninitLv;
|
||||||
|
deserPtr = rawBuf.data();
|
||||||
|
deserSize = 3;
|
||||||
|
result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(uninitLv.getSerializedSize() == 3);
|
||||||
|
const uint8_t* storedValue = uninitLv.getValue(nullptr);
|
||||||
|
uint16_t sourceIdRaw = 0;
|
||||||
|
REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize,
|
||||||
|
SerializeIF::Endianness::BIG) == result::OK);
|
||||||
|
REQUIRE(sourceIdRaw == 0x0ff0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Invalid Input") {
|
||||||
|
Lv uninitLv;
|
||||||
|
REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) ==
|
||||||
|
HasReturnvaluesIF::RETURN_FAILED);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) ==
|
||||||
|
SerializeIF::BUFFER_TOO_SHORT);
|
||||||
|
REQUIRE(uninitLv.serialize(nullptr, nullptr, 12, SerializeIF::Endianness::BIG));
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG) ==
|
||||||
|
SerializeIF::STREAM_TOO_SHORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("String LV") {
|
||||||
|
std::string filename = "hello.txt";
|
||||||
|
StringLv sourceFileName(filename);
|
||||||
|
REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size());
|
||||||
|
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK);
|
||||||
|
REQUIRE(rawBuf[0] == filename.size());
|
||||||
|
std::string filenameFromRaw(reinterpret_cast<const char*>(rawBuf.data() + 1), filename.size());
|
||||||
|
REQUIRE(filenameFromRaw == filename);
|
||||||
|
}
|
||||||
|
}
|
137
unittests/cfdp/testOtherTlvs.cpp
Normal file
137
unittests/cfdp/testOtherTlvs.cpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
#include <fsfw/cfdp/tlv/EntityIdTlv.h>
|
||||||
|
#include <fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h>
|
||||||
|
#include <fsfw/cfdp/tlv/FilestoreRequestTlv.h>
|
||||||
|
#include <fsfw/cfdp/tlv/FilestoreResponseTlv.h>
|
||||||
|
#include <fsfw/cfdp/tlv/FlowLabelTlv.h>
|
||||||
|
#include <fsfw/cfdp/tlv/MessageToUserTlv.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "fsfw/cfdp/pdu/PduConfig.h"
|
||||||
|
#include "fsfw/cfdp/tlv/Lv.h"
|
||||||
|
#include "fsfw/cfdp/tlv/Tlv.h"
|
||||||
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
|
|
||||||
|
TEST_CASE("CFDP LV", "[cfdp][lv]") {
|
||||||
|
using namespace cfdp;
|
||||||
|
ReturnValue_t result;
|
||||||
|
std::array<uint8_t, 255> rawBuf{};
|
||||||
|
uint8_t* serPtr = rawBuf.data();
|
||||||
|
const uint8_t* deserPtr = rawBuf.data();
|
||||||
|
size_t deserSize = 0;
|
||||||
|
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0);
|
||||||
|
|
||||||
|
SECTION("Filestore Response TLV") {
|
||||||
|
std::string name = "hello.txt";
|
||||||
|
cfdp::Lv firstName(reinterpret_cast<const uint8_t*>(name.data()), name.size());
|
||||||
|
std::string name2 = "hello2.txt";
|
||||||
|
cfdp::Lv secondName(reinterpret_cast<const uint8_t*>(name2.data()), name2.size());
|
||||||
|
std::string msg = "12345";
|
||||||
|
cfdp::Lv fsMsg(reinterpret_cast<const uint8_t*>(msg.data()), msg.size());
|
||||||
|
FilestoreResponseTlv response(cfdp::FilestoreActionCode::APPEND_FILE, cfdp::FSR_SUCCESS,
|
||||||
|
firstName, &fsMsg);
|
||||||
|
response.setSecondFileName(&secondName);
|
||||||
|
REQUIRE(response.getLengthField() == 10 + 11 + 6 + 1);
|
||||||
|
REQUIRE(response.getSerializedSize() == response.getLengthField() + 2);
|
||||||
|
|
||||||
|
cfdp::Tlv rawResponse;
|
||||||
|
std::array<uint8_t, 128> serBuf = {};
|
||||||
|
result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
|
||||||
|
cfdp::Lv emptyMsg;
|
||||||
|
cfdp::Lv emptySecondName;
|
||||||
|
FilestoreResponseTlv emptyTlv(firstName, &emptyMsg);
|
||||||
|
emptyTlv.setSecondFileName(&emptySecondName);
|
||||||
|
result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
|
||||||
|
REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS);
|
||||||
|
size_t firstNameLen = 0;
|
||||||
|
const char* firstNamePtr =
|
||||||
|
reinterpret_cast<const char*>(emptyTlv.getFirstFileName().getValue(&firstNameLen));
|
||||||
|
auto helloString = std::string(firstNamePtr, firstNameLen);
|
||||||
|
REQUIRE(helloString == "hello.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Filestore Request TLV") {
|
||||||
|
std::string name = "hello.txt";
|
||||||
|
cfdp::Lv firstName(reinterpret_cast<const uint8_t*>(name.data()), name.size());
|
||||||
|
std::string name2 = "hello2.txt";
|
||||||
|
cfdp::Lv secondName(reinterpret_cast<const uint8_t*>(name2.data()), name2.size());
|
||||||
|
FilestoreRequestTlv request(cfdp::FilestoreActionCode::APPEND_FILE, firstName);
|
||||||
|
|
||||||
|
// second name not set yet
|
||||||
|
REQUIRE(request.getLengthField() == 10 + 1);
|
||||||
|
REQUIRE(request.getSerializedSize() == request.getLengthField() + 2);
|
||||||
|
|
||||||
|
std::array<uint8_t, 128> serBuf = {};
|
||||||
|
uint8_t* ptr = serBuf.data();
|
||||||
|
size_t sz = 0;
|
||||||
|
result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == cfdp::FILESTORE_REQUIRES_SECOND_FILE);
|
||||||
|
|
||||||
|
ptr = serBuf.data();
|
||||||
|
sz = 0;
|
||||||
|
request.setSecondFileName(&secondName);
|
||||||
|
size_t expectedSz = request.getLengthField();
|
||||||
|
REQUIRE(expectedSz == 10 + 11 + 1);
|
||||||
|
REQUIRE(request.getSerializedSize() == expectedSz + 2);
|
||||||
|
result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(sz == expectedSz + 2);
|
||||||
|
|
||||||
|
FilestoreRequestTlv emptyRequest(firstName);
|
||||||
|
emptyRequest.setSecondFileName(&secondName);
|
||||||
|
const uint8_t* constptr = serBuf.data();
|
||||||
|
result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
|
cfdp::Tlv rawRequest;
|
||||||
|
ptr = serBuf.data();
|
||||||
|
sz = 0;
|
||||||
|
result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
|
||||||
|
|
||||||
|
emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE);
|
||||||
|
result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
|
||||||
|
REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Other") {
|
||||||
|
MessageToUserTlv emptyTlv;
|
||||||
|
uint8_t flowLabel = 1;
|
||||||
|
FlowLabelTlv flowLabelTlv(&flowLabel, 1);
|
||||||
|
|
||||||
|
FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION,
|
||||||
|
cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
|
||||||
|
size_t sz = 0;
|
||||||
|
result =
|
||||||
|
faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(faultOverrideTlv.getSerializedSize() == 3);
|
||||||
|
REQUIRE(sz == 3);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
|
FaultHandlerOverrideTlv emptyOverrideTlv;
|
||||||
|
result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
|
EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42);
|
||||||
|
EntityId emptyId;
|
||||||
|
EntityIdTlv idTlv(emptyId);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
deserPtr = rawBuf.data();
|
||||||
|
result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
}
|
||||||
|
}
|
130
unittests/cfdp/testTlv.cpp
Normal file
130
unittests/cfdp/testTlv.cpp
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#include <array>
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "fsfw/cfdp.h"
|
||||||
|
|
||||||
|
TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
|
||||||
|
using namespace cfdp;
|
||||||
|
ReturnValue_t result;
|
||||||
|
std::array<uint8_t, 255> rawBuf{};
|
||||||
|
uint8_t* serPtr = rawBuf.data();
|
||||||
|
const uint8_t* deserPtr = rawBuf.data();
|
||||||
|
size_t deserSize = 0;
|
||||||
|
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0);
|
||||||
|
|
||||||
|
SECTION("Entity ID Serialization") {
|
||||||
|
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) == result::OK);
|
||||||
|
REQUIRE(deserSize == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("TLV Serialization") {
|
||||||
|
std::array<uint8_t, 8> tlvBuf{};
|
||||||
|
REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == result::OK);
|
||||||
|
auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize);
|
||||||
|
REQUIRE(tlv.getSerializedSize() == 4);
|
||||||
|
REQUIRE(tlv.getLengthField() == 2);
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
|
||||||
|
result::OK);
|
||||||
|
REQUIRE(deserSize == 4);
|
||||||
|
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
|
||||||
|
REQUIRE(rawBuf[1] == 2);
|
||||||
|
uint16_t entityId = 0;
|
||||||
|
REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize,
|
||||||
|
SerializeIF::Endianness::NETWORK) == result::OK);
|
||||||
|
REQUIRE(entityId == 0x0ff0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("TLV Other Value") {
|
||||||
|
auto tlv = Tlv(TlvTypes::ENTITY_ID, rawBuf.data(), deserSize);
|
||||||
|
// Set new value
|
||||||
|
sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12);
|
||||||
|
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) == result::OK);
|
||||||
|
tlv.setValue(rawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
|
||||||
|
REQUIRE(rawBuf[1] == 4);
|
||||||
|
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("TLV Invalid") {
|
||||||
|
auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0);
|
||||||
|
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK);
|
||||||
|
tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3);
|
||||||
|
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) !=
|
||||||
|
HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(tlvInvalid.getSerializedSize() == 0);
|
||||||
|
REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) !=
|
||||||
|
HasReturnvaluesIF::RETURN_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("TLV Zero Length Field") {
|
||||||
|
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
|
||||||
|
REQUIRE(zeroLenField.getSerializedSize() == 2);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) ==
|
||||||
|
HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER);
|
||||||
|
REQUIRE(rawBuf[1] == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("TLV Deserialization") {
|
||||||
|
// Serialization was tested before, generate raw data now
|
||||||
|
std::array<uint8_t, 8> tlvRawBuf{};
|
||||||
|
serPtr = tlvRawBuf.data();
|
||||||
|
result =
|
||||||
|
sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||||
|
auto tlvSerialization = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
result = tlvSerialization.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
Tlv tlv;
|
||||||
|
deserPtr = rawBuf.data();
|
||||||
|
result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(tlv.getSerializedSize() == 4);
|
||||||
|
REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID);
|
||||||
|
deserPtr = tlv.getValue();
|
||||||
|
uint16_t entityId = 0;
|
||||||
|
deserSize = 0;
|
||||||
|
SerializeAdapter::deSerialize(&entityId, deserPtr, &deserSize,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(entityId == 0x0ff0);
|
||||||
|
|
||||||
|
REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) !=
|
||||||
|
HasReturnvaluesIF::RETURN_OK);
|
||||||
|
deserPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) ==
|
||||||
|
SerializeIF::STREAM_TOO_SHORT);
|
||||||
|
// Set invalid TLV
|
||||||
|
rawBuf[0] = TlvTypes::INVALID_TLV;
|
||||||
|
deserSize = 4;
|
||||||
|
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) !=
|
||||||
|
HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
|
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
|
||||||
|
serPtr = rawBuf.data();
|
||||||
|
deserSize = 0;
|
||||||
|
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
|
||||||
|
SerializeIF::Endianness::NETWORK) ==
|
||||||
|
HasReturnvaluesIF::RETURN_OK);
|
||||||
|
deserPtr = rawBuf.data();
|
||||||
|
result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
REQUIRE(zeroLenField.getSerializedSize() == 2);
|
||||||
|
REQUIRE(deserSize == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -1,330 +0,0 @@
|
|||||||
#include <fsfw/cfdp/tlv/EntityIdTlv.h>
|
|
||||||
#include <fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h>
|
|
||||||
#include <fsfw/cfdp/tlv/FilestoreRequestTlv.h>
|
|
||||||
#include <fsfw/cfdp/tlv/FilestoreResponseTlv.h>
|
|
||||||
#include <fsfw/cfdp/tlv/FlowLabelTlv.h>
|
|
||||||
#include <fsfw/cfdp/tlv/MessageToUserTlv.h>
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "fsfw/cfdp/pdu/PduConfig.h"
|
|
||||||
#include "fsfw/cfdp/tlv/Lv.h"
|
|
||||||
#include "fsfw/cfdp/tlv/Tlv.h"
|
|
||||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
|
||||||
|
|
||||||
TEST_CASE("CFDP TLV LV", "[cfdp]") {
|
|
||||||
using namespace cfdp;
|
|
||||||
ReturnValue_t result;
|
|
||||||
std::array<uint8_t, 255> rawBuf{};
|
|
||||||
uint8_t* serPtr = rawBuf.data();
|
|
||||||
const uint8_t* deserPtr = rawBuf.data();
|
|
||||||
size_t deserSize = 0;
|
|
||||||
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0);
|
|
||||||
|
|
||||||
SECTION("TLV Serialization") {
|
|
||||||
std::array<uint8_t, 8> tlvRawBuf{};
|
|
||||||
serPtr = tlvRawBuf.data();
|
|
||||||
result =
|
|
||||||
sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(deserSize == 2);
|
|
||||||
auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize);
|
|
||||||
REQUIRE(tlv.getSerializedSize() == 4);
|
|
||||||
REQUIRE(tlv.getLengthField() == 2);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(deserSize == 4);
|
|
||||||
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
|
|
||||||
REQUIRE(rawBuf[1] == 2);
|
|
||||||
uint16_t entityId = 0;
|
|
||||||
SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize,
|
|
||||||
SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(entityId == 0x0ff0);
|
|
||||||
|
|
||||||
// Set new value
|
|
||||||
sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12);
|
|
||||||
serPtr = tlvRawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result =
|
|
||||||
sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
tlv.setValue(tlvRawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
|
|
||||||
REQUIRE(rawBuf[1] == 4);
|
|
||||||
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, tlvRawBuf.data(), 0);
|
|
||||||
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK);
|
|
||||||
tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3);
|
|
||||||
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) !=
|
|
||||||
HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(tlvInvalid.getSerializedSize() == 0);
|
|
||||||
REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) !=
|
|
||||||
HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
|
|
||||||
REQUIRE(zeroLenField.getSerializedSize() == 2);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK) ==
|
|
||||||
HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER);
|
|
||||||
REQUIRE(rawBuf[1] == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("TLV Deserialization") {
|
|
||||||
// Serialization was tested before, generate raw data now
|
|
||||||
std::array<uint8_t, 8> tlvRawBuf{};
|
|
||||||
serPtr = tlvRawBuf.data();
|
|
||||||
result =
|
|
||||||
sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
auto tlvSerialization = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result = tlvSerialization.serialize(&serPtr, &deserSize, rawBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK);
|
|
||||||
Tlv tlv;
|
|
||||||
deserPtr = rawBuf.data();
|
|
||||||
result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(tlv.getSerializedSize() == 4);
|
|
||||||
REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID);
|
|
||||||
deserPtr = tlv.getValue();
|
|
||||||
uint16_t entityId = 0;
|
|
||||||
deserSize = 0;
|
|
||||||
SerializeAdapter::deSerialize(&entityId, deserPtr, &deserSize,
|
|
||||||
SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(entityId == 0x0ff0);
|
|
||||||
|
|
||||||
REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) !=
|
|
||||||
HasReturnvaluesIF::RETURN_OK);
|
|
||||||
deserPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) ==
|
|
||||||
SerializeIF::STREAM_TOO_SHORT);
|
|
||||||
// Set invalid TLV
|
|
||||||
rawBuf[0] = TlvTypes::INVALID_TLV;
|
|
||||||
deserSize = 4;
|
|
||||||
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) !=
|
|
||||||
HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK) ==
|
|
||||||
HasReturnvaluesIF::RETURN_OK);
|
|
||||||
deserPtr = rawBuf.data();
|
|
||||||
result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(zeroLenField.getSerializedSize() == 2);
|
|
||||||
REQUIRE(deserSize == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("LV Serialization") {
|
|
||||||
std::array<uint8_t, 8> lvRawBuf{};
|
|
||||||
serPtr = lvRawBuf.data();
|
|
||||||
result =
|
|
||||||
sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(deserSize == 2);
|
|
||||||
auto lv = cfdp::Lv(lvRawBuf.data(), 2);
|
|
||||||
auto lvCopy = cfdp::Lv(lv);
|
|
||||||
REQUIRE(lv.getSerializedSize() == 3);
|
|
||||||
REQUIRE(lvCopy.getSerializedSize() == 3);
|
|
||||||
REQUIRE(lv.getValue(nullptr) == lvCopy.getValue(nullptr));
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(deserSize == 3);
|
|
||||||
REQUIRE(rawBuf[0] == 2);
|
|
||||||
uint16_t sourceIdRaw = 0;
|
|
||||||
result = SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize,
|
|
||||||
SerializeIF::Endianness::BIG);
|
|
||||||
REQUIRE(sourceIdRaw == 0x0ff0);
|
|
||||||
|
|
||||||
auto lvEmpty = Lv();
|
|
||||||
REQUIRE(lvEmpty.getSerializedSize() == 1);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result =
|
|
||||||
lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(deserSize == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("LV Deserialization") {
|
|
||||||
std::array<uint8_t, 8> lvRawBuf{};
|
|
||||||
serPtr = lvRawBuf.data();
|
|
||||||
result =
|
|
||||||
sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
auto lv = cfdp::Lv(lvRawBuf.data(), 2);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
Lv uninitLv;
|
|
||||||
deserPtr = rawBuf.data();
|
|
||||||
deserSize = 3;
|
|
||||||
result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(uninitLv.getSerializedSize() == 3);
|
|
||||||
const uint8_t* storedValue = uninitLv.getValue(nullptr);
|
|
||||||
uint16_t sourceIdRaw = 0;
|
|
||||||
result = SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize,
|
|
||||||
SerializeIF::Endianness::BIG);
|
|
||||||
REQUIRE(sourceIdRaw == 0x0ff0);
|
|
||||||
|
|
||||||
auto lvEmpty = Lv();
|
|
||||||
REQUIRE(lvEmpty.getSerializedSize() == 1);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
result =
|
|
||||||
lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(deserSize == 1);
|
|
||||||
deserPtr = rawBuf.data();
|
|
||||||
result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(uninitLv.getSerializedSize() == 1);
|
|
||||||
|
|
||||||
REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) ==
|
|
||||||
HasReturnvaluesIF::RETURN_FAILED);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
deserSize = 0;
|
|
||||||
REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) ==
|
|
||||||
SerializeIF::BUFFER_TOO_SHORT);
|
|
||||||
REQUIRE(uninitLv.serialize(nullptr, nullptr, 12, SerializeIF::Endianness::BIG));
|
|
||||||
deserSize = 0;
|
|
||||||
REQUIRE(uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG) ==
|
|
||||||
SerializeIF::STREAM_TOO_SHORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("Filestore Response TLV") {
|
|
||||||
std::string name = "hello.txt";
|
|
||||||
cfdp::Lv firstName(reinterpret_cast<const uint8_t*>(name.data()), name.size());
|
|
||||||
std::string name2 = "hello2.txt";
|
|
||||||
cfdp::Lv secondName(reinterpret_cast<const uint8_t*>(name2.data()), name2.size());
|
|
||||||
std::string msg = "12345";
|
|
||||||
cfdp::Lv fsMsg(reinterpret_cast<const uint8_t*>(msg.data()), msg.size());
|
|
||||||
FilestoreResponseTlv response(cfdp::FilestoreActionCode::APPEND_FILE, cfdp::FSR_SUCCESS,
|
|
||||||
firstName, &fsMsg);
|
|
||||||
response.setSecondFileName(&secondName);
|
|
||||||
REQUIRE(response.getLengthField() == 10 + 11 + 6 + 1);
|
|
||||||
REQUIRE(response.getSerializedSize() == response.getLengthField() + 2);
|
|
||||||
|
|
||||||
cfdp::Tlv rawResponse;
|
|
||||||
std::array<uint8_t, 128> serBuf = {};
|
|
||||||
result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
|
|
||||||
cfdp::Lv emptyMsg;
|
|
||||||
cfdp::Lv emptySecondName;
|
|
||||||
FilestoreResponseTlv emptyTlv(firstName, &emptyMsg);
|
|
||||||
emptyTlv.setSecondFileName(&emptySecondName);
|
|
||||||
result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
|
|
||||||
REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS);
|
|
||||||
size_t firstNameLen = 0;
|
|
||||||
const char* firstNamePtr =
|
|
||||||
reinterpret_cast<const char*>(emptyTlv.getFirstFileName().getValue(&firstNameLen));
|
|
||||||
auto helloString = std::string(firstNamePtr, firstNameLen);
|
|
||||||
REQUIRE(helloString == "hello.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("Filestore Request TLV") {
|
|
||||||
std::string name = "hello.txt";
|
|
||||||
cfdp::Lv firstName(reinterpret_cast<const uint8_t*>(name.data()), name.size());
|
|
||||||
std::string name2 = "hello2.txt";
|
|
||||||
cfdp::Lv secondName(reinterpret_cast<const uint8_t*>(name2.data()), name2.size());
|
|
||||||
FilestoreRequestTlv request(cfdp::FilestoreActionCode::APPEND_FILE, firstName);
|
|
||||||
|
|
||||||
// second name not set yet
|
|
||||||
REQUIRE(request.getLengthField() == 10 + 1);
|
|
||||||
REQUIRE(request.getSerializedSize() == request.getLengthField() + 2);
|
|
||||||
|
|
||||||
std::array<uint8_t, 128> serBuf = {};
|
|
||||||
uint8_t* ptr = serBuf.data();
|
|
||||||
size_t sz = 0;
|
|
||||||
result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == cfdp::FILESTORE_REQUIRES_SECOND_FILE);
|
|
||||||
|
|
||||||
ptr = serBuf.data();
|
|
||||||
sz = 0;
|
|
||||||
request.setSecondFileName(&secondName);
|
|
||||||
size_t expectedSz = request.getLengthField();
|
|
||||||
REQUIRE(expectedSz == 10 + 11 + 1);
|
|
||||||
REQUIRE(request.getSerializedSize() == expectedSz + 2);
|
|
||||||
result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(sz == expectedSz + 2);
|
|
||||||
|
|
||||||
FilestoreRequestTlv emptyRequest(firstName);
|
|
||||||
emptyRequest.setSecondFileName(&secondName);
|
|
||||||
const uint8_t* constptr = serBuf.data();
|
|
||||||
result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
cfdp::Tlv rawRequest;
|
|
||||||
ptr = serBuf.data();
|
|
||||||
sz = 0;
|
|
||||||
result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(),
|
|
||||||
SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
|
|
||||||
|
|
||||||
emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE);
|
|
||||||
result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
|
|
||||||
REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("Other") {
|
|
||||||
MessageToUserTlv emptyTlv;
|
|
||||||
uint8_t flowLabel = 1;
|
|
||||||
FlowLabelTlv flowLabelTlv(&flowLabel, 1);
|
|
||||||
|
|
||||||
FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION,
|
|
||||||
cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
|
|
||||||
size_t sz = 0;
|
|
||||||
result =
|
|
||||||
faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(faultOverrideTlv.getSerializedSize() == 3);
|
|
||||||
REQUIRE(sz == 3);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
FaultHandlerOverrideTlv emptyOverrideTlv;
|
|
||||||
result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
|
|
||||||
EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42);
|
|
||||||
EntityId emptyId;
|
|
||||||
EntityIdTlv idTlv(emptyId);
|
|
||||||
serPtr = rawBuf.data();
|
|
||||||
result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
|
|
||||||
cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
deserPtr = rawBuf.data();
|
|
||||||
result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK);
|
|
||||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,7 +9,7 @@ void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::Condition
|
|||||||
void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {}
|
void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {}
|
||||||
void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {}
|
void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {}
|
||||||
void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {}
|
void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {}
|
||||||
void cfdp::UserMock::fileSegmentRecvdIndication() {}
|
void cfdp::UserMock::fileSegmentRecvdIndication(FileSegmentRecvdParams params) {}
|
||||||
void cfdp::UserMock::reportIndication() {}
|
void cfdp::UserMock::reportIndication() {}
|
||||||
void cfdp::UserMock::suspendedIndication() {}
|
void cfdp::UserMock::suspendedIndication() {}
|
||||||
void cfdp::UserMock::resumedIndication() {}
|
void cfdp::UserMock::resumedIndication() {}
|
||||||
|
@ -14,7 +14,7 @@ class UserMock : public UserBase {
|
|||||||
void eofRecvIndication(TransactionId id) override;
|
void eofRecvIndication(TransactionId id) override;
|
||||||
void transactionFinishedIndication(TransactionFinishedParams params) override;
|
void transactionFinishedIndication(TransactionFinishedParams params) override;
|
||||||
void metadataRecvdIndication(MetadataRecvParams params) override;
|
void metadataRecvdIndication(MetadataRecvParams params) override;
|
||||||
void fileSegmentRecvdIndication() override;
|
void fileSegmentRecvdIndication(FileSegmentRecvdParams params) override;
|
||||||
void reportIndication() override;
|
void reportIndication() override;
|
||||||
void suspendedIndication() override;
|
void suspendedIndication() override;
|
||||||
void resumedIndication() override;
|
void resumedIndication() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user