all retval replacements

This commit is contained in:
Robin Müller 2022-08-22 16:35:53 +02:00
parent 9e5dddf79c
commit d12c59c8ac
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
27 changed files with 204 additions and 207 deletions

View File

@ -9,24 +9,24 @@ ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& addre
AcceptsTelecommandsIF& tcDest) { AcceptsTelecommandsIF& tcDest) {
for (const auto& dest : tcDestinations) { for (const auto& dest : tcDestinations) {
if (dest.id == address) { if (dest.id == address) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
} }
tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue()); tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue());
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) {
auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId()); auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId());
if (accessorPair.first != HasReturnvaluesIF::RETURN_OK) { if (accessorPair.first != returnvalue::OK) {
return accessorPair.first; return accessorPair.first;
} }
ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size()); ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size());
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = pduReader.parseData(); result = pduReader.parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
cfdp::EntityId foundId; cfdp::EntityId foundId;
@ -44,7 +44,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) {
} }
// Packet was forwarded successfully, so do not delete it. // Packet was forwarded successfully, so do not delete it.
accessorPair.second.release(); accessorPair.second.release();
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
const char* CfdpDistributor::getName() const { return "CFDP Distributor"; } const char* CfdpDistributor::getName() const { return "CFDP Distributor"; }

View File

@ -5,7 +5,7 @@
#include <vector> #include <vector>
#include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/cfdp/pdu/HeaderReader.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tcdistribution/CfdpPacketChecker.h" #include "fsfw/tcdistribution/CfdpPacketChecker.h"
#include "fsfw/tcdistribution/TcDistributorBase.h" #include "fsfw/tcdistribution/TcDistributorBase.h"
#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" #include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h"
@ -61,8 +61,8 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF {
MessageQueueId_t queueId; MessageQueueId_t queueId;
}; };
HeaderReader pduReader; HeaderReader pduReader;
ReturnValue_t lastTcError = HasReturnvaluesIF::RETURN_OK; ReturnValue_t lastTcError = returnvalue::OK;
ReturnValue_t lastTmError = HasReturnvaluesIF::RETURN_OK; ReturnValue_t lastTmError = returnvalue::OK;
// I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think
// it is okay to accept the overhead here // it is okay to accept the overhead here
std::vector<EntityInfo> tcDestinations; std::vector<EntityInfo> tcDestinations;

View File

@ -61,4 +61,3 @@
//}; //};
// //
//#endif /* FSFW_CFDP_CFDPHANDLER_H_ */ //#endif /* FSFW_CFDP_CFDPHANDLER_H_ */

View File

@ -23,30 +23,30 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() {
case TransactionStep::SENDING_FINISHED_PDU: case TransactionStep::SENDING_FINISHED_PDU:
break; break;
} }
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) {
if (p.packetListRef.full()) { if (p.packetListRef.full()) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
p.packetListRef.push_back(packet); p.packetListRef.push_back(packet);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t cfdp::DestHandler::initialize() { ReturnValue_t cfdp::DestHandler::initialize() {
if (p.tmStore == nullptr) { if (p.tmStore == nullptr) {
p.tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE); p.tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (p.tmStore == nullptr) { if (p.tmStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
} }
if (p.tcStore == nullptr) { if (p.tcStore == nullptr) {
p.tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE); p.tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (p.tcStore == nullptr) { if (p.tcStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
} }
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }

View File

@ -6,6 +6,7 @@ AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Ac
ReturnValue_t AckPduDeserializer::parseData() { ReturnValue_t AckPduDeserializer::parseData() {
ReturnValue_t result = FileDirectiveReader::parseData(); ReturnValue_t result = FileDirectiveReader::parseData();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result;
} }
size_t currentIdx = FileDirectiveReader::getHeaderSize(); size_t currentIdx = FileDirectiveReader::getHeaderSize();
if (currentIdx + 2 > this->maxSize) { if (currentIdx + 2 > this->maxSize) {

View File

@ -12,13 +12,13 @@ size_t FileDirectiveCreator::getSerializedSize() const {
ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
if (buffer == nullptr or size == nullptr) { if (buffer == nullptr or size == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
if (FileDirectiveCreator::getWholePduSize() > maxSize) { if (FileDirectiveCreator::getWholePduSize() > maxSize) {
return BUFFER_TOO_SHORT; return BUFFER_TOO_SHORT;
} }
ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -28,7 +28,7 @@ ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, si
**buffer = directiveCode; **buffer = directiveCode;
*buffer += 1; *buffer += 1;
*size += 1; *size += 1;
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) { void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) {

View File

@ -7,7 +7,7 @@ cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return file
ReturnValue_t FileDirectiveReader::parseData() { ReturnValue_t FileDirectiveReader::parseData() {
ReturnValue_t result = HeaderReader::parseData(); ReturnValue_t result = HeaderReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
if (this->getPduDataFieldLen() < 1) { if (this->getPduDataFieldLen() < 1) {
@ -21,7 +21,7 @@ ReturnValue_t FileDirectiveReader::parseData() {
return cfdp::INVALID_DIRECTIVE_FIELDS; return cfdp::INVALID_DIRECTIVE_FIELDS;
} }
setFileDirective(static_cast<cfdp::FileDirectives>(pointers.rawPtr[currentIdx])); setFileDirective(static_cast<cfdp::FileDirectives>(pointers.rawPtr[currentIdx]));
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
size_t FileDirectiveReader::getHeaderSize() const { size_t FileDirectiveReader::getHeaderSize() const {

View File

@ -12,7 +12,7 @@ HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t i
ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
if (buffer == nullptr or size == nullptr) { if (buffer == nullptr or size == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
if (maxSize < this->getSerializedSize()) { if (maxSize < this->getSerializedSize()) {
return BUFFER_TOO_SHORT; return BUFFER_TOO_SHORT;
@ -29,19 +29,19 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma
*buffer += 1; *buffer += 1;
*size += 4; *size += 4;
ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
size_t HeaderCreator::getSerializedSize() const { size_t HeaderCreator::getSerializedSize() const {
@ -51,7 +51,7 @@ size_t HeaderCreator::getSerializedSize() const {
ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size, ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) { Endianness streamEndianness) {
// We could implement this, but I prefer dedicated classes // We could implement this, but I prefer dedicated classes
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
size_t HeaderCreator::getWholePduSize() const { size_t HeaderCreator::getWholePduSize() const {

View File

@ -8,7 +8,7 @@ HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduB
ReturnValue_t HeaderReader::parseData() { ReturnValue_t HeaderReader::parseData() {
if (pointers.rawPtr == nullptr) { if (pointers.rawPtr == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
if (maxSize < 7) { if (maxSize < 7) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
@ -20,19 +20,19 @@ ReturnValue_t HeaderReader::parseData() {
cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); cfdp::WidthInBytes widthSeqNum = getLenSeqNum();
seqNumRaw = static_cast<uint8_t *>(sourceIdRaw) + static_cast<uint8_t>(widthEntityIds); seqNumRaw = static_cast<uint8_t *>(sourceIdRaw) + static_cast<uint8_t>(widthEntityIds);
destIdRaw = static_cast<uint8_t *>(seqNumRaw) + static_cast<uint8_t>(widthSeqNum); destIdRaw = static_cast<uint8_t *>(seqNumRaw) + static_cast<uint8_t>(widthSeqNum);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) {
if (dataPtr == nullptr) { if (dataPtr == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
if (maxSize_ < 7) { if (maxSize_ < 7) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
pointers.rawPtr = dataPtr; pointers.rawPtr = dataPtr;
maxSize = maxSize_; maxSize = maxSize_;
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
size_t HeaderReader::getHeaderSize() const { size_t HeaderReader::getHeaderSize() const {

View File

@ -7,7 +7,7 @@
#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/FwClassIds.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/returnvalue.h"
struct FilesystemParams { struct FilesystemParams {
explicit FilesystemParams(const char* path) : path(path) {} explicit FilesystemParams(const char* path) : path(path) {}

View File

@ -36,7 +36,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) {
#endif #endif
auto accessorPair = tcStore->getData(currentMessage.getStorageId()); auto accessorPair = tcStore->getData(currentMessage.getStorageId());
ReturnValue_t result = accessorPair.first; ReturnValue_t result = accessorPair.first;
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CCSDSDistributor::selectDestination: Getting data from" sif::error << "CCSDSDistributor::selectDestination: Getting data from"
@ -64,7 +64,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) {
} }
SpacePacketReader currentPacket(accessorPair.second.data(), accessorPair.second.size()); SpacePacketReader currentPacket(accessorPair.second.data(), accessorPair.second.size());
result = packetChecker->checkPacket(currentPacket, accessorPair.second.size()); result = packetChecker->checkPacket(currentPacket, accessorPair.second.size());
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
handlePacketCheckFailure(result); handlePacketCheckFailure(result);
return result; return result;
} }
@ -90,7 +90,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) {
return handleCcsdsHeaderRemoval(accessorPair.second); return handleCcsdsHeaderRemoval(accessorPair.second);
} }
accessorPair.second.release(); accessorPair.second.release();
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) {
@ -116,10 +116,10 @@ void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) {
MessageQueueId_t CcsdsDistributor::getRequestQueue() const { return tcQueue->getId(); } MessageQueueId_t CcsdsDistributor::getRequestQueue() const { return tcQueue->getId(); }
ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) { ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) {
ReturnValue_t returnValue = RETURN_OK; ReturnValue_t returnValue = returnvalue::OK;
auto insertPair = receiverMap.emplace(info.apid, info); auto insertPair = receiverMap.emplace(info.apid, info);
if (not insertPair.second) { if (not insertPair.second) {
returnValue = RETURN_FAILED; returnValue = returnvalue::FAILED;
} }
return returnValue; return returnValue;
} }
@ -128,7 +128,7 @@ uint32_t CcsdsDistributor::getIdentifier() const { return 0; }
ReturnValue_t CcsdsDistributor::initialize() { ReturnValue_t CcsdsDistributor::initialize() {
ReturnValue_t result = TcDistributorBase::initialize(); ReturnValue_t result = TcDistributorBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
if (packetChecker == nullptr) { if (packetChecker == nullptr) {
@ -156,10 +156,10 @@ ReturnValue_t CcsdsDistributor::initialize() {
} }
ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) { ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
if (queueStatus != RETURN_OK) { if (queueStatus != returnvalue::OK) {
tcStore->deleteData(currentMessage.getStorageId()); tcStore->deleteData(currentMessage.getStorageId());
} }
return RETURN_OK; return returnvalue::OK;
} }
void CcsdsDistributor::print() { void CcsdsDistributor::print() {
@ -180,7 +180,7 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a
store_address_t newStoreId; store_address_t newStoreId;
ReturnValue_t result = tcStore->addData(&newStoreId, accessor.data() + ccsds::HEADER_LEN, ReturnValue_t result = tcStore->addData(&newStoreId, accessor.data() + ccsds::HEADER_LEN,
accessor.size() - ccsds::HEADER_LEN); accessor.size() - ccsds::HEADER_LEN);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << __func__ << ": TC store full" << std::endl; sif::error << __func__ << ": TC store full" << std::endl;
#else #else
@ -190,5 +190,5 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a
} }
currentMessage.setStorageId(newStoreId); currentMessage.setStorageId(newStoreId);
// The const accessor will delete the old data automatically // The const accessor will delete the old data automatically
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }

View File

@ -27,8 +27,8 @@ ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) {
// TODO: Need to set the data // TODO: Need to set the data
const uint8_t* packetPtr = nullptr; const uint8_t* packetPtr = nullptr;
size_t packetLen = 0; size_t packetLen = 0;
ReturnValue_t result = store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != ReturnValue_t result =
returnvalue::OK; store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK;
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
tcStatus = PACKET_LOST; tcStatus = PACKET_LOST;
return result; return result;

View File

@ -20,11 +20,11 @@ TcDistributorBase::~TcDistributorBase() {
ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) {
ReturnValue_t status; ReturnValue_t status;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = returnvalue::OK;
for (status = tcQueue->receiveMessage(&currentMessage); status == RETURN_OK; for (status = tcQueue->receiveMessage(&currentMessage); status == returnvalue::OK;
status = tcQueue->receiveMessage(&currentMessage)) { status = tcQueue->receiveMessage(&currentMessage)) {
ReturnValue_t packetResult = handlePacket(); ReturnValue_t packetResult = handlePacket();
if (packetResult != HasReturnvaluesIF::RETURN_OK) { if (packetResult != returnvalue::OK) {
result = packetResult; result = packetResult;
triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, 1); triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, 1);
} }
@ -38,12 +38,12 @@ ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) {
ReturnValue_t TcDistributorBase::handlePacket() { ReturnValue_t TcDistributorBase::handlePacket() {
MessageQueueId_t destId; MessageQueueId_t destId;
ReturnValue_t result = selectDestination(destId); ReturnValue_t result = selectDestination(destId);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
return result; return result;
} }
return callbackAfterSending(tcQueue->sendMessage(destId, &currentMessage)); return callbackAfterSending(tcQueue->sendMessage(destId, &currentMessage));
} }
ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) { ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) {
return RETURN_OK; return returnvalue::OK;
} }

View File

@ -10,7 +10,7 @@
namespace tmtcdistrib { namespace tmtcdistrib {
static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION; static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION;
static constexpr ReturnValue_t NO_DESTINATION_FOUND = result::makeCode(INTERFACE_ID, 0); static constexpr ReturnValue_t NO_DESTINATION_FOUND = returnvalue::makeCode(INTERFACE_ID, 0);
static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1);
static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3); static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3);

View File

@ -12,7 +12,7 @@ HostFilesystem::HostFilesystem() = default;
ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) { ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) {
if (params.path() == nullptr) { if (params.path() == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path path(params.path()); path path(params.path());
if (not exists(path)) { if (not exists(path)) {
@ -24,13 +24,13 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da
} }
file.seekp(static_cast<unsigned int>(params.offset)); file.seekp(static_cast<unsigned int>(params.offset));
file.write(reinterpret_cast<const char *>(data), static_cast<unsigned int>(params.size)); file.write(reinterpret_cast<const char *>(data), static_cast<unsigned int>(params.size));
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize,
size_t maxSize) { size_t maxSize) {
if (params.path() == nullptr) { if (params.path() == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path path(params.path()); path path(params.path());
if (not exists(path)) { if (not exists(path)) {
@ -48,13 +48,13 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer
file.read(reinterpret_cast<char *>(*buffer), sizeToRead); file.read(reinterpret_cast<char *>(*buffer), sizeToRead);
readSize += sizeToRead; readSize += sizeToRead;
*buffer += sizeToRead; *buffer += sizeToRead;
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t *data, ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t *data,
size_t size) { size_t size) {
if (params.path == nullptr) { if (params.path == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path path(params.path); path path(params.path);
if (exists(path)) { if (exists(path)) {
@ -64,26 +64,26 @@ ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t
if (file.fail()) { if (file.fail()) {
return HasFileSystemIF::GENERIC_FILE_ERROR; return HasFileSystemIF::GENERIC_FILE_ERROR;
} }
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *args) { ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *args) {
if (path_ == nullptr) { if (path_ == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path path(path_); path path(path_);
if (not exists(path)) { if (not exists(path)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
} }
if (remove(path, errorCode)) { if (remove(path, errorCode)) {
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
return HasFileSystemIF::GENERIC_FILE_ERROR; return HasFileSystemIF::GENERIC_FILE_ERROR;
} }
ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) { ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) {
if (params.path == nullptr) { if (params.path == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path dirPath(params.path); path dirPath(params.path);
@ -93,19 +93,19 @@ ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool crea
if (createParentDirs) { if (createParentDirs) {
if (create_directories(dirPath, errorCode)) { if (create_directories(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
return HasFileSystemIF::GENERIC_DIR_ERROR; return HasFileSystemIF::GENERIC_DIR_ERROR;
} }
if (create_directory(dirPath, errorCode)) { if (create_directory(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
return HasFileSystemIF::GENERIC_DIR_ERROR; return HasFileSystemIF::GENERIC_DIR_ERROR;
} }
ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) { ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) {
if (params.path == nullptr) { if (params.path == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path dirPath(params.path); path dirPath(params.path);
if (not exists(dirPath)) { if (not exists(dirPath)) {
@ -116,11 +116,11 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele
} }
if (deleteRecurively) { if (deleteRecurively) {
if (remove_all(dirPath, errorCode)) { if (remove_all(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
} else { } else {
if (remove(dirPath, errorCode)) { if (remove(dirPath, errorCode)) {
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
} }
// Error handling // Error handling
@ -133,7 +133,7 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele
ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_,
FileSystemArgsIF *args) { FileSystemArgsIF *args) {
if (oldPath_ == nullptr or newPath_ == nullptr) { if (oldPath_ == nullptr or newPath_ == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
path oldPath(oldPath_); path oldPath(oldPath_);
path newPath(newPath_); path newPath(newPath_);
@ -142,5 +142,5 @@ ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_,
if (errorCode) { if (errorCode) {
return HasFileSystemIF::GENERIC_RENAME_ERROR; return HasFileSystemIF::GENERIC_RENAME_ERROR;
} }
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }

View File

@ -36,41 +36,41 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
uint8_t* dataPtr = nullptr; uint8_t* dataPtr = nullptr;
SECTION("State") { SECTION("State") {
CHECK(distributor.initialize() == result::OK); CHECK(distributor.initialize() == returnvalue::OK);
CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0); CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0);
CHECK(distributor.getIdentifier() == 0); CHECK(distributor.getIdentifier() == 0);
CHECK(distributor.getRequestQueue() == queue.getId()); CHECK(distributor.getRequestQueue() == queue.getId());
} }
SECTION("Packet Forwarding") { SECTION("Packet Forwarding") {
CHECK(distributor.initialize() == result::OK); CHECK(distributor.initialize() == returnvalue::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK);
size_t serLen = 0; size_t serLen = 0;
store_address_t storeId; store_address_t storeId;
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) ==
result::OK); returnvalue::OK);
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
result::OK); returnvalue::OK);
TmTcMessage msg(storeId); TmTcMessage msg(storeId);
queue.addReceivedMessage(msg); queue.addReceivedMessage(msg);
CHECK(distributor.performOperation(0) == result::OK); CHECK(distributor.performOperation(0) == returnvalue::OK);
CHECK(queue.wasMessageSent()); CHECK(queue.wasMessageSent());
CHECK(queue.numberOfSentMessages() == 1); CHECK(queue.numberOfSentMessages() == 1);
// The packet is forwarded, with no need to delete the data // The packet is forwarded, with no need to delete the data
CHECK(pool.hasDataAtId(storeId)); CHECK(pool.hasDataAtId(storeId));
TmTcMessage sentMsg; TmTcMessage sentMsg;
CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == result::OK); CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == returnvalue::OK);
CHECK(sentMsg.getStorageId() == storeId); CHECK(sentMsg.getStorageId() == storeId);
} }
SECTION("No Destination found") { SECTION("No Destination found") {
CHECK(distributor.initialize() == result::OK); CHECK(distributor.initialize() == returnvalue::OK);
size_t serLen = 0; size_t serLen = 0;
store_address_t storeId; store_address_t storeId;
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) ==
result::OK); returnvalue::OK);
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
result::OK); returnvalue::OK);
TmTcMessage msg(storeId); TmTcMessage msg(storeId);
queue.addReceivedMessage(msg); queue.addReceivedMessage(msg);
CHECK(distributor.performOperation(0) == tmtcdistrib::NO_DESTINATION_FOUND); CHECK(distributor.performOperation(0) == tmtcdistrib::NO_DESTINATION_FOUND);
@ -81,19 +81,19 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
pool.nextModifyDataCallFails.second = StorageManagerIF::DATA_DOES_NOT_EXIST; pool.nextModifyDataCallFails.second = StorageManagerIF::DATA_DOES_NOT_EXIST;
size_t serLen = 0; size_t serLen = 0;
store_address_t storeId; store_address_t storeId;
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK);
CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) ==
result::OK); returnvalue::OK);
REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) ==
result::OK); returnvalue::OK);
TmTcMessage msg(storeId); TmTcMessage msg(storeId);
queue.addReceivedMessage(msg); queue.addReceivedMessage(msg);
CHECK(distributor.performOperation(0) == StorageManagerIF::DATA_DOES_NOT_EXIST); CHECK(distributor.performOperation(0) == StorageManagerIF::DATA_DOES_NOT_EXIST);
} }
SECTION("Duplicate registration") { SECTION("Duplicate registration") {
CHECK(distributor.initialize() == result::OK); CHECK(distributor.initialize() == returnvalue::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK);
CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::FAILED); CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::FAILED);
} }
} }

View File

@ -3,7 +3,7 @@
#include "fsfw/cfdp/pdu/HeaderCreator.h" #include "fsfw/cfdp/pdu/HeaderCreator.h"
#include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/cfdp/pdu/HeaderReader.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/returnvalue.h"
TEST_CASE("CFDP Header", "[cfdp]") { TEST_CASE("CFDP Header", "[cfdp]") {
using namespace cfdp; using namespace cfdp;
@ -49,12 +49,12 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Deserialization fails") { SECTION("Deserialization fails") {
const uint8_t** dummyPtr = nullptr; const uint8_t** dummyPtr = nullptr;
REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) == REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) ==
result::FAILED); returnvalue::FAILED);
} }
SECTION("Serialization fails") { SECTION("Serialization fails") {
REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(), REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(),
SerializeIF::Endianness::NETWORK) == result::FAILED); SerializeIF::Endianness::NETWORK) == returnvalue::FAILED);
} }
SECTION("Buffer Too Short") { SECTION("Buffer Too Short") {
@ -93,7 +93,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Regular") { SECTION("Regular") {
// Everything except version bit flipped to one now // Everything except version bit flipped to one now
REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG) == result::OK); SerializeIF::Endianness::BIG) == returnvalue::OK);
CHECK(serBuf[0] == 0x3f); CHECK(serBuf[0] == 0x3f);
CHECK(serBuf[3] == 0x99); CHECK(serBuf[3] == 0x99);
REQUIRE(headerSerializer.getCrcFlag() == true); REQUIRE(headerSerializer.getCrcFlag() == true);
@ -114,7 +114,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(pduConf.sourceId.getSerializedSize() == 4); REQUIRE(pduConf.sourceId.getSerializedSize() == 4);
REQUIRE(headerSerializer.getSerializedSize() == 14); REQUIRE(headerSerializer.getSerializedSize() == 14);
REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG) == result::OK); SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(headerSerializer.getCrcFlag() == true); REQUIRE(headerSerializer.getCrcFlag() == true);
REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER);
REQUIRE(headerSerializer.getLargeFileFlag() == true); REQUIRE(headerSerializer.getLargeFileFlag() == true);
@ -157,17 +157,17 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Invalid Variable Sized Fields") { SECTION("Invalid Variable Sized Fields") {
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff);
REQUIRE(result == result::FAILED); REQUIRE(result == returnvalue::FAILED);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff);
REQUIRE(result == result::FAILED); REQUIRE(result == returnvalue::FAILED);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff);
REQUIRE(result == result::FAILED); REQUIRE(result == returnvalue::FAILED);
} }
SECTION("Header Serialization") { SECTION("Header Serialization") {
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
REQUIRE(serSize == 7); REQUIRE(serSize == 7);
// Only version bits are set // Only version bits are set
REQUIRE(serBuf[0] == 0b00100000); REQUIRE(serBuf[0] == 0b00100000);
@ -216,7 +216,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
SECTION("Header Deserialization") { SECTION("Header Deserialization") {
REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG) == result::OK); SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[1] == 0);
REQUIRE(serBuf[2] == 0); REQUIRE(serBuf[2] == 0);
// Entity and Transaction Sequence number are 1 byte large // Entity and Transaction Sequence number are 1 byte large
@ -226,7 +226,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
auto headerDeser = HeaderReader(serBuf.data(), serBuf.size()); auto headerDeser = HeaderReader(serBuf.data(), serBuf.size());
ReturnValue_t serResult = headerDeser.parseData(); ReturnValue_t serResult = headerDeser.parseData();
REQUIRE(serResult == result::OK); REQUIRE(serResult == returnvalue::OK);
REQUIRE(headerDeser.getPduDataFieldLen() == 0); REQUIRE(headerDeser.getPduDataFieldLen() == 0);
REQUIRE(headerDeser.getHeaderSize() == 7); REQUIRE(headerDeser.getHeaderSize() == 7);
REQUIRE(headerDeser.getWholePduSize() == 7); REQUIRE(headerDeser.getWholePduSize() == 7);
@ -249,11 +249,11 @@ TEST_CASE("CFDP Header", "[cfdp]") {
headerSerializer.setPduType(cfdp::PduType::FILE_DATA); headerSerializer.setPduType(cfdp::PduType::FILE_DATA);
headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff);
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00);
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff);
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
serTarget = serBuf.data(); serTarget = serBuf.data();
serSize = 0; serSize = 0;
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
@ -261,7 +261,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
headerDeser = HeaderReader(serBuf.data(), serBuf.size()); headerDeser = HeaderReader(serBuf.data(), serBuf.size());
result = headerDeser.parseData(); result = headerDeser.parseData();
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
// Everything except version bit flipped to one now // Everything except version bit flipped to one now
REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[0] == 0x3f);
REQUIRE(serBuf[3] == 0b11001010); REQUIRE(serBuf[3] == 0b11001010);
@ -293,9 +293,9 @@ TEST_CASE("CFDP Header", "[cfdp]") {
serTarget = serBuf.data(); serTarget = serBuf.data();
const auto** serTargetConst = const_cast<const uint8_t**>(&serTarget); const auto** serTargetConst = const_cast<const uint8_t**>(&serTarget);
result = headerDeser.parseData(); result = headerDeser.parseData();
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
CHECK(headerDeser.setData(nullptr, -1) != result::OK); CHECK(headerDeser.setData(nullptr, -1) != returnvalue::OK);
REQUIRE(headerDeser.getHeaderSize() == 14); REQUIRE(headerDeser.getHeaderSize() == 14);
headerDeser.setData(serBuf.data(), serBuf.size()); headerDeser.setData(serBuf.data(), serBuf.size());
@ -305,7 +305,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48);
result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(),
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
REQUIRE(result == result::OK); REQUIRE(result == returnvalue::OK);
REQUIRE(headerDeser.getWholePduSize() == 8); REQUIRE(headerDeser.getWholePduSize() == 8);
headerDeser.setData(serBuf.data(), serBuf.size()); headerDeser.setData(serBuf.data(), serBuf.size());

View File

@ -23,7 +23,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
serTarget = serBuf.data(); serTarget = serBuf.data();
serSize = 0; serSize = 0;
result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
// Only version bits are set // Only version bits are set
REQUIRE(serBuf[0] == 0b00100000); REQUIRE(serBuf[0] == 0b00100000);
// PDU data field length is 5 (4 + Directive code octet) // PDU data field length is 5 (4 + Directive code octet)
@ -42,7 +42,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
SECTION("Serialization fails") { SECTION("Serialization fails") {
REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_FAILED); returnvalue::FAILED);
} }
SECTION("Buffer Too Short") { SECTION("Buffer Too Short") {
@ -56,11 +56,11 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
SECTION("Deserialize") { SECTION("Deserialize") {
CHECK(fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) == CHECK(fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) ==
result::OK); returnvalue::OK);
serTarget = serBuf.data(); serTarget = serBuf.data();
REQUIRE(fdSer.deSerialize(&deserTarget, &serSize, SerializeIF::Endianness::NETWORK) == REQUIRE(fdSer.deSerialize(&deserTarget, &serSize, SerializeIF::Endianness::NETWORK) ==
HasReturnvaluesIF::RETURN_FAILED); returnvalue::FAILED);
deserTarget = serBuf.data(); deserTarget = serBuf.data();
CHECK(serSize == 8); CHECK(serSize == 8);
auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size());
@ -70,7 +70,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE);
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);
fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK);
REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); REQUIRE(fdDeser.parseData() == returnvalue::OK);
REQUIRE(not fdDeser.isNull()); REQUIRE(not fdDeser.isNull());
REQUIRE(fdDeser); REQUIRE(fdDeser);
REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK);

View File

@ -5,7 +5,7 @@
TEST_CASE("CFDP LV", "[cfdp][lv]") { TEST_CASE("CFDP LV", "[cfdp][lv]") {
using namespace cfdp; using namespace cfdp;
ReturnValue_t result = result::OK; ReturnValue_t result = returnvalue::OK;
std::array<uint8_t, 255> rawBuf{}; std::array<uint8_t, 255> rawBuf{};
uint8_t* serPtr = rawBuf.data(); uint8_t* serPtr = rawBuf.data();
const uint8_t* deserPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data();
@ -16,7 +16,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
std::array<uint8_t, 8> lvRawBuf{}; std::array<uint8_t, 8> lvRawBuf{};
serPtr = lvRawBuf.data(); serPtr = lvRawBuf.data();
REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK); SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(deserSize == 2); REQUIRE(deserSize == 2);
auto lv = cfdp::Lv(lvRawBuf.data(), 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2);
@ -31,12 +31,12 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
serPtr = rawBuf.data(); serPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
result::OK); returnvalue::OK);
REQUIRE(deserSize == 3); REQUIRE(deserSize == 3);
REQUIRE(rawBuf[0] == 2); REQUIRE(rawBuf[0] == 2);
uint16_t sourceIdRaw = 0; uint16_t sourceIdRaw = 0;
REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize, REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize,
SerializeIF::Endianness::BIG) == result::OK); SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(sourceIdRaw == 0x0ff0); REQUIRE(sourceIdRaw == 0x0ff0);
} }
@ -47,11 +47,11 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
deserSize = 0; deserSize = 0;
result = result =
lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(deserSize == 1); REQUIRE(deserSize == 1);
deserPtr = rawBuf.data(); deserPtr = rawBuf.data();
result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(lvEmpty.getSerializedSize() == 1); REQUIRE(lvEmpty.getSerializedSize() == 1);
} }
@ -59,29 +59,29 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
std::array<uint8_t, 8> lvRawBuf{}; std::array<uint8_t, 8> lvRawBuf{};
serPtr = lvRawBuf.data(); serPtr = lvRawBuf.data();
REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK); SerializeIF::Endianness::NETWORK) == returnvalue::OK);
auto lv = cfdp::Lv(lvRawBuf.data(), 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2);
serPtr = rawBuf.data(); serPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
Lv uninitLv; Lv uninitLv;
deserPtr = rawBuf.data(); deserPtr = rawBuf.data();
deserSize = 3; deserSize = 3;
result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(uninitLv.getSerializedSize() == 3); REQUIRE(uninitLv.getSerializedSize() == 3);
const uint8_t* storedValue = uninitLv.getValue(nullptr); const uint8_t* storedValue = uninitLv.getValue(nullptr);
uint16_t sourceIdRaw = 0; uint16_t sourceIdRaw = 0;
REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize, REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize,
SerializeIF::Endianness::BIG) == result::OK); SerializeIF::Endianness::BIG) == returnvalue::OK);
REQUIRE(sourceIdRaw == 0x0ff0); REQUIRE(sourceIdRaw == 0x0ff0);
} }
SECTION("Invalid Input") { SECTION("Invalid Input") {
Lv uninitLv; Lv uninitLv;
REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) ==
HasReturnvaluesIF::RETURN_FAILED); returnvalue::FAILED);
serPtr = rawBuf.data(); serPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) ==
@ -96,7 +96,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
std::string filename = "hello.txt"; std::string filename = "hello.txt";
StringLv sourceFileName(filename); StringLv sourceFileName(filename);
REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size()); REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size());
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK); REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK);
REQUIRE(rawBuf[0] == filename.size()); REQUIRE(rawBuf[0] == filename.size());
std::string filenameFromRaw(reinterpret_cast<const char*>(rawBuf.data() + 1), filename.size()); std::string filenameFromRaw(reinterpret_cast<const char*>(rawBuf.data() + 1), filename.size());
REQUIRE(filenameFromRaw == filename); REQUIRE(filenameFromRaw == filename);
@ -106,7 +106,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
const char filename[] = "hello.txt"; const char filename[] = "hello.txt";
StringLv sourceFileName(filename, sizeof(filename) - 1); StringLv sourceFileName(filename, sizeof(filename) - 1);
REQUIRE(sourceFileName.getSerializedSize() == 1 + sizeof(filename) - 1); REQUIRE(sourceFileName.getSerializedSize() == 1 + sizeof(filename) - 1);
REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK); REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK);
REQUIRE(rawBuf[0] == sizeof(filename) - 1); REQUIRE(rawBuf[0] == sizeof(filename) - 1);
rawBuf[deserSize] = '\0'; rawBuf[deserSize] = '\0';
const char* filenameFromRaw = reinterpret_cast<const char*>(rawBuf.data() + 1); const char* filenameFromRaw = reinterpret_cast<const char*>(rawBuf.data() + 1);

View File

@ -40,14 +40,14 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
std::array<uint8_t, 128> serBuf = {}; std::array<uint8_t, 128> serBuf = {};
result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(),
SerializeIF::Endianness::NETWORK); SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
cfdp::StringLv emptyMsg; cfdp::StringLv emptyMsg;
cfdp::StringLv emptySecondName; cfdp::StringLv emptySecondName;
FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); FilestoreResponseTlv emptyTlv(firstName, &emptyMsg);
emptyTlv.setSecondFileName(&emptySecondName); emptyTlv.setSecondFileName(&emptySecondName);
result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS); REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS);
size_t firstNameLen = 0; size_t firstNameLen = 0;
@ -81,26 +81,26 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
REQUIRE(expectedSz == 10 + 11 + 1); REQUIRE(expectedSz == 10 + 11 + 1);
REQUIRE(request.getSerializedSize() == expectedSz + 2); REQUIRE(request.getSerializedSize() == expectedSz + 2);
result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(sz == expectedSz + 2); REQUIRE(sz == expectedSz + 2);
FilestoreRequestTlv emptyRequest(firstName); FilestoreRequestTlv emptyRequest(firstName);
emptyRequest.setSecondFileName(&secondName); emptyRequest.setSecondFileName(&secondName);
const uint8_t* constptr = serBuf.data(); const uint8_t* constptr = serBuf.data();
result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK); result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
cfdp::Tlv rawRequest; cfdp::Tlv rawRequest;
ptr = serBuf.data(); ptr = serBuf.data();
sz = 0; sz = 0;
result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(),
SerializeIF::Endianness::NETWORK); SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE);
result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
} }
@ -117,11 +117,11 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(faultOverrideTlv.getSerializedSize() == 3); REQUIRE(faultOverrideTlv.getSerializedSize() == 3);
REQUIRE(sz == 3); REQUIRE(sz == 3);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
FaultHandlerOverrideTlv emptyOverrideTlv; FaultHandlerOverrideTlv emptyOverrideTlv;
result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK); result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42); EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42);
EntityId emptyId; EntityId emptyId;
@ -129,9 +129,9 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
serPtr = rawBuf.data(); serPtr = rawBuf.data();
result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
deserPtr = rawBuf.data(); deserPtr = rawBuf.data();
result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
} }
} }

View File

@ -14,25 +14,25 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
SECTION("Entity ID Serialization") { SECTION("Entity ID Serialization") {
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK); SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(deserSize == 2); REQUIRE(deserSize == 2);
} }
SECTION("TLV Serialization") { SECTION("TLV Serialization") {
std::array<uint8_t, 8> tlvBuf{}; std::array<uint8_t, 8> tlvBuf{};
REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == result::OK); REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == returnvalue::OK);
auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize); auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize);
REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getSerializedSize() == 4);
REQUIRE(tlv.getLengthField() == 2); REQUIRE(tlv.getLengthField() == 2);
deserSize = 0; deserSize = 0;
REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
result::OK); returnvalue::OK);
REQUIRE(deserSize == 4); REQUIRE(deserSize == 4);
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
REQUIRE(rawBuf[1] == 2); REQUIRE(rawBuf[1] == 2);
uint16_t entityId = 0; uint16_t entityId = 0;
REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize, REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize,
SerializeIF::Endianness::NETWORK) == result::OK); SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(entityId == 0x0ff0); REQUIRE(entityId == 0x0ff0);
} }
@ -41,30 +41,30 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
// Set new value // Set new value
sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12); sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12);
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == result::OK); SerializeIF::Endianness::NETWORK) == returnvalue::OK);
tlv.setValue(rawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES); tlv.setValue(rawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES);
serPtr = rawBuf.data(); serPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
REQUIRE(rawBuf[1] == 4); REQUIRE(rawBuf[1] == 4);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
} }
SECTION("TLV Invalid") { SECTION("TLV Invalid") {
auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0); auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); SerializeIF::Endianness::NETWORK) != returnvalue::OK);
tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); SerializeIF::Endianness::NETWORK) != returnvalue::OK);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK); returnvalue::OK);
REQUIRE(tlvInvalid.getSerializedSize() == 0); REQUIRE(tlvInvalid.getSerializedSize() == 0);
REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK); returnvalue::OK);
} }
SECTION("TLV Zero Length Field") { SECTION("TLV Zero Length Field") {
@ -73,8 +73,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
serPtr = rawBuf.data(); serPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == SerializeIF::Endianness::NETWORK) == returnvalue::OK);
HasReturnvaluesIF::RETURN_OK);
REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER);
REQUIRE(rawBuf[1] == 0); REQUIRE(rawBuf[1] == 0);
} }
@ -93,7 +92,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
Tlv tlv; Tlv tlv;
deserPtr = rawBuf.data(); deserPtr = rawBuf.data();
result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getSerializedSize() == 4);
REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID);
deserPtr = tlv.getValue(); deserPtr = tlv.getValue();
@ -103,8 +102,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
SerializeIF::Endianness::NETWORK); SerializeIF::Endianness::NETWORK);
REQUIRE(entityId == 0x0ff0); REQUIRE(entityId == 0x0ff0);
REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != returnvalue::OK);
HasReturnvaluesIF::RETURN_OK);
deserPtr = rawBuf.data(); deserPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) ==
@ -113,17 +111,16 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
rawBuf[0] = TlvTypes::INVALID_TLV; rawBuf[0] = TlvTypes::INVALID_TLV;
deserSize = 4; deserSize = 4;
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) !=
HasReturnvaluesIF::RETURN_OK); returnvalue::OK);
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
serPtr = rawBuf.data(); serPtr = rawBuf.data();
deserSize = 0; deserSize = 0;
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == SerializeIF::Endianness::NETWORK) == returnvalue::OK);
HasReturnvaluesIF::RETURN_OK);
deserPtr = rawBuf.data(); deserPtr = rawBuf.data();
result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == returnvalue::OK);
REQUIRE(zeroLenField.getSerializedSize() == 2); REQUIRE(zeroLenField.getSerializedSize() == 2);
REQUIRE(deserSize == 0); REQUIRE(deserSize == 0);
} }

View File

@ -10,7 +10,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") {
SECTION("Create File") { SECTION("Create File") {
FilesystemParams params("hello.txt"); FilesystemParams params("hello.txt");
CHECK(fsMock.createFile(params) == result::OK); CHECK(fsMock.createFile(params) == returnvalue::OK);
auto iter = fsMock.fileMap.find("hello.txt"); auto iter = fsMock.fileMap.find("hello.txt");
REQUIRE(iter != fsMock.fileMap.end()); REQUIRE(iter != fsMock.fileMap.end());
FilesystemMock::FileInfo &stats = iter->second; FilesystemMock::FileInfo &stats = iter->second;
@ -22,7 +22,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") {
std::string testData = "test data"; std::string testData = "test data";
FileOpParams params("hello.txt", testData.size()); FileOpParams params("hello.txt", testData.size());
CHECK(fsMock.writeToFile(params, reinterpret_cast<const uint8_t *>(testData.data())) == CHECK(fsMock.writeToFile(params, reinterpret_cast<const uint8_t *>(testData.data())) ==
HasReturnvaluesIF::RETURN_OK); returnvalue::OK);
auto iter = fsMock.fileMap.find("hello.txt"); auto iter = fsMock.fileMap.find("hello.txt");
REQUIRE(iter != fsMock.fileMap.end()); REQUIRE(iter != fsMock.fileMap.end());
FilesystemMock::FileInfo &stats = iter->second; FilesystemMock::FileInfo &stats = iter->second;
@ -38,7 +38,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") {
SECTION("Create Directory") { SECTION("Create Directory") {
FilesystemParams params("hello"); FilesystemParams params("hello");
CHECK(fsMock.createDirectory(params) == result::OK); CHECK(fsMock.createDirectory(params) == returnvalue::OK);
REQUIRE(not fsMock.dirMap.empty()); REQUIRE(not fsMock.dirMap.empty());
auto iter = fsMock.dirMap.find("hello"); auto iter = fsMock.dirMap.find("hello");
REQUIRE(iter != fsMock.dirMap.end()); REQUIRE(iter != fsMock.dirMap.end());

View File

@ -23,51 +23,51 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Create file") { SECTION("Create file") {
FilesystemParams params(file0.c_str()); FilesystemParams params(file0.c_str());
REQUIRE(hostFs.createFile(params) == result::OK); REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0)); CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0)); REQUIRE(fs::exists(file0));
} }
SECTION("Remove File") { SECTION("Remove File") {
FilesystemParams params(file0.c_str()); FilesystemParams params(file0.c_str());
REQUIRE(hostFs.createFile(params) == result::OK); REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0)); CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0)); REQUIRE(fs::exists(file0));
REQUIRE(hostFs.removeFile(file0.c_str()) == result::OK); REQUIRE(hostFs.removeFile(file0.c_str()) == returnvalue::OK);
REQUIRE(not fs::exists(file0)); REQUIRE(not fs::exists(file0));
} }
SECTION("Create Directory") { SECTION("Create Directory") {
FilesystemParams params(dir0.c_str()); FilesystemParams params(dir0.c_str());
REQUIRE(hostFs.createDirectory(params) == result::OK); REQUIRE(hostFs.createDirectory(params) == returnvalue::OK);
CHECK(fs::is_directory(dir0)); CHECK(fs::is_directory(dir0));
REQUIRE(fs::exists(dir0)); REQUIRE(fs::exists(dir0));
} }
SECTION("Remove Directory") { SECTION("Remove Directory") {
FilesystemParams params(dir0.c_str()); FilesystemParams params(dir0.c_str());
REQUIRE(hostFs.createDirectory(params) == result::OK); REQUIRE(hostFs.createDirectory(params) == returnvalue::OK);
REQUIRE(fs::exists(dir0)); REQUIRE(fs::exists(dir0));
REQUIRE(hostFs.removeDirectory(params) == result::OK); REQUIRE(hostFs.removeDirectory(params) == returnvalue::OK);
REQUIRE(not fs::exists(dir0)); REQUIRE(not fs::exists(dir0));
} }
SECTION("Rename File") { SECTION("Rename File") {
FilesystemParams params(file0.c_str()); FilesystemParams params(file0.c_str());
REQUIRE(hostFs.createFile(params) == result::OK); REQUIRE(hostFs.createFile(params) == returnvalue::OK);
CHECK(fs::is_regular_file(file0)); CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0)); REQUIRE(fs::exists(file0));
REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == result::OK); REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == returnvalue::OK);
} }
SECTION("Write To File") { SECTION("Write To File") {
std::string data = "hello world!"; std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size()); FileOpParams params(file0.c_str(), data.size());
REQUIRE(hostFs.createFile(params.fsParams) == result::OK); REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK);
CHECK(fs::is_regular_file(file0)); CHECK(fs::is_regular_file(file0));
REQUIRE(fs::exists(file0)); REQUIRE(fs::exists(file0));
CHECK(hostFs.writeToFile(params, reinterpret_cast<const uint8_t*>(data.c_str())) == CHECK(hostFs.writeToFile(params, reinterpret_cast<const uint8_t*>(data.c_str())) ==
HasReturnvaluesIF::RETURN_OK); returnvalue::OK);
CHECK(fs::file_size(file0) == data.size()); CHECK(fs::file_size(file0) == data.size());
ifstream ifile(file0); ifstream ifile(file0);
char readBuf[524]{}; char readBuf[524]{};
@ -79,7 +79,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Read From File") { SECTION("Read From File") {
std::string data = "hello world!"; std::string data = "hello world!";
FileOpParams params(file0.c_str(), data.size()); FileOpParams params(file0.c_str(), data.size());
REQUIRE(hostFs.createFile(params.fsParams) == result::OK); REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK);
CHECK(fs::is_regular_file(file0)); CHECK(fs::is_regular_file(file0));
ofstream of(file0); ofstream of(file0);
of.write(data.c_str(), static_cast<unsigned int>(data.size())); of.write(data.c_str(), static_cast<unsigned int>(data.size()));
@ -89,8 +89,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
std::array<uint8_t, 256> readBuf{}; std::array<uint8_t, 256> readBuf{};
uint8_t* readPtr = readBuf.data(); uint8_t* readPtr = readBuf.data();
size_t readSize = 0; size_t readSize = 0;
CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == returnvalue::OK);
HasReturnvaluesIF::RETURN_OK);
std::string readBackString(reinterpret_cast<const char*>(readBuf.data())); std::string readBackString(reinterpret_cast<const char*>(readBuf.data()));
CHECK(readSize == data.size()); CHECK(readSize == data.size());
CHECK(data == readBackString); CHECK(data == readBackString);
@ -98,20 +97,20 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Invalid Input does not crash") { SECTION("Invalid Input does not crash") {
FileOpParams params(nullptr, 10); FileOpParams params(nullptr, 10);
REQUIRE(hostFs.createFile(params.fsParams) != result::OK); REQUIRE(hostFs.createFile(params.fsParams) != returnvalue::OK);
REQUIRE(hostFs.createDirectory(params.fsParams) != result::OK); REQUIRE(hostFs.createDirectory(params.fsParams) != returnvalue::OK);
REQUIRE(hostFs.createFile(params.fsParams) != result::OK); REQUIRE(hostFs.createFile(params.fsParams) != returnvalue::OK);
REQUIRE(hostFs.removeDirectory(params.fsParams) != result::OK); REQUIRE(hostFs.removeDirectory(params.fsParams) != returnvalue::OK);
REQUIRE(hostFs.removeFile(nullptr) != result::OK); REQUIRE(hostFs.removeFile(nullptr) != returnvalue::OK);
REQUIRE(hostFs.rename(nullptr, nullptr) != result::OK); REQUIRE(hostFs.rename(nullptr, nullptr) != returnvalue::OK);
REQUIRE(hostFs.writeToFile(params, nullptr) != result::OK); REQUIRE(hostFs.writeToFile(params, nullptr) != returnvalue::OK);
size_t readLen = 0; size_t readLen = 0;
REQUIRE(hostFs.readFromFile(params, nullptr, readLen, 20) != result::OK); REQUIRE(hostFs.readFromFile(params, nullptr, readLen, 20) != returnvalue::OK);
} }
SECTION("Create File but already exists") { SECTION("Create File but already exists") {
FilesystemParams params(file0.c_str()); FilesystemParams params(file0.c_str());
REQUIRE(hostFs.createFile(params) == result::OK); REQUIRE(hostFs.createFile(params) == returnvalue::OK);
REQUIRE(hostFs.createFile(params) == HasFileSystemIF::FILE_ALREADY_EXISTS); REQUIRE(hostFs.createFile(params) == HasFileSystemIF::FILE_ALREADY_EXISTS);
} }
@ -121,7 +120,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
SECTION("Create Directory but already exists") { SECTION("Create Directory but already exists") {
FileOpParams params(file0.c_str(), 12); FileOpParams params(file0.c_str(), 12);
REQUIRE(hostFs.createDirectory(params.fsParams) == HasReturnvaluesIF::RETURN_OK); REQUIRE(hostFs.createDirectory(params.fsParams) == returnvalue::OK);
REQUIRE(hostFs.createDirectory(params.fsParams) == HasFileSystemIF::DIRECTORY_ALREADY_EXISTS); REQUIRE(hostFs.createDirectory(params.fsParams) == HasFileSystemIF::DIRECTORY_ALREADY_EXISTS);
} }
@ -158,7 +157,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
ofstream of(fileInDir0); ofstream of(fileInDir0);
CHECK(fs::is_directory(dir0)); CHECK(fs::is_directory(dir0));
CHECK(fs::is_regular_file(fileInDir0)); CHECK(fs::is_regular_file(fileInDir0));
REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str()), true) == result::OK); REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str()), true) == returnvalue::OK);
CHECK(not fs::is_directory(dir0)); CHECK(not fs::is_directory(dir0));
CHECK(not fs::is_regular_file(fileInDir0)); CHECK(not fs::is_regular_file(fileInDir0));
} }
@ -173,7 +172,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") {
} }
SECTION("Create directory with parent directory") { SECTION("Create directory with parent directory") {
CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.c_str()), true) == result::OK); CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.c_str()), true) == returnvalue::OK);
CHECK(fs::is_directory(dir0)); CHECK(fs::is_directory(dir0));
CHECK(fs::is_directory(dirWithParent)); CHECK(fs::is_directory(dirWithParent));
} }

View File

@ -7,7 +7,7 @@ class CcsdsCheckerMock : public CcsdsPacketCheckIF {
CcsdsCheckerMock(); CcsdsCheckerMock();
unsigned int checkCallCount = 0; unsigned int checkCallCount = 0;
size_t checkedPacketLen = 0; size_t checkedPacketLen = 0;
ReturnValue_t nextResult = HasReturnvaluesIF::RETURN_OK; ReturnValue_t nextResult = returnvalue::OK;
ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override; ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override;
private: private:

View File

@ -6,19 +6,19 @@
ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) { ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) {
if (not std::filesystem::exists(filename)) { if (not std::filesystem::exists(filename)) {
return HasReturnvaluesIF::RETURN_FAILED; return returnvalue::FAILED;
} }
size_t fileSize = std::filesystem::file_size(filename); size_t fileSize = std::filesystem::file_size(filename);
FileOpParams params(filename.c_str(), fileSize); FileOpParams params(filename.c_str(), fileSize);
std::vector<uint8_t> rawData(fileSize); std::vector<uint8_t> rawData(fileSize);
file.read(reinterpret_cast<char *>(rawData.data()), static_cast<unsigned int>(rawData.size())); file.read(reinterpret_cast<char *>(rawData.data()), static_cast<unsigned int>(rawData.size()));
createOrAddToFile(params, rawData.data()); createOrAddToFile(params, rawData.data());
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) {
createOrAddToFile(params, data); createOrAddToFile(params, data);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize,
@ -32,7 +32,7 @@ ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer
size_t readLen = params.size; size_t readLen = params.size;
if (params.offset + params.size > info.fileRaw.size()) { if (params.offset + params.size > info.fileRaw.size()) {
if (params.offset > info.fileRaw.size()) { if (params.offset > info.fileRaw.size()) {
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
readLen = info.fileRaw.size() - params.offset; readLen = info.fileRaw.size() - params.offset;
} }
@ -43,14 +43,14 @@ ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer
*buffer += readLen; *buffer += readLen;
readSize += readLen; readSize += readLen;
} }
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data, ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data,
size_t size) { size_t size) {
FileOpParams params2(params.path, size); FileOpParams params2(params.path, size);
createOrAddToFile(params2, data); createOrAddToFile(params2, data);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) { ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) {
@ -60,7 +60,7 @@ ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *arg
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
} else { } else {
fileMap.erase(iter); fileMap.erase(iter);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
} }
@ -68,20 +68,20 @@ ReturnValue_t FilesystemMock::createDirectory(FilesystemParams params, bool crea
std::string dirPath = params.path; std::string dirPath = params.path;
dirMap[dirPath].createCallCount++; dirMap[dirPath].createCallCount++;
dirMap[dirPath].wihParentDir.push(createParentDirs); dirMap[dirPath].wihParentDir.push(createParentDirs);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) { ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) {
std::string dirPath = params.path; std::string dirPath = params.path;
dirMap[dirPath].delCallCount++; dirMap[dirPath].delCallCount++;
dirMap[dirPath].recursiveDeletion.push(deleteRecurively); dirMap[dirPath].recursiveDeletion.push(deleteRecurively);
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath, ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath,
FileSystemArgsIF *args) { FileSystemArgsIF *args) {
renameQueue.push(RenameInfo(oldPath, newPath)); renameQueue.push(RenameInfo(oldPath, newPath));
return HasReturnvaluesIF::RETURN_OK; return returnvalue::OK;
} }
void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) { void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) {

View File

@ -67,13 +67,13 @@ StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const
void StorageManagerMock::reset() { void StorageManagerMock::reset() {
clearStore(); clearStore();
nextAddDataCallFails.first = false; nextAddDataCallFails.first = false;
nextAddDataCallFails.second = result::OK; nextAddDataCallFails.second = returnvalue::OK;
nextModifyDataCallFails.first = false; nextModifyDataCallFails.first = false;
nextModifyDataCallFails.second = result::OK; nextModifyDataCallFails.second = returnvalue::OK;
nextDeleteDataCallFails.first = false; nextDeleteDataCallFails.first = false;
nextDeleteDataCallFails.second = result::OK; nextDeleteDataCallFails.second = returnvalue::OK;
nextFreeElementCallFails.first = false; nextFreeElementCallFails.first = false;
nextFreeElementCallFails.second = result::OK; nextFreeElementCallFails.second = returnvalue::OK;
} }
StorageManagerMock::StorageManagerMock(object_id_t setObjectId, StorageManagerMock::StorageManagerMock(object_id_t setObjectId,

View File

@ -35,11 +35,12 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
spCreator.setCcsdsLenFromTotalDataFieldLen(dataFieldLen); spCreator.setCcsdsLenFromTotalDataFieldLen(dataFieldLen);
uint8_t* dataPtr; uint8_t* dataPtr;
REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize() + dataFieldLen, &dataPtr) == REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize() + dataFieldLen, &dataPtr) ==
result::OK); returnvalue::OK);
size_t serLen = 0; size_t serLen = 0;
REQUIRE(spCreator.SerializeIF::serializeBe(dataPtr, serLen, ccsds::HEADER_LEN) == result::OK); REQUIRE(spCreator.SerializeIF::serializeBe(dataPtr, serLen, ccsds::HEADER_LEN) ==
returnvalue::OK);
REQUIRE(spCreator.SerializeIF::serializeBe(buf.data(), serLen, ccsds::HEADER_LEN) == REQUIRE(spCreator.SerializeIF::serializeBe(buf.data(), serLen, ccsds::HEADER_LEN) ==
result::OK); returnvalue::OK);
if (dataField == nullptr) { if (dataField == nullptr) {
dataPtr[ccsds::HEADER_LEN] = 0; dataPtr[ccsds::HEADER_LEN] = 0;
buf[ccsds::HEADER_LEN] = 0; buf[ccsds::HEADER_LEN] = 0;
@ -51,7 +52,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
}; };
SECTION("State") { SECTION("State") {
CHECK(ccsdsDistrib.initialize() == result::OK); CHECK(ccsdsDistrib.initialize() == returnvalue::OK);
CHECK(ccsdsDistrib.getRequestQueue() == 1); CHECK(ccsdsDistrib.getRequestQueue() == 1);
CHECK(ccsdsDistrib.getIdentifier() == 0); CHECK(ccsdsDistrib.getIdentifier() == 0);
CHECK(ccsdsDistrib.getObjectId() == 1); CHECK(ccsdsDistrib.getObjectId() == 1);
@ -61,12 +62,12 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
SECTION("Basic Forwarding") { SECTION("Basic Forwarding") {
CcsdsDistributor::DestInfo info(tcAcceptorMock, false); CcsdsDistributor::DestInfo info(tcAcceptorMock, false);
REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK);
TmTcMessage message; TmTcMessage message;
createSpacePacket(tcAcceptorApid, message); createSpacePacket(tcAcceptorApid, message);
store_address_t storeId = message.getStorageId(); store_address_t storeId = message.getStorageId();
queue.addReceivedMessage(message); queue.addReceivedMessage(message);
REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK);
CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkedPacketLen == 7);
CHECK(checkerMock.checkCallCount == 1); CHECK(checkerMock.checkCallCount == 1);
CHECK(queue.wasMessageSent()); CHECK(queue.wasMessageSent());
@ -74,10 +75,10 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
// The packet is forwarded, with no need to delete the data // The packet is forwarded, with no need to delete the data
CHECK(pool.hasDataAtId(storeId)); CHECK(pool.hasDataAtId(storeId));
TmTcMessage sentMsg; TmTcMessage sentMsg;
CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == result::OK); CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == returnvalue::OK);
CHECK(sentMsg.getStorageId() == storeId); CHECK(sentMsg.getStorageId() == storeId);
auto accessor = pool.getData(storeId); auto accessor = pool.getData(storeId);
CHECK(accessor.first == result::OK); CHECK(accessor.first == returnvalue::OK);
CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1);
for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { for (size_t i = 0; i < ccsds::HEADER_LEN; i++) {
CHECK(accessor.second.data()[i] == buf[i]); CHECK(accessor.second.data()[i] == buf[i]);
@ -101,7 +102,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
store_address_t storeId = message.getStorageId(); store_address_t storeId = message.getStorageId();
message.setStorageId(storeId); message.setStorageId(storeId);
queue.addReceivedMessage(message); queue.addReceivedMessage(message);
REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK);
CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkedPacketLen == 7);
CHECK(checkerMock.checkCallCount == 1); CHECK(checkerMock.checkCallCount == 1);
CHECK(queue.wasMessageSent()); CHECK(queue.wasMessageSent());
@ -109,10 +110,10 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
// The packet is forwarded, with no need to delete the data // The packet is forwarded, with no need to delete the data
CHECK(pool.hasDataAtId(storeId)); CHECK(pool.hasDataAtId(storeId));
TmTcMessage sentMsg; TmTcMessage sentMsg;
CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == result::OK); CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == returnvalue::OK);
CHECK(sentMsg.getStorageId() == storeId); CHECK(sentMsg.getStorageId() == storeId);
auto accessor = pool.getData(storeId); auto accessor = pool.getData(storeId);
CHECK(accessor.first == result::OK); CHECK(accessor.first == returnvalue::OK);
CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1);
for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { for (size_t i = 0; i < ccsds::HEADER_LEN; i++) {
CHECK(accessor.second.data()[i] == buf[i]); CHECK(accessor.second.data()[i] == buf[i]);
@ -126,13 +127,13 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
CcsdsDistributor::DestInfo info(defReceiverMock, true); CcsdsDistributor::DestInfo info(defReceiverMock, true);
tgtApid = defaultApid; tgtApid = defaultApid;
tgtQueueId = defaultQueueId; tgtQueueId = defaultQueueId;
REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK);
} }
SECTION("Specific destination") { SECTION("Specific destination") {
CcsdsDistributor::DestInfo info(tcAcceptorMock, true); CcsdsDistributor::DestInfo info(tcAcceptorMock, true);
tgtApid = tcAcceptorApid; tgtApid = tcAcceptorApid;
tgtQueueId = tcAcceptorQueueId; tgtQueueId = tcAcceptorQueueId;
REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK);
} }
TmTcMessage message; TmTcMessage message;
std::array<uint8_t, 5> dataField = {0, 1, 2, 3, 4}; std::array<uint8_t, 5> dataField = {0, 1, 2, 3, 4};
@ -140,16 +141,16 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") {
store_address_t storeId = message.getStorageId(); store_address_t storeId = message.getStorageId();
message.setStorageId(storeId); message.setStorageId(storeId);
queue.addReceivedMessage(message); queue.addReceivedMessage(message);
REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK);
CHECK(checkerMock.checkedPacketLen == 11); CHECK(checkerMock.checkedPacketLen == 11);
CHECK(checkerMock.checkCallCount == 1); CHECK(checkerMock.checkCallCount == 1);
// Data was deleted from old slot to re-store without the header // Data was deleted from old slot to re-store without the header
CHECK(not pool.hasDataAtId(storeId)); CHECK(not pool.hasDataAtId(storeId));
TmTcMessage sentMsg; TmTcMessage sentMsg;
CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == result::OK); CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == returnvalue::OK);
CHECK(sentMsg.getStorageId() != storeId); CHECK(sentMsg.getStorageId() != storeId);
auto accessor = pool.getData(sentMsg.getStorageId()); auto accessor = pool.getData(sentMsg.getStorageId());
CHECK(accessor.first == result::OK); CHECK(accessor.first == returnvalue::OK);
CHECK(accessor.second.size() == 5); CHECK(accessor.second.size() == 5);
// Verify correctness of data field // Verify correctness of data field
for (size_t i = 0; i < 5; i++) { for (size_t i = 0; i < 5; i++) {