From d12c59c8acd9f7a59dfdfea04dbfe76dcae41836 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 16:35:53 +0200 Subject: [PATCH] all retval replacements --- src/fsfw/cfdp/CfdpDistributor.cpp | 12 ++--- src/fsfw/cfdp/CfdpDistributor.h | 6 +-- src/fsfw/cfdp/CfdpHandler.h | 1 - src/fsfw/cfdp/handler/DestHandler.cpp | 12 ++--- src/fsfw/cfdp/pdu/AckPduDeserializer.cpp | 1 + src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp | 6 +-- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 4 +- src/fsfw/cfdp/pdu/HeaderCreator.cpp | 12 ++--- src/fsfw/cfdp/pdu/HeaderReader.cpp | 8 +-- src/fsfw/filesystem/HasFileSystemIF.h | 2 +- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 20 ++++---- src/fsfw/tcdistribution/PusDistributor.cpp | 4 +- src/fsfw/tcdistribution/TcDistributorBase.cpp | 10 ++-- src/fsfw/tcdistribution/definitions.h | 2 +- src/fsfw_hal/host/HostFilesystem.cpp | 32 ++++++------ unittests/cfdp/handler/testDistributor.cpp | 32 ++++++------ unittests/cfdp/pdu/testCfdpHeader.cpp | 36 +++++++------- unittests/cfdp/pdu/testFileDirective.cpp | 10 ++-- unittests/cfdp/testLvs.cpp | 26 +++++----- unittests/cfdp/testOtherTlvs.cpp | 20 ++++---- unittests/cfdp/testTlv.cpp | 37 +++++++------- unittests/hal/testFsMock.cpp | 6 +-- unittests/hal/testHostFilesystem.cpp | 49 +++++++++---------- unittests/mocks/CcsdsCheckerMock.h | 2 +- unittests/mocks/FilesystemMock.cpp | 20 ++++---- unittests/mocks/StorageManagerMock.cpp | 8 +-- .../tcdistributor/testCcsdsDistributor.cpp | 33 +++++++------ 27 files changed, 204 insertions(+), 207 deletions(-) diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index e2377024..d0237959 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -9,24 +9,24 @@ ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& addre AcceptsTelecommandsIF& tcDest) { for (const auto& dest : tcDestinations) { if (dest.id == address) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId()); - if (accessorPair.first != HasReturnvaluesIF::RETURN_OK) { + if (accessorPair.first != returnvalue::OK) { return accessorPair.first; } ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduReader.parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } cfdp::EntityId foundId; @@ -44,7 +44,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { } // Packet was forwarded successfully, so do not delete it. accessorPair.second.release(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const char* CfdpDistributor::getName() const { return "CFDP Distributor"; } diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h index 64c5ca9f..39ce0d27 100644 --- a/src/fsfw/cfdp/CfdpDistributor.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -5,7 +5,7 @@ #include #include "fsfw/cfdp/pdu/HeaderReader.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tcdistribution/CfdpPacketChecker.h" #include "fsfw/tcdistribution/TcDistributorBase.h" #include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" @@ -61,8 +61,8 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { MessageQueueId_t queueId; }; HeaderReader pduReader; - ReturnValue_t lastTcError = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t lastTmError = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t lastTcError = returnvalue::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 // it is okay to accept the overhead here std::vector tcDestinations; diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index c81a6cf7..8c2827ec 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -61,4 +61,3 @@ //}; // //#endif /* FSFW_CFDP_CFDPHANDLER_H_ */ - diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index f04a4b12..85ef03f4 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -23,30 +23,30 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { case TransactionStep::SENDING_FINISHED_PDU: break; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { if (p.packetListRef.full()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } p.packetListRef.push_back(packet); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t cfdp::DestHandler::initialize() { if (p.tmStore == nullptr) { p.tmStore = ObjectManager::instance()->get(objects::TM_STORE); if (p.tmStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } if (p.tcStore == nullptr) { p.tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (p.tcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp index 7e92ef9a..f09db97e 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp @@ -6,6 +6,7 @@ AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Ac ReturnValue_t AckPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { + return result; } size_t currentIdx = FileDirectiveReader::getHeaderSize(); if (currentIdx + 2 > this->maxSize) { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp index 169c2d5f..86c1ad92 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp @@ -12,13 +12,13 @@ size_t FileDirectiveCreator::getSerializedSize() const { ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (FileDirectiveCreator::getWholePduSize() > maxSize) { return BUFFER_TOO_SHORT; } ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -28,7 +28,7 @@ ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, si **buffer = directiveCode; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index bc06a9d7..4099efd9 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -7,7 +7,7 @@ cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return file ReturnValue_t FileDirectiveReader::parseData() { ReturnValue_t result = HeaderReader::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (this->getPduDataFieldLen() < 1) { @@ -21,7 +21,7 @@ ReturnValue_t FileDirectiveReader::parseData() { return cfdp::INVALID_DIRECTIVE_FIELDS; } setFileDirective(static_cast(pointers.rawPtr[currentIdx])); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FileDirectiveReader::getHeaderSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp index 1a7afe0d..e64f8481 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.cpp +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -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, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < this->getSerializedSize()) { return BUFFER_TOO_SHORT; @@ -29,19 +29,19 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma *buffer += 1; *size += 4; ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } 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, Endianness streamEndianness) { // We could implement this, but I prefer dedicated classes - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t HeaderCreator::getWholePduSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index 1fd40b78..f220ccd3 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -8,7 +8,7 @@ HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduB ReturnValue_t HeaderReader::parseData() { if (pointers.rawPtr == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < 7) { return SerializeIF::STREAM_TOO_SHORT; @@ -20,19 +20,19 @@ ReturnValue_t HeaderReader::parseData() { cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { if (dataPtr == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize_ < 7) { return SerializeIF::STREAM_TOO_SHORT; } pointers.rawPtr = dataPtr; maxSize = maxSize_; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderReader::getHeaderSize() const { diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 078de7c0..e7e2a529 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -7,7 +7,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" struct FilesystemParams { explicit FilesystemParams(const char* path) : path(path) {} diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index a2080ea8..4668a3bc 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -36,7 +36,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { #endif auto accessorPair = tcStore->getData(currentMessage.getStorageId()); ReturnValue_t result = accessorPair.first; - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 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()); result = packetChecker->checkPacket(currentPacket, accessorPair.second.size()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { handlePacketCheckFailure(result); return result; } @@ -90,7 +90,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { return handleCcsdsHeaderRemoval(accessorPair.second); } accessorPair.second.release(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { @@ -116,10 +116,10 @@ void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { MessageQueueId_t CcsdsDistributor::getRequestQueue() const { return tcQueue->getId(); } ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) { - ReturnValue_t returnValue = RETURN_OK; + ReturnValue_t returnValue = returnvalue::OK; auto insertPair = receiverMap.emplace(info.apid, info); if (not insertPair.second) { - returnValue = RETURN_FAILED; + returnValue = returnvalue::FAILED; } return returnValue; } @@ -128,7 +128,7 @@ uint32_t CcsdsDistributor::getIdentifier() const { return 0; } ReturnValue_t CcsdsDistributor::initialize() { ReturnValue_t result = TcDistributorBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (packetChecker == nullptr) { @@ -156,10 +156,10 @@ ReturnValue_t CcsdsDistributor::initialize() { } ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) { - if (queueStatus != RETURN_OK) { + if (queueStatus != returnvalue::OK) { tcStore->deleteData(currentMessage.getStorageId()); } - return RETURN_OK; + return returnvalue::OK; } void CcsdsDistributor::print() { @@ -180,7 +180,7 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a store_address_t newStoreId; ReturnValue_t result = tcStore->addData(&newStoreId, accessor.data() + ccsds::HEADER_LEN, accessor.size() - ccsds::HEADER_LEN); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << __func__ << ": TC store full" << std::endl; #else @@ -190,5 +190,5 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a } currentMessage.setStorageId(newStoreId); // The const accessor will delete the old data automatically - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 352e32ff..7599114b 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -27,8 +27,8 @@ ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) { // TODO: Need to set the data const uint8_t* packetPtr = nullptr; size_t packetLen = 0; - ReturnValue_t result = store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != - returnvalue::OK; + ReturnValue_t result = + store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK; if (result != returnvalue::OK) { tcStatus = PACKET_LOST; return result; diff --git a/src/fsfw/tcdistribution/TcDistributorBase.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp index 230c97fb..f87993f8 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -20,11 +20,11 @@ TcDistributorBase::~TcDistributorBase() { ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t status; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; + ReturnValue_t result = returnvalue::OK; + for (status = tcQueue->receiveMessage(¤tMessage); status == returnvalue::OK; status = tcQueue->receiveMessage(¤tMessage)) { ReturnValue_t packetResult = handlePacket(); - if (packetResult != HasReturnvaluesIF::RETURN_OK) { + if (packetResult != returnvalue::OK) { result = packetResult; triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, 1); } @@ -38,12 +38,12 @@ ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t TcDistributorBase::handlePacket() { MessageQueueId_t destId; ReturnValue_t result = selectDestination(destId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return callbackAfterSending(tcQueue->sendMessage(destId, ¤tMessage)); } ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) { - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index d28f9d40..01fc3085 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -10,7 +10,7 @@ namespace tmtcdistrib { 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_APID = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3); diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 7ebe5df8..20678a8c 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -12,7 +12,7 @@ HostFilesystem::HostFilesystem() = default; ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) { if (params.path() == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(params.path()); if (not exists(path)) { @@ -24,13 +24,13 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da } file.seekp(static_cast(params.offset)); file.write(reinterpret_cast(data), static_cast(params.size)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) { if (params.path() == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(params.path()); if (not exists(path)) { @@ -48,13 +48,13 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer file.read(reinterpret_cast(*buffer), sizeToRead); readSize += sizeToRead; *buffer += sizeToRead; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t *data, size_t size) { if (params.path == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(params.path); if (exists(path)) { @@ -64,26 +64,26 @@ ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t if (file.fail()) { return HasFileSystemIF::GENERIC_FILE_ERROR; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *args) { if (path_ == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(path_); if (not exists(path)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } if (remove(path, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return HasFileSystemIF::GENERIC_FILE_ERROR; } ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) { if (params.path == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path dirPath(params.path); @@ -93,19 +93,19 @@ ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool crea if (createParentDirs) { if (create_directories(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return HasFileSystemIF::GENERIC_DIR_ERROR; } if (create_directory(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return HasFileSystemIF::GENERIC_DIR_ERROR; } ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) { if (params.path == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path dirPath(params.path); if (not exists(dirPath)) { @@ -116,11 +116,11 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele } if (deleteRecurively) { if (remove_all(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } else { if (remove(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } // Error handling @@ -133,7 +133,7 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, FileSystemArgsIF *args) { if (oldPath_ == nullptr or newPath_ == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path oldPath(oldPath_); path newPath(newPath_); @@ -142,5 +142,5 @@ ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, if (errorCode) { return HasFileSystemIF::GENERIC_RENAME_ERROR; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/unittests/cfdp/handler/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp index 161e21cc..368ca9c0 100644 --- a/unittests/cfdp/handler/testDistributor.cpp +++ b/unittests/cfdp/handler/testDistributor.cpp @@ -36,41 +36,41 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { uint8_t* dataPtr = nullptr; SECTION("State") { - CHECK(distributor.initialize() == result::OK); + CHECK(distributor.initialize() == returnvalue::OK); CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0); CHECK(distributor.getIdentifier() == 0); CHECK(distributor.getRequestQueue() == queue.getId()); } SECTION("Packet Forwarding") { - CHECK(distributor.initialize() == result::OK); - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); + CHECK(distributor.initialize() == returnvalue::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK); size_t serLen = 0; store_address_t storeId; CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == - result::OK); + returnvalue::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == - result::OK); + returnvalue::OK); TmTcMessage msg(storeId); queue.addReceivedMessage(msg); - CHECK(distributor.performOperation(0) == result::OK); + CHECK(distributor.performOperation(0) == returnvalue::OK); CHECK(queue.wasMessageSent()); CHECK(queue.numberOfSentMessages() == 1); // The packet is forwarded, with no need to delete the data CHECK(pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() == storeId); } SECTION("No Destination found") { - CHECK(distributor.initialize() == result::OK); + CHECK(distributor.initialize() == returnvalue::OK); size_t serLen = 0; store_address_t storeId; CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == - result::OK); + returnvalue::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == - result::OK); + returnvalue::OK); TmTcMessage msg(storeId); queue.addReceivedMessage(msg); 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; size_t serLen = 0; 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) == - result::OK); + returnvalue::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == - result::OK); + returnvalue::OK); TmTcMessage msg(storeId); queue.addReceivedMessage(msg); CHECK(distributor.performOperation(0) == StorageManagerIF::DATA_DOES_NOT_EXIST); } SECTION("Duplicate registration") { - CHECK(distributor.initialize() == result::OK); - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::FAILED); + CHECK(distributor.initialize() == returnvalue::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::FAILED); } } \ No newline at end of file diff --git a/unittests/cfdp/pdu/testCfdpHeader.cpp b/unittests/cfdp/pdu/testCfdpHeader.cpp index a01325fa..99a0c470 100644 --- a/unittests/cfdp/pdu/testCfdpHeader.cpp +++ b/unittests/cfdp/pdu/testCfdpHeader.cpp @@ -3,7 +3,7 @@ #include "fsfw/cfdp/pdu/HeaderCreator.h" #include "fsfw/cfdp/pdu/HeaderReader.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" TEST_CASE("CFDP Header", "[cfdp]") { using namespace cfdp; @@ -49,12 +49,12 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Deserialization fails") { const uint8_t** dummyPtr = nullptr; REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) == - result::FAILED); + returnvalue::FAILED); } SECTION("Serialization fails") { REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(), - SerializeIF::Endianness::NETWORK) == result::FAILED); + SerializeIF::Endianness::NETWORK) == returnvalue::FAILED); } SECTION("Buffer Too Short") { @@ -93,7 +93,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Regular") { // Everything except version bit flipped to one now REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); CHECK(serBuf[0] == 0x3f); CHECK(serBuf[3] == 0x99); REQUIRE(headerSerializer.getCrcFlag() == true); @@ -114,7 +114,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(pduConf.sourceId.getSerializedSize() == 4); REQUIRE(headerSerializer.getSerializedSize() == 14); REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(headerSerializer.getCrcFlag() == true); REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); REQUIRE(headerSerializer.getLargeFileFlag() == true); @@ -157,17 +157,17 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Invalid Variable Sized Fields") { 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); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); } SECTION("Header Serialization") { result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serSize == 7); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); @@ -216,7 +216,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Header Deserialization") { REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // 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()); ReturnValue_t serResult = headerDeser.parseData(); - REQUIRE(serResult == result::OK); + REQUIRE(serResult == returnvalue::OK); REQUIRE(headerDeser.getPduDataFieldLen() == 0); REQUIRE(headerDeser.getHeaderSize() == 7); REQUIRE(headerDeser.getWholePduSize() == 7); @@ -249,11 +249,11 @@ TEST_CASE("CFDP Header", "[cfdp]") { headerSerializer.setPduType(cfdp::PduType::FILE_DATA); headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); 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); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); serTarget = serBuf.data(); serSize = 0; result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), @@ -261,7 +261,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { headerDeser = HeaderReader(serBuf.data(), serBuf.size()); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Everything except version bit flipped to one now REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[3] == 0b11001010); @@ -293,9 +293,9 @@ TEST_CASE("CFDP Header", "[cfdp]") { serTarget = serBuf.data(); const auto** serTargetConst = const_cast(&serTarget); 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); headerDeser.setData(serBuf.data(), serBuf.size()); @@ -305,7 +305,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(headerDeser.getWholePduSize() == 8); headerDeser.setData(serBuf.data(), serBuf.size()); diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index 3dfaaa57..3af8b966 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -23,7 +23,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { serTarget = serBuf.data(); serSize = 0; result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); // PDU data field length is 5 (4 + Directive code octet) @@ -42,7 +42,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { SECTION("Serialization fails") { REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); } SECTION("Buffer Too Short") { @@ -56,11 +56,11 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { SECTION("Deserialize") { CHECK(fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) == - result::OK); + returnvalue::OK); serTarget = serBuf.data(); REQUIRE(fdSer.deSerialize(&deserTarget, &serSize, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); deserTarget = serBuf.data(); CHECK(serSize == 8); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); @@ -70,7 +70,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); - REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(fdDeser.parseData() == returnvalue::OK); REQUIRE(not fdDeser.isNull()); REQUIRE(fdDeser); REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index 2adc84b8..062281e5 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -5,7 +5,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { using namespace cfdp; - ReturnValue_t result = result::OK; + ReturnValue_t result = returnvalue::OK; std::array rawBuf{}; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); @@ -16,7 +16,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { std::array lvRawBuf{}; serPtr = lvRawBuf.data(); REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(deserSize == 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2); @@ -31,12 +31,12 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { serPtr = rawBuf.data(); deserSize = 0; REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == - result::OK); + returnvalue::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); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(sourceIdRaw == 0x0ff0); } @@ -47,11 +47,11 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { deserSize = 0; result = lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 1); deserPtr = rawBuf.data(); result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(lvEmpty.getSerializedSize() == 1); } @@ -59,29 +59,29 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { std::array lvRawBuf{}; serPtr = lvRawBuf.data(); REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::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); + REQUIRE(result == returnvalue::OK); Lv uninitLv; deserPtr = rawBuf.data(); deserSize = 3; result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::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); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(sourceIdRaw == 0x0ff0); } SECTION("Invalid Input") { Lv uninitLv; REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == @@ -96,7 +96,7 @@ TEST_CASE("CFDP LV", "[cfdp][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(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK); REQUIRE(rawBuf[0] == filename.size()); std::string filenameFromRaw(reinterpret_cast(rawBuf.data() + 1), filename.size()); REQUIRE(filenameFromRaw == filename); @@ -106,7 +106,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { const char filename[] = "hello.txt"; StringLv sourceFileName(filename, 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); rawBuf[deserSize] = '\0'; const char* filenameFromRaw = reinterpret_cast(rawBuf.data() + 1); diff --git a/unittests/cfdp/testOtherTlvs.cpp b/unittests/cfdp/testOtherTlvs.cpp index 6393c230..4eb51a7c 100644 --- a/unittests/cfdp/testOtherTlvs.cpp +++ b/unittests/cfdp/testOtherTlvs.cpp @@ -40,14 +40,14 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { std::array serBuf = {}; result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); cfdp::StringLv emptyMsg; cfdp::StringLv emptySecondName; FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); emptyTlv.setSecondFileName(&emptySecondName); 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.getStatusCode() == cfdp::FSR_SUCCESS); size_t firstNameLen = 0; @@ -81,26 +81,26 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { 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(result == returnvalue::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); + REQUIRE(result == returnvalue::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(result == returnvalue::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(result == returnvalue::OK); REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); 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); REQUIRE(faultOverrideTlv.getSerializedSize() == 3); REQUIRE(sz == 3); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FaultHandlerOverrideTlv emptyOverrideTlv; 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 emptyId; @@ -129,9 +129,9 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { 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); + REQUIRE(result == returnvalue::OK); deserPtr = rawBuf.data(); result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } } diff --git a/unittests/cfdp/testTlv.cpp b/unittests/cfdp/testTlv.cpp index 5b6e0a63..3e7435cd 100644 --- a/unittests/cfdp/testTlv.cpp +++ b/unittests/cfdp/testTlv.cpp @@ -14,25 +14,25 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { SECTION("Entity ID Serialization") { REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(deserSize == 2); } SECTION("TLV Serialization") { std::array 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); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getLengthField() == 2); deserSize = 0; REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == - result::OK); + returnvalue::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); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(entityId == 0x0ff0); } @@ -41,30 +41,30 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { // Set new value sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12); 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); serPtr = rawBuf.data(); deserSize = 0; 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[1] == 4); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::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); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); 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) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); REQUIRE(tlvInvalid.getSerializedSize() == 0); REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("TLV Zero Length Field") { @@ -73,8 +73,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); REQUIRE(rawBuf[1] == 0); } @@ -93,7 +92,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { Tlv tlv; deserPtr = rawBuf.data(); result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); deserPtr = tlv.getValue(); @@ -103,8 +102,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { SerializeIF::Endianness::NETWORK); REQUIRE(entityId == 0x0ff0); - REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != returnvalue::OK); deserPtr = rawBuf.data(); deserSize = 0; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == @@ -113,17 +111,16 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { rawBuf[0] = TlvTypes::INVALID_TLV; deserSize = 4; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::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); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); deserPtr = rawBuf.data(); result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(zeroLenField.getSerializedSize() == 2); REQUIRE(deserSize == 0); } diff --git a/unittests/hal/testFsMock.cpp b/unittests/hal/testFsMock.cpp index 7040e734..2ebcd231 100644 --- a/unittests/hal/testFsMock.cpp +++ b/unittests/hal/testFsMock.cpp @@ -10,7 +10,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") { SECTION("Create File") { FilesystemParams params("hello.txt"); - CHECK(fsMock.createFile(params) == result::OK); + CHECK(fsMock.createFile(params) == returnvalue::OK); auto iter = fsMock.fileMap.find("hello.txt"); REQUIRE(iter != fsMock.fileMap.end()); FilesystemMock::FileInfo &stats = iter->second; @@ -22,7 +22,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") { std::string testData = "test data"; FileOpParams params("hello.txt", testData.size()); CHECK(fsMock.writeToFile(params, reinterpret_cast(testData.data())) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); auto iter = fsMock.fileMap.find("hello.txt"); REQUIRE(iter != fsMock.fileMap.end()); FilesystemMock::FileInfo &stats = iter->second; @@ -38,7 +38,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") { SECTION("Create Directory") { FilesystemParams params("hello"); - CHECK(fsMock.createDirectory(params) == result::OK); + CHECK(fsMock.createDirectory(params) == returnvalue::OK); REQUIRE(not fsMock.dirMap.empty()); auto iter = fsMock.dirMap.find("hello"); REQUIRE(iter != fsMock.dirMap.end()); diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index 2da185da..3873d5e9 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -23,51 +23,51 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Create file") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); } SECTION("Remove File") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); CHECK(fs::is_regular_file(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)); } SECTION("Create Directory") { FilesystemParams params(dir0.c_str()); - REQUIRE(hostFs.createDirectory(params) == result::OK); + REQUIRE(hostFs.createDirectory(params) == returnvalue::OK); CHECK(fs::is_directory(dir0)); REQUIRE(fs::exists(dir0)); } SECTION("Remove Directory") { FilesystemParams params(dir0.c_str()); - REQUIRE(hostFs.createDirectory(params) == result::OK); + REQUIRE(hostFs.createDirectory(params) == returnvalue::OK); REQUIRE(fs::exists(dir0)); - REQUIRE(hostFs.removeDirectory(params) == result::OK); + REQUIRE(hostFs.removeDirectory(params) == returnvalue::OK); REQUIRE(not fs::exists(dir0)); } SECTION("Rename File") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); CHECK(fs::is_regular_file(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") { std::string data = "hello world!"; 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)); REQUIRE(fs::exists(file0)); CHECK(hostFs.writeToFile(params, reinterpret_cast(data.c_str())) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(fs::file_size(file0) == data.size()); ifstream ifile(file0); char readBuf[524]{}; @@ -79,7 +79,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Read From File") { std::string data = "hello world!"; 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)); ofstream of(file0); of.write(data.c_str(), static_cast(data.size())); @@ -89,8 +89,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { std::array readBuf{}; uint8_t* readPtr = readBuf.data(); size_t readSize = 0; - CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == - HasReturnvaluesIF::RETURN_OK); + CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == returnvalue::OK); std::string readBackString(reinterpret_cast(readBuf.data())); CHECK(readSize == data.size()); CHECK(data == readBackString); @@ -98,20 +97,20 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Invalid Input does not crash") { FileOpParams params(nullptr, 10); - REQUIRE(hostFs.createFile(params.fsParams) != result::OK); - REQUIRE(hostFs.createDirectory(params.fsParams) != result::OK); - REQUIRE(hostFs.createFile(params.fsParams) != result::OK); - REQUIRE(hostFs.removeDirectory(params.fsParams) != result::OK); - REQUIRE(hostFs.removeFile(nullptr) != result::OK); - REQUIRE(hostFs.rename(nullptr, nullptr) != result::OK); - REQUIRE(hostFs.writeToFile(params, nullptr) != result::OK); + REQUIRE(hostFs.createFile(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.createDirectory(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.createFile(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.removeDirectory(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.removeFile(nullptr) != returnvalue::OK); + REQUIRE(hostFs.rename(nullptr, nullptr) != returnvalue::OK); + REQUIRE(hostFs.writeToFile(params, nullptr) != returnvalue::OK); 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") { 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); } @@ -121,7 +120,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Create Directory but already exists") { 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); } @@ -158,7 +157,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { ofstream of(fileInDir0); CHECK(fs::is_directory(dir0)); 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_regular_file(fileInDir0)); } @@ -173,7 +172,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { } 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(dirWithParent)); } diff --git a/unittests/mocks/CcsdsCheckerMock.h b/unittests/mocks/CcsdsCheckerMock.h index a9388ae5..bdcd491a 100644 --- a/unittests/mocks/CcsdsCheckerMock.h +++ b/unittests/mocks/CcsdsCheckerMock.h @@ -7,7 +7,7 @@ class CcsdsCheckerMock : public CcsdsPacketCheckIF { CcsdsCheckerMock(); unsigned int checkCallCount = 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; private: diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index 8f9e3f8f..3d18e3cb 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -6,19 +6,19 @@ ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) { if (not std::filesystem::exists(filename)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t fileSize = std::filesystem::file_size(filename); FileOpParams params(filename.c_str(), fileSize); std::vector rawData(fileSize); file.read(reinterpret_cast(rawData.data()), static_cast(rawData.size())); createOrAddToFile(params, rawData.data()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { createOrAddToFile(params, data); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } 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; if (params.offset + params.size > info.fileRaw.size()) { if (params.offset > info.fileRaw.size()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } readLen = info.fileRaw.size() - params.offset; } @@ -43,14 +43,14 @@ ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer *buffer += readLen; readSize += readLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data, size_t size) { FileOpParams params2(params.path, size); createOrAddToFile(params2, data); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } 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; } else { 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; dirMap[dirPath].createCallCount++; dirMap[dirPath].wihParentDir.push(createParentDirs); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) { std::string dirPath = params.path; dirMap[dirPath].delCallCount++; dirMap[dirPath].recursiveDeletion.push(deleteRecurively); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath, FileSystemArgsIF *args) { renameQueue.push(RenameInfo(oldPath, newPath)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) { diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp index 387b5b17..5cd3a575 100644 --- a/unittests/mocks/StorageManagerMock.cpp +++ b/unittests/mocks/StorageManagerMock.cpp @@ -67,13 +67,13 @@ StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const void StorageManagerMock::reset() { clearStore(); nextAddDataCallFails.first = false; - nextAddDataCallFails.second = result::OK; + nextAddDataCallFails.second = returnvalue::OK; nextModifyDataCallFails.first = false; - nextModifyDataCallFails.second = result::OK; + nextModifyDataCallFails.second = returnvalue::OK; nextDeleteDataCallFails.first = false; - nextDeleteDataCallFails.second = result::OK; + nextDeleteDataCallFails.second = returnvalue::OK; nextFreeElementCallFails.first = false; - nextFreeElementCallFails.second = result::OK; + nextFreeElementCallFails.second = returnvalue::OK; } StorageManagerMock::StorageManagerMock(object_id_t setObjectId, diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp index ce96a425..c8aa81f7 100644 --- a/unittests/tcdistributor/testCcsdsDistributor.cpp +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -35,11 +35,12 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { spCreator.setCcsdsLenFromTotalDataFieldLen(dataFieldLen); uint8_t* dataPtr; REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize() + dataFieldLen, &dataPtr) == - result::OK); + returnvalue::OK); 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) == - result::OK); + returnvalue::OK); if (dataField == nullptr) { dataPtr[ccsds::HEADER_LEN] = 0; buf[ccsds::HEADER_LEN] = 0; @@ -51,7 +52,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { }; SECTION("State") { - CHECK(ccsdsDistrib.initialize() == result::OK); + CHECK(ccsdsDistrib.initialize() == returnvalue::OK); CHECK(ccsdsDistrib.getRequestQueue() == 1); CHECK(ccsdsDistrib.getIdentifier() == 0); CHECK(ccsdsDistrib.getObjectId() == 1); @@ -61,12 +62,12 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { SECTION("Basic Forwarding") { CcsdsDistributor::DestInfo info(tcAcceptorMock, false); - REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK); TmTcMessage message; createSpacePacket(tcAcceptorApid, message); store_address_t storeId = message.getStorageId(); queue.addReceivedMessage(message); - REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK); CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkCallCount == 1); CHECK(queue.wasMessageSent()); @@ -74,10 +75,10 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { // The packet is forwarded, with no need to delete the data CHECK(pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() == storeId); auto accessor = pool.getData(storeId); - CHECK(accessor.first == result::OK); + CHECK(accessor.first == returnvalue::OK); CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { CHECK(accessor.second.data()[i] == buf[i]); @@ -101,7 +102,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { store_address_t storeId = message.getStorageId(); message.setStorageId(storeId); queue.addReceivedMessage(message); - REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK); CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkCallCount == 1); CHECK(queue.wasMessageSent()); @@ -109,10 +110,10 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { // The packet is forwarded, with no need to delete the data CHECK(pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() == storeId); auto accessor = pool.getData(storeId); - CHECK(accessor.first == result::OK); + CHECK(accessor.first == returnvalue::OK); CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { CHECK(accessor.second.data()[i] == buf[i]); @@ -126,13 +127,13 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { CcsdsDistributor::DestInfo info(defReceiverMock, true); tgtApid = defaultApid; tgtQueueId = defaultQueueId; - REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK); } SECTION("Specific destination") { CcsdsDistributor::DestInfo info(tcAcceptorMock, true); tgtApid = tcAcceptorApid; tgtQueueId = tcAcceptorQueueId; - REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK); } TmTcMessage message; std::array dataField = {0, 1, 2, 3, 4}; @@ -140,16 +141,16 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { store_address_t storeId = message.getStorageId(); message.setStorageId(storeId); queue.addReceivedMessage(message); - REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK); CHECK(checkerMock.checkedPacketLen == 11); CHECK(checkerMock.checkCallCount == 1); // Data was deleted from old slot to re-store without the header CHECK(not pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() != storeId); auto accessor = pool.getData(sentMsg.getStorageId()); - CHECK(accessor.first == result::OK); + CHECK(accessor.first == returnvalue::OK); CHECK(accessor.second.size() == 5); // Verify correctness of data field for (size_t i = 0; i < 5; i++) {